@registrucentras/rc-ses-react-components 2.0.0-rc.3 → 2.0.0-rc.5

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 (80) hide show
  1. package/dist/assets/icons/ArrowRightIcon.d.ts +1 -1
  2. package/dist/assets/icons/WarningCircleIcon.d.ts +1 -1
  3. package/dist/components/common/Alert/index.d.ts +8 -2
  4. package/dist/components/common/CardShell/index.d.ts +1 -1
  5. package/dist/components/common/CardShell/types.d.ts +3 -1
  6. package/dist/components/common/IconWithSquareBackground/index.d.ts +12 -0
  7. package/dist/components/common/ServiceLinks/ServiceLinkItem/index.d.ts +15 -0
  8. package/dist/components/common/ServiceLinks/index.d.ts +3 -0
  9. package/dist/components/common/ServiceLinks/types.d.ts +34 -0
  10. package/dist/components/common/SideNav/SideNav.types.d.ts +20 -0
  11. package/dist/components/common/SideNav/SideNavLayout.d.ts +4 -0
  12. package/dist/components/common/SideNav/components/SideNavPill.d.ts +9 -0
  13. package/dist/components/common/SideNav/components/SideNavPillList.d.ts +9 -0
  14. package/dist/components/common/SideNav/components/SideNavRow.d.ts +9 -0
  15. package/dist/components/common/SideNav/hooks/useSideNavScrollSpy.d.ts +12 -0
  16. package/dist/components/common/SideNav/index.d.ts +4 -0
  17. package/dist/components/common/TitleBlock/index.d.ts +3 -0
  18. package/dist/components/common/TitleBlock/types.d.ts +73 -0
  19. package/dist/components/utils/normalizeSx.d.ts +4 -0
  20. package/dist/library/index.d.ts +8 -2
  21. package/dist/library/types.d.ts +6 -2
  22. package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
  23. package/dist/registrucentras-rc-ses-react-components.js +3489 -2703
  24. package/dist/stories/components/display/CardShell.stories.d.ts +1 -1
  25. package/dist/stories/components/display/SelectableCardList.stories.d.ts +1 -0
  26. package/dist/stories/components/display/ServiceLinks.stories.d.ts +28 -0
  27. package/dist/stories/components/display/TitleBlock.stories.d.ts +20 -0
  28. package/dist/stories/components/feedback/Alert.stories.d.ts +4 -0
  29. package/dist/stories/components/form/FormControlWrapper.stories.d.ts +1 -0
  30. package/dist/stories/components/icons/IconWithSquareBackground.stories.d.ts +7 -0
  31. package/dist/stories/components/navigation/SideNav.stories.d.ts +7 -0
  32. package/package.json +1 -1
  33. package/src/assets/icons/ArrowRightIcon.tsx +2 -1
  34. package/src/assets/icons/WarningCircleIcon.tsx +8 -2
  35. package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +8 -6
  36. package/src/components/common/Alert/index.test.tsx +157 -2
  37. package/src/components/common/Alert/index.tsx +144 -10
  38. package/src/components/common/Card/index.tsx +1 -23
  39. package/src/components/common/CardShell/index.tsx +4 -1
  40. package/src/components/common/CardShell/types.ts +3 -1
  41. package/src/components/common/IconWithSquareBackground/index.test.tsx +55 -0
  42. package/src/components/common/IconWithSquareBackground/index.tsx +83 -0
  43. package/src/components/common/ServiceLinks/ServiceLinkItem/index.tsx +177 -0
  44. package/src/components/common/ServiceLinks/index.test.tsx +166 -0
  45. package/src/components/common/ServiceLinks/index.tsx +66 -0
  46. package/src/components/common/ServiceLinks/types.ts +37 -0
  47. package/src/components/common/SideNav/SideNav.types.ts +24 -0
  48. package/src/components/common/SideNav/SideNavLayout.test.tsx +113 -0
  49. package/src/components/common/SideNav/SideNavLayout.tsx +67 -0
  50. package/src/components/common/SideNav/components/SideNavPill.tsx +62 -0
  51. package/src/components/common/SideNav/components/SideNavPillList.tsx +190 -0
  52. package/src/components/common/SideNav/components/SideNavRow.tsx +72 -0
  53. package/src/components/common/SideNav/hooks/useSideNavScrollSpy.test.ts +457 -0
  54. package/src/components/common/SideNav/hooks/useSideNavScrollSpy.ts +154 -0
  55. package/src/components/common/SideNav/index.test.tsx +99 -0
  56. package/src/components/common/SideNav/index.tsx +83 -0
  57. package/src/components/common/TitleBlock/index.test.tsx +366 -0
  58. package/src/components/common/TitleBlock/index.tsx +144 -0
  59. package/src/components/common/TitleBlock/types.ts +82 -0
  60. package/src/components/utils/normalizeSx.ts +24 -0
  61. package/src/i18n/namespaces/common/en.json +4 -0
  62. package/src/i18n/namespaces/common/lt.json +4 -0
  63. package/src/library/index.ts +8 -2
  64. package/src/library/types.ts +20 -8
  65. package/src/stories/components/display/CardShell.stories.tsx +14 -12
  66. package/src/stories/components/display/SelectableCardList.stories.tsx +33 -1
  67. package/src/stories/components/display/ServiceLinks.stories.tsx +154 -0
  68. package/src/stories/components/display/TitleBlock.stories.tsx +506 -0
  69. package/src/stories/components/feedback/Alert.stories.tsx +135 -4
  70. package/src/stories/components/form/FormControlWrapper.stories.tsx +23 -0
  71. package/src/stories/components/icons/IconWithSquareBackground.stories.tsx +60 -0
  72. package/src/stories/components/navigation/SideNav.stories.tsx +110 -0
  73. package/src/theme/cards.ts +1 -1
  74. package/src/theme/light/MuiAlert.tsx +28 -20
  75. package/src/theme/light/MuiButton.tsx +6 -0
  76. package/dist/components/common/CardShell/CardHeader/index.d.ts +0 -3
  77. package/dist/components/common/CardShell/CardHeader/types.d.ts +0 -33
  78. package/src/components/common/CardShell/CardHeader/index.test.tsx +0 -207
  79. package/src/components/common/CardShell/CardHeader/index.tsx +0 -104
  80. package/src/components/common/CardShell/CardHeader/types.ts +0 -36
@@ -33,3 +33,26 @@ export const Default: Story = {
33
33
  </RcSesFormControlWrapper>
34
34
  ),
35
35
  }
36
+
37
+ export const WithError: Story = {
38
+ args: {
39
+ label: 'Label',
40
+ hideLabel: false,
41
+ labelOnTop: false,
42
+ required: true,
43
+ errors: { type: 'required', message: 'This field is required' },
44
+ },
45
+ render: (args) => (
46
+ <RcSesFormControlWrapper {...args}>
47
+ <TextField id='input' placeholder='Type text here' size='small' fullWidth error />
48
+ </RcSesFormControlWrapper>
49
+ ),
50
+ parameters: {
51
+ docs: {
52
+ description: {
53
+ story:
54
+ 'Pass the react-hook-form `fieldState.error` as `errors` and the message renders below the field, leaving the field itself untouched. This is the validation pattern for any wrapped control, including ones that are not inputs - see `SelectableCardList` → `ValidationError`. When `errors.type` is `required` and no `message` is set, a translated fallback is shown instead.',
55
+ },
56
+ },
57
+ },
58
+ }
@@ -0,0 +1,60 @@
1
+ import { Stack, Typography } from '@mui/material'
2
+ import type { Meta, StoryObj } from '@storybook/react-vite'
3
+
4
+ import InfoFillIcon from '@/assets/icons/InfoFillIcon'
5
+ import RcSesIconWithSquareBackground from '@/components/common/IconWithSquareBackground'
6
+
7
+ const meta: Meta<typeof RcSesIconWithSquareBackground> = {
8
+ title: 'components/icons/IconWithSquareBackground',
9
+ component: RcSesIconWithSquareBackground,
10
+ tags: ['autodocs'],
11
+ argTypes: {
12
+ size: {
13
+ control: { type: 'select' },
14
+ options: [40, 44],
15
+ },
16
+ variant: {
17
+ control: { type: 'select' },
18
+ options: ['solid', 'soft', 'muted'],
19
+ },
20
+ },
21
+ }
22
+
23
+ export default meta
24
+ type Story = StoryObj<typeof meta>
25
+
26
+ export const Default: Story = {
27
+ args: {
28
+ Icon: InfoFillIcon,
29
+ size: 44,
30
+ variant: 'solid',
31
+ },
32
+ }
33
+
34
+ const SIZES = [40, 44] as const
35
+ const VARIANTS = ['solid', 'soft', 'muted'] as const
36
+
37
+ export const AllVariantsAndSizes: Story = {
38
+ parameters: { controls: { disable: true } },
39
+ render: () => (
40
+ <Stack spacing={3}>
41
+ {SIZES.map((size) => (
42
+ <Stack key={size} spacing={1}>
43
+ <Typography variant='caption'>size: {size}</Typography>
44
+ <Stack direction='row' spacing={2} sx={{ alignItems: 'center' }}>
45
+ {VARIANTS.map((variant) => (
46
+ <Stack key={variant} spacing={0.5} sx={{ alignItems: 'center' }}>
47
+ <RcSesIconWithSquareBackground
48
+ Icon={InfoFillIcon}
49
+ size={size}
50
+ variant={variant}
51
+ />
52
+ <Typography variant='caption'>{variant}</Typography>
53
+ </Stack>
54
+ ))}
55
+ </Stack>
56
+ </Stack>
57
+ ))}
58
+ </Stack>
59
+ ),
60
+ }
@@ -0,0 +1,110 @@
1
+ import { Box, Typography } from '@mui/material'
2
+ import { Meta, StoryObj } from '@storybook/react-vite'
3
+ import { useState } from 'react'
4
+
5
+ import { RcSesSideNavItem } from '@/components/common/SideNav/SideNav.types'
6
+ import RcSesSideNavLayout from '@/components/common/SideNav/SideNavLayout'
7
+ import FieldView from '@/components/storybook/FieldView'
8
+
9
+ const ITEMS: RcSesSideNavItem[] = [
10
+ { id: 'family', label: 'Aš ir mano šeima', count: 4 },
11
+ { id: 'documents', label: 'Dokumentai apie gyventoją', count: 2 },
12
+ { id: 'signature', label: 'Elektroninis parašas', count: 1 },
13
+ { id: 'residence', label: 'Gyvenamosios vietos deklaravimas', count: 7 },
14
+ { id: 'authorizations', label: 'Įgaliojimai', count: 6 },
15
+ { id: 'marriage', label: 'Santuoka ir skyrybos', count: 7 },
16
+ ]
17
+
18
+ const SECTION_HEIGHT = 320
19
+
20
+ function Sections() {
21
+ return (
22
+ <>
23
+ {ITEMS.map((item) => (
24
+ <Box
25
+ key={item.id}
26
+ id={item.id}
27
+ sx={{
28
+ height: `${SECTION_HEIGHT}px`,
29
+ borderBottom: '1px dashed #dce0e5',
30
+ paddingTop: '1rem',
31
+ }}
32
+ >
33
+ <Typography variant='h3' sx={{ fontSize: '1.25rem', fontWeight: 600 }}>
34
+ {item.label}
35
+ </Typography>
36
+ <Typography sx={{ color: '#6b747f' }}>
37
+ {item.count} paslaugos šioje temoje.
38
+ </Typography>
39
+ </Box>
40
+ ))}
41
+ </>
42
+ )
43
+ }
44
+
45
+ const meta: Meta<typeof RcSesSideNavLayout> = {
46
+ title: 'components/navigation/SideNav',
47
+ component: RcSesSideNavLayout,
48
+ tags: ['autodocs'],
49
+ parameters: {
50
+ docs: {
51
+ description: {
52
+ component:
53
+ 'RcSesSideNavLayout is the only supported way to use this component - it lays out the sticky nav column (a topic list on desktop, a horizontally scrollable pill bar on mobile) alongside its section children, which is what guarantees the desktop sticky behavior works. By default (no `activeItemId`) it tracks scroll position itself and scrolls the page on click - pass `activeItemId`/`onItemClick` to take full control instead. See `WithScrollSpy` for the default, self-contained behavior; `Main` demonstrates the fully-controlled mode, which is why it wires the state itself.',
54
+ },
55
+ },
56
+ },
57
+ }
58
+
59
+ export default meta
60
+
61
+ type Story = StoryObj<typeof RcSesSideNavLayout>
62
+
63
+ function ControlledDemo({
64
+ activeItemId: initialActiveItemId,
65
+ ...args
66
+ }: React.ComponentProps<typeof RcSesSideNavLayout>) {
67
+ const [activeItemId, setActiveItemId] = useState(initialActiveItemId ?? ITEMS[0].id)
68
+
69
+ return (
70
+ <RcSesSideNavLayout
71
+ {...args}
72
+ activeItemId={activeItemId}
73
+ onItemClick={setActiveItemId}
74
+ />
75
+ )
76
+ }
77
+
78
+ export const Main: Story = {
79
+ render: (args) => (
80
+ <FieldView>
81
+ <ControlledDemo {...args}>
82
+ <Sections />
83
+ </ControlledDemo>
84
+ </FieldView>
85
+ ),
86
+ args: {
87
+ items: ITEMS,
88
+ title: 'Temos',
89
+ },
90
+ }
91
+
92
+ export const WithScrollSpy: Story = {
93
+ render: () => (
94
+ <FieldView>
95
+ {/* The real page scrolls the window (as in the confirmed design), so this demo
96
+ does too, rather than nesting its own scroll container. */}
97
+ <RcSesSideNavLayout items={ITEMS} title='Temos'>
98
+ <Sections />
99
+ </RcSesSideNavLayout>
100
+ </FieldView>
101
+ ),
102
+ parameters: {
103
+ docs: {
104
+ description: {
105
+ story:
106
+ 'The default, uncontrolled mode: no `activeItemId`/`onItemClick` passed, so the nav tracks scroll position itself and scrolls to a section when its topic is clicked.',
107
+ },
108
+ },
109
+ },
110
+ }
@@ -12,7 +12,7 @@ const borderWidth = '1px'
12
12
  const card = {
13
13
  borderRadius: '0.75rem',
14
14
  gap: { xs: '1rem', md: '1.5rem' },
15
- padding: { xs: '1.25rem 1.5rem 1.5rem', md: '1.5rem 2rem 2rem' },
15
+ padding: { xs: '1.25rem 1.5rem', md: '1.5rem 2rem' },
16
16
  }
17
17
 
18
18
  const subcard = {
@@ -3,8 +3,7 @@ import { Components, createTheme } from '@mui/material'
3
3
  import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
4
4
  import CloseIcon from '@/assets/icons/CloseIcon'
5
5
  import InfoFillIcon from '@/assets/icons/InfoFillIcon'
6
- import ScrollIcon from '@/assets/icons/ScrollIcon'
7
- import WarningDiamondFillIcon from '@/assets/icons/WarningDiamondFillIcon'
6
+ import WarningCircleIcon from '@/assets/icons/WarningCircleIcon'
8
7
  import WarningFillIcon from '@/assets/icons/WarningFillIcon'
9
8
 
10
9
  import palette from '../palette'
@@ -15,11 +14,11 @@ const MuiAlert: Components['MuiAlert'] = {
15
14
  defaultProps: {
16
15
  elevation: 0,
17
16
  iconMapping: {
18
- grey: <InfoFillIcon />,
19
- error: <WarningDiamondFillIcon />,
20
- info: <ScrollIcon />,
21
- success: <CheckCircleFillIcon />,
22
- warning: <WarningFillIcon />,
17
+ grey: <InfoFillIcon weight='regular' aria-hidden />,
18
+ error: <WarningCircleIcon weight='regular' aria-hidden />,
19
+ info: <InfoFillIcon weight='regular' aria-hidden />,
20
+ success: <CheckCircleFillIcon weight='regular' aria-hidden />,
21
+ warning: <WarningFillIcon weight='regular' aria-hidden />,
23
22
  },
24
23
  slots: {
25
24
  closeIcon: CloseIcon,
@@ -69,13 +68,13 @@ const MuiAlert: Components['MuiAlert'] = {
69
68
  paddingTop: 0,
70
69
 
71
70
  [breakpoints.up('sm')]: {
72
- alignSelf: 'center',
73
71
  marginRight: '.75rem',
74
72
  },
75
73
  },
76
74
 
77
75
  message: {
78
76
  flexGrow: 1,
77
+ minWidth: 0,
79
78
  overflowY: 'hidden',
80
79
 
81
80
  [breakpoints.down('sm')]: {
@@ -194,53 +193,62 @@ const MuiAlert: Components['MuiAlert'] = {
194
193
  outlined: {
195
194
  fontSize: '.8125rem',
196
195
  fontWeight: 400,
196
+ flexWrap: 'nowrap',
197
+ alignItems: 'center',
198
+ gap: '.75rem',
199
+ padding: '.75rem 1rem',
200
+ borderRadius: '0.5rem',
197
201
 
198
202
  [breakpoints.up('md')]: {
199
203
  fontSize: '.875rem',
200
204
  },
201
205
 
206
+ '.MuiAlert-icon': {
207
+ alignSelf: 'flex-start',
208
+ margin: 0,
209
+ padding: 0,
210
+ },
211
+
202
212
  '.MuiAlert-message': {
203
213
  lineHeight: '1rem',
204
214
  padding: 0,
205
215
 
206
- [breakpoints.up('sm')]: {
216
+ [breakpoints.up('md')]: {
207
217
  lineHeight: '1.25rem',
208
- padding: '.125rem 0',
209
218
  },
210
219
 
211
220
  a: {
212
221
  fontWeight: 600,
213
222
  },
214
223
  },
215
-
216
224
  // Was outlined<Severity>; see the note on standard above.
217
225
  '&.MuiAlert-colorGrey': {
218
226
  backgroundColor: palette.grey['50'],
219
- borderColor: palette.grey['200'],
227
+ border: `1px solid ${palette.grey['200']}`,
220
228
 
221
229
  '.MuiAlert-icon': {
222
230
  color: palette.grey['600'],
223
231
  },
224
232
  },
225
233
  '&.MuiAlert-colorError': {
226
- backgroundColor: palette.error['50'],
227
- borderColor: palette.error['200'],
234
+ backgroundColor: palette.error['100'],
235
+ border: `1px solid ${palette.error['500']}`,
228
236
 
229
237
  '.MuiAlert-icon': {
230
238
  color: palette.error['600'],
231
239
  },
232
240
  },
233
241
  '&.MuiAlert-colorInfo': {
234
- backgroundColor: palette.primary['50'],
235
- borderColor: palette.primary['300'],
242
+ backgroundColor: palette.primary['100'],
243
+ border: `1px solid ${palette.primary['400']}`,
236
244
 
237
245
  '.MuiAlert-icon': {
238
- color: palette.primary['500'],
246
+ color: palette.primary['600'],
239
247
  },
240
248
  },
241
249
  '&.MuiAlert-colorSuccess': {
242
250
  backgroundColor: palette.secondary['100'],
243
- borderColor: palette.secondary['300'],
251
+ border: `1px solid ${palette.secondary['500']}`,
244
252
 
245
253
  '.MuiAlert-icon': {
246
254
  color: palette.secondary['600'],
@@ -248,10 +256,10 @@ const MuiAlert: Components['MuiAlert'] = {
248
256
  },
249
257
  '&.MuiAlert-colorWarning': {
250
258
  backgroundColor: palette.warning['100'],
251
- borderColor: palette.warning['300'],
259
+ border: `1px solid ${palette.warning['400']}`,
252
260
 
253
261
  '.MuiAlert-icon': {
254
- color: palette.warning['600'],
262
+ color: palette.warning['500'],
255
263
  },
256
264
  },
257
265
  },
@@ -21,6 +21,12 @@ const MuiButton: Components['MuiButton'] = {
21
21
  fontSize: '.875rem',
22
22
  fontWeight: 600,
23
23
  height: '2.375rem',
24
+ // Link buttons are typographic elements — they sit flush with the
25
+ // surrounding text, not with contained/outlined button hit-area
26
+ // padding. sizeSmall/sizeLarge already opt out of the root horizontal
27
+ // padding; the default (medium) needs the same treatment so a
28
+ // any link lines up under a heading, not 20px indented.
29
+ padding: '.8125rem 0',
24
30
 
25
31
  '&.Mui-disabled': {
26
32
  opacity: 0.4,
@@ -1,3 +0,0 @@
1
- import { RcSesCardHeaderProps } from './types';
2
- declare function RcSesCardHeader({ title, headingLevel, icon, count, description, actions, className, testIds, }: RcSesCardHeaderProps): import("react").JSX.Element;
3
- export default RcSesCardHeader;
@@ -1,33 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export type CardHeadingLevel = 2 | 3 | 4 | 5 | 6;
3
- export type RcSesCardHeaderTestIds = {
4
- root?: string;
5
- icon?: string;
6
- heading?: string;
7
- badge?: string;
8
- description?: string;
9
- actions?: string;
10
- };
11
- export type RcSesCardHeaderProps = {
12
- title: ReactNode;
13
- headingLevel?: CardHeadingLevel;
14
- /**
15
- * Decorative leading visual, `Icon-tile` once SAV-6476 lands. Rendered
16
- * `aria-hidden`, so it never contributes to the heading's accessible name.
17
- */
18
- icon?: ReactNode;
19
- /**
20
- * Count rendered as a Neutral/Small `Badge` inside the heading, so it is
21
- * announced together with the title. Intended for short section headings.
22
- */
23
- count?: number;
24
- description?: ReactNode;
25
- /**
26
- * Up to two CTAs, rendered at the end of the header row. A trailing
27
- * affordance such as the Category-tile chevron is not a CTA and will need its
28
- * own slot.
29
- */
30
- actions?: ReactNode;
31
- className?: string;
32
- testIds?: RcSesCardHeaderTestIds;
33
- };
@@ -1,207 +0,0 @@
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 RcSesCardHeader from '.'
10
-
11
- const renderCardHeader = (ui: ReactElement) =>
12
- render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
13
-
14
- describe('RcSesCardHeader', () => {
15
- test('renders title and description', () => {
16
- renderCardHeader(
17
- <RcSesCardHeader title='Test Title' description='Test description' />,
18
- )
19
-
20
- expect(
21
- screen.getByRole('heading', { level: 3, name: 'Test Title' }),
22
- ).toBeInTheDocument()
23
- expect(screen.getByText('Test description')).toBeInTheDocument()
24
- })
25
-
26
- test('uses default heading level 3 when not provided', () => {
27
- renderCardHeader(<RcSesCardHeader title='Test Title' />)
28
-
29
- expect(screen.getByRole('heading', { level: 3 })).toBeInTheDocument()
30
- })
31
-
32
- test('respects custom headingLevel prop', () => {
33
- renderCardHeader(<RcSesCardHeader title='Test Title' headingLevel={2} />)
34
-
35
- expect(
36
- screen.getByRole('heading', { level: 2, name: 'Test Title' }),
37
- ).toBeInTheDocument()
38
- })
39
-
40
- test('omits description when not provided', () => {
41
- renderCardHeader(
42
- <RcSesCardHeader title='Test Title' testIds={{ description: 'description' }} />,
43
- )
44
-
45
- expect(screen.queryByTestId('description')).not.toBeInTheDocument()
46
- })
47
-
48
- test('applies testIds correctly', () => {
49
- renderCardHeader(
50
- <RcSesCardHeader
51
- description='Test description'
52
- testIds={{
53
- root: 'header-root',
54
- heading: 'header-heading',
55
- description: 'header-desc',
56
- }}
57
- title='Test Title'
58
- />,
59
- )
60
-
61
- expect(screen.getByTestId('header-root')).toBeInTheDocument()
62
- expect(screen.getByTestId('header-heading')).toBeInTheDocument()
63
- expect(screen.getByTestId('header-desc')).toBeInTheDocument()
64
- })
65
-
66
- test('handles ReactNode as title', () => {
67
- renderCardHeader(
68
- <RcSesCardHeader
69
- title={
70
- <span>
71
- Complex <strong>Title</strong>
72
- </span>
73
- }
74
- />,
75
- )
76
-
77
- expect(screen.getByRole('heading', { level: 3 })).toBeInTheDocument()
78
- expect(screen.getByText('Complex')).toBeInTheDocument()
79
- expect(screen.getByText('Title')).toBeInTheDocument()
80
- })
81
-
82
- test('handles ReactNode as description', () => {
83
- renderCardHeader(
84
- <RcSesCardHeader
85
- description={
86
- <span>
87
- Description with <em>emphasis</em>
88
- </span>
89
- }
90
- title='Test Title'
91
- />,
92
- )
93
-
94
- expect(screen.getByText('Description with')).toBeInTheDocument()
95
- expect(screen.getByText('emphasis')).toBeInTheDocument()
96
- })
97
-
98
- test('heading levels 2 through 6 render correctly', () => {
99
- const levels = [2, 3, 4, 5, 6] as const
100
-
101
- levels.forEach((level) => {
102
- const { unmount } = renderCardHeader(
103
- <RcSesCardHeader headingLevel={level} title={`Level ${level} Title`} />,
104
- )
105
-
106
- expect(
107
- screen.getByRole('heading', { level, name: `Level ${level} Title` }),
108
- ).toBeInTheDocument()
109
- unmount()
110
- })
111
- })
112
-
113
- test('title and description keep the design type ramp', () => {
114
- renderCardHeader(
115
- <RcSesCardHeader
116
- description='Test description'
117
- testIds={{ description: 'description' }}
118
- title='Test Title'
119
- />,
120
- )
121
-
122
- expect(screen.getByText('Test Title')).toHaveStyle({
123
- fontSize: '1.125rem',
124
- fontWeight: '600',
125
- lineHeight: '1.5rem',
126
- })
127
- expect(screen.getByTestId('description')).toHaveStyle({
128
- fontSize: '0.875rem',
129
- lineHeight: '1.25rem',
130
- })
131
- })
132
-
133
- test('count renders a badge inside the heading accessible name', () => {
134
- renderCardHeader(<RcSesCardHeader count={4} title='Pasirinktos teisės' />)
135
-
136
- expect(
137
- screen.getByRole('heading', { level: 3, name: 'Pasirinktos teisės 4' }),
138
- ).toBeInTheDocument()
139
- })
140
-
141
- test('count of zero still renders the badge', () => {
142
- renderCardHeader(
143
- <RcSesCardHeader
144
- count={0}
145
- testIds={{ badge: 'badge' }}
146
- title='Pasirinktos teisės'
147
- />,
148
- )
149
-
150
- expect(screen.getByTestId('badge')).toHaveTextContent('0')
151
- })
152
-
153
- test('omits the badge when count is not provided', () => {
154
- renderCardHeader(<RcSesCardHeader testIds={{ badge: 'badge' }} title='Test Title' />)
155
-
156
- expect(screen.queryByTestId('badge')).not.toBeInTheDocument()
157
- expect(
158
- screen.getByRole('heading', { level: 3, name: 'Test Title' }),
159
- ).toBeInTheDocument()
160
- })
161
-
162
- test('icon is decorative and stays out of the accessible name', () => {
163
- renderCardHeader(
164
- <RcSesCardHeader
165
- icon={<span>dekoracija</span>}
166
- testIds={{ icon: 'icon' }}
167
- title='Test Title'
168
- />,
169
- )
170
-
171
- expect(screen.getByTestId('icon')).toHaveAttribute('aria-hidden', 'true')
172
- expect(
173
- screen.getByRole('heading', { level: 3, name: 'Test Title' }),
174
- ).toBeInTheDocument()
175
- })
176
-
177
- test('renders up to two actions at the end of the row', () => {
178
- renderCardHeader(
179
- <RcSesCardHeader
180
- actions={
181
- <>
182
- <button type='button'>Atšaukti</button>
183
- <button type='button'>Tęsti</button>
184
- </>
185
- }
186
- testIds={{ actions: 'actions' }}
187
- title='Test Title'
188
- />,
189
- )
190
-
191
- const actions = screen.getByTestId('actions')
192
- expect(actions).toContainElement(screen.getByRole('button', { name: 'Atšaukti' }))
193
- expect(actions).toContainElement(screen.getByRole('button', { name: 'Tęsti' }))
194
- })
195
-
196
- test('omits the icon and actions slots when not provided', () => {
197
- renderCardHeader(
198
- <RcSesCardHeader
199
- testIds={{ actions: 'actions', icon: 'icon' }}
200
- title='Test Title'
201
- />,
202
- )
203
-
204
- expect(screen.queryByTestId('icon')).not.toBeInTheDocument()
205
- expect(screen.queryByTestId('actions')).not.toBeInTheDocument()
206
- })
207
- })