1
1
import React , { useEffect , useState , forwardRef , useRef } from "react" ;
2
- import { onChangeInput } from "../../constant/Utils" ;
2
+ import { getMonth , getYear , onChangeInput , range } from "../../constant/Utils" ;
3
3
import DatePicker from "react-datepicker" ;
4
4
import "react-datepicker/dist/react-datepicker.css" ;
5
5
import "../../styles/signature.css" ;
@@ -15,6 +15,21 @@ function PlaceholderType(props) {
15
15
const inputRef = useRef ( null ) ;
16
16
const [ textValue , setTextValue ] = useState ( ) ;
17
17
const [ selectedCheckbox , setSelectedCheckbox ] = useState ( [ ] ) ;
18
+ const years = range ( 1990 , getYear ( new Date ( ) ) + 16 , 1 ) ;
19
+ const months = [
20
+ "January" ,
21
+ "February" ,
22
+ "March" ,
23
+ "April" ,
24
+ "May" ,
25
+ "June" ,
26
+ "July" ,
27
+ "August" ,
28
+ "September" ,
29
+ "October" ,
30
+ "November" ,
31
+ "December"
32
+ ] ;
18
33
const validateExpression = ( regexValidation ) => {
19
34
let regexObject = regexValidation ;
20
35
if ( props . pos ?. options . validation . type === "regex" ) {
@@ -31,7 +46,6 @@ function PlaceholderType(props) {
31
46
const handleInputBlur = ( ) => {
32
47
props . setDraggingEnabled ( true ) ;
33
48
const validateType = props . pos ?. options ?. validation ?. type ;
34
-
35
49
let regexValidation ;
36
50
if ( validateType ) {
37
51
switch ( validateType ) {
@@ -293,6 +307,7 @@ function PlaceholderType(props) {
293
307
isRadio
294
308
) ;
295
309
} ;
310
+
296
311
switch ( type ) {
297
312
case "signature" :
298
313
return props . pos . SignUrl ? (
@@ -595,6 +610,34 @@ function PlaceholderType(props) {
595
610
return (
596
611
< div >
597
612
< DatePicker
613
+ renderCustomHeader = { ( { date, changeYear, changeMonth } ) => (
614
+ < div className = "flex justify-start ml-2 " >
615
+ < select
616
+ className = "bg-transparent outline-none"
617
+ value = { months [ getMonth ( date ) ] }
618
+ onChange = { ( { target : { value } } ) =>
619
+ changeMonth ( months . indexOf ( value ) )
620
+ }
621
+ >
622
+ { months . map ( ( option ) => (
623
+ < option key = { option } value = { option } >
624
+ { option }
625
+ </ option >
626
+ ) ) }
627
+ </ select >
628
+ < select
629
+ className = "bg-transparent outline-none"
630
+ value = { getYear ( date ) }
631
+ onChange = { ( { target : { value } } ) => changeYear ( value ) }
632
+ >
633
+ { years . map ( ( option ) => (
634
+ < option key = { option } value = { option } >
635
+ { option }
636
+ </ option >
637
+ ) ) }
638
+ </ select >
639
+ </ div >
640
+ ) }
598
641
disabled = {
599
642
props . isNeedSign && props . data ?. signerObjId !== props . signerObjId
600
643
}
0 commit comments