@registrucentras/rc-ses-react-components 1.8.0 → 1.9.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.
- package/dist/components/loaders/FullPageLoader/index.d.ts +9 -0
- package/dist/components/loaders/Loader/index.d.ts +26 -0
- package/dist/library/index.d.ts +4 -2
- package/dist/library/types.d.ts +4 -2
- package/dist/registrucentras-rc-ses-react-components.cjs +8 -8
- package/dist/registrucentras-rc-ses-react-components.js +1365 -1271
- package/dist/stories/components/loaders/FullPageLoader.stories.d.ts +37 -0
- package/dist/stories/components/loaders/Loader.stories.d.ts +36 -0
- package/dist/stories/components/{spinner → loaders}/LoadingSpinner.stories.d.ts +4 -4
- package/package.json +1 -1
- package/src/components/common/Button/index.tsx +1 -3
- package/src/components/common/Snackbar/index.test.tsx +10 -4
- package/src/components/form/inputs/CheckboxFormControl.test.tsx +11 -7
- package/src/components/loaders/FullPageLoader/index.test.tsx +80 -0
- package/src/components/loaders/FullPageLoader/index.tsx +68 -0
- package/src/components/loaders/Loader/index.test.tsx +58 -0
- package/src/components/loaders/Loader/index.tsx +65 -0
- package/src/components/{LoadingSpinner/LoadingSpinner.test.tsx → loaders/LoadingSpinner/index.test.tsx} +1 -1
- package/src/components/{LoadingSpinner/LoadingSpinner.tsx → loaders/LoadingSpinner/index.tsx} +1 -1
- package/src/components/overlays/Dialog/index.test.tsx +1 -1
- package/src/i18n/namespaces/common/en.json +3 -0
- package/src/i18n/namespaces/common/lt.json +3 -0
- package/src/library/index.ts +5 -1
- package/src/library/types.ts +13 -4
- package/src/setupTests.ts +13 -0
- package/src/stories/components/loaders/FullPageLoader.stories.tsx +126 -0
- package/src/stories/components/loaders/Loader.stories.tsx +76 -0
- package/src/stories/components/{spinner → loaders}/LoadingSpinner.stories.tsx +2 -2
- /package/dist/components/{LoadingSpinner/LoadingSpinner.d.ts → loaders/LoadingSpinner/index.d.ts} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react';
|
|
2
|
+
import { default as RcSesFullPageLoader } from '../../../components/loaders/FullPageLoader';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof RcSesFullPageLoader;
|
|
6
|
+
tags: string[];
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: {
|
|
9
|
+
include: string[];
|
|
10
|
+
};
|
|
11
|
+
docs: {
|
|
12
|
+
story: {
|
|
13
|
+
inline: boolean;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
description: {
|
|
17
|
+
component: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
argTypes: {
|
|
22
|
+
backdrop: {
|
|
23
|
+
control: "radio";
|
|
24
|
+
options: string[];
|
|
25
|
+
};
|
|
26
|
+
label: {
|
|
27
|
+
control: "text";
|
|
28
|
+
};
|
|
29
|
+
showLabel: {
|
|
30
|
+
control: "boolean";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export default meta;
|
|
35
|
+
type Story = StoryObj<typeof meta>;
|
|
36
|
+
export declare const Default: Story;
|
|
37
|
+
export declare const DarkBackdrop: Story;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react';
|
|
2
|
+
import { default as RcSesLoader } from '../../../components/loaders/Loader';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof RcSesLoader;
|
|
6
|
+
tags: string[];
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: {
|
|
9
|
+
include: string[];
|
|
10
|
+
};
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
argTypes: {
|
|
18
|
+
label: {
|
|
19
|
+
control: "text";
|
|
20
|
+
};
|
|
21
|
+
showLabel: {
|
|
22
|
+
control: "boolean";
|
|
23
|
+
};
|
|
24
|
+
size: {
|
|
25
|
+
control: "radio";
|
|
26
|
+
options: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export default meta;
|
|
31
|
+
type Story = StoryObj<typeof meta>;
|
|
32
|
+
export declare const Default: Story;
|
|
33
|
+
export declare const Small: Story;
|
|
34
|
+
export declare const Medium: Story;
|
|
35
|
+
export declare const Large: Story;
|
|
36
|
+
export declare const WithoutLabel: Story;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react';
|
|
2
|
-
import { default as RcSesLoadingSpinner } from '../../../components/
|
|
2
|
+
import { default as RcSesLoadingSpinner } from '../../../components/loaders/LoadingSpinner';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof RcSesLoadingSpinner;
|
|
@@ -14,11 +14,11 @@ declare const meta: {
|
|
|
14
14
|
argTypes: {
|
|
15
15
|
color: {
|
|
16
16
|
description: string;
|
|
17
|
-
options: ("
|
|
18
|
-
mapping: ("
|
|
17
|
+
options: ("inherit" | "success" | "info" | "warning" | "error" | "primary" | "secondary")[];
|
|
18
|
+
mapping: ("inherit" | "success" | "info" | "warning" | "error" | "primary" | "secondary")[];
|
|
19
19
|
control: {
|
|
20
20
|
type: "select";
|
|
21
|
-
labels: ("
|
|
21
|
+
labels: ("inherit" | "success" | "info" | "warning" | "error" | "primary" | "secondary")[];
|
|
22
22
|
};
|
|
23
23
|
table: {
|
|
24
24
|
defaultValue: {
|
package/package.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Button as MuiButton, ButtonProps as MuiButtonProps } from '@mui/material'
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
3
|
|
|
4
|
-
import RcSesLoadingSpinner, {
|
|
5
|
-
getSpinnerColor,
|
|
6
|
-
} from '@/components/LoadingSpinner/LoadingSpinner'
|
|
4
|
+
import RcSesLoadingSpinner, { getSpinnerColor } from '@/components/loaders/LoadingSpinner'
|
|
7
5
|
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
8
6
|
|
|
9
7
|
const defaultProps: Partial<MuiButtonProps> = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react'
|
|
2
|
+
import { act, fireEvent, render, screen } from '@testing-library/react'
|
|
3
3
|
import { ReactNode } from 'react'
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
|
|
5
5
|
|
|
@@ -20,7 +20,9 @@ describe('RcSesSnackbar', () => {
|
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
afterEach(() => {
|
|
23
|
-
|
|
23
|
+
act(() => {
|
|
24
|
+
vi.runOnlyPendingTimers()
|
|
25
|
+
})
|
|
24
26
|
vi.useRealTimers()
|
|
25
27
|
})
|
|
26
28
|
|
|
@@ -67,7 +69,9 @@ describe('RcSesSnackbar', () => {
|
|
|
67
69
|
const statusElement = screen.getByText('Test')
|
|
68
70
|
expect(statusElement).toBeInTheDocument()
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
act(() => {
|
|
73
|
+
vi.advanceTimersByTime(1000)
|
|
74
|
+
})
|
|
71
75
|
|
|
72
76
|
expect(handleClose).toHaveBeenCalled()
|
|
73
77
|
})
|
|
@@ -78,7 +82,9 @@ describe('RcSesSnackbar', () => {
|
|
|
78
82
|
<RcSesSnackbar {...DEFAULT_PROPS} onClose={handleClose} persist duration={1000} />,
|
|
79
83
|
)
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
act(() => {
|
|
86
|
+
vi.advanceTimersByTime(2000)
|
|
87
|
+
})
|
|
82
88
|
|
|
83
89
|
expect(handleClose).not.toHaveBeenCalled()
|
|
84
90
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
-
import { render } from '@testing-library/react'
|
|
2
|
+
import { fireEvent, render, waitFor } from '@testing-library/react'
|
|
3
3
|
import { useForm } from 'react-hook-form'
|
|
4
4
|
import { describe, expect, test, vi } from 'vitest'
|
|
5
5
|
|
|
@@ -40,7 +40,7 @@ describe('RcSesCheckboxFormControl - Indeterminate State', () => {
|
|
|
40
40
|
expect(checkbox.checked).toBe(false)
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
-
test('should call onChildValuesChange with [true, true, true] when clicking parent in indeterminate state', () => {
|
|
43
|
+
test('should call onChildValuesChange with [true, true, true] when clicking parent in indeterminate state', async () => {
|
|
44
44
|
const onChildValuesChange = vi.fn()
|
|
45
45
|
const { container } = render(
|
|
46
46
|
<TestWrapper
|
|
@@ -49,11 +49,13 @@ describe('RcSesCheckboxFormControl - Indeterminate State', () => {
|
|
|
49
49
|
/>,
|
|
50
50
|
)
|
|
51
51
|
const checkbox = container.querySelector('input#checkbox') as HTMLInputElement
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
fireEvent.click(checkbox)
|
|
53
|
+
await waitFor(() => {
|
|
54
|
+
expect(onChildValuesChange).toHaveBeenCalledWith([true, true, true])
|
|
55
|
+
})
|
|
54
56
|
})
|
|
55
57
|
|
|
56
|
-
test('should call onChildValuesChange with [false, false, false] when clicking checked parent', () => {
|
|
58
|
+
test('should call onChildValuesChange with [false, false, false] when clicking checked parent', async () => {
|
|
57
59
|
const onChildValuesChange = vi.fn()
|
|
58
60
|
const { container } = render(
|
|
59
61
|
<TestWrapper
|
|
@@ -62,7 +64,9 @@ describe('RcSesCheckboxFormControl - Indeterminate State', () => {
|
|
|
62
64
|
/>,
|
|
63
65
|
)
|
|
64
66
|
const checkbox = container.querySelector('input#checkbox') as HTMLInputElement
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
fireEvent.click(checkbox)
|
|
68
|
+
await waitFor(() => {
|
|
69
|
+
expect(onChildValuesChange).toHaveBeenCalledWith([false, false, false])
|
|
70
|
+
})
|
|
67
71
|
})
|
|
68
72
|
})
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ThemeProvider, alpha } from '@mui/material/styles'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
import { type ReactElement } from 'react'
|
|
4
|
+
import { beforeEach, describe, expect, it } from 'vitest'
|
|
5
|
+
|
|
6
|
+
import i18n from '@/i18n/i18n'
|
|
7
|
+
import theme from '@/theme/light'
|
|
8
|
+
|
|
9
|
+
import RcSesFullPageLoader from './index'
|
|
10
|
+
|
|
11
|
+
const getDefaultLoaderLabel = () => i18n.t('components.Loader.loading', { ns: 'common' })
|
|
12
|
+
|
|
13
|
+
const renderWithTheme = (ui: ReactElement) =>
|
|
14
|
+
render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
|
|
15
|
+
|
|
16
|
+
describe('RcSesFullPageLoader', () => {
|
|
17
|
+
beforeEach(async () => {
|
|
18
|
+
await i18n.changeLanguage('lt')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should render paper container in full page mode', () => {
|
|
22
|
+
renderWithTheme(<RcSesFullPageLoader />)
|
|
23
|
+
|
|
24
|
+
expect(screen.getByRole('status').closest('.MuiPaper-root')).toBeInTheDocument()
|
|
25
|
+
expect(screen.getByRole('progressbar')).toHaveStyle({ height: '64px', width: '64px' })
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should render light backdrop variant', () => {
|
|
29
|
+
renderWithTheme(<RcSesFullPageLoader backdrop='light' />)
|
|
30
|
+
|
|
31
|
+
const backdrop = document.querySelector('.MuiBackdrop-root') as HTMLElement
|
|
32
|
+
|
|
33
|
+
expect(backdrop).toHaveStyle({
|
|
34
|
+
backgroundColor: alpha(theme.palette.common.white, 0.72),
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('should render dark backdrop variant', () => {
|
|
39
|
+
renderWithTheme(<RcSesFullPageLoader backdrop='dark' />)
|
|
40
|
+
|
|
41
|
+
const backdrop = document.querySelector('.MuiBackdrop-root') as HTMLElement
|
|
42
|
+
|
|
43
|
+
expect(backdrop).toHaveStyle({
|
|
44
|
+
backgroundColor: alpha(theme.palette.grey[900], 0.45),
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should prevent and restore background focus', () => {
|
|
49
|
+
const backgroundButton = document.createElement('button')
|
|
50
|
+
backgroundButton.textContent = 'Background action'
|
|
51
|
+
document.body.appendChild(backgroundButton)
|
|
52
|
+
backgroundButton.focus()
|
|
53
|
+
|
|
54
|
+
const { unmount } = renderWithTheme(<RcSesFullPageLoader />)
|
|
55
|
+
|
|
56
|
+
expect(backgroundButton).not.toHaveFocus()
|
|
57
|
+
|
|
58
|
+
unmount()
|
|
59
|
+
|
|
60
|
+
expect(backgroundButton).toHaveFocus()
|
|
61
|
+
document.body.removeChild(backgroundButton)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should pass loader props to base loader', () => {
|
|
65
|
+
renderWithTheme(<RcSesFullPageLoader label='Duomenys kraunami' showLabel={false} />)
|
|
66
|
+
|
|
67
|
+
expect(screen.queryByText('Duomenys kraunami')).not.toBeInTheDocument()
|
|
68
|
+
expect(screen.getByRole('status')).toHaveAttribute('aria-label', 'Duomenys kraunami')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('should use translated aria-label when label is hidden', () => {
|
|
72
|
+
renderWithTheme(<RcSesFullPageLoader showLabel={false} />)
|
|
73
|
+
|
|
74
|
+
expect(screen.queryByText(getDefaultLoaderLabel())).not.toBeInTheDocument()
|
|
75
|
+
expect(screen.getByRole('status')).toHaveAttribute(
|
|
76
|
+
'aria-label',
|
|
77
|
+
getDefaultLoaderLabel(),
|
|
78
|
+
)
|
|
79
|
+
})
|
|
80
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Box, BoxProps, Modal, Paper } from '@mui/material'
|
|
2
|
+
import { alpha } from '@mui/material/styles'
|
|
3
|
+
|
|
4
|
+
import RcSesLoader, { RcSesLoaderProps } from '@/components/loaders/Loader'
|
|
5
|
+
|
|
6
|
+
export type RcSesLoaderBackdrop = 'dark' | 'light'
|
|
7
|
+
|
|
8
|
+
// dimensions are based on the Figma design specifications
|
|
9
|
+
const FULL_PAGE_LOADER_CONTAINER_WIDTH = 187
|
|
10
|
+
const FULL_PAGE_LOADER_CONTAINER_HEIGHT = 198
|
|
11
|
+
|
|
12
|
+
type FullPageLoaderContentProps = Pick<RcSesLoaderProps, 'label' | 'showLabel'>
|
|
13
|
+
|
|
14
|
+
export interface RcSesFullPageLoaderProps
|
|
15
|
+
extends Omit<BoxProps, 'children' | 'sx'>,
|
|
16
|
+
FullPageLoaderContentProps {
|
|
17
|
+
backdrop?: RcSesLoaderBackdrop
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function RcSesFullPageLoader({
|
|
21
|
+
backdrop = 'light',
|
|
22
|
+
label,
|
|
23
|
+
showLabel,
|
|
24
|
+
...props
|
|
25
|
+
}: RcSesFullPageLoaderProps) {
|
|
26
|
+
return (
|
|
27
|
+
<Modal
|
|
28
|
+
disableEscapeKeyDown
|
|
29
|
+
open
|
|
30
|
+
slotProps={{
|
|
31
|
+
backdrop: {
|
|
32
|
+
sx: {
|
|
33
|
+
backgroundColor: (theme) =>
|
|
34
|
+
backdrop === 'dark'
|
|
35
|
+
? alpha(theme.palette.grey[900], 0.45)
|
|
36
|
+
: alpha(theme.palette.common.white, 0.72),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<Box
|
|
42
|
+
sx={{
|
|
43
|
+
display: 'grid',
|
|
44
|
+
inset: 0,
|
|
45
|
+
placeItems: 'center',
|
|
46
|
+
position: 'fixed',
|
|
47
|
+
}}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
<Paper
|
|
51
|
+
elevation={4}
|
|
52
|
+
sx={{
|
|
53
|
+
borderRadius: 2,
|
|
54
|
+
boxSizing: 'border-box',
|
|
55
|
+
display: 'grid',
|
|
56
|
+
height: FULL_PAGE_LOADER_CONTAINER_HEIGHT,
|
|
57
|
+
placeItems: 'center',
|
|
58
|
+
width: FULL_PAGE_LOADER_CONTAINER_WIDTH,
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<RcSesLoader label={label} showLabel={showLabel} size='large' />
|
|
62
|
+
</Paper>
|
|
63
|
+
</Box>
|
|
64
|
+
</Modal>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default RcSesFullPageLoader
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import { beforeEach, describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import i18n from '@/i18n/i18n'
|
|
5
|
+
|
|
6
|
+
import RcSesLoader from './index'
|
|
7
|
+
|
|
8
|
+
const getDefaultLoaderLabel = () => i18n.t('components.Loader.loading', { ns: 'common' })
|
|
9
|
+
|
|
10
|
+
describe('RcSesLoader', () => {
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await i18n.changeLanguage('lt')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('should render loader with default label', () => {
|
|
16
|
+
render(<RcSesLoader />)
|
|
17
|
+
|
|
18
|
+
expect(screen.getByRole('status')).toBeInTheDocument()
|
|
19
|
+
expect(screen.getByText(getDefaultLoaderLabel())).toBeInTheDocument()
|
|
20
|
+
expect(screen.getByRole('progressbar')).toBeInTheDocument()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it.each([
|
|
24
|
+
['small', '24px'],
|
|
25
|
+
['medium', '40px'],
|
|
26
|
+
['large', '64px'],
|
|
27
|
+
] as const)('should render the proper loader size', (size, expectedSize) => {
|
|
28
|
+
render(<RcSesLoader size={size} />)
|
|
29
|
+
|
|
30
|
+
expect(screen.getByRole('progressbar')).toHaveStyle({
|
|
31
|
+
height: expectedSize,
|
|
32
|
+
width: expectedSize,
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should render custom label', () => {
|
|
37
|
+
render(<RcSesLoader label='Duomenys kraunami' />)
|
|
38
|
+
|
|
39
|
+
expect(screen.getByText('Duomenys kraunami')).toBeInTheDocument()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should hide label and set aria-label when showLabel is false', () => {
|
|
43
|
+
render(<RcSesLoader showLabel={false} />)
|
|
44
|
+
|
|
45
|
+
expect(screen.queryByText(getDefaultLoaderLabel())).not.toBeInTheDocument()
|
|
46
|
+
expect(screen.getByRole('status')).toHaveAttribute(
|
|
47
|
+
'aria-label',
|
|
48
|
+
getDefaultLoaderLabel(),
|
|
49
|
+
)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should use custom label for aria-label when label is string and showLabel is false', () => {
|
|
53
|
+
render(<RcSesLoader label='Duomenys kraunami' showLabel={false} />)
|
|
54
|
+
|
|
55
|
+
expect(screen.queryByText('Duomenys kraunami')).not.toBeInTheDocument()
|
|
56
|
+
expect(screen.getByRole('status')).toHaveAttribute('aria-label', 'Duomenys kraunami')
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Stack, StackProps, Typography } from '@mui/material'
|
|
2
|
+
import { useTranslation } from 'react-i18next'
|
|
3
|
+
|
|
4
|
+
import RcSesLoadingSpinner from '@/components/loaders/LoadingSpinner'
|
|
5
|
+
import RcSesPalette from '@/theme/palette'
|
|
6
|
+
|
|
7
|
+
const LOADER_SIZE_MAP = {
|
|
8
|
+
small: {
|
|
9
|
+
gap: 1,
|
|
10
|
+
spinnerSize: '24px',
|
|
11
|
+
textVariant: 'body2',
|
|
12
|
+
},
|
|
13
|
+
medium: {
|
|
14
|
+
gap: 1.5,
|
|
15
|
+
spinnerSize: '40px',
|
|
16
|
+
textVariant: 'body1',
|
|
17
|
+
},
|
|
18
|
+
large: {
|
|
19
|
+
gap: 2,
|
|
20
|
+
spinnerSize: '64px',
|
|
21
|
+
textVariant: 'body1',
|
|
22
|
+
},
|
|
23
|
+
} as const
|
|
24
|
+
|
|
25
|
+
export type RcSesLoaderSize = keyof typeof LOADER_SIZE_MAP
|
|
26
|
+
|
|
27
|
+
export interface RcSesLoaderProps extends Omit<StackProps, 'children'> {
|
|
28
|
+
label?: string
|
|
29
|
+
size?: RcSesLoaderSize
|
|
30
|
+
showLabel?: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function RcSesLoader({
|
|
34
|
+
'aria-label': ariaLabel,
|
|
35
|
+
label,
|
|
36
|
+
size = 'medium',
|
|
37
|
+
showLabel = true,
|
|
38
|
+
sx,
|
|
39
|
+
...props
|
|
40
|
+
}: RcSesLoaderProps) {
|
|
41
|
+
const { t } = useTranslation('common', { keyPrefix: 'components.Loader' })
|
|
42
|
+
const { gap, spinnerSize, textVariant } = LOADER_SIZE_MAP[size]
|
|
43
|
+
const resolvedLabel = label ?? t('loading')
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Stack
|
|
47
|
+
role='status'
|
|
48
|
+
aria-live='polite'
|
|
49
|
+
aria-label={!showLabel ? (ariaLabel ?? resolvedLabel) : ariaLabel}
|
|
50
|
+
alignItems='center'
|
|
51
|
+
gap={gap}
|
|
52
|
+
sx={[{ color: RcSesPalette.primary[700] }, ...(Array.isArray(sx) ? sx : [sx])]}
|
|
53
|
+
{...props}
|
|
54
|
+
>
|
|
55
|
+
<RcSesLoadingSpinner color='inherit' size={spinnerSize} />
|
|
56
|
+
{showLabel && (
|
|
57
|
+
<Typography color='text.secondary' variant={textVariant}>
|
|
58
|
+
{resolvedLabel}
|
|
59
|
+
</Typography>
|
|
60
|
+
)}
|
|
61
|
+
</Stack>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default RcSesLoader
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react'
|
|
2
2
|
import { describe, expect, it } from 'vitest'
|
|
3
3
|
|
|
4
|
-
import RcSesLoadingSpinner from './
|
|
4
|
+
import RcSesLoadingSpinner from './index'
|
|
5
5
|
|
|
6
6
|
describe('RcSesLoadingSpinner', () => {
|
|
7
7
|
it('should render a progress bar', () => {
|
package/src/library/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type {} from '@mui/system'
|
|
|
3
3
|
import type {} from '@mui/x-date-pickers/themeAugmentation'
|
|
4
4
|
|
|
5
5
|
import RcSesIconProps from '@/assets/IconProps'
|
|
6
|
-
import RcSesLoadingSpinner from '@/components/LoadingSpinner/LoadingSpinner'
|
|
7
6
|
import RcSesAccordion from '@/components/common/Accordion'
|
|
8
7
|
import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
|
|
9
8
|
import RcSesAlert from '@/components/common/Alert'
|
|
@@ -47,6 +46,9 @@ import RcSesCardFormContainer from '@/components/layout/ServiceFormContainer/Car
|
|
|
47
46
|
import RcSesServiceHeader from '@/components/layout/ServiceHeader'
|
|
48
47
|
import RcSesServicePage from '@/components/layout/ServicePage'
|
|
49
48
|
import ServiceWizardStepper from '@/components/layout/ServiceWizardStepper'
|
|
49
|
+
import RcSesFullPageLoader from '@/components/loaders/FullPageLoader'
|
|
50
|
+
import RcSesLoader from '@/components/loaders/Loader'
|
|
51
|
+
import RcSesLoadingSpinner from '@/components/loaders/LoadingSpinner'
|
|
50
52
|
import RcSesDialog from '@/components/overlays/Dialog'
|
|
51
53
|
import RcSesModal from '@/components/overlays/Modal'
|
|
52
54
|
import RcSesTheme from '@/theme/light'
|
|
@@ -67,6 +69,8 @@ export {
|
|
|
67
69
|
RcSesBreadcrumbs,
|
|
68
70
|
RcSesButton,
|
|
69
71
|
RcSesButtonWithPopover,
|
|
72
|
+
RcSesFullPageLoader,
|
|
73
|
+
RcSesLoader,
|
|
70
74
|
RcSesLoadingSpinner,
|
|
71
75
|
RcSesCard,
|
|
72
76
|
RcSesDialog,
|
package/src/library/types.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RcSesLoadingSpinnerProps,
|
|
3
|
-
RcSesSpinnerColor,
|
|
4
|
-
} from '@/components/LoadingSpinner/LoadingSpinner'
|
|
5
1
|
import { RcSesCardProps } from '@/components/common/Card'
|
|
6
2
|
import { ListWithIconsProps } from '@/components/common/ListWithIcons'
|
|
7
3
|
import { ListWithIconsItemData } from '@/components/common/ListWithIcons/ListWithIcons.types'
|
|
@@ -9,6 +5,15 @@ import { RcSesFormControlLabelProps } from '@/components/form/inputs/FormControl
|
|
|
9
5
|
import { SimpleCheckboxProps } from '@/components/form/inputs/SimpleCheckbox'
|
|
10
6
|
import { RcSesCardFormContainerProps } from '@/components/layout/ServiceFormContainer/CardFormContainer'
|
|
11
7
|
import { ServiceWizardStepperProps } from '@/components/layout/ServiceWizardStepper'
|
|
8
|
+
import {
|
|
9
|
+
RcSesFullPageLoaderProps,
|
|
10
|
+
RcSesLoaderBackdrop,
|
|
11
|
+
} from '@/components/loaders/FullPageLoader'
|
|
12
|
+
import { RcSesLoaderProps, RcSesLoaderSize } from '@/components/loaders/Loader'
|
|
13
|
+
import {
|
|
14
|
+
RcSesLoadingSpinnerProps,
|
|
15
|
+
RcSesSpinnerColor,
|
|
16
|
+
} from '@/components/loaders/LoadingSpinner'
|
|
12
17
|
import { DialogSize, RcSesDialogProps } from '@/components/overlays/Dialog'
|
|
13
18
|
import { ModalVariant, RcSesModalProps } from '@/components/overlays/Modal'
|
|
14
19
|
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
@@ -17,6 +22,10 @@ export type { ListWithIconsProps, ListWithIconsItemData }
|
|
|
17
22
|
export type { ButtonProps }
|
|
18
23
|
|
|
19
24
|
export type {
|
|
25
|
+
RcSesFullPageLoaderProps,
|
|
26
|
+
RcSesLoaderBackdrop,
|
|
27
|
+
RcSesLoaderProps,
|
|
28
|
+
RcSesLoaderSize,
|
|
20
29
|
RcSesCardFormContainerProps,
|
|
21
30
|
RcSesCardProps,
|
|
22
31
|
ServiceWizardStepperProps,
|
package/src/setupTests.ts
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/vitest'
|
|
2
|
+
import i18n from 'i18next'
|
|
3
|
+
import { initReactI18next } from 'react-i18next'
|
|
4
|
+
|
|
5
|
+
if (!i18n.isInitialized) {
|
|
6
|
+
i18n.use(initReactI18next).init({
|
|
7
|
+
fallbackLng: 'lt',
|
|
8
|
+
interpolation: { escapeValue: false },
|
|
9
|
+
lng: 'lt',
|
|
10
|
+
resources: {
|
|
11
|
+
lt: { translation: {} },
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
}
|