Skip to content

Commit 5561673

Browse files
committed
Merge pull request #866 from nxglabs/fix_main_issues
1 parent 0df4406 commit 5561673

File tree

7 files changed

+56
-32
lines changed

7 files changed

+56
-32
lines changed

apps/OpenSign/src/components/pdf/BorderResize.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ function BorderResize(props) {
1212

1313
return (
1414
<div
15-
style={{
16-
width: getHeight() || "14px",
17-
height: getHeight() || "14px"
18-
}}
15+
style={{ width: getHeight() || "14px", height: getHeight() || "14px" }}
1916
className={`${props.right ? `-right-[12px]` : "-right-[2px]"} ${
20-
props.top ? `-bottom-[12px]` : "-bottom-[2px] "
17+
props.top ? `-bottom-[12px]` : "-bottom-[2px]"
2118
} absolute inline-block hover:cursor-sw-resize border-r-[3px] border-b-[3px] border-[#188ae2]`}
2219
></div>
2320
);

apps/OpenSign/src/components/pdf/CellsWidget.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState, useEffect, useRef } from "react";
22

33
const Cell = ({
4+
isEnabled,
45
count,
56
h,
67
value,
@@ -15,10 +16,11 @@ const Cell = ({
1516
hint
1617
}) => (
1718
<div
18-
className="flex items-center justify-center border border-gray-800 bg-white"
19+
className={`${isEnabled ? "bg-white border-gray-400" : "select-none-cls pointer-events-none border-gray-500"} flex items-center justify-center border-[1px]`}
1920
style={{ flex: `0 0 ${100 / count}%`, height: h }}
2021
>
2122
<input
23+
disabled={!isEnabled}
2224
maxLength={1}
2325
value={value}
2426
readOnly={!editable}
@@ -27,14 +29,15 @@ const Cell = ({
2729
onKeyDown={editable ? (e) => onKeyDown && onKeyDown(e, index) : undefined}
2830
// trigger validation when leaving a cell
2931
onBlur={editable ? (e) => onBlur && onBlur(e, index) : undefined}
30-
className="w-full text-center focus:outline-none bg-transparent placeholder-gray-300"
32+
className={`${isEnabled ? "placeholder-gray-300" : "placeholder-gray-500"} w-full text-center focus:outline-none bg-transparent`}
3133
placeholder={hint}
3234
style={{ fontFamily: "Arial, sans-serif", fontSize, color: fontColor }}
3335
/>
3436
</div>
3537
);
3638

3739
export default function CellsWidget({
40+
isEnabled,
3841
count = 8,
3942
height = 40,
4043
value = "",
@@ -120,6 +123,7 @@ export default function CellsWidget({
120123
{cells.map((val, i) => (
121124
<Cell
122125
key={i}
126+
isEnabled={isEnabled}
123127
count={cellCount}
124128
h={height}
125129
value={val}

apps/OpenSign/src/components/pdf/Placeholder.jsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ function Placeholder(props) {
740740
return "not-allowed";
741741
}
742742
} else {
743-
return "all-scroll";
743+
return "move";
744744
}
745745
};
746746

@@ -946,23 +946,24 @@ function Placeholder(props) {
946946
props.pos.key === props?.currWidgetsDetails?.key && <BorderResize />
947947
)}
948948

949-
{/* 1- Show a ouline if props.pos.key === props?.currWidgetsDetails?.key, indicating the current user's selected widget.
950-
2- If props.isShowBorder is true, display ouline for all widgets.
951-
3- Use the combination of props?.isAlllowModify and !props?.assignedWidgetId.includes(props.pos.key) to determine when to show ouline:
952-
3.1- When isAlllowModify is true, show ouline.
953-
3.2- Do not display ouline for widgets already assigned (props.assignedWidgetId.includes(props.pos.key) is true).
949+
{/* 1- Show a border if props.pos.key === props?.currWidgetsDetails?.key, indicating the current user's selected widget.
950+
2- If props.isShowBorder is true, display border for all widgets.
951+
3- Use the combination of props?.isAlllowModify and !props?.assignedWidgetId.includes(props.pos.key) to determine when to show border:
952+
3.1- When isAlllowModify is true, show border.
953+
3.2- Do not display border for widgets already assigned (props.assignedWidgetId.includes(props.pos.key) is true).
954954
*/}
955+
{props.pos.key === props?.currWidgetsDetails?.key &&
956+
(props.isShowBorder ||
957+
(props?.isAlllowModify &&
958+
!props?.assignedWidgetId.includes(props.pos.key))) && (
959+
<div
960+
style={{ borderColor: themeColor }}
961+
className="w-[calc(100%+21px)] h-[calc(100%+21px)] cursor-move absolute inline-block border-[1px] border-dashed"
962+
></div>
963+
)}
955964
<div
956-
className={`${
957-
props.pos.key === props?.currWidgetsDetails?.key &&
958-
(props.isShowBorder ||
959-
(props?.isAlllowModify &&
960-
!props?.assignedWidgetId.includes(props.pos.key)))
961-
? "outline-[0.3px] outline-dashed outline-offset-[10px]"
962-
: ""
963-
} flex items-stretch justify-center`}
965+
className="flex items-stretch justify-center"
964966
style={{
965-
outlineColor: themeColor,
966967
left: xPos(props.pos, props.isSignYourself),
967968
top: yPos(props.pos, props.isSignYourself),
968969
width: "100%",

apps/OpenSign/src/components/pdf/PlaceholderType.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ function PlaceholderType(props) {
226226
props.isPlaceholder || props.isSignYourself || props.isSelfSign;
227227
return (
228228
<CellsWidget
229+
isEnabled={iswidgetEnable}
229230
count={count}
230231
height={height}
231232
value={cells.join("")}

apps/OpenSign/src/components/pdf/WidgetNameModal.jsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,23 @@ const WidgetNameModal = (props) => {
123123
}
124124
};
125125

126+
const handleChangeValidateInput = (e) => {
127+
if (e) {
128+
if (e.target.value === "ssn") {
129+
setFormdata({
130+
...formdata,
131+
[e.target.name]: e.target.value,
132+
hint: "xxx-xx-xxxx",
133+
cellCount: 11
134+
});
135+
} else {
136+
setFormdata({ ...formdata, [e.target.name]: e.target.value });
137+
}
138+
} else {
139+
setFormdata({ ...formdata, textvalidate: "" });
140+
}
141+
};
142+
126143
const handledefaultChange = (e) => {
127144
if (formdata.textvalidate) {
128145
const regexObject = RegexParser(handleValidation(formdata.textvalidate));
@@ -148,7 +165,7 @@ const WidgetNameModal = (props) => {
148165
//allow space in text regex
149166
return "/^[a-zA-Z ]+$/";
150167
case "ssn":
151-
return "^\\d{3}-\\d{2}-\\d{4}$";
168+
return "/^(?!000|666|9\\d{2})\\d{3}-(?!00)\\d{2}-(?!0000)\\d{4}$/";
152169
default:
153170
return type;
154171
}

apps/OpenSign/src/components/pdf/WidgetsValueModal.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,7 @@ function WidgetsValueModal(props) {
14721472
case cellsWidget:
14731473
return (
14741474
<CellsWidget
1475+
isEnabled={true}
14751476
count={cellsValue.length}
14761477
height="100%"
14771478
value={cellsValue.join("")}
@@ -1762,6 +1763,10 @@ function WidgetsValueModal(props) {
17621763
regexValidation = /^[0-9\s]*$/;
17631764
validateExpression(regexValidation);
17641765
break;
1766+
case "ssn":
1767+
regexValidation = /^(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}$/;
1768+
validateExpression(regexValidation);
1769+
break;
17651770
default:
17661771
// Grab the current pattern (if it exists)
17671772
const pattern = currWidgetsDetails?.options?.validation?.pattern;
@@ -1872,6 +1877,11 @@ function WidgetsValueModal(props) {
18721877
}
18731878
};
18741879
const handleclose = () => {
1880+
// If validation is shown, clear the response and close the modal
1881+
if (isShowValidation) {
1882+
handleClear();
1883+
setIsShowValidation(false);
1884+
}
18751885
dispatch(setIsShowModal({}));
18761886
dispatch(setLastIndex(""));
18771887
if (currWidgetsDetails?.type === textWidget && uniqueId) {
@@ -1936,7 +1946,7 @@ function WidgetsValueModal(props) {
19361946
<>
19371947
<ModalUi
19381948
isOpen={true}
1939-
handleClose={() => !isShowValidation && handleclose()}
1949+
handleClose={() => handleclose()}
19401950
position="bottom"
19411951
>
19421952
<div className="h-[100%] p-[18px]">

apps/OpenSign/src/pages/PlaceHolderSign.jsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,13 +1608,7 @@ function PlaceHolderSign() {
16081608
parseInt(defaultdata?.cellCount || 5)
16091609
),
16101610
validation:
1611-
isSubscribe && inputype
1612-
? {
1613-
type: inputype,
1614-
pattern:
1615-
inputype === "regex" ? defaultdata.textvalidate : ""
1616-
}
1617-
: {},
1611+
{},
16181612
fontSize:
16191613
fontSize || currWidgetsDetails?.options?.fontSize || 12,
16201614
fontColor:
@@ -2636,7 +2630,7 @@ function PlaceHolderSign() {
26362630
title={t("document-alert")}
26372631
showClose={false}
26382632
>
2639-
<div className="h-[100%] p-[20px]">
2633+
<div className="h-[100%] p-[20px] text-base-content">
26402634
<p>{isAlreadyPlace.message}</p>
26412635
<div className="h-[1px] w-full my-[15px] bg-[#9f9f9f]"></div>
26422636
<button

0 commit comments

Comments
 (0)