@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.
Files changed (158) hide show
  1. package/dist/api-core.js +22 -29
  2. package/dist/api-core.js.map +1 -1
  3. package/dist/api-custom-tools.js +23 -29
  4. package/dist/api-custom-tools.js.map +1 -1
  5. package/dist/business-calendar/BusinessCalendarDrawer.d.ts +19 -0
  6. package/dist/business-calendar/BusinessCalendarDrawer.d.ts.map +1 -0
  7. package/dist/business-calendar/BusinessCalendarDrawer.js +41 -0
  8. package/dist/business-calendar/BusinessCalendarDrawer.js.map +1 -0
  9. package/dist/business-calendar/business-calendar-requests.d.ts +25 -0
  10. package/dist/business-calendar/business-calendar-requests.d.ts.map +1 -0
  11. package/dist/business-calendar/business-calendar-requests.js +46 -0
  12. package/dist/business-calendar/business-calendar-requests.js.map +1 -0
  13. package/dist/business-calendar/business-calendar-state.d.ts +22 -0
  14. package/dist/business-calendar/business-calendar-state.d.ts.map +1 -0
  15. package/dist/business-calendar/business-calendar-state.js +74 -0
  16. package/dist/business-calendar/business-calendar-state.js.map +1 -0
  17. package/dist/business-calendar/useBusinessCalendarRequests.d.ts +15 -0
  18. package/dist/business-calendar/useBusinessCalendarRequests.d.ts.map +1 -0
  19. package/dist/business-calendar/useBusinessCalendarRequests.js +30 -0
  20. package/dist/business-calendar/useBusinessCalendarRequests.js.map +1 -0
  21. package/dist/display-conditions/ConditionGroup.d.ts.map +1 -1
  22. package/dist/display-conditions/ConditionGroup.js +20 -89
  23. package/dist/display-conditions/ConditionGroup.js.map +1 -1
  24. package/dist/display-conditions/ConditionGroupsSection.d.ts.map +1 -1
  25. package/dist/display-conditions/ConditionGroupsSection.js +2 -70
  26. package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
  27. package/dist/display-conditions/ConditionRow.d.ts.map +1 -1
  28. package/dist/display-conditions/ConditionRow.js +88 -212
  29. package/dist/display-conditions/ConditionRow.js.map +1 -1
  30. package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -1
  31. package/dist/display-conditions/DisplayConditionModal.js +39 -194
  32. package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
  33. package/dist/display-conditions/LookupValueControl.js +42 -105
  34. package/dist/display-conditions/LookupValueControl.js.map +1 -1
  35. package/dist/display-conditions/SeparatorWithChip.js +1 -10
  36. package/dist/display-conditions/SeparatorWithChip.js.map +1 -1
  37. package/dist/display-conditions/constants.js +15 -20
  38. package/dist/display-conditions/constants.js.map +1 -1
  39. package/dist/display-conditions/displayConditionController.js +5 -8
  40. package/dist/display-conditions/displayConditionController.js.map +1 -1
  41. package/dist/display-conditions/lookupOptionsController.js +16 -16
  42. package/dist/display-conditions/lookupOptionsController.js.map +1 -1
  43. package/dist/display-conditions/nunjucks.js +98 -116
  44. package/dist/display-conditions/nunjucks.js.map +1 -1
  45. package/dist/display-conditions/schemaDataPoints.js +13 -11
  46. package/dist/display-conditions/schemaDataPoints.js.map +1 -1
  47. package/dist/display-conditions/types.js +23 -67
  48. package/dist/display-conditions/types.js.map +1 -1
  49. package/dist/display-conditions/useConditionForms.js +38 -56
  50. package/dist/display-conditions/useConditionForms.js.map +1 -1
  51. package/dist/display-conditions/useLookupOptions.js +24 -44
  52. package/dist/display-conditions/useLookupOptions.js.map +1 -1
  53. package/dist/e-sign-offset/ESignDateSignedOffsetModal.js +42 -155
  54. package/dist/e-sign-offset/ESignDateSignedOffsetModal.js.map +1 -1
  55. package/dist/e-sign-offset/ESignOffsetRuleRow.js +12 -73
  56. package/dist/e-sign-offset/ESignOffsetRuleRow.js.map +1 -1
  57. package/dist/e-sign-offset/eSignOffsetController.js +5 -8
  58. package/dist/e-sign-offset/eSignOffsetController.js.map +1 -1
  59. package/dist/editor-core-source.d.ts +2 -2
  60. package/dist/editor-core-source.d.ts.map +1 -1
  61. package/dist/editor-core-source.js +3 -3
  62. package/dist/editor-core-source.js.map +1 -1
  63. package/dist/editor-core.js +2 -2
  64. package/dist/editor-core.js.map +1 -1
  65. package/dist/editor.d.ts.map +1 -1
  66. package/dist/editor.js +56 -118
  67. package/dist/editor.js.map +1 -1
  68. package/dist/image-upload-error.js +3 -3
  69. package/dist/image-upload-error.js.map +1 -1
  70. package/dist/index.d.ts +1 -0
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +0 -1
  73. package/dist/index.js.map +1 -1
  74. package/dist/loadScript.js +7 -8
  75. package/dist/loadScript.js.map +1 -1
  76. package/dist/log.js +2 -3
  77. package/dist/log.js.map +1 -1
  78. package/dist/merge-tags.js +18 -17
  79. package/dist/merge-tags.js.map +1 -1
  80. package/dist/shared/configs.js +1 -2
  81. package/dist/shared/configs.js.map +1 -1
  82. package/dist/shared/const.d.ts +70 -0
  83. package/dist/shared/const.d.ts.map +1 -1
  84. package/dist/shared/const.js +13 -4
  85. package/dist/shared/const.js.map +1 -1
  86. package/dist/shared/date-calc.js +47 -38
  87. package/dist/shared/date-calc.js.map +1 -1
  88. package/dist/shared/e-sign-offset.js +46 -63
  89. package/dist/shared/e-sign-offset.js.map +1 -1
  90. package/dist/shared/edit-icon.js +0 -1
  91. package/dist/shared/edit-icon.js.map +1 -1
  92. package/dist/shared/fonts.js +16 -17
  93. package/dist/shared/fonts.js.map +1 -1
  94. package/dist/shared/forms.js +16 -38
  95. package/dist/shared/forms.js.map +1 -1
  96. package/dist/shared/instance-id.js +6 -9
  97. package/dist/shared/instance-id.js.map +1 -1
  98. package/dist/shared/nunjucks-helpers.js +2 -5
  99. package/dist/shared/nunjucks-helpers.js.map +1 -1
  100. package/dist/shared/schema.js +52 -96
  101. package/dist/shared/schema.js.map +1 -1
  102. package/dist/shared/tools.js +6 -13
  103. package/dist/shared/tools.js.map +1 -1
  104. package/dist/store.d.ts +15 -1
  105. package/dist/store.d.ts.map +1 -1
  106. package/dist/store.js +851 -548
  107. package/dist/store.js.map +1 -1
  108. package/dist/tools.js +133 -143
  109. package/dist/tools.js.map +1 -1
  110. package/dist/unlayer-interface.d.ts +15 -4
  111. package/dist/unlayer-interface.d.ts.map +1 -1
  112. package/dist/unlayer-interface.js +1 -2
  113. package/dist/unlayer-interface.js.map +1 -1
  114. package/dist/unlayer.js +86 -113
  115. package/dist/unlayer.js.map +1 -1
  116. package/dist/vendor/dte-shared/business-calendar-validation.utils.d.ts +25 -0
  117. package/dist/vendor/dte-shared/business-calendar-validation.utils.js +80 -0
  118. package/dist/vendor/dte-shared/components/business-calendar-section.d.ts +15 -0
  119. package/dist/vendor/dte-shared/components/business-calendar-section.js +14 -0
  120. package/dist/vendor/dte-shared/components/schedule-drawer.d.ts +18 -0
  121. package/dist/vendor/dte-shared/components/schedule-drawer.js +119 -0
  122. package/dist/vendor/dte-shared/components/schedule-picker.d.ts +8 -0
  123. package/dist/vendor/dte-shared/components/schedule-picker.js +88 -0
  124. package/dist/vendor/dte-shared/constants.d.ts +31 -0
  125. package/dist/vendor/dte-shared/constants.js +34 -0
  126. package/dist/vendor/dte-shared/field-schedule-editor-context.d.ts +31 -0
  127. package/dist/vendor/dte-shared/field-schedule-editor-context.js +110 -0
  128. package/dist/vendor/dte-shared/index.d.ts +8 -0
  129. package/dist/vendor/dte-shared/index.js +7 -0
  130. package/dist/vendor/dte-shared/schedule-bindings.utils.d.ts +22 -0
  131. package/dist/vendor/dte-shared/schedule-bindings.utils.js +31 -0
  132. package/dist/vendor/dte-shared/styles/schedule.css +19 -0
  133. package/dist/vendor/dte-shared/types.d.ts +129 -0
  134. package/dist/vendor/dte-shared/types.js +1 -0
  135. package/package.json +7 -1
  136. package/src/__tests__/business-calendar-drawer.test.tsx +183 -0
  137. package/src/__tests__/business-calendar-requests.test.ts +166 -0
  138. package/src/__tests__/business-calendar-state.test.tsx +142 -0
  139. package/src/__tests__/condition-row.test.tsx +51 -8
  140. package/src/__tests__/e-sign-offset-modal.test.tsx +13 -2
  141. package/src/__tests__/store.business-calendar.test.ts +185 -0
  142. package/src/__tests__/unlayer.e-sign-types.test.ts +30 -0
  143. package/src/business-calendar/BusinessCalendarDrawer.tsx +76 -0
  144. package/src/business-calendar/business-calendar-requests.ts +80 -0
  145. package/src/business-calendar/business-calendar-state.ts +113 -0
  146. package/src/business-calendar/useBusinessCalendarRequests.ts +49 -0
  147. package/src/display-conditions/ConditionGroup.tsx +13 -3
  148. package/src/display-conditions/ConditionGroupsSection.tsx +24 -21
  149. package/src/display-conditions/ConditionRow.tsx +75 -32
  150. package/src/display-conditions/DisplayConditionModal.tsx +18 -59
  151. package/src/e-sign-offset/ESignDateSignedOffsetModal.tsx +6 -6
  152. package/src/editor-core-source.ts +2 -2
  153. package/src/editor.tsx +15 -0
  154. package/src/index.ts +10 -0
  155. package/src/shared/const.ts +59 -0
  156. package/src/store.ts +67 -5
  157. package/src/unlayer-interface.tsx +15 -4
  158. 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
- group,
22
- onUpdate
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
- ...group,
31
- conditions: next
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
- group,
56
- onUpdate
57
- ]);
58
- return /*#__PURE__*/ _jsx(Flex, {
59
- direction: "column",
60
- gap: "2",
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"],"sourcesContent":["import { Button, Flex } from '@servicetitan/anvil2';\nimport PlusIcon from '@servicetitan/anvil2/assets/icons/material/round/add.svg';\nimport { useCallback } from 'react';\nimport { FormInfo } from '../shared/forms';\nimport { ConditionRow } from './ConditionRow';\nimport { defaultCondition } from './constants';\nimport { ConditionGroup as ConditionGroupType, FormFieldOption, SingleCondition } from './types';\nimport type { DataPointOption } from './types';\n\nexport interface ConditionGroupProps {\n dataPointOptions: DataPointOption[];\n formFieldOptions: FormFieldOption[];\n forms: FormInfo[];\n group: ConditionGroupType;\n onFormSelect: (formId: number) => void;\n onUpdate: (g: ConditionGroupType) => void;\n}\n\nexport function ConditionGroup({\n dataPointOptions,\n formFieldOptions,\n forms,\n group,\n onFormSelect,\n onUpdate,\n}: Readonly<ConditionGroupProps>) {\n const addCondition = useCallback(() => {\n const newCondition: SingleCondition = {\n ...defaultCondition(),\n logicalOperator: 'and',\n };\n onUpdate({\n ...group,\n conditions: [...group.conditions, newCondition],\n });\n }, [group, onUpdate]);\n\n const updateCondition = useCallback(\n (index: number, c: SingleCondition) => {\n const next = [...group.conditions];\n next[index] = c;\n onUpdate({ ...group, conditions: next });\n },\n [group, onUpdate],\n );\n\n const removeCondition = useCallback(\n (index: number) => {\n let next = group.conditions.filter((_, i) => i !== index);\n if (index === 0 && next.length > 0) {\n next = [{ ...next[0], logicalOperator: undefined }, ...next.slice(1)];\n }\n onUpdate({\n ...group,\n conditions: next.length ? next : [defaultCondition()],\n });\n },\n [group, onUpdate],\n );\n\n return (\n <Flex direction=\"column\" gap=\"2\" style={{ width: '100%' }}>\n <Flex direction=\"column\" gap=\"3\" style={{ width: '100%' }}>\n {group.conditions.map((c, i) => (\n <Flex key={c.id} direction=\"column\" gap=\"3\" style={{ padding: '8px 0' }}>\n <ConditionRow\n canRemove\n condition={c}\n dataPointOptions={dataPointOptions}\n forms={forms}\n formFieldOptions={formFieldOptions}\n onChange={next => updateCondition(i, next)}\n onFormSelect={onFormSelect}\n onRemove={() => removeCondition(i)}\n />\n </Flex>\n ))}\n <Flex justifyContent=\"center\" style={{ paddingTop: 8, width: '100%' }}>\n <Button\n appearance=\"secondary\"\n icon={{ before: PlusIcon }}\n size=\"small\"\n onClick={addCondition}\n >\n Add Condition\n </Button>\n </Flex>\n </Flex>\n </Flex>\n );\n}\n"],"names":["Button","Flex","PlusIcon","useCallback","ConditionRow","defaultCondition","ConditionGroup","dataPointOptions","formFieldOptions","forms","group","onFormSelect","onUpdate","addCondition","newCondition","logicalOperator","conditions","updateCondition","index","c","next","removeCondition","filter","_","i","length","undefined","slice","direction","gap","style","width","map","padding","canRemove","condition","onChange","onRemove","id","justifyContent","paddingTop","appearance","icon","before","size","onClick"],"mappings":";AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,uBAAuB;AACpD,OAAOC,cAAc,2DAA2D;AAChF,SAASC,WAAW,QAAQ,QAAQ;AAEpC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,gBAAgB,QAAQ,cAAc;AAa/C,OA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CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAE5B,KAAC,IAAI,IAED,SAAS,EAAC,QAAQ,EAClB,GAAG,EAAC,GAAG,EACP,KAAK,EAAE;wBACH,OAAO,EAAE,KAAK;wBACd,UAAU,EAAE,SAAS;wBACrB,SAAS,EAAE,yBAAyB;wBACpC,YAAY,EAAE,KAAK;qBACtB,YAED,KAAC,YAAY,IACT,SAAS,QACT,SAAS,EAAE,CAAC,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,EAC1C,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,GACpC,IAnBG,CAAC,CAAC,EAAE,CAoBN,CACV,CAAC,EACF,KAAC,IAAI,IAAC,cAAc,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YACjE,KAAC,MAAM,IACH,UAAU,EAAC,WAAW,EACtB,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAC1B,OAAO,EAAE,YAAY,8BAGhB,GACN,IACJ,GACJ,CACV,CAAC;AACN,CAAC"}
@@ -1 +1 @@
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,sCAuCvC"}
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 /*#__PURE__*/ _jsxs(Flex, {
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"],"sourcesContent":["import { Chip, Flex, SegmentedControl, Text } from '@servicetitan/anvil2';\nimport type { ReactNode } from 'react';\nimport { FormInfo } from '../shared/forms';\nimport { ConditionGroup } from './ConditionGroup';\nimport { ConditionGroup as ConditionGroupType, FormFieldOption } from './types';\nimport type { DataPointOption } from './types';\n\nexport type MatchType = 'all' | 'any';\n\nexport interface ConditionGroupsSectionProps {\n behaviorSection?: ReactNode;\n dataPointOptions: DataPointOption[];\n formFieldOptions: FormFieldOption[];\n forms: FormInfo[];\n groups: ConditionGroupType[];\n matchType: MatchType;\n onFormSelect: (formId: number) => void;\n onMatchTypeChange: (matchType: MatchType) => void;\n onUpdateGroup: (index: number, group: ConditionGroupType) => void;\n}\n\nexport function ConditionGroupsSection({\n behaviorSection,\n dataPointOptions,\n formFieldOptions,\n forms,\n groups,\n matchType,\n onFormSelect,\n onMatchTypeChange,\n onUpdateGroup,\n}: Readonly<ConditionGroupsSectionProps>) {\n const firstGroup = groups[0];\n if (!firstGroup) {\n return null;\n }\n\n return (\n <Flex direction=\"column\" gap=\"4\">\n <Flex direction=\"row\" alignItems=\"center\" gap=\"1\" style={{ flexWrap: 'wrap' }}>\n <Text size=\"small\" variant=\"body\" style={{ fontWeight: 'bold' }}>\n When\n </Text>\n <SegmentedControl\n selected={matchType}\n size=\"small\"\n onChange={(value: string) => onMatchTypeChange(value as MatchType)}\n >\n <SegmentedControl.Segment value=\"all\">All</SegmentedControl.Segment>\n <SegmentedControl.Segment value=\"any\">Any</SegmentedControl.Segment>\n </SegmentedControl>\n <Text size=\"small\" variant=\"body\" style={{ fontWeight: 'bold' }}>\n of the\n </Text>\n <Chip label=\"IF\" size=\"small\" />\n <Text size=\"small\" variant=\"body\" style={{ fontWeight: 'bold' }}>\n conditions are met\n </Text>\n </Flex>\n {behaviorSection}\n <ConditionGroup\n dataPointOptions={dataPointOptions}\n formFieldOptions={formFieldOptions}\n forms={forms}\n group={firstGroup}\n onFormSelect={onFormSelect}\n onUpdate={g => onUpdateGroup(0, g)}\n />\n </Flex>\n );\n}\n"],"names":["Chip","Flex","SegmentedControl","Text","ConditionGroup","ConditionGroupsSection","behaviorSection","dataPointOptions","formFieldOptions","forms","groups","matchType","onFormSelect","onMatchTypeChange","onUpdateGroup","firstGroup","direction","gap","alignItems","style","flexWrap","size","variant","fontWeight","selected","onChange","value","Segment","label","group","onUpdate","g"],"mappings":";AAAA,SAASA,IAAI,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,uBAAuB;AAG1E,SAASC,cAAc,QAAQ,mBAAmB;AAkBlD,OAAO,SAASC,uBAAuB,EACnCC,eAAe,EACfC,gBAAgB,EAChBC,gBAAgB,EAChBC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,iBAAiB,EACjBC,aAAa,EACuB;IACpC,MAAMC,aAAaL,MAAM,CAAC,EAAE;IAC5B,IAAI,CAACK,YAAY;QACb,OAAO;IACX;IAEA,qBACI,MAACd;QAAKe,WAAU;QAASC,KAAI;;0BACzB,MAAChB;gBAAKe,WAAU;gBAAME,YAAW;gBAASD,KAAI;gBAAIE,OAAO;oBAAEC,UAAU;gBAAO;;kCACxE,KAACjB;wBAAKkB,MAAK;wBAAQC,SAAQ;wBAAOH,OAAO;4BAAEI,YAAY;wBAAO;kCAAG;;kCAGjE,MAACrB;wBACGsB,UAAUb;wBACVU,MAAK;wBACLI,UAAU,CAACC,QAAkBb,kBAAkBa;;0CAE/C,KAACxB,iBAAiByB,OAAO;gCAACD,OAAM;0CAAM;;0CACtC,KAACxB,iBAAiByB,OAAO;gCAACD,OAAM;0CAAM;;;;kCAE1C,KAACvB;wBAAKkB,MAAK;wBAAQC,SAAQ;wBAAOH,OAAO;4BAAEI,YAAY;wBAAO;kCAAG;;kCAGjE,KAACvB;wBAAK4B,OAAM;wBAAKP,MAAK;;kCACtB,KAAClB;wBAAKkB,MAAK;wBAAQC,SAAQ;wBAAOH,OAAO;4BAAEI,YAAY;wBAAO;kCAAG;;;;YAIpEjB;0BACD,KAACF;gBACGG,kBAAkBA;gBAClBC,kBAAkBA;gBAClBC,OAAOA;gBACPoB,OAAOd;gBACPH,cAAcA;gBACdkB,UAAUC,CAAAA,IAAKjB,cAAc,GAAGiB;;;;AAIhD"}
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,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,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
- export function ConditionRow({ canRemove, condition, dataPointOptions, formFieldOptions, forms, onChange, onFormSelect, onRemove }) {
9
- var _ref;
10
- const selectedFormFieldMeta = useMemo(()=>parseFormFieldKey(condition.dataPointKey), [
11
- condition.dataPointKey
12
- ]);
13
- const [selectedSourceValue, setSelectedSourceValue] = useState(selectedFormFieldMeta ? `form:${selectedFormFieldMeta.formId}` : 'schema');
14
- const sourceOptions = useMemo(()=>[
15
- {
16
- label: 'Merge tags',
17
- value: 'schema'
18
- },
19
- ...forms.map((form)=>({
20
- formId: form.id,
21
- label: form.name,
22
- value: `form:${form.id}`
23
- }))
24
- ], [
25
- forms
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
- setSelectedSourceValue(`form:${selectedFormFieldMeta.formId}`);
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((opt)=>opt.fullKey === condition.dataPointKey);
34
+ const hasSchemaMatch = dataPointOptions.some(opt => opt.fullKey === condition.dataPointKey);
43
35
  if (hasSchemaMatch) {
44
- setSelectedSourceValue('schema');
36
+ setSourceKind('schema');
45
37
  }
46
- }, [
47
- condition.dataPointKey,
48
- dataPointOptions,
49
- selectedFormFieldMeta
50
- ]);
51
- const currentFormId = selectedSource === null || selectedSource === void 0 ? void 0 : selectedSource.formId;
52
- const activeDataPointOptions = useMemo(()=>currentFormId ? formFieldOptions.filter((option)=>option.formId === currentFormId) : dataPointOptions, [
53
- currentFormId,
54
- dataPointOptions,
55
- formFieldOptions
56
- ]);
57
- const selectedDataPoint = useMemo(()=>{
58
- var _activeDataPointOptions_find;
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
- ...NUMBER_OPERATORS
68
- ] : [
69
- ...STRING_OPERATORS
70
- ], [
71
- fieldType
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((op)=>op.value === condition.operator);
60
+ const operatorReset = !nextOperatorItems.some(op => op.value === condition.operator);
85
61
  onChange({
86
62
  ...condition,
87
- dataPointKey: (_ref = item === null || item === void 0 ? void 0 : item.fullKey) !== null && _ref !== void 0 ? _ref : '',
88
- operator: operatorReset ? nextIsNumber ? 'num_eq' : 'is_equal_to' : condition.operator
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
- setSelectedSourceValue(item.value);
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
- ...condition,
99
- dataPointKey: '',
100
- operator: 'is_equal_to',
101
- value: ''
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((option)=>({
109
- id: option.value,
110
- label: option.label
111
- }));
112
- const dataPointSelectOptions = activeDataPointOptions.map((option)=>({
113
- id: option.fullKey,
114
- label: option.title
115
- }));
116
- const operatorSelectOptions = operatorItems.map((option)=>({
117
- id: option.value,
118
- label: option.label
119
- }));
120
- return /*#__PURE__*/ _jsxs(Flex, {
121
- direction: "column",
122
- gap: "4",
123
- flex: 1,
124
- children: [
125
- /*#__PURE__*/ _jsx(Flex, {
126
- flex: 1,
127
- gap: "2",
128
- children: /*#__PURE__*/ _jsx(SelectFieldSync, {
129
- flex: 1,
130
- disableSearch: true,
131
- disableClearButton: true,
132
- label: "Source",
133
- placeholder: "Select source...",
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: (_ref = option === null || option === void 0 ? void 0 : option.id) !== null && _ref !== void 0 ? _ref : 'is_equal_to'
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