@@ -114,6 +114,10 @@ function Placeholder(props) {
114
114
props . pos ?. options ?. validation ?. format
115
115
)
116
116
) ;
117
+ const [ getCheckboxRenderWidth , setGetCheckboxRenderWidth ] = useState ( {
118
+ width : null ,
119
+ height : null
120
+ } ) ;
117
121
const dateFormatArr = [
118
122
"L" ,
119
123
"DD-MM-YYYY" ,
@@ -125,6 +129,21 @@ function Placeholder(props) {
125
129
"DD MMM, YYYY" ,
126
130
"DD MMMM, YYYY"
127
131
] ;
132
+
133
+ useEffect ( ( ) => {
134
+ const updateWidth = ( ) => {
135
+ const rndElement = document . getElementById ( props . pos . key ) ;
136
+ if ( rndElement ) {
137
+ const { width, height } = rndElement . getBoundingClientRect ( ) ;
138
+ setGetCheckboxRenderWidth ( { width : width , height : height } ) ;
139
+ }
140
+ } ;
141
+
142
+ // Delay to ensure rendering is complete
143
+ const timer = setTimeout ( updateWidth , 0 ) ;
144
+
145
+ return ( ) => clearTimeout ( timer ) ;
146
+ } , [ props . pos ] ) ;
128
147
//function change format array list with selected date and format
129
148
const changeDateFormat = ( ) => {
130
149
const updateDate = [ ] ;
@@ -168,8 +187,8 @@ function Placeholder(props) {
168
187
} ;
169
188
} , [ isShowDateFormat ] ) ;
170
189
171
- //onclick placeholder function to open signature pad
172
- const handlePlaceholderClick = ( ) => {
190
+ //`handleWidgetIdandPopup` is used to set current widget id and open relative popup
191
+ const handleWidgetIdandPopup = ( ) => {
173
192
if ( props . setSelectWidgetId ) {
174
193
props . setSelectWidgetId ( props . pos . key ) ;
175
194
}
@@ -238,9 +257,18 @@ function Placeholder(props) {
238
257
}
239
258
}
240
259
} ;
241
-
242
- //function to set state value of onclick on widget's setting icon
243
- const handleWidgetsOnclick = ( ) => {
260
+ const handleOnClickPlaceholder = ( ) => {
261
+ if ( ! props . isNeedSign ) {
262
+ props . setWidgetType ( props . pos . type ) ;
263
+ }
264
+ if ( props . isNeedSign && props . data ?. signerObjId === props . signerObjId ) {
265
+ handleWidgetIdandPopup ( ) ;
266
+ } else if ( props . isPlaceholder || props . isSignYourself ) {
267
+ handleWidgetIdandPopup ( ) ;
268
+ }
269
+ } ;
270
+ //`handleOnClickSettingIcon` is used set current widget details and open setting of it
271
+ const handleOnClickSettingIcon = ( ) => {
244
272
if ( props . pos . type === radioButtonWidget ) {
245
273
props . setIsRadio ( true ) ;
246
274
} else if ( props . pos . type === "dropdown" ) {
@@ -312,17 +340,17 @@ function Placeholder(props) {
312
340
< i
313
341
onClick = { ( e ) => {
314
342
e . stopPropagation ( ) ;
315
- handleWidgetsOnclick ( ) ;
343
+ handleOnClickSettingIcon ( ) ;
316
344
} }
317
345
onTouchEnd = { ( e ) => {
318
346
e . stopPropagation ( ) ;
319
- handleWidgetsOnclick ( ) ;
347
+ handleOnClickSettingIcon ( ) ;
320
348
} }
321
349
className = "fa-solid fa-gear settingIcon"
322
350
style = { {
323
351
color : "#188ae2" ,
324
- right : "9px " ,
325
- top : "-28px "
352
+ right : "29px " ,
353
+ top : "-19px "
326
354
} }
327
355
> </ i >
328
356
) : (
@@ -335,26 +363,14 @@ function Placeholder(props) {
335
363
< i
336
364
onClick = { ( e ) => {
337
365
e . stopPropagation ( ) ;
338
- handleWidgetsOnclick ( ) ;
366
+ handleOnClickSettingIcon ( ) ;
339
367
} }
340
368
onTouchEnd = { ( e ) => {
341
369
e . stopPropagation ( ) ;
342
- handleWidgetsOnclick ( ) ;
370
+ handleOnClickSettingIcon ( ) ;
343
371
} }
344
372
className = "fa-solid fa-gear settingIcon"
345
- style = { {
346
- color : "#188ae2" ,
347
- right : [ "checkbox" , radioButtonWidget ] . includes (
348
- props . pos . type
349
- )
350
- ? "24px"
351
- : "47px" ,
352
- top : [ "checkbox" , radioButtonWidget ] . includes (
353
- props . pos . type
354
- )
355
- ? "-28px"
356
- : "-19px"
357
- } }
373
+ style = { { color : "#188ae2" , right : "47px" , top : "-19px" } }
358
374
> </ i >
359
375
)
360
376
) }
@@ -373,19 +389,7 @@ function Placeholder(props) {
373
389
props . handleLinkUser ( props . data . Id ) ;
374
390
props . setUniqueId ( props . data . Id ) ;
375
391
} }
376
- style = { {
377
- color : "#188ae2" ,
378
- right :
379
- props . pos . type === "checkbox" ||
380
- props . pos . type === radioButtonWidget
381
- ? "8px"
382
- : "32px" ,
383
- top :
384
- props . pos . type === "checkbox" ||
385
- props . pos . type === radioButtonWidget
386
- ? "-28px"
387
- : "-18px"
388
- } }
392
+ style = { { color : "#188ae2" , right : "32px" , top : "-18px" } }
389
393
> </ i >
390
394
) }
391
395
</ >
@@ -463,19 +467,7 @@ function Placeholder(props) {
463
467
className = "fa-regular fa-copy signCopy"
464
468
onClick = { ( e ) => handleCopyPlaceholder ( e ) }
465
469
onTouchEnd = { ( e ) => handleCopyPlaceholder ( e ) }
466
- style = { {
467
- color : "#188ae2" ,
468
- right :
469
- props . pos . type === "checkbox" ||
470
- props . pos . type === radioButtonWidget
471
- ? "-9px"
472
- : "12px" ,
473
- top :
474
- props . pos . type === "checkbox" ||
475
- props . pos . type === radioButtonWidget
476
- ? "-28px"
477
- : "-18px"
478
- } }
470
+ style = { { color : "#188ae2" , right : "12px" , top : "-18px" } }
479
471
> </ i >
480
472
< i
481
473
className = "fa-regular fa-circle-xmark signCloseBtn"
@@ -498,19 +490,7 @@ function Placeholder(props) {
498
490
props . setIsStamp ( false ) ;
499
491
}
500
492
} }
501
- style = { {
502
- color : "#188ae2" ,
503
- right :
504
- props . pos . type === "checkbox" ||
505
- props . pos . type === radioButtonWidget
506
- ? "-27px"
507
- : "-8px" ,
508
- top :
509
- props . pos . type === "checkbox" ||
510
- props . pos . type === radioButtonWidget
511
- ? "-28px"
512
- : "-18px"
513
- } }
493
+ style = { { color : "#188ae2" , right : "-8px" , top : "-18px" } }
514
494
> </ i >
515
495
</ >
516
496
)
@@ -519,6 +499,7 @@ function Placeholder(props) {
519
499
520
500
return (
521
501
< Rnd
502
+ id = { props . pos . key }
522
503
data-tut = { props . pos . key === props . unSignedWidgetId ? "IsSigned" : "" }
523
504
key = { props . pos . key }
524
505
lockAspectRatio = {
@@ -622,33 +603,13 @@ function Placeholder(props) {
622
603
false
623
604
) ;
624
605
} }
625
- onClick = { ( ) => {
626
- ! props . isNeedSign && props . setWidgetType ( props . pos . type ) ;
627
- props . isNeedSign && props . data ?. signerObjId === props . signerObjId
628
- ? handlePlaceholderClick ( )
629
- : props . isPlaceholder
630
- ? handlePlaceholderClick ( )
631
- : props . isSignYourself && handlePlaceholderClick ( ) ;
632
- } }
606
+ onClick = { ( ) => handleOnClickPlaceholder ( ) }
633
607
>
634
608
{ props . isShowBorder &&
635
609
props . pos . type !== radioButtonWidget &&
636
610
props . pos . type !== "checkbox" &&
637
611
props . pos . key === props . selectWidgetId ? (
638
- < BorderResize
639
- right = {
640
- props . pos . type === "checkbox" ||
641
- props . pos . type === radioButtonWidget
642
- ? - 21
643
- : - 12
644
- }
645
- top = {
646
- props . pos . type === "checkbox" ||
647
- props . pos . type === radioButtonWidget
648
- ? - 21
649
- : - 11
650
- }
651
- />
612
+ < BorderResize right = { - 12 } top = { - 11 } />
652
613
) : props . data && props . isNeedSign && props . pos . type !== "checkbox" ? (
653
614
props . data ?. signerObjId === props . signerObjId &&
654
615
props . pos . type !== radioButtonWidget &&
@@ -668,25 +629,19 @@ function Placeholder(props) {
668
629
setDraggingEnabled = { setDraggingEnabled }
669
630
pos = { props . pos }
670
631
isPlaceholder = { props . isPlaceholder }
632
+ getCheckboxRenderWidth = { getCheckboxRenderWidth }
671
633
/>
672
634
) }
673
635
{ isMobile ? (
674
636
< div
675
637
style = { {
676
638
left : props . xPos ( props . pos , props . isSignYourself ) ,
677
639
top : props . yPos ( props . pos , props . isSignYourself ) ,
678
- width : props . posWidth ( props . pos , props . isSignYourself ) ,
640
+ width : "auto" , // props.posWidth(props.pos, props.isSignYourself),
679
641
// height: props.posHeight(props.pos, props.isSignYourself),
680
642
zIndex : "10"
681
643
} }
682
- onTouchEnd = { ( ) => {
683
- ! props . isNeedSign && props . setWidgetType ( props . pos . type ) ;
684
- props . isNeedSign && props . data ?. signerObjId === props . signerObjId
685
- ? handlePlaceholderClick ( )
686
- : props . isPlaceholder
687
- ? handlePlaceholderClick ( )
688
- : props . isSignYourself && handlePlaceholderClick ( ) ;
689
- } }
644
+ onTouchEnd = { ( ) => handleOnClickPlaceholder ( ) }
690
645
>
691
646
{ props . pos . key === props . selectWidgetId && < PlaceholderIcon /> }
692
647
0 commit comments