@campxdev/shared 1.4.1 → 1.4.3
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/package.json +1 -1
- package/src/components/ActionButton.tsx +0 -1
- package/src/components/Chips.tsx +1 -1
- package/src/components/HookForm/MultiSelect.tsx +25 -78
- package/src/components/HookForm/TextField.tsx +2 -4
- package/src/components/Input/MultiSelect.tsx +95 -12
- package/src/components/Input/SingleCheckbox.tsx +4 -2
- package/src/components/Input/SingleSelect.tsx +1 -7
- package/src/components/Input/TextField.tsx +4 -7
- package/src/theme/muiTheme.ts +26 -31
package/package.json
CHANGED
|
@@ -8,7 +8,6 @@ interface ActionButtonProps extends ButtonProps {
|
|
|
8
8
|
export default function ActionButton({ loading, ...props }: ActionButtonProps) {
|
|
9
9
|
return (
|
|
10
10
|
<Button
|
|
11
|
-
fullWidth
|
|
12
11
|
sx={{ height: '50px' }}
|
|
13
12
|
variant={!props?.variant ? 'contained' : props?.variant}
|
|
14
13
|
endIcon={loading ? <CircularProgress size={20} /> : null}
|
package/src/components/Chips.tsx
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Autocomplete, CircularProgress, TextField } from '@mui/material'
|
|
3
|
-
import React from 'react'
|
|
1
|
+
import { ReactNode } from 'react'
|
|
4
2
|
import { Controller } from 'react-hook-form'
|
|
5
|
-
import
|
|
3
|
+
import { MultiSelect } from '../Input'
|
|
6
4
|
|
|
7
5
|
interface MultiSelectProps {
|
|
8
|
-
control
|
|
9
|
-
label:
|
|
10
|
-
name
|
|
11
|
-
options: {
|
|
6
|
+
control: any
|
|
7
|
+
label: ReactNode
|
|
8
|
+
name: string
|
|
9
|
+
options: { label: ReactNode; value: any }[]
|
|
12
10
|
placeholder?: string
|
|
13
11
|
loading?: boolean
|
|
14
|
-
|
|
15
|
-
hookForm?: boolean
|
|
16
|
-
value?: any
|
|
17
|
-
onChange?: (value: any) => void
|
|
12
|
+
required?: boolean
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
export default function FormMultiSelect({
|
|
@@ -23,78 +18,30 @@ export default function FormMultiSelect({
|
|
|
23
18
|
options,
|
|
24
19
|
label,
|
|
25
20
|
loading,
|
|
26
|
-
|
|
27
|
-
onChange,
|
|
28
|
-
hookForm = true,
|
|
21
|
+
required,
|
|
29
22
|
...props
|
|
30
23
|
}: MultiSelectProps) {
|
|
31
|
-
if (!hookForm) {
|
|
32
|
-
return (
|
|
33
|
-
<Autocomplete
|
|
34
|
-
multiple
|
|
35
|
-
value={value}
|
|
36
|
-
loading={loading}
|
|
37
|
-
fullWidth
|
|
38
|
-
isOptionEqualToValue={(option, value) => option.key === value.key}
|
|
39
|
-
onChange={(e, value) => {
|
|
40
|
-
if (!onChange) return
|
|
41
|
-
onChange(value)
|
|
42
|
-
}}
|
|
43
|
-
options={options || []}
|
|
44
|
-
getOptionLabel={(option) => option?.name || ''}
|
|
45
|
-
renderInput={(params) => (
|
|
46
|
-
<TextField
|
|
47
|
-
{...params}
|
|
48
|
-
variant="outlined"
|
|
49
|
-
label={<FormLabel label={label} required={props.required} />}
|
|
50
|
-
/>
|
|
51
|
-
)}
|
|
52
|
-
{...props}
|
|
53
|
-
/>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
24
|
return (
|
|
57
25
|
<Controller
|
|
58
26
|
control={control}
|
|
59
27
|
name={name}
|
|
60
|
-
render={({ field, fieldState: { error } }) =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...params.InputProps,
|
|
78
|
-
endAdornment: (
|
|
79
|
-
<React.Fragment>
|
|
80
|
-
{loading ? (
|
|
81
|
-
<CircularProgress color="inherit" size={20} />
|
|
82
|
-
) : null}
|
|
83
|
-
{params.InputProps.endAdornment}
|
|
84
|
-
</React.Fragment>
|
|
85
|
-
),
|
|
86
|
-
}}
|
|
87
|
-
label={<FormLabel label={label} required={props.required} />}
|
|
88
|
-
error={error ? true : false}
|
|
89
|
-
helperText={error ? error.message : null}
|
|
90
|
-
/>
|
|
91
|
-
)}
|
|
92
|
-
ChipProps={{
|
|
93
|
-
deleteIcon: <Close />,
|
|
94
|
-
}}
|
|
95
|
-
{...props}
|
|
96
|
-
/>
|
|
97
|
-
)}
|
|
28
|
+
render={({ field, fieldState: { error } }) => {
|
|
29
|
+
return (
|
|
30
|
+
<MultiSelect
|
|
31
|
+
value={field.value}
|
|
32
|
+
label={label}
|
|
33
|
+
onChange={(e) => {
|
|
34
|
+
field.onChange(e)
|
|
35
|
+
}}
|
|
36
|
+
loading={loading}
|
|
37
|
+
options={options || []}
|
|
38
|
+
error={!!error}
|
|
39
|
+
required={required}
|
|
40
|
+
helperText={error ? error.message : null}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
)
|
|
44
|
+
}}
|
|
98
45
|
/>
|
|
99
46
|
)
|
|
100
47
|
}
|
|
@@ -4,11 +4,9 @@ import { Controller } from 'react-hook-form'
|
|
|
4
4
|
import { TextField } from '../Input'
|
|
5
5
|
|
|
6
6
|
type MyTextFieldProps = MuiTextFieldProps & {
|
|
7
|
-
control
|
|
7
|
+
control: any
|
|
8
8
|
label?: string
|
|
9
|
-
name
|
|
10
|
-
value?: any
|
|
11
|
-
hookForm?: boolean
|
|
9
|
+
name: string
|
|
12
10
|
required?: boolean
|
|
13
11
|
handleChange?: React.ChangeEventHandler<
|
|
14
12
|
HTMLTextAreaElement | HTMLInputElement
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { Close } from '@mui/icons-material'
|
|
2
|
-
import {
|
|
1
|
+
import { Close, KeyboardArrowDown } from '@mui/icons-material'
|
|
2
|
+
import {
|
|
3
|
+
alpha,
|
|
4
|
+
Autocomplete,
|
|
5
|
+
Checkbox,
|
|
6
|
+
CircularProgress,
|
|
7
|
+
Popper,
|
|
8
|
+
styled,
|
|
9
|
+
} from '@mui/material'
|
|
3
10
|
import { ReactNode } from 'react'
|
|
4
|
-
import
|
|
11
|
+
import { BpCheckedIcon, BpIcon } from './SingleCheckbox'
|
|
12
|
+
import TextField from './TextField'
|
|
5
13
|
|
|
6
14
|
interface MultiSelectProps {
|
|
7
|
-
label:
|
|
15
|
+
label: ReactNode
|
|
8
16
|
name?: string
|
|
9
17
|
options: { label: string | ReactNode; value: any }[]
|
|
10
18
|
placeholder?: string
|
|
@@ -12,8 +20,53 @@ interface MultiSelectProps {
|
|
|
12
20
|
value: { label: string | ReactNode; value: any }[]
|
|
13
21
|
onChange: (value: any) => void
|
|
14
22
|
required?: boolean
|
|
23
|
+
error?: boolean
|
|
24
|
+
helperText?: string
|
|
15
25
|
}
|
|
16
26
|
|
|
27
|
+
const StyledAutocomplete = styled(Autocomplete)(({ theme }) => ({
|
|
28
|
+
'& .MuiAutocomplete-tag': {
|
|
29
|
+
border: '1px solid #D1D1D1',
|
|
30
|
+
background: '#F8F8F8',
|
|
31
|
+
borderRadius: '5px',
|
|
32
|
+
height: '38px',
|
|
33
|
+
'& .MuiSvgIcon-root': {
|
|
34
|
+
fontSize: '15px',
|
|
35
|
+
marginLeft: '5px',
|
|
36
|
+
fontWeight: 700,
|
|
37
|
+
color: theme.palette.secondary.main,
|
|
38
|
+
'&:hover': {
|
|
39
|
+
color: alpha(theme.palette.secondary.main, 0.8),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}))
|
|
44
|
+
|
|
45
|
+
const StyledPopper = styled(Popper)(({ theme }) => ({
|
|
46
|
+
'& .MuiPaper-root': {
|
|
47
|
+
borderRadius: '10px',
|
|
48
|
+
borderTopRightRadius: 0,
|
|
49
|
+
borderTopLeftRadius: 0,
|
|
50
|
+
boxShadow: '0px 4px 16px #0000000F',
|
|
51
|
+
maxHeight: 360,
|
|
52
|
+
marginTop: '1px',
|
|
53
|
+
'& .MuiAutocomplete-listbox': {
|
|
54
|
+
minWidth: '240px',
|
|
55
|
+
padding: '10px',
|
|
56
|
+
'& .MuiAutocomplete-option': {
|
|
57
|
+
padding: '10px',
|
|
58
|
+
background: 'none',
|
|
59
|
+
'&.Mui-focused': {
|
|
60
|
+
background: 'none',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
'& .MuiCheckbox-root': {
|
|
64
|
+
padding: 0,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
}))
|
|
69
|
+
|
|
17
70
|
export default function MultiSelect({
|
|
18
71
|
name,
|
|
19
72
|
options,
|
|
@@ -22,30 +75,60 @@ export default function MultiSelect({
|
|
|
22
75
|
value,
|
|
23
76
|
onChange,
|
|
24
77
|
required,
|
|
78
|
+
error,
|
|
79
|
+
helperText,
|
|
25
80
|
...props
|
|
26
81
|
}: MultiSelectProps) {
|
|
27
82
|
return (
|
|
28
|
-
<
|
|
83
|
+
<StyledAutocomplete
|
|
29
84
|
multiple
|
|
30
85
|
value={value}
|
|
31
86
|
loading={loading}
|
|
32
87
|
fullWidth
|
|
88
|
+
getOptionLabel={(option: any) => option?.label || ''}
|
|
89
|
+
options={options || []}
|
|
33
90
|
onChange={(e, value) => {
|
|
34
91
|
if (!onChange) return
|
|
35
92
|
onChange(value)
|
|
36
93
|
}}
|
|
37
|
-
|
|
38
|
-
|
|
94
|
+
isOptionEqualToValue={(option: any, value: any) =>
|
|
95
|
+
option.value === value.value
|
|
96
|
+
}
|
|
97
|
+
disableCloseOnSelect
|
|
98
|
+
PopperComponent={StyledPopper}
|
|
99
|
+
renderOption={(props, option: any, { selected }) => (
|
|
100
|
+
<li {...props}>
|
|
101
|
+
<Checkbox
|
|
102
|
+
icon={<BpIcon />}
|
|
103
|
+
checkedIcon={<BpCheckedIcon />}
|
|
104
|
+
style={{ marginRight: 8 }}
|
|
105
|
+
checked={selected}
|
|
106
|
+
/>
|
|
107
|
+
{option.label}
|
|
108
|
+
</li>
|
|
109
|
+
)}
|
|
110
|
+
popupIcon={<KeyboardArrowDown />}
|
|
111
|
+
ChipProps={{ deleteIcon: <Close /> }}
|
|
39
112
|
renderInput={(params) => (
|
|
40
113
|
<TextField
|
|
114
|
+
error={error}
|
|
115
|
+
helperText={helperText}
|
|
116
|
+
label={label}
|
|
117
|
+
required={required}
|
|
118
|
+
InputProps={{
|
|
119
|
+
...params.InputProps,
|
|
120
|
+
endAdornment: (
|
|
121
|
+
<>
|
|
122
|
+
{loading ? (
|
|
123
|
+
<CircularProgress color="inherit" size={20} />
|
|
124
|
+
) : null}
|
|
125
|
+
{params.InputProps.endAdornment}
|
|
126
|
+
</>
|
|
127
|
+
),
|
|
128
|
+
}}
|
|
41
129
|
{...params}
|
|
42
|
-
variant="outlined"
|
|
43
|
-
label={<FormLabel label={label} required={required} name={name} />}
|
|
44
130
|
/>
|
|
45
131
|
)}
|
|
46
|
-
ChipProps={{
|
|
47
|
-
deleteIcon: <Close />,
|
|
48
|
-
}}
|
|
49
132
|
{...props}
|
|
50
133
|
/>
|
|
51
134
|
)
|
|
@@ -6,10 +6,11 @@ import {
|
|
|
6
6
|
} from '@mui/material'
|
|
7
7
|
import { ReactNode } from 'react'
|
|
8
8
|
|
|
9
|
-
const BpIcon = styled('span')(({}) => ({
|
|
9
|
+
export const BpIcon = styled('span')(({}) => ({
|
|
10
10
|
borderRadius: 3,
|
|
11
11
|
width: 18,
|
|
12
12
|
height: 18,
|
|
13
|
+
marginLeft: '2px',
|
|
13
14
|
border: '1px solid #CBCBCB',
|
|
14
15
|
backgroundColor: '#F8F8F8',
|
|
15
16
|
'.Mui-focusVisible &': {
|
|
@@ -25,11 +26,12 @@ const BpIcon = styled('span')(({}) => ({
|
|
|
25
26
|
},
|
|
26
27
|
}))
|
|
27
28
|
|
|
28
|
-
const BpCheckedIcon = styled(BpIcon)(({ theme }) => ({
|
|
29
|
+
export const BpCheckedIcon = styled(BpIcon)(({ theme }) => ({
|
|
29
30
|
backgroundColor: '#F8F8F8',
|
|
30
31
|
border: `1px solid ${theme.palette.primary.main}`,
|
|
31
32
|
backgroundImage:
|
|
32
33
|
'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))',
|
|
34
|
+
marginLeft: '2px',
|
|
33
35
|
'&:before': {
|
|
34
36
|
content: '""',
|
|
35
37
|
display: 'block',
|
|
@@ -22,11 +22,7 @@ type Props = {
|
|
|
22
22
|
const StyledFormControl = styled(FormControl)(({ theme }) => ({
|
|
23
23
|
'& .MuiInputBase-root': {
|
|
24
24
|
'& legend': { display: 'none' },
|
|
25
|
-
'& .MuiSelect-select': {
|
|
26
|
-
boxSizing: 'border-box',
|
|
27
|
-
height: '50px',
|
|
28
|
-
padding: '14px',
|
|
29
|
-
},
|
|
25
|
+
'& .MuiSelect-select': {},
|
|
30
26
|
'& .MuiSvgIcon-root': {
|
|
31
27
|
right: '14px',
|
|
32
28
|
},
|
|
@@ -39,8 +35,6 @@ const PaperProps = {
|
|
|
39
35
|
borderRadius: '10px',
|
|
40
36
|
borderTopRightRadius: 0,
|
|
41
37
|
borderTopLeftRadius: 0,
|
|
42
|
-
border: '1px solid #1212121A',
|
|
43
|
-
borderTop: 'none',
|
|
44
38
|
boxShadow: '0px 4px 16px #0000000F',
|
|
45
39
|
maxHeight: 360,
|
|
46
40
|
marginTop: '1px',
|
|
@@ -6,12 +6,6 @@ import {
|
|
|
6
6
|
} from '@mui/material'
|
|
7
7
|
import FieldLabel from './FormLabel'
|
|
8
8
|
|
|
9
|
-
type MyTextFieldProps = MuiTextFieldProps & {
|
|
10
|
-
name?: string
|
|
11
|
-
value?: any
|
|
12
|
-
required?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
const StyledTextField = styled(MuiTextField)(({ theme }) => ({
|
|
16
10
|
'& label': {
|
|
17
11
|
display: 'none',
|
|
@@ -21,6 +15,9 @@ const StyledTextField = styled(MuiTextField)(({ theme }) => ({
|
|
|
21
15
|
display: 'none',
|
|
22
16
|
},
|
|
23
17
|
},
|
|
18
|
+
'& .MuiInputAdornment-positionStart': {
|
|
19
|
+
paddingLeft: '14px',
|
|
20
|
+
},
|
|
24
21
|
}))
|
|
25
22
|
|
|
26
23
|
export default function TextField({
|
|
@@ -30,7 +27,7 @@ export default function TextField({
|
|
|
30
27
|
onChange,
|
|
31
28
|
required = false,
|
|
32
29
|
...rest
|
|
33
|
-
}:
|
|
30
|
+
}: MuiTextFieldProps) {
|
|
34
31
|
return (
|
|
35
32
|
<Box width="100%">
|
|
36
33
|
<FieldLabel label={label} required={required} name={name} />
|
package/src/theme/muiTheme.ts
CHANGED
|
@@ -187,19 +187,18 @@ const muiTheme = createTheme({
|
|
|
187
187
|
MuiInputBase: {
|
|
188
188
|
styleOverrides: {
|
|
189
189
|
root: {
|
|
190
|
-
|
|
190
|
+
minHeight: '50px',
|
|
191
191
|
borderRadius: '10px',
|
|
192
192
|
'& input': {
|
|
193
|
-
padding: '10px 14px',
|
|
194
193
|
fontSize: '15px',
|
|
195
194
|
boxSizing: 'border-box',
|
|
196
|
-
|
|
195
|
+
minHeight: '50px',
|
|
197
196
|
},
|
|
198
197
|
'&.MuiInputBase-sizeSmall': {
|
|
199
198
|
borderRadius: '6px',
|
|
200
|
-
|
|
201
|
-
'& input': {
|
|
202
|
-
'& fieldset': {
|
|
199
|
+
minHeight: '40px',
|
|
200
|
+
'& input': { minHeight: '40px' },
|
|
201
|
+
'& fieldset': { minHeight: '40px' },
|
|
203
202
|
},
|
|
204
203
|
},
|
|
205
204
|
},
|
|
@@ -213,7 +212,7 @@ const muiTheme = createTheme({
|
|
|
213
212
|
},
|
|
214
213
|
'& .MuiOutlinedInput-notchedOutline': {
|
|
215
214
|
top: 1,
|
|
216
|
-
|
|
215
|
+
minHeight: '50px',
|
|
217
216
|
borderColor: alpha(colors.common.black, 0.15),
|
|
218
217
|
'& legend': {
|
|
219
218
|
'& > span': {
|
|
@@ -251,6 +250,23 @@ const muiTheme = createTheme({
|
|
|
251
250
|
MuiFormControl: {
|
|
252
251
|
styleOverrides: {
|
|
253
252
|
root: {
|
|
253
|
+
'&.MuiTextField-root > .MuiInputBase-root': {
|
|
254
|
+
padding: 0,
|
|
255
|
+
},
|
|
256
|
+
'& .MuiSelect-select': {
|
|
257
|
+
padding: '14px',
|
|
258
|
+
'&.MuiInputBase-inputSizeSmall': {
|
|
259
|
+
padding: '10px 14px',
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
'& .MuiAutocomplete-inputRoot.MuiInputBase-root': {
|
|
263
|
+
padding: '5px',
|
|
264
|
+
'& > .MuiInputBase-input': {
|
|
265
|
+
marginLeft: '5px',
|
|
266
|
+
minHeight: '40px',
|
|
267
|
+
padding: 0,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
254
270
|
'& .MuiFormHelperText-root': {
|
|
255
271
|
fontStyle: 'oblique',
|
|
256
272
|
marginTop: '10px',
|
|
@@ -263,37 +279,16 @@ const muiTheme = createTheme({
|
|
|
263
279
|
},
|
|
264
280
|
MuiAutocomplete: {
|
|
265
281
|
styleOverrides: {
|
|
266
|
-
tag: {
|
|
267
|
-
margin: 1,
|
|
268
|
-
},
|
|
282
|
+
tag: { margin: 1 },
|
|
269
283
|
root: {
|
|
270
284
|
'.MuiAutocomplete-inputRoot.MuiOutlinedInput-root .MuiAutocomplete-endAdornment':
|
|
271
285
|
{ right: 14 },
|
|
272
|
-
'& .MuiAutocomplete-tag': {
|
|
273
|
-
border: '1px solid #D1D1D1',
|
|
274
|
-
background: '#F8F8F8',
|
|
275
|
-
borderRadius: '5px',
|
|
276
|
-
height: '38px',
|
|
277
|
-
'& .MuiSvgIcon-root': {
|
|
278
|
-
fontSize: '15px',
|
|
279
|
-
marginLeft: '5px',
|
|
280
|
-
fontWeight: 700,
|
|
281
|
-
color: colors.secondary.main,
|
|
282
|
-
'&:hover': {
|
|
283
|
-
color: alpha(colors.secondary.main, 0.8),
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
'& .MuiInputBase-root': {
|
|
288
|
-
padding: '5px',
|
|
289
|
-
},
|
|
290
286
|
},
|
|
291
287
|
clearIndicator: {
|
|
292
288
|
background: colors.error.lighter,
|
|
293
289
|
borderRadius: '5px',
|
|
294
290
|
color: colors.error.main,
|
|
295
291
|
marginRight: 8,
|
|
296
|
-
|
|
297
292
|
'&:hover': {
|
|
298
293
|
background: colors.error.lighter,
|
|
299
294
|
color: colors.error.dark,
|
|
@@ -301,7 +296,6 @@ const muiTheme = createTheme({
|
|
|
301
296
|
},
|
|
302
297
|
popupIndicator: {
|
|
303
298
|
color: alpha(colors.common.black, 0.5),
|
|
304
|
-
|
|
305
299
|
'&:hover': {
|
|
306
300
|
background: colors.primary.lighter,
|
|
307
301
|
color: colors.primary.main,
|
|
@@ -528,7 +522,8 @@ const muiTheme = createTheme({
|
|
|
528
522
|
MuiChip: {
|
|
529
523
|
styleOverrides: {
|
|
530
524
|
root: {
|
|
531
|
-
fontFamily:
|
|
525
|
+
fontFamily: PRIMARY_FONT,
|
|
526
|
+
fontWeight: 600,
|
|
532
527
|
fontSize: '14px',
|
|
533
528
|
},
|
|
534
529
|
},
|