@registrucentras/rc-ses-react-components 1.12.0 → 1.13.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/assets/icons/CaretUpBoldIcon.d.ts +3 -0
- package/dist/assets/icons/CaretUpIcon.d.ts +3 -0
- package/dist/assets/icons/ListIcon.d.ts +3 -0
- package/dist/assets/icons/MinusIcon.d.ts +3 -0
- package/dist/assets/icons/NotePencilIcon.d.ts +3 -0
- package/dist/assets/icons/PlusIcon.d.ts +3 -0
- package/dist/assets/icons/TrashIcon.d.ts +3 -0
- package/dist/assets/icons/UserIcon.d.ts +3 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.d.ts +106 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.d.ts +12 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.d.ts +7 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.d.ts +2 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/index.d.ts +4 -0
- package/dist/components/common/AdvancedList/index.d.ts +11 -0
- package/dist/components/common/SelectableCardList/components/SelectableCardListItem.d.ts +4 -1
- package/dist/components/common/SelectableCardList/index.d.ts +3 -0
- package/dist/components/form/inputs/Select/index.d.ts +1 -0
- package/dist/library/icons.d.ts +9 -1
- package/dist/library/index.d.ts +3 -0
- package/dist/registrucentras-rc-ses-react-components.cjs +10 -10
- package/dist/registrucentras-rc-ses-react-components.js +3807 -3102
- package/dist/stories/components/display/AdvancedList.stories.d.ts +33 -0
- package/dist/stories/components/display/AdvancedListItem.stories.d.ts +33 -0
- package/dist/stories/components/loaders/LoadingSpinner.stories.d.ts +3 -3
- package/dist/theme/motion.d.ts +16 -0
- package/package.json +1 -1
- package/src/assets/icons/CaretUpBoldIcon.tsx +17 -0
- package/src/assets/icons/CaretUpIcon.tsx +9 -0
- package/src/assets/icons/ListIcon.tsx +17 -0
- package/src/assets/icons/MinusIcon.tsx +9 -0
- package/src/assets/icons/NotePencilIcon.tsx +9 -0
- package/src/assets/icons/PlusIcon.tsx +9 -0
- package/src/assets/icons/TrashIcon.tsx +23 -0
- package/src/assets/icons/UserIcon.tsx +17 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.ts +100 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +214 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +241 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.test.ts +80 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.ts +28 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.test.tsx +631 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +329 -0
- package/src/components/common/AdvancedList/index.test.tsx +97 -0
- package/src/components/common/AdvancedList/index.tsx +52 -0
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.test.tsx +50 -0
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +34 -0
- package/src/components/common/SelectableCardList/index.tsx +6 -0
- package/src/components/common/Tooltip/index.test.tsx +1 -3
- package/src/components/form/inputs/FileDropzone.tsx +1 -0
- package/src/components/form/inputs/FileUpload.tsx +1 -0
- package/src/components/form/inputs/NumberStepper.tsx +1 -0
- package/src/components/form/inputs/RadioButtonGroup.test.tsx +71 -0
- package/src/components/form/inputs/RadioButtonGroup.tsx +1 -0
- package/src/components/form/inputs/Select/index.test.tsx +57 -0
- package/src/components/form/inputs/Select/index.tsx +2 -0
- package/src/i18n/namespaces/common/en.json +11 -0
- package/src/i18n/namespaces/common/lt.json +11 -0
- package/src/library/icons.ts +16 -0
- package/src/library/index.ts +3 -0
- package/src/setupTests.ts +7 -1
- package/src/stories/components/display/AdvancedList.stories.tsx +660 -0
- package/src/stories/components/display/AdvancedListItem.stories.tsx +593 -0
- package/src/stories/components/display/SelectableCardList.stories.tsx +3 -0
- package/src/theme/motion.tsx +10 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
import { useForm } from 'react-hook-form'
|
|
5
|
+
|
|
6
|
+
import theme from '@/theme/light'
|
|
7
|
+
|
|
8
|
+
import RcSesRadioButtonGroup from './RadioButtonGroup'
|
|
9
|
+
|
|
10
|
+
const options = [
|
|
11
|
+
{ label: 'Fizinis asmuo', value: 'natural' },
|
|
12
|
+
{ label: 'Juridinis asmuo', value: 'legal' },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
type TestWrapperProps = {
|
|
16
|
+
shouldUnregister?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const TestWrapper = ({ shouldUnregister }: TestWrapperProps) => {
|
|
20
|
+
const { control, getValues } = useForm({
|
|
21
|
+
defaultValues: { ownerType: 'natural' },
|
|
22
|
+
})
|
|
23
|
+
const [mounted, setMounted] = useState(true)
|
|
24
|
+
const [formValues, setFormValues] = useState('')
|
|
25
|
+
|
|
26
|
+
const slotProps =
|
|
27
|
+
shouldUnregister === undefined ? undefined : { controller: { shouldUnregister } }
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ThemeProvider theme={theme}>
|
|
31
|
+
{mounted && (
|
|
32
|
+
<RcSesRadioButtonGroup
|
|
33
|
+
id='ownerType'
|
|
34
|
+
name='ownerType'
|
|
35
|
+
control={control}
|
|
36
|
+
label='Savininko tipas'
|
|
37
|
+
options={options}
|
|
38
|
+
slotProps={slotProps}
|
|
39
|
+
/>
|
|
40
|
+
)}
|
|
41
|
+
|
|
42
|
+
<button type='button' onClick={() => setMounted(false)}>
|
|
43
|
+
Hide
|
|
44
|
+
</button>
|
|
45
|
+
<button type='button' onClick={() => setFormValues(JSON.stringify(getValues()))}>
|
|
46
|
+
Read
|
|
47
|
+
</button>
|
|
48
|
+
<div data-testid='form-values'>{formValues}</div>
|
|
49
|
+
</ThemeProvider>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
describe('RcSesRadioButtonGroup', () => {
|
|
54
|
+
test('keeps the value in the form by default when the field unmounts', () => {
|
|
55
|
+
render(<TestWrapper />)
|
|
56
|
+
|
|
57
|
+
fireEvent.click(screen.getByRole('button', { name: 'Hide' }))
|
|
58
|
+
fireEvent.click(screen.getByRole('button', { name: 'Read' }))
|
|
59
|
+
|
|
60
|
+
expect(screen.getByTestId('form-values')).toHaveTextContent('natural')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('drops the value when slotProps.controller turns shouldUnregister on', () => {
|
|
64
|
+
render(<TestWrapper shouldUnregister />)
|
|
65
|
+
|
|
66
|
+
fireEvent.click(screen.getByRole('button', { name: 'Hide' }))
|
|
67
|
+
fireEvent.click(screen.getByRole('button', { name: 'Read' }))
|
|
68
|
+
|
|
69
|
+
expect(screen.getByTestId('form-values')).not.toHaveTextContent('natural')
|
|
70
|
+
})
|
|
71
|
+
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ThemeProvider } from '@mui/material/styles'
|
|
2
2
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
|
3
|
+
import { useState } from 'react'
|
|
3
4
|
import { useForm } from 'react-hook-form'
|
|
4
5
|
|
|
5
6
|
import theme from '@/theme/light'
|
|
@@ -21,6 +22,44 @@ const options = [
|
|
|
21
22
|
},
|
|
22
23
|
]
|
|
23
24
|
|
|
25
|
+
type UnregisterTestWrapperProps = {
|
|
26
|
+
shouldUnregister?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const UnregisterTestWrapper = ({ shouldUnregister }: UnregisterTestWrapperProps) => {
|
|
30
|
+
const { control, getValues } = useForm({
|
|
31
|
+
defaultValues: { selection: 'short-option' as string | null },
|
|
32
|
+
})
|
|
33
|
+
const [mounted, setMounted] = useState(true)
|
|
34
|
+
const [formValues, setFormValues] = useState('')
|
|
35
|
+
|
|
36
|
+
const slotProps =
|
|
37
|
+
shouldUnregister === undefined ? undefined : { controller: { shouldUnregister } }
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ThemeProvider theme={theme}>
|
|
41
|
+
{mounted && (
|
|
42
|
+
<RcSesSelect
|
|
43
|
+
id='selection'
|
|
44
|
+
name='selection'
|
|
45
|
+
control={control}
|
|
46
|
+
label='Pasirinkti'
|
|
47
|
+
options={options}
|
|
48
|
+
slotProps={slotProps}
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
51
|
+
|
|
52
|
+
<button type='button' onClick={() => setMounted(false)}>
|
|
53
|
+
Hide
|
|
54
|
+
</button>
|
|
55
|
+
<button type='button' onClick={() => setFormValues(JSON.stringify(getValues()))}>
|
|
56
|
+
Read
|
|
57
|
+
</button>
|
|
58
|
+
<div data-testid='form-values'>{formValues}</div>
|
|
59
|
+
</ThemeProvider>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
24
63
|
const TestWrapper = ({ defaultValue = null }: TestWrapperProps) => {
|
|
25
64
|
const { control } = useForm({
|
|
26
65
|
defaultValues: {
|
|
@@ -99,4 +138,22 @@ describe('RcSesSelect', () => {
|
|
|
99
138
|
|
|
100
139
|
expect(screen.getByRole('combobox')).toHaveAttribute('readonly')
|
|
101
140
|
})
|
|
141
|
+
|
|
142
|
+
test('drops the value from the form by default when the field unmounts', () => {
|
|
143
|
+
render(<UnregisterTestWrapper />)
|
|
144
|
+
|
|
145
|
+
fireEvent.click(screen.getByRole('button', { name: 'Hide' }))
|
|
146
|
+
fireEvent.click(screen.getByRole('button', { name: 'Read' }))
|
|
147
|
+
|
|
148
|
+
expect(screen.getByTestId('form-values')).not.toHaveTextContent('short-option')
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
test('keeps the value when slotProps.controller turns shouldUnregister off', () => {
|
|
152
|
+
render(<UnregisterTestWrapper shouldUnregister={false} />)
|
|
153
|
+
|
|
154
|
+
fireEvent.click(screen.getByRole('button', { name: 'Hide' }))
|
|
155
|
+
fireEvent.click(screen.getByRole('button', { name: 'Read' }))
|
|
156
|
+
|
|
157
|
+
expect(screen.getByTestId('form-values')).toHaveTextContent('short-option')
|
|
158
|
+
})
|
|
102
159
|
})
|
|
@@ -42,6 +42,7 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
42
42
|
onInputChange?: AutocompleteProps<Option, boolean, boolean, false>['onInputChange']
|
|
43
43
|
|
|
44
44
|
slotProps?: {
|
|
45
|
+
controller?: Partial<Omit<TControllerProps, ImmediateControllerProps>>
|
|
45
46
|
field?: Partial<
|
|
46
47
|
Omit<
|
|
47
48
|
AutocompleteProps<Option, boolean, boolean, false>,
|
|
@@ -94,6 +95,7 @@ function RcSesSelect(props: Props) {
|
|
|
94
95
|
name,
|
|
95
96
|
rules,
|
|
96
97
|
shouldUnregister: true,
|
|
98
|
+
...slotProps?.controller,
|
|
97
99
|
})
|
|
98
100
|
|
|
99
101
|
const hasError = !!errors
|
|
@@ -15,8 +15,19 @@
|
|
|
15
15
|
"options": "Options",
|
|
16
16
|
"tabs": "Tabs"
|
|
17
17
|
},
|
|
18
|
+
"AdvancedListItemTrailing": {
|
|
19
|
+
"decrease": "Decrease",
|
|
20
|
+
"increase": "Increase",
|
|
21
|
+
"delete": "Delete",
|
|
22
|
+
"toggle": "Toggle",
|
|
23
|
+
"vat": "incl. VAT"
|
|
24
|
+
},
|
|
18
25
|
"Tooltip": {
|
|
19
26
|
"trigger": "Explanation"
|
|
27
|
+
},
|
|
28
|
+
"AdvancedListItemLeading": {
|
|
29
|
+
"moveUp": "Move up",
|
|
30
|
+
"moveDown": "Move down"
|
|
20
31
|
}
|
|
21
32
|
}
|
|
22
33
|
}
|
|
@@ -15,8 +15,19 @@
|
|
|
15
15
|
"options": "Parinktys",
|
|
16
16
|
"tabs": "Skirtukai"
|
|
17
17
|
},
|
|
18
|
+
"AdvancedListItemTrailing": {
|
|
19
|
+
"decrease": "Sumažinti",
|
|
20
|
+
"increase": "Padidinti",
|
|
21
|
+
"delete": "Pašalinti",
|
|
22
|
+
"toggle": "Perjungti",
|
|
23
|
+
"vat": "su PVM"
|
|
24
|
+
},
|
|
18
25
|
"Tooltip": {
|
|
19
26
|
"trigger": "Paaiškinimas"
|
|
27
|
+
},
|
|
28
|
+
"AdvancedListItemLeading": {
|
|
29
|
+
"moveUp": "Perkelti aukštyn",
|
|
30
|
+
"moveDown": "Perkelti žemyn"
|
|
20
31
|
}
|
|
21
32
|
}
|
|
22
33
|
}
|
package/src/library/icons.ts
CHANGED
|
@@ -12,6 +12,8 @@ import CaretDownIcon from '@/assets/icons/CaretDownIcon'
|
|
|
12
12
|
import CaretLeftBoldIcon from '@/assets/icons/CaretLeftBoldIcon'
|
|
13
13
|
import CaretLeftIcon from '@/assets/icons/CaretLeftIcon'
|
|
14
14
|
import CaretRightBoldIcon from '@/assets/icons/CaretRightBoldIcon'
|
|
15
|
+
import CaretUpBoldIcon from '@/assets/icons/CaretUpBoldIcon'
|
|
16
|
+
import CaretUpIcon from '@/assets/icons/CaretUpIcon'
|
|
15
17
|
import CheckBoldIcon from '@/assets/icons/CheckBoldIcon'
|
|
16
18
|
import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
|
|
17
19
|
import CheckIcon from '@/assets/icons/CheckIcon'
|
|
@@ -23,11 +25,15 @@ import CopyIcon from '@/assets/icons/CopyIcon'
|
|
|
23
25
|
import DotCircleFilledIcon from '@/assets/icons/DotCircleFilledIcon'
|
|
24
26
|
import ExpandChevronsIcon from '@/assets/icons/ExpandChevronsIcon'
|
|
25
27
|
import InfoFillIcon from '@/assets/icons/InfoFillIcon'
|
|
28
|
+
import ListIcon from '@/assets/icons/ListIcon'
|
|
26
29
|
import MagnifyingGlassIcon from '@/assets/icons/MagnifyingGlassIcon'
|
|
27
30
|
import MapPinAreaIcon from '@/assets/icons/MapPinAreaIcon'
|
|
28
31
|
import MinusBoldIcon from '@/assets/icons/MinusBoldIcon'
|
|
32
|
+
import MinusIcon from '@/assets/icons/MinusIcon'
|
|
33
|
+
import NotePencilIcon from '@/assets/icons/NotePencilIcon'
|
|
29
34
|
import PencilSimpleLineIcon from '@/assets/icons/PencilSimpleLineIcon'
|
|
30
35
|
import PlusBoldIcon from '@/assets/icons/PlusBoldIcon'
|
|
36
|
+
import PlusIcon from '@/assets/icons/PlusIcon'
|
|
31
37
|
import QuestionFillIcon from '@/assets/icons/QuestionFillIcon'
|
|
32
38
|
import QuestionIcon from '@/assets/icons/QuestionIcon'
|
|
33
39
|
import ScalesIcon from '@/assets/icons/ScalesIcon'
|
|
@@ -35,7 +41,9 @@ import ScrollIcon from '@/assets/icons/ScrollIcon'
|
|
|
35
41
|
import SearchHelpIcon from '@/assets/icons/SearchHelpIcon'
|
|
36
42
|
import SearchXIcon from '@/assets/icons/SearchXIcon'
|
|
37
43
|
import SpinnerGapBoldIcon from '@/assets/icons/SpinnerGapBoldIcon'
|
|
44
|
+
import TrashIcon from '@/assets/icons/TrashIcon'
|
|
38
45
|
import UploadSimpleIcon from '@/assets/icons/UploadSimpleIcon'
|
|
46
|
+
import UserIcon from '@/assets/icons/UserIcon'
|
|
39
47
|
import WarningCircleIcon from '@/assets/icons/WarningCircleIcon'
|
|
40
48
|
import WarningDiamondFillIcon from '@/assets/icons/WarningDiamondFillIcon'
|
|
41
49
|
import WarningFillIcon from '@/assets/icons/WarningFillIcon'
|
|
@@ -56,6 +64,8 @@ export {
|
|
|
56
64
|
CaretLeftBoldIcon,
|
|
57
65
|
CaretLeftIcon,
|
|
58
66
|
CaretRightBoldIcon,
|
|
67
|
+
CaretUpIcon,
|
|
68
|
+
CaretUpBoldIcon,
|
|
59
69
|
CheckBoldIcon,
|
|
60
70
|
CheckCircleFillIcon,
|
|
61
71
|
CheckIcon,
|
|
@@ -67,11 +77,15 @@ export {
|
|
|
67
77
|
DotCircleFilledIcon,
|
|
68
78
|
ExpandChevronsIcon,
|
|
69
79
|
InfoFillIcon,
|
|
80
|
+
ListIcon,
|
|
70
81
|
MagnifyingGlassIcon,
|
|
71
82
|
MapPinAreaIcon,
|
|
72
83
|
MinusBoldIcon,
|
|
84
|
+
MinusIcon,
|
|
85
|
+
NotePencilIcon,
|
|
73
86
|
PencilSimpleLineIcon,
|
|
74
87
|
PlusBoldIcon,
|
|
88
|
+
PlusIcon,
|
|
75
89
|
QuestionFillIcon,
|
|
76
90
|
QuestionIcon,
|
|
77
91
|
ScalesIcon,
|
|
@@ -79,7 +93,9 @@ export {
|
|
|
79
93
|
SearchHelpIcon,
|
|
80
94
|
SearchXIcon,
|
|
81
95
|
SpinnerGapBoldIcon,
|
|
96
|
+
TrashIcon,
|
|
82
97
|
UploadSimpleIcon,
|
|
98
|
+
UserIcon,
|
|
83
99
|
WarningDiamondFillIcon,
|
|
84
100
|
WarningFillIcon,
|
|
85
101
|
WarningCircleIcon,
|
package/src/library/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type {} from '@mui/x-date-pickers/themeAugmentation'
|
|
|
5
5
|
import RcSesIconProps from '@/assets/IconProps'
|
|
6
6
|
import RcSesAccordion from '@/components/common/Accordion'
|
|
7
7
|
import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
|
|
8
|
+
import RcSesAdvancedList from '@/components/common/AdvancedList'
|
|
9
|
+
import RcSesAdvancedListItem from '@/components/common/AdvancedList/components/AdvancedListItem'
|
|
8
10
|
import RcSesAlert from '@/components/common/Alert'
|
|
9
11
|
import RcSesBadge from '@/components/common/Badge'
|
|
10
12
|
import RcSesBreadcrumbs from '@/components/common/Breadcrumbs'
|
|
@@ -68,6 +70,7 @@ declare module '@mui/x-date-pickers/models' {
|
|
|
68
70
|
|
|
69
71
|
export { RcSesPalette, RcSesTheme }
|
|
70
72
|
export { RcSesAccordion, useAccordionController }
|
|
73
|
+
export { RcSesAdvancedList, RcSesAdvancedListItem }
|
|
71
74
|
export {
|
|
72
75
|
RcSesAlert,
|
|
73
76
|
RcSesBadge,
|
package/src/setupTests.ts
CHANGED
|
@@ -2,13 +2,19 @@ import '@testing-library/jest-dom/vitest'
|
|
|
2
2
|
import i18n from 'i18next'
|
|
3
3
|
import { initReactI18next } from 'react-i18next'
|
|
4
4
|
|
|
5
|
+
import commonEn from '@/i18n/namespaces/common/en.json'
|
|
6
|
+
import commonLt from '@/i18n/namespaces/common/lt.json'
|
|
7
|
+
import inputEn from '@/i18n/namespaces/input/en.json'
|
|
8
|
+
import inputLt from '@/i18n/namespaces/input/lt.json'
|
|
9
|
+
|
|
5
10
|
if (!i18n.isInitialized) {
|
|
6
11
|
i18n.use(initReactI18next).init({
|
|
7
12
|
fallbackLng: 'lt',
|
|
8
13
|
interpolation: { escapeValue: false },
|
|
9
14
|
lng: 'lt',
|
|
10
15
|
resources: {
|
|
11
|
-
lt: {
|
|
16
|
+
lt: { common: commonLt, input: inputLt },
|
|
17
|
+
en: { common: commonEn, input: inputEn },
|
|
12
18
|
},
|
|
13
19
|
})
|
|
14
20
|
}
|