@campxdev/shared 1.4.16 → 1.4.18
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 -3
- package/src/components/IconButtons/Icons.tsx +3 -3
- package/src/components/Image/Image.tsx +4 -2
- package/src/components/Input/DatePicker.tsx +1 -1
- package/src/components/Input/DateRangePicker.tsx +76 -123
- package/src/components/Input/DateTimePicker.tsx +4 -2
- package/src/components/index.ts +2 -0
- package/src/theme/muiTheme.ts +2 -2
- package/src/utils/index.ts +0 -1
- package/yarn-error.log +4 -18069
- package/src/utils/withLocalization.tsx +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@campxdev/shared",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.18",
|
|
4
4
|
"main": "./exports.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "react-scripts start",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"@mui/icons-material": "^5.6.2",
|
|
34
34
|
"@mui/lab": "^5.0.0-alpha.112",
|
|
35
35
|
"@mui/material": "^5.7.0",
|
|
36
|
-
"@mui/x-date-pickers": "^5.0.0-alpha.3",
|
|
37
36
|
"axios": "^0.27.2",
|
|
38
37
|
"date-fns": "^2.28.0",
|
|
39
38
|
"js-cookie": "^3.0.1",
|
|
@@ -77,7 +76,6 @@
|
|
|
77
76
|
"eslint-plugin-prettier": "^4.2.1",
|
|
78
77
|
"eslint-plugin-react": "^7.31.1",
|
|
79
78
|
"eslint-plugin-storybook": "^0.6.8",
|
|
80
|
-
"lerna": "^5.5.1",
|
|
81
79
|
"prettier": "^2.5.0",
|
|
82
80
|
"react-scripts": "^5.0.1",
|
|
83
81
|
"storybook-addon-react-router-v6": "^0.2.1",
|
|
@@ -249,9 +249,9 @@ export const DateRangeIcon = () => {
|
|
|
249
249
|
return (
|
|
250
250
|
<svg
|
|
251
251
|
xmlns="http://www.w3.org/2000/svg"
|
|
252
|
-
width="
|
|
253
|
-
height="
|
|
254
|
-
viewBox="0 0
|
|
252
|
+
width="20"
|
|
253
|
+
height="15"
|
|
254
|
+
viewBox="0 0 20 15"
|
|
255
255
|
>
|
|
256
256
|
<g id="transfer" transform="translate(0 -51.198)" opacity="0.501">
|
|
257
257
|
<g id="Group_807" data-name="Group 807" transform="translate(0 51.198)">
|
|
@@ -8,6 +8,7 @@ interface ImageProps {
|
|
|
8
8
|
width: string | number
|
|
9
9
|
fit?: 'cover' | 'contain' | 'fill'
|
|
10
10
|
radius?: string | number
|
|
11
|
+
defaultImage?: any
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export default function Image({
|
|
@@ -17,6 +18,7 @@ export default function Image({
|
|
|
17
18
|
width,
|
|
18
19
|
fit = 'contain',
|
|
19
20
|
radius = '10px',
|
|
21
|
+
defaultImage = null,
|
|
20
22
|
}: ImageProps) {
|
|
21
23
|
return (
|
|
22
24
|
<Box
|
|
@@ -32,10 +34,10 @@ export default function Image({
|
|
|
32
34
|
}}
|
|
33
35
|
>
|
|
34
36
|
<img
|
|
35
|
-
src={src}
|
|
37
|
+
src={src || defaultImage}
|
|
36
38
|
alt={alt}
|
|
37
39
|
onError={(e: any) => {
|
|
38
|
-
e.target.src = brokenImage
|
|
40
|
+
e.target.src = defaultImage ? defaultImage : brokenImage
|
|
39
41
|
}}
|
|
40
42
|
/>
|
|
41
43
|
</Box>
|
|
@@ -1,131 +1,84 @@
|
|
|
1
|
+
import { Box, styled, SvgIcon } from '@mui/material'
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
1
3
|
import { DateRangeIcon } from '../IconButtons'
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import DateTimePicker from './DateTimePicker'
|
|
5
|
+
|
|
6
|
+
const StyledDateRangePicker = styled(Box)<{ size: 'small' | 'medium' }>(
|
|
7
|
+
({ theme, size }) => ({
|
|
8
|
+
borderRadius: '10px',
|
|
9
|
+
height: '50px',
|
|
10
|
+
display: 'flex',
|
|
11
|
+
justifyContent: 'space-between',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
border: theme.borders.grayLight,
|
|
14
|
+
'& .MuiOutlinedInput-notchedOutline': {
|
|
15
|
+
display: 'none',
|
|
16
|
+
},
|
|
17
|
+
'& .MuiSvgIcon-root': {
|
|
18
|
+
margin: '0 20px',
|
|
19
|
+
marginTop: '8px',
|
|
20
|
+
},
|
|
21
|
+
...(size === 'small' && {
|
|
22
|
+
borderRadius: '5px',
|
|
23
|
+
height: '40px',
|
|
24
|
+
'& .MuiSvgIcon-root': {
|
|
25
|
+
margin: '0 20px',
|
|
26
|
+
marginTop: '8px',
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
}),
|
|
30
|
+
)
|
|
31
|
+
|
|
6
32
|
interface Props {
|
|
7
|
-
|
|
8
|
-
|
|
33
|
+
value: [Date, Date]
|
|
34
|
+
onChange: (value: [Date, Date]) => void
|
|
35
|
+
enableTime?: boolean
|
|
9
36
|
size?: 'small' | 'medium'
|
|
10
|
-
control?: any
|
|
11
|
-
minDate?: any
|
|
12
|
-
maxDate?: any
|
|
13
|
-
required?: boolean
|
|
14
|
-
|
|
15
|
-
onChangeFromDate: any
|
|
16
|
-
onChangeToDate: any
|
|
17
|
-
fromValue: any
|
|
18
|
-
toValue: any
|
|
19
37
|
}
|
|
20
|
-
export default function DateRangePicker(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} = props
|
|
33
|
-
const [fromOpen, setFromOpen] = useState(false)
|
|
34
|
-
const [toOpen, setToOpen] = useState(false)
|
|
38
|
+
export default function DateRangePicker({
|
|
39
|
+
value,
|
|
40
|
+
onChange,
|
|
41
|
+
enableTime = false,
|
|
42
|
+
size = 'medium',
|
|
43
|
+
}: Props) {
|
|
44
|
+
const [state, setState] = useState([null, null])
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setState(value)
|
|
48
|
+
}, [value])
|
|
49
|
+
|
|
35
50
|
return (
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
borderRadius: '10px',
|
|
44
|
-
padding: '5px',
|
|
51
|
+
<StyledDateRangePicker size={size}>
|
|
52
|
+
<DateTimePicker
|
|
53
|
+
value={state[0]}
|
|
54
|
+
placeholder="From Date"
|
|
55
|
+
onChange={(value) => {
|
|
56
|
+
setState((prev) => [value, prev[1]])
|
|
57
|
+
onChange([value, state[1]])
|
|
45
58
|
}}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
InputProps
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
open={fromOpen}
|
|
71
|
-
renderInput={(params) => (
|
|
72
|
-
<TextField sx={{ width: '200px' }} size={'small'} {...params} />
|
|
73
|
-
)}
|
|
74
|
-
/>
|
|
75
|
-
<Box>
|
|
76
|
-
<DateRangeIcon />
|
|
77
|
-
</Box>
|
|
78
|
-
<StyledDatepicker
|
|
79
|
-
onChange={onChangeToDate}
|
|
80
|
-
value={toValue}
|
|
81
|
-
label={'end date'}
|
|
82
|
-
mask="__/__/____"
|
|
83
|
-
inputFormat="DD/MM/yyyy"
|
|
84
|
-
OpenPickerButtonProps={{
|
|
85
|
-
onFocus: (e) => {
|
|
86
|
-
setToOpen(true)
|
|
87
|
-
},
|
|
88
|
-
}}
|
|
89
|
-
onClose={() => {
|
|
90
|
-
setToOpen(false)
|
|
91
|
-
}}
|
|
92
|
-
PopperProps={{
|
|
93
|
-
disablePortal: true,
|
|
94
|
-
}}
|
|
95
|
-
InputProps={{
|
|
96
|
-
onFocus: () => {
|
|
97
|
-
setToOpen(true)
|
|
98
|
-
},
|
|
99
|
-
}}
|
|
100
|
-
open={toOpen}
|
|
101
|
-
renderInput={(params) => (
|
|
102
|
-
<TextField sx={{ width: '200px' }} size={'small'} {...params} />
|
|
103
|
-
)}
|
|
104
|
-
/>
|
|
105
|
-
</Box>
|
|
106
|
-
{/* {error && (
|
|
107
|
-
<Typography
|
|
108
|
-
variant="caption"
|
|
109
|
-
component={'div'}
|
|
110
|
-
sx={{ pl: '2px' }}
|
|
111
|
-
color="rgb(211, 47, 47)"
|
|
112
|
-
>
|
|
113
|
-
{error.message}
|
|
114
|
-
</Typography>
|
|
115
|
-
)} */}
|
|
116
|
-
</LocalizationProvider>
|
|
59
|
+
enableTime={enableTime}
|
|
60
|
+
inputProps={{
|
|
61
|
+
InputProps: null,
|
|
62
|
+
size: size,
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
<SvgIcon>
|
|
66
|
+
<DateRangeIcon />
|
|
67
|
+
</SvgIcon>
|
|
68
|
+
<DateTimePicker
|
|
69
|
+
value={state[1]}
|
|
70
|
+
minDate={state[0]}
|
|
71
|
+
placeholder="To Date"
|
|
72
|
+
enableTime={enableTime}
|
|
73
|
+
onChange={(value) => {
|
|
74
|
+
setState((prev) => [prev[0], value])
|
|
75
|
+
onChange([state[0], value])
|
|
76
|
+
}}
|
|
77
|
+
inputProps={{
|
|
78
|
+
InputProps: null,
|
|
79
|
+
size: size,
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
</StyledDateRangePicker>
|
|
117
83
|
)
|
|
118
84
|
}
|
|
119
|
-
|
|
120
|
-
const StyledDatepicker = styled(DatePicker)({
|
|
121
|
-
'& .MuiFormLabel-root .Mui-focused': {
|
|
122
|
-
display: 'none',
|
|
123
|
-
},
|
|
124
|
-
'& .MuiInputAdornment-root': {
|
|
125
|
-
display: 'none',
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
'& fieldset': {
|
|
129
|
-
display: 'none',
|
|
130
|
-
},
|
|
131
|
-
})
|
|
@@ -17,6 +17,7 @@ export interface IDateTimePicker {
|
|
|
17
17
|
onChange: (value: Date) => void
|
|
18
18
|
placeholder?: string
|
|
19
19
|
inputProps?: TextFieldProps
|
|
20
|
+
enableTime?: boolean
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export default function DateTimePicker({
|
|
@@ -30,13 +31,14 @@ export default function DateTimePicker({
|
|
|
30
31
|
onChange,
|
|
31
32
|
value,
|
|
32
33
|
placeholder,
|
|
34
|
+
enableTime = true,
|
|
33
35
|
...rest
|
|
34
36
|
}: IDateTimePicker) {
|
|
35
37
|
return (
|
|
36
38
|
<Flatpickr
|
|
37
39
|
options={{
|
|
38
|
-
enableTime
|
|
39
|
-
dateFormat: 'd-m-Y h:i K',
|
|
40
|
+
enableTime,
|
|
41
|
+
dateFormat: enableTime ? 'd-m-Y h:i K' : 'd-m-Y',
|
|
40
42
|
minDate,
|
|
41
43
|
maxDate,
|
|
42
44
|
minTime,
|
package/src/components/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ import DialogWrapper from './DrawerWrapper/DialogWrapper'
|
|
|
25
25
|
import Form from './Form/Form'
|
|
26
26
|
import RenderForm from './Form/RenderForm'
|
|
27
27
|
import AsyncSearchSelect from './Input/AsyncSearchSelect'
|
|
28
|
+
import FilterButton from './FilterComponents/FilterButton'
|
|
28
29
|
export { default as Image } from './Image'
|
|
29
30
|
export { default as PageHeader } from './PageHeader'
|
|
30
31
|
export { PageContent } from './PageContent'
|
|
@@ -79,6 +80,7 @@ export {
|
|
|
79
80
|
Form,
|
|
80
81
|
RenderForm,
|
|
81
82
|
AsyncSearchSelect,
|
|
83
|
+
FilterButton,
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
export * from './UploadButton/types'
|
package/src/theme/muiTheme.ts
CHANGED
|
@@ -217,7 +217,7 @@ const muiTheme = createTheme({
|
|
|
217
217
|
'& .MuiOutlinedInput-notchedOutline': {
|
|
218
218
|
top: 1,
|
|
219
219
|
minHeight: '50px',
|
|
220
|
-
|
|
220
|
+
border: borders.grayLight,
|
|
221
221
|
'& legend': {
|
|
222
222
|
'& > span': {
|
|
223
223
|
paddingRight: 2,
|
|
@@ -225,7 +225,7 @@ const muiTheme = createTheme({
|
|
|
225
225
|
},
|
|
226
226
|
},
|
|
227
227
|
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
228
|
-
borderColor: alpha(colors.common.black, 0.
|
|
228
|
+
borderColor: alpha(colors.common.black, 0.2),
|
|
229
229
|
},
|
|
230
230
|
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
|
|
231
231
|
borderColor: colors.primary.main,
|
package/src/utils/index.ts
CHANGED
|
@@ -4,5 +4,4 @@ export { default as romanize } from './romanize'
|
|
|
4
4
|
|
|
5
5
|
export { default as withRouteWrapper } from './withRouteWrapper'
|
|
6
6
|
export { default as withSuspense } from './withSuspense'
|
|
7
|
-
export { default as withLocalization } from './withLocalization'
|
|
8
7
|
export { default as onLogout } from './logout'
|