@registrucentras/rc-ses-react-components 1.6.6 → 1.7.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 (62) hide show
  1. package/dist/assets/icons/SearchHelpIcon.d.ts +3 -0
  2. package/dist/assets/icons/SearchXIcon.d.ts +3 -0
  3. package/dist/components/common/Breadcrumbs/index.d.ts +3 -1
  4. package/dist/components/common/Snackbar/SnackbarProvider.d.ts +22 -0
  5. package/dist/components/common/Snackbar/config.d.ts +21 -0
  6. package/dist/components/common/Snackbar/index.d.ts +16 -0
  7. package/dist/components/common/Snackbar/types.d.ts +2 -0
  8. package/dist/components/form/inputs/CheckboxFormControl.d.ts +2 -0
  9. package/dist/components/form/inputs/FormControlLabel.d.ts +10 -0
  10. package/dist/components/form/inputs/SimpleCheckbox.d.ts +6 -0
  11. package/dist/components/layout/ServiceHeader.d.ts +2 -1
  12. package/dist/components/utils/loading.d.ts +3 -0
  13. package/dist/library/icons.d.ts +4 -1
  14. package/dist/library/index.d.ts +9 -2
  15. package/dist/library/types.d.ts +3 -1
  16. package/dist/registrucentras-rc-ses-react-components.cjs +9 -26
  17. package/dist/registrucentras-rc-ses-react-components.js +3155 -2755
  18. package/dist/stories/components/actions/Button.stories.d.ts +5 -0
  19. package/dist/stories/components/{SelectableCardList.stories.d.ts → display/SelectableCardList.stories.d.ts} +1 -1
  20. package/dist/stories/components/feedback/Snackbar.stories.d.ts +143 -0
  21. package/dist/stories/components/form/CheckboxFormControl.stories.d.ts +3 -0
  22. package/dist/stories/components/form/SimpleCheckbox.stories.d.ts +19 -0
  23. package/dist/stories/components/layout/ServiceHeader.stories.d.ts +1 -0
  24. package/dist/theme/light/index.d.ts +6 -0
  25. package/dist/theme/palette.d.ts +9 -1
  26. package/package.json +1 -1
  27. package/src/assets/icons/CheckIcon.tsx +1 -1
  28. package/src/assets/icons/SearchHelpIcon.tsx +44 -0
  29. package/src/assets/icons/SearchXIcon.tsx +41 -0
  30. package/src/components/common/Breadcrumbs/index.tsx +4 -3
  31. package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +5 -3
  32. package/src/components/common/ListWithIcons/index.tsx +1 -1
  33. package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +3 -1
  34. package/src/components/common/Snackbar/SnackbarProvider.tsx +78 -0
  35. package/src/components/common/Snackbar/config.ts +77 -0
  36. package/src/components/common/Snackbar/index.test.tsx +119 -0
  37. package/src/components/common/Snackbar/index.tsx +181 -0
  38. package/src/components/common/Snackbar/types.ts +2 -0
  39. package/src/components/form/inputs/Checkbox.tsx +2 -2
  40. package/src/components/form/inputs/CheckboxFormControl.test.tsx +68 -0
  41. package/src/components/form/inputs/CheckboxFormControl.tsx +48 -29
  42. package/src/components/form/inputs/FormControlLabel.tsx +36 -0
  43. package/src/components/form/inputs/SimpleCheckbox.tsx +23 -0
  44. package/src/components/layout/ServiceHeader.tsx +22 -8
  45. package/src/components/utils/loading.tsx +9 -0
  46. package/src/i18n/namespaces/input/en.json +6 -0
  47. package/src/i18n/namespaces/input/lt.json +6 -0
  48. package/src/library/icons.ts +6 -0
  49. package/src/library/index.ts +13 -1
  50. package/src/library/types.ts +9 -1
  51. package/src/stories/Colors.mdx +127 -0
  52. package/src/stories/components/actions/Button.stories.tsx +130 -0
  53. package/src/stories/components/{SelectableCardList.stories.tsx → display/SelectableCardList.stories.tsx} +36 -19
  54. package/src/stories/components/feedback/Snackbar.stories.tsx +504 -0
  55. package/src/stories/components/form/CheckboxFormControl.stories.tsx +312 -2
  56. package/src/stories/components/form/SimpleCheckbox.stories.tsx +52 -0
  57. package/src/stories/components/icons/Icons.stories.tsx +35 -0
  58. package/src/stories/components/layout/ServiceHeader.stories.tsx +43 -8
  59. package/src/theme/light/MuiButton.tsx +34 -1
  60. package/src/theme/light/index.tsx +6 -0
  61. package/src/theme/light/themePalette.tsx +2 -0
  62. package/src/theme/palette.tsx +11 -1
@@ -73,3 +73,8 @@ export declare const WarningContained: Story;
73
73
  export declare const WarningOutlined: Story;
74
74
  export declare const ErrorContained: Story;
75
75
  export declare const ErrorOutlined: Story;
76
+ export declare const LightOutlined: Story;
77
+ export declare const LightOutlinedWithIcon: Story;
78
+ export declare const LightOutlinedDisabled: Story;
79
+ export declare const GhostOutlinedIconOnly: Story;
80
+ export declare const GhostOutlinedIconOnlyDisabled: Story;
@@ -1,5 +1,5 @@
1
1
  import { StoryObj } from '@storybook/react';
2
- import { SelectableCardListItemData, SelectableCardListProps } from '../../components/common/SelectableCardList';
2
+ import { SelectableCardListItemData, SelectableCardListProps } from '../../../components/common/SelectableCardList';
3
3
  declare const meta: {
4
4
  title: string;
5
5
  component: ({ items, selectedId, onSelect, error, }: SelectableCardListProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,143 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { default as RcSesSnackbar } from '../../../components/common/Snackbar';
3
+ declare const meta: Meta<typeof RcSesSnackbar>;
4
+ export default meta;
5
+ export declare const Default: {
6
+ render: (args: any) => import("react/jsx-runtime").JSX.Element;
7
+ args: {
8
+ open: boolean;
9
+ state: string;
10
+ message: string;
11
+ size: string;
12
+ actionLabel: string;
13
+ duration: number;
14
+ persist: boolean;
15
+ showClose: boolean;
16
+ dismissOnAction: boolean;
17
+ };
18
+ argTypes: {
19
+ open: {
20
+ control: string;
21
+ description: string;
22
+ };
23
+ state: {
24
+ control: string;
25
+ options: string[];
26
+ description: string;
27
+ };
28
+ message: {
29
+ control: string;
30
+ description: string;
31
+ };
32
+ size: {
33
+ control: string;
34
+ options: string[];
35
+ description: string;
36
+ };
37
+ duration: {
38
+ control: {
39
+ type: string;
40
+ min: number;
41
+ max: number;
42
+ step: number;
43
+ };
44
+ description: string;
45
+ };
46
+ persist: {
47
+ control: string;
48
+ description: string;
49
+ };
50
+ showClose: {
51
+ control: string;
52
+ description: string;
53
+ };
54
+ dismissOnAction: {
55
+ control: string;
56
+ description: string;
57
+ };
58
+ actionLabel: {
59
+ control: string;
60
+ description: string;
61
+ };
62
+ onAction: {
63
+ action: string;
64
+ description: string;
65
+ };
66
+ onClose: {
67
+ action: string;
68
+ description: string;
69
+ };
70
+ };
71
+ parameters: {
72
+ docs: {
73
+ description: {
74
+ story: string;
75
+ };
76
+ };
77
+ };
78
+ };
79
+ export declare const CompactWithText: {
80
+ render: () => import("react/jsx-runtime").JSX.Element;
81
+ parameters: {
82
+ docs: {
83
+ description: {
84
+ story: string;
85
+ };
86
+ source: {
87
+ code: string;
88
+ };
89
+ };
90
+ };
91
+ };
92
+ export declare const StandardWithButtons: {
93
+ render: () => import("react/jsx-runtime").JSX.Element;
94
+ parameters: {
95
+ docs: {
96
+ description: {
97
+ story: string;
98
+ };
99
+ source: {
100
+ code: string;
101
+ };
102
+ };
103
+ };
104
+ };
105
+ export declare const CustomDuration: {
106
+ render: () => import("react/jsx-runtime").JSX.Element;
107
+ parameters: {
108
+ docs: {
109
+ description: {
110
+ story: string;
111
+ };
112
+ source: {
113
+ code: string;
114
+ };
115
+ };
116
+ };
117
+ };
118
+ export declare const Persistent: {
119
+ render: () => import("react/jsx-runtime").JSX.Element;
120
+ parameters: {
121
+ docs: {
122
+ description: {
123
+ story: string;
124
+ };
125
+ source: {
126
+ code: string;
127
+ };
128
+ };
129
+ };
130
+ };
131
+ export declare const LongText: {
132
+ render: () => import("react/jsx-runtime").JSX.Element;
133
+ parameters: {
134
+ docs: {
135
+ description: {
136
+ story: string;
137
+ };
138
+ source: {
139
+ code: string;
140
+ };
141
+ };
142
+ };
143
+ };
@@ -4,3 +4,6 @@ declare const meta: Meta<typeof RcSesCheckboxFormControl>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof RcSesCheckboxFormControl>;
6
6
  export declare const Main: Story;
7
+ export declare const Loading: Story;
8
+ export declare const Indeterminate: Story;
9
+ export declare const ParentChildLogicLoading: Story;
@@ -0,0 +1,19 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as SimpleCheckbox } from '../../../components/form/inputs/SimpleCheckbox';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof SimpleCheckbox;
6
+ parameters: {
7
+ layout: string;
8
+ docs: {
9
+ description: {
10
+ component: string;
11
+ };
12
+ };
13
+ };
14
+ tags: string[];
15
+ };
16
+ export default meta;
17
+ type Story = StoryObj<typeof meta>;
18
+ export declare const Basic: Story;
19
+ export declare const Loading: Story;
@@ -4,3 +4,4 @@ declare const meta: Meta<typeof RcSesServiceHeader>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
6
6
  export declare const Default: Story;
7
+ export declare const WhiteBackground: Story;
@@ -3,10 +3,14 @@ declare module '@mui/material/styles' {
3
3
  interface Palette {
4
4
  dark: Palette['grey'];
5
5
  grey: Palette['grey'];
6
+ light: Palette['grey'];
7
+ ghost: Palette['grey'];
6
8
  }
7
9
  interface PaletteOptions {
8
10
  dark?: PaletteOptions['grey'];
9
11
  grey?: PaletteOptions['grey'];
12
+ light?: PaletteOptions['grey'];
13
+ ghost?: PaletteOptions['grey'];
10
14
  }
11
15
  }
12
16
  declare module '@mui/material' {
@@ -24,6 +28,8 @@ declare module '@mui/material' {
24
28
  interface ButtonPropsColorOverrides {
25
29
  grey: any;
26
30
  dark: any;
31
+ light: any;
32
+ ghost: any;
27
33
  }
28
34
  interface RadioPropsColorOverrides {
29
35
  grey: true;
@@ -68,7 +68,15 @@ declare const error: {
68
68
  '950': string;
69
69
  main: string;
70
70
  };
71
- export { primary, secondary, grey, warning, error };
71
+ declare const overlays: {
72
+ '200': string;
73
+ '300': string;
74
+ main: string;
75
+ };
76
+ declare const common: {
77
+ white: string;
78
+ };
79
+ export { primary, secondary, grey, warning, error, overlays, common };
72
80
  declare const _default: {
73
81
  primary: {
74
82
  '50': string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@registrucentras/rc-ses-react-components",
3
3
  "author": "VĮ REGISTRŲ CENTRAS",
4
- "version": "1.6.6",
4
+ "version": "1.7.0",
5
5
  "description": "RC SES React komponentų biblioteka",
6
6
  "type": "module",
7
7
  "private": false,
@@ -6,7 +6,7 @@ function CheckIcon({
6
6
  className,
7
7
  fillColor,
8
8
  size = 24,
9
- weight = 'fill',
9
+ weight = 'regular',
10
10
  ...rest
11
11
  }: IconProps) {
12
12
  return (
@@ -0,0 +1,44 @@
1
+ import {
2
+ MagnifyingGlassIcon as MagnifyingGlass,
3
+ QuestionMarkIcon,
4
+ } from '@phosphor-icons/react'
5
+
6
+ import IconProps from '../IconProps'
7
+
8
+ function SearchHelpIcon({ className, size = 24, fillColor, ...rest }: IconProps) {
9
+ const innerSize = Math.round(size * 0.45)
10
+
11
+ return (
12
+ <span
13
+ className={className}
14
+ style={{
15
+ display: 'inline-flex',
16
+ height: size,
17
+ position: 'relative',
18
+ verticalAlign: 'middle',
19
+ width: size,
20
+ }}
21
+ >
22
+ <MagnifyingGlass
23
+ {...rest}
24
+ size={size}
25
+ color={fillColor}
26
+ style={{ position: 'absolute', inset: 0 }}
27
+ />
28
+ <QuestionMarkIcon
29
+ aria-hidden='true'
30
+ size={innerSize}
31
+ weight='bold'
32
+ color={fillColor}
33
+ style={{
34
+ left: '44.5%',
35
+ position: 'absolute',
36
+ top: '43%',
37
+ transform: 'translate(-50%, -50%)',
38
+ }}
39
+ />
40
+ </span>
41
+ )
42
+ }
43
+
44
+ export default SearchHelpIcon
@@ -0,0 +1,41 @@
1
+ import { MagnifyingGlassIcon as MagnifyingGlass, XIcon } from '@phosphor-icons/react'
2
+
3
+ import IconProps from '../IconProps'
4
+
5
+ function SearchXIcon({ className, size = 24, fillColor, ...rest }: IconProps) {
6
+ const innerSize = Math.round(size * 0.45)
7
+
8
+ return (
9
+ <span
10
+ className={className}
11
+ style={{
12
+ display: 'inline-flex',
13
+ height: size,
14
+ position: 'relative',
15
+ verticalAlign: 'middle',
16
+ width: size,
17
+ }}
18
+ >
19
+ <MagnifyingGlass
20
+ {...rest}
21
+ size={size}
22
+ color={fillColor}
23
+ style={{ position: 'absolute', inset: 0 }}
24
+ />
25
+ <XIcon
26
+ aria-hidden='true'
27
+ size={innerSize}
28
+ weight='bold'
29
+ color={fillColor}
30
+ style={{
31
+ left: '44.5%',
32
+ position: 'absolute',
33
+ top: '43%',
34
+ transform: 'translate(-50%, -50%)',
35
+ }}
36
+ />
37
+ </span>
38
+ )
39
+ }
40
+
41
+ export default SearchXIcon
@@ -1,14 +1,15 @@
1
- import { Link, Breadcrumbs as MuiBreadcrumbs } from '@mui/material'
1
+ import { Link, Breadcrumbs as MuiBreadcrumbs, SxProps, Theme } from '@mui/material'
2
2
 
3
3
  export type BreadcrumbItem = { label: string; path: string }
4
4
 
5
5
  type Props = {
6
6
  path: BreadcrumbItem[]
7
+ sx?: SxProps<Theme>
7
8
  }
8
9
 
9
- function RcSesBreadcrumbs({ path }: Props) {
10
+ function RcSesBreadcrumbs({ path, sx }: Props) {
10
11
  return (
11
- <MuiBreadcrumbs>
12
+ <MuiBreadcrumbs sx={sx}>
12
13
  {path.map((step) => (
13
14
  <Link key={step.path} underline='hover' color='inherit' href={step.path}>
14
15
  {step.label}
@@ -27,9 +27,11 @@ const ListWithIconsItem = ({
27
27
  maxWidth: { xs: '100%', md: 'none' },
28
28
  }}
29
29
  >
30
- <Box sx={{ display: 'flex', alignItems: 'center' }}>
31
- {Icon && <Icon fillColor={textColor ?? palette.grey[600]} size={16} />}
32
- </Box>
30
+ {Icon && (
31
+ <Box sx={{ display: 'flex', alignItems: 'center' }}>
32
+ <Icon fillColor={textColor ?? palette.grey[600]} size={16} />
33
+ </Box>
34
+ )}
33
35
  <Typography
34
36
  variant='body2'
35
37
  sx={{
@@ -31,7 +31,7 @@ const ListWithIcons = ({
31
31
  flexWrap: layout === 'horizontal' ? 'wrap' : 'nowrap',
32
32
  gap: {
33
33
  xs: '0.25rem',
34
- md: layout === 'horizontal' ? '1rem' : '0.5rem',
34
+ md: layout === 'horizontal' ? '0.25rem 1rem' : '0.5rem',
35
35
  },
36
36
  }}
37
37
  >
@@ -98,7 +98,9 @@ const SelectableCardListItem = ({
98
98
  },
99
99
  }}
100
100
  >
101
- <ListWithIcons items={listItems} layout='horizontal' isLoading={isLoading} />
101
+ {(isLoading || (!!listItems && listItems.length > 0)) && (
102
+ <ListWithIcons items={listItems} layout='horizontal' isLoading={isLoading} />
103
+ )}
102
104
  </RcSesCard>
103
105
  )
104
106
  }
@@ -0,0 +1,78 @@
1
+ import {
2
+ ReactNode,
3
+ createContext,
4
+ useCallback,
5
+ useContext,
6
+ useMemo,
7
+ useState,
8
+ } from 'react'
9
+
10
+ import RcSesSnackbar from './index'
11
+ import { type SnackbarSize, type SnackbarState } from './types'
12
+
13
+ export interface SnackbarConfig {
14
+ state: SnackbarState
15
+ message: string
16
+ size?: SnackbarSize
17
+ onAction?: () => void
18
+ actionLabel?: string
19
+ duration?: number
20
+ persist?: boolean
21
+ dismissOnAction?: boolean
22
+ showClose?: boolean
23
+ }
24
+
25
+ interface SnackbarContextType {
26
+ showSnackbar: (config: SnackbarConfig) => void
27
+ hideSnackbar: () => void
28
+ }
29
+
30
+ const SnackbarContext = createContext<SnackbarContextType | undefined>(undefined)
31
+
32
+ export function RcSesSnackbarProvider({ children }: { children: ReactNode }) {
33
+ const [snackbar, setSnackbar] = useState<SnackbarConfig | null>(null)
34
+
35
+ const showSnackbar = useCallback((config: SnackbarConfig) => {
36
+ setSnackbar(config)
37
+ }, [])
38
+
39
+ const hideSnackbar = useCallback(() => {
40
+ setSnackbar(null)
41
+ }, [])
42
+
43
+ const value = useMemo(
44
+ () => ({ showSnackbar, hideSnackbar }),
45
+ [showSnackbar, hideSnackbar],
46
+ )
47
+
48
+ return (
49
+ <SnackbarContext.Provider value={value}>
50
+ {children}
51
+ {snackbar && (
52
+ <RcSesSnackbar
53
+ state={snackbar.state}
54
+ message={snackbar.message}
55
+ size={snackbar.size}
56
+ onAction={snackbar.onAction}
57
+ actionLabel={snackbar.actionLabel}
58
+ duration={snackbar.duration}
59
+ persist={snackbar.persist}
60
+ dismissOnAction={snackbar.dismissOnAction}
61
+ showClose={snackbar.showClose ?? true}
62
+ onClose={hideSnackbar}
63
+ open
64
+ />
65
+ )}
66
+ </SnackbarContext.Provider>
67
+ )
68
+ }
69
+
70
+ export function useSnackbar() {
71
+ const context = useContext(SnackbarContext)
72
+ if (!context) {
73
+ throw new Error('useSnackbar must be used within RcSesSnackbarProvider')
74
+ }
75
+ return context
76
+ }
77
+
78
+ export default RcSesSnackbarProvider
@@ -0,0 +1,77 @@
1
+ import type { ComponentType } from 'react'
2
+
3
+ import {
4
+ CheckCircleFillIcon,
5
+ InfoFillIcon,
6
+ ScrollIcon,
7
+ WarningFillIcon,
8
+ XCircleFillIcon,
9
+ } from '@/library/icons'
10
+ import { error, primary, secondary, warning } from '@/theme/palette'
11
+
12
+ import { type SnackbarSize, type SnackbarState } from './types'
13
+
14
+ export const SNACKBAR_DURATION = 10000 // 10s
15
+
16
+ export const SNACKBAR_ICON_SIZE = { width: 18, height: 20 }
17
+
18
+ export const stateConfig: Record<
19
+ SnackbarState,
20
+ {
21
+ icon: ComponentType<{ fillColor?: string; 'aria-hidden'?: boolean }>
22
+ color: string
23
+ severity: 'success' | 'error' | 'warning' | 'info'
24
+ ariaLive: 'polite' | 'assertive'
25
+ }
26
+ > = {
27
+ success: {
28
+ icon: CheckCircleFillIcon,
29
+ color: secondary['400'],
30
+ severity: 'success',
31
+ ariaLive: 'polite',
32
+ },
33
+ error: {
34
+ icon: XCircleFillIcon,
35
+ color: error['400'],
36
+ severity: 'error',
37
+ ariaLive: 'assertive',
38
+ },
39
+ warning: {
40
+ icon: WarningFillIcon,
41
+ color: warning['400'],
42
+ severity: 'warning',
43
+ ariaLive: 'polite',
44
+ },
45
+ info: {
46
+ icon: InfoFillIcon,
47
+ color: primary['400'],
48
+ severity: 'info',
49
+ ariaLive: 'polite',
50
+ },
51
+ 'action-needed': {
52
+ icon: ScrollIcon,
53
+ color: primary['400'],
54
+ severity: 'info',
55
+ ariaLive: 'assertive',
56
+ },
57
+ }
58
+
59
+ export const sizeConfig: Record<
60
+ SnackbarSize,
61
+ {
62
+ maxHeight: number
63
+ width: number
64
+ padding: string
65
+ }
66
+ > = {
67
+ standard: {
68
+ maxHeight: 120,
69
+ width: 400,
70
+ padding: '12px 16px',
71
+ },
72
+ compact: {
73
+ maxHeight: 96,
74
+ width: 320,
75
+ padding: '8px 12px',
76
+ },
77
+ }
@@ -0,0 +1,119 @@
1
+ import { ThemeProvider } from '@mui/material/styles'
2
+ import { fireEvent, render, screen } from '@testing-library/react'
3
+ import { ReactNode } from 'react'
4
+ import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
5
+
6
+ import theme from '@/theme/light'
7
+
8
+ import RcSesSnackbar from './index'
9
+
10
+ const DEFAULT_PROPS = { state: 'success' as const, message: 'Test', open: true }
11
+
12
+ const renderSnackbar = (props: ReactNode) =>
13
+ render(<ThemeProvider theme={theme}>{props}</ThemeProvider>)
14
+
15
+ const getMuiSnackbar = () => document.querySelector('.MuiSnackbar-root') as HTMLElement
16
+
17
+ describe('RcSesSnackbar', () => {
18
+ beforeEach(() => {
19
+ vi.useFakeTimers()
20
+ })
21
+
22
+ afterEach(() => {
23
+ vi.runOnlyPendingTimers()
24
+ vi.useRealTimers()
25
+ })
26
+
27
+ test('renders message', () => {
28
+ renderSnackbar(<RcSesSnackbar {...DEFAULT_PROPS} message='Test message' />)
29
+
30
+ expect(screen.getByText('Test message')).toBeInTheDocument()
31
+ })
32
+
33
+ test('renders standard size by default', () => {
34
+ const { container } = renderSnackbar(<RcSesSnackbar {...DEFAULT_PROPS} />)
35
+
36
+ expect(container.querySelector('[role="status"]')).toHaveStyle({
37
+ maxHeight: '120px',
38
+ width: '400px',
39
+ })
40
+ })
41
+
42
+ test('renders compact size', () => {
43
+ const { container } = renderSnackbar(
44
+ <RcSesSnackbar {...DEFAULT_PROPS} size='compact' />,
45
+ )
46
+
47
+ expect(container.querySelector('[role="status"]')).toHaveStyle({
48
+ maxHeight: '96px',
49
+ width: '320px',
50
+ })
51
+ })
52
+
53
+ test('closes on Escape key', () => {
54
+ const handleClose = vi.fn()
55
+ renderSnackbar(<RcSesSnackbar {...DEFAULT_PROPS} onClose={handleClose} />)
56
+ const snackbar = getMuiSnackbar()
57
+ fireEvent.keyDown(snackbar, { key: 'Escape', code: 'Escape' })
58
+
59
+ expect(handleClose).toHaveBeenCalled()
60
+ })
61
+
62
+ test('auto-hides after duration', () => {
63
+ const handleClose = vi.fn()
64
+ renderSnackbar(
65
+ <RcSesSnackbar {...DEFAULT_PROPS} onClose={handleClose} duration={1000} />,
66
+ )
67
+ const statusElement = screen.getByText('Test')
68
+ expect(statusElement).toBeInTheDocument()
69
+
70
+ vi.advanceTimersByTime(1000)
71
+
72
+ expect(handleClose).toHaveBeenCalled()
73
+ })
74
+
75
+ test('does not auto-hide when persist is true', async () => {
76
+ const handleClose = vi.fn()
77
+ renderSnackbar(
78
+ <RcSesSnackbar {...DEFAULT_PROPS} onClose={handleClose} persist duration={1000} />,
79
+ )
80
+
81
+ vi.advanceTimersByTime(2000)
82
+
83
+ expect(handleClose).not.toHaveBeenCalled()
84
+ })
85
+
86
+ test('renders action button in standard size with onAction', () => {
87
+ renderSnackbar(
88
+ <RcSesSnackbar
89
+ {...DEFAULT_PROPS}
90
+ size='standard'
91
+ onAction={() => {}}
92
+ actionLabel='Undo'
93
+ />,
94
+ )
95
+
96
+ expect(screen.getByRole('button', { name: 'Undo' })).toBeInTheDocument()
97
+ })
98
+
99
+ test('does not render action button in compact size', () => {
100
+ renderSnackbar(
101
+ <RcSesSnackbar
102
+ {...DEFAULT_PROPS}
103
+ size='compact'
104
+ onAction={() => {}}
105
+ actionLabel='Undo'
106
+ />,
107
+ )
108
+
109
+ expect(screen.queryByRole('button', { name: 'Undo' })).not.toBeInTheDocument()
110
+ })
111
+
112
+ test('has correct accessibility attributes', () => {
113
+ renderSnackbar(<RcSesSnackbar {...DEFAULT_PROPS} />)
114
+ const status = screen.getByRole('status')
115
+
116
+ expect(status).toHaveAttribute('aria-atomic', 'true')
117
+ expect(status).toHaveAttribute('aria-live', 'polite')
118
+ })
119
+ })