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

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 (72) hide show
  1. package/dist/assets/icons/ArrowRightIcon.d.ts +1 -1
  2. package/dist/components/common/CardShell/index.d.ts +1 -1
  3. package/dist/components/common/CardShell/types.d.ts +3 -1
  4. package/dist/components/common/IconWithSquareBackground/index.d.ts +12 -0
  5. package/dist/components/common/ServiceLinks/ServiceLinkItem/index.d.ts +15 -0
  6. package/dist/components/common/ServiceLinks/index.d.ts +3 -0
  7. package/dist/components/common/ServiceLinks/types.d.ts +34 -0
  8. package/dist/components/common/SideNav/SideNav.types.d.ts +20 -0
  9. package/dist/components/common/SideNav/SideNavLayout.d.ts +4 -0
  10. package/dist/components/common/SideNav/components/SideNavPill.d.ts +9 -0
  11. package/dist/components/common/SideNav/components/SideNavPillList.d.ts +9 -0
  12. package/dist/components/common/SideNav/components/SideNavRow.d.ts +9 -0
  13. package/dist/components/common/SideNav/hooks/useSideNavScrollSpy.d.ts +12 -0
  14. package/dist/components/common/SideNav/index.d.ts +4 -0
  15. package/dist/components/common/TitleBlock/index.d.ts +3 -0
  16. package/dist/components/common/TitleBlock/types.d.ts +73 -0
  17. package/dist/components/utils/normalizeSx.d.ts +4 -0
  18. package/dist/library/index.d.ts +8 -2
  19. package/dist/library/types.d.ts +6 -2
  20. package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
  21. package/dist/registrucentras-rc-ses-react-components.js +3412 -2728
  22. package/dist/stories/components/display/CardShell.stories.d.ts +1 -1
  23. package/dist/stories/components/display/SelectableCardList.stories.d.ts +1 -0
  24. package/dist/stories/components/display/ServiceLinks.stories.d.ts +28 -0
  25. package/dist/stories/components/display/TitleBlock.stories.d.ts +20 -0
  26. package/dist/stories/components/form/FormControlWrapper.stories.d.ts +1 -0
  27. package/dist/stories/components/icons/IconWithSquareBackground.stories.d.ts +7 -0
  28. package/dist/stories/components/navigation/SideNav.stories.d.ts +7 -0
  29. package/package.json +1 -1
  30. package/src/assets/icons/ArrowRightIcon.tsx +2 -1
  31. package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +8 -6
  32. package/src/components/common/Card/index.tsx +1 -23
  33. package/src/components/common/CardShell/index.tsx +4 -1
  34. package/src/components/common/CardShell/types.ts +3 -1
  35. package/src/components/common/IconWithSquareBackground/index.test.tsx +55 -0
  36. package/src/components/common/IconWithSquareBackground/index.tsx +83 -0
  37. package/src/components/common/ServiceLinks/ServiceLinkItem/index.tsx +177 -0
  38. package/src/components/common/ServiceLinks/index.test.tsx +166 -0
  39. package/src/components/common/ServiceLinks/index.tsx +66 -0
  40. package/src/components/common/ServiceLinks/types.ts +37 -0
  41. package/src/components/common/SideNav/SideNav.types.ts +24 -0
  42. package/src/components/common/SideNav/SideNavLayout.test.tsx +113 -0
  43. package/src/components/common/SideNav/SideNavLayout.tsx +67 -0
  44. package/src/components/common/SideNav/components/SideNavPill.tsx +62 -0
  45. package/src/components/common/SideNav/components/SideNavPillList.tsx +190 -0
  46. package/src/components/common/SideNav/components/SideNavRow.tsx +72 -0
  47. package/src/components/common/SideNav/hooks/useSideNavScrollSpy.test.ts +457 -0
  48. package/src/components/common/SideNav/hooks/useSideNavScrollSpy.ts +154 -0
  49. package/src/components/common/SideNav/index.test.tsx +99 -0
  50. package/src/components/common/SideNav/index.tsx +83 -0
  51. package/src/components/common/TitleBlock/index.test.tsx +366 -0
  52. package/src/components/common/TitleBlock/index.tsx +144 -0
  53. package/src/components/common/TitleBlock/types.ts +82 -0
  54. package/src/components/utils/normalizeSx.ts +24 -0
  55. package/src/i18n/namespaces/common/en.json +4 -0
  56. package/src/i18n/namespaces/common/lt.json +4 -0
  57. package/src/library/index.ts +8 -2
  58. package/src/library/types.ts +20 -8
  59. package/src/stories/components/display/CardShell.stories.tsx +14 -12
  60. package/src/stories/components/display/SelectableCardList.stories.tsx +33 -1
  61. package/src/stories/components/display/ServiceLinks.stories.tsx +154 -0
  62. package/src/stories/components/display/TitleBlock.stories.tsx +506 -0
  63. package/src/stories/components/form/FormControlWrapper.stories.tsx +23 -0
  64. package/src/stories/components/icons/IconWithSquareBackground.stories.tsx +60 -0
  65. package/src/stories/components/navigation/SideNav.stories.tsx +110 -0
  66. package/src/theme/cards.ts +1 -1
  67. package/src/theme/light/MuiButton.tsx +6 -0
  68. package/dist/components/common/CardShell/CardHeader/index.d.ts +0 -3
  69. package/dist/components/common/CardShell/CardHeader/types.d.ts +0 -33
  70. package/src/components/common/CardShell/CardHeader/index.test.tsx +0 -207
  71. package/src/components/common/CardShell/CardHeader/index.tsx +0 -104
  72. package/src/components/common/CardShell/CardHeader/types.ts +0 -36
@@ -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 = {
@@ -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
- })
@@ -1,104 +0,0 @@
1
- import { Box, Stack, Typography } from '@mui/material'
2
-
3
- import RcSesBadge from '@/components/common/Badge'
4
- import cards from '@/theme/cards'
5
- import palette from '@/theme/palette'
6
-
7
- import { RcSesCardHeaderProps } from './types'
8
-
9
- function RcSesCardHeader({
10
- title,
11
- headingLevel = 3,
12
- icon,
13
- count,
14
- description,
15
- actions,
16
- className,
17
- testIds,
18
- }: RcSesCardHeaderProps) {
19
- const HeadingTag = `h${headingLevel}` as 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
20
- const hasCount = count !== undefined && count !== null
21
-
22
- return (
23
- <Stack
24
- className={className}
25
- data-testid={testIds?.root}
26
- direction='row'
27
- spacing={cards.header.rowGap}
28
- sx={{ alignItems: 'flex-start', width: '100%' }}
29
- >
30
- {icon ? (
31
- <Box
32
- aria-hidden
33
- data-testid={testIds?.icon}
34
- sx={{ display: 'flex', flexShrink: 0 }}
35
- >
36
- {icon}
37
- </Box>
38
- ) : null}
39
-
40
- <Stack spacing={cards.header.gap} sx={{ flex: 1, minWidth: 0 }}>
41
- <HeadingTag data-testid={testIds?.heading} style={{ margin: 0 }}>
42
- <Typography
43
- component='span'
44
- variant='h6'
45
- sx={{
46
- color: palette.grey[900],
47
- // inline only when the badge has to sit on the heading's last line
48
- display: hasCount ? 'inline' : 'block',
49
- fontWeight: cards.header.titleFontWeight,
50
- overflowWrap: 'anywhere',
51
- }}
52
- >
53
- {title}
54
- </Typography>
55
-
56
- {hasCount ? (
57
- <Box
58
- component='span'
59
- data-testid={testIds?.badge}
60
- sx={{
61
- display: 'inline-flex',
62
- ml: cards.header.badgeGap,
63
- verticalAlign: 'middle',
64
- }}
65
- >
66
- <RcSesBadge
67
- label={String(count)}
68
- showIcon={false}
69
- size='small'
70
- variant='neutral'
71
- />
72
- </Box>
73
- ) : null}
74
- </HeadingTag>
75
-
76
- {description !== undefined && description !== null ? (
77
- <Typography
78
- data-testid={testIds?.description}
79
- variant='body2'
80
- sx={{
81
- color: palette.grey[700],
82
- lineHeight: cards.header.descriptionLineHeight,
83
- }}
84
- >
85
- {description}
86
- </Typography>
87
- ) : null}
88
- </Stack>
89
-
90
- {actions ? (
91
- <Stack
92
- data-testid={testIds?.actions}
93
- direction='row'
94
- spacing={cards.header.actionsGap}
95
- sx={{ alignItems: 'center', flexShrink: 0 }}
96
- >
97
- {actions}
98
- </Stack>
99
- ) : null}
100
- </Stack>
101
- )
102
- }
103
-
104
- export default RcSesCardHeader
@@ -1,36 +0,0 @@
1
- import { ReactNode } from 'react'
2
-
3
- export type CardHeadingLevel = 2 | 3 | 4 | 5 | 6
4
-
5
- export type RcSesCardHeaderTestIds = {
6
- root?: string
7
- icon?: string
8
- heading?: string
9
- badge?: string
10
- description?: string
11
- actions?: string
12
- }
13
-
14
- export type RcSesCardHeaderProps = {
15
- title: ReactNode
16
- headingLevel?: CardHeadingLevel
17
- /**
18
- * Decorative leading visual, `Icon-tile` once SAV-6476 lands. Rendered
19
- * `aria-hidden`, so it never contributes to the heading's accessible name.
20
- */
21
- icon?: ReactNode
22
- /**
23
- * Count rendered as a Neutral/Small `Badge` inside the heading, so it is
24
- * announced together with the title. Intended for short section headings.
25
- */
26
- count?: number
27
- description?: ReactNode
28
- /**
29
- * Up to two CTAs, rendered at the end of the header row. A trailing
30
- * affordance such as the Category-tile chevron is not a CTA and will need its
31
- * own slot.
32
- */
33
- actions?: ReactNode
34
- className?: string
35
- testIds?: RcSesCardHeaderTestIds
36
- }