Skip to content

Commit c04fd80

Browse files
feat: change label widget name to text and text widget name to text input
1 parent 08e8055 commit c04fd80

File tree

9 files changed

+86
-58
lines changed

9 files changed

+86
-58
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import React, { useState, useEffect } from "react";
22
import BorderResize from "./BorderResize";
33
import PlaceholderBorder from "./PlaceholderBorder";
44
import { Rnd } from "react-rnd";
5-
import { defaultWidthHeight, isMobile } from "../../constant/Utils";
5+
import {
6+
defaultWidthHeight,
7+
isMobile,
8+
textInputWidget,
9+
textWidget
10+
} from "../../constant/Utils";
611
import PlaceholderType from "./PlaceholderType";
712
import moment from "moment";
813
import "../../styles/opensigndrive.css";
@@ -202,7 +207,7 @@ function Placeholder(props) {
202207
}
203208

204209
const widgetTypeExist = [
205-
"text",
210+
textInputWidget,
206211
"checkbox",
207212
"name",
208213
"company",
@@ -238,7 +243,7 @@ function Placeholder(props) {
238243
} else if (
239244
props.isPlaceholder &&
240245
!props.isDragging &&
241-
props.pos.type !== "label"
246+
props.pos.type !== textWidget
242247
) {
243248
if (props.pos.key === props.selectWidgetId) {
244249
props.handleLinkUser(props.data.Id);
@@ -277,18 +282,18 @@ function Placeholder(props) {
277282
props?.handleNameModal(true);
278283
}
279284

280-
if (props.isPlaceholder && props.type !== "label") {
285+
if (props.isPlaceholder && props.type !== textWidget) {
281286
props.setUniqueId(props.data.Id);
282287
}
283288
props.setSignKey(props.pos.key);
284289
props.setWidgetType(props.pos.type);
285290
props.setCurrWidgetsDetails(props.pos);
286291
};
287292
const handleCopyPlaceholder = (e) => {
288-
if (props.data && props?.pos?.type !== "label") {
293+
if (props.data && props?.pos?.type !== textWidget) {
289294
props.setSignerObjId(props?.data?.signerObjId);
290295
props.setUniqueId(props?.data?.Id);
291-
} else if (props.data && props.pos.type === "label") {
296+
} else if (props.data && props.pos.type === textWidget) {
292297
props.setTempSignerId(props.uniqueId);
293298
props.setSignerObjId(props?.data?.signerObjId);
294299
props.setUniqueId(props?.data?.Id);
@@ -324,7 +329,9 @@ function Placeholder(props) {
324329
) : (
325330
((!props?.pos?.type && props.pos.isStamp) ||
326331
(props?.pos?.type &&
327-
!["date", "label", "signature"].includes(props.pos.type) &&
332+
!["date", textWidget, "signature"].includes(
333+
props.pos.type
334+
) &&
328335
!props.isSignYourself)) && (
329336
<i
330337
onClick={(e) => {
@@ -349,7 +356,7 @@ function Placeholder(props) {
349356
)
350357
)}
351358

352-
{props.pos.type !== "label" && !props.isSignYourself && (
359+
{props.pos.type !== textWidget && !props.isSignYourself && (
353360
<i
354361
data-tut="reactourLinkUser"
355362
className="fa-regular fa-user signUserIcon"
@@ -511,7 +518,7 @@ function Placeholder(props) {
511518
//ref={nodeRef}
512519
key={props.pos.key}
513520
lockAspectRatio={
514-
props.pos.type !== "label" &&
521+
props.pos.type !== textWidget &&
515522
(props.pos.Width
516523
? props.pos.Width / props.pos.Height
517524
: defaultWidthHeight(props.pos.type).width /

apps/OpenSign/src/components/pdf/PlaceholderCopy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react";
22
import { themeColor } from "../../constant/const";
33
import ModalUi from "../../primitives/ModalUi";
4-
import { randomId } from "../../constant/Utils";
4+
import { randomId, textWidget } from "../../constant/Utils";
55

66
function PlaceholderCopy(props) {
77
const copyType = ["All pages", "All pages but last", "All pages but first"];
@@ -181,7 +181,7 @@ function PlaceholderCopy(props) {
181181
}
182182
};
183183
const handleUniqueId = () => {
184-
if (props.widgetType === "label") {
184+
if (props.widgetType === textWidget) {
185185
props.setUniqueId(props?.tempSignerId);
186186
props.setTempSignerId("");
187187
}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import React, { useEffect, useState, forwardRef, useRef } from "react";
2-
import { getMonth, getYear, onChangeInput, range } from "../../constant/Utils";
2+
import {
3+
getMonth,
4+
getYear,
5+
onChangeInput,
6+
range,
7+
textInputWidget,
8+
textWidget
9+
} from "../../constant/Utils";
310
import DatePicker from "react-datepicker";
411
import "react-datepicker/dist/react-datepicker.css";
512
import "../../styles/signature.css";
@@ -77,7 +84,7 @@ function PlaceholderType(props) {
7784
case "number":
7885
setValidatePlaceholder("12345");
7986
break;
80-
case "text":
87+
case textInputWidget:
8188
setValidatePlaceholder("enter text");
8289
break;
8390
default:
@@ -132,7 +139,7 @@ function PlaceholderType(props) {
132139
useEffect(() => {
133140
if (type && type === "date") {
134141
if (props?.selectDate) {
135-
let updateDate;
142+
// let updateDate;
136143
// if (props?.selectDate.format === "dd-MM-yyyy") {
137144
// // console.log('saveDateformat',props.saveDateFormat)
138145
// const [day, month, year] = props.saveDateFormat.split("-");
@@ -410,7 +417,7 @@ function PlaceholderType(props) {
410417
})}
411418
</div>
412419
);
413-
case "text":
420+
case textInputWidget:
414421
return props.isSignYourself ||
415422
(props.isNeedSign && props.data?.signerObjId === props.signerObjId) ? (
416423
<input
@@ -770,7 +777,7 @@ function PlaceholderType(props) {
770777
})}
771778
</div>
772779
);
773-
case "label":
780+
case textWidget:
774781
return (
775782
<textarea
776783
placeholder="Enter label"

apps/OpenSign/src/components/pdf/WidgetComponent.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ModalUi from "../../primitives/ModalUi";
33
import RecipientList from "./RecipientList";
44
import { useDrag } from "react-dnd";
55
import WidgetList from "./WidgetList";
6-
import { widgets } from "../../constant/Utils";
6+
import { textInputWidget, textWidget, widgets } from "../../constant/Utils";
77
import { themeColor } from "../../constant/const";
88
function WidgetComponent({
99
dragSignature,
@@ -58,16 +58,15 @@ function WidgetComponent({
5858
isDragCheck: !!monitor.isDragging()
5959
})
6060
});
61-
const [, text] = useDrag({
61+
const [, textInput] = useDrag({
6262
type: "BOX",
6363
item: {
6464
type: "BOX",
6565
id: 7,
66-
text: "text"
66+
text: textInputWidget
6767
},
68-
6968
collect: (monitor) => ({
70-
isDragText: !!monitor.isDragging()
69+
isDragTextInput: !!monitor.isDragging()
7170
})
7271
});
7372
const [, initials] = useDrag({
@@ -165,16 +164,16 @@ function WidgetComponent({
165164
isDragRadio: !!monitor.isDragging()
166165
})
167166
});
168-
const [, label] = useDrag({
167+
const [, text] = useDrag({
169168
type: "BOX",
170169

171170
item: {
172171
type: "BOX",
173172
id: 16,
174-
text: "label"
173+
text: textWidget
175174
},
176175
collect: (monitor) => ({
177-
isDragLabel: !!monitor.isDragging()
176+
isDragText: !!monitor.isDragging()
178177
})
179178
});
180179
const isMobile = window.innerWidth < 767;
@@ -208,8 +207,8 @@ function WidgetComponent({
208207
jobTitle,
209208
company,
210209
date,
211-
label,
212210
text,
211+
textInput,
213212
checkbox,
214213
dropdown,
215214
radio,
@@ -227,13 +226,15 @@ function WidgetComponent({
227226

228227
const filterWidgets = widget.filter(
229228
(data) =>
230-
data.type !== "dropdown" && data.type !== "radio" && data.type !== "label"
229+
data.type !== "dropdown" &&
230+
data.type !== "radio" &&
231+
data.type !== textWidget
231232
);
232-
const labelWidget = widget.filter((data) => data.type !== "label");
233+
const textWidgetData = widget.filter((data) => data.type !== textWidget);
233234
const updateWidgets = isSignYourself
234235
? filterWidgets
235236
: isTemplateFlow
236-
? labelWidget
237+
? textWidgetData
237238
: widget;
238239

239240
return (

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
22
import ModalUi from "../../primitives/ModalUi";
33
import "../../styles/AddUser.css";
44
import RegexParser from "regex-parser";
5+
import { textInputWidget } from "../../constant/Utils";
56

67
const WidgetNameModal = (props) => {
78
const [formdata, setFormdata] = useState({
@@ -69,7 +70,7 @@ const WidgetNameModal = (props) => {
6970
return "/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/";
7071
case "number":
7172
return "/^\\d+$/";
72-
case "text":
73+
case textInputWidget:
7374
return "/^[a-zA-Zs]+$/";
7475
default:
7576
return type;
@@ -111,8 +112,8 @@ const WidgetNameModal = (props) => {
111112
required
112113
/>
113114
</div>
114-
{(props.defaultdata?.type === "text" ||
115-
props.widgetName === "text") && (
115+
{(props.defaultdata?.type === textInputWidget ||
116+
props.widgetName === textInputWidget) && (
116117
<>
117118
<div className="form-section">
118119
<label htmlFor="textvalidate" style={{ fontSize: 13 }}>
@@ -243,8 +244,8 @@ const WidgetNameModal = (props) => {
243244
})}
244245
</div>
245246
</div>
246-
{(props.defaultdata?.type === "text" ||
247-
props?.widgetName === "text") && (
247+
{(props.defaultdata?.type === textInputWidget ||
248+
props?.widgetName === textInputWidget) && (
248249
<div className="form-section">
249250
<label htmlFor="hint" style={{ fontSize: 13 }}>
250251
Hint

apps/OpenSign/src/constant/Utils.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import React from "react";
55
import { rgb } from "pdf-lib";
66

77
export const isMobile = window.innerWidth < 767;
8+
export const textInputWidget = "text input";
9+
export const textWidget = "text";
810
export const openInNewTab = (url) => {
911
window.open(url, "_blank", "noopener,noreferrer");
1012
};
@@ -182,12 +184,12 @@ export const widgets = [
182184
iconSize: "20px"
183185
},
184186
{
185-
type: "label",
187+
type: textWidget,
186188
icon: "fa-solid fa-text-width",
187189
iconSize: "20px"
188190
},
189191
{
190-
type: "text",
192+
type: textInputWidget,
191193
icon: "fa-solid fa-font",
192194
iconSize: "21px"
193195
},
@@ -236,7 +238,7 @@ export const addWidgetOptions = (type) => {
236238
return defaultOpt;
237239
case "checkbox":
238240
return defaultOpt;
239-
case "text":
241+
case textInputWidget:
240242
return { ...defaultOpt, validation: { type: "text", pattern: "" } };
241243
case "initials":
242244
return defaultOpt;
@@ -256,7 +258,7 @@ export const addWidgetOptions = (type) => {
256258
return defaultOpt;
257259
case "radio":
258260
return { ...defaultOpt, values: [] };
259-
case "label":
261+
case textWidget:
260262
return defaultOpt;
261263
default:
262264
return {};
@@ -322,7 +324,7 @@ export const defaultWidthHeight = (type) => {
322324
return { width: 150, height: 60 };
323325
case "checkbox":
324326
return { width: 15, height: 15 };
325-
case "text":
327+
case textInputWidget:
326328
return { width: 150, height: 25 };
327329
case "dropdown":
328330
return { width: 120, height: 22 };
@@ -342,7 +344,7 @@ export const defaultWidthHeight = (type) => {
342344
return { width: 150, height: 20 };
343345
case "radio":
344346
return { width: 15, height: 30 };
345-
case "label":
347+
case textWidget:
346348
return { width: 150, height: 17 };
347349
default:
348350
return { width: 150, height: 60 };
@@ -1137,7 +1139,7 @@ export const multiSignEmbed = async (
11371139
}
11381140
};
11391141
const widgetTypeExist = [
1140-
"text",
1142+
textInputWidget,
11411143
"name",
11421144
"company",
11431145
"job title",
@@ -1183,7 +1185,7 @@ export const multiSignEmbed = async (
11831185
checkbox.enableReadOnly();
11841186
});
11851187
}
1186-
} else if (position.type === "label") {
1188+
} else if (position.type === textWidget) {
11871189
const font = await pdfDoc.embedFont("Helvetica");
11881190
const fontSize = 12;
11891191
let textContent;

0 commit comments

Comments
 (0)