@registrucentras/rc-ses-react-components 2.0.0-rc.7 → 2.0.0-rc.9

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 (203) hide show
  1. package/dist/components/common/Accordion/hooks/useAccordionController.d.ts +2 -2
  2. package/dist/components/common/Accordion/types/AccordionControllerState.d.ts +2 -2
  3. package/dist/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.d.ts +2 -2
  4. package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.d.ts +2 -2
  5. package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.d.ts +2 -2
  6. package/dist/components/common/Badge/index.d.ts +2 -2
  7. package/dist/components/common/Breadcrumbs/index.d.ts +4 -4
  8. package/dist/components/common/Card/index.d.ts +2 -2
  9. package/dist/components/common/CardShell/CardFooter/index.d.ts +1 -1
  10. package/dist/components/common/CardShell/CardFooter/types.d.ts +4 -9
  11. package/dist/components/common/CardShell/types.d.ts +4 -4
  12. package/dist/components/common/IconWithCircularBackground.d.ts +2 -2
  13. package/dist/components/common/IconWithSquareBackground/index.d.ts +2 -2
  14. package/dist/components/common/ImageCard/index.d.ts +2 -2
  15. package/dist/components/common/SelectableCardList/components/SelectableCardListItem.d.ts +2 -2
  16. package/dist/components/common/SelectableCardList/index.d.ts +2 -2
  17. package/dist/components/common/ServiceLinks/types.d.ts +6 -6
  18. package/dist/components/common/SideNav/SideNav.types.d.ts +9 -6
  19. package/dist/components/common/SideNav/SideNavLayout.d.ts +1 -1
  20. package/dist/components/common/SideNav/components/SideNavPill.d.ts +2 -2
  21. package/dist/components/common/SideNav/components/SideNavPillList.d.ts +2 -2
  22. package/dist/components/common/SideNav/components/SideNavRow.d.ts +4 -3
  23. package/dist/components/common/SideNav/hooks/useElementHeight.d.ts +11 -0
  24. package/dist/components/common/SideNav/hooks/useKeepActiveItemInView.d.ts +19 -0
  25. package/dist/components/common/SideNav/hooks/useSideNavScrollSpy.d.ts +2 -2
  26. package/dist/components/common/SideNav/index.d.ts +2 -2
  27. package/dist/components/common/Tabs/TabPanel.d.ts +2 -2
  28. package/dist/components/common/Tabs/TabsWrapper.d.ts +2 -2
  29. package/dist/components/common/TitleBlock/types.d.ts +4 -4
  30. package/dist/components/form/components/FormControlWrapper/components/FieldSuffix.d.ts +2 -2
  31. package/dist/components/form/components/FormControlWrapper/index.d.ts +2 -2
  32. package/dist/components/form/inputs/RadioButtonGroup.d.ts +3 -3
  33. package/dist/components/form/inputs/SearchableField.d.ts +2 -2
  34. package/dist/components/form/inputs/Select/Select.types.d.ts +2 -2
  35. package/dist/components/layout/Footer/index.d.ts +2 -2
  36. package/dist/components/layout/ServiceFormActions.d.ts +2 -2
  37. package/dist/components/layout/ServiceFormContainer/AccordionFormContainer/components/AccordionCollapseControls.d.ts +2 -2
  38. package/dist/components/layout/ServiceFormContainer/AccordionFormContainer/index.d.ts +2 -2
  39. package/dist/components/layout/ServiceHeader.d.ts +2 -2
  40. package/dist/components/layout/ServicePage.d.ts +2 -2
  41. package/dist/components/utils/normalizeSx.d.ts +1 -1
  42. package/dist/library/types.d.ts +2 -2
  43. package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
  44. package/dist/registrucentras-rc-ses-react-components.js +1660 -1589
  45. package/dist/types/assets/IconProps.d.ts +2 -2
  46. package/dist/types/cards/CardServiceProps.d.ts +2 -2
  47. package/dist/types/common/QuickLinkType.d.ts +2 -2
  48. package/dist/types/inputs/InputIconProps.d.ts +2 -2
  49. package/dist/types/lists/ListNewsItemType.d.ts +2 -2
  50. package/dist/types/lists/ListServicesItemType.d.ts +3 -3
  51. package/package.json +2 -1
  52. package/src/components/common/Accordion/hooks/useAccordionController.tsx +1 -1
  53. package/src/components/common/Accordion/index.tsx +1 -4
  54. package/src/components/common/Accordion/types/AccordionControllerState.ts +1 -1
  55. package/src/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.ts +1 -1
  56. package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +1 -1
  57. package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +1 -1
  58. package/src/components/common/AdvancedList/components/AdvancedListItem/index.test.tsx +2 -2
  59. package/src/components/common/Badge/index.tsx +3 -3
  60. package/src/components/common/Breadcrumbs/index.tsx +5 -2
  61. package/src/components/common/Card/index.tsx +1 -1
  62. package/src/components/common/CardShell/CardFooter/index.tsx +6 -13
  63. package/src/components/common/CardShell/CardFooter/types.ts +2 -7
  64. package/src/components/common/CardShell/types.ts +2 -2
  65. package/src/components/common/IconWithCircularBackground.tsx +7 -8
  66. package/src/components/common/IconWithSquareBackground/index.tsx +7 -8
  67. package/src/components/common/ImageCard/index.tsx +1 -1
  68. package/src/components/common/SegmentedControl/components/SegmentButton/index.tsx +18 -19
  69. package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +1 -1
  70. package/src/components/common/SelectableCardList/index.tsx +1 -1
  71. package/src/components/common/ServiceLinks/types.ts +3 -3
  72. package/src/components/common/SideNav/SideNav.types.ts +22 -4
  73. package/src/components/common/SideNav/SideNavLayout.test.tsx +52 -0
  74. package/src/components/common/SideNav/SideNavLayout.tsx +23 -3
  75. package/src/components/common/SideNav/components/SideNavPill.tsx +1 -1
  76. package/src/components/common/SideNav/components/SideNavPillList.tsx +8 -23
  77. package/src/components/common/SideNav/components/SideNavRow.tsx +6 -2
  78. package/src/components/common/SideNav/hooks/useElementHeight.test.ts +135 -0
  79. package/src/components/common/SideNav/hooks/useElementHeight.ts +46 -0
  80. package/src/components/common/SideNav/hooks/useKeepActiveItemInView.test.ts +258 -0
  81. package/src/components/common/SideNav/hooks/useKeepActiveItemInView.ts +80 -0
  82. package/src/components/common/SideNav/hooks/useSideNavScrollSpy.test.ts +9 -2
  83. package/src/components/common/SideNav/hooks/useSideNavScrollSpy.ts +4 -3
  84. package/src/components/common/SideNav/index.test.tsx +51 -0
  85. package/src/components/common/SideNav/index.tsx +58 -13
  86. package/src/components/common/Snackbar/index.test.tsx +40 -0
  87. package/src/components/common/Snackbar/index.tsx +9 -3
  88. package/src/components/common/Tabs/TabPanel.tsx +1 -1
  89. package/src/components/common/Tabs/TabsWrapper.tsx +1 -1
  90. package/src/components/common/TitleBlock/index.test.tsx +9 -7
  91. package/src/components/common/TitleBlock/index.tsx +13 -9
  92. package/src/components/common/TitleBlock/types.ts +2 -2
  93. package/src/components/form/components/FormControlWrapper/components/FieldSuffix.tsx +1 -1
  94. package/src/components/form/components/FormControlWrapper/index.tsx +1 -1
  95. package/src/components/form/inputs/Datepicker/index.test.tsx +1 -1
  96. package/src/components/form/inputs/FileDropzone.tsx +1 -4
  97. package/src/components/form/inputs/NumberStepper.test.tsx +83 -0
  98. package/src/components/form/inputs/NumberStepper.tsx +7 -8
  99. package/src/components/form/inputs/RadioButtonGroup.test.tsx +1 -1
  100. package/src/components/form/inputs/RadioButtonGroup.tsx +2 -2
  101. package/src/components/form/inputs/SearchInput/index.tsx +1 -1
  102. package/src/components/form/inputs/SearchableField.test.tsx +2 -2
  103. package/src/components/form/inputs/SearchableField.tsx +1 -1
  104. package/src/components/form/inputs/Select/Select.types.ts +1 -1
  105. package/src/components/form/inputs/Select/index.test.tsx +3 -3
  106. package/src/components/layout/Footer/index.tsx +1 -1
  107. package/src/components/layout/ServiceFormActions.tsx +1 -1
  108. package/src/components/layout/ServiceFormContainer/AccordionFormContainer/components/AccordionCollapseControls.tsx +1 -1
  109. package/src/components/layout/ServiceFormContainer/AccordionFormContainer/index.tsx +1 -1
  110. package/src/components/layout/ServiceHeader.tsx +1 -1
  111. package/src/components/layout/ServicePage.tsx +1 -1
  112. package/src/components/utils/normalizeSx.ts +2 -4
  113. package/src/examples/ListWithPagination/index.tsx +0 -2
  114. package/src/examples/MultipleStepForm/components/AdditionalServicesForm.tsx +1 -1
  115. package/src/examples/MultipleStepForm/components/ServiceIssuanceForm.tsx +1 -1
  116. package/src/examples/MultipleStepForm/components/TermsAndConditionsForm.tsx +1 -1
  117. package/src/examples/MultipleStepForm/types/MultiStepFormModel.ts +1 -1
  118. package/src/examples/SingleStepForm/components/ObjectIdentifierSearchModal.tsx +2 -2
  119. package/src/examples/SingleStepForm/types/SingleStepFormModel.ts +1 -1
  120. package/src/library/types.ts +2 -1
  121. package/src/stories/atoms/Button.stories.tsx +9 -14
  122. package/src/stories/atoms/Checkbox.stories.tsx +1 -1
  123. package/src/stories/atoms/Icons.stories.tsx +1 -1
  124. package/src/stories/atoms/NumberStepper.stories.tsx +1 -1
  125. package/src/stories/atoms/PhoneInput.stories.tsx +1 -1
  126. package/src/stories/atoms/Select.stories.tsx +7 -9
  127. package/src/stories/atoms/Switch.stories.tsx +1 -1
  128. package/src/stories/molecules/Alert.stories.tsx +2 -2
  129. package/src/stories/molecules/CardShell.stories.tsx +4 -4
  130. package/src/stories/molecules/CheckboxFormControl.stories.tsx +13 -21
  131. package/src/stories/molecules/RadioButtonGroup.stories.tsx +1 -1
  132. package/src/stories/molecules/Snackbar.stories.tsx +2 -2
  133. package/src/stories/molecules/TitleBlock.stories.tsx +40 -1
  134. package/src/stories/organisms/AdvancedList.stories.tsx +4 -4
  135. package/src/stories/organisms/FileDropzone.stories.tsx +1 -1
  136. package/src/stories/organisms/FileUpload.stories.tsx +1 -1
  137. package/src/stories/organisms/SideNav.stories.tsx +41 -3
  138. package/src/stubs/Component.tsx +4 -4
  139. package/src/types/assets/IconProps.tsx +1 -1
  140. package/src/types/cards/CardServiceProps.tsx +1 -1
  141. package/src/types/common/QuickLinkType.tsx +1 -1
  142. package/src/types/inputs/InputIconProps.tsx +1 -1
  143. package/src/types/lists/ListNewsItemType.tsx +1 -1
  144. package/src/types/lists/ListServicesItemType.tsx +2 -2
  145. package/src/vite-env.d.ts +2 -2
  146. package/dist/stories/atoms/Badge.stories.d.ts +0 -9
  147. package/dist/stories/atoms/Button.stories.d.ts +0 -107
  148. package/dist/stories/atoms/Checkbox.stories.d.ts +0 -21
  149. package/dist/stories/atoms/IconWithCircularBackground.stories.d.ts +0 -6
  150. package/dist/stories/atoms/IconWithSquareBackground.stories.d.ts +0 -7
  151. package/dist/stories/atoms/Icons.stories.d.ts +0 -7
  152. package/dist/stories/atoms/Loader.stories.d.ts +0 -36
  153. package/dist/stories/atoms/LoadingSpinner.stories.d.ts +0 -62
  154. package/dist/stories/atoms/Logo.stories.d.ts +0 -12
  155. package/dist/stories/atoms/NumberStepper.stories.d.ts +0 -6
  156. package/dist/stories/atoms/PhoneInput.stories.d.ts +0 -10
  157. package/dist/stories/atoms/SearchInput.stories.d.ts +0 -11
  158. package/dist/stories/atoms/Select.stories.d.ts +0 -7
  159. package/dist/stories/atoms/SimpleCheckbox.stories.d.ts +0 -19
  160. package/dist/stories/atoms/Switch.stories.d.ts +0 -17
  161. package/dist/stories/atoms/Tab.stories.d.ts +0 -8
  162. package/dist/stories/atoms/TextField.stories.d.ts +0 -6
  163. package/dist/stories/atoms/Tooltip.stories.d.ts +0 -48
  164. package/dist/stories/foundations/ThemedMuiComponents.stories.d.ts +0 -25
  165. package/dist/stories/molecules/Alert.stories.d.ts +0 -14
  166. package/dist/stories/molecules/Breadcrumbs.stories.d.ts +0 -6
  167. package/dist/stories/molecules/ButtonWithPopover.stories.d.ts +0 -7
  168. package/dist/stories/molecules/Card.stories.d.ts +0 -8
  169. package/dist/stories/molecules/CardShell.stories.d.ts +0 -18
  170. package/dist/stories/molecules/CheckboxFormControl.stories.d.ts +0 -9
  171. package/dist/stories/molecules/DatePicker.stories.d.ts +0 -152
  172. package/dist/stories/molecules/FormControlWrapper.stories.d.ts +0 -7
  173. package/dist/stories/molecules/ImageCard.stories.d.ts +0 -8
  174. package/dist/stories/molecules/ListWithIcons.stories.d.ts +0 -34
  175. package/dist/stories/molecules/PhoneInputFormControl.stories.d.ts +0 -6
  176. package/dist/stories/molecules/Popover.stories.d.ts +0 -12
  177. package/dist/stories/molecules/RadioButtonGroup.stories.d.ts +0 -6
  178. package/dist/stories/molecules/SearchableField.stories.d.ts +0 -6
  179. package/dist/stories/molecules/SegmentedControl.stories.d.ts +0 -202
  180. package/dist/stories/molecules/Snackbar.stories.d.ts +0 -143
  181. package/dist/stories/molecules/TabPanel.stories.d.ts +0 -7
  182. package/dist/stories/molecules/Tabs.stories.d.ts +0 -7
  183. package/dist/stories/molecules/TabsWrapper.stories.d.ts +0 -6
  184. package/dist/stories/molecules/TitleBlock.stories.d.ts +0 -22
  185. package/dist/stories/organisms/Accordion.stories.d.ts +0 -18
  186. package/dist/stories/organisms/AdvancedList.stories.d.ts +0 -33
  187. package/dist/stories/organisms/AdvancedListItem.stories.d.ts +0 -33
  188. package/dist/stories/organisms/CardFormContainer.stories.d.ts +0 -7
  189. package/dist/stories/organisms/DataPagination.stories.d.ts +0 -47
  190. package/dist/stories/organisms/Dialog.stories.d.ts +0 -15
  191. package/dist/stories/organisms/FileDropzone.stories.d.ts +0 -6
  192. package/dist/stories/organisms/FileUpload.stories.d.ts +0 -18
  193. package/dist/stories/organisms/Footer.stories.d.ts +0 -6
  194. package/dist/stories/organisms/FullPageLoader.stories.d.ts +0 -37
  195. package/dist/stories/organisms/Modal.stories.d.ts +0 -10
  196. package/dist/stories/organisms/SelectableCardList.stories.d.ts +0 -37
  197. package/dist/stories/organisms/ServiceFormActions.stories.d.ts +0 -6
  198. package/dist/stories/organisms/ServiceFormContainer.stories.d.ts +0 -15
  199. package/dist/stories/organisms/ServiceHeader.stories.d.ts +0 -7
  200. package/dist/stories/organisms/ServiceLinks.stories.d.ts +0 -28
  201. package/dist/stories/organisms/ServiceWizardStepper.stories.d.ts +0 -7
  202. package/dist/stories/organisms/SideNav.stories.d.ts +0 -7
  203. package/dist/stories/templates/ServicePage.stories.d.ts +0 -6
@@ -6,7 +6,7 @@ const ACTIVATION_LINE_EPSILON = 1
6
6
  // long document).
7
7
  const PROGRAMMATIC_SCROLL_SETTLE_MS = 600
8
8
 
9
- type UseSideNavScrollSpyOptions = {
9
+ interface UseSideNavScrollSpyOptions {
10
10
  itemIds: string[]
11
11
  offset?: number
12
12
  // Bounds id resolution to this subtree so an id collision elsewhere on the page
@@ -16,8 +16,9 @@ type UseSideNavScrollSpyOptions = {
16
16
 
17
17
  function findScopedElement(root: Document | HTMLElement, id: string): HTMLElement | null {
18
18
  if (root instanceof Document) return root.getElementById(id)
19
- // Attribute selector, so an id that is not a valid CSS selector cannot throw.
20
- return root.querySelector<HTMLElement>(`[id="${id.replace(/"/g, '\\"')}"]`)
19
+ // Attribute selector, so an id that is not a valid CSS identifier still
20
+ // resolves. Escapes both characters a CSS string cannot hold raw.
21
+ return root.querySelector<HTMLElement>(`[id="${id.replace(/["\\]/g, '\\$&')}"]`)
21
22
  }
22
23
 
23
24
  function useSideNavScrollSpy({ itemIds, offset = 0, scope }: UseSideNavScrollSpyOptions) {
@@ -25,6 +25,12 @@ const items: RcSesSideNavItem[] = [
25
25
  const renderSideNav = (ui: ReactElement) =>
26
26
  render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
27
27
 
28
+ // The desktop column and its scrolling row list carry no role of their own; the
29
+ // nav landmark is the only stable handle into that part of the tree.
30
+ const getDesktopColumn = () =>
31
+ screen.getByRole('navigation').firstElementChild as HTMLElement
32
+ const getRowList = () => getDesktopColumn().lastElementChild as HTMLElement
33
+
28
34
  describe('RcSesSideNav', () => {
29
35
  beforeEach(async () => {
30
36
  await i18n.changeLanguage('lt')
@@ -90,6 +96,51 @@ describe('RcSesSideNav', () => {
90
96
  expect(screen.queryAllByRole('button')).toHaveLength(0)
91
97
  })
92
98
 
99
+ it('lets the desktop list grow as tall as it needs by default', () => {
100
+ renderSideNav(<RcSesSideNav items={items} />)
101
+
102
+ expect(getRowList()).not.toHaveStyle({ overflowY: 'auto' })
103
+ expect(window.getComputedStyle(getDesktopColumn()).maxHeight).not.toContain('100vh')
104
+ })
105
+
106
+ it("caps the desktop list to the viewport and scrolls it inside itself with overflow='scroll'", () => {
107
+ renderSideNav(<RcSesSideNav items={items} overflow='scroll' offset={96} />)
108
+
109
+ expect(window.getComputedStyle(getDesktopColumn()).maxHeight).toBe(
110
+ 'calc(100vh - 96px)',
111
+ )
112
+ expect(getRowList()).toHaveStyle({ overflowY: 'auto' })
113
+ })
114
+
115
+ it('scrolls an active item that sits past the bottom of the list into view', () => {
116
+ const { rerender } = renderSideNav(
117
+ <RcSesSideNav items={items} overflow='scroll' offset={96} />,
118
+ )
119
+
120
+ const list = getRowList()
121
+ const scrollTo = vi.fn()
122
+ list.scrollTo = scrollTo
123
+ // jsdom has no layout: the list ends at 300, the row runs on to 360.
124
+ list.getBoundingClientRect = () =>
125
+ ({ top: 100, bottom: 300, left: 0, right: 200 }) as DOMRect
126
+ const row = list.querySelector<HTMLElement>('[data-item-id="signature"]')!
127
+ row.getBoundingClientRect = () =>
128
+ ({ top: 320, bottom: 360, left: 0, right: 200 }) as DOMRect
129
+
130
+ rerender(
131
+ <ThemeProvider theme={theme}>
132
+ <RcSesSideNav
133
+ items={items}
134
+ overflow='scroll'
135
+ offset={96}
136
+ activeItemId='signature'
137
+ />
138
+ </ThemeProvider>,
139
+ )
140
+
141
+ expect(scrollTo).toHaveBeenCalledWith({ top: 60, behavior: 'smooth' })
142
+ })
143
+
93
144
  it('renders in English when the language is changed', async () => {
94
145
  await i18n.changeLanguage('en')
95
146
  renderSideNav(<RcSesSideNav items={items} />)
@@ -1,4 +1,5 @@
1
1
  import { Box, Typography } from '@mui/material'
2
+ import { useEffect, useRef } from 'react'
2
3
  import { useTranslation } from 'react-i18next'
3
4
 
4
5
  import normalizeSx from '@/components/utils/normalizeSx'
@@ -7,16 +8,41 @@ import palette, { common } from '@/theme/palette'
7
8
  import { RcSesSideNavItem, RcSesSideNavProps } from './SideNav.types'
8
9
  import SideNavPillList from './components/SideNavPillList'
9
10
  import SideNavRow from './components/SideNavRow'
11
+ import useElementHeight from './hooks/useElementHeight'
12
+ import useKeepActiveItemInView from './hooks/useKeepActiveItemInView'
13
+
14
+ const ROW_GAP = '0.25rem'
10
15
 
11
16
  function RcSesSideNav({
12
17
  items,
13
18
  activeItemId,
14
19
  onItemClick,
15
20
  title,
21
+ overflow = 'fit',
22
+ offset = 0,
23
+ onOverlayHeightChange,
16
24
  sx,
17
25
  }: RcSesSideNavProps) {
18
26
  const { t } = useTranslation('common', { keyPrefix: 'components.RcSesSideNav' })
19
27
  const navTitle = title ?? t('title')
28
+ const rowListRef = useRef<HTMLDivElement>(null)
29
+ const pillBarRef = useRef<HTMLDivElement>(null)
30
+
31
+ const isScrollable = overflow === 'scroll'
32
+ useKeepActiveItemInView({
33
+ containerRef: rowListRef,
34
+ activeItemId,
35
+ axis: 'vertical',
36
+ enabled: isScrollable,
37
+ behavior: 'smooth',
38
+ })
39
+
40
+ // 0 above the mobile breakpoint, where the bar is display: none and the nav is
41
+ // a column beside the content rather than a layer on top of it.
42
+ const overlayHeight = useElementHeight(pillBarRef)
43
+ useEffect(() => {
44
+ onOverlayHeightChange?.(overlayHeight)
45
+ }, [overlayHeight, onOverlayHeightChange])
20
46
 
21
47
  const getItemAriaLabel = (item: RcSesSideNavItem) =>
22
48
  item.count !== undefined
@@ -42,7 +68,11 @@ function RcSesSideNav({
42
68
  sx={{
43
69
  display: { xs: 'none', md: 'flex' },
44
70
  flexDirection: 'column',
45
- gap: '0.25rem',
71
+ gap: ROW_GAP,
72
+ // Capped to what is left of the viewport below the sticky header, so
73
+ // the list can never run past the bottom of the screen. The title stays
74
+ // put and only the rows scroll, hence minHeight: 0 on this flex column.
75
+ ...(isScrollable && { maxHeight: `calc(100vh - ${offset}px)`, minHeight: 0 }),
46
76
  }}
47
77
  >
48
78
  <Typography
@@ -55,19 +85,30 @@ function RcSesSideNav({
55
85
  >
56
86
  {navTitle}
57
87
  </Typography>
58
- {items.map((item) => (
59
- <SideNavRow
60
- key={item.id}
61
- label={item.label}
62
- count={item.count}
63
- ariaLabel={getItemAriaLabel(item)}
64
- active={item.id === activeItemId}
65
- onClick={onItemClick ? () => onItemClick(item.id) : undefined}
66
- />
67
- ))}
88
+ <Box
89
+ ref={rowListRef}
90
+ sx={{
91
+ display: 'flex',
92
+ flexDirection: 'column',
93
+ gap: ROW_GAP,
94
+ ...(isScrollable && { overflowY: 'auto', minHeight: 0 }),
95
+ }}
96
+ >
97
+ {items.map((item) => (
98
+ <SideNavRow
99
+ key={item.id}
100
+ itemId={item.id}
101
+ label={item.label}
102
+ count={item.count}
103
+ ariaLabel={getItemAriaLabel(item)}
104
+ active={item.id === activeItemId}
105
+ onClick={onItemClick ? () => onItemClick(item.id) : undefined}
106
+ />
107
+ ))}
108
+ </Box>
68
109
  </Box>
69
110
 
70
- <Box sx={{ display: { xs: 'block', md: 'none' } }}>
111
+ <Box ref={pillBarRef} sx={{ display: { xs: 'block', md: 'none' } }}>
71
112
  <SideNavPillList
72
113
  items={items}
73
114
  activeItemId={activeItemId}
@@ -80,4 +121,8 @@ function RcSesSideNav({
80
121
  }
81
122
 
82
123
  export default RcSesSideNav
83
- export type { RcSesSideNavItem, RcSesSideNavProps } from './SideNav.types'
124
+ export type {
125
+ RcSesSideNavItem,
126
+ RcSesSideNavOverflow,
127
+ RcSesSideNavProps,
128
+ } from './SideNav.types'
@@ -115,6 +115,46 @@ describe('RcSesSnackbar', () => {
115
115
  expect(screen.queryByRole('button', { name: 'Undo' })).not.toBeInTheDocument()
116
116
  })
117
117
 
118
+ test('follows the open prop when the parent toggles it', () => {
119
+ const { rerender } = renderSnackbar(<RcSesSnackbar {...DEFAULT_PROPS} open />)
120
+ expect(screen.getByText('Test')).toBeInTheDocument()
121
+
122
+ rerender(
123
+ <ThemeProvider theme={theme}>
124
+ <RcSesSnackbar {...DEFAULT_PROPS} open={false} />
125
+ </ThemeProvider>,
126
+ )
127
+ act(() => {
128
+ vi.runOnlyPendingTimers()
129
+ })
130
+ expect(screen.queryByText('Test')).not.toBeInTheDocument()
131
+
132
+ rerender(
133
+ <ThemeProvider theme={theme}>
134
+ <RcSesSnackbar {...DEFAULT_PROPS} open />
135
+ </ThemeProvider>,
136
+ )
137
+ expect(screen.getByText('Test')).toBeInTheDocument()
138
+ })
139
+
140
+ test('still closes from the inside while the parent holds open at true', () => {
141
+ const { rerender } = renderSnackbar(<RcSesSnackbar {...DEFAULT_PROPS} open />)
142
+ fireEvent.keyDown(getMuiSnackbar(), { key: 'Escape', code: 'Escape' })
143
+ act(() => {
144
+ vi.runOnlyPendingTimers()
145
+ })
146
+ expect(screen.queryByText('Test')).not.toBeInTheDocument()
147
+
148
+ // A re-render with `open` unchanged must not resurrect it - only an actual
149
+ // false -> true transition of the prop may reopen the snackbar.
150
+ rerender(
151
+ <ThemeProvider theme={theme}>
152
+ <RcSesSnackbar {...DEFAULT_PROPS} open />
153
+ </ThemeProvider>,
154
+ )
155
+ expect(screen.queryByText('Test')).not.toBeInTheDocument()
156
+ })
157
+
118
158
  test('has correct accessibility attributes', () => {
119
159
  renderSnackbar(<RcSesSnackbar {...DEFAULT_PROPS} />)
120
160
  const status = screen.getByRole('status')
@@ -6,7 +6,7 @@ import {
6
6
  useMediaQuery,
7
7
  useTheme,
8
8
  } from '@mui/material'
9
- import { useEffect, useLayoutEffect, useRef, useState } from 'react'
9
+ import { useLayoutEffect, useRef, useState } from 'react'
10
10
  import { useTranslation } from 'react-i18next'
11
11
 
12
12
  import CloseIcon from '@/assets/icons/CloseIcon'
@@ -53,13 +53,19 @@ function RcSesSnackbar({
53
53
  const { t } = useTranslation('input')
54
54
  const [internalOpen, setInternalOpen] = useState(controlledOpen ?? true)
55
55
  const [isPaused, setIsPaused] = useState(false)
56
+ const [prevControlledOpen, setPrevControlledOpen] = useState(controlledOpen)
56
57
  const persist = controlledPersist ?? state === 'action-needed'
57
58
 
58
- useEffect(() => {
59
+ // The `open` prop drives the internal state, but closing from the inside
60
+ // (Escape, autohide, close button) has to keep working while the parent holds
61
+ // `open` at true. Adjusting the state during render instead of in an effect
62
+ // preserves both without the extra render pass an effect would cause.
63
+ if (controlledOpen !== prevControlledOpen) {
64
+ setPrevControlledOpen(controlledOpen)
59
65
  if (controlledOpen !== undefined) {
60
66
  setInternalOpen(controlledOpen)
61
67
  }
62
- }, [controlledOpen])
68
+ }
63
69
 
64
70
  const config = stateConfig[state]
65
71
  const StateIcon = config.icon
@@ -1,7 +1,7 @@
1
1
  import { Box } from '@mui/material'
2
2
  import React from 'react'
3
3
 
4
- type Props = {
4
+ interface Props {
5
5
  activeTab: number
6
6
  children?: React.ReactNode
7
7
  index: number
@@ -3,7 +3,7 @@ import React from 'react'
3
3
 
4
4
  import palette from '@/theme/palette'
5
5
 
6
- type Props = {
6
+ interface Props {
7
7
  children?: React.ReactNode
8
8
  heading?: React.ReactNode
9
9
  }
@@ -241,10 +241,9 @@ describe('RcSesTitleBlock', () => {
241
241
  )
242
242
  })
243
243
 
244
- test('actions slot stacks vertically on mobile (xs)', () => {
245
- // MUI's responsive `direction={{ xs: 'column', sm: 'row' }}` emits
246
- // `flex-direction: column` as the base (xs) rule; the sm breakpoint
247
- // override lives behind a media query and does not affect the base style.
244
+ test('actions slot renders as a wrapping row', () => {
245
+ // jsdom does not evaluate media queries or measure widths, so this only
246
+ // asserts the base flex styles — not the actual mobile wrap behaviour.
248
247
  renderTitleBlock(
249
248
  <RcSesTitleBlock
250
249
  actions={
@@ -258,10 +257,13 @@ describe('RcSesTitleBlock', () => {
258
257
  />,
259
258
  )
260
259
 
261
- expect(screen.getByTestId('actions')).toHaveStyle({ flexDirection: 'column' })
260
+ expect(screen.getByTestId('actions')).toHaveStyle({
261
+ flexDirection: 'row',
262
+ flexWrap: 'wrap',
263
+ })
262
264
  })
263
265
 
264
- test('actions slot stacks vertically on mobile even with a single action', () => {
266
+ test('actions slot renders as a row with a single action', () => {
265
267
  renderTitleBlock(
266
268
  <RcSesTitleBlock
267
269
  actions={<button type='button'>Užsakyti</button>}
@@ -270,7 +272,7 @@ describe('RcSesTitleBlock', () => {
270
272
  />,
271
273
  )
272
274
 
273
- expect(screen.getByTestId('actions')).toHaveStyle({ flexDirection: 'column' })
275
+ expect(screen.getByTestId('actions')).toHaveStyle({ flexDirection: 'row' })
274
276
  })
275
277
 
276
278
  test('omits the icon and actions slots when not provided', () => {
@@ -4,7 +4,7 @@ import RcSesBadge from '@/components/common/Badge'
4
4
  import cards from '@/theme/cards'
5
5
  import palette from '@/theme/palette'
6
6
 
7
- import { RcSesTitleBlockProps } from './types'
7
+ import { RcSesTitleBlockProps, TitleBlockHeadingLevel } from './types'
8
8
 
9
9
  function RcSesTitleBlock({
10
10
  title,
@@ -20,7 +20,10 @@ function RcSesTitleBlock({
20
20
  className,
21
21
  testIds,
22
22
  }: RcSesTitleBlockProps) {
23
- const HeadingTag = `h${headingLevel}` as 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
23
+ // Annotated rather than asserted: a template literal expression widens to
24
+ // `string` without a contextual type, and JSX cannot resolve an intrinsic
25
+ // element from that.
26
+ const HeadingTag: `h${TitleBlockHeadingLevel}` = `h${headingLevel}`
24
27
  const hasCount = count !== undefined && count !== null
25
28
  const hasDescription = description !== undefined && description !== null
26
29
  const isVertical = orientation === 'vertical'
@@ -103,11 +106,15 @@ function RcSesTitleBlock({
103
106
  const actionsSlot = actions ? (
104
107
  <Stack
105
108
  data-testid={testIds?.actions}
106
- direction={{ xs: 'column', sm: 'row' }}
109
+ direction='row'
107
110
  spacing={cards.header.actionsGap}
111
+ // Flex gap instead of sibling margin, so wrapped rows get the vertical
112
+ // gap and the first action of each row has no stray left margin.
113
+ useFlexGap
108
114
  sx={{
109
- alignItems: { xs: 'flex-start', sm: 'center' },
115
+ alignItems: 'center',
110
116
  flexShrink: 0,
117
+ flexWrap: 'wrap',
111
118
  }}
112
119
  >
113
120
  {actions}
@@ -125,10 +132,7 @@ function RcSesTitleBlock({
125
132
  // leaving a sibling-selector margin above the title.
126
133
  useFlexGap
127
134
  sx={{
128
- alignItems:
129
- isVertical || hasDescription
130
- ? 'flex-start'
131
- : { xs: 'flex-start', sm: 'center' },
135
+ alignItems: isVertical ? 'flex-start' : { xs: 'flex-start', sm: 'center' },
132
136
  width: '100%',
133
137
  }}
134
138
  >
@@ -145,7 +149,7 @@ function RcSesTitleBlock({
145
149
  direction='row'
146
150
  spacing={cards.header.rowGap}
147
151
  sx={{
148
- alignItems: hasDescription ? 'flex-start' : 'center',
152
+ alignItems: 'center',
149
153
  flex: 1,
150
154
  minWidth: 0,
151
155
  width: '100%',
@@ -6,7 +6,7 @@ export type TitleBlockTitleVariant = 'h4' | 'h5' | 'h6' | 'body1'
6
6
 
7
7
  export type TitleBlockOrientation = 'horizontal' | 'vertical'
8
8
 
9
- export type RcSesTitleBlockTestIds = {
9
+ export interface RcSesTitleBlockTestIds {
10
10
  root?: string
11
11
  icon?: string
12
12
  heading?: string
@@ -15,7 +15,7 @@ export type RcSesTitleBlockTestIds = {
15
15
  actions?: string
16
16
  }
17
17
 
18
- export type RcSesTitleBlockBaseProps = {
18
+ export interface RcSesTitleBlockBaseProps {
19
19
  title: ReactNode
20
20
  headingLevel?: TitleBlockHeadingLevel
21
21
  /**
@@ -1,6 +1,6 @@
1
1
  import { Box, SxProps, Theme } from '@mui/material'
2
2
 
3
- type Props = {
3
+ interface Props {
4
4
  children: React.ReactNode
5
5
  sx?: SxProps<Theme>
6
6
  }
@@ -8,7 +8,7 @@ import theme from '@/theme/light'
8
8
  import FieldSuffix from './components/FieldSuffix'
9
9
  import { formControlDesktopLabelWidth } from './const/FormControlLayoutVariables'
10
10
 
11
- type Props = {
11
+ interface Props {
12
12
  children: React.ReactNode
13
13
  className?: string
14
14
  description?: React.ReactNode
@@ -16,7 +16,7 @@ import RcSesDatepicker from '.'
16
16
  const REFERENCE = new Date(2026, 0, 15)
17
17
  const MAX = new Date(2026, 0, 20)
18
18
 
19
- type HarnessProps = {
19
+ interface HarnessProps {
20
20
  /** Seeds the field, so a day renders as selected. */
21
21
  value?: string | null
22
22
  /** Bounds the calendar, so later days render as disabled. */
@@ -70,10 +70,7 @@ function RcSesFileDropzone(props: Props) {
70
70
 
71
71
  const hasValidFileSelection = value && Array.isArray(value) && value.length > 0
72
72
 
73
- const onRemoveFile = (
74
- e: React.MouseEvent<HTMLButtonElement, MouseEvent>,
75
- index: number,
76
- ) => {
73
+ const onRemoveFile = (e: React.MouseEvent<HTMLButtonElement>, index: number) => {
77
74
  e.preventDefault()
78
75
  e.stopPropagation()
79
76
 
@@ -0,0 +1,83 @@
1
+ import { ThemeProvider } from '@mui/material/styles'
2
+ import { fireEvent, render, screen } from '@testing-library/react'
3
+ import { useForm } from 'react-hook-form'
4
+
5
+ import theme from '@/theme/light'
6
+
7
+ import RcSesNumberStepper from './NumberStepper'
8
+
9
+ interface TestWrapperProps {
10
+ defaultValue?: number
11
+ disabled?: boolean
12
+ max?: number
13
+ min?: number
14
+ }
15
+
16
+ const TestWrapper = ({ defaultValue = 5, disabled, max, min }: TestWrapperProps) => {
17
+ const { control } = useForm({ defaultValues: { quantity: defaultValue } })
18
+
19
+ return (
20
+ <ThemeProvider theme={theme}>
21
+ <RcSesNumberStepper
22
+ id='quantity'
23
+ name='quantity'
24
+ control={control}
25
+ label='Kiekis'
26
+ displayStepperControls
27
+ disabled={disabled}
28
+ rules={{ min, max }}
29
+ />
30
+ </ThemeProvider>
31
+ )
32
+ }
33
+
34
+ const subtractButton = () => screen.getByRole('button', { name: 'Atimti' })
35
+ const addButton = () => screen.getByRole('button', { name: 'Pridėti' })
36
+
37
+ describe('RcSesNumberStepper', () => {
38
+ test('enables both controls when the value sits between min and max', () => {
39
+ render(<TestWrapper defaultValue={5} min={0} max={10} />)
40
+
41
+ expect(subtractButton()).toBeEnabled()
42
+ expect(addButton()).toBeEnabled()
43
+ })
44
+
45
+ test('disables subtract on the first render when the value is already at min', () => {
46
+ render(<TestWrapper defaultValue={0} min={0} max={10} />)
47
+
48
+ expect(subtractButton()).toBeDisabled()
49
+ expect(addButton()).toBeEnabled()
50
+ })
51
+
52
+ test('disables add on the first render when the value is already at max', () => {
53
+ render(<TestWrapper defaultValue={10} min={0} max={10} />)
54
+
55
+ expect(subtractButton()).toBeEnabled()
56
+ expect(addButton()).toBeDisabled()
57
+ })
58
+
59
+ test('disables both controls when the field is disabled', () => {
60
+ render(<TestWrapper defaultValue={5} disabled min={0} max={10} />)
61
+
62
+ expect(subtractButton()).toBeDisabled()
63
+ expect(addButton()).toBeDisabled()
64
+ })
65
+
66
+ test('leaves both controls enabled when no min or max is set', () => {
67
+ render(<TestWrapper defaultValue={0} />)
68
+
69
+ expect(subtractButton()).toBeEnabled()
70
+ expect(addButton()).toBeEnabled()
71
+ })
72
+
73
+ test('re-evaluates the controls as the value reaches a bound', () => {
74
+ render(<TestWrapper defaultValue={9} min={0} max={10} />)
75
+
76
+ expect(addButton()).toBeEnabled()
77
+
78
+ fireEvent.click(addButton())
79
+
80
+ expect(addButton()).toBeDisabled()
81
+ expect(subtractButton()).toBeEnabled()
82
+ })
83
+ })
@@ -51,7 +51,7 @@ const NumberInput = styled(OutlinedInput)({
51
51
  },
52
52
  })
53
53
 
54
- type ArrowButtonProps = {
54
+ interface ArrowButtonProps {
55
55
  ariaLabel: string
56
56
  direction: 'plus' | 'minus'
57
57
  disabled: boolean
@@ -110,8 +110,6 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
110
110
  function RcSesNumberStepper(props: Props) {
111
111
  const { t } = useTranslation('input', { keyPrefix: 'components.RcSesNumberStepper' })
112
112
 
113
- const [buttonState, setButtonState] = React.useState<[boolean, boolean]>([true, true])
114
-
115
113
  const {
116
114
  control,
117
115
  displayStepperControls,
@@ -138,20 +136,21 @@ function RcSesNumberStepper(props: Props) {
138
136
  ...slotProps?.controller,
139
137
  })
140
138
 
141
- React.useEffect(() => {
139
+ // [subtractDisabled, addDisabled] - derived from the current value and the
140
+ // controller rules, so the buttons render with the right state on first paint.
141
+ const buttonState = useMemo<[boolean, boolean]>(() => {
142
142
  if (disabled) {
143
- setButtonState([true, true])
144
- return
143
+ return [true, true]
145
144
  }
146
145
 
147
- setButtonState([
146
+ return [
148
147
  Number.isInteger(rules?.min)
149
148
  ? parseInt(rules?.min as string, 10) >= parseInt((value ?? 0) as string, 10)
150
149
  : false,
151
150
  Number.isInteger(rules?.max)
152
151
  ? parseInt(rules?.max as string, 10) <= parseInt((value ?? 0) as string, 10)
153
152
  : false,
154
- ])
153
+ ]
155
154
  }, [disabled, rules?.max, rules?.min, value])
156
155
 
157
156
  const handleInputOnChange = (
@@ -12,7 +12,7 @@ const options = [
12
12
  { label: 'Juridinis asmuo', value: 'legal' },
13
13
  ]
14
14
 
15
- type TestWrapperProps = {
15
+ interface TestWrapperProps {
16
16
  shouldUnregister?: boolean
17
17
  }
18
18
 
@@ -15,7 +15,7 @@ import RcSesFormControlWrapper, {
15
15
  RcSesFormControlWrapperProps,
16
16
  } from '../components/FormControlWrapper'
17
17
 
18
- export type RadioOption = {
18
+ export interface RadioOption {
19
19
  label: string
20
20
  value: string
21
21
  }
@@ -35,7 +35,7 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
35
35
  id?: string
36
36
  className?: string
37
37
  hideNativeRadio?: boolean
38
- options: Array<RadioOption>
38
+ options: RadioOption[]
39
39
  variant?: 'flat' | 'outlined' | 'filled'
40
40
  slotProps?: {
41
41
  controller?: Partial<Omit<TControllerProps, ImmediateControllerProps>>
@@ -62,7 +62,7 @@ const RcSesSearchInput = React.forwardRef<HTMLInputElement, Props>((props, ref)
62
62
  if (typeof ref === 'function') {
63
63
  ref(el)
64
64
  } else if (ref) {
65
- ;(ref as React.MutableRefObject<HTMLInputElement | null>).current = el
65
+ ref.current = el
66
66
  }
67
67
  },
68
68
  [ref],
@@ -25,7 +25,7 @@ vi.mock('react-i18next', () => ({
25
25
  * the runtime breaks. These tests pin the behaviour so the migration is verifiable.
26
26
  */
27
27
 
28
- type ModalProps = {
28
+ interface ModalProps {
29
29
  open: boolean
30
30
  onSubmit: (value: string) => void
31
31
  onClose: () => void
@@ -58,7 +58,7 @@ const TestWrapper = ({ defaultValue = '' }: { defaultValue?: string }) => {
58
58
  )
59
59
  }
60
60
 
61
- const getField = () => screen.getByRole('textbox') as HTMLInputElement
61
+ const getField = () => screen.getByRole<HTMLInputElement>('textbox')
62
62
 
63
63
  describe('RcSesSearchableField', () => {
64
64
  it('should render the field with the value from the form', () => {
@@ -15,7 +15,7 @@ import RcSesFormControlWrapper, {
15
15
  RcSesFormControlWrapperProps,
16
16
  } from '../components/FormControlWrapper'
17
17
 
18
- type ModalComponentProps = {
18
+ interface ModalComponentProps {
19
19
  open: boolean
20
20
  onSubmit: (value: string) => void
21
21
  onClose: () => void
@@ -1,4 +1,4 @@
1
- export type Option = {
1
+ export interface Option {
2
2
  label: string
3
3
  value: string
4
4
  description?: string