@servicetitan/dte-pdf-editor 1.12.0 → 1.13.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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button,
|
|
2
|
+
import { Button, Combobox, Flex, Textarea, TextField } from '@servicetitan/anvil2';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { E_SIGN_FIELD_TYPE_OPTIONS } from '../../constants';
|
|
5
5
|
import { FieldTypeEnum } from '../../interface/types';
|
|
6
|
-
import { generateESignPath } from '../../utils';
|
|
6
|
+
import { generateESignPath, generateFillablePath } from '../../utils';
|
|
7
7
|
export const FieldConfigPanel = ({ field, onDeleteField, onFieldConfigChange, recipients = [], }) => {
|
|
8
8
|
const recipientOptions = useMemo(() => recipients.map(recipient => ({
|
|
9
9
|
id: recipient.name,
|
|
@@ -12,11 +12,16 @@ export const FieldConfigPanel = ({ field, onDeleteField, onFieldConfigChange, re
|
|
|
12
12
|
const selectedRecipient = useMemo(() => { var _a; return (_a = recipientOptions.find(option => option.id === field.recipient)) !== null && _a !== void 0 ? _a : null; }, [recipientOptions, field.recipient]);
|
|
13
13
|
const handleRecipientChange = (item) => {
|
|
14
14
|
if (item) {
|
|
15
|
+
let path = field.path;
|
|
16
|
+
if (field.type === FieldTypeEnum.eSign) {
|
|
17
|
+
path = generateESignPath(item.id, field.subType);
|
|
18
|
+
}
|
|
19
|
+
if (field.type === FieldTypeEnum.fillable) {
|
|
20
|
+
path = generateFillablePath(item.id, field.id);
|
|
21
|
+
}
|
|
15
22
|
onFieldConfigChange({
|
|
16
23
|
recipient: item.id,
|
|
17
|
-
path
|
|
18
|
-
? generateESignPath(item.id, field.subType)
|
|
19
|
-
: field.path,
|
|
24
|
+
path,
|
|
20
25
|
});
|
|
21
26
|
}
|
|
22
27
|
};
|
|
@@ -31,9 +36,7 @@ export const FieldConfigPanel = ({ field, onDeleteField, onFieldConfigChange, re
|
|
|
31
36
|
};
|
|
32
37
|
return (_jsxs(Flex, { direction: "column", gap: "4", children: [(field.type === FieldTypeEnum.fillable || field.type === FieldTypeEnum.eSign) && (_jsx(TextField, { label: "Label", value: field.label, onChange: e => onFieldConfigChange({
|
|
33
38
|
label: e.target.value,
|
|
34
|
-
}) })), (field.type === FieldTypeEnum.fillable || field.type === FieldTypeEnum.eSign) && (_jsxs(Combobox, { items: recipientOptions, itemToString: item => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.name) !== null && _a !== void 0 ? _a : ''; }, onChange: handleRecipientChange, selectedItem: selectedRecipient, children: [_jsx(Combobox.SearchField, { placeholder: "", label: "Recipient" }), _jsx(Combobox.Content, { children: ({ items }) => (_jsx(Combobox.List, { children: items.map((item, i) => (_jsx(Combobox.Item, { item: item, index: i, children: item.name }, item.id))) })) })] })), field.type === FieldTypeEnum.eSign && (_jsxs(Combobox, { items: E_SIGN_FIELD_TYPE_OPTIONS, itemToString: item => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.name) !== null && _a !== void 0 ? _a : ''; }, onChange: handleESignFieldTypeChange, selectedItem: selectedESignFieldType, children: [_jsx(Combobox.SearchField, { label: "Field Type" }), _jsx(Combobox.Content, { children: ({ items }) => (_jsx(Combobox.List, { children: items.map((item, i) => (_jsx(Combobox.Item, { item: item, index: i, children: item.name }, item.id))) })) })] })), _jsx(TextField, { label: "Data Path", value: field.path, disabled: true }),
|
|
35
|
-
required: !field.required,
|
|
36
|
-
}) })), _jsx(Textarea, { label: "Description", value: field.description, onChange: e => {
|
|
39
|
+
}) })), (field.type === FieldTypeEnum.fillable || field.type === FieldTypeEnum.eSign) && (_jsxs(Combobox, { items: recipientOptions, itemToString: item => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.name) !== null && _a !== void 0 ? _a : ''; }, onChange: handleRecipientChange, selectedItem: selectedRecipient, filterOptions: { keys: ['name'] }, children: [_jsx(Combobox.SearchField, { placeholder: "", label: "Recipient" }), _jsx(Combobox.Content, { children: ({ items }) => (_jsx(Combobox.List, { children: items.map((item, i) => (_jsx(Combobox.Item, { item: item, index: i, children: item.name }, item.id))) })) })] })), field.type === FieldTypeEnum.eSign && (_jsxs(Combobox, { items: E_SIGN_FIELD_TYPE_OPTIONS, itemToString: item => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.name) !== null && _a !== void 0 ? _a : ''; }, onChange: handleESignFieldTypeChange, selectedItem: selectedESignFieldType, children: [_jsx(Combobox.SearchField, { label: "Field Type" }), _jsx(Combobox.Content, { children: ({ items }) => (_jsx(Combobox.List, { children: items.map((item, i) => (_jsx(Combobox.Item, { item: item, index: i, children: item.name }, item.id))) })) })] })), _jsx(TextField, { label: "Data Path", value: field.path, disabled: true }), _jsx(Textarea, { label: "Description", value: field.description, onChange: e => {
|
|
37
40
|
var _a;
|
|
38
41
|
return onFieldConfigChange({
|
|
39
42
|
description: (_a = e === null || e === void 0 ? void 0 : e.target.value) !== null && _a !== void 0 ? _a : '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-config-panel.js","sourceRoot":"","sources":["../../../src/components/field-config-panel/field-config-panel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"field-config-panel.js","sourceRoot":"","sources":["../../../src/components/field-config-panel/field-config-panel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAM,OAAO,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAkB,aAAa,EAA2B,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA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,EAAE,QAAQ,SAAG,EAa3D,KAAC,QAAQ,IACL,KAAK,EAAC,aAAa,EACnB,KAAK,EAAE,KAAK,CAAC,WAAW,EACxB,QAAQ,EAAE,CAAC,CAAC,EAAE;;oBACV,OAAA,mBAAmB,CAAC;wBAChB,WAAW,EAAE,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,MAAM,CAAC,KAAK,mCAAI,EAAE;qBACrC,CAAC,CAAA;iBAAA,GAER,EACF,KAAC,MAAM,IAAC,SAAS,EAAC,YAAY,EAAC,OAAO,EAAE,aAAa,6BAE5C,IACN,CACV,CAAC;AACN,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Button,
|
|
1
|
+
import { Button, Combobox, Flex, Textarea, TextField } from '@servicetitan/anvil2';
|
|
2
2
|
import { FC, useMemo } from 'react';
|
|
3
3
|
import { E_SIGN_FIELD_TYPE_OPTIONS } from '../../constants';
|
|
4
4
|
import { ESignFieldType, FieldTypeEnum, PdfField, RecipientInfo } from '../../interface/types';
|
|
5
|
-
import { generateESignPath } from '../../utils';
|
|
5
|
+
import { generateESignPath, generateFillablePath } from '../../utils';
|
|
6
6
|
|
|
7
7
|
interface FieldConfigPanelProps {
|
|
8
8
|
field: PdfField;
|
|
@@ -33,12 +33,16 @@ export const FieldConfigPanel: FC<FieldConfigPanelProps> = ({
|
|
|
33
33
|
|
|
34
34
|
const handleRecipientChange = (item: { id: string; name: string } | null) => {
|
|
35
35
|
if (item) {
|
|
36
|
+
let path = field.path;
|
|
37
|
+
if (field.type === FieldTypeEnum.eSign) {
|
|
38
|
+
path = generateESignPath(item.id, field.subType as ESignFieldType);
|
|
39
|
+
}
|
|
40
|
+
if (field.type === FieldTypeEnum.fillable) {
|
|
41
|
+
path = generateFillablePath(item.id, field.id);
|
|
42
|
+
}
|
|
36
43
|
onFieldConfigChange({
|
|
37
44
|
recipient: item.id,
|
|
38
|
-
path
|
|
39
|
-
field.type === FieldTypeEnum.eSign
|
|
40
|
-
? generateESignPath(item.id, field.subType as ESignFieldType)
|
|
41
|
-
: field.path,
|
|
45
|
+
path,
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
48
|
};
|
|
@@ -70,13 +74,13 @@ export const FieldConfigPanel: FC<FieldConfigPanelProps> = ({
|
|
|
70
74
|
}
|
|
71
75
|
/>
|
|
72
76
|
)}
|
|
73
|
-
|
|
74
77
|
{(field.type === FieldTypeEnum.fillable || field.type === FieldTypeEnum.eSign) && (
|
|
75
78
|
<Combobox
|
|
76
79
|
items={recipientOptions}
|
|
77
80
|
itemToString={item => item?.name ?? ''}
|
|
78
81
|
onChange={handleRecipientChange}
|
|
79
82
|
selectedItem={selectedRecipient}
|
|
83
|
+
filterOptions={{ keys: ['name'] }}
|
|
80
84
|
>
|
|
81
85
|
<Combobox.SearchField placeholder="" label="Recipient" />
|
|
82
86
|
<Combobox.Content>
|
|
@@ -92,7 +96,6 @@ export const FieldConfigPanel: FC<FieldConfigPanelProps> = ({
|
|
|
92
96
|
</Combobox.Content>
|
|
93
97
|
</Combobox>
|
|
94
98
|
)}
|
|
95
|
-
|
|
96
99
|
{field.type === FieldTypeEnum.eSign && (
|
|
97
100
|
<Combobox
|
|
98
101
|
items={E_SIGN_FIELD_TYPE_OPTIONS}
|
|
@@ -114,21 +117,19 @@ export const FieldConfigPanel: FC<FieldConfigPanelProps> = ({
|
|
|
114
117
|
</Combobox.Content>
|
|
115
118
|
</Combobox>
|
|
116
119
|
)}
|
|
117
|
-
|
|
118
120
|
<TextField label="Data Path" value={field.path} disabled />
|
|
119
|
-
|
|
120
|
-
{field.type === FieldTypeEnum.fillable && (
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
)}
|
|
131
|
-
|
|
121
|
+
{/* Todo need to uncomment when in MFE starts handle validations */}
|
|
122
|
+
{/* {field.type === FieldTypeEnum.fillable && (*/}
|
|
123
|
+
{/* <Checkbox*/}
|
|
124
|
+
{/* label="Required"*/}
|
|
125
|
+
{/* checked={field.required}*/}
|
|
126
|
+
{/* onChange={() =>*/}
|
|
127
|
+
{/* onFieldConfigChange({*/}
|
|
128
|
+
{/* required: !field.required,*/}
|
|
129
|
+
{/* })*/}
|
|
130
|
+
{/* }*/}
|
|
131
|
+
{/* />*/}
|
|
132
|
+
{/* )}*/}
|
|
132
133
|
<Textarea
|
|
133
134
|
label="Description"
|
|
134
135
|
value={field.description}
|
|
@@ -138,7 +139,6 @@ export const FieldConfigPanel: FC<FieldConfigPanelProps> = ({
|
|
|
138
139
|
})
|
|
139
140
|
}
|
|
140
141
|
/>
|
|
141
|
-
|
|
142
142
|
<Button className="full-width" onClick={onDeleteField}>
|
|
143
143
|
Delete Field
|
|
144
144
|
</Button>
|