@registrucentras/rc-ses-react-components 1.6.4 → 1.6.6
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/IconProps.d.ts +2 -0
- package/dist/assets/icons/ArrowsClockwiseIcon.d.ts +3 -0
- package/dist/assets/icons/CheckIcon.d.ts +3 -0
- package/dist/assets/icons/PencilSimpleLineIcon.d.ts +3 -0
- package/dist/components/common/Card/index.d.ts +4 -1
- package/dist/components/form/inputs/SearchInput/index.d.ts +27 -0
- package/dist/components/form/inputs/Select/Select.types.d.ts +5 -0
- package/dist/components/form/inputs/Select/hooks/useFilteredOptions.d.ts +3 -0
- package/dist/components/form/inputs/Select/hooks/useSelectAllLogic.d.ts +7 -0
- package/dist/components/form/inputs/{Select.d.ts → Select/index.d.ts} +12 -12
- package/dist/library/icons.d.ts +3 -1
- package/dist/library/index.d.ts +2 -0
- package/dist/registrucentras-rc-ses-react-components.cjs +11 -11
- package/dist/registrucentras-rc-ses-react-components.js +3346 -2752
- package/dist/stories/components/display/Card.stories.d.ts +6 -47
- package/dist/stories/components/display/ImageCard.stories.d.ts +6 -6
- package/dist/stories/components/feedback/Alert.stories.d.ts +7 -16
- package/dist/stories/components/form/CardFormContainer.stories.d.ts +5 -5
- package/dist/stories/components/form/CheckboxFormControl.stories.d.ts +3 -23
- package/dist/stories/components/form/ServiceFormActions.stories.d.ts +3 -9
- package/dist/stories/components/icons/Icons.stories.d.ts +3 -2
- package/dist/stories/components/inputs/FileDropzone.stories.d.ts +3 -29
- package/dist/stories/components/inputs/NumberStepper.stories.d.ts +3 -31
- package/dist/stories/components/inputs/RadioButtonGroup.stories.d.ts +4 -32
- package/dist/stories/components/inputs/SearchInput.stories.d.ts +11 -0
- package/dist/stories/components/inputs/SearchableField.stories.d.ts +3 -332
- package/dist/stories/components/inputs/Select.stories.d.ts +4 -871
- package/dist/stories/components/inputs/TextField.stories.d.ts +3 -610
- package/dist/stories/components/layout/Footer.stories.d.ts +3 -5
- package/dist/stories/components/navigation/Breadcrumbs.stories.d.ts +4 -6
- package/dist/stories/components/navigation/ServiceWizardStepper.stories.d.ts +5 -5
- package/dist/theme/light/MuiOutlinedInput.d.ts +3 -0
- package/package.json +1 -1
- package/src/assets/IconProps.ts +2 -0
- package/src/assets/icons/ArrowsClockwiseIcon.tsx +16 -0
- package/src/assets/icons/CheckIcon.tsx +23 -0
- package/src/assets/icons/PencilSimpleLineIcon.tsx +17 -0
- package/src/components/common/Card/index.test.tsx +8 -0
- package/src/components/common/Card/index.tsx +64 -25
- package/src/components/common/SelectableCardList/index.tsx +2 -1
- package/src/components/form/components/FormControlWrapper/index.tsx +6 -1
- package/src/components/form/inputs/PhoneInputFormControl/index.tsx +11 -3
- package/src/components/form/inputs/SearchInput/index.test.tsx +203 -0
- package/src/components/form/inputs/SearchInput/index.tsx +282 -0
- package/src/components/form/inputs/Select/Select.types.ts +5 -0
- package/src/components/form/inputs/Select/hooks/useFilteredOptions.ts +18 -0
- package/src/components/form/inputs/Select/hooks/useSelectAllLogic.ts +22 -0
- package/src/components/form/inputs/Select/index.tsx +494 -0
- package/src/i18n/namespaces/input/en.json +5 -0
- package/src/i18n/namespaces/input/lt.json +5 -0
- package/src/library/icons.ts +4 -0
- package/src/library/index.ts +2 -0
- package/src/stories/components/display/Card.stories.tsx +64 -47
- package/src/stories/components/display/ImageCard.stories.tsx +29 -27
- package/src/stories/components/feedback/Alert.stories.tsx +59 -50
- package/src/stories/components/form/CardFormContainer.stories.tsx +77 -63
- package/src/stories/components/form/CheckboxFormControl.stories.tsx +29 -71
- package/src/stories/components/form/ServiceFormActions.stories.tsx +18 -21
- package/src/stories/components/form/ServiceFormContainer.stories.tsx +1 -1
- package/src/stories/components/icons/Icons.stories.tsx +6 -2
- package/src/stories/components/inputs/FileDropzone.stories.tsx +17 -34
- package/src/stories/components/inputs/NumberStepper.stories.tsx +32 -60
- package/src/stories/components/inputs/RadioButtonGroup.stories.tsx +22 -20
- package/src/stories/components/inputs/SearchInput.stories.tsx +134 -0
- package/src/stories/components/inputs/SearchableField.stories.tsx +16 -14
- package/src/stories/components/inputs/Select.stories.tsx +245 -13
- package/src/stories/components/inputs/TextField.stories.tsx +47 -47
- package/src/stories/components/layout/Footer.stories.tsx +6 -6
- package/src/stories/components/navigation/Breadcrumbs.stories.tsx +6 -8
- package/src/stories/components/navigation/ServiceWizardStepper.stories.tsx +29 -22
- package/src/theme/light/MuiAutocomplete.ts +52 -3
- package/src/theme/light/MuiOutlinedInput.ts +15 -0
- package/src/theme/light/index.tsx +2 -0
- package/src/components/form/inputs/Select.tsx +0 -152
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Meta, StoryContext, StoryFn } from '@storybook/react'
|
|
1
|
+
import { Meta, StoryContext, StoryObj } from '@storybook/react'
|
|
3
2
|
|
|
4
3
|
import RcSesTextField from '@/components/form/inputs/TextField'
|
|
5
4
|
import FieldPreviewRow from '@/components/storybook/FieldPreviewRow'
|
|
@@ -15,38 +14,7 @@ const meta: Meta<typeof RcSesTextField> = {
|
|
|
15
14
|
|
|
16
15
|
export default meta
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
<Fields>
|
|
20
|
-
<FieldView>
|
|
21
|
-
<RcSesTextField {...args} />
|
|
22
|
-
</FieldView>
|
|
23
|
-
|
|
24
|
-
<FieldPreviewRow>
|
|
25
|
-
<PreviewTitle>State previews label on side</PreviewTitle>
|
|
26
|
-
<RcSesTextField label='Label' />
|
|
27
|
-
<RcSesTextField
|
|
28
|
-
errors={{ message: 'Klaidos pranešimas', type: 'required' }}
|
|
29
|
-
label='Label'
|
|
30
|
-
/>
|
|
31
|
-
<RcSesTextField disabled label='Label' />
|
|
32
|
-
</FieldPreviewRow>
|
|
33
|
-
|
|
34
|
-
<FieldPreviewRow>
|
|
35
|
-
<PreviewTitle>State previews label on top</PreviewTitle>
|
|
36
|
-
<RcSesTextField slotProps={{ wrapper: { labelOnTop: true } }} label='Label' />
|
|
37
|
-
<RcSesTextField
|
|
38
|
-
slotProps={{ wrapper: { labelOnTop: true } }}
|
|
39
|
-
errors={{ message: 'Klaidos pranešimas', type: 'required' }}
|
|
40
|
-
label='Label'
|
|
41
|
-
/>
|
|
42
|
-
<RcSesTextField
|
|
43
|
-
slotProps={{ wrapper: { labelOnTop: true } }}
|
|
44
|
-
disabled
|
|
45
|
-
label='Label'
|
|
46
|
-
/>
|
|
47
|
-
</FieldPreviewRow>
|
|
48
|
-
</Fields>
|
|
49
|
-
)
|
|
17
|
+
type Story = StoryObj<typeof RcSesTextField>
|
|
50
18
|
|
|
51
19
|
const codeBlock = (args: any) => {
|
|
52
20
|
const { slotProps, disabled, label } = args
|
|
@@ -58,20 +26,52 @@ const codeBlock = (args: any) => {
|
|
|
58
26
|
);`
|
|
59
27
|
}
|
|
60
28
|
|
|
61
|
-
export const Main =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
29
|
+
export const Main: Story = {
|
|
30
|
+
render: (args) => (
|
|
31
|
+
<Fields>
|
|
32
|
+
<FieldView>
|
|
33
|
+
<RcSesTextField {...args} />
|
|
34
|
+
</FieldView>
|
|
68
35
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
36
|
+
<FieldPreviewRow>
|
|
37
|
+
<PreviewTitle>State previews label on side</PreviewTitle>
|
|
38
|
+
<RcSesTextField label='Label' />
|
|
39
|
+
<RcSesTextField
|
|
40
|
+
errors={{ message: 'Klaidos pranešimas', type: 'required' }}
|
|
41
|
+
label='Label'
|
|
42
|
+
/>
|
|
43
|
+
<RcSesTextField disabled label='Label' />
|
|
44
|
+
</FieldPreviewRow>
|
|
45
|
+
|
|
46
|
+
<FieldPreviewRow>
|
|
47
|
+
<PreviewTitle>State previews label on top</PreviewTitle>
|
|
48
|
+
<RcSesTextField slotProps={{ wrapper: { labelOnTop: true } }} label='Label' />
|
|
49
|
+
<RcSesTextField
|
|
50
|
+
slotProps={{ wrapper: { labelOnTop: true } }}
|
|
51
|
+
errors={{ message: 'Klaidos pranešimas', type: 'required' }}
|
|
52
|
+
label='Label'
|
|
53
|
+
/>
|
|
54
|
+
<RcSesTextField
|
|
55
|
+
slotProps={{ wrapper: { labelOnTop: true } }}
|
|
56
|
+
disabled
|
|
57
|
+
label='Label'
|
|
58
|
+
/>
|
|
59
|
+
</FieldPreviewRow>
|
|
60
|
+
</Fields>
|
|
61
|
+
),
|
|
62
|
+
args: {
|
|
63
|
+
label: 'label',
|
|
64
|
+
disabled: false,
|
|
65
|
+
multiline: true,
|
|
66
|
+
slotProps: { wrapper: { labelOnTop: false } },
|
|
67
|
+
},
|
|
68
|
+
parameters: {
|
|
69
|
+
docs: {
|
|
70
|
+
source: {
|
|
71
|
+
type: 'dynamic',
|
|
72
|
+
transform: (_code: string, storyContext: StoryContext) =>
|
|
73
|
+
codeBlock(storyContext.args),
|
|
74
|
+
},
|
|
75
75
|
},
|
|
76
76
|
},
|
|
77
77
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { Meta, StoryFn } from '@storybook/react'
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
2
|
|
|
4
3
|
import RcSesFooter from '@/components/layout/Footer'
|
|
5
4
|
|
|
@@ -11,9 +10,10 @@ const meta: Meta<typeof RcSesFooter> = {
|
|
|
11
10
|
|
|
12
11
|
export default meta
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
type Story = StoryObj<typeof RcSesFooter>
|
|
15
14
|
|
|
16
|
-
export const Main =
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export const Main: Story = {
|
|
16
|
+
args: {
|
|
17
|
+
text: '© Valstybės įmonė Registrų centras. Duomenys apie įmonę kaupiami ir saugomi Juridinių asmenų registre.\nStudentų g. 39, LT-08106 Vilnius | tel. +370 5 268 8262 | el. p. info@registrucentras.lt | įmonės kodas 124110246 | PVM mokėtojo kodas LT241102419',
|
|
18
|
+
},
|
|
19
19
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Meta, StoryFn } from '@storybook/react'
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
3
2
|
|
|
4
3
|
import RcSesBreadcrumbs from '@/components/common/Breadcrumbs'
|
|
5
4
|
|
|
@@ -22,11 +21,10 @@ const meta: Meta<typeof RcSesBreadcrumbs> = {
|
|
|
22
21
|
|
|
23
22
|
export default meta
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
<RcSesBreadcrumbs {...args} />
|
|
27
|
-
)
|
|
24
|
+
type Story = StoryObj<typeof RcSesBreadcrumbs>
|
|
28
25
|
|
|
29
|
-
export const Main =
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
export const Main: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
path: Path,
|
|
29
|
+
},
|
|
32
30
|
}
|
|
@@ -27,27 +27,34 @@ export default meta
|
|
|
27
27
|
|
|
28
28
|
type Story = StoryObj<typeof ServiceWizardStepper>
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
30
|
+
function ServiceWizardStepperDemo({
|
|
31
|
+
orientation,
|
|
32
|
+
...args
|
|
33
|
+
}: {
|
|
34
|
+
orientation: 'horizontal' | 'vertical'
|
|
35
|
+
} & Record<string, unknown>) {
|
|
36
|
+
const [activeStep, setActiveStep] = useState(0)
|
|
37
|
+
|
|
38
|
+
const handleStepClick = (index: number) => {
|
|
39
|
+
if (index > activeStep) return
|
|
40
|
+
setActiveStep(index)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<ServiceWizardStepper
|
|
45
|
+
{...args}
|
|
46
|
+
steps={steps}
|
|
47
|
+
activeStep={activeStep}
|
|
48
|
+
onStepClick={handleStepClick}
|
|
49
|
+
orientation={orientation}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
50
53
|
|
|
51
|
-
export const Horizontal =
|
|
54
|
+
export const Horizontal: Story = {
|
|
55
|
+
render: (args) => <ServiceWizardStepperDemo {...args} orientation='horizontal' />,
|
|
56
|
+
}
|
|
52
57
|
|
|
53
|
-
export const Vertical =
|
|
58
|
+
export const Vertical: Story = {
|
|
59
|
+
render: (args) => <ServiceWizardStepperDemo {...args} orientation='vertical' />,
|
|
60
|
+
}
|
|
@@ -9,6 +9,18 @@ const MuiAutocomplete: Components['MuiAutocomplete'] = {
|
|
|
9
9
|
'.MuiOutlinedInput-root': {
|
|
10
10
|
borderRadius: '.5rem',
|
|
11
11
|
|
|
12
|
+
'.MuiOutlinedInput-notchedOutline': {
|
|
13
|
+
borderRadius: '.5rem',
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
'&.Mui-focused': {
|
|
17
|
+
borderRadius: '.5rem',
|
|
18
|
+
|
|
19
|
+
'.MuiOutlinedInput-notchedOutline': {
|
|
20
|
+
borderRadius: '.5rem',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
|
|
12
24
|
'.MuiAutocomplete-input': {
|
|
13
25
|
marginRight: '2rem',
|
|
14
26
|
padding: '.25rem .1875rem',
|
|
@@ -16,20 +28,56 @@ const MuiAutocomplete: Components['MuiAutocomplete'] = {
|
|
|
16
28
|
},
|
|
17
29
|
},
|
|
18
30
|
paper: {
|
|
19
|
-
|
|
31
|
+
backgroundColor: 'white',
|
|
32
|
+
borderRadius: '.375rem',
|
|
20
33
|
fontSize: '.9375rem',
|
|
21
34
|
lineHeight: '1.125rem',
|
|
22
35
|
|
|
23
36
|
'.MuiAutocomplete-listbox': {
|
|
37
|
+
'.MuiAutocomplete-groupLabel': {
|
|
38
|
+
color: palette.primary['600'],
|
|
39
|
+
fontFamily: '"Public Sans", sans-serif',
|
|
40
|
+
fontSize: '.75rem',
|
|
41
|
+
fontStyle: 'normal',
|
|
42
|
+
fontWeight: 500,
|
|
43
|
+
letterSpacing: '.0075rem',
|
|
44
|
+
lineHeight: '140%',
|
|
45
|
+
padding: '.5rem .75rem .25rem',
|
|
46
|
+
textTransform: 'uppercase',
|
|
47
|
+
},
|
|
48
|
+
|
|
24
49
|
'.MuiAutocomplete-option': {
|
|
25
50
|
alignItems: 'flex-start',
|
|
51
|
+
backgroundColor: 'transparent',
|
|
26
52
|
borderRadius: '.375rem',
|
|
53
|
+
color: palette.grey['900'],
|
|
27
54
|
flexDirection: 'column',
|
|
28
55
|
margin: '0 .375rem',
|
|
29
56
|
padding: '.8125rem .75rem',
|
|
57
|
+
transition: 'background-color 150ms cubic-bezier(0.4, 0, 0.2, 1)',
|
|
58
|
+
|
|
59
|
+
'&:hover': {
|
|
60
|
+
backgroundColor: palette.grey['100'],
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
'&.Mui-focused': {
|
|
64
|
+
backgroundColor: palette.grey['100'],
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
'&.Mui-selected': {
|
|
68
|
+
backgroundColor: 'transparent',
|
|
69
|
+
|
|
70
|
+
'&:hover, &.Mui-focused': {
|
|
71
|
+
backgroundColor: palette.grey['100'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
'&[aria-selected="true"]': {
|
|
76
|
+
backgroundColor: 'transparent',
|
|
77
|
+
},
|
|
30
78
|
|
|
31
|
-
'.Mui-focused': {
|
|
32
|
-
|
|
79
|
+
'&[aria-selected="true"].Mui-focused, &[aria-selected="true"]:hover': {
|
|
80
|
+
backgroundColor: palette.grey['100'],
|
|
33
81
|
},
|
|
34
82
|
|
|
35
83
|
'.rc-ses-select-option-label': {
|
|
@@ -42,6 +90,7 @@ const MuiAutocomplete: Components['MuiAutocomplete'] = {
|
|
|
42
90
|
fontStyle: 'italic',
|
|
43
91
|
lineHeight: '1rem',
|
|
44
92
|
marginTop: '.25rem',
|
|
93
|
+
fontWeight: 500,
|
|
45
94
|
},
|
|
46
95
|
},
|
|
47
96
|
},
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Components } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
const MuiOutlinedInput: Components['MuiOutlinedInput'] = {
|
|
4
|
+
styleOverrides: {
|
|
5
|
+
root: {
|
|
6
|
+
borderRadius: '.5rem',
|
|
7
|
+
|
|
8
|
+
'.MuiOutlinedInput-notchedOutline': {
|
|
9
|
+
borderRadius: '.5rem',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default MuiOutlinedInput
|
|
@@ -26,6 +26,7 @@ import MuiFormLabel from '@/theme/light/MuiFormLabel'
|
|
|
26
26
|
import MuiIconButton from '@/theme/light/MuiIconButton'
|
|
27
27
|
import MuiInputBase from '@/theme/light/MuiInputBase'
|
|
28
28
|
import MuiLinearProgress from '@/theme/light/MuiLinearProgress'
|
|
29
|
+
import MuiOutlinedInput from '@/theme/light/MuiOutlinedInput'
|
|
29
30
|
import MuiPickersLayout from '@/theme/light/MuiPickersLayout'
|
|
30
31
|
import MuiPopover from '@/theme/light/MuiPopover'
|
|
31
32
|
import MuiRadio from '@/theme/light/MuiRadio'
|
|
@@ -108,6 +109,7 @@ const theme = createTheme(themePalette, ltLT, enUS, {
|
|
|
108
109
|
MuiIconButton,
|
|
109
110
|
MuiInputBase,
|
|
110
111
|
MuiLinearProgress,
|
|
112
|
+
MuiOutlinedInput,
|
|
111
113
|
MuiPickersLayout,
|
|
112
114
|
MuiPagination,
|
|
113
115
|
MuiPaginationItem,
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Box, CircularProgress, TextField } from '@mui/material'
|
|
2
|
-
import Autocomplete, { AutocompleteProps } from '@mui/material/Autocomplete'
|
|
3
|
-
import React, { useMemo } from 'react'
|
|
4
|
-
import { UseControllerProps, useController } from 'react-hook-form'
|
|
5
|
-
import { v4 as uuidv4 } from 'uuid'
|
|
6
|
-
|
|
7
|
-
import RcSesFormControlWrapper, {
|
|
8
|
-
RcSesFormControlWrapperProps,
|
|
9
|
-
} from '../components/FormControlWrapper'
|
|
10
|
-
|
|
11
|
-
type Option = {
|
|
12
|
-
description?: string
|
|
13
|
-
label: string
|
|
14
|
-
value: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type TControllerProps = UseControllerProps<any, any>
|
|
18
|
-
type ImmediateControllerProps = 'control' | 'rules' | 'name' | 'disabled'
|
|
19
|
-
|
|
20
|
-
type TFieldProps = Omit<
|
|
21
|
-
AutocompleteProps<Option | '', false, boolean, false>,
|
|
22
|
-
'value' | 'disableClearable'
|
|
23
|
-
>
|
|
24
|
-
type ImmediateFieldProps = 'onInputChange'
|
|
25
|
-
|
|
26
|
-
type TWrapperProps = RcSesFormControlWrapperProps
|
|
27
|
-
type ImmediateWrapperProps = 'id' | 'label' | 'errors'
|
|
28
|
-
|
|
29
|
-
type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
30
|
-
Pick<TFieldProps, ImmediateFieldProps> &
|
|
31
|
-
Pick<TWrapperProps, ImmediateWrapperProps> & {
|
|
32
|
-
clearable?: boolean
|
|
33
|
-
loading?: boolean
|
|
34
|
-
options: (Option | '')[]
|
|
35
|
-
placeholder?: string
|
|
36
|
-
slotProps?: {
|
|
37
|
-
controller?: Partial<Omit<TControllerProps, ImmediateControllerProps>>
|
|
38
|
-
field?: Partial<Omit<TFieldProps, ImmediateFieldProps>>
|
|
39
|
-
wrapper?: Partial<Omit<TWrapperProps, ImmediateWrapperProps>>
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function RcSesSelect(props: Props) {
|
|
44
|
-
const [inputValue, setInputValue] = React.useState<string>('')
|
|
45
|
-
|
|
46
|
-
const {
|
|
47
|
-
clearable,
|
|
48
|
-
control,
|
|
49
|
-
errors,
|
|
50
|
-
label,
|
|
51
|
-
loading,
|
|
52
|
-
onInputChange,
|
|
53
|
-
options,
|
|
54
|
-
placeholder,
|
|
55
|
-
rules,
|
|
56
|
-
slotProps,
|
|
57
|
-
...fieldProps
|
|
58
|
-
} = props
|
|
59
|
-
const { disabled, name } = fieldProps
|
|
60
|
-
|
|
61
|
-
const id = useMemo(() => fieldProps.id ?? uuidv4(), [fieldProps.id])
|
|
62
|
-
|
|
63
|
-
const {
|
|
64
|
-
field: { onChange, value },
|
|
65
|
-
} = useController({
|
|
66
|
-
control,
|
|
67
|
-
name,
|
|
68
|
-
rules,
|
|
69
|
-
shouldUnregister: true,
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
const hasError = !!errors
|
|
73
|
-
|
|
74
|
-
const resolvedValue = React.useMemo(
|
|
75
|
-
() =>
|
|
76
|
-
value
|
|
77
|
-
? {
|
|
78
|
-
value,
|
|
79
|
-
label: (options.find((o) => (o && o.value) === value) as Option)?.label ?? '',
|
|
80
|
-
}
|
|
81
|
-
: null,
|
|
82
|
-
[options, value],
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<RcSesFormControlWrapper
|
|
87
|
-
id={id}
|
|
88
|
-
errors={errors}
|
|
89
|
-
label={label}
|
|
90
|
-
required={!!rules?.required}
|
|
91
|
-
{...slotProps?.wrapper}
|
|
92
|
-
>
|
|
93
|
-
<Autocomplete
|
|
94
|
-
id={id}
|
|
95
|
-
disabled={disabled}
|
|
96
|
-
disableClearable={clearable === false}
|
|
97
|
-
getOptionLabel={(option) => (typeof option === 'object' ? option.label : '')}
|
|
98
|
-
getOptionKey={(option) => (typeof option === 'object' ? option?.value : '')}
|
|
99
|
-
inputValue={inputValue}
|
|
100
|
-
isOptionEqualToValue={(option, selection) =>
|
|
101
|
-
option === '' ||
|
|
102
|
-
(typeof option === 'object' &&
|
|
103
|
-
typeof selection === 'object' &&
|
|
104
|
-
option?.value === selection?.value)
|
|
105
|
-
}
|
|
106
|
-
loading={loading}
|
|
107
|
-
onChange={(_event, item) => onChange(typeof item === 'object' && item?.value)}
|
|
108
|
-
onInputChange={(event, val, reason) => {
|
|
109
|
-
setInputValue(val ?? null)
|
|
110
|
-
if (onInputChange) onInputChange(event, val, reason)
|
|
111
|
-
}}
|
|
112
|
-
options={options}
|
|
113
|
-
renderInput={(params) => (
|
|
114
|
-
<TextField
|
|
115
|
-
{...params}
|
|
116
|
-
disabled={disabled}
|
|
117
|
-
error={hasError}
|
|
118
|
-
InputProps={{
|
|
119
|
-
...params.InputProps,
|
|
120
|
-
endAdornment: (
|
|
121
|
-
<>
|
|
122
|
-
{loading ? <CircularProgress color='inherit' size={16} /> : null}
|
|
123
|
-
{params.InputProps.endAdornment}
|
|
124
|
-
</>
|
|
125
|
-
),
|
|
126
|
-
}}
|
|
127
|
-
placeholder={placeholder}
|
|
128
|
-
/>
|
|
129
|
-
)}
|
|
130
|
-
renderOption={(optionProps, option, _state, ownerState) => {
|
|
131
|
-
const { key, ...rest } = optionProps as any
|
|
132
|
-
return (
|
|
133
|
-
<Box key={key} component='li' {...rest}>
|
|
134
|
-
<span className='rc-ses-select-option-label'>
|
|
135
|
-
{ownerState.getOptionLabel(option)}
|
|
136
|
-
</span>
|
|
137
|
-
{!!option && (
|
|
138
|
-
<span className='rc-ses-select-option-description'>
|
|
139
|
-
{option.description}
|
|
140
|
-
</span>
|
|
141
|
-
)}
|
|
142
|
-
</Box>
|
|
143
|
-
)
|
|
144
|
-
}}
|
|
145
|
-
value={resolvedValue}
|
|
146
|
-
{...slotProps?.field}
|
|
147
|
-
/>
|
|
148
|
-
</RcSesFormControlWrapper>
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export default RcSesSelect
|