@servicetitan/dte-pdf-editor 1.47.0 → 1.48.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/display-conditions/display-condition.d.ts.map +1 -1
- package/dist/components/display-conditions/display-condition.js +10 -2
- package/dist/components/display-conditions/display-condition.js.map +1 -1
- package/package.json +1 -1
- package/src/components/display-conditions/display-condition.tsx +42 -9
- package/src/styles/generic.css +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-condition.d.ts","sourceRoot":"","sources":["../../../src/components/display-conditions/display-condition.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"display-condition.d.ts","sourceRoot":"","sources":["../../../src/components/display-conditions/display-condition.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,EAAE,EAAsB,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAyB,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAE9F,UAAU,qBACN,SAAQ,IAAI,CACR,0BAA0B,EACxB,gBAAgB,GAChB,oBAAoB,GACpB,yBAAyB,GACzB,OAAO,GACP,cAAc,GACd,qBAAqB,GACrB,QAAQ,CACb;IACD,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAoEtD,CAAC"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button } from '@servicetitan/anvil2';
|
|
2
|
+
import { Button, Flex, Text } from '@servicetitan/anvil2';
|
|
3
3
|
import PlusIcon from '@servicetitan/anvil2/assets/icons/material/round/add.svg';
|
|
4
|
+
import DeleteIcon from '@servicetitan/anvil2/assets/icons/material/round/delete.svg';
|
|
5
|
+
import EditIcon from '@servicetitan/anvil2/assets/icons/material/round/edit.svg';
|
|
4
6
|
import { Fragment, useState } from 'react';
|
|
5
7
|
import { DisplayConditionModal } from './display-condition-modal';
|
|
6
8
|
export const DisplayCondition = ({ documentFields, formFieldsByFormId, formFieldsLoadingFormId, forms, initialState, onRequestFormFields, onSave, schema, }) => {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
7
10
|
const [open, setOpen] = useState(false);
|
|
8
|
-
|
|
11
|
+
const conditionCount = (_d = (_c = (_b = (_a = initialState === null || initialState === void 0 ? void 0 : initialState.groups) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.conditions) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
|
|
12
|
+
return (_jsxs(Fragment, { children: [conditionCount === 0 ? (_jsx(Button, { appearance: "secondary", className: "full-width", icon: PlusIcon, onClick: () => setOpen(true), children: "Add Display Condition" })) : (_jsxs(Flex, { gap: 2, justifyContent: "space-between", alignItems: "center", className: "bordered-paper", children: [_jsxs(Flex, { direction: "column", children: [_jsx(Text, { children: (initialState === null || initialState === void 0 ? void 0 : initialState.behavior) === 'show'
|
|
13
|
+
? 'Show condition configured'
|
|
14
|
+
: 'Hide condition configured' }), _jsx(Text, { size: "small", subdued: true, variant: "body", children: conditionCount === 1
|
|
15
|
+
? '1 condition is currently applied'
|
|
16
|
+
: `${conditionCount} conditions are currently applied` })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Button, { size: "small", icon: EditIcon, onClick: () => setOpen(true) }), _jsx(Button, { size: "small", icon: DeleteIcon, onClick: () => onSave({ displayCondition: undefined }) })] })] })), open && (_jsx(DisplayConditionModal, { onClose: () => setOpen(false), onSave: state => onSave({ displayCondition: state !== null && state !== void 0 ? state : undefined }), documentFields: documentFields, formFieldsByFormId: formFieldsByFormId, formFieldsLoadingFormId: formFieldsLoadingFormId, forms: forms, initialState: initialState, onRequestFormFields: onRequestFormFields, schema: schema }))] }));
|
|
9
17
|
};
|
|
10
18
|
//# sourceMappingURL=display-condition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-condition.js","sourceRoot":"","sources":["../../../src/components/display-conditions/display-condition.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"display-condition.js","sourceRoot":"","sources":["../../../src/components/display-conditions/display-condition.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,QAAQ,MAAM,0DAA0D,CAAC;AAChF,OAAO,UAAU,MAAM,6DAA6D,CAAC;AACrF,OAAO,QAAQ,MAAM,2DAA2D,CAAC;AACjF,OAAO,EAAM,QAAQ,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAA8B,MAAM,2BAA2B,CAAC;AAgB9F,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EACxD,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,EACL,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,MAAM,GACT,EAAE,EAAE;;IACD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,cAAc,GAAG,MAAA,MAAA,MAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,0CAAG,CAAC,CAAC,0CAAE,UAAU,0CAAE,MAAM,mCAAI,CAAC,CAAC;IAE1E,OAAO,CACH,MAAC,QAAQ,eACJ,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,CACpB,KAAC,MAAM,IACH,UAAU,EAAC,WAAW,EACtB,SAAS,EAAC,YAAY,EACtB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IA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,YAAY,EAC1B,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,GAChB,CACL,IACM,CACd,CAAC;AACN,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Button } from '@servicetitan/anvil2';
|
|
1
|
+
import { Button, Flex, Text } from '@servicetitan/anvil2';
|
|
2
2
|
import PlusIcon from '@servicetitan/anvil2/assets/icons/material/round/add.svg';
|
|
3
|
+
import DeleteIcon from '@servicetitan/anvil2/assets/icons/material/round/delete.svg';
|
|
4
|
+
import EditIcon from '@servicetitan/anvil2/assets/icons/material/round/edit.svg';
|
|
3
5
|
import { FC, Fragment, useState } from 'react';
|
|
4
6
|
import { PdfField } from '../../interface/types';
|
|
5
7
|
import { DisplayConditionModal, DisplayConditionModalProps } from './display-condition-modal';
|
|
@@ -29,17 +31,48 @@ export const DisplayCondition: FC<DisplayConditionProps> = ({
|
|
|
29
31
|
schema,
|
|
30
32
|
}) => {
|
|
31
33
|
const [open, setOpen] = useState(false);
|
|
34
|
+
const conditionCount = initialState?.groups?.[0]?.conditions?.length ?? 0;
|
|
32
35
|
|
|
33
36
|
return (
|
|
34
37
|
<Fragment>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
{conditionCount === 0 ? (
|
|
39
|
+
<Button
|
|
40
|
+
appearance="secondary"
|
|
41
|
+
className="full-width"
|
|
42
|
+
icon={PlusIcon}
|
|
43
|
+
onClick={() => setOpen(true)}
|
|
44
|
+
>
|
|
45
|
+
Add Display Condition
|
|
46
|
+
</Button>
|
|
47
|
+
) : (
|
|
48
|
+
<Flex
|
|
49
|
+
gap={2}
|
|
50
|
+
justifyContent="space-between"
|
|
51
|
+
alignItems="center"
|
|
52
|
+
className="bordered-paper"
|
|
53
|
+
>
|
|
54
|
+
<Flex direction="column">
|
|
55
|
+
<Text>
|
|
56
|
+
{initialState?.behavior === 'show'
|
|
57
|
+
? 'Show condition configured'
|
|
58
|
+
: 'Hide condition configured'}
|
|
59
|
+
</Text>
|
|
60
|
+
<Text size="small" subdued variant="body">
|
|
61
|
+
{conditionCount === 1
|
|
62
|
+
? '1 condition is currently applied'
|
|
63
|
+
: `${conditionCount} conditions are currently applied`}
|
|
64
|
+
</Text>
|
|
65
|
+
</Flex>
|
|
66
|
+
<Flex gap={2}>
|
|
67
|
+
<Button size="small" icon={EditIcon} onClick={() => setOpen(true)} />
|
|
68
|
+
<Button
|
|
69
|
+
size="small"
|
|
70
|
+
icon={DeleteIcon}
|
|
71
|
+
onClick={() => onSave({ displayCondition: undefined })}
|
|
72
|
+
/>
|
|
73
|
+
</Flex>
|
|
74
|
+
</Flex>
|
|
75
|
+
)}
|
|
43
76
|
{open && (
|
|
44
77
|
<DisplayConditionModal
|
|
45
78
|
onClose={() => setOpen(false)}
|