@registrucentras/rc-ses-react-components 1.10.0 → 1.12.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 (43) hide show
  1. package/README.md +5 -1
  2. package/dist/components/common/Badge/index.d.ts +10 -0
  3. package/dist/components/common/SelectableCardList/index.d.ts +1 -1
  4. package/dist/components/common/Switch/index.d.ts +10 -0
  5. package/dist/components/common/Tooltip/index.d.ts +20 -0
  6. package/dist/library/index.d.ts +5 -1
  7. package/dist/library/types.d.ts +2 -1
  8. package/dist/registrucentras-rc-ses-react-components.cjs +10 -10
  9. package/dist/registrucentras-rc-ses-react-components.js +3120 -2757
  10. package/dist/stories/components/display/Badge.stories.d.ts +9 -0
  11. package/dist/stories/components/display/SelectableCardList.stories.d.ts +8 -1
  12. package/dist/stories/components/display/Tooltip.stories.d.ts +48 -0
  13. package/dist/stories/components/inputs/Switch.stories.d.ts +17 -0
  14. package/dist/theme/light/MuiSwitch.d.ts +3 -0
  15. package/dist/theme/light/MuiTooltip.d.ts +3 -0
  16. package/package.json +1 -1
  17. package/src/components/common/Badge/index.test.tsx +129 -0
  18. package/src/components/common/Badge/index.tsx +162 -0
  19. package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +7 -5
  20. package/src/components/common/SelectableCardList/index.test.tsx +56 -2
  21. package/src/components/common/SelectableCardList/index.tsx +23 -10
  22. package/src/components/common/Switch/index.test.tsx +214 -0
  23. package/src/components/common/Switch/index.tsx +49 -0
  24. package/src/components/common/Tooltip/index.test.tsx +87 -0
  25. package/src/components/common/Tooltip/index.tsx +167 -0
  26. package/src/components/form/inputs/Select/index.test.tsx +102 -0
  27. package/src/components/form/inputs/Select/index.tsx +107 -53
  28. package/src/i18n/namespaces/common/en.json +3 -0
  29. package/src/i18n/namespaces/common/lt.json +3 -0
  30. package/src/i18n/namespaces/input/en.json +6 -0
  31. package/src/i18n/namespaces/input/lt.json +6 -0
  32. package/src/library/index.ts +6 -0
  33. package/src/library/types.ts +2 -0
  34. package/src/stories/components/display/Badge.stories.tsx +165 -0
  35. package/src/stories/components/display/SelectableCardList.stories.tsx +16 -0
  36. package/src/stories/components/display/Tooltip.stories.tsx +67 -0
  37. package/src/stories/components/inputs/Select.stories.tsx +38 -2
  38. package/src/stories/components/inputs/Switch.stories.tsx +70 -0
  39. package/src/theme/light/MuiAutocomplete.ts +3 -1
  40. package/src/theme/light/MuiInputBase.ts +4 -0
  41. package/src/theme/light/MuiSwitch.tsx +77 -0
  42. package/src/theme/light/MuiTooltip.ts +40 -0
  43. package/src/theme/light/index.tsx +4 -0
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { default as RcSesBadge } from '../../../components/common/Badge';
3
+ declare const meta: Meta<typeof RcSesBadge>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof RcSesBadge>;
6
+ export declare const Main: Story;
7
+ export declare const AllCombinations: Story;
8
+ export declare const LongLabel: Story;
9
+ export declare const BaselineAlignment: Story;
@@ -2,8 +2,15 @@ import { StoryObj } from '@storybook/react';
2
2
  import { SelectableCardListItemData, SelectableCardListProps } from '../../../components/common/SelectableCardList';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: ({ items, selectedId, onSelect, error, }: SelectableCardListProps) => import("react/jsx-runtime").JSX.Element;
5
+ component: (props: SelectableCardListProps) => import("react/jsx-runtime").JSX.Element;
6
6
  tags: string[];
7
+ parameters: {
8
+ docs: {
9
+ description: {
10
+ component: string;
11
+ };
12
+ };
13
+ };
7
14
  args: {
8
15
  items: SelectableCardListItemData[];
9
16
  selectedId: null;
@@ -0,0 +1,48 @@
1
+ import { default as RcSesTooltip } from '../../../components/common/Tooltip';
2
+ declare const meta: {
3
+ title: string;
4
+ component: typeof RcSesTooltip;
5
+ parameters: {
6
+ layout: string;
7
+ };
8
+ tags: string[];
9
+ argTypes: {
10
+ title: {
11
+ control: "text";
12
+ description: string;
13
+ };
14
+ placement: {
15
+ control: "select";
16
+ options: string[];
17
+ description: string;
18
+ };
19
+ slotProps: {
20
+ control: false;
21
+ description: string;
22
+ };
23
+ children: {
24
+ control: false;
25
+ description: string;
26
+ };
27
+ };
28
+ };
29
+ export default meta;
30
+ export declare const Default: {
31
+ readonly args: {
32
+ readonly title: "Deklaruojant išvykimą iš Lietuvos nurodoma užsienio valstybė, į kurią išvykstama.";
33
+ };
34
+ readonly render: (args: any) => import("react/jsx-runtime").JSX.Element;
35
+ };
36
+ export declare const CustomTrigger: {
37
+ readonly args: {
38
+ readonly title: "Papildoma informacija apie paslaugą.";
39
+ };
40
+ readonly render: (args: any) => import("react/jsx-runtime").JSX.Element;
41
+ readonly parameters: {
42
+ readonly docs: {
43
+ readonly source: {
44
+ readonly code: "<RcSesTooltip title=\"Papildoma informacija apie paslaugą.\">\n <Button variant=\"text\">Mygtukas</Button>\n</RcSesTooltip>";
45
+ };
46
+ };
47
+ };
48
+ };
@@ -0,0 +1,17 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as RcSesSwitch } from '../../../components/common/Switch';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof RcSesSwitch;
6
+ parameters: {
7
+ layout: string;
8
+ };
9
+ tags: string[];
10
+ };
11
+ export default meta;
12
+ type Story = StoryObj<typeof meta>;
13
+ export declare const On: Story;
14
+ export declare const Off: Story;
15
+ export declare const OnDisabled: Story;
16
+ export declare const OffDisabled: Story;
17
+ export declare const LongLabel: Story;
@@ -0,0 +1,3 @@
1
+ import { Components } from '@mui/material';
2
+ declare const MuiSwitch: Components['MuiSwitch'];
3
+ export default MuiSwitch;
@@ -0,0 +1,3 @@
1
+ import { Components } from '@mui/material';
2
+ declare const MuiTooltip: Components['MuiTooltip'];
3
+ export default MuiTooltip;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@registrucentras/rc-ses-react-components",
3
3
  "author": "VĮ REGISTRŲ CENTRAS",
4
- "version": "1.10.0",
4
+ "version": "1.12.0",
5
5
  "description": "RC SES React komponentų biblioteka",
6
6
  "type": "module",
7
7
  "private": false,
@@ -0,0 +1,129 @@
1
+ import { ThemeProvider } from '@mui/material/styles'
2
+ import { fireEvent, render, screen } from '@testing-library/react'
3
+ import { ReactElement } from 'react'
4
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
5
+
6
+ import i18n from '@/i18n/i18n'
7
+ import theme from '@/theme/light'
8
+
9
+ import RcSesBadge from './index'
10
+
11
+ const getCloseAriaLabel = (label: string) =>
12
+ i18n.t('components.RcSesBadge.aria.close', { label, ns: 'input' })
13
+
14
+ const renderBadge = (ui: ReactElement) =>
15
+ render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
16
+
17
+ describe('RcSesBadge', () => {
18
+ beforeEach(async () => {
19
+ await i18n.changeLanguage('lt')
20
+ })
21
+
22
+ it('renders the label', () => {
23
+ renderBadge(<RcSesBadge label='Dabartinė' variant='success' size='regular' />)
24
+
25
+ expect(screen.getByText('Dabartinė')).toBeInTheDocument()
26
+ })
27
+
28
+ it('sets the label as the title attribute for truncation tooltips', () => {
29
+ renderBadge(
30
+ <RcSesBadge label='Labai ilgas pavadinimas' variant='info' size='regular' />,
31
+ )
32
+
33
+ expect(screen.getByText('Labai ilgas pavadinimas')).toHaveAttribute(
34
+ 'title',
35
+ 'Labai ilgas pavadinimas',
36
+ )
37
+ })
38
+
39
+ it.each([
40
+ ['small', '1.625rem'],
41
+ ['regular', '2.125rem'],
42
+ ] as const)('renders the %s size', (size, expectedHeight) => {
43
+ const { container } = renderBadge(
44
+ <RcSesBadge label='Label' variant='neutral' size={size} />,
45
+ )
46
+
47
+ expect(container.firstChild).toHaveStyle({ height: expectedHeight })
48
+ })
49
+
50
+ it('shows the status icon by default', () => {
51
+ const { container } = renderBadge(
52
+ <RcSesBadge label='Label' variant='neutral' size='regular' />,
53
+ )
54
+
55
+ expect(container.querySelector('svg')).toBeInTheDocument()
56
+ })
57
+
58
+ it('hides the status icon when showIcon is false', () => {
59
+ const { container } = renderBadge(
60
+ <RcSesBadge label='Label' variant='neutral' size='regular' showIcon={false} />,
61
+ )
62
+
63
+ expect(container.querySelector('svg')).not.toBeInTheDocument()
64
+ })
65
+
66
+ it('does not render a close button by default', () => {
67
+ renderBadge(<RcSesBadge label='Label' variant='neutral' size='regular' />)
68
+
69
+ expect(screen.queryByRole('button')).not.toBeInTheDocument()
70
+ })
71
+
72
+ it('renders a close button with a translated aria-label when showClose is true', () => {
73
+ renderBadge(
74
+ <RcSesBadge
75
+ label='Dabartinė'
76
+ variant='neutral'
77
+ size='regular'
78
+ showClose
79
+ onClose={() => {}}
80
+ />,
81
+ )
82
+
83
+ expect(
84
+ screen.getByRole('button', { name: getCloseAriaLabel('Dabartinė') }),
85
+ ).toBeInTheDocument()
86
+ })
87
+
88
+ it('calls onClose when the close button is clicked', () => {
89
+ const handleClose = vi.fn()
90
+ renderBadge(
91
+ <RcSesBadge
92
+ label='Dabartinė'
93
+ variant='neutral'
94
+ size='regular'
95
+ showClose
96
+ onClose={handleClose}
97
+ />,
98
+ )
99
+
100
+ fireEvent.click(screen.getByRole('button', { name: getCloseAriaLabel('Dabartinė') }))
101
+
102
+ expect(handleClose).toHaveBeenCalledTimes(1)
103
+ })
104
+
105
+ it('renders in English when the language is changed', async () => {
106
+ await i18n.changeLanguage('en')
107
+ renderBadge(
108
+ <RcSesBadge
109
+ label='Current'
110
+ variant='neutral'
111
+ size='regular'
112
+ showClose
113
+ onClose={() => {}}
114
+ />,
115
+ )
116
+
117
+ expect(
118
+ screen.getByRole('button', { name: getCloseAriaLabel('Current') }),
119
+ ).toBeInTheDocument()
120
+ })
121
+
122
+ it('does not throw when the close button is clicked without an onClose handler', () => {
123
+ renderBadge(<RcSesBadge label='Label' variant='neutral' size='regular' showClose />)
124
+
125
+ expect(() =>
126
+ fireEvent.click(screen.getByRole('button', { name: getCloseAriaLabel('Label') })),
127
+ ).not.toThrow()
128
+ })
129
+ })
@@ -0,0 +1,162 @@
1
+ import { Box } from '@mui/material'
2
+ import { useTranslation } from 'react-i18next'
3
+
4
+ import CircleFilledIcon from '@/assets/icons/CircleFilledIcon'
5
+ import CloseIcon from '@/assets/icons/CloseIcon'
6
+ import { common, error, grey, primary, secondary, warning } from '@/theme/palette'
7
+
8
+ export type RcSesBadgeProps = {
9
+ label: string
10
+ variant: 'neutral' | 'success' | 'warning' | 'error' | 'info' | 'brand'
11
+ size: 'small' | 'regular'
12
+ showIcon?: boolean
13
+ showClose?: boolean
14
+ onClose?: () => void
15
+ }
16
+
17
+ type VariantStyle = {
18
+ border: string
19
+ background: string
20
+ iconColor: string
21
+ color: string
22
+ }
23
+
24
+ const variantStyles: Record<RcSesBadgeProps['variant'], VariantStyle> = {
25
+ neutral: {
26
+ border: grey['300'],
27
+ background: common.white,
28
+ iconColor: grey['900'],
29
+ color: grey['900'],
30
+ },
31
+ success: {
32
+ border: secondary['500'],
33
+ background: secondary['100'],
34
+ iconColor: secondary['600'],
35
+ color: secondary['800'],
36
+ },
37
+ warning: {
38
+ border: warning['400'],
39
+ background: warning['100'],
40
+ iconColor: warning['500'],
41
+ color: warning['800'],
42
+ },
43
+ error: {
44
+ border: error['500'],
45
+ background: error['100'],
46
+ iconColor: error['600'],
47
+ color: error['700'],
48
+ },
49
+ info: {
50
+ border: primary['400'],
51
+ background: primary['100'],
52
+ iconColor: primary['500'],
53
+ color: primary['800'],
54
+ },
55
+ brand: {
56
+ border: primary['500'],
57
+ background: primary['200'],
58
+ iconColor: primary['950'],
59
+ color: primary['950'],
60
+ },
61
+ }
62
+
63
+ type SizeStyle = {
64
+ height: string
65
+ padding: string
66
+ fontSize: string
67
+ lineHeight: string
68
+ }
69
+
70
+ const sizeStyles: Record<RcSesBadgeProps['size'], SizeStyle> = {
71
+ small: {
72
+ height: '1.625rem',
73
+ padding: '0.25rem 0.5rem',
74
+ fontSize: '0.8125rem',
75
+ lineHeight: '1.125rem',
76
+ },
77
+ regular: {
78
+ height: '2.125rem',
79
+ padding: '0.375rem 0.75rem',
80
+ fontSize: '0.9375rem',
81
+ lineHeight: '1.375rem',
82
+ },
83
+ }
84
+
85
+ function RcSesBadge(props: RcSesBadgeProps) {
86
+ const { label, variant, size, showIcon = true, showClose = false, onClose } = props
87
+ const { t } = useTranslation('input', { keyPrefix: 'components.RcSesBadge' })
88
+
89
+ const variantStyle = variantStyles[variant]
90
+ const sizeStyle = sizeStyles[size]
91
+
92
+ const baseStyle = {
93
+ display: 'inline-flex',
94
+ alignItems: 'center',
95
+ justifyContent: 'center',
96
+ verticalAlign: 'baseline',
97
+ gap: '0.25rem',
98
+ maxWidth: '100%',
99
+ borderRadius: '9999px',
100
+ border: `1px solid ${variantStyle.border}`,
101
+ background: variantStyle.background,
102
+ color: variantStyle.color,
103
+ ...sizeStyle,
104
+ }
105
+
106
+ return (
107
+ <Box sx={baseStyle}>
108
+ {showIcon && (
109
+ <CircleFilledIcon
110
+ size={14}
111
+ fillColor={variantStyle.iconColor}
112
+ aria-hidden
113
+ focusable={false}
114
+ style={{ flexShrink: 0 }}
115
+ />
116
+ )}
117
+ <Box
118
+ component='span'
119
+ title={label}
120
+ sx={{
121
+ overflow: 'hidden',
122
+ textOverflow: 'ellipsis',
123
+ whiteSpace: 'nowrap',
124
+ minWidth: 0,
125
+ }}
126
+ >
127
+ {label}
128
+ </Box>
129
+ {showClose && (
130
+ <Box
131
+ component='button'
132
+ type='button'
133
+ onClick={onClose}
134
+ aria-label={t('aria.close', { label })}
135
+ sx={{
136
+ display: 'inline-flex',
137
+ alignItems: 'center',
138
+ justifyContent: 'center',
139
+ flexShrink: 0,
140
+ minWidth: 16,
141
+ minHeight: 16,
142
+ padding: 0,
143
+ border: 'none',
144
+ background: 'none',
145
+ cursor: onClose ? 'pointer' : 'default',
146
+ opacity: 0.6,
147
+ '&:hover': { opacity: 1 },
148
+ }}
149
+ >
150
+ <CloseIcon
151
+ size={14}
152
+ fillColor={variantStyle.iconColor}
153
+ aria-hidden
154
+ focusable={false}
155
+ />
156
+ </Box>
157
+ )}
158
+ </Box>
159
+ )
160
+ }
161
+
162
+ export default RcSesBadge
@@ -21,14 +21,14 @@ const ListWithIconsItem = ({
21
21
  const content = (
22
22
  <Box
23
23
  sx={{
24
- display: 'inline-flex',
25
- alignItems: 'center',
24
+ display: 'flex',
25
+ alignItems: 'flex-start',
26
26
  gap: 0.5,
27
- maxWidth: { xs: '100%', md: 'none' },
27
+ maxWidth: '100%',
28
28
  }}
29
29
  >
30
30
  {Icon && (
31
- <Box sx={{ display: 'flex', alignItems: 'center' }}>
31
+ <Box sx={{ display: 'flex', alignItems: 'center', height: 20 }}>
32
32
  <Icon fillColor={textColor ?? palette.grey[600]} size={16} />
33
33
  </Box>
34
34
  )}
@@ -38,7 +38,8 @@ const ListWithIconsItem = ({
38
38
  fontSize: '14px',
39
39
  lineHeight: '20px',
40
40
  fontWeight: 300,
41
- whiteSpace: 'nowrap',
41
+ whiteSpace: 'normal',
42
+ wordBreak: 'break-word',
42
43
  color: textColor,
43
44
  }}
44
45
  >
@@ -81,6 +82,7 @@ const ListWithIconsItem = ({
81
82
  display: 'flex',
82
83
  alignItems: 'center',
83
84
  width: { xs: '100%', md: isLoading ? '120px' : 'auto' },
85
+ maxWidth: '100%',
84
86
  gap: 0.5,
85
87
  minHeight: 20,
86
88
  opacity: disabled ? 0.5 : 1,
@@ -41,7 +41,7 @@ describe('SelectableCardList', () => {
41
41
  expect(screen.queryByRole('radio')).not.toBeInTheDocument()
42
42
  })
43
43
 
44
- test('renders all items on the first page when count <= PAGE_SIZE', () => {
44
+ test('renders all items on the first page when count <= desktop page size', () => {
45
45
  renderList(<SelectableCardList items={makeItems(3)} onSelect={vi.fn()} />)
46
46
 
47
47
  expect(screen.getByText('Item 1')).toBeInTheDocument()
@@ -49,7 +49,7 @@ describe('SelectableCardList', () => {
49
49
  expect(screen.getByText('Item 3')).toBeInTheDocument()
50
50
  })
51
51
 
52
- test('shows only 5 items per page', () => {
52
+ test('shows only 5 items per page on desktop', () => {
53
53
  renderList(<SelectableCardList items={makeItems(8)} onSelect={vi.fn()} />)
54
54
 
55
55
  expect(screen.getByText('Item 1')).toBeInTheDocument()
@@ -68,6 +68,60 @@ describe('SelectableCardList', () => {
68
68
  expect(screen.queryByText('Item 1')).not.toBeInTheDocument()
69
69
  })
70
70
 
71
+ test('shows only 3 items per page on mobile, split across 3 pages', () => {
72
+ mockedUseMediaQuery.mockReturnValue(true)
73
+
74
+ renderList(<SelectableCardList items={makeItems(8)} onSelect={vi.fn()} />)
75
+
76
+ expect(screen.getByText('Item 1')).toBeInTheDocument()
77
+ expect(screen.getByText('Item 3')).toBeInTheDocument()
78
+ expect(screen.queryByText('Item 4')).not.toBeInTheDocument()
79
+ expect(screen.getByRole('button', { name: 'page 1' })).toBeInTheDocument()
80
+ expect(screen.getByRole('button', { name: 'Go to page 3' })).toBeInTheDocument()
81
+ expect(screen.queryByRole('button', { name: 'Go to page 4' })).not.toBeInTheDocument()
82
+ })
83
+
84
+ test('resets to page 1 when switching from desktop to mobile page size', () => {
85
+ const { rerender } = renderList(
86
+ <SelectableCardList items={makeItems(8)} onSelect={vi.fn()} />,
87
+ )
88
+
89
+ fireEvent.click(screen.getByRole('button', { name: 'Kitas' }))
90
+ expect(screen.getByText('Item 6')).toBeInTheDocument()
91
+
92
+ mockedUseMediaQuery.mockReturnValue(true)
93
+ rerender(
94
+ <ThemeProvider theme={theme}>
95
+ <SelectableCardList items={makeItems(8)} onSelect={vi.fn()} />
96
+ </ThemeProvider>,
97
+ )
98
+
99
+ expect(screen.getByText('Item 1')).toBeInTheDocument()
100
+ expect(screen.getByText('Item 3')).toBeInTheDocument()
101
+ expect(screen.queryByText('Item 4')).not.toBeInTheDocument()
102
+ })
103
+
104
+ test('resets to page 1 when switching from mobile to desktop page size', () => {
105
+ mockedUseMediaQuery.mockReturnValue(true)
106
+ const { rerender } = renderList(
107
+ <SelectableCardList items={makeItems(8)} onSelect={vi.fn()} />,
108
+ )
109
+
110
+ fireEvent.click(screen.getByRole('button', { name: 'Go to page 3' }))
111
+ expect(screen.getByText('Item 7')).toBeInTheDocument()
112
+
113
+ mockedUseMediaQuery.mockReturnValue(false)
114
+ rerender(
115
+ <ThemeProvider theme={theme}>
116
+ <SelectableCardList items={makeItems(8)} onSelect={vi.fn()} />
117
+ </ThemeProvider>,
118
+ )
119
+
120
+ expect(screen.getByText('Item 1')).toBeInTheDocument()
121
+ expect(screen.getByText('Item 5')).toBeInTheDocument()
122
+ expect(screen.queryByText('Item 6')).not.toBeInTheDocument()
123
+ })
124
+
71
125
  test('calls onSelect with the correct item id when a card is clicked', async () => {
72
126
  const onSelect = vi.fn()
73
127
 
@@ -1,4 +1,4 @@
1
- import { Box, Container } from '@mui/material'
1
+ import { Box, Container, useMediaQuery, useTheme } from '@mui/material'
2
2
  import { ReactNode, useMemo, useState } from 'react'
3
3
 
4
4
  import DataPagination from '../DataPagination'
@@ -18,29 +18,34 @@ export interface SelectableCardListProps {
18
18
  error?: ReactNode
19
19
  }
20
20
 
21
- const SKELETON_COUNT = 5
22
- const PAGE_SIZE = 5
23
- const SelectableCardList = ({
21
+ const MOBILE_PAGE_SIZE = 3
22
+ const DESKTOP_PAGE_SIZE = 5
23
+ type SelectableCardListPagedProps = SelectableCardListProps & {
24
+ pageSize: number
25
+ }
26
+
27
+ const SelectableCardListPaged = ({
24
28
  items,
25
29
  selectedId,
26
30
  onSelect,
27
31
  error,
28
- }: SelectableCardListProps) => {
32
+ pageSize,
33
+ }: SelectableCardListPagedProps) => {
29
34
  const [page, setPage] = useState(1)
30
35
 
31
- const totalPages = items ? Math.ceil(items.length / PAGE_SIZE) : 0
36
+ const totalPages = items ? Math.ceil(items.length / pageSize) : 0
32
37
  const currentPage = totalPages > 0 ? Math.min(page, totalPages) : 1
33
38
  const pagedItems = useMemo(() => {
34
39
  if (!items) {
35
40
  return []
36
41
  }
37
42
 
38
- const startIndex = (currentPage - 1) * PAGE_SIZE
39
- return items.slice(startIndex, startIndex + PAGE_SIZE)
40
- }, [currentPage, items])
43
+ const startIndex = (currentPage - 1) * pageSize
44
+ return items.slice(startIndex, startIndex + pageSize)
45
+ }, [currentPage, items, pageSize])
41
46
 
42
47
  const renderSkeletons = () =>
43
- Array.from({ length: SKELETON_COUNT }).map((_, i) => (
48
+ Array.from({ length: pageSize }).map((_, i) => (
44
49
  <SelectableCardListItem
45
50
  // eslint-disable-next-line react/no-array-index-key
46
51
  key={i}
@@ -96,4 +101,12 @@ const SelectableCardList = ({
96
101
  )
97
102
  }
98
103
 
104
+ const SelectableCardList = (props: SelectableCardListProps) => {
105
+ const theme = useTheme()
106
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'))
107
+ const pageSize = isMobile ? MOBILE_PAGE_SIZE : DESKTOP_PAGE_SIZE
108
+
109
+ return <SelectableCardListPaged key={pageSize} {...props} pageSize={pageSize} />
110
+ }
111
+
99
112
  export default SelectableCardList