@registrucentras/rc-ses-react-components 2.3.0 → 2.5.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 (169) hide show
  1. package/dist/assets/icons/createIcon.d.ts +18 -0
  2. package/dist/assets/icons/phosphorIcons.d.ts +221 -0
  3. package/dist/components/common/Badge/index.d.ts +1 -0
  4. package/dist/components/overlays/Drawer/Drawer.types.d.ts +30 -0
  5. package/dist/components/overlays/Drawer/index.d.ts +9 -0
  6. package/dist/library/icons.d.ts +2 -48
  7. package/dist/library/index.d.ts +2 -1
  8. package/dist/library/types.d.ts +2 -0
  9. package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
  10. package/dist/registrucentras-rc-ses-react-components.js +2579 -2762
  11. package/package.json +5 -5
  12. package/src/assets/icons/createIcon.test.tsx +49 -0
  13. package/src/assets/icons/createIcon.tsx +49 -0
  14. package/src/assets/icons/phosphorIcons.ts +162 -0
  15. package/src/components/common/Accordion/index.tsx +1 -1
  16. package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +1 -3
  17. package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +6 -4
  18. package/src/components/common/AdvancedList/components/AdvancedListItem/index.test.tsx +5 -3
  19. package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.test.tsx +23 -0
  20. package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.tsx +6 -0
  21. package/src/components/common/Alert/index.tsx +1 -1
  22. package/src/components/common/Badge/index.test.tsx +16 -0
  23. package/src/components/common/Badge/index.tsx +35 -12
  24. package/src/components/common/Button/ButtonWithPopover.tsx +1 -2
  25. package/src/components/common/DataPagination/index.tsx +1 -2
  26. package/src/components/common/IconWithSquareBackground/index.test.tsx +1 -1
  27. package/src/components/common/ServiceLinks/ServiceLinkItem/index.tsx +1 -1
  28. package/src/components/common/Snackbar/index.tsx +1 -1
  29. package/src/components/common/StepCard/StepCardFooter/index.tsx +5 -3
  30. package/src/components/common/Tooltip/index.tsx +1 -1
  31. package/src/components/form/inputs/CheckboxFormControl.tsx +1 -2
  32. package/src/components/form/inputs/Datepicker/components/RcSesDatepickerCalendarHeader.tsx +6 -4
  33. package/src/components/form/inputs/Datepicker/index.tsx +1 -2
  34. package/src/components/form/inputs/FileDropzone.tsx +1 -2
  35. package/src/components/form/inputs/FileUpload.tsx +1 -1
  36. package/src/components/form/inputs/NumberStepper.tsx +1 -2
  37. package/src/components/form/inputs/PhoneInputFormControl/components/AutocompleteInput.tsx +1 -1
  38. package/src/components/form/inputs/PhoneInputFormControl/index.tsx +1 -1
  39. package/src/components/form/inputs/SearchInput/index.tsx +1 -2
  40. package/src/components/form/inputs/SearchableField.tsx +1 -2
  41. package/src/components/form/inputs/Select/components/OptionCheckbox.tsx +1 -1
  42. package/src/components/form/inputs/Select/index.tsx +1 -2
  43. package/src/components/form/inputs/SimpleCheckbox.tsx +1 -2
  44. package/src/components/layout/ServiceFormActions.tsx +1 -2
  45. package/src/components/layout/ServiceFormContainer/AccordionFormContainer/components/AccordionCollapseControls.tsx +1 -2
  46. package/src/components/layout/ServiceWizardStepper/components/CustomStepIcon.tsx +1 -2
  47. package/src/components/layout/ServiceWizardStepper/components/HorizontalStepperButton.tsx +1 -2
  48. package/src/components/overlays/BottomSheet/index.tsx +1 -1
  49. package/src/components/overlays/Drawer/Drawer.types.ts +32 -0
  50. package/src/components/overlays/Drawer/index.test.tsx +174 -0
  51. package/src/components/overlays/Drawer/index.tsx +192 -0
  52. package/src/components/overlays/Modal/index.tsx +6 -4
  53. package/src/i18n/namespaces/common/en.json +3 -0
  54. package/src/i18n/namespaces/common/lt.json +3 -0
  55. package/src/library/icons.ts +3 -100
  56. package/src/library/index.ts +2 -0
  57. package/src/library/types.ts +2 -0
  58. package/src/stories/atoms/Badge.stories.tsx +40 -0
  59. package/src/stories/atoms/Button.stories.tsx +1 -1
  60. package/src/stories/atoms/IconWithCircularBackground.stories.tsx +1 -1
  61. package/src/stories/atoms/IconWithSquareBackground.stories.tsx +1 -1
  62. package/src/stories/atoms/Icons.stories.tsx +134 -225
  63. package/src/stories/molecules/Card.stories.tsx +5 -3
  64. package/src/stories/molecules/CardShell.stories.tsx +1 -1
  65. package/src/stories/molecules/ImageCard.stories.tsx +1 -1
  66. package/src/stories/molecules/ListWithIcons.stories.tsx +1 -2
  67. package/src/stories/molecules/TitleBlock.stories.tsx +6 -3
  68. package/src/stories/organisms/AdvancedList.stories.tsx +6 -4
  69. package/src/stories/organisms/AdvancedListItem.stories.tsx +1 -3
  70. package/src/stories/organisms/AdvancedListItemShell.stories.tsx +93 -4
  71. package/src/stories/organisms/Drawer.stories.tsx +90 -0
  72. package/src/stories/organisms/SelectableCardList.stories.tsx +1 -3
  73. package/src/stories/organisms/ServiceLinks.stories.tsx +1 -1
  74. package/src/theme/light/MuiAccordionSummary.tsx +1 -1
  75. package/src/theme/light/MuiAlert.tsx +7 -5
  76. package/dist/assets/icons/ArrowLeftIcon.d.ts +0 -3
  77. package/dist/assets/icons/ArrowRightIcon.d.ts +0 -3
  78. package/dist/assets/icons/ArrowsClockwiseIcon.d.ts +0 -3
  79. package/dist/assets/icons/BarcodeIcon.d.ts +0 -3
  80. package/dist/assets/icons/CalendarBlankIcon.d.ts +0 -3
  81. package/dist/assets/icons/CaretDoubleLeftBoldIcon.d.ts +0 -3
  82. package/dist/assets/icons/CaretDoubleRightBoldIcon.d.ts +0 -3
  83. package/dist/assets/icons/CaretDownBoldIcon.d.ts +0 -3
  84. package/dist/assets/icons/CaretDownFill.d.ts +0 -3
  85. package/dist/assets/icons/CaretDownIcon.d.ts +0 -3
  86. package/dist/assets/icons/CaretLeftBoldIcon.d.ts +0 -3
  87. package/dist/assets/icons/CaretLeftIcon.d.ts +0 -3
  88. package/dist/assets/icons/CaretRightBoldIcon.d.ts +0 -3
  89. package/dist/assets/icons/CaretUpBoldIcon.d.ts +0 -3
  90. package/dist/assets/icons/CaretUpIcon.d.ts +0 -3
  91. package/dist/assets/icons/CheckBoldIcon.d.ts +0 -3
  92. package/dist/assets/icons/CheckCircleFillIcon.d.ts +0 -3
  93. package/dist/assets/icons/CheckIcon.d.ts +0 -3
  94. package/dist/assets/icons/CheckUncheckedBoldIcon.d.ts +0 -3
  95. package/dist/assets/icons/CircleFilledIcon.d.ts +0 -3
  96. package/dist/assets/icons/CloseIcon.d.ts +0 -3
  97. package/dist/assets/icons/CollapseChevronsIcon.d.ts +0 -3
  98. package/dist/assets/icons/CopyIcon.d.ts +0 -3
  99. package/dist/assets/icons/ExpandChevronsIcon.d.ts +0 -3
  100. package/dist/assets/icons/InfoFillIcon.d.ts +0 -3
  101. package/dist/assets/icons/ListIcon.d.ts +0 -3
  102. package/dist/assets/icons/MagnifyingGlassIcon.d.ts +0 -3
  103. package/dist/assets/icons/MapPinAreaIcon.d.ts +0 -3
  104. package/dist/assets/icons/MinusBoldIcon.d.ts +0 -3
  105. package/dist/assets/icons/MinusIcon.d.ts +0 -3
  106. package/dist/assets/icons/NotePencilIcon.d.ts +0 -3
  107. package/dist/assets/icons/PencilSimpleLineIcon.d.ts +0 -3
  108. package/dist/assets/icons/PlusBoldIcon.d.ts +0 -3
  109. package/dist/assets/icons/PlusIcon.d.ts +0 -3
  110. package/dist/assets/icons/QuestionFillIcon.d.ts +0 -3
  111. package/dist/assets/icons/QuestionIcon.d.ts +0 -3
  112. package/dist/assets/icons/ScalesIcon.d.ts +0 -3
  113. package/dist/assets/icons/ScrollIcon.d.ts +0 -3
  114. package/dist/assets/icons/ShoppingCartIcon.d.ts +0 -3
  115. package/dist/assets/icons/SpinnerGapBoldIcon.d.ts +0 -3
  116. package/dist/assets/icons/TrashIcon.d.ts +0 -3
  117. package/dist/assets/icons/UploadSimpleIcon.d.ts +0 -3
  118. package/dist/assets/icons/UserIcon.d.ts +0 -3
  119. package/dist/assets/icons/WarningCircleIcon.d.ts +0 -3
  120. package/dist/assets/icons/WarningDiamondFillIcon.d.ts +0 -3
  121. package/dist/assets/icons/WarningFillIcon.d.ts +0 -3
  122. package/dist/assets/icons/XCircleFillIcon.d.ts +0 -3
  123. package/src/assets/icons/ArrowLeftIcon.tsx +0 -16
  124. package/src/assets/icons/ArrowRightIcon.tsx +0 -17
  125. package/src/assets/icons/ArrowsClockwiseIcon.tsx +0 -16
  126. package/src/assets/icons/BarcodeIcon.tsx +0 -9
  127. package/src/assets/icons/CalendarBlankIcon.tsx +0 -9
  128. package/src/assets/icons/CaretDoubleLeftBoldIcon.tsx +0 -22
  129. package/src/assets/icons/CaretDoubleRightBoldIcon.tsx +0 -22
  130. package/src/assets/icons/CaretDownBoldIcon.tsx +0 -17
  131. package/src/assets/icons/CaretDownFill.tsx +0 -17
  132. package/src/assets/icons/CaretDownIcon.tsx +0 -9
  133. package/src/assets/icons/CaretLeftBoldIcon.tsx +0 -17
  134. package/src/assets/icons/CaretLeftIcon.tsx +0 -9
  135. package/src/assets/icons/CaretRightBoldIcon.tsx +0 -17
  136. package/src/assets/icons/CaretUpBoldIcon.tsx +0 -17
  137. package/src/assets/icons/CaretUpIcon.tsx +0 -9
  138. package/src/assets/icons/CheckBoldIcon.tsx +0 -17
  139. package/src/assets/icons/CheckCircleFillIcon.tsx +0 -23
  140. package/src/assets/icons/CheckIcon.tsx +0 -23
  141. package/src/assets/icons/CheckUncheckedBoldIcon.tsx +0 -9
  142. package/src/assets/icons/CircleFilledIcon.tsx +0 -11
  143. package/src/assets/icons/CloseIcon.tsx +0 -9
  144. package/src/assets/icons/CollapseChevronsIcon.tsx +0 -17
  145. package/src/assets/icons/CopyIcon.tsx +0 -23
  146. package/src/assets/icons/ExpandChevronsIcon.tsx +0 -17
  147. package/src/assets/icons/InfoFillIcon.tsx +0 -17
  148. package/src/assets/icons/ListIcon.tsx +0 -17
  149. package/src/assets/icons/MagnifyingGlassIcon.tsx +0 -9
  150. package/src/assets/icons/MapPinAreaIcon.tsx +0 -9
  151. package/src/assets/icons/MinusBoldIcon.tsx +0 -11
  152. package/src/assets/icons/MinusIcon.tsx +0 -9
  153. package/src/assets/icons/NotePencilIcon.tsx +0 -9
  154. package/src/assets/icons/PencilSimpleLineIcon.tsx +0 -23
  155. package/src/assets/icons/PlusBoldIcon.tsx +0 -11
  156. package/src/assets/icons/PlusIcon.tsx +0 -9
  157. package/src/assets/icons/QuestionFillIcon.tsx +0 -23
  158. package/src/assets/icons/QuestionIcon.tsx +0 -9
  159. package/src/assets/icons/ScalesIcon.tsx +0 -9
  160. package/src/assets/icons/ScrollIcon.tsx +0 -9
  161. package/src/assets/icons/ShoppingCartIcon.tsx +0 -16
  162. package/src/assets/icons/SpinnerGapBoldIcon.tsx +0 -17
  163. package/src/assets/icons/TrashIcon.tsx +0 -23
  164. package/src/assets/icons/UploadSimpleIcon.tsx +0 -9
  165. package/src/assets/icons/UserIcon.tsx +0 -17
  166. package/src/assets/icons/WarningCircleIcon.tsx +0 -22
  167. package/src/assets/icons/WarningDiamondFillIcon.tsx +0 -17
  168. package/src/assets/icons/WarningFillIcon.tsx +0 -22
  169. package/src/assets/icons/XCircleFillIcon.tsx +0 -17
@@ -4,8 +4,7 @@ import { UseControllerProps, useController } from 'react-hook-form'
4
4
  import { useTranslation } from 'react-i18next'
5
5
  import { v4 as uuidv4 } from 'uuid'
6
6
 
7
- import MinusBoldIcon from '@/assets/icons/MinusBoldIcon'
8
- import PlusBoldIcon from '@/assets/icons/PlusBoldIcon'
7
+ import { MinusBoldIcon, PlusBoldIcon } from '@/assets/icons/phosphorIcons'
9
8
  import palette from '@/theme/palette'
10
9
 
11
10
  import RcSesFormControlWrapper, {
@@ -3,7 +3,7 @@ import InputAdornment from '@mui/material/InputAdornment'
3
3
  import TextField from '@mui/material/TextField'
4
4
  import { useTranslation } from 'react-i18next'
5
5
 
6
- import MagnifyingGlassIcon from '@/assets/icons/MagnifyingGlassIcon'
6
+ import { MagnifyingGlassIcon } from '@/assets/icons/phosphorIcons'
7
7
  import palette from '@/theme/palette'
8
8
 
9
9
  function AutocompleteInput(props: AutocompleteRenderInputParams) {
@@ -19,7 +19,7 @@ import React, { useMemo } from 'react'
19
19
  import { UseControllerProps, useController } from 'react-hook-form'
20
20
  import { useTranslation } from 'react-i18next'
21
21
 
22
- import CaretDownFill from '@/assets/icons/CaretDownFill'
22
+ import { CaretDownFill } from '@/assets/icons/phosphorIcons'
23
23
  import '@/i18n/i18n'
24
24
  import theme from '@/theme/light'
25
25
  import palette from '@/theme/palette'
@@ -8,8 +8,7 @@ import { useController } from 'react-hook-form'
8
8
  import { useTranslation } from 'react-i18next'
9
9
  import { v4 as uuidv4 } from 'uuid'
10
10
 
11
- import MagnifyingGlassIcon from '@/assets/icons/MagnifyingGlassIcon'
12
- import XCircleFillIcon from '@/assets/icons/XCircleFillIcon'
11
+ import { MagnifyingGlassIcon, XCircleFillIcon } from '@/assets/icons/phosphorIcons'
13
12
  import RcSesButton from '@/components/common/Button'
14
13
  import RcSesFormControlWrapper, {
15
14
  RcSesFormControlWrapperProps,
@@ -8,8 +8,7 @@ import { useController } from 'react-hook-form'
8
8
  import { useTranslation } from 'react-i18next'
9
9
  import { v4 as uuidv4 } from 'uuid'
10
10
 
11
- import MagnifyingGlassIcon from '@/assets/icons/MagnifyingGlassIcon'
12
- import XCircleFillIcon from '@/assets/icons/XCircleFillIcon'
11
+ import { MagnifyingGlassIcon, XCircleFillIcon } from '@/assets/icons/phosphorIcons'
13
12
 
14
13
  import RcSesFormControlWrapper, {
15
14
  RcSesFormControlWrapperProps,
@@ -1,6 +1,6 @@
1
1
  import { Box } from '@mui/material'
2
2
 
3
- import CheckIcon from '@/assets/icons/CheckIcon'
3
+ import { CheckIcon } from '@/assets/icons/phosphorIcons'
4
4
  import palette from '@/theme/palette'
5
5
 
6
6
  interface Props {
@@ -5,8 +5,7 @@ import { FieldValues, UseControllerProps, useController } from 'react-hook-form'
5
5
  import { useTranslation } from 'react-i18next'
6
6
  import { v4 as uuidv4 } from 'uuid'
7
7
 
8
- import CaretDownIcon from '@/assets/icons/CaretDownIcon'
9
- import CheckIcon from '@/assets/icons/CheckIcon'
8
+ import { CaretDownIcon, CheckIcon } from '@/assets/icons/phosphorIcons'
10
9
  import RcSesBadge from '@/components/common/Badge'
11
10
  import palette from '@/theme/palette'
12
11
 
@@ -1,8 +1,7 @@
1
1
  import { Checkbox as MuiCheckbox, CheckboxProps as MuiCheckboxProps } from '@mui/material'
2
2
  import React from 'react'
3
3
 
4
- import CheckBoldIcon from '@/assets/icons/CheckBoldIcon'
5
- import CheckUncheckedBoldIcon from '@/assets/icons/CheckUncheckedBoldIcon'
4
+ import { CheckBoldIcon, CheckUncheckedBoldIcon } from '@/assets/icons/phosphorIcons'
6
5
  import getLoadingIcon from '@/components/utils/loading'
7
6
 
8
7
  export type SimpleCheckboxProps = MuiCheckboxProps & {
@@ -1,8 +1,7 @@
1
1
  import { Card, Grid } from '@mui/material'
2
2
  import { useTranslation } from 'react-i18next'
3
3
 
4
- import ArrowRightIcon from '@/assets/icons/ArrowRightIcon'
5
- import CaretLeftIcon from '@/assets/icons/CaretLeftIcon'
4
+ import { ArrowRightIcon, CaretLeftIcon } from '@/assets/icons/phosphorIcons'
6
5
  import Button from '@/components/common/Button'
7
6
  import palette from '@/theme/palette'
8
7
 
@@ -1,7 +1,6 @@
1
1
  import { Grid } from '@mui/material'
2
2
 
3
- import CollapseChevronsIcon from '@/assets/icons/CollapseChevronsIcon'
4
- import ExpandChevronsIcon from '@/assets/icons/ExpandChevronsIcon'
3
+ import { CollapseChevronsIcon, ExpandChevronsIcon } from '@/assets/icons/phosphorIcons'
5
4
  import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
6
5
  import Button from '@/components/common/Button'
7
6
 
@@ -1,8 +1,7 @@
1
1
  import { StepIconProps } from '@mui/material'
2
2
 
3
- import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
4
- import CircleFilledIcon from '@/assets/icons/CircleFilledIcon'
5
3
  import DotCircleFilledIcon from '@/assets/icons/DotCircleFilledIcon'
4
+ import { CheckCircleFillIcon, CircleFilledIcon } from '@/assets/icons/phosphorIcons'
6
5
  import palette from '@/theme/palette'
7
6
 
8
7
  const CustomStepIcon = ({ active, completed, className, style }: StepIconProps) => {
@@ -1,7 +1,6 @@
1
1
  import { Button, ButtonProps } from '@mui/material'
2
2
 
3
- import CaretLeftIcon from '@/assets/icons/CaretLeftIcon'
4
- import CaretRightBoldIcon from '@/assets/icons/CaretRightBoldIcon'
3
+ import { CaretLeftIcon, CaretRightBoldIcon } from '@/assets/icons/phosphorIcons'
5
4
  import palette from '@/theme/palette'
6
5
 
7
6
  type Props = ButtonProps & {
@@ -17,7 +17,7 @@ import {
17
17
  } from 'react'
18
18
  import { useTranslation } from 'react-i18next'
19
19
 
20
- import ArrowLeftIcon from '@/assets/icons/ArrowLeftIcon'
20
+ import { ArrowLeftIcon } from '@/assets/icons/phosphorIcons'
21
21
  import usePrefersReducedMotion from '@/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion'
22
22
  import RcSesButton from '@/components/common/Button'
23
23
  import { grey } from '@/theme/palette'
@@ -0,0 +1,32 @@
1
+ import { ReactNode } from 'react'
2
+
3
+ export interface RcSesDrawerTestIds {
4
+ root?: string
5
+ header?: string
6
+ closeButton?: string
7
+ body?: string
8
+ footer?: string
9
+ }
10
+
11
+ export interface RcSesDrawerProps {
12
+ /** Whether the drawer is open */
13
+ isOpen: boolean
14
+ /** Callback fired when the drawer should close */
15
+ onClose: () => void
16
+ /** Drawer title displayed in header */
17
+ title: ReactNode
18
+ /** Main content of the drawer (scrollable body) */
19
+ children: ReactNode
20
+ /** Label for the secondary (left) action button */
21
+ secondaryActionLabel?: string
22
+ /** Callback fired when secondary action button is clicked */
23
+ onSecondaryAction?: () => void
24
+ /** Label for the primary (right) action button */
25
+ primaryActionLabel?: string
26
+ /** Callback fired when primary action button is clicked */
27
+ onPrimaryAction?: () => void
28
+ /** Test IDs for testing */
29
+ testIds?: RcSesDrawerTestIds
30
+ /** Optional CSS class name */
31
+ className?: string
32
+ }
@@ -0,0 +1,174 @@
1
+ import { fireEvent, render, screen } from '@testing-library/react'
2
+ import { describe, expect, it, vi } from 'vitest'
3
+
4
+ import RcSesDrawer from '.'
5
+
6
+ describe('RcSesDrawer', () => {
7
+ it('renders when isOpen is true', () => {
8
+ render(
9
+ <RcSesDrawer isOpen title='Test Drawer' onClose={vi.fn()}>
10
+ Test content
11
+ </RcSesDrawer>,
12
+ )
13
+
14
+ expect(screen.getByText('Test Drawer')).toBeInTheDocument()
15
+ expect(screen.getByText('Test content')).toBeInTheDocument()
16
+ })
17
+
18
+ it('does not display when isOpen is false', () => {
19
+ render(
20
+ <RcSesDrawer isOpen={false} title='Test Drawer' onClose={vi.fn()}>
21
+ Test content
22
+ </RcSesDrawer>,
23
+ )
24
+
25
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
26
+ })
27
+
28
+ it('calls onClose when close button is clicked', () => {
29
+ const onClose = vi.fn()
30
+ render(
31
+ <RcSesDrawer
32
+ isOpen
33
+ title='Test Drawer'
34
+ onClose={onClose}
35
+ testIds={{ closeButton: 'test-close-btn' }}
36
+ >
37
+ Test content
38
+ </RcSesDrawer>,
39
+ )
40
+
41
+ const closeButton = screen.getByTestId('test-close-btn')
42
+ fireEvent.click(closeButton)
43
+
44
+ expect(onClose).toHaveBeenCalledTimes(1)
45
+ })
46
+
47
+ it('calls onClose when backdrop is clicked', () => {
48
+ const onClose = vi.fn()
49
+ render(
50
+ <RcSesDrawer isOpen title='Test Drawer' onClose={onClose}>
51
+ Test content
52
+ </RcSesDrawer>,
53
+ )
54
+
55
+ const backdrop = document.querySelector('.MuiBackdrop-root') as Element
56
+ fireEvent.click(backdrop)
57
+ expect(onClose).toHaveBeenCalledTimes(1)
58
+ })
59
+
60
+ it('calls onClose when Escape key is pressed', () => {
61
+ const onClose = vi.fn()
62
+ render(
63
+ <RcSesDrawer isOpen title='Test Drawer' onClose={onClose}>
64
+ Test content
65
+ </RcSesDrawer>,
66
+ )
67
+
68
+ const dialog = screen.getByRole('dialog')
69
+ fireEvent.keyDown(dialog, { key: 'Escape' })
70
+ expect(onClose).toHaveBeenCalledTimes(1)
71
+ })
72
+
73
+ it('renders footer when action labels are provided', () => {
74
+ render(
75
+ <RcSesDrawer
76
+ isOpen
77
+ title='Test Drawer'
78
+ onClose={vi.fn()}
79
+ secondaryActionLabel='Cancel'
80
+ primaryActionLabel='Apply'
81
+ >
82
+ Test content
83
+ </RcSesDrawer>,
84
+ )
85
+
86
+ expect(screen.getByText('Cancel')).toBeInTheDocument()
87
+ expect(screen.getByText('Apply')).toBeInTheDocument()
88
+ })
89
+
90
+ it('does not render footer when no action labels are provided', () => {
91
+ render(
92
+ <RcSesDrawer isOpen title='Test Drawer' onClose={vi.fn()}>
93
+ Test content
94
+ </RcSesDrawer>,
95
+ )
96
+
97
+ expect(
98
+ screen.queryByRole('button', { name: /cancel|apply/i }),
99
+ ).not.toBeInTheDocument()
100
+ })
101
+
102
+ it('calls onPrimaryAction when primary button is clicked', () => {
103
+ const onPrimaryAction = vi.fn()
104
+ render(
105
+ <RcSesDrawer
106
+ isOpen
107
+ title='Test Drawer'
108
+ onClose={vi.fn()}
109
+ primaryActionLabel='Apply'
110
+ onPrimaryAction={onPrimaryAction}
111
+ >
112
+ Test content
113
+ </RcSesDrawer>,
114
+ )
115
+
116
+ fireEvent.click(screen.getByText('Apply'))
117
+
118
+ expect(onPrimaryAction).toHaveBeenCalledTimes(1)
119
+ })
120
+
121
+ it('calls onSecondaryAction when secondary button is clicked', () => {
122
+ const onSecondaryAction = vi.fn()
123
+ render(
124
+ <RcSesDrawer
125
+ isOpen
126
+ title='Test Drawer'
127
+ onClose={vi.fn()}
128
+ secondaryActionLabel='Cancel'
129
+ onSecondaryAction={onSecondaryAction}
130
+ >
131
+ Test content
132
+ </RcSesDrawer>,
133
+ )
134
+
135
+ fireEvent.click(screen.getByText('Cancel'))
136
+
137
+ expect(onSecondaryAction).toHaveBeenCalledTimes(1)
138
+ })
139
+
140
+ it('has proper ARIA attributes', () => {
141
+ render(
142
+ <RcSesDrawer isOpen title='Test Drawer' onClose={vi.fn()}>
143
+ Test content
144
+ </RcSesDrawer>,
145
+ )
146
+
147
+ const dialog = screen.getByRole('dialog')
148
+ expect(dialog).toHaveAttribute('aria-modal', 'true')
149
+ })
150
+
151
+ it('renders with testIds', () => {
152
+ render(
153
+ <RcSesDrawer
154
+ isOpen
155
+ title='Test Drawer'
156
+ onClose={vi.fn()}
157
+ testIds={{
158
+ root: 'test-drawer-root',
159
+ header: 'test-drawer-header',
160
+ body: 'test-drawer-body',
161
+ footer: 'test-drawer-footer',
162
+ closeButton: 'test-drawer-close',
163
+ }}
164
+ >
165
+ Test content
166
+ </RcSesDrawer>,
167
+ )
168
+
169
+ expect(screen.getByTestId('test-drawer-root')).toBeInTheDocument()
170
+ expect(screen.getByTestId('test-drawer-header')).toBeInTheDocument()
171
+ expect(screen.getByTestId('test-drawer-body')).toBeInTheDocument()
172
+ expect(screen.getByTestId('test-drawer-close')).toBeInTheDocument()
173
+ })
174
+ })
@@ -0,0 +1,192 @@
1
+ import {
2
+ Box,
3
+ Fade,
4
+ Dialog as MuiDialog,
5
+ Slide,
6
+ SlideProps,
7
+ Typography,
8
+ } from '@mui/material'
9
+ import { forwardRef, useId } from 'react'
10
+ import { useTranslation } from 'react-i18next'
11
+
12
+ import { CloseIcon } from '@/assets/icons/phosphorIcons'
13
+ import usePrefersReducedMotion from '@/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion'
14
+ import RcSesButton from '@/components/common/Button'
15
+
16
+ import { RcSesDrawerProps, RcSesDrawerTestIds } from './Drawer.types'
17
+
18
+ const DRAWER_WIDTH = 440
19
+ const ANIMATION_DURATION = 250
20
+ const BACKDROP_OPACITY = 0.5
21
+
22
+ /**
23
+ * SlideLeftTransition - Wrapper for Slide component with direction='left'
24
+ * Allows type-safe usage without 'as any' cast
25
+ */
26
+ const SlideLeftTransition = forwardRef<HTMLDivElement, SlideProps>((props, ref) => (
27
+ <Slide ref={ref} direction='left' {...props} />
28
+ ))
29
+
30
+ /**
31
+ * RcSesDrawer component - a slide-over panel that slides in from the right.
32
+ * Built on MUI Dialog for proper focus management, scroll locking, and DOM handling.
33
+ * Composition: Header (title + close button), scrollable body, and optional footer.
34
+ */
35
+ const RcSesDrawer = ({
36
+ isOpen,
37
+ onClose,
38
+ title,
39
+ children,
40
+ secondaryActionLabel,
41
+ onSecondaryAction,
42
+ primaryActionLabel,
43
+ onPrimaryAction,
44
+ testIds,
45
+ className,
46
+ }: RcSesDrawerProps) => {
47
+ const prefersReducedMotion = usePrefersReducedMotion()
48
+ const { t } = useTranslation('common', { keyPrefix: 'components.Drawer' })
49
+ const headerId = useId()
50
+
51
+ const handleClose = () => {
52
+ onClose()
53
+ }
54
+
55
+ return (
56
+ <MuiDialog
57
+ open={isOpen}
58
+ onClose={handleClose}
59
+ aria-labelledby={headerId}
60
+ maxWidth={false}
61
+ transitionDuration={prefersReducedMotion ? 0 : ANIMATION_DURATION}
62
+ sx={{
63
+ '& .MuiDialog-container': {
64
+ height: '100vh',
65
+ minHeight: '100vh',
66
+ },
67
+ }}
68
+ slots={{
69
+ transition: prefersReducedMotion ? Fade : SlideLeftTransition,
70
+ }}
71
+ slotProps={{
72
+ transition: {
73
+ appear: true,
74
+ },
75
+ backdrop: {
76
+ sx: {
77
+ backgroundColor: `rgba(0, 0, 0, ${BACKDROP_OPACITY})`,
78
+ },
79
+ },
80
+ container: {
81
+ sx: {
82
+ display: 'flex',
83
+ justifyContent: 'flex-end',
84
+ alignItems: 'stretch',
85
+ width: '100%',
86
+ margin: 0,
87
+ padding: 0,
88
+ },
89
+ },
90
+ paper: {
91
+ sx: {
92
+ margin: 0,
93
+ padding: 0,
94
+ width: DRAWER_WIDTH,
95
+ maxWidth: DRAWER_WIDTH,
96
+ flex: '1 1 auto',
97
+ minHeight: '100vh',
98
+ borderRadius: 0,
99
+ boxShadow: '-4px 0 24px rgba(0, 0, 0, 0.18)',
100
+ backgroundColor: (theme) => theme.palette.common.white,
101
+ },
102
+ },
103
+ }}
104
+ >
105
+ <Box
106
+ data-testid={testIds?.root}
107
+ className={className}
108
+ sx={{
109
+ display: 'flex',
110
+ flexDirection: 'column',
111
+ height: '100%',
112
+ width: '100%',
113
+ }}
114
+ >
115
+ <Box
116
+ data-testid={testIds?.header}
117
+ sx={{
118
+ display: 'flex',
119
+ alignItems: 'center',
120
+ justifyContent: 'space-between',
121
+ padding: '1.25rem 1rem 1rem 1.5rem',
122
+ borderBottom: (theme) => `1px solid ${theme.palette.grey[200]}`,
123
+ flexShrink: 0,
124
+ gap: '1rem',
125
+ }}
126
+ >
127
+ <Typography
128
+ id={headerId}
129
+ component='h2'
130
+ sx={{
131
+ fontSize: '14px',
132
+ fontStyle: 'normal',
133
+ fontWeight: 600,
134
+ lineHeight: '20px',
135
+ }}
136
+ >
137
+ {title}
138
+ </Typography>
139
+ <RcSesButton
140
+ variant='link'
141
+ onClick={handleClose}
142
+ data-testid={testIds?.closeButton}
143
+ sx={{ flexShrink: 0, width: '2.75rem', height: '2.75rem' }}
144
+ aria-label={t('closeDrawer')}
145
+ >
146
+ <CloseIcon size={24} />
147
+ </RcSesButton>
148
+ </Box>
149
+
150
+ <Box
151
+ data-testid={testIds?.body}
152
+ sx={{
153
+ flex: 1,
154
+ overflowY: 'auto',
155
+ padding: '1rem 1.5rem',
156
+ backgroundColor: (theme) => theme.palette.grey[50],
157
+ }}
158
+ >
159
+ {children}
160
+ </Box>
161
+
162
+ {(secondaryActionLabel || primaryActionLabel) && (
163
+ <Box
164
+ data-testid={testIds?.footer}
165
+ sx={{
166
+ padding: '1rem 1.5rem',
167
+ borderTop: (theme) => `1px solid ${theme.palette.grey[200]}`,
168
+ flexShrink: 0,
169
+ display: 'flex',
170
+ alignItems: 'center',
171
+ justifyContent: secondaryActionLabel ? 'space-between' : 'flex-end',
172
+ }}
173
+ >
174
+ {secondaryActionLabel && (
175
+ <RcSesButton variant='link' onClick={onSecondaryAction}>
176
+ {secondaryActionLabel}
177
+ </RcSesButton>
178
+ )}
179
+ {primaryActionLabel && (
180
+ <RcSesButton variant='contained' onClick={onPrimaryAction}>
181
+ {primaryActionLabel}
182
+ </RcSesButton>
183
+ )}
184
+ </Box>
185
+ )}
186
+ </Box>
187
+ </MuiDialog>
188
+ )
189
+ }
190
+
191
+ export default RcSesDrawer
192
+ export type { RcSesDrawerProps, RcSesDrawerTestIds }
@@ -2,10 +2,12 @@ import { Button, Typography } from '@mui/material'
2
2
  import { ReactNode } from 'react'
3
3
  import { useTranslation } from 'react-i18next'
4
4
 
5
- import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
6
- import InfoFillIcon from '@/assets/icons/InfoFillIcon'
7
- import QuestionFillIcon from '@/assets/icons/QuestionFillIcon'
8
- import WarningFillIcon from '@/assets/icons/WarningFillIcon'
5
+ import {
6
+ CheckCircleFillIcon,
7
+ InfoFillIcon,
8
+ QuestionFillIcon,
9
+ WarningFillIcon,
10
+ } from '@/assets/icons/phosphorIcons'
9
11
  import palette from '@/theme/palette'
10
12
 
11
13
  import RcSesDialog, { RcSesDialogProps } from '../Dialog'
@@ -39,6 +39,9 @@
39
39
  "RcSesSideNav": {
40
40
  "title": "Topics",
41
41
  "itemLabel": "{{label}}, {{count}}"
42
+ },
43
+ "Drawer": {
44
+ "closeDrawer": "Close drawer"
42
45
  }
43
46
  }
44
47
  }
@@ -39,6 +39,9 @@
39
39
  "RcSesSideNav": {
40
40
  "title": "Temos",
41
41
  "itemLabel": "{{label}}, {{count}}"
42
+ },
43
+ "Drawer": {
44
+ "closeDrawer": "Uždaryti"
42
45
  }
43
46
  }
44
47
  }