@servicetitan/dte-pdf-editor 1.19.0 → 1.20.0
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/dist/components/pdf-view/pdf-view-field-container.d.ts +1 -0
- package/dist/components/pdf-view/pdf-view-field-container.d.ts.map +1 -1
- package/dist/components/pdf-view/pdf-view-field-container.js +11 -4
- package/dist/components/pdf-view/pdf-view-field-container.js.map +1 -1
- package/dist/components/pdf-view/pdf-view-fillable.d.ts.map +1 -1
- package/dist/components/pdf-view/pdf-view-fillable.js +15 -2
- package/dist/components/pdf-view/pdf-view-fillable.js.map +1 -1
- package/dist/components/pdf-view/pdf-view.d.ts +1 -0
- package/dist/components/pdf-view/pdf-view.d.ts.map +1 -1
- package/dist/components/pdf-view/pdf-view.js +2 -2
- package/dist/components/pdf-view/pdf-view.js.map +1 -1
- package/package.json +1 -1
- package/src/components/pdf-view/pdf-view-field-container.tsx +16 -0
- package/src/components/pdf-view/pdf-view-fillable.tsx +15 -2
- package/src/components/pdf-view/pdf-view.tsx +3 -0
|
@@ -2,6 +2,7 @@ import { FC, PropsWithChildren, RefObject } from 'react';
|
|
|
2
2
|
import { PdfField } from '../../interface/types';
|
|
3
3
|
interface PdfViewFieldContainer {
|
|
4
4
|
pdfWrapperRef: RefObject<HTMLDivElement>;
|
|
5
|
+
error?: string;
|
|
5
6
|
field: PdfField;
|
|
6
7
|
recipientsColors: Record<string, string>;
|
|
7
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-view-field-container.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-field-container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,UAAU,qBAAqB;IAC3B,aAAa,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACzC,KAAK,EAAE,QAAQ,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,
|
|
1
|
+
{"version":3,"file":"pdf-view-field-container.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-field-container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,UAAU,qBAAqB;IAC3B,aAAa,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAwC9E,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getFieldBackgroundColor, getPagePosition } from '../../utils';
|
|
3
|
-
export const PdfViewFieldContainer = ({ children, field, pdfWrapperRef, recipientsColors, }) => {
|
|
3
|
+
export const PdfViewFieldContainer = ({ children, error, field, pdfWrapperRef, recipientsColors, }) => {
|
|
4
4
|
const pagePos = getPagePosition(field.page, pdfWrapperRef);
|
|
5
5
|
const bgColor = getFieldBackgroundColor(field.recipient, recipientsColors);
|
|
6
|
-
return (
|
|
6
|
+
return (_jsxs("div", { style: {
|
|
7
7
|
display: 'flex',
|
|
8
8
|
alignItems: 'center',
|
|
9
9
|
position: 'absolute',
|
|
@@ -13,6 +13,13 @@ export const PdfViewFieldContainer = ({ children, field, pdfWrapperRef, recipien
|
|
|
13
13
|
top: `${pagePos.top + field.y}px`,
|
|
14
14
|
width: `${field.width}px`,
|
|
15
15
|
height: `${field.height}px`,
|
|
16
|
-
|
|
16
|
+
borderColor: error ? 'red' : undefined,
|
|
17
|
+
}, children: [children, error && (_jsx("span", { style: {
|
|
18
|
+
top: '100%',
|
|
19
|
+
color: 'red',
|
|
20
|
+
marginTop: '4px',
|
|
21
|
+
minWidth: '100px',
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
}, children: error }))] }));
|
|
17
24
|
};
|
|
18
25
|
//# sourceMappingURL=pdf-view-field-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-view-field-container.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-field-container.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"pdf-view-field-container.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-field-container.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AASvE,MAAM,CAAC,MAAM,qBAAqB,GAAiD,CAAC,EAChF,QAAQ,EACR,KAAK,EACL,KAAK,EACL,aAAa,EACb,gBAAgB,GACnB,EAAE,EAAE;IACD,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAC3E,OAAO,CACH,eACI,KAAK,EAAE;YACH,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,UAAU;YACpB,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,OAAO;YACnB,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI;YACnC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,IAAI;YACjC,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK,IAAI;YACzB,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,IAAI;YAC3B,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACzC,aAEA,QAAQ,EACR,KAAK,IAAI,CACN,eACI,KAAK,EAAE;oBACH,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE,KAAK;oBACZ,SAAS,EAAE,KAAK;oBAChB,QAAQ,EAAE,OAAO;oBACjB,QAAQ,EAAE,UAAU;iBACvB,YAEA,KAAK,GACH,CACV,IACC,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-view-fillable.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-fillable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGlG,UAAU,oBAAoB;IAC1B,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,CAAC,WAAW,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxE;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"pdf-view-fillable.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-fillable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGlG,UAAU,oBAAoB;IAC1B,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,CAAC,WAAW,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxE;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAyIpD,CAAC"}
|
|
@@ -19,7 +19,12 @@ export const PdfViewFillable = ({ data, field, fillingBy, onDataChange, previewM
|
|
|
19
19
|
background: 'inherit',
|
|
20
20
|
width: 'inherit',
|
|
21
21
|
height: 'inherit',
|
|
22
|
-
}, children: [_jsx("input", { style: {
|
|
22
|
+
}, children: [_jsx("input", { style: {
|
|
23
|
+
width: 'inherit',
|
|
24
|
+
height: 'inherit',
|
|
25
|
+
margin: 0,
|
|
26
|
+
borderColor: 'inherit',
|
|
27
|
+
}, type: "checkbox", checked: resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : false, disabled: !isFillable, name: field.path, onChange: e => handleDataChange === null || handleDataChange === void 0 ? void 0 : handleDataChange(e.target.checked) }), field.label] }));
|
|
23
28
|
}
|
|
24
29
|
if (field.subType === 'radio') {
|
|
25
30
|
return (_jsxs("div", { style: {
|
|
@@ -28,13 +33,19 @@ export const PdfViewFillable = ({ data, field, fillingBy, onDataChange, previewM
|
|
|
28
33
|
background: 'inherit',
|
|
29
34
|
width: 'inherit',
|
|
30
35
|
height: 'inherit',
|
|
31
|
-
}, children: [_jsx("input", { style: {
|
|
36
|
+
}, children: [_jsx("input", { style: {
|
|
37
|
+
width: 'inherit',
|
|
38
|
+
height: 'inherit',
|
|
39
|
+
margin: 0,
|
|
40
|
+
borderColor: 'inherit',
|
|
41
|
+
}, type: "radio", value: field.id, checked: resolvedValue === field.id, disabled: !isFillable, name: field.path, onChange: () => handleDataChange(field.id) }), field.label] }));
|
|
32
42
|
}
|
|
33
43
|
if (field.subType === 'date') {
|
|
34
44
|
return (_jsx("input", { type: "date", style: {
|
|
35
45
|
background: 'inherit',
|
|
36
46
|
width: 'inherit',
|
|
37
47
|
height: 'inherit',
|
|
48
|
+
borderColor: 'inherit',
|
|
38
49
|
}, disabled: !isFillable, id: field.path, name: field.path, value: resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : '', onChange: e => handleDataChange(e.target.value), placeholder: getFieldPlaceholderText(field, 'mm/dd/yyyy') }));
|
|
39
50
|
}
|
|
40
51
|
if (field.subType === 'number') {
|
|
@@ -42,12 +53,14 @@ export const PdfViewFillable = ({ data, field, fillingBy, onDataChange, previewM
|
|
|
42
53
|
background: 'inherit',
|
|
43
54
|
width: 'inherit',
|
|
44
55
|
height: 'inherit',
|
|
56
|
+
borderColor: 'inherit',
|
|
45
57
|
}, disabled: !isFillable, id: field.path, name: field.path, value: resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : '', onChange: e => handleDataChange(e.target.value), placeholder: getFieldPlaceholderText(field) }));
|
|
46
58
|
}
|
|
47
59
|
return (_jsx("input", { type: "text", style: {
|
|
48
60
|
background: 'inherit',
|
|
49
61
|
width: 'inherit',
|
|
50
62
|
height: 'inherit',
|
|
63
|
+
borderColor: 'inherit',
|
|
51
64
|
}, disabled: !isFillable, id: field.path, name: field.path, value: resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : '', onChange: e => handleDataChange(e.target.value), placeholder: getFieldPlaceholderText(field) }));
|
|
52
65
|
};
|
|
53
66
|
//# sourceMappingURL=pdf-view-fillable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-view-fillable.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-fillable.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAUtD,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,EACtD,IAAI,EACJ,KAAK,EACL,SAAS,EACT,YAAY,EACZ,WAAW,GACd,EAAE,EAAE;IACD,MAAM,aAAa,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,KAAK,CAAC,IAAK,CAAC,CAAC;IAC1C,MAAM,wBAAwB,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,KAAK,CAAC,SAAU,CAAC,CAAC;IACvE,MAAM,UAAU,GACZ,WAAW,KAAK,UAAU;QACtB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,WAAW,KAAK,MAAM;YACtB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,wBAAwB,CAAC;IAErC,MAAM,gBAAgB,GAAG,CAAC,UAAqC,EAAE,EAAE;QAC/D,MAAM,WAAW,GAAG,EAAE,CAAC,KAAK,CAAC,IAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QAClD,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,WAAW,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC;IAEF,IAAI,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,CACH,eACI,KAAK,EAAE;gBACH,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE,QAAQ;gBACpB,UAAU,EAAE,SAAS;gBACrB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,SAAS;aACpB,aAED,gBACI,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"pdf-view-fillable.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-fillable.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAUtD,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,EACtD,IAAI,EAC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'../../interface/types';
|
|
3
3
|
export interface PdfViewProps {
|
|
4
4
|
fields: PdfField[];
|
|
5
|
+
errors?: Record<string, string>;
|
|
5
6
|
previewMode?: PreviewMode;
|
|
6
7
|
data?: DataModelValues;
|
|
7
8
|
pdfUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-view.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAoB,MAAM,OAAO,CAAC;AAExD,OAAO,EACH,iBAAiB,EACjB,eAAe,EAEf,QAAQ,EACR,WAAW,EACX,aAAa,EAChB,MAAM,uBAAuB,CAAC;AAS/B,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAOlB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,aAAa,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,YAAY,CAAC,CAAC,WAAW,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxE;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"pdf-view.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAoB,MAAM,OAAO,CAAC;AAExD,OAAO,EACH,iBAAiB,EACjB,eAAe,EAEf,QAAQ,EACR,WAAW,EACX,aAAa,EAChB,MAAM,uBAAuB,CAAC;AAS/B,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAOlB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,aAAa,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,YAAY,CAAC,CAAC,WAAW,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxE;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAoFpC,CAAC"}
|
|
@@ -10,7 +10,7 @@ import { PdfViewDataModel } from './pdf-view-data-model';
|
|
|
10
10
|
import { PdfViewESign } from './pdf-view-e-sign';
|
|
11
11
|
import { PdfViewFieldContainer } from './pdf-view-field-container';
|
|
12
12
|
import { PdfViewFillable } from './pdf-view-fillable';
|
|
13
|
-
export const PdfView = ({ data, errorPlaceholder, fields, fillingBy, loading = false, loadingPlaceholder, onDataChange, onLoadSuccess, pdfUrl, previewMode, recipients, }) => {
|
|
13
|
+
export const PdfView = ({ data, errorPlaceholder, errors = {}, fields, fillingBy, loading = false, loadingPlaceholder, onDataChange, onLoadSuccess, pdfUrl, previewMode, recipients, }) => {
|
|
14
14
|
const [isPdfLoaded, setIsPdfLoaded] = useState(false);
|
|
15
15
|
const [previewData, setPreviewData] = useState(data !== null && data !== void 0 ? data : {});
|
|
16
16
|
const pdfWrapperRef = useRef(null);
|
|
@@ -28,6 +28,6 @@ export const PdfView = ({ data, errorPlaceholder, fields, fillingBy, loading = f
|
|
|
28
28
|
onDataChange === null || onDataChange === void 0 ? void 0 : onDataChange(data, field);
|
|
29
29
|
};
|
|
30
30
|
const recipientsColors = mapColorsToRecipients(recipients);
|
|
31
|
-
return (_jsx(Flex, { flex: 1, className: "dte-pdf-view-container", style: { maxWidth: BASE_PAGE_WIDTH }, children: _jsxs("div", { ref: pdfWrapperRef, className: "dte-pdf-wrapper", children: [_jsx(PdfDocumentRenderer, { pdfUrl: pdfUrl, loading: loading, pageWidth: BASE_PAGE_WIDTH, errorPlaceholder: errorPlaceholder, loadingPlaceholder: loadingPlaceholder, onDocumentLoadSuccess: onDocumentLoadSuccess }), isPdfLoaded && (_jsx("div", { className: "dte-pdf-field-overlay --view-mode", children: fields.map(field => (_jsxs(PdfViewFieldContainer, { field: field, recipientsColors: recipientsColors, pdfWrapperRef: pdfWrapperRef, children: [field.type === FieldTypeEnum.dataModel && (_jsx(PdfViewDataModel, { field: field, data: data })), field.type === FieldTypeEnum.eSign && (_jsx(PdfViewESign, { field: field })), field.type === FieldTypeEnum.calculated && (_jsx(PdfViewCalculated, { field: field, data: previewMode === 'fillable' ? previewData : data })), field.type === FieldTypeEnum.fillable && (_jsx(PdfViewFillable, { data: previewMode === 'fillable' ? previewData : data, field: field, fillingBy: fillingBy, previewMode: previewMode, onDataChange: handleDataChange }))] }, field.id))) }))] }) }));
|
|
31
|
+
return (_jsx(Flex, { flex: 1, className: "dte-pdf-view-container", style: { maxWidth: BASE_PAGE_WIDTH }, children: _jsxs("div", { ref: pdfWrapperRef, className: "dte-pdf-wrapper", children: [_jsx(PdfDocumentRenderer, { pdfUrl: pdfUrl, loading: loading, pageWidth: BASE_PAGE_WIDTH, errorPlaceholder: errorPlaceholder, loadingPlaceholder: loadingPlaceholder, onDocumentLoadSuccess: onDocumentLoadSuccess }), isPdfLoaded && (_jsx("div", { className: "dte-pdf-field-overlay --view-mode", children: fields.map(field => (_jsxs(PdfViewFieldContainer, { field: field, error: errors[field.path] || '', recipientsColors: recipientsColors, pdfWrapperRef: pdfWrapperRef, children: [field.type === FieldTypeEnum.dataModel && (_jsx(PdfViewDataModel, { field: field, data: data })), field.type === FieldTypeEnum.eSign && (_jsx(PdfViewESign, { field: field })), field.type === FieldTypeEnum.calculated && (_jsx(PdfViewCalculated, { field: field, data: previewMode === 'fillable' ? previewData : data })), field.type === FieldTypeEnum.fillable && (_jsx(PdfViewFillable, { data: previewMode === 'fillable' ? previewData : data, field: field, fillingBy: fillingBy, previewMode: previewMode, onDataChange: handleDataChange }))] }, field.id))) }))] }) }));
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=pdf-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-view.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAiB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAGH,aAAa,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"pdf-view.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view.tsx"],"names":[],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AAY,IAAC,KAAK,EAAE,KAAK,GAAI,CACjC,EACA,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC,UAAU,IAAI,CACxC,KAAC,iBAAiB,IACd,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,WAAW,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GACvD,CACL,EACA,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC,QAAQ,IAAI,CACtC,KAAC,eAAe,IACZ,IAAI,EAAE,WAAW,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EACrD,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,gBAAgB,GAChC,CACL,KA1BI,KAAK,CAAC,EAAE,CA2BO,CAC3B,CAAC,GACA,CACT,IACC,GACH,CACV,CAAC;AACN,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,12 +4,14 @@ import { getFieldBackgroundColor, getPagePosition } from '../../utils';
|
|
|
4
4
|
|
|
5
5
|
interface PdfViewFieldContainer {
|
|
6
6
|
pdfWrapperRef: RefObject<HTMLDivElement>;
|
|
7
|
+
error?: string;
|
|
7
8
|
field: PdfField;
|
|
8
9
|
recipientsColors: Record<string, string>;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export const PdfViewFieldContainer: FC<PropsWithChildren<PdfViewFieldContainer>> = ({
|
|
12
13
|
children,
|
|
14
|
+
error,
|
|
13
15
|
field,
|
|
14
16
|
pdfWrapperRef,
|
|
15
17
|
recipientsColors,
|
|
@@ -28,9 +30,23 @@ export const PdfViewFieldContainer: FC<PropsWithChildren<PdfViewFieldContainer>>
|
|
|
28
30
|
top: `${pagePos.top + field.y}px`,
|
|
29
31
|
width: `${field.width}px`,
|
|
30
32
|
height: `${field.height}px`,
|
|
33
|
+
borderColor: error ? 'red' : undefined,
|
|
31
34
|
}}
|
|
32
35
|
>
|
|
33
36
|
{children}
|
|
37
|
+
{error && (
|
|
38
|
+
<span
|
|
39
|
+
style={{
|
|
40
|
+
top: '100%',
|
|
41
|
+
color: 'red',
|
|
42
|
+
marginTop: '4px',
|
|
43
|
+
minWidth: '100px',
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{error}
|
|
48
|
+
</span>
|
|
49
|
+
)}
|
|
34
50
|
</div>
|
|
35
51
|
);
|
|
36
52
|
};
|
|
@@ -43,7 +43,12 @@ export const PdfViewFillable: FC<PdfViewFillableProps> = ({
|
|
|
43
43
|
}}
|
|
44
44
|
>
|
|
45
45
|
<input
|
|
46
|
-
style={{
|
|
46
|
+
style={{
|
|
47
|
+
width: 'inherit',
|
|
48
|
+
height: 'inherit',
|
|
49
|
+
margin: 0,
|
|
50
|
+
borderColor: 'inherit',
|
|
51
|
+
}}
|
|
47
52
|
type="checkbox"
|
|
48
53
|
checked={resolvedValue ?? false}
|
|
49
54
|
disabled={!isFillable}
|
|
@@ -67,7 +72,12 @@ export const PdfViewFillable: FC<PdfViewFillableProps> = ({
|
|
|
67
72
|
}}
|
|
68
73
|
>
|
|
69
74
|
<input
|
|
70
|
-
style={{
|
|
75
|
+
style={{
|
|
76
|
+
width: 'inherit',
|
|
77
|
+
height: 'inherit',
|
|
78
|
+
margin: 0,
|
|
79
|
+
borderColor: 'inherit',
|
|
80
|
+
}}
|
|
71
81
|
type="radio"
|
|
72
82
|
value={field.id}
|
|
73
83
|
checked={resolvedValue === field.id}
|
|
@@ -88,6 +98,7 @@ export const PdfViewFillable: FC<PdfViewFillableProps> = ({
|
|
|
88
98
|
background: 'inherit',
|
|
89
99
|
width: 'inherit',
|
|
90
100
|
height: 'inherit',
|
|
101
|
+
borderColor: 'inherit',
|
|
91
102
|
}}
|
|
92
103
|
disabled={!isFillable}
|
|
93
104
|
id={field.path}
|
|
@@ -107,6 +118,7 @@ export const PdfViewFillable: FC<PdfViewFillableProps> = ({
|
|
|
107
118
|
background: 'inherit',
|
|
108
119
|
width: 'inherit',
|
|
109
120
|
height: 'inherit',
|
|
121
|
+
borderColor: 'inherit',
|
|
110
122
|
}}
|
|
111
123
|
disabled={!isFillable}
|
|
112
124
|
id={field.path}
|
|
@@ -125,6 +137,7 @@ export const PdfViewFillable: FC<PdfViewFillableProps> = ({
|
|
|
125
137
|
background: 'inherit',
|
|
126
138
|
width: 'inherit',
|
|
127
139
|
height: 'inherit',
|
|
140
|
+
borderColor: 'inherit',
|
|
128
141
|
}}
|
|
129
142
|
disabled={!isFillable}
|
|
130
143
|
id={field.path}
|
|
@@ -19,6 +19,7 @@ import { PdfViewFillable } from './pdf-view-fillable';
|
|
|
19
19
|
|
|
20
20
|
export interface PdfViewProps {
|
|
21
21
|
fields: PdfField[];
|
|
22
|
+
errors?: Record<string, string>;
|
|
22
23
|
previewMode?: PreviewMode;
|
|
23
24
|
data?: DataModelValues;
|
|
24
25
|
pdfUrl: string;
|
|
@@ -40,6 +41,7 @@ export interface PdfViewProps {
|
|
|
40
41
|
export const PdfView: FC<PdfViewProps> = ({
|
|
41
42
|
data,
|
|
42
43
|
errorPlaceholder,
|
|
44
|
+
errors = {},
|
|
43
45
|
fields,
|
|
44
46
|
fillingBy,
|
|
45
47
|
loading = false,
|
|
@@ -88,6 +90,7 @@ export const PdfView: FC<PdfViewProps> = ({
|
|
|
88
90
|
<PdfViewFieldContainer
|
|
89
91
|
key={field.id}
|
|
90
92
|
field={field}
|
|
93
|
+
error={errors[field.path!] || ''}
|
|
91
94
|
recipientsColors={recipientsColors}
|
|
92
95
|
pdfWrapperRef={pdfWrapperRef}
|
|
93
96
|
>
|