@integry/sdk 4.7.39 → 4.7.41

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 (267) hide show
  1. package/dist/esm/index.csm.js +1 -1
  2. package/dist/umd/index.umd.js +1 -1
  3. package/package.json +6 -1
  4. package/.eslintignore +0 -1
  5. package/.vscode/launch.json +0 -17
  6. package/CHANGELOG_INTERNAL.md +0 -134
  7. package/README_INTERNAL.md +0 -176
  8. package/THIRD_PARTY_LICENSES +0 -525
  9. package/generateTests.js +0 -80
  10. package/jest.config.cjs +0 -10
  11. package/src/components/AddTagButton/index.ts +0 -23
  12. package/src/components/BasicSelect/index.ts +0 -123
  13. package/src/components/BasicSelect/styles.module.scss +0 -44
  14. package/src/components/Button/index.ts +0 -97
  15. package/src/components/Button/styles.module.scss +0 -152
  16. package/src/components/CheckboxGroup/Checkbox.ts +0 -104
  17. package/src/components/CheckboxGroup/index.ts +0 -190
  18. package/src/components/CheckboxGroup/styles.module.scss +0 -63
  19. package/src/components/CollapsedMenu/index.ts +0 -104
  20. package/src/components/CollapsedMenu/styles.module.scss +0 -46
  21. package/src/components/ConfigureFieldWrapper/index.ts +0 -85
  22. package/src/components/ConfigureFieldWrapper/styles.module.scss +0 -57
  23. package/src/components/EditableText/index.ts +0 -121
  24. package/src/components/EditableText/styles.module.scss +0 -38
  25. package/src/components/EditableTextArea/index.ts +0 -143
  26. package/src/components/EditableTextArea/styles.module.scss +0 -91
  27. package/src/components/ErrorMessage/index.ts +0 -16
  28. package/src/components/ErrorMessage/styles.module.scss +0 -19
  29. package/src/components/ErrorPage/index.ts +0 -42
  30. package/src/components/ErrorPage/styles.module.scss +0 -26
  31. package/src/components/Footer/index.ts +0 -41
  32. package/src/components/Footer/styles.module.scss +0 -40
  33. package/src/components/HTMLContent/index.tsx +0 -205
  34. package/src/components/HTMLContent/styles.module.scss +0 -3
  35. package/src/components/InfoBox/index.ts +0 -48
  36. package/src/components/InfoBox/styles.module.scss +0 -21
  37. package/src/components/Input/BaseInput/index.ts +0 -170
  38. package/src/components/Input/BaseInput/styles.module.scss +0 -95
  39. package/src/components/Input/DateInput/index.ts +0 -103
  40. package/src/components/Input/DateInput/styles.module.scss +0 -50
  41. package/src/components/Input/Input/index.ts +0 -225
  42. package/src/components/Input/Input/styles.module.scss +0 -16
  43. package/src/components/Input/PasswordInput/index.ts +0 -164
  44. package/src/components/Input/PasswordInput/styles.module.scss +0 -37
  45. package/src/components/Input/index.ts +0 -7
  46. package/src/components/Label/index.ts +0 -61
  47. package/src/components/Label/styles.module.scss +0 -41
  48. package/src/components/LargeLoader/index.ts +0 -25
  49. package/src/components/LargeLoader/styles.module.scss +0 -16
  50. package/src/components/Listbox/ListBoxItem.ts +0 -57
  51. package/src/components/Listbox/index.ts +0 -488
  52. package/src/components/Listbox/styles.module.scss +0 -197
  53. package/src/components/Loader/index.ts +0 -25
  54. package/src/components/Loader/styles.module.scss +0 -16
  55. package/src/components/MediaGallery/MediaGalleryModal.ts +0 -82
  56. package/src/components/MediaGallery/MediaSlider.ts +0 -76
  57. package/src/components/MediaGallery/index.ts +0 -92
  58. package/src/components/MediaGallery/styles.module.scss +0 -156
  59. package/src/components/MediaUpload/index.ts +0 -233
  60. package/src/components/MediaUpload/styles.module.scss +0 -118
  61. package/src/components/Modal/index.ts +0 -87
  62. package/src/components/Modal/styles.module.scss +0 -441
  63. package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +0 -59
  64. package/src/components/MultipurposeField/Dropdown/index.tsx +0 -1202
  65. package/src/components/MultipurposeField/Dropdown/styles.module.scss +0 -215
  66. package/src/components/MultipurposeField/TagMenu/index.ts +0 -536
  67. package/src/components/MultipurposeField/TagMenu/styles.module.scss +0 -175
  68. package/src/components/MultipurposeField/TagOptions/index.tsx +0 -83
  69. package/src/components/MultipurposeField/TagOptions/styles.module.scss +0 -95
  70. package/src/components/MultipurposeField/index.tsx +0 -944
  71. package/src/components/MultipurposeField/styles.module.scss +0 -77
  72. package/src/components/NewModal/index.ts +0 -69
  73. package/src/components/NewModal/styles.module.scss +0 -70
  74. package/src/components/OverflowTooltip/index.tsx +0 -59
  75. package/src/components/PopUp/ConfirmationPopUp/index.ts +0 -58
  76. package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +0 -49
  77. package/src/components/PopUp/SuccessPopUp/index.ts +0 -62
  78. package/src/components/PopUp/SuccessPopUp/styles.module.scss +0 -38
  79. package/src/components/RadioGroup/Radio.ts +0 -128
  80. package/src/components/RadioGroup/index.ts +0 -169
  81. package/src/components/RadioGroup/styles.module.scss +0 -81
  82. package/src/components/Search/index.ts +0 -69
  83. package/src/components/Search/styles.module.scss +0 -149
  84. package/src/components/TabBar/Tab.ts +0 -33
  85. package/src/components/TabBar/index.ts +0 -64
  86. package/src/components/TabBar/styles.module.scss +0 -43
  87. package/src/components/Tag/index.ts +0 -29
  88. package/src/components/Tag/styles.module.scss +0 -57
  89. package/src/components/TagsMenu/index.ts +0 -1697
  90. package/src/components/TagsMenu/styles.module.scss +0 -350
  91. package/src/components/TestComponent/index.ts +0 -71
  92. package/src/components/TestComponent/styles.module.scss +0 -152
  93. package/src/components/TextArea/index.ts +0 -172
  94. package/src/components/TextArea/styles.module.scss +0 -72
  95. package/src/components/TextContent/index.tsx +0 -128
  96. package/src/components/TextContent/styles.module.scss +0 -6
  97. package/src/components/ThreeDotLoader/index.ts +0 -39
  98. package/src/components/ThreeDotLoader/styles.module.scss +0 -41
  99. package/src/components/TimeInput/index.ts +0 -129
  100. package/src/components/TimeInput/styles.module.scss +0 -16
  101. package/src/components/Toggle/index.ts +0 -34
  102. package/src/components/Toggle/styles.module.scss +0 -56
  103. package/src/components/Toggle-v2/index.ts +0 -40
  104. package/src/components/Toggle-v2/styles.module.scss +0 -86
  105. package/src/components/Tooltip/index.ts +0 -271
  106. package/src/components/Tooltip/styles.module.scss +0 -105
  107. package/src/components/form/FunctionField/index.ts +0 -816
  108. package/src/components/form/FunctionField/styles.module.scss +0 -478
  109. package/src/components/form/ObjectField/__snapshots__/index.ts.test.tsx.snap +0 -3
  110. package/src/components/form/ObjectField/index.ts +0 -593
  111. package/src/components/form/ObjectField/index.ts.test.tsx +0 -213
  112. package/src/components/form/ObjectField/styles.module.scss +0 -103
  113. package/src/components/form/index.ts +0 -4
  114. package/src/contexts/AppContext.ts +0 -12
  115. package/src/declaration.d.ts +0 -7
  116. package/src/extensions/HMAC.ts +0 -25
  117. package/src/extensions/IntegryAPIError.ts +0 -19
  118. package/src/features/common/AccountDropdown/index.ts +0 -291
  119. package/src/features/common/AccountDropdown/styles.module.scss +0 -19
  120. package/src/features/common/ActionForm/index.ts +0 -2602
  121. package/src/features/common/ActionForm/styles.module.scss +0 -35
  122. package/src/features/common/AppCard/index.ts +0 -207
  123. package/src/features/common/AppCard/styles.module.scss +0 -117
  124. package/src/features/common/AppCardCompact/index.ts +0 -189
  125. package/src/features/common/AppCardCompact/styles.module.scss +0 -141
  126. package/src/features/common/AuthSelector/index.ts +0 -537
  127. package/src/features/common/AuthSelector/styles.module.scss +0 -161
  128. package/src/features/common/AuthSelectorCompact/index.ts +0 -706
  129. package/src/features/common/AuthSelectorCompact/styles.module.scss +0 -219
  130. package/src/features/common/AuthSelectorDropdown/index.ts +0 -704
  131. package/src/features/common/AuthSelectorDropdown/styles.module.scss +0 -361
  132. package/src/features/common/AuthSelectorV2/index.ts +0 -336
  133. package/src/features/common/AuthSelectorV2/styles.module.scss +0 -235
  134. package/src/features/common/DynamicField/index.ts +0 -402
  135. package/src/features/common/DynamicField/styles.module.scss +0 -266
  136. package/src/features/common/DynamicTypedField/index.ts +0 -504
  137. package/src/features/common/DynamicTypedField/styles.module.scss +0 -135
  138. package/src/features/common/FunctionForm/index.ts +0 -1095
  139. package/src/features/common/FunctionForm/styles.module.scss +0 -225
  140. package/src/features/common/MappingUI/index.ts +0 -649
  141. package/src/features/common/MappingUI/styles.module.scss +0 -121
  142. package/src/features/common/MarketplaceAppCard/index.ts +0 -279
  143. package/src/features/common/MarketplaceAppCard/styles.module.scss +0 -231
  144. package/src/features/common/MarketplaceAppCardCompact/index.ts +0 -283
  145. package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +0 -255
  146. package/src/features/common/NewMappingUI/index.ts +0 -515
  147. package/src/features/common/NewMappingUI/styles.module.scss +0 -113
  148. package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +0 -67
  149. package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +0 -23
  150. package/src/features/common/RequestAppWidget/index.ts +0 -48
  151. package/src/features/common/RequestAppWidget/request-app-form.ts +0 -89
  152. package/src/features/common/RequestAppWidget/styles.module.scss +0 -43
  153. package/src/features/common/SectionField/index.ts +0 -272
  154. package/src/features/common/SectionField/styles.module.scss +0 -67
  155. package/src/features/common/Step/index.ts +0 -827
  156. package/src/features/common/Step/styles.module.scss +0 -12
  157. package/src/features/common/StepNavigation/CollapsedSteps.ts +0 -131
  158. package/src/features/common/StepNavigation/NavItem.ts +0 -111
  159. package/src/features/common/StepNavigation/index.ts +0 -261
  160. package/src/features/common/StepNavigation/styles.module.scss +0 -117
  161. package/src/features/common/Steps/index.ts +0 -1140
  162. package/src/features/common/Steps/styles.module.scss +0 -314
  163. package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +0 -404
  164. package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +0 -367
  165. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.test.tsx +0 -58
  166. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +0 -208
  167. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.test.tsx +0 -49
  168. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +0 -421
  169. package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +0 -577
  170. package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +0 -83
  171. package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +0 -233
  172. package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +0 -45
  173. package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +0 -1085
  174. package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +0 -465
  175. package/src/features/containers/AppFlowContainer/Authentication/index.ts +0 -610
  176. package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +0 -468
  177. package/src/features/containers/AppFlowContainer/index.ts +0 -114
  178. package/src/features/containers/AppPageContainer/AppPage/index.tsx +0 -262
  179. package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +0 -120
  180. package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +0 -165
  181. package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +0 -81
  182. package/src/features/containers/AppPageContainer/index.tsx +0 -93
  183. package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
  184. package/src/features/containers/AppsForFlows/index.ts +0 -161
  185. package/src/features/containers/AppsForFlows/styles.module.scss +0 -280
  186. package/src/features/containers/AppsForFlowsCompact/index.ts +0 -161
  187. package/src/features/containers/AppsForFlowsCompact/styles.module.scss +0 -279
  188. package/src/features/containers/AuthSetupContainer/AppSelection.ts +0 -73
  189. package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +0 -67
  190. package/src/features/containers/AuthSetupContainer/Footer.ts +0 -32
  191. package/src/features/containers/AuthSetupContainer/Header.ts +0 -39
  192. package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +0 -27
  193. package/src/features/containers/AuthSetupContainer/index.ts +0 -349
  194. package/src/features/containers/AuthSetupContainer/styles.module.scss +0 -229
  195. package/src/features/containers/FlowSetupContainer/index.ts +0 -391
  196. package/src/features/containers/FlowSetupContainer/styles.module.scss +0 -18
  197. package/src/features/containers/MarkeplaceApps/index.ts +0 -583
  198. package/src/features/containers/MarkeplaceApps/styles.module.scss +0 -558
  199. package/src/features/containers/MarketplaceAppsCompact/index.ts +0 -585
  200. package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +0 -563
  201. package/src/features/containers/MarketplaceAppsContainer/index.ts +0 -91
  202. package/src/features/containers/MarketplaceContainer/AppCard/index.ts +0 -91
  203. package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +0 -66
  204. package/src/features/containers/MarketplaceContainer/AppListing/index.ts +0 -34
  205. package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +0 -10
  206. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +0 -132
  207. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +0 -117
  208. package/src/features/containers/MarketplaceContainer/index.ts +0 -242
  209. package/src/features/containers/MarketplaceContainer/styles.module.scss +0 -84
  210. package/src/features/containers/SDKContainer/index.ts +0 -817
  211. package/src/features/containers/SDKContainer/styles.module.scss +0 -266
  212. package/src/features/containers/SDKDebugContainer/index.ts +0 -137
  213. package/src/features/containers/SDKDebugContainer/styles.module.scss +0 -37
  214. package/src/features/containers/SDKFailedContainer/index.ts +0 -117
  215. package/src/features/containers/SDKFailedContainer/styles.module.scss +0 -57
  216. package/src/features/integrations/IntegrationRow/Icons.ts +0 -77
  217. package/src/features/integrations/IntegrationRow/index.ts +0 -129
  218. package/src/features/integrations/IntegrationRow/styles.module.scss +0 -62
  219. package/src/features/integrations/IntegrationsHeader/index.ts +0 -34
  220. package/src/features/integrations/IntegrationsHeader/styles.module.scss +0 -47
  221. package/src/features/integrations/IntegrationsList/index.ts +0 -252
  222. package/src/features/integrations/IntegrationsList/styles.module.scss +0 -67
  223. package/src/features/templates/Template/index.ts +0 -295
  224. package/src/features/templates/Template/styles.module.scss +0 -226
  225. package/src/features/templates/TemplatesView/index.ts +0 -368
  226. package/src/features/templates/TemplatesView/styles.module.scss +0 -71
  227. package/src/features/templates/TemplatesViewCompact/index.ts +0 -364
  228. package/src/features/templates/TemplatesViewCompact/styles.module.scss +0 -141
  229. package/src/hooks/useAutosizeTextArea.ts +0 -22
  230. package/src/hooks/useCustomRef.ts +0 -13
  231. package/src/hooks/useDebounce.ts +0 -17
  232. package/src/hooks/useElementResize.ts +0 -40
  233. package/src/hooks/useEventListener.ts +0 -42
  234. package/src/hooks/useHover.ts +0 -40
  235. package/src/hooks/useOnClickOutside.ts +0 -32
  236. package/src/index.ts +0 -2244
  237. package/src/index.umd.ts +0 -13
  238. package/src/interfaces/index.ts +0 -938
  239. package/src/modules/api/index.ts +0 -1325
  240. package/src/modules/api/responseHandler.ts +0 -38
  241. package/src/modules/event-emitter/index.ts +0 -72
  242. package/src/modules/event-emitter/runners/abstract.ts +0 -21
  243. package/src/modules/event-emitter/runners/default.ts +0 -11
  244. package/src/modules/event-emitter/runners/ntimes.ts +0 -28
  245. package/src/modules/event-emitter/types.ts +0 -34
  246. package/src/store/actionFunctions.ts +0 -1578
  247. package/src/store/index.ts +0 -17
  248. package/src/store/initialState.ts +0 -58
  249. package/src/types/index.ts +0 -320
  250. package/src/types/preact-compat.d.ts +0 -4
  251. package/src/types/store.ts +0 -366
  252. package/src/types/utils.ts +0 -19
  253. package/src/utils/ActivityOutputUtils.ts +0 -176
  254. package/src/utils/common.ts +0 -20
  255. package/src/utils/copyToClipboard.ts +0 -24
  256. package/src/utils/datetime.ts +0 -101
  257. package/src/utils/getUrlParam.ts +0 -11
  258. package/src/utils/isAuthMessage.ts +0 -16
  259. package/src/utils/isBrowser.ts +0 -1
  260. package/src/utils/jsonEncodeDecode.ts +0 -15
  261. package/src/utils/objectUtils.ts +0 -117
  262. package/src/utils/popup.ts +0 -30
  263. package/src/utils/searchJson.ts +0 -51
  264. package/src/utils/stepUtils.ts +0 -45
  265. package/src/utils/truncate.ts +0 -6
  266. package/test/setup.ts +0 -1
  267. package/vitest.config.ts +0 -16
@@ -1,593 +0,0 @@
1
- import { html } from 'htm/preact';
2
- import { useState, useEffect } from 'preact/hooks';
3
- import { Input } from '@/components/Input';
4
- import { TextArea } from '@/components/TextArea';
5
- import { CheckboxGroup } from '@/components/CheckboxGroup';
6
- import ConfigureFieldWrapper from '@/components/ConfigureFieldWrapper';
7
- import { ListBox } from '@/components/MultipurposeField/Dropdown';
8
- import { MultipurposeField } from '@/components/MultipurposeField';
9
- import styles from './styles.module.scss';
10
-
11
- interface ObjectFieldProps {
12
- field: any;
13
- functionArguments: any;
14
- connectedAccount: string;
15
- appName: string;
16
- onChange: (
17
- fieldId: string,
18
- value: any,
19
- type: string,
20
- required: boolean,
21
- parentFieldId?: string,
22
- index?: number,
23
- ) => void;
24
- onChangeInFlow?: (val: any) => void;
25
- apiHandler: any;
26
- isArray?: boolean; // New prop to check if the input is an array
27
- activityOutputData: any;
28
- activityOutputDataRaw: any;
29
- objectValue?: any;
30
- isDisabled?: boolean;
31
- tagsTree?: any; // Optional prop for tags tree
32
- showMenuOnLeft?: boolean; // Optional prop to show menu on the left
33
- }
34
-
35
- type Option = {
36
- id: any;
37
- value: string;
38
- };
39
- interface FieldDetails {
40
- meta: {
41
- title: string;
42
- description_for_users: string;
43
- is_required: boolean;
44
- machine_name?: string;
45
- ui: {
46
- placeholder: string;
47
- regex?: string;
48
- regex_error_message?: string;
49
- ui_field: {
50
- type?: string;
51
- options?: Option[];
52
- data_source?: any; // If needed, define this more specifically
53
- endpointURL?: string; // Add endpointURL here
54
- option_key_path?: string;
55
- value_key_path?: string;
56
- };
57
- };
58
- };
59
- properties?: any; // If there are nested fields for objects
60
- type: string;
61
- }
62
-
63
- // Define the structure of each object in the array
64
- type FieldObject = {
65
- [key: string]: any; // Allow any string key with any value
66
- };
67
-
68
- const transformTemplateFieldsToProperties = (templateFields: any[]) => {
69
- const properties: { [key: string]: FieldDetails } = {};
70
-
71
- templateFields.forEach((tf) => {
72
- properties[tf.id || tf.machine_name] = {
73
- meta: {
74
- title: tf.title,
75
- description_for_users: tf.description,
76
- is_required: tf.is_required,
77
- machine_name:
78
- tf?.activity_field?.machine_name || tf?.machine_name || '',
79
- ui: {
80
- placeholder: tf.placeholder,
81
- regex: tf.regex || '',
82
- regex_error_message: tf.regex_msg || 'Invalid input.',
83
- ui_field: tf?.ui_field || {
84
- type: tf.type || 'TEXTFIELD',
85
- options: [], // Populate if needed
86
- data_source: null, // Adjust if needed
87
- endpointURL: '', // Adjust if needed
88
- },
89
- },
90
- },
91
- properties: tf.template_fields?.length
92
- ? transformTemplateFieldsToProperties(tf.template_fields)
93
- : undefined,
94
- type: tf.data_type || 'string',
95
- };
96
- });
97
-
98
- return properties;
99
- };
100
-
101
- const ObjectField = (props: ObjectFieldProps) => {
102
- const {
103
- field,
104
- functionArguments,
105
- connectedAccount,
106
- appName,
107
- onChange,
108
- onChangeInFlow,
109
- apiHandler,
110
- isArray = false, // Default to false
111
- activityOutputData,
112
- activityOutputDataRaw,
113
- objectValue,
114
- isDisabled = false,
115
- tagsTree = null,
116
- showMenuOnLeft = false, // Default to false
117
- } = props;
118
-
119
- // Calculate initial state based on field properties
120
- const calculateInitialObjectHasFields = (f: any) => {
121
- // Special case for the Blocks field or similar fields
122
- if (
123
- field.type === 'TEXTAREA' &&
124
- (field.data_type === 'OBJECT[]' || field.data_type === 'OBJECT') &&
125
- (!field.template_fields || field.template_fields.length === 0)
126
- ) {
127
- return false;
128
- }
129
-
130
- // For other cases, use the original logic
131
- if (Array.isArray(field.template_fields)) {
132
- if (field.template_fields.length > 0) {
133
- return true;
134
- }
135
- if (field.type === 'TEXTAREA' || field.type === 'DYNAMIC') {
136
- return false;
137
- }
138
- } else if (field.properties && Object.keys(field.properties).length === 0) {
139
- return false;
140
- }
141
-
142
- return true;
143
- };
144
-
145
- const calculateInitialShowAddMoreOption = (f: any) => {
146
- // Special case for the Blocks field or similar fields
147
- if (
148
- field.type === 'TEXTAREA' &&
149
- (field.data_type === 'OBJECT[]' || field.data_type === 'OBJECT') &&
150
- (!field.template_fields || field.template_fields.length === 0)
151
- ) {
152
- return false;
153
- }
154
-
155
- // For other cases, use the original logic
156
- if (Array.isArray(field.template_fields)) {
157
- if (field.template_fields.length > 0) {
158
- return true;
159
- }
160
- if (field.type === 'TEXTAREA' || field.type === 'DYNAMIC') {
161
- return false;
162
- }
163
- } else if (field.properties && Object.keys(field.properties).length === 0) {
164
- return false;
165
- }
166
-
167
- return true;
168
- };
169
-
170
- const [objectArray, setObjectArray] = useState<FieldObject[]>(
171
- Array.isArray(objectValue) ? objectValue : [{}],
172
- ); // Start with one empty object in the array
173
- const [showAddMoreOption, setShowAddMoreOption] = useState(() =>
174
- calculateInitialShowAddMoreOption(field),
175
- );
176
- const [objectHasFields, setObjectHasFields] = useState(() =>
177
- calculateInitialObjectHasFields(field),
178
- );
179
-
180
- let templateFields = [];
181
-
182
- if (Array.isArray(field.template_fields)) {
183
- if (field.template_fields.length > 0) {
184
- templateFields = field.template_fields;
185
- } else if (field.type === 'TEXTAREA' || field.type === 'DYNAMIC') {
186
- if (field.data_type === 'OBJECT[]' || field.data_type === 'OBJECT') {
187
- field.type = 'TEXTAREA';
188
- setShowAddMoreOption(false);
189
- setObjectHasFields(false);
190
- }
191
-
192
- templateFields = [field];
193
- }
194
- } else if (field.properties && Object.keys(field.properties).length === 0) {
195
- field.type = 'TEXTAREA';
196
- field.template_fields = [];
197
- field.properties = null;
198
- templateFields = [field];
199
- setShowAddMoreOption(false);
200
- setObjectHasFields(false);
201
- }
202
- const normalizedField = {
203
- ...field,
204
- properties:
205
- field.properties ||
206
- (field.template_fields
207
- ? transformTemplateFieldsToProperties(templateFields)
208
- : {}),
209
- };
210
-
211
- const isFlow = !field.properties && !!field.template_fields;
212
-
213
- if (isFlow) {
214
- setObjectHasFields(
215
- !!Object.keys(normalizedField?.template_fields || []).length,
216
- );
217
- setShowAddMoreOption(
218
- !!Object.keys(normalizedField?.template_fields || []).length,
219
- );
220
- } else {
221
- setObjectHasFields(!!Object.keys(normalizedField?.properties || []).length);
222
- setShowAddMoreOption(
223
- !!Object.keys(normalizedField?.properties || []).length,
224
- );
225
- }
226
-
227
- useEffect(() => {
228
- let objectValueCopy = objectValue;
229
- if (
230
- typeof objectValue === 'string' &&
231
- objectValue.length > 0 &&
232
- field.type !== 'TEXTAREA'
233
- ) {
234
- // if default value was sent as a strinfiyed object
235
- objectValueCopy = JSON.parse(objectValue);
236
- }
237
- if (objectValueCopy) {
238
- if (Array.isArray(objectValueCopy)) {
239
- setObjectArray(objectValueCopy);
240
- } else {
241
- setObjectArray([objectValueCopy]);
242
- }
243
- }
244
- }, [objectValue]);
245
-
246
- // Method to handle field changes for each object in the array
247
- const handleFieldChange = (
248
- index: number,
249
- fieldId: string,
250
- value: any,
251
- dataType: string,
252
- machine_name?: string,
253
- ) => {
254
- const updatedObjectArray =
255
- field.type === 'TEXTAREA' ? value : [...objectArray];
256
- const updatedObjectArrayKey = (isFlow && machine_name) || fieldId;
257
- if (field.type !== 'TEXTAREA') {
258
- updatedObjectArray[index][updatedObjectArrayKey] = value;
259
- }
260
-
261
- // Update the state with the modified object array
262
- if (field.type === 'TEXTAREA') {
263
- setObjectArray([updatedObjectArray]);
264
- } else {
265
- setObjectArray(updatedObjectArray);
266
- }
267
-
268
- // Optionally trigger the parent change handler
269
- if (isArray) {
270
- if (isFlow && onChangeInFlow) {
271
- if (normalizedField.template_fields?.length > 0) {
272
- onChangeInFlow(JSON.stringify(updatedObjectArray));
273
- } else {
274
- onChangeInFlow(value);
275
- }
276
- } else {
277
- onChange(
278
- fieldId,
279
- updatedObjectArray,
280
- dataType,
281
- field.is_required,
282
- field.id,
283
- index,
284
- );
285
- }
286
- } else if (isFlow && onChangeInFlow) {
287
- if (normalizedField.template_fields?.length > 0) {
288
- onChangeInFlow(
289
- JSON.stringify({
290
- [machine_name || '']: value,
291
- }),
292
- );
293
- } else {
294
- onChangeInFlow(value);
295
- }
296
- } else {
297
- onChange(fieldId, value, dataType, field.is_required, field.id);
298
- }
299
- };
300
-
301
- // Method to handle the 'Add More' button click
302
- const handleAddMore = () => {
303
- setObjectArray([...objectArray, {}]); // Add another empty object to the array
304
- };
305
-
306
- const getRegex: any = (f: any) => {
307
- if (f.type === 'boolean') {
308
- return '^(true|false)$'; // Matches "true" or "false" as strings
309
- }
310
- if (f.type === 'number') {
311
- return '^\\d+$'; // Matches numeric values only
312
- }
313
- if (f.type === 'array' && f.items && f.items.type === 'number') {
314
- return '^\\d+$'; // Matches numeric values only
315
- }
316
-
317
- return ''; // Default to empty string
318
- };
319
-
320
- const getRegexErrorMessage: any = (f: any) => {
321
- if (f.type === 'boolean') {
322
- return 'Please enter "true" or "false".'; // Error message for boolean fields
323
- }
324
- if (f.type === 'number') {
325
- return 'Please enter a valid number.'; // Error message for number fields
326
- }
327
- if (f.type === 'array' && f.items && f.items.type === 'number') {
328
- return 'Please enter a valid number.'; // Error message for number fields
329
- }
330
-
331
- return 'Invalid input.'; // Default error message
332
- };
333
-
334
- const handleDeleteIconClick = (index: number) => {
335
- setObjectArray((prevValues) => {
336
- const newValues = prevValues.filter((_, i) => i !== index);
337
- return newValues;
338
- });
339
- };
340
-
341
- const formatValueForTextarea = (value: any): string => {
342
- if (typeof value === 'object' && value !== null) {
343
- return JSON.stringify(value, null, 2); // Pretty-print with 2-space indentation
344
- }
345
- return String(value || ''); // Convert other values to string
346
- };
347
-
348
- // Render fields for each object in the array
349
- const renderFields = (
350
- properties: { [key: string]: FieldDetails },
351
- objectIndex: number,
352
- ) =>
353
- Object.entries(properties).map(([fieldName, fieldDetails], index) => {
354
- const fieldType = fieldDetails.meta.ui.ui_field?.type || 'TEXTFIELD';
355
- let options: Option[] = fieldDetails.meta.ui.ui_field?.options || [];
356
- if (fieldType === 'CHECKBOX') {
357
- options = [
358
- {
359
- id: '0',
360
- value: 'No',
361
- },
362
- {
363
- id: '1',
364
- value: 'Yes',
365
- },
366
- ];
367
- }
368
- const placeholder =
369
- fieldDetails.meta.ui.placeholder ||
370
- (['DYNAMIC_DROPDOWN', 'STATIC_DROPDOWN'].includes(
371
- fieldDetails.meta.ui.ui_field?.type || '',
372
- )
373
- ? `Select or enter a value here...`
374
- : `Enter value here...`);
375
-
376
- const fieldElement = html`
377
- <div
378
- id=${[
379
- 'integry-action-field-wrap',
380
- field?.activity_field?.machine_name !==
381
- fieldDetails?.meta?.machine_name
382
- ? field?.activity_field?.machine_name
383
- : null,
384
- fieldDetails?.meta?.machine_name,
385
- isArray ? objectIndex : null,
386
- ]
387
- .filter(Boolean)
388
- .join('-')}
389
- class="${styles.functionFieldWrap
390
- ? styles.functionFieldWrap
391
- : ''} integry-action-field-wrap"
392
- >
393
- <${ConfigureFieldWrapper} field=${fieldDetails}>
394
- ${fieldType === 'TEXTFIELD' &&
395
- html`
396
- <${MultipurposeField}
397
- id="${fieldName}"
398
- title="${fieldDetails.meta.title}"
399
- activityOutputData=${activityOutputData}
400
- activityOutputDataRaw=${activityOutputDataRaw}
401
- description="${fieldDetails.meta.description_for_users}"
402
- value=${(objectArray[objectIndex] || {})[
403
- fieldDetails?.meta?.machine_name || ''
404
- ] || ''}
405
- placeholder="${placeholder}"
406
- onChange=${(val: any) => {
407
- const valueReceived =
408
- fieldDetails.type === 'number' ? Number(val) : val;
409
- handleFieldChange(
410
- objectIndex,
411
- fieldName,
412
- valueReceived,
413
- fieldDetails.meta.ui.ui_field?.type || 'TEXTFIELD',
414
- fieldDetails.meta.machine_name,
415
- );
416
- }}
417
- regex=${fieldDetails.meta.ui.regex || getRegex(fieldDetails)}
418
- regexErrorMessage=${fieldDetails.meta.ui.regex_error_message ||
419
- getRegexErrorMessage(fieldDetails)}
420
- isRequired="${fieldDetails.meta.is_required}"
421
- type=${fieldType}
422
- isMappable=${activityOutputDataRaw &&
423
- Object.entries(activityOutputDataRaw).length > 0}
424
- isEditable=${true}
425
- allowTagsInText=${activityOutputDataRaw}
426
- fieldId=${`${field.id}_${fieldName}`}
427
- isDisabled=${isDisabled}
428
- ><//>
429
- `}
430
- ${fieldType === 'TEXTAREA' &&
431
- html`
432
- <${MultipurposeField}
433
- id="${fieldName}"
434
- title="${fieldDetails.meta.title}"
435
- description="${fieldDetails.meta.description_for_users}"
436
- activityOutputData=${activityOutputData}
437
- activityOutputDataRaw=${activityOutputDataRaw}
438
- value=${(objectArray[objectIndex] || {})[fieldName] || ''}
439
- onChange=${(val: any) =>
440
- handleFieldChange(
441
- objectIndex,
442
- fieldName,
443
- val,
444
- fieldDetails.meta.ui.ui_field?.type || 'TEXTAREA',
445
- fieldDetails.meta.machine_name,
446
- )}
447
- placeholder="${placeholder}"
448
- isRequired="${fieldDetails.meta.is_required}"
449
- regex=${fieldDetails.meta.ui.regex || getRegex(fieldDetails)}
450
- regexErrorMessage=${fieldDetails.meta.ui.regex_error_message ||
451
- getRegexErrorMessage(fieldDetails)}
452
- isEditable=${true}
453
- fieldId=${`${field.id}_${fieldName}`}
454
- type=${fieldType}
455
- isMappable=${tagsTree
456
- ? true
457
- : activityOutputDataRaw &&
458
- Object.entries(activityOutputDataRaw).length > 0}
459
- allowTagsInText=${activityOutputDataRaw || tagsTree}
460
- value=${objectHasFields
461
- ? (objectArray[objectIndex] || {})[
462
- fieldDetails?.meta?.machine_name || ''
463
- ] || ''
464
- : formatValueForTextarea(objectValue)}
465
- isDisabled=${isDisabled}
466
- tagsTree=${tagsTree}
467
- showMenuOnLeft=${showMenuOnLeft}
468
- ><//>
469
- `}
470
- ${fieldType === 'DYNAMIC_DROPDOWN' &&
471
- html`
472
- <${ListBox}
473
- key=${fieldName}
474
- fieldId=${fieldName}
475
- apiHandler=${apiHandler}
476
- title=${fieldDetails.meta.title}
477
- description=${fieldDetails.meta.description_for_users}
478
- placeholder="${placeholder}"
479
- isRequired="${fieldDetails.meta.is_required}"
480
- isDynamic=${true}
481
- isDisabled=${isDisabled}
482
- endpointUrl=${fieldDetails.meta.ui.ui_field?.data_source?.url ||
483
- ''}
484
- options=${options}
485
- value=${(objectArray[objectIndex] || {})[fieldName] || ''}
486
- onChange=${(val: any) =>
487
- handleFieldChange(
488
- objectIndex,
489
- fieldName,
490
- val,
491
- fieldDetails.meta.ui.ui_field?.type || 'DYNAMIC_DROPDOWN',
492
- fieldDetails.meta.machine_name,
493
- )}
494
- optionKeyPath=${fieldDetails.meta.ui.ui_field?.value_key_path ||
495
- ''}
496
- valueKeyPath=${fieldDetails.meta.ui.ui_field?.option_key_path ||
497
- ''}
498
- />
499
- `}
500
- ${(fieldType === 'STATIC_DROPDOWN' || fieldType === 'CHECKBOX') &&
501
- html`
502
- <${ListBox}
503
- key=${`${fieldName}_${objectIndex}`}
504
- fieldId=${`${fieldName}_${objectIndex}`}
505
- apiHandler=${apiHandler}
506
- title=${fieldDetails.meta.title}
507
- description=${fieldDetails.meta.description_for_users}
508
- placeholder="${placeholder}"
509
- isRequired="${fieldDetails.meta.is_required}"
510
- isDynamic=${false}
511
- isDisabled=${isDisabled}
512
- endpointUrl=${JSON.stringify(options) || ''}
513
- options=${options}
514
- type=${fieldType}
515
- value=${(objectArray[objectIndex] || {})[fieldName] || ''}
516
- onChange=${(val: any) =>
517
- handleFieldChange(
518
- objectIndex,
519
- fieldName,
520
- val,
521
- fieldDetails.meta.ui.ui_field?.type || 'DYNAMIC_DROPDOWN',
522
- fieldDetails.meta.machine_name,
523
- )}
524
- />
525
- `}
526
- <//>
527
- </div>
528
- `;
529
-
530
- return fieldElement;
531
- });
532
- return html`
533
- <div class="${styles.objectContainer}">
534
- ${objectArray.map(
535
- (_, index) =>
536
- html`
537
- <div class="${objectHasFields ? styles.objectFieldWrap : ''}">
538
- ${objectHasFields &&
539
- html`<div class="${styles.label}">
540
- <label class="${styles.subLabel}">
541
- <div>
542
- ${field.title}${isArray ? ` ${index + 1}` : ''}
543
- ${isArray &&
544
- objectArray.length > 1 &&
545
- index !== objectArray.length - 1 &&
546
- html`
547
- <div class=${styles.removeButton}>
548
- <button
549
- class="${styles.removeButton}"
550
- onClick=${() => {
551
- if (handleDeleteIconClick) {
552
- handleDeleteIconClick(index);
553
- }
554
- }}
555
- tabindex="-1"
556
- >
557
- <svg
558
- width="15"
559
- height="15"
560
- viewBox="0 0 15 15"
561
- fill="none"
562
- xmlns="http://www.w3.org/2000/svg"
563
- >
564
- <path d="M1.5 4.1999H13.65" stroke="#999999" />
565
- <path
566
- d="M11.6254 5.5498V6.2248L10.9504 13.6498H4.20039L3.52539 6.2248V5.5498"
567
- stroke="#999999"
568
- stroke-linejoin="round"
569
- />
570
- <path
571
- d="M5.55078 3.525V2.175C5.55078 1.80221 5.85299 1.5 6.22578 1.5H8.92578C9.29857 1.5 9.60078 1.80221 9.60078 2.175V3.525"
572
- stroke="#999999"
573
- />
574
- </svg>
575
- </button>
576
- </div>
577
- `}
578
- </div>
579
- <div>${field.description}</div>
580
- </label>
581
- </div>`}
582
- ${renderFields(normalizedField.properties, index)}
583
- </div>
584
- `,
585
- )}
586
- ${isArray &&
587
- showAddMoreOption &&
588
- html` <a onClick=${handleAddMore}>+ Add another ${field.title}</a> `}
589
- </div>
590
- `;
591
- };
592
-
593
- export { ObjectField, ObjectFieldProps };