@servicetitan/dte-pdf-editor 1.86.0 → 1.87.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-fields-overlay/pdf-overlay-field-fillable.d.ts.map +1 -1
- package/dist/components/pdf-fields-overlay/pdf-overlay-field-fillable.js +22 -8
- package/dist/components/pdf-fields-overlay/pdf-overlay-field-fillable.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 +3 -3
- package/dist/components/pdf-view/pdf-view-fillable.js.map +1 -1
- package/dist/utils/field/field-placeholder-text.utils.d.ts +1 -0
- package/dist/utils/field/field-placeholder-text.utils.d.ts.map +1 -1
- package/dist/utils/field/field-placeholder-text.utils.js +9 -4
- package/dist/utils/field/field-placeholder-text.utils.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/field-types/custom-fields.test.ts +187 -0
- package/src/components/pdf-fields-overlay/pdf-overlay-field-fillable.tsx +46 -14
- package/src/components/pdf-view/pdf-view-fillable.tsx +3 -2
- package/src/utils/field/__tests__/field-placeholder-text.utils.test.ts +17 -1
- package/src/utils/field/field-placeholder-text.utils.ts +10 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-overlay-field-fillable.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-fields-overlay/pdf-overlay-field-fillable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"pdf-overlay-field-fillable.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-fields-overlay/pdf-overlay-field-fillable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD,UAAU,4BAA4B;IAClC,KAAK,EAAE,QAAQ,CAAC;IAChB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC5C;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CAkHpE,CAAC"}
|
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
-
import { getFieldPlaceholderText, getFieldTextClipClassName } from '../../utils';
|
|
4
|
+
import { getFieldPlaceholderText, getFieldTextClipClassName, getFillablePaintedLabel, } from '../../utils';
|
|
5
5
|
import { AddHandle } from './add-handle';
|
|
6
6
|
export const PdfOverlayFieldFillable = ({ field, handleAddNewField, }) => {
|
|
7
7
|
const placeholderText = getFieldPlaceholderText(field);
|
|
8
8
|
const clipClassName = getFieldTextClipClassName(field);
|
|
9
9
|
switch (field.subType) {
|
|
10
10
|
case 'checkbox':
|
|
11
|
-
return (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return (_jsxs(Fragment, { children: [_jsx("input", { type: "radio", readOnly: true, className: "dte-pdf-field-fillable", style: {
|
|
11
|
+
return (_jsxs("div", { className: "dte-pdf-field-content", style: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
background: 'inherit',
|
|
15
|
+
}, children: [_jsx("input", { title: field.label, type: "checkbox", readOnly: true, className: "dte-pdf-field-fillable", style: {
|
|
17
16
|
width: field.width,
|
|
18
17
|
height: field.height,
|
|
19
|
-
|
|
18
|
+
margin: 0,
|
|
19
|
+
border: 'none',
|
|
20
|
+
} }), getFillablePaintedLabel(field)] }));
|
|
21
|
+
case 'radio':
|
|
22
|
+
return (_jsxs(Fragment, { children: [_jsxs("div", { className: "dte-pdf-field-content", style: {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
background: 'inherit',
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
}, children: [_jsx("input", { title: field.label, type: "radio", readOnly: true, className: "dte-pdf-field-fillable", style: {
|
|
29
|
+
width: field.width,
|
|
30
|
+
height: field.height,
|
|
31
|
+
margin: 0,
|
|
32
|
+
border: 'none',
|
|
33
|
+
} }), getFillablePaintedLabel(field)] }), _jsx(AddHandle, { onClick: () => handleAddNewField({
|
|
20
34
|
...field,
|
|
21
35
|
x: field.x + field.width + 15,
|
|
22
36
|
id: uuidv4(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-overlay-field-fillable.js","sourceRoot":"","sources":["../../../src/components/pdf-fields-overlay/pdf-overlay-field-fillable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,
|
|
1
|
+
{"version":3,"file":"pdf-overlay-field-fillable.js","sourceRoot":"","sources":["../../../src/components/pdf-fields-overlay/pdf-overlay-field-fillable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EACH,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzC,MAAM,CAAC,MAAM,uBAAuB,GAAqC,CAAC,EACtE,KAAK,EACL,iBAAiB,GACpB,EAAE,EAAE;IACD,MAAM,eAAe,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAEvD,MAAM,aAAa,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IAEvD,QAAQ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AC;QAEN,KAAK,MAAM;YACP,OAAO,CACH,gBACI,IAAI,EAAC,MAAM,EACX,QAAQ,QACR,SAAS,EAAE,0BAA0B,aAAa,EAAE,EACpD,WAAW,EAAE,eAAe,GAC9B,CACL,CAAC;QAEN,KAAK,QAAQ;YACT,OAAO,CACH,gBACI,IAAI,EAAC,QAAQ,EACb,QAAQ,QACR,SAAS,EAAE,0BAA0B,aAAa,EAAE,EACpD,WAAW,EAAE,eAAe,GAC9B,CACL,CAAC;QAEN;YACI,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;gBAClB,OAAO,CACH,mBACI,QAAQ,QACR,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAClE,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,0BAA0B,aAAa,EAAE,GACtD,CACL,CAAC;YACN,CAAC;YACD,OAAO,CACH,gBACI,IAAI,EAAC,MAAM,EACX,QAAQ,QACR,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,0BAA0B,aAAa,EAAE,GACtD,CACL,CAAC;IACV,CAAC;AACL,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,EACH,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,WAAW,EACnB,MAAM,uBAAuB,CAAC;
|
|
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,EACH,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,WAAW,EACnB,MAAM,uBAAuB,CAAC;AAS/B,UAAU,oBAAoB;IAC1B,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,YAAY,CAAC,CAAC,WAAW,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxE;AAED,UAAU,sBAAsB;IAC5B,KAAK,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAaD,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CAqBxD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,sBAAsB,CAoB5D,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAoIpD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { dateToUtcZero, getFieldPlaceholderText, getFieldTextClipClassName, toDateInputValue, } from '../../utils';
|
|
2
|
+
import { dateToUtcZero, getFieldPlaceholderText, getFieldTextClipClassName, getFillablePaintedLabel, toDateInputValue, } from '../../utils';
|
|
3
3
|
const fillableTextStyles = {
|
|
4
4
|
background: 'inherit',
|
|
5
5
|
width: '100%',
|
|
@@ -38,7 +38,7 @@ export const PdfViewFillable = ({ data, field, fillingBy, onDataChange, readOnly
|
|
|
38
38
|
height: field.height,
|
|
39
39
|
margin: 0,
|
|
40
40
|
border: 'none',
|
|
41
|
-
}, type: "checkbox", checked: resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : false, disabled: isInputDisabled, name: field.path, onChange: e => handleDataChange(e.target.checked) }),
|
|
41
|
+
}, type: "checkbox", checked: resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : false, disabled: isInputDisabled, name: field.path, onChange: e => handleDataChange(e.target.checked) }), getFillablePaintedLabel(field)] }));
|
|
42
42
|
}
|
|
43
43
|
if (field.subType === 'radio') {
|
|
44
44
|
return (_jsxs("div", { className: "dte-pdf-field-content", style: {
|
|
@@ -52,7 +52,7 @@ export const PdfViewFillable = ({ data, field, fillingBy, onDataChange, readOnly
|
|
|
52
52
|
height: field.height,
|
|
53
53
|
margin: 0,
|
|
54
54
|
border: 'none',
|
|
55
|
-
}, type: "radio", value: field.id, checked: resolvedValue === field.id, disabled: isInputDisabled, name: field.path, onChange: () => handleDataChange(field.id) }),
|
|
55
|
+
}, type: "radio", value: field.id, checked: resolvedValue === field.id, disabled: isInputDisabled, name: field.path, onChange: () => handleDataChange(field.id) }), getFillablePaintedLabel(field)] }));
|
|
56
56
|
}
|
|
57
57
|
if (field.subType === 'date') {
|
|
58
58
|
const dateInputValue = toDateInputValue(resolvedValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-view-fillable.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-fillable.tsx"],"names":[],"mappings":";AAOA,OAAO,EACH,aAAa,EACb,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,GACnB,MAAM,aAAa,CAAC;AAmBrB,MAAM,kBAAkB,GAAG;IACvB,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,YAAqB;IAChC,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;CACH,CAAC;AAEX,MAAM,CAAC,MAAM,iBAAiB,GAA+B,CAAC,EAC1D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AAC,IAAI,EAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GACnD,EACD,
|
|
1
|
+
{"version":3,"file":"pdf-view-fillable.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-fillable.tsx"],"names":[],"mappings":";AAOA,OAAO,EACH,aAAa,EACb,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,GACnB,MAAM,aAAa,CAAC;AAmBrB,MAAM,kBAAkB,GAAG;IACvB,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,YAAqB;IAChC,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;CACH,CAAC;AAEX,MAAM,CAAC,MAAM,iBAAiB,GAA+B,CAAC,EAC1D,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,GACR,EAAE,EAAE;IACD,OAAO,CACH,gBACI,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,0BAA0B,yBAAyB,CAAC,KAAK,CAAC,EAAE,EACvE,KAAK,EAAE,kBAAkB,EACzB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,KAAK,CAAC,IAAI,EACd,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACvC,WAAW,EAAE,uBAAuB,CAAC,KAAK,CAAC,GAC7C,CACL,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAA+B,CAAC,EAC9D,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,GACR,EAA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,KAAK,CAAC,IAAI,EACd,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,EAC1B,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC/C,WAAW,EAAE,uBAAuB,CAAC,KAAK,CAAC,GAC7C,CACL,CAAC;IACN,CAAC;IAED,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAClF,OAAO,CACH,KAAC,aAAa,IACV,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,EAC1B,QAAQ,EAAE,CAAC,UAAU,EACrB,QAAQ,EAAE,gBAAgB,GAC5B,CACL,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type PdfField } from '../../interface/types';
|
|
2
|
+
export declare const getFillablePaintedLabel: (field: PdfField) => string;
|
|
2
3
|
export declare const getFieldPlaceholderText: (field: PdfField, prefix?: string) => string;
|
|
3
4
|
//# sourceMappingURL=field-placeholder-text.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-placeholder-text.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/field/field-placeholder-text.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,eAAO,MAAM,uBAAuB,GAAI,OAAO,QAAQ,EAAE,SAAS,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"field-placeholder-text.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/field/field-placeholder-text.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,eAAO,MAAM,uBAAuB,GAAI,OAAO,QAAQ,WAEtD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,OAAO,QAAQ,EAAE,SAAS,MAAM,KAAG,MAU1E,CAAC"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
export const getFillablePaintedLabel = (field) => {
|
|
2
|
+
return field.hideLabel ? '' : field.label || '';
|
|
3
|
+
};
|
|
1
4
|
export const getFieldPlaceholderText = (field, prefix) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
/*
|
|
6
|
+
* A hidden label takes its required marker with it - a lone '*' floating in an otherwise empty box
|
|
7
|
+
* reads as stray ink on the document, not as a hint. Any prefix stays: it is a format hint supplied
|
|
8
|
+
* by the caller (e.g. 'mm/dd/yyyy'), not part of the label.
|
|
9
|
+
*/
|
|
5
10
|
const requiredIndicator = field.required && !field.hideLabel ? '*' : '';
|
|
6
|
-
const label = field
|
|
11
|
+
const label = getFillablePaintedLabel(field);
|
|
7
12
|
const parts = [prefix, label, requiredIndicator].filter(Boolean);
|
|
8
13
|
return parts.join(' ');
|
|
9
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-placeholder-text.utils.js","sourceRoot":"","sources":["../../../src/utils/field/field-placeholder-text.utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"field-placeholder-text.utils.js","sourceRoot":"","sources":["../../../src/utils/field/field-placeholder-text.utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAe,EAAE,EAAE;IACvD,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAe,EAAE,MAAe,EAAU,EAAE;IAChF;;;;OAIG;IACH,MAAM,iBAAiB,GAAG,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACxE,MAAM,KAAK,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { FieldTypeEnum, type SchemaObject } from '../../interface/types';
|
|
2
|
+
import {
|
|
3
|
+
extractGroupedFieldsFromDataModel,
|
|
4
|
+
getSchemaDataPointOptions,
|
|
5
|
+
resolvePdfDataValues,
|
|
6
|
+
} from '../../utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Scenario tests for tenant Custom Fields (DTE-4560).
|
|
10
|
+
*
|
|
11
|
+
* This editor has no notion of custom fields — it renders whatever the data model describes. The
|
|
12
|
+
* consumer (`clients/web`) builds a `__custom_fields` object node from the tenant's catalog and
|
|
13
|
+
* merges it into the template type's data model, then hands the matching values in as data.
|
|
14
|
+
*
|
|
15
|
+
* These tests pin the contract that arrangement depends on, so a change here surfaces as a failure
|
|
16
|
+
* rather than as blank fields in a signed contract:
|
|
17
|
+
* • the group is offered in the sidebar under its own name;
|
|
18
|
+
* • each option's path is `__custom_fields.<key>`, which is what a dropped field persists;
|
|
19
|
+
* • the same path resolves against the values the consumer supplies;
|
|
20
|
+
* • custom fields reach the display-condition picker but not the formula picker.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** Shaped exactly as `buildCustomFieldsSchemaNode` in clients/web produces it. */
|
|
24
|
+
const customFieldsNode: SchemaObject = {
|
|
25
|
+
type: 'object',
|
|
26
|
+
title: 'Custom Fields',
|
|
27
|
+
properties: {
|
|
28
|
+
Contract_Term: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
title: 'Contract Term',
|
|
31
|
+
options: { sampleData: 'Contract Term', useInConditionals: true },
|
|
32
|
+
},
|
|
33
|
+
Rev_2: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
title: 'Rev. 2',
|
|
36
|
+
options: { sampleData: 'Rev. 2', useInConditionals: true },
|
|
37
|
+
},
|
|
38
|
+
Срок_договора: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
title: 'Срок договора',
|
|
41
|
+
options: { sampleData: 'Срок договора', useInConditionals: true },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const schemaWithCustomFields: SchemaObject = {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
Job: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
title: 'Job',
|
|
52
|
+
properties: {
|
|
53
|
+
Total: {
|
|
54
|
+
type: 'number',
|
|
55
|
+
title: 'Total',
|
|
56
|
+
options: { useInCalculatedFields: true, useInConditionals: true },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
61
|
+
__custom_fields: customFieldsNode,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** What the consumer supplies as data — a dictionary, never the domain's `CustomFields` array. */
|
|
66
|
+
const customFieldValues = {
|
|
67
|
+
Job: { Total: 150 },
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
69
|
+
__custom_fields: {
|
|
70
|
+
Contract_Term: '36 months',
|
|
71
|
+
Rev_2: 'approved',
|
|
72
|
+
Срок_договора: '36 месяцев',
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const customFieldsGroup = () =>
|
|
77
|
+
extractGroupedFieldsFromDataModel(schemaWithCustomFields).find(
|
|
78
|
+
group => group.groupName === 'Custom Fields',
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
describe('custom fields — sidebar', () => {
|
|
82
|
+
it('offers a Custom Fields group alongside the data model groups', () => {
|
|
83
|
+
const groupNames = extractGroupedFieldsFromDataModel(schemaWithCustomFields).map(
|
|
84
|
+
group => group.groupName,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(groupNames).toContain('Custom Fields');
|
|
88
|
+
expect(groupNames).toContain('Job');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('labels each entry with the display name, not the key', () => {
|
|
92
|
+
expect(customFieldsGroup()!.fields.map(field => field.label)).toEqual([
|
|
93
|
+
'Contract Term',
|
|
94
|
+
'Rev. 2',
|
|
95
|
+
'Срок договора',
|
|
96
|
+
]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('gives every entry a __custom_fields path, which is what a dropped field persists', () => {
|
|
100
|
+
// usePdfFieldDnD copies option.path onto the new field and, for dataModel, its initializer
|
|
101
|
+
// is `base => base` — so the path below is verbatim what ends up in the saved template.
|
|
102
|
+
expect(customFieldsGroup()!.fields.map(field => field.path)).toEqual([
|
|
103
|
+
'__custom_fields.Contract_Term',
|
|
104
|
+
'__custom_fields.Rev_2',
|
|
105
|
+
'__custom_fields.Срок_договора',
|
|
106
|
+
]);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('types the entries as data model fields so they drop like any other merge tag', () => {
|
|
110
|
+
expect(customFieldsGroup()!.fields.every(f => f.type === FieldTypeEnum.dataModel)).toBe(
|
|
111
|
+
true,
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('carries sample data so the sidebar and the preview have something to show', () => {
|
|
116
|
+
expect(customFieldsGroup()!.fields.map(field => field.sampleData)).toEqual([
|
|
117
|
+
'Contract Term',
|
|
118
|
+
'Rev. 2',
|
|
119
|
+
'Срок договора',
|
|
120
|
+
]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('offers no group at all when the tenant has no custom fields', () => {
|
|
124
|
+
// The consumer omits the node entirely rather than sending an empty one, so an empty
|
|
125
|
+
// "Custom Fields" heading never appears.
|
|
126
|
+
const groups = extractGroupedFieldsFromDataModel({
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: { Job: schemaWithCustomFields.properties.Job },
|
|
129
|
+
} as SchemaObject);
|
|
130
|
+
|
|
131
|
+
expect(groups.map(group => group.groupName)).not.toContain('Custom Fields');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('custom fields — rendering values', () => {
|
|
136
|
+
it.each([
|
|
137
|
+
['__custom_fields.Contract_Term', '36 months'],
|
|
138
|
+
['__custom_fields.Rev_2', 'approved'],
|
|
139
|
+
['__custom_fields.Срок_договора', '36 месяцев'],
|
|
140
|
+
])('resolves %s to %s', (path, expected) => {
|
|
141
|
+
expect(resolvePdfDataValues(customFieldValues, path)).toBe(expected);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('draws every placed custom field from the values the consumer supplies', () => {
|
|
145
|
+
const drawn = customFieldsGroup()!.fields.map(field =>
|
|
146
|
+
resolvePdfDataValues(customFieldValues, field.path),
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
expect(drawn).toEqual(['36 months', 'approved', '36 месяцев']);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('draws nothing, rather than throwing, when a field has no answer', () => {
|
|
153
|
+
expect(resolvePdfDataValues({ __custom_fields: {} }, '__custom_fields.Contract_Term')).toBe(
|
|
154
|
+
'',
|
|
155
|
+
);
|
|
156
|
+
expect(resolvePdfDataValues({}, '__custom_fields.Contract_Term')).toBe('');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('cannot resolve the domain array shape, which is why the consumer reshapes it first', () => {
|
|
160
|
+
// The Contracts payload sends CustomFields: [{ Name, Value }]. No dot path reaches into it —
|
|
161
|
+
// this is the reason __custom_fields exists at all.
|
|
162
|
+
const domainShape = {
|
|
163
|
+
CustomFields: [{ Name: 'Contract Term', Value: '36 months' }],
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
expect(resolvePdfDataValues(domainShape, '__custom_fields.Contract_Term')).toBe('');
|
|
167
|
+
expect(resolvePdfDataValues(domainShape, 'CustomFields.Contract_Term')).toBe('');
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
describe('custom fields — pickers', () => {
|
|
172
|
+
it('appears in the display-condition picker', () => {
|
|
173
|
+
const keys = getSchemaDataPointOptions(schemaWithCustomFields).map(o => o.fullKey);
|
|
174
|
+
|
|
175
|
+
expect(keys).toContain('__custom_fields.Contract_Term');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('stays out of the formula picker', () => {
|
|
179
|
+
// Every custom-field answer arrives as a string, which the formula evaluator resolves to no
|
|
180
|
+
// value, so the consumer deliberately omits useInCalculatedFields.
|
|
181
|
+
const calculated = extractGroupedFieldsFromDataModel(schemaWithCustomFields, {
|
|
182
|
+
onlyUseInCalculatedFields: true,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
expect(calculated.map(group => group.groupName)).not.toContain('Custom Fields');
|
|
186
|
+
});
|
|
187
|
+
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FC, Fragment } from 'react';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import { type PdfField } from '../../interface/types';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getFieldPlaceholderText,
|
|
6
|
+
getFieldTextClipClassName,
|
|
7
|
+
getFillablePaintedLabel,
|
|
8
|
+
} from '../../utils';
|
|
5
9
|
import { AddHandle } from './add-handle';
|
|
6
10
|
|
|
7
11
|
interface PdfOverlayFieldFillableProps {
|
|
@@ -20,29 +24,57 @@ export const PdfOverlayFieldFillable: FC<PdfOverlayFieldFillableProps> = ({
|
|
|
20
24
|
switch (field.subType) {
|
|
21
25
|
case 'checkbox':
|
|
22
26
|
return (
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
readOnly
|
|
26
|
-
className="dte-pdf-field-fillable"
|
|
27
|
+
<div
|
|
28
|
+
className="dte-pdf-field-content"
|
|
27
29
|
style={{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
background: 'inherit',
|
|
30
33
|
}}
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
case 'radio':
|
|
35
|
-
return (
|
|
36
|
-
<Fragment>
|
|
34
|
+
>
|
|
37
35
|
<input
|
|
38
|
-
|
|
36
|
+
title={field.label}
|
|
37
|
+
type="checkbox"
|
|
39
38
|
readOnly
|
|
40
39
|
className="dte-pdf-field-fillable"
|
|
41
40
|
style={{
|
|
42
41
|
width: field.width,
|
|
43
42
|
height: field.height,
|
|
43
|
+
margin: 0,
|
|
44
|
+
border: 'none',
|
|
44
45
|
}}
|
|
45
46
|
/>
|
|
47
|
+
{getFillablePaintedLabel(field)}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
case 'radio':
|
|
52
|
+
return (
|
|
53
|
+
<Fragment>
|
|
54
|
+
<div
|
|
55
|
+
className="dte-pdf-field-content"
|
|
56
|
+
style={{
|
|
57
|
+
display: 'flex',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
background: 'inherit',
|
|
60
|
+
width: '100%',
|
|
61
|
+
height: '100%',
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<input
|
|
65
|
+
title={field.label}
|
|
66
|
+
type="radio"
|
|
67
|
+
readOnly
|
|
68
|
+
className="dte-pdf-field-fillable"
|
|
69
|
+
style={{
|
|
70
|
+
width: field.width,
|
|
71
|
+
height: field.height,
|
|
72
|
+
margin: 0,
|
|
73
|
+
border: 'none',
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
{getFillablePaintedLabel(field)}
|
|
77
|
+
</div>
|
|
46
78
|
<AddHandle
|
|
47
79
|
onClick={() =>
|
|
48
80
|
handleAddNewField({
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
dateToUtcZero,
|
|
10
10
|
getFieldPlaceholderText,
|
|
11
11
|
getFieldTextClipClassName,
|
|
12
|
+
getFillablePaintedLabel,
|
|
12
13
|
toDateInputValue,
|
|
13
14
|
} from '../../utils';
|
|
14
15
|
|
|
@@ -132,7 +133,7 @@ export const PdfViewFillable: FC<PdfViewFillableProps> = ({
|
|
|
132
133
|
name={field.path}
|
|
133
134
|
onChange={e => handleDataChange(e.target.checked)}
|
|
134
135
|
/>
|
|
135
|
-
{
|
|
136
|
+
{getFillablePaintedLabel(field)}
|
|
136
137
|
</div>
|
|
137
138
|
);
|
|
138
139
|
}
|
|
@@ -164,7 +165,7 @@ export const PdfViewFillable: FC<PdfViewFillableProps> = ({
|
|
|
164
165
|
name={field.path}
|
|
165
166
|
onChange={() => handleDataChange(field.id)}
|
|
166
167
|
/>
|
|
167
|
-
{
|
|
168
|
+
{getFillablePaintedLabel(field)}
|
|
168
169
|
</div>
|
|
169
170
|
);
|
|
170
171
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldTypeEnum, type PdfField } from '../../../interface/types';
|
|
2
|
-
import { getFieldPlaceholderText } from '../field-placeholder-text.utils';
|
|
2
|
+
import { getFieldPlaceholderText, getFillablePaintedLabel } from '../field-placeholder-text.utils';
|
|
3
3
|
|
|
4
4
|
const buildField = (overrides: Partial<PdfField> = {}): PdfField => ({
|
|
5
5
|
id: 'field-1',
|
|
@@ -60,3 +60,19 @@ describe('getFieldPlaceholderText', () => {
|
|
|
60
60
|
expect(subject(buildField({ hideLabel: false, required: true }))).toBe('Field Label *');
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
+
|
|
64
|
+
describe('getFillablePaintedLabel', () => {
|
|
65
|
+
const subject = (field: PdfField) => getFillablePaintedLabel(field);
|
|
66
|
+
|
|
67
|
+
test('returns the label so editor and fill paint the same adjacent text', () => {
|
|
68
|
+
expect(subject(buildField({ subType: 'checkbox' }))).toBe('Field Label');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('returns empty when hideLabel is set, including in the authoring overlay', () => {
|
|
72
|
+
expect(subject(buildField({ subType: 'checkbox', hideLabel: true }))).toBe('');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('treats an absent hideLabel as shown, so pre-existing fields keep their label', () => {
|
|
76
|
+
expect(subject(buildField({ subType: 'radio' }))).toBe('Field Label');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { type PdfField } from '../../interface/types';
|
|
2
2
|
|
|
3
|
+
export const getFillablePaintedLabel = (field: PdfField) => {
|
|
4
|
+
return field.hideLabel ? '' : field.label || '';
|
|
5
|
+
};
|
|
6
|
+
|
|
3
7
|
export const getFieldPlaceholderText = (field: PdfField, prefix?: string): string => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
/*
|
|
9
|
+
* A hidden label takes its required marker with it - a lone '*' floating in an otherwise empty box
|
|
10
|
+
* reads as stray ink on the document, not as a hint. Any prefix stays: it is a format hint supplied
|
|
11
|
+
* by the caller (e.g. 'mm/dd/yyyy'), not part of the label.
|
|
12
|
+
*/
|
|
7
13
|
const requiredIndicator = field.required && !field.hideLabel ? '*' : '';
|
|
8
|
-
const label = field
|
|
14
|
+
const label = getFillablePaintedLabel(field);
|
|
9
15
|
const parts = [prefix, label, requiredIndicator].filter(Boolean);
|
|
10
16
|
return parts.join(' ');
|
|
11
17
|
};
|