@servicetitan/dte-unlayer 0.158.0 → 0.160.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/api-core.js +22 -29
- package/dist/api-core.js.map +1 -1
- package/dist/api-custom-tools.js +23 -29
- package/dist/api-custom-tools.js.map +1 -1
- package/dist/business-calendar/BusinessCalendarDrawer.d.ts +19 -0
- package/dist/business-calendar/BusinessCalendarDrawer.d.ts.map +1 -0
- package/dist/business-calendar/BusinessCalendarDrawer.js +41 -0
- package/dist/business-calendar/BusinessCalendarDrawer.js.map +1 -0
- package/dist/business-calendar/business-calendar-requests.d.ts +25 -0
- package/dist/business-calendar/business-calendar-requests.d.ts.map +1 -0
- package/dist/business-calendar/business-calendar-requests.js +46 -0
- package/dist/business-calendar/business-calendar-requests.js.map +1 -0
- package/dist/business-calendar/business-calendar-state.d.ts +22 -0
- package/dist/business-calendar/business-calendar-state.d.ts.map +1 -0
- package/dist/business-calendar/business-calendar-state.js +74 -0
- package/dist/business-calendar/business-calendar-state.js.map +1 -0
- package/dist/business-calendar/useBusinessCalendarRequests.d.ts +15 -0
- package/dist/business-calendar/useBusinessCalendarRequests.d.ts.map +1 -0
- package/dist/business-calendar/useBusinessCalendarRequests.js +30 -0
- package/dist/business-calendar/useBusinessCalendarRequests.js.map +1 -0
- package/dist/display-conditions/ConditionGroup.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroup.js +20 -89
- package/dist/display-conditions/ConditionGroup.js.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.js +2 -70
- package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
- package/dist/display-conditions/ConditionRow.d.ts.map +1 -1
- package/dist/display-conditions/ConditionRow.js +88 -212
- package/dist/display-conditions/ConditionRow.js.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.js +39 -194
- package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
- package/dist/display-conditions/LookupValueControl.js +42 -105
- package/dist/display-conditions/LookupValueControl.js.map +1 -1
- package/dist/display-conditions/SeparatorWithChip.js +1 -10
- package/dist/display-conditions/SeparatorWithChip.js.map +1 -1
- package/dist/display-conditions/constants.js +15 -20
- package/dist/display-conditions/constants.js.map +1 -1
- package/dist/display-conditions/displayConditionController.js +5 -8
- package/dist/display-conditions/displayConditionController.js.map +1 -1
- package/dist/display-conditions/lookupOptionsController.js +16 -16
- package/dist/display-conditions/lookupOptionsController.js.map +1 -1
- package/dist/display-conditions/nunjucks.js +98 -116
- package/dist/display-conditions/nunjucks.js.map +1 -1
- package/dist/display-conditions/schemaDataPoints.js +13 -11
- package/dist/display-conditions/schemaDataPoints.js.map +1 -1
- package/dist/display-conditions/types.js +23 -67
- package/dist/display-conditions/types.js.map +1 -1
- package/dist/display-conditions/useConditionForms.js +38 -56
- package/dist/display-conditions/useConditionForms.js.map +1 -1
- package/dist/display-conditions/useLookupOptions.js +24 -44
- package/dist/display-conditions/useLookupOptions.js.map +1 -1
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.js +42 -155
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.js.map +1 -1
- package/dist/e-sign-offset/ESignOffsetRuleRow.js +12 -73
- package/dist/e-sign-offset/ESignOffsetRuleRow.js.map +1 -1
- package/dist/e-sign-offset/eSignOffsetController.js +5 -8
- package/dist/e-sign-offset/eSignOffsetController.js.map +1 -1
- package/dist/editor-core-source.d.ts +2 -2
- package/dist/editor-core-source.d.ts.map +1 -1
- package/dist/editor-core-source.js +3 -3
- package/dist/editor-core-source.js.map +1 -1
- package/dist/editor-core.js +2 -2
- package/dist/editor-core.js.map +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +56 -118
- package/dist/editor.js.map +1 -1
- package/dist/image-upload-error.js +3 -3
- package/dist/image-upload-error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/loadScript.js +7 -8
- package/dist/loadScript.js.map +1 -1
- package/dist/log.js +2 -3
- package/dist/log.js.map +1 -1
- package/dist/merge-tags.js +18 -17
- package/dist/merge-tags.js.map +1 -1
- package/dist/shared/configs.js +1 -2
- package/dist/shared/configs.js.map +1 -1
- package/dist/shared/const.d.ts +70 -0
- package/dist/shared/const.d.ts.map +1 -1
- package/dist/shared/const.js +13 -4
- package/dist/shared/const.js.map +1 -1
- package/dist/shared/date-calc.js +47 -38
- package/dist/shared/date-calc.js.map +1 -1
- package/dist/shared/e-sign-offset.js +46 -63
- package/dist/shared/e-sign-offset.js.map +1 -1
- package/dist/shared/edit-icon.js +0 -1
- package/dist/shared/edit-icon.js.map +1 -1
- package/dist/shared/fonts.js +16 -17
- package/dist/shared/fonts.js.map +1 -1
- package/dist/shared/forms.js +16 -38
- package/dist/shared/forms.js.map +1 -1
- package/dist/shared/instance-id.js +6 -9
- package/dist/shared/instance-id.js.map +1 -1
- package/dist/shared/nunjucks-helpers.js +2 -5
- package/dist/shared/nunjucks-helpers.js.map +1 -1
- package/dist/shared/schema.js +52 -96
- package/dist/shared/schema.js.map +1 -1
- package/dist/shared/tools.js +6 -13
- package/dist/shared/tools.js.map +1 -1
- package/dist/store.d.ts +15 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +851 -548
- package/dist/store.js.map +1 -1
- package/dist/tools.js +133 -143
- package/dist/tools.js.map +1 -1
- package/dist/unlayer-interface.d.ts +15 -4
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer-interface.js +1 -2
- package/dist/unlayer-interface.js.map +1 -1
- package/dist/unlayer.js +86 -113
- package/dist/unlayer.js.map +1 -1
- package/dist/vendor/dte-shared/business-calendar-validation.utils.d.ts +25 -0
- package/dist/vendor/dte-shared/business-calendar-validation.utils.js +80 -0
- package/dist/vendor/dte-shared/components/business-calendar-section.d.ts +15 -0
- package/dist/vendor/dte-shared/components/business-calendar-section.js +14 -0
- package/dist/vendor/dte-shared/components/schedule-drawer.d.ts +18 -0
- package/dist/vendor/dte-shared/components/schedule-drawer.js +119 -0
- package/dist/vendor/dte-shared/components/schedule-picker.d.ts +8 -0
- package/dist/vendor/dte-shared/components/schedule-picker.js +88 -0
- package/dist/vendor/dte-shared/constants.d.ts +31 -0
- package/dist/vendor/dte-shared/constants.js +34 -0
- package/dist/vendor/dte-shared/field-schedule-editor-context.d.ts +31 -0
- package/dist/vendor/dte-shared/field-schedule-editor-context.js +110 -0
- package/dist/vendor/dte-shared/index.d.ts +8 -0
- package/dist/vendor/dte-shared/index.js +7 -0
- package/dist/vendor/dte-shared/schedule-bindings.utils.d.ts +22 -0
- package/dist/vendor/dte-shared/schedule-bindings.utils.js +31 -0
- package/dist/vendor/dte-shared/styles/schedule.css +19 -0
- package/dist/vendor/dte-shared/types.d.ts +129 -0
- package/dist/vendor/dte-shared/types.js +1 -0
- package/package.json +7 -1
- package/src/__tests__/business-calendar-drawer.test.tsx +183 -0
- package/src/__tests__/business-calendar-requests.test.ts +166 -0
- package/src/__tests__/business-calendar-state.test.tsx +142 -0
- package/src/__tests__/condition-row.test.tsx +51 -8
- package/src/__tests__/e-sign-offset-modal.test.tsx +13 -2
- package/src/__tests__/store.business-calendar.test.ts +185 -0
- package/src/__tests__/unlayer.e-sign-types.test.ts +30 -0
- package/src/business-calendar/BusinessCalendarDrawer.tsx +76 -0
- package/src/business-calendar/business-calendar-requests.ts +80 -0
- package/src/business-calendar/business-calendar-state.ts +113 -0
- package/src/business-calendar/useBusinessCalendarRequests.ts +49 -0
- package/src/display-conditions/ConditionGroup.tsx +13 -3
- package/src/display-conditions/ConditionGroupsSection.tsx +24 -21
- package/src/display-conditions/ConditionRow.tsx +75 -32
- package/src/display-conditions/DisplayConditionModal.tsx +18 -59
- package/src/e-sign-offset/ESignDateSignedOffsetModal.tsx +6 -6
- package/src/editor-core-source.ts +2 -2
- package/src/editor.tsx +15 -0
- package/src/index.ts +10 -0
- package/src/shared/const.ts +59 -0
- package/src/store.ts +67 -5
- package/src/unlayer-interface.tsx +15 -4
- package/src/unlayer.tsx +5 -5
|
@@ -4,106 +4,37 @@ import PlusIcon from '@servicetitan/anvil2/assets/icons/material/round/add.svg';
|
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
5
|
import { ConditionRow } from './ConditionRow';
|
|
6
6
|
import { defaultCondition } from './constants';
|
|
7
|
-
export function ConditionGroup({ dataPointOptions, formFieldOptions, forms, group, onFormSelect, onUpdate }) {
|
|
8
|
-
const addCondition = useCallback(()=>{
|
|
7
|
+
export function ConditionGroup({ dataPointOptions, formFieldOptions, forms, group, onFormSelect, onUpdate, }) {
|
|
8
|
+
const addCondition = useCallback(() => {
|
|
9
9
|
const newCondition = {
|
|
10
10
|
...defaultCondition(),
|
|
11
|
-
logicalOperator: 'and'
|
|
11
|
+
logicalOperator: 'and',
|
|
12
12
|
};
|
|
13
13
|
onUpdate({
|
|
14
14
|
...group,
|
|
15
|
-
conditions: [
|
|
16
|
-
...group.conditions,
|
|
17
|
-
newCondition
|
|
18
|
-
]
|
|
15
|
+
conditions: [...group.conditions, newCondition],
|
|
19
16
|
});
|
|
20
|
-
}, [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
]);
|
|
24
|
-
const updateCondition = useCallback((index, c)=>{
|
|
25
|
-
const next = [
|
|
26
|
-
...group.conditions
|
|
27
|
-
];
|
|
17
|
+
}, [group, onUpdate]);
|
|
18
|
+
const updateCondition = useCallback((index, c) => {
|
|
19
|
+
const next = [...group.conditions];
|
|
28
20
|
next[index] = c;
|
|
29
|
-
onUpdate({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, [
|
|
34
|
-
group,
|
|
35
|
-
onUpdate
|
|
36
|
-
]);
|
|
37
|
-
const removeCondition = useCallback((index)=>{
|
|
38
|
-
let next = group.conditions.filter((_, i)=>i !== index);
|
|
21
|
+
onUpdate({ ...group, conditions: next });
|
|
22
|
+
}, [group, onUpdate]);
|
|
23
|
+
const removeCondition = useCallback((index) => {
|
|
24
|
+
let next = group.conditions.filter((_, i) => i !== index);
|
|
39
25
|
if (index === 0 && next.length > 0) {
|
|
40
|
-
next = [
|
|
41
|
-
{
|
|
42
|
-
...next[0],
|
|
43
|
-
logicalOperator: undefined
|
|
44
|
-
},
|
|
45
|
-
...next.slice(1)
|
|
46
|
-
];
|
|
26
|
+
next = [{ ...next[0], logicalOperator: undefined }, ...next.slice(1)];
|
|
47
27
|
}
|
|
48
28
|
onUpdate({
|
|
49
29
|
...group,
|
|
50
|
-
conditions: next.length ? next : [
|
|
51
|
-
defaultCondition()
|
|
52
|
-
]
|
|
30
|
+
conditions: next.length ? next : [defaultCondition()],
|
|
53
31
|
});
|
|
54
|
-
}, [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
style: {
|
|
62
|
-
width: '100%'
|
|
63
|
-
},
|
|
64
|
-
children: /*#__PURE__*/ _jsxs(Flex, {
|
|
65
|
-
direction: "column",
|
|
66
|
-
gap: "3",
|
|
67
|
-
style: {
|
|
68
|
-
width: '100%'
|
|
69
|
-
},
|
|
70
|
-
children: [
|
|
71
|
-
group.conditions.map((c, i)=>/*#__PURE__*/ _jsx(Flex, {
|
|
72
|
-
direction: "column",
|
|
73
|
-
gap: "3",
|
|
74
|
-
style: {
|
|
75
|
-
padding: '8px 0'
|
|
76
|
-
},
|
|
77
|
-
children: /*#__PURE__*/ _jsx(ConditionRow, {
|
|
78
|
-
canRemove: true,
|
|
79
|
-
condition: c,
|
|
80
|
-
dataPointOptions: dataPointOptions,
|
|
81
|
-
forms: forms,
|
|
82
|
-
formFieldOptions: formFieldOptions,
|
|
83
|
-
onChange: (next)=>updateCondition(i, next),
|
|
84
|
-
onFormSelect: onFormSelect,
|
|
85
|
-
onRemove: ()=>removeCondition(i)
|
|
86
|
-
})
|
|
87
|
-
}, c.id)),
|
|
88
|
-
/*#__PURE__*/ _jsx(Flex, {
|
|
89
|
-
justifyContent: "center",
|
|
90
|
-
style: {
|
|
91
|
-
paddingTop: 8,
|
|
92
|
-
width: '100%'
|
|
93
|
-
},
|
|
94
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
95
|
-
appearance: "secondary",
|
|
96
|
-
icon: {
|
|
97
|
-
before: PlusIcon
|
|
98
|
-
},
|
|
99
|
-
size: "small",
|
|
100
|
-
onClick: addCondition,
|
|
101
|
-
children: "Add Condition"
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
]
|
|
105
|
-
})
|
|
106
|
-
});
|
|
32
|
+
}, [group, onUpdate]);
|
|
33
|
+
return (_jsx(Flex, { direction: "column", gap: "2", style: { padding: '0 8px', width: '100%' }, children: _jsxs(Flex, { direction: "column", gap: "3", style: { width: '100%' }, children: [group.conditions.map((c, i) => (_jsx(Flex, { direction: "column", gap: "3", style: {
|
|
34
|
+
padding: '8px',
|
|
35
|
+
background: '#f7f7f7',
|
|
36
|
+
boxShadow: '0px 0px 4px 1px #e0e0e0',
|
|
37
|
+
borderRadius: '8px',
|
|
38
|
+
}, children: _jsx(ConditionRow, { canRemove: true, condition: c, dataPointOptions: dataPointOptions, forms: forms, formFieldOptions: formFieldOptions, onChange: next => updateCondition(i, next), onFormSelect: onFormSelect, onRemove: () => removeCondition(i) }) }, c.id))), _jsx(Flex, { justifyContent: "center", style: { paddingTop: 8, width: '100%' }, children: _jsx(Button, { appearance: "secondary", icon: { before: PlusIcon }, onClick: addCondition, children: "Add Condition" }) })] }) }));
|
|
107
39
|
}
|
|
108
|
-
|
|
109
40
|
//# sourceMappingURL=ConditionGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/display-conditions/ConditionGroup.tsx"],"
|
|
1
|
+
{"version":3,"file":"ConditionGroup.js","sourceRoot":"","sources":["../../src/display-conditions/ConditionGroup.tsx"],"names":[],"mappings":";AAAA,O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CAAC;CACrE;AAED,wBAAgB,sBAAsB,CAAC,EACnC,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,aAAa,GAChB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,
|
|
1
|
+
{"version":3,"file":"ConditionGroupsSection.d.ts","sourceRoot":"","sources":["../../src/display-conditions/ConditionGroupsSection.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAEtC,MAAM,WAAW,2BAA2B;IACxC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iBAAiB,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;IAClD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACrE;AAED,wBAAgB,sBAAsB,CAAC,EACnC,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,aAAa,GAChB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,sCA0CvC"}
|
|
@@ -1,79 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Chip, Flex, SegmentedControl, Text } from '@servicetitan/anvil2';
|
|
3
3
|
import { ConditionGroup } from './ConditionGroup';
|
|
4
|
-
export function ConditionGroupsSection({ behaviorSection, dataPointOptions, formFieldOptions, forms, groups, matchType, onFormSelect, onMatchTypeChange, onUpdateGroup }) {
|
|
4
|
+
export function ConditionGroupsSection({ behaviorSection, dataPointOptions, formFieldOptions, forms, groups, matchType, onFormSelect, onMatchTypeChange, onUpdateGroup, }) {
|
|
5
5
|
const firstGroup = groups[0];
|
|
6
6
|
if (!firstGroup) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
|
-
return
|
|
10
|
-
direction: "column",
|
|
11
|
-
gap: "4",
|
|
12
|
-
children: [
|
|
13
|
-
/*#__PURE__*/ _jsxs(Flex, {
|
|
14
|
-
direction: "row",
|
|
15
|
-
alignItems: "center",
|
|
16
|
-
gap: "1",
|
|
17
|
-
style: {
|
|
18
|
-
flexWrap: 'wrap'
|
|
19
|
-
},
|
|
20
|
-
children: [
|
|
21
|
-
/*#__PURE__*/ _jsx(Text, {
|
|
22
|
-
size: "small",
|
|
23
|
-
variant: "body",
|
|
24
|
-
style: {
|
|
25
|
-
fontWeight: 'bold'
|
|
26
|
-
},
|
|
27
|
-
children: "When"
|
|
28
|
-
}),
|
|
29
|
-
/*#__PURE__*/ _jsxs(SegmentedControl, {
|
|
30
|
-
selected: matchType,
|
|
31
|
-
size: "small",
|
|
32
|
-
onChange: (value)=>onMatchTypeChange(value),
|
|
33
|
-
children: [
|
|
34
|
-
/*#__PURE__*/ _jsx(SegmentedControl.Segment, {
|
|
35
|
-
value: "all",
|
|
36
|
-
children: "All"
|
|
37
|
-
}),
|
|
38
|
-
/*#__PURE__*/ _jsx(SegmentedControl.Segment, {
|
|
39
|
-
value: "any",
|
|
40
|
-
children: "Any"
|
|
41
|
-
})
|
|
42
|
-
]
|
|
43
|
-
}),
|
|
44
|
-
/*#__PURE__*/ _jsx(Text, {
|
|
45
|
-
size: "small",
|
|
46
|
-
variant: "body",
|
|
47
|
-
style: {
|
|
48
|
-
fontWeight: 'bold'
|
|
49
|
-
},
|
|
50
|
-
children: "of the"
|
|
51
|
-
}),
|
|
52
|
-
/*#__PURE__*/ _jsx(Chip, {
|
|
53
|
-
label: "IF",
|
|
54
|
-
size: "small"
|
|
55
|
-
}),
|
|
56
|
-
/*#__PURE__*/ _jsx(Text, {
|
|
57
|
-
size: "small",
|
|
58
|
-
variant: "body",
|
|
59
|
-
style: {
|
|
60
|
-
fontWeight: 'bold'
|
|
61
|
-
},
|
|
62
|
-
children: "conditions are met"
|
|
63
|
-
})
|
|
64
|
-
]
|
|
65
|
-
}),
|
|
66
|
-
behaviorSection,
|
|
67
|
-
/*#__PURE__*/ _jsx(ConditionGroup, {
|
|
68
|
-
dataPointOptions: dataPointOptions,
|
|
69
|
-
formFieldOptions: formFieldOptions,
|
|
70
|
-
forms: forms,
|
|
71
|
-
group: firstGroup,
|
|
72
|
-
onFormSelect: onFormSelect,
|
|
73
|
-
onUpdate: (g)=>onUpdateGroup(0, g)
|
|
74
|
-
})
|
|
75
|
-
]
|
|
76
|
-
});
|
|
9
|
+
return (_jsxs(Flex, { direction: "column", gap: "6", children: [_jsxs(Flex, { direction: "column", gap: "3", children: [_jsxs(Flex, { direction: "row", alignItems: "center", gap: "2", style: { flexWrap: 'wrap' }, children: [_jsx(Text, { size: "medium", variant: "body", style: { fontWeight: 'bold' }, children: "When" }), _jsxs(SegmentedControl, { selected: matchType, size: "small", onChange: (value) => onMatchTypeChange(value), children: [_jsx(SegmentedControl.Segment, { value: "all", children: "All" }), _jsx(SegmentedControl.Segment, { value: "any", children: "Any" })] }), _jsx(Text, { size: "medium", variant: "body", style: { fontWeight: 'bold' }, children: "of the" }), _jsx(Chip, { label: "IF", size: "small" }), _jsx(Text, { size: "medium", variant: "body", style: { fontWeight: 'bold' }, children: "conditions are met" })] }), behaviorSection] }), _jsx(ConditionGroup, { dataPointOptions: dataPointOptions, formFieldOptions: formFieldOptions, forms: forms, group: firstGroup, onFormSelect: onFormSelect, onUpdate: g => onUpdateGroup(0, g) })] }));
|
|
77
10
|
}
|
|
78
|
-
|
|
79
11
|
//# sourceMappingURL=ConditionGroupsSection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/display-conditions/ConditionGroupsSection.tsx"],"
|
|
1
|
+
{"version":3,"file":"ConditionGroupsSection.js","sourceRoot":"","sources":["../../src/display-conditions/ConditionGroupsSection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG1E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAkBlD,MAAM,UAAU,sBAAsB,CAAC,EACnC,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACuB;IACpC,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,CAAC,UAAU,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAEH,MAAC,IAAI,IAAC,SAAS,EAAC,QAAQ,EAAC,GAAG,EAAC,GAAG,aAC5B,MAAC,IAAI,IAAC,SAAS,EAAC,QAAQ,EAAC,GAAG,EAAC,GAAG,aAC5B,MAAC,IAAI,IAAC,SAAS,EAAC,KAAK,EAAC,UAAU,EAAC,QAAQ,EAAC,GAAG,EAAC,GAAG,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,aACzE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,MAAM,EAAC,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EA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,CAAC;IACnB,SAAS,EAAE,eAAe,CAAC;IAC3B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,IAAI,CAAC;IACvC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"ConditionRow.d.ts","sourceRoot":"","sources":["../../src/display-conditions/ConditionRow.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAqB,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAoB,eAAe,EAA0C,MAAM,SAAS,CAAC;AACpG,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,eAAe,CAAC;IAC3B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,IAAI,CAAC;IACvC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB;AAmBD,wBAAgB,YAAY,CAAC,EACzB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,QAAQ,GACX,EAAE,QAAQ,CAAC,iBAAiB,CAAC,+BAwP7B"}
|
|
@@ -5,242 +5,118 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
5
5
|
import { parseFormFieldKey } from '../shared/forms';
|
|
6
6
|
import { LookupValueControl } from './LookupValueControl';
|
|
7
7
|
import { NUMBER_OPERATORS, STRING_OPERATORS, VALUE_LESS_OPERATORS } from './types';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
]);
|
|
27
|
-
const selectedSource = useMemo(()=>{
|
|
28
|
-
var _ref, _sourceOptions_find;
|
|
29
|
-
return (_ref = (_sourceOptions_find = sourceOptions.find((opt)=>opt.value === selectedSourceValue)) !== null && _sourceOptions_find !== void 0 ? _sourceOptions_find : sourceOptions[0]) !== null && _ref !== void 0 ? _ref : null;
|
|
30
|
-
}, [
|
|
31
|
-
selectedSourceValue,
|
|
32
|
-
sourceOptions
|
|
33
|
-
]);
|
|
34
|
-
useEffect(()=>{
|
|
8
|
+
const SOURCE_KIND_LABELS = {
|
|
9
|
+
form: 'Form',
|
|
10
|
+
schema: 'Merge tags',
|
|
11
|
+
};
|
|
12
|
+
export function ConditionRow({ canRemove, condition, dataPointOptions, formFieldOptions, forms, onChange, onFormSelect, onRemove, }) {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
const selectedFormFieldMeta = useMemo(() => parseFormFieldKey(condition.dataPointKey), [condition.dataPointKey]);
|
|
15
|
+
// As in BYOD: the source is "Merge tags" or "Form", and a form source gets its own form picker.
|
|
16
|
+
const [sourceKind, setSourceKind] = useState(selectedFormFieldMeta ? 'form' : 'schema');
|
|
17
|
+
const [selectedFormId, setSelectedFormId] = useState(selectedFormFieldMeta === null || selectedFormFieldMeta === void 0 ? void 0 : selectedFormFieldMeta.formId);
|
|
18
|
+
const sourceOptions = useMemo(() => {
|
|
19
|
+
const kinds = forms.length || selectedFormFieldMeta ? ['schema', 'form'] : ['schema'];
|
|
20
|
+
return kinds.map(value => ({ label: SOURCE_KIND_LABELS[value], value }));
|
|
21
|
+
}, [forms.length, selectedFormFieldMeta]);
|
|
22
|
+
const selectedSource = (_b = (_a = sourceOptions.find(opt => opt.value === sourceKind)) !== null && _a !== void 0 ? _a : sourceOptions[0]) !== null && _b !== void 0 ? _b : null;
|
|
23
|
+
const sortedForms = useMemo(() => [...forms].sort((a, b) => a.name.localeCompare(b.name)), [forms]);
|
|
24
|
+
const selectedForm = useMemo(() => { var _a; return (_a = sortedForms.find(form => form.id === selectedFormId)) !== null && _a !== void 0 ? _a : null; }, [selectedFormId, sortedForms]);
|
|
25
|
+
useEffect(() => {
|
|
35
26
|
if (selectedFormFieldMeta) {
|
|
36
|
-
|
|
27
|
+
setSourceKind('form');
|
|
28
|
+
setSelectedFormId(selectedFormFieldMeta.formId);
|
|
37
29
|
return;
|
|
38
30
|
}
|
|
39
31
|
if (!condition.dataPointKey) {
|
|
40
32
|
return;
|
|
41
33
|
}
|
|
42
|
-
const hasSchemaMatch = dataPointOptions.some(
|
|
34
|
+
const hasSchemaMatch = dataPointOptions.some(opt => opt.fullKey === condition.dataPointKey);
|
|
43
35
|
if (hasSchemaMatch) {
|
|
44
|
-
|
|
36
|
+
setSourceKind('schema');
|
|
45
37
|
}
|
|
46
|
-
}, [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
currentFormId
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
]);
|
|
57
|
-
const selectedDataPoint = useMemo(()=>{
|
|
58
|
-
|
|
59
|
-
return (_activeDataPointOptions_find = activeDataPointOptions.find((opt)=>opt.fullKey === condition.dataPointKey)) !== null && _activeDataPointOptions_find !== void 0 ? _activeDataPointOptions_find : null;
|
|
60
|
-
}, [
|
|
61
|
-
activeDataPointOptions,
|
|
62
|
-
condition.dataPointKey
|
|
63
|
-
]);
|
|
64
|
-
const fieldType = (_ref = selectedDataPoint === null || selectedDataPoint === void 0 ? void 0 : selectedDataPoint.fieldType) !== null && _ref !== void 0 ? _ref : 'string';
|
|
38
|
+
}, [condition.dataPointKey, dataPointOptions, selectedFormFieldMeta]);
|
|
39
|
+
const isFormSource = (selectedSource === null || selectedSource === void 0 ? void 0 : selectedSource.value) === 'form';
|
|
40
|
+
const currentFormId = isFormSource ? selectedFormId : undefined;
|
|
41
|
+
const activeDataPointOptions = useMemo(() => {
|
|
42
|
+
if (!isFormSource) {
|
|
43
|
+
return dataPointOptions;
|
|
44
|
+
}
|
|
45
|
+
return currentFormId
|
|
46
|
+
? formFieldOptions.filter(option => option.formId === currentFormId)
|
|
47
|
+
: [];
|
|
48
|
+
}, [currentFormId, dataPointOptions, formFieldOptions, isFormSource]);
|
|
49
|
+
const selectedDataPoint = useMemo(() => { var _a; return (_a = activeDataPointOptions.find(opt => opt.fullKey === condition.dataPointKey)) !== null && _a !== void 0 ? _a : null; }, [activeDataPointOptions, condition.dataPointKey]);
|
|
50
|
+
const fieldType = (_c = selectedDataPoint === null || selectedDataPoint === void 0 ? void 0 : selectedDataPoint.fieldType) !== null && _c !== void 0 ? _c : 'string';
|
|
65
51
|
const isValueLess = VALUE_LESS_OPERATORS.includes(condition.operator);
|
|
66
|
-
const operatorItems = useMemo(()=>fieldType === 'number'
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
]);
|
|
73
|
-
const selectedOperator = useMemo(()=>{
|
|
74
|
-
var _operatorItems_find;
|
|
75
|
-
return (_operatorItems_find = operatorItems.find((op)=>op.value === condition.operator)) !== null && _operatorItems_find !== void 0 ? _operatorItems_find : null;
|
|
76
|
-
}, [
|
|
77
|
-
operatorItems,
|
|
78
|
-
condition.operator
|
|
79
|
-
]);
|
|
80
|
-
const handleDataPointChange = (item)=>{
|
|
81
|
-
var _ref;
|
|
52
|
+
const operatorItems = useMemo(() => fieldType === 'number'
|
|
53
|
+
? [...NUMBER_OPERATORS]
|
|
54
|
+
: [...STRING_OPERATORS], [fieldType]);
|
|
55
|
+
const selectedOperator = useMemo(() => { var _a; return (_a = operatorItems.find(op => op.value === condition.operator)) !== null && _a !== void 0 ? _a : null; }, [operatorItems, condition.operator]);
|
|
56
|
+
const handleDataPointChange = (item) => {
|
|
57
|
+
var _a;
|
|
82
58
|
const nextIsNumber = (item === null || item === void 0 ? void 0 : item.fieldType) === 'number';
|
|
83
59
|
const nextOperatorItems = nextIsNumber ? NUMBER_OPERATORS : STRING_OPERATORS;
|
|
84
|
-
const operatorReset = !nextOperatorItems.some(
|
|
60
|
+
const operatorReset = !nextOperatorItems.some(op => op.value === condition.operator);
|
|
85
61
|
onChange({
|
|
86
62
|
...condition,
|
|
87
|
-
dataPointKey: (
|
|
88
|
-
operator: operatorReset
|
|
63
|
+
dataPointKey: (_a = item === null || item === void 0 ? void 0 : item.fullKey) !== null && _a !== void 0 ? _a : '',
|
|
64
|
+
operator: operatorReset
|
|
65
|
+
? nextIsNumber
|
|
66
|
+
? 'num_eq'
|
|
67
|
+
: 'is_equal_to'
|
|
68
|
+
: condition.operator,
|
|
89
69
|
});
|
|
90
70
|
};
|
|
91
|
-
const handleSourceChange = (item)=>{
|
|
71
|
+
const handleSourceChange = (item) => {
|
|
92
72
|
if (!item) {
|
|
93
73
|
return;
|
|
94
74
|
}
|
|
95
|
-
|
|
75
|
+
setSourceKind(item.value);
|
|
76
|
+
setSelectedFormId(undefined);
|
|
96
77
|
// As in BYOD, a new source starts the condition over instead of picking a data point for it.
|
|
97
|
-
onChange({
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
if (item.formId) {
|
|
104
|
-
onFormSelect(item.formId);
|
|
78
|
+
onChange({ ...condition, dataPointKey: '', operator: 'is_equal_to', value: '' });
|
|
79
|
+
};
|
|
80
|
+
const handleFormChange = (formId) => {
|
|
81
|
+
if (formId === undefined) {
|
|
82
|
+
return;
|
|
105
83
|
}
|
|
84
|
+
setSelectedFormId(formId);
|
|
85
|
+
// Switching forms keeps the "Form" source and its picker, and starts the condition over.
|
|
86
|
+
onChange({ ...condition, dataPointKey: '', operator: 'is_equal_to', value: '' });
|
|
87
|
+
onFormSelect(formId);
|
|
106
88
|
};
|
|
107
89
|
// Same controls and layout as BYOD's condition row (`dte-pdf-editor`'s `ConditionRow`).
|
|
108
|
-
const sourceSelectOptions = sourceOptions.map(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
options: sourceSelectOptions,
|
|
135
|
-
value: selectedSource ? {
|
|
136
|
-
id: selectedSource.value,
|
|
137
|
-
label: selectedSource.label
|
|
138
|
-
} : null,
|
|
139
|
-
onSelectedOptionChange: (option)=>{
|
|
140
|
-
var _sourceOptions_find;
|
|
141
|
-
return handleSourceChange((_sourceOptions_find = sourceOptions.find((o)=>o.value === (option === null || option === void 0 ? void 0 : option.id))) !== null && _sourceOptions_find !== void 0 ? _sourceOptions_find : null);
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
}),
|
|
145
|
-
/*#__PURE__*/ _jsxs(Flex, {
|
|
146
|
-
direction: "row",
|
|
147
|
-
alignItems: "flex-end",
|
|
148
|
-
gap: "2",
|
|
149
|
-
flex: 1,
|
|
150
|
-
style: {
|
|
151
|
-
flexWrap: 'wrap'
|
|
152
|
-
},
|
|
153
|
-
children: [
|
|
154
|
-
/*#__PURE__*/ _jsx(Flex, {
|
|
155
|
-
alignItems: "flex-end",
|
|
156
|
-
style: {
|
|
157
|
-
padding: '8px 12px'
|
|
158
|
-
},
|
|
159
|
-
children: /*#__PURE__*/ _jsx(Chip, {
|
|
160
|
-
label: "IF",
|
|
161
|
-
size: "medium"
|
|
162
|
-
})
|
|
163
|
-
}),
|
|
164
|
-
/*#__PURE__*/ _jsx(Flex, {
|
|
165
|
-
flex: 1,
|
|
166
|
-
style: {
|
|
167
|
-
minWidth: 160
|
|
168
|
-
},
|
|
169
|
-
children: /*#__PURE__*/ _jsx(SelectFieldSync, {
|
|
170
|
-
flex: 1,
|
|
171
|
-
disableSearch: true,
|
|
172
|
-
disableClearButton: true,
|
|
173
|
-
label: "Data point",
|
|
174
|
-
placeholder: currentFormId ? 'Select form field...' : 'Select data point...',
|
|
175
|
-
options: dataPointSelectOptions,
|
|
176
|
-
value: selectedDataPoint ? {
|
|
177
|
-
id: selectedDataPoint.fullKey,
|
|
178
|
-
label: selectedDataPoint.title
|
|
179
|
-
} : null,
|
|
180
|
-
onSelectedOptionChange: (option)=>{
|
|
181
|
-
var _activeDataPointOptions_find;
|
|
182
|
-
return handleDataPointChange((_activeDataPointOptions_find = activeDataPointOptions.find((o)=>o.fullKey === (option === null || option === void 0 ? void 0 : option.id))) !== null && _activeDataPointOptions_find !== void 0 ? _activeDataPointOptions_find : null);
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
}),
|
|
186
|
-
/*#__PURE__*/ _jsx(Flex, {
|
|
187
|
-
flex: 1,
|
|
188
|
-
style: {
|
|
189
|
-
minWidth: 160
|
|
190
|
-
},
|
|
191
|
-
children: /*#__PURE__*/ _jsx(SelectFieldSync, {
|
|
192
|
-
flex: 1,
|
|
193
|
-
disableSearch: true,
|
|
194
|
-
disableClearButton: true,
|
|
195
|
-
label: "Condition",
|
|
196
|
-
placeholder: "Select...",
|
|
197
|
-
options: operatorSelectOptions,
|
|
198
|
-
value: selectedOperator ? {
|
|
199
|
-
id: selectedOperator.value,
|
|
200
|
-
label: selectedOperator.label
|
|
201
|
-
} : null,
|
|
202
|
-
onSelectedOptionChange: (option)=>{
|
|
203
|
-
var _ref;
|
|
90
|
+
const sourceSelectOptions = sourceOptions.map(option => ({
|
|
91
|
+
id: option.value,
|
|
92
|
+
label: option.label,
|
|
93
|
+
}));
|
|
94
|
+
const formSelectOptions = sortedForms.map(form => ({ id: form.id, label: form.name }));
|
|
95
|
+
const dataPointSelectOptions = activeDataPointOptions.map(option => ({
|
|
96
|
+
id: option.fullKey,
|
|
97
|
+
label: option.title,
|
|
98
|
+
}));
|
|
99
|
+
const operatorSelectOptions = operatorItems.map(option => ({
|
|
100
|
+
id: option.value,
|
|
101
|
+
label: option.label,
|
|
102
|
+
}));
|
|
103
|
+
return (_jsxs(Flex, { direction: "column", gap: "4", flex: 1, children: [_jsxs(Flex, { flex: 1, gap: "2", children: [_jsx(SelectFieldSync, { flex: 1, disableSearch: true, disableClearButton: true, label: "Source", placeholder: "Select source...", options: sourceSelectOptions, value: selectedSource
|
|
104
|
+
? { id: selectedSource.value, label: selectedSource.label }
|
|
105
|
+
: null, onSelectedOptionChange: (option) => { var _a; return handleSourceChange((_a = sourceOptions.find(o => o.value === (option === null || option === void 0 ? void 0 : option.id))) !== null && _a !== void 0 ? _a : null); } }), isFormSource && (_jsx(SelectFieldSync, { flex: 1, disableSearch: true, disableClearButton: true, label: "Select Form", placeholder: "Select form...", options: formSelectOptions, value: selectedForm ? { id: selectedForm.id, label: selectedForm.name } : null, onSelectedOptionChange: (option) => handleFormChange(option === null || option === void 0 ? void 0 : option.id) }))] }), _jsxs(Flex, { direction: "row", alignItems: "flex-end", gap: "2", flex: 1, style: { flexWrap: 'wrap' }, children: [_jsx(Flex, { alignItems: "flex-end", style: { padding: '8px 12px' }, children: _jsx(Chip, { label: "IF", size: "medium" }) }), _jsx(Flex, { flex: 1, style: { minWidth: 160 }, children: _jsx(SelectFieldSync, { flex: 1, disableSearch: true, disableClearButton: true, disabled: isFormSource && !currentFormId, label: "Data point", placeholder: isFormSource && !currentFormId
|
|
106
|
+
? 'Select a form first...'
|
|
107
|
+
: 'Select data point...', options: dataPointSelectOptions, value: selectedDataPoint
|
|
108
|
+
? { id: selectedDataPoint.fullKey, label: selectedDataPoint.title }
|
|
109
|
+
: null, onSelectedOptionChange: (option) => {
|
|
110
|
+
var _a;
|
|
111
|
+
return handleDataPointChange((_a = activeDataPointOptions.find(o => o.fullKey === (option === null || option === void 0 ? void 0 : option.id))) !== null && _a !== void 0 ? _a : null);
|
|
112
|
+
} }) }), _jsx(Flex, { flex: 1, style: { minWidth: 160 }, children: _jsx(SelectFieldSync, { flex: 1, disableSearch: true, disableClearButton: true, label: "Condition", placeholder: "Select...", options: operatorSelectOptions, value: selectedOperator
|
|
113
|
+
? { id: selectedOperator.value, label: selectedOperator.label }
|
|
114
|
+
: null, onSelectedOptionChange: (option) => {
|
|
115
|
+
var _a;
|
|
204
116
|
return onChange({
|
|
205
117
|
...condition,
|
|
206
|
-
operator: (
|
|
118
|
+
operator: ((_a = option === null || option === void 0 ? void 0 : option.id) !== null && _a !== void 0 ? _a : 'is_equal_to'),
|
|
207
119
|
});
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
}),
|
|
211
|
-
!isValueLess && /*#__PURE__*/ _jsx(Flex, {
|
|
212
|
-
flex: 1,
|
|
213
|
-
style: {
|
|
214
|
-
minWidth: 160
|
|
215
|
-
},
|
|
216
|
-
children: /*#__PURE__*/ _jsx(LookupValueControl, {
|
|
217
|
-
value: condition.value,
|
|
218
|
-
fieldType: fieldType,
|
|
219
|
-
lookupSource: selectedDataPoint === null || selectedDataPoint === void 0 ? void 0 : selectedDataPoint.lookupSource,
|
|
220
|
-
onChange: (value)=>onChange({
|
|
221
|
-
...condition,
|
|
222
|
-
value
|
|
223
|
-
})
|
|
224
|
-
})
|
|
225
|
-
}),
|
|
226
|
-
canRemove && /*#__PURE__*/ _jsx(Flex, {
|
|
227
|
-
alignItems: "flex-end",
|
|
228
|
-
style: {
|
|
229
|
-
padding: '6px 12px'
|
|
230
|
-
},
|
|
231
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
232
|
-
appearance: "secondary",
|
|
233
|
-
"aria-label": "Remove condition",
|
|
234
|
-
icon: {
|
|
235
|
-
before: TrashIcon
|
|
236
|
-
},
|
|
237
|
-
onClick: onRemove
|
|
238
|
-
})
|
|
239
|
-
})
|
|
240
|
-
]
|
|
241
|
-
})
|
|
242
|
-
]
|
|
243
|
-
});
|
|
120
|
+
} }) }), !isValueLess && (_jsx(Flex, { flex: 1, style: { minWidth: 160 }, children: _jsx(LookupValueControl, { value: condition.value, fieldType: fieldType, lookupSource: selectedDataPoint === null || selectedDataPoint === void 0 ? void 0 : selectedDataPoint.lookupSource, onChange: value => onChange({ ...condition, value }) }) })), canRemove && (_jsx(Flex, { alignItems: "flex-end", style: { padding: '6px 12px' }, children: _jsx(Button, { appearance: "secondary", "aria-label": "Remove condition", icon: { before: TrashIcon }, onClick: onRemove }) }))] })] }));
|
|
244
121
|
}
|
|
245
|
-
|
|
246
122
|
//# sourceMappingURL=ConditionRow.js.map
|