@integry/sdk 4.5.2 → 4.5.4

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 (279) hide show
  1. package/.vscode/launch.json +2 -2
  2. package/THIRD_PARTY_LICENSES +0 -37
  3. package/dist/esm/index.csm.d.ts +12 -2
  4. package/dist/esm/index.csm.js +7262 -1
  5. package/dist/umd/index.umd.d.ts +9 -1
  6. package/dist/umd/index.umd.js +7262 -1
  7. package/jest.config.cjs +10 -0
  8. package/package.json +10 -4
  9. package/src/components/AddTagButton/index.ts +23 -0
  10. package/src/components/BasicSelect/index.ts +114 -0
  11. package/src/components/BasicSelect/styles.module.scss +44 -0
  12. package/src/components/Button/index.ts +94 -0
  13. package/src/components/Button/styles.module.scss +152 -0
  14. package/src/components/CheckboxGroup/Checkbox.ts +104 -0
  15. package/src/components/CheckboxGroup/index.ts +190 -0
  16. package/src/components/CheckboxGroup/styles.module.scss +63 -0
  17. package/src/components/CollapsedMenu/index.ts +101 -0
  18. package/src/components/CollapsedMenu/styles.module.scss +46 -0
  19. package/src/components/ConfigureFieldWrapper/index.ts +85 -0
  20. package/src/components/ConfigureFieldWrapper/styles.module.scss +57 -0
  21. package/src/components/EditableText/index.ts +121 -0
  22. package/src/components/EditableText/styles.module.scss +38 -0
  23. package/src/components/EditableTextArea/index.ts +143 -0
  24. package/src/components/EditableTextArea/styles.module.scss +91 -0
  25. package/src/components/ErrorMessage/index.ts +16 -0
  26. package/src/components/ErrorMessage/styles.module.scss +19 -0
  27. package/src/components/ErrorPage/index.ts +42 -0
  28. package/src/components/ErrorPage/styles.module.scss +26 -0
  29. package/src/components/Footer/index.ts +41 -0
  30. package/src/components/Footer/styles.module.scss +40 -0
  31. package/src/components/HTMLContent/index.tsx +275 -0
  32. package/src/components/HTMLContent/styles.module.scss +3 -0
  33. package/src/components/InfoBox/index.ts +48 -0
  34. package/src/components/InfoBox/styles.module.scss +21 -0
  35. package/src/components/Input/BaseInput/index.ts +170 -0
  36. package/src/components/Input/BaseInput/styles.module.scss +94 -0
  37. package/src/components/Input/DateInput/index.ts +103 -0
  38. package/src/components/Input/DateInput/styles.module.scss +50 -0
  39. package/src/components/Input/Input/index.ts +206 -0
  40. package/src/components/Input/Input/styles.module.scss +14 -0
  41. package/src/components/Input/PasswordInput/index.ts +164 -0
  42. package/src/components/Input/PasswordInput/styles.module.scss +37 -0
  43. package/src/components/Input/index.ts +7 -0
  44. package/src/components/Label/index.ts +61 -0
  45. package/src/components/Label/styles.module.scss +41 -0
  46. package/src/components/LargeLoader/index.ts +25 -0
  47. package/src/components/LargeLoader/styles.module.scss +16 -0
  48. package/src/components/Listbox/ListBoxItem.ts +57 -0
  49. package/src/components/Listbox/index.ts +479 -0
  50. package/src/components/Listbox/styles.module.scss +197 -0
  51. package/src/components/Loader/index.ts +25 -0
  52. package/src/components/Loader/styles.module.scss +16 -0
  53. package/src/components/MediaGallery/MediaGalleryModal.ts +82 -0
  54. package/src/components/MediaGallery/MediaSlider.ts +76 -0
  55. package/src/components/MediaGallery/index.ts +92 -0
  56. package/src/components/MediaGallery/styles.module.scss +156 -0
  57. package/src/components/MediaUpload/index.ts +233 -0
  58. package/src/components/MediaUpload/styles.module.scss +118 -0
  59. package/src/components/Modal/index.ts +87 -0
  60. package/src/components/Modal/styles.module.scss +441 -0
  61. package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +58 -0
  62. package/src/components/MultipurposeField/Dropdown/index.tsx +981 -0
  63. package/src/components/MultipurposeField/Dropdown/styles.module.scss +208 -0
  64. package/src/components/MultipurposeField/TagMenu/index.ts +384 -0
  65. package/src/components/MultipurposeField/TagMenu/styles.module.scss +136 -0
  66. package/src/components/MultipurposeField/TagOptions/index.tsx +83 -0
  67. package/src/components/MultipurposeField/TagOptions/styles.module.scss +95 -0
  68. package/src/components/MultipurposeField/index.tsx +687 -0
  69. package/src/components/MultipurposeField/styles.module.scss +56 -0
  70. package/src/components/NewModal/index.ts +69 -0
  71. package/src/components/NewModal/styles.module.scss +70 -0
  72. package/src/components/OverflowTooltip/index.tsx +59 -0
  73. package/src/components/PopUp/ConfirmationPopUp/index.ts +58 -0
  74. package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +49 -0
  75. package/src/components/PopUp/SuccessPopUp/index.ts +62 -0
  76. package/src/components/PopUp/SuccessPopUp/styles.module.scss +38 -0
  77. package/src/components/RadioGroup/Radio.ts +129 -0
  78. package/src/components/RadioGroup/index.ts +169 -0
  79. package/src/components/RadioGroup/styles.module.scss +81 -0
  80. package/src/components/Search/index.ts +69 -0
  81. package/src/components/Search/styles.module.scss +149 -0
  82. package/src/components/TabBar/Tab.ts +33 -0
  83. package/src/components/TabBar/index.ts +64 -0
  84. package/src/components/TabBar/styles.module.scss +43 -0
  85. package/src/components/Tag/index.ts +29 -0
  86. package/src/components/Tag/styles.module.scss +57 -0
  87. package/src/components/TextArea/index.ts +172 -0
  88. package/src/components/TextArea/styles.module.scss +70 -0
  89. package/src/components/TextContent/index.tsx +128 -0
  90. package/src/components/TextContent/styles.module.scss +6 -0
  91. package/src/components/ThreeDotLoader/index.ts +39 -0
  92. package/src/components/ThreeDotLoader/styles.module.scss +41 -0
  93. package/src/components/TimeInput/index.ts +129 -0
  94. package/src/components/TimeInput/styles.module.scss +16 -0
  95. package/src/components/Toggle/index.ts +34 -0
  96. package/src/components/Toggle/styles.module.scss +56 -0
  97. package/src/components/Toggle-v2/index.ts +40 -0
  98. package/src/components/Toggle-v2/styles.module.scss +86 -0
  99. package/src/components/Tooltip/index.ts +271 -0
  100. package/src/components/Tooltip/styles.module.scss +105 -0
  101. package/src/components/form/ObjectField/index.ts +364 -0
  102. package/src/components/form/ObjectField/styles.module.scss +103 -0
  103. package/src/components/form/index.ts +3 -0
  104. package/src/contexts/AppContext.ts +12 -0
  105. package/src/declaration.d.ts +7 -0
  106. package/src/extensions/HMAC.ts +25 -0
  107. package/src/extensions/IntegryAPIError.ts +19 -0
  108. package/src/features/common/AccountDropdown/index.ts +291 -0
  109. package/src/features/common/AccountDropdown/styles.module.scss +19 -0
  110. package/src/features/common/ActionForm/index.ts +1818 -0
  111. package/src/features/common/ActionForm/styles.module.scss +23 -0
  112. package/src/features/common/AppCard/index.ts +207 -0
  113. package/src/features/common/AppCard/styles.module.scss +117 -0
  114. package/src/features/common/AppCardCompact/index.ts +189 -0
  115. package/src/features/common/AppCardCompact/styles.module.scss +141 -0
  116. package/src/features/common/AuthSelector/index.ts +537 -0
  117. package/src/features/common/AuthSelector/styles.module.scss +161 -0
  118. package/src/features/common/AuthSelectorCompact/index.ts +706 -0
  119. package/src/features/common/AuthSelectorCompact/styles.module.scss +219 -0
  120. package/src/features/common/AuthSelectorDropdown/index.ts +704 -0
  121. package/src/features/common/AuthSelectorDropdown/styles.module.scss +361 -0
  122. package/src/features/common/DynamicField/index.ts +229 -0
  123. package/src/features/common/DynamicField/styles.module.scss +67 -0
  124. package/src/features/common/DynamicTypedField/index.ts +217 -0
  125. package/src/features/common/DynamicTypedField/styles.module.scss +67 -0
  126. package/src/features/common/FunctionForm/index.ts +862 -0
  127. package/src/features/common/FunctionForm/styles.module.scss +163 -0
  128. package/src/features/common/MappingUI/index.ts +649 -0
  129. package/src/features/common/MappingUI/styles.module.scss +121 -0
  130. package/src/features/common/MarketplaceAppCard/index.ts +279 -0
  131. package/src/features/common/MarketplaceAppCard/styles.module.scss +231 -0
  132. package/src/features/common/MarketplaceAppCardCompact/index.ts +283 -0
  133. package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +255 -0
  134. package/src/features/common/NewMappingUI/index.ts +515 -0
  135. package/src/features/common/NewMappingUI/styles.module.scss +113 -0
  136. package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +67 -0
  137. package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +23 -0
  138. package/src/features/common/RequestAppWidget/index.ts +48 -0
  139. package/src/features/common/RequestAppWidget/request-app-form.ts +89 -0
  140. package/src/features/common/RequestAppWidget/styles.module.scss +43 -0
  141. package/src/features/common/SectionField/index.ts +272 -0
  142. package/src/features/common/SectionField/styles.module.scss +67 -0
  143. package/src/features/common/Step/index.ts +827 -0
  144. package/src/features/common/Step/styles.module.scss +12 -0
  145. package/src/features/common/StepNavigation/CollapsedSteps.ts +125 -0
  146. package/src/features/common/StepNavigation/NavItem.ts +111 -0
  147. package/src/features/common/StepNavigation/index.ts +257 -0
  148. package/src/features/common/StepNavigation/styles.module.scss +117 -0
  149. package/src/features/common/Steps/index.ts +1139 -0
  150. package/src/features/common/Steps/styles.module.scss +314 -0
  151. package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +383 -0
  152. package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +367 -0
  153. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +194 -0
  154. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +389 -0
  155. package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +577 -0
  156. package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +83 -0
  157. package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +212 -0
  158. package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +45 -0
  159. package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +1081 -0
  160. package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +452 -0
  161. package/src/features/containers/AppFlowContainer/Authentication/index.ts +610 -0
  162. package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +468 -0
  163. package/src/features/containers/AppFlowContainer/index.ts +114 -0
  164. package/src/features/containers/AppPageContainer/AppPage/index.tsx +262 -0
  165. package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +120 -0
  166. package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +165 -0
  167. package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +81 -0
  168. package/src/features/containers/AppPageContainer/index.tsx +93 -0
  169. package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
  170. package/src/features/containers/AppsForFlows/index.ts +161 -0
  171. package/src/features/containers/AppsForFlows/styles.module.scss +280 -0
  172. package/src/features/containers/AppsForFlowsCompact/index.ts +161 -0
  173. package/src/features/containers/AppsForFlowsCompact/styles.module.scss +279 -0
  174. package/src/features/containers/AuthSetupContainer/AppSelection.ts +73 -0
  175. package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +67 -0
  176. package/src/features/containers/AuthSetupContainer/Footer.ts +32 -0
  177. package/src/features/containers/AuthSetupContainer/Header.ts +39 -0
  178. package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +27 -0
  179. package/src/features/containers/AuthSetupContainer/index.ts +349 -0
  180. package/src/features/containers/AuthSetupContainer/styles.module.scss +229 -0
  181. package/src/features/containers/FlowSetupContainer/index.ts +390 -0
  182. package/src/features/containers/FlowSetupContainer/styles.module.scss +18 -0
  183. package/src/features/containers/MarkeplaceApps/index.ts +574 -0
  184. package/src/features/containers/MarkeplaceApps/styles.module.scss +559 -0
  185. package/src/features/containers/MarketplaceAppsCompact/index.ts +576 -0
  186. package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +546 -0
  187. package/src/features/containers/MarketplaceAppsContainer/index.ts +83 -0
  188. package/src/features/containers/MarketplaceContainer/AppCard/index.ts +91 -0
  189. package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +66 -0
  190. package/src/features/containers/MarketplaceContainer/AppListing/index.ts +34 -0
  191. package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +10 -0
  192. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +132 -0
  193. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +117 -0
  194. package/src/features/containers/MarketplaceContainer/index.ts +242 -0
  195. package/src/features/containers/MarketplaceContainer/styles.module.scss +84 -0
  196. package/src/features/containers/SDKContainer/index.ts +817 -0
  197. package/src/features/containers/SDKContainer/styles.module.scss +266 -0
  198. package/src/features/containers/SDKDebugContainer/index.ts +137 -0
  199. package/src/features/containers/SDKDebugContainer/styles.module.scss +37 -0
  200. package/src/features/containers/SDKFailedContainer/index.ts +117 -0
  201. package/src/features/containers/SDKFailedContainer/styles.module.scss +57 -0
  202. package/src/features/integrations/IntegrationRow/Icons.ts +77 -0
  203. package/src/features/integrations/IntegrationRow/index.ts +129 -0
  204. package/src/features/integrations/IntegrationRow/styles.module.scss +62 -0
  205. package/src/features/integrations/IntegrationsHeader/index.ts +34 -0
  206. package/src/features/integrations/IntegrationsHeader/styles.module.scss +47 -0
  207. package/src/features/integrations/IntegrationsList/index.ts +252 -0
  208. package/src/features/integrations/IntegrationsList/styles.module.scss +67 -0
  209. package/src/features/templates/Template/index.ts +295 -0
  210. package/src/features/templates/Template/styles.module.scss +226 -0
  211. package/src/features/templates/TemplatesView/index.ts +368 -0
  212. package/src/features/templates/TemplatesView/styles.module.scss +71 -0
  213. package/src/features/templates/TemplatesViewCompact/index.ts +364 -0
  214. package/src/features/templates/TemplatesViewCompact/styles.module.scss +141 -0
  215. package/src/hooks/useAutosizeTextArea.ts +22 -0
  216. package/src/hooks/useCustomRef.ts +13 -0
  217. package/src/hooks/useDebounce.ts +17 -0
  218. package/src/hooks/useElementResize.ts +40 -0
  219. package/src/hooks/useEventListener.ts +44 -0
  220. package/src/hooks/useHover.ts +40 -0
  221. package/src/hooks/useOnClickOutside.ts +32 -0
  222. package/src/index.ts +2051 -0
  223. package/src/index.umd.ts +13 -0
  224. package/src/interfaces/index.ts +924 -0
  225. package/src/modules/api/index.ts +1315 -0
  226. package/src/modules/api/responseHandler.ts +38 -0
  227. package/src/modules/event-emitter/index.ts +72 -0
  228. package/src/modules/event-emitter/runners/abstract.ts +21 -0
  229. package/src/modules/event-emitter/runners/default.ts +11 -0
  230. package/src/modules/event-emitter/runners/ntimes.ts +28 -0
  231. package/src/modules/event-emitter/types.ts +34 -0
  232. package/src/store/actionFunctions.ts +1573 -0
  233. package/src/store/index.ts +17 -0
  234. package/src/store/initialState.ts +58 -0
  235. package/src/stories/Button.stories.tsx +83 -0
  236. package/src/stories/Checkbox/Checkbox.stories.tsx +41 -0
  237. package/src/stories/Checkbox/CheckboxGroup.stories.tsx +46 -0
  238. package/src/stories/EditableText.stories.tsx +35 -0
  239. package/src/stories/Input/BaseInput.stories.tsx +48 -0
  240. package/src/stories/Input/DateInput.stories.tsx +28 -0
  241. package/src/stories/Input/Input.stories.tsx +24 -0
  242. package/src/stories/Input/PasswordInput.stories.tsx +26 -0
  243. package/src/stories/Introduction.stories.mdx +211 -0
  244. package/src/stories/Label.stories.tsx +27 -0
  245. package/src/stories/Listbox.stories.tsx +122 -0
  246. package/src/stories/Radio/Radio.stories.tsx +39 -0
  247. package/src/stories/Radio/RadioGroup.stories.tsx +46 -0
  248. package/src/stories/StepNavigation/NavItem.stories.tsx +31 -0
  249. package/src/stories/StepNavigation/StepNavigation.stories.tsx +50 -0
  250. package/src/stories/TabBar.stories.tsx +31 -0
  251. package/src/stories/TextArea.stories.tsx +23 -0
  252. package/src/stories/TimeInput.stories.tsx +37 -0
  253. package/src/stories/Toggle.stories.tsx +33 -0
  254. package/src/stories/assets/code-brackets.svg +1 -0
  255. package/src/stories/assets/colors.svg +1 -0
  256. package/src/stories/assets/comments.svg +1 -0
  257. package/src/stories/assets/direction.svg +1 -0
  258. package/src/stories/assets/flow.svg +1 -0
  259. package/src/stories/assets/plugin.svg +1 -0
  260. package/src/stories/assets/repo.svg +1 -0
  261. package/src/stories/assets/stackalt.svg +1 -0
  262. package/src/types/index.ts +293 -0
  263. package/src/types/store.ts +366 -0
  264. package/src/types/utils.ts +19 -0
  265. package/src/utils/ActivityOutputUtils.ts +163 -0
  266. package/src/utils/common.ts +20 -0
  267. package/src/utils/copyToClipboard.ts +24 -0
  268. package/src/utils/datetime.ts +101 -0
  269. package/src/utils/getUrlParam.ts +11 -0
  270. package/src/utils/isAuthMessage.ts +16 -0
  271. package/src/utils/isBrowser.ts +1 -0
  272. package/src/utils/jsonEncodeDecode.ts +15 -0
  273. package/src/utils/objectUtils.ts +116 -0
  274. package/src/utils/popup.ts +30 -0
  275. package/src/utils/searchJson.ts +51 -0
  276. package/src/utils/stepUtils.ts +45 -0
  277. package/src/utils/truncate.ts +6 -0
  278. package/test/setup.ts +1 -0
  279. package/vitest.config.ts +10 -0
@@ -0,0 +1,574 @@
1
+ import { html } from 'htm/preact';
2
+ import { useEffect, useState, useContext, useRef } from 'preact/hooks';
3
+
4
+ import { LargeLoader } from '@/components/LargeLoader';
5
+ import AppCard from '@/features/common/MarketplaceAppCard';
6
+ import AppCardCompact from '@/features/common/MarketplaceAppCardCompact';
7
+ import { ThreeDotLoader } from '@/components/ThreeDotLoader';
8
+ import { Hint } from '@/components/Tooltip';
9
+ import isBrowser from '@/utils/isBrowser';
10
+ import { openPopupWindow } from '@/utils/popup';
11
+ import { AuthData, isAuthMessage } from '@/utils/isAuthMessage';
12
+ import { truncate, isTruncatable } from '@/utils/truncate';
13
+ import Footer from '@/components/Footer';
14
+
15
+ import { connect } from 'unistore/preact';
16
+ import { StoreType } from '@/types/store';
17
+ import { actionFunctions } from '@/store';
18
+ import AppContext from '@/contexts/AppContext';
19
+ import { ViewStyles } from '@/types';
20
+
21
+ import styles from './styles.module.scss';
22
+
23
+ const Confirmation = (props: { callback(shouldDelete: boolean): void }) => {
24
+ const { callback } = props;
25
+ const [isProcessing, setIsProcessing] = useState(false);
26
+
27
+ const handleYesClick = () => {
28
+ setIsProcessing(true); // Update the state to show "..."
29
+ callback(true); // Trigger the callback function
30
+ };
31
+
32
+ return html`
33
+ <div class=${styles.confirmation}>
34
+ <div class=${styles.confirmationText}>Are you sure?</div>
35
+ <button disabled=${isProcessing} onclick=${() => callback(false)}>
36
+ No
37
+ </button>
38
+ <button onclick=${handleYesClick}>
39
+ ${isProcessing ? html`<${ThreeDotLoader} color="#fff" />` : 'Yes'}
40
+ </button>
41
+ </div>
42
+ `;
43
+ };
44
+
45
+ const AuthorizationRow = (props: {
46
+ id: string;
47
+ value: string;
48
+ isChecked?: boolean;
49
+ isLoading: boolean;
50
+ willDelete?: boolean;
51
+ isDeleting?: boolean;
52
+ error?: string;
53
+ status: 'VERIFYING' | 'CONNECTED' | 'ERROR' | 'IDLE' | null;
54
+ handleChange?: (id: string) => void;
55
+ handleReverify?: () => void;
56
+ handleDelete?: (shouldDelete: boolean) => void;
57
+ handleWillDelete?: () => void;
58
+ isReadOnly?: boolean;
59
+ forcedLoading?: boolean;
60
+ }) => {
61
+ const {
62
+ id,
63
+ value,
64
+ isChecked,
65
+ status = 'IDLE',
66
+ isDeleting = false,
67
+ willDelete = false,
68
+ handleChange,
69
+ handleReverify,
70
+ handleDelete = () => null,
71
+ handleWillDelete = () => null,
72
+ error,
73
+ isReadOnly,
74
+ } = props;
75
+ return html`
76
+ <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
77
+ <div class="${styles.checkboxRow} ${styles.buttonShadow}">
78
+ <div
79
+ class="${styles.connectedAccountRow} ${willDelete
80
+ ? styles.statusWrapShortWidth
81
+ : ''}"
82
+ >
83
+ <span class="${styles.connectedAccountValue}"
84
+ >${isTruncatable(value, 66) ? truncate(value, 66) : value}</span
85
+ >
86
+ <div class=${`${styles.statusWrap}`}>
87
+ <div class=${styles.status}>
88
+ <svg
89
+ width="12"
90
+ height="13"
91
+ viewBox="0 0 12 13"
92
+ fill="none"
93
+ xmlns="http://www.w3.org/2000/svg"
94
+ >
95
+ <circle cx="6" cy="6.5" r="6" fill="#C4E9D2" />
96
+ <path
97
+ d="M8.49951 4.5L5.22003 8.25L3.49951 6.28264"
98
+ stroke="#3BB568"
99
+ stroke-linecap="round"
100
+ />
101
+ </svg>
102
+ </div>
103
+ </div>
104
+ </div>
105
+
106
+ ${willDelete &&
107
+ !isDeleting &&
108
+ html` <${Confirmation} callback=${handleDelete} /> `}
109
+ ${!(status === 'VERIFYING' || isDeleting || willDelete) &&
110
+ !isReadOnly &&
111
+ html`
112
+ <div class=${styles.deleteIcon} onclick=${handleWillDelete}>
113
+ <svg
114
+ width="15"
115
+ height="15"
116
+ viewBox="0 0 15 15"
117
+ fill="none"
118
+ xmlns="http://www.w3.org/2000/svg"
119
+ >
120
+ <path d="M1.5 4.1999H13.65" stroke="#F05C42" />
121
+ <path
122
+ d="M11.6254 5.5498V6.2248L10.9504 13.6498H4.20039L3.52539 6.2248V5.5498"
123
+ stroke="#F05C42"
124
+ stroke-linejoin="round"
125
+ />
126
+ <path
127
+ 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"
128
+ stroke="#F05C42"
129
+ />
130
+ </svg>
131
+ </div>
132
+ `}
133
+ </div>
134
+ <//>
135
+ `;
136
+ };
137
+
138
+ const MarketplaceApps = (props: any) => {
139
+ const { genericData, renderMode, userConfig, appName } = props;
140
+ const context = useContext(AppContext);
141
+ const [apps, setApps] = useState<any[]>([]);
142
+ const [filteredApps, setFilteredApps] = useState<any[]>([]);
143
+ const [isFetchingApps, setIsFetchingApps] = useState<boolean>(true);
144
+ const [searchText, setSearchText] = useState<string>('');
145
+ const [totalApps, setTotalApps] = useState<number>(0);
146
+ const [cursor, setCursor] = useState<string>('');
147
+ const [filteredAppsCount, setFilteredAppsCount] = useState<number>(0);
148
+ const [loadingNextPage, setLoadingNextPage] = useState<boolean>(false);
149
+ const [searchInProgress, setSearchInProgress] = useState<boolean>(false);
150
+ const [selectedApp, setSelectedApp] = useState<any>(null);
151
+ const [
152
+ selectedAppConnectedAccounts,
153
+ setSelectedAppConnectedAccounts,
154
+ ] = useState<any[]>([]);
155
+ const [willDeleteAuthWithIndex, setWillDeleteAuthWithIndex] = useState<
156
+ number | null
157
+ >(null);
158
+ const [allowMultipleAuths, setAllowMultipleAuth] = useState<boolean>(true);
159
+
160
+ const DEBOUNCE_DELAY = 500;
161
+ const debounceTimeout = useRef<ReturnType<typeof setTimeout>>(0);
162
+
163
+ const getApps = ({
164
+ currentApps = <any>[],
165
+ search = '',
166
+ initialLoad = false,
167
+ nextCursor = '',
168
+ }) => {
169
+ setIsFetchingApps(true);
170
+
171
+ const cursorToUse = nextCursor || cursor;
172
+
173
+ context?.apiHandler
174
+ .getMarketplaceAppsV2({
175
+ cursor: search !== '' ? null : cursorToUse,
176
+ search,
177
+ })
178
+ .then((appsResponse) => {
179
+ const tempApps = appsResponse.apps.map((app: any) => ({
180
+ ...app,
181
+ }));
182
+ if (appsResponse._cursor || search === '') {
183
+ // we don't want to
184
+ setCursor(appsResponse._cursor);
185
+ }
186
+
187
+ setTotalApps(appsResponse.count || (tempApps || []).length);
188
+ if (search === '') {
189
+ setFilteredApps((prev) => [...prev, ...tempApps]);
190
+ } else {
191
+ setFilteredApps(tempApps);
192
+ }
193
+
194
+ if (initialLoad) {
195
+ setApps((prev) => [...prev, ...tempApps]);
196
+ }
197
+ setIsFetchingApps(false);
198
+ setLoadingNextPage(false);
199
+ setSearchInProgress(false);
200
+ })
201
+ .catch((error) => {
202
+ // eslint-disable-next-line no-console
203
+ console.log('error', { error });
204
+ setIsFetchingApps(false);
205
+ setLoadingNextPage(false);
206
+ setSearchInProgress(false);
207
+ });
208
+ };
209
+
210
+ const handleScroll = (e: any) => {
211
+ const bottom =
212
+ Math.floor(e.target.scrollHeight) ===
213
+ Math.floor(e.target.scrollTop + e.target.clientHeight);
214
+
215
+ if (bottom && !isFetchingApps && cursor && !loadingNextPage) {
216
+ // Trigger the next page load when at the bottom
217
+ setLoadingNextPage(true);
218
+ getApps({
219
+ currentApps: filteredApps,
220
+ search: searchText,
221
+ initialLoad: true, // we consider the next page to be part of the initial load
222
+ nextCursor: cursor, // Use the cursor for pagination
223
+ });
224
+ }
225
+ };
226
+
227
+ const filterApps = (inputString: string, items: any) => {
228
+ const cleanedInput = inputString.trim(); // Remove trailing spaces
229
+ setSearchInProgress(true);
230
+
231
+ if (cleanedInput === '') {
232
+ setFilteredApps(items); // Set the apps when there's no search input
233
+ return items;
234
+ }
235
+
236
+ setFilteredApps([]); // Clear the apps on each input change
237
+
238
+ // Clear the previous timeout to avoid executing the previous search
239
+ if (debounceTimeout.current) {
240
+ clearTimeout(debounceTimeout.current);
241
+ }
242
+
243
+ // Set a new debounce timeout to trigger the search after the delay
244
+ debounceTimeout.current = setTimeout(() => {
245
+ // Call the server-side function to fetch apps based on the search term
246
+ getApps({ currentApps: items, search: cleanedInput });
247
+ }, DEBOUNCE_DELAY); // Delay search until user stops typing
248
+
249
+ return [];
250
+ };
251
+
252
+ const handleGoBackToApps = () => {
253
+ setSelectedApp(null);
254
+ };
255
+
256
+ const onAuthResponseReceived = (messageEvent: MessageEvent<AuthData>) => {
257
+ if (isAuthMessage(messageEvent) && messageEvent.data.activity_name) {
258
+ const tempAccounts = [
259
+ ...selectedAppConnectedAccounts,
260
+ {
261
+ id: messageEvent.data.authorization_id,
262
+ display_name: messageEvent.data.user_identity,
263
+ },
264
+ ];
265
+ if (selectedApp && !selectedApp.allow_multiple_connected_accounts) {
266
+ setAllowMultipleAuth(false);
267
+ }
268
+ setSelectedAppConnectedAccounts(tempAccounts);
269
+ if (isBrowser())
270
+ window.removeEventListener('message', onAuthResponseReceived);
271
+ }
272
+ };
273
+
274
+ const openAuthWindow = () => {
275
+ if (isBrowser()) window.addEventListener('message', onAuthResponseReceived);
276
+ if (context && selectedApp && allowMultipleAuths) {
277
+ const url = selectedApp.login_url;
278
+ openPopupWindow(url, 'Auth Window', window, 800, 600);
279
+ }
280
+ };
281
+
282
+ const deleteAuth = (authIndex: number) => {
283
+ const auth = selectedAppConnectedAccounts[authIndex];
284
+
285
+ context?.apiHandler
286
+ .deleteAuth(auth.id)
287
+ .then((res) => {
288
+ if (res?.status === 200) {
289
+ if (selectedAppConnectedAccounts && authIndex >= 0) {
290
+ selectedAppConnectedAccounts.splice(authIndex, 1);
291
+ if (selectedAppConnectedAccounts.length === 0) {
292
+ setAllowMultipleAuth(true);
293
+ }
294
+ }
295
+ const eventPayload = selectedApp;
296
+ eventPayload.connected_account_id = auth.id;
297
+ context.eventEmitter.emit('app-disconnected', eventPayload);
298
+ }
299
+ })
300
+ .catch((err) => {
301
+ console.error(err);
302
+ })
303
+ .finally(() => {
304
+ // setWillDeleteAuth(false);
305
+ // setIsDeletingAuth(false);
306
+ setWillDeleteAuthWithIndex(null);
307
+ });
308
+ };
309
+
310
+ const willDelete = (authIndex: number) => {
311
+ setWillDeleteAuthWithIndex(authIndex);
312
+ };
313
+
314
+ const getApp = (_appName: string) => {
315
+ context?.apiHandler.getApp(_appName).then((app) => {
316
+ setSelectedApp(app);
317
+ if (
318
+ app.allow_multiple_connected_accounts ||
319
+ app.connected_accounts.length === 0
320
+ ) {
321
+ setAllowMultipleAuth(true);
322
+ } else {
323
+ setAllowMultipleAuth(false);
324
+ }
325
+ setIsFetchingApps(false);
326
+ });
327
+ };
328
+
329
+ useEffect(() => {
330
+ if (appName && appName !== '') {
331
+ getApp(appName);
332
+ } else {
333
+ getApps({
334
+ currentApps: apps,
335
+ search: '',
336
+ initialLoad: true,
337
+ });
338
+ }
339
+ }, []);
340
+
341
+ useEffect(() => {
342
+ setSelectedAppConnectedAccounts(selectedApp?.connected_accounts || []);
343
+ }, [selectedApp]);
344
+ return html`
345
+ <div
346
+ id="embed--appsContainer"
347
+ class="${renderMode === 'INLINE'
348
+ ? styles.appsContainerInline
349
+ : styles.appsContainer}
350
+ ${genericData.viewStyle === ViewStyles.COMPACT
351
+ ? styles['compact-view']
352
+ : ''}"
353
+ style="${renderMode === 'INLINE' && props.showMarketplaceModal
354
+ ? 'display: flex;'
355
+ : ''}"
356
+ >
357
+ <div
358
+ id="apps-header"
359
+ class="${styles.appsHeader} ${selectedApp
360
+ ? styles.appsHeaderWithBorder
361
+ : ''}"
362
+ >
363
+ ${selectedApp
364
+ ? html`
365
+ <div class="${styles.backLink} ${styles.appsHeaderTitle}">
366
+ ${!appName &&
367
+ html`<svg
368
+ width="33"
369
+ height="33"
370
+ viewBox="0 0 33 33"
371
+ fill="none"
372
+ xmlns="http://www.w3.org/2000/svg"
373
+ onclick=${handleGoBackToApps}
374
+ >
375
+ <circle
376
+ cx="16.6758"
377
+ cy="16.5684"
378
+ r="15.5"
379
+ fill="white"
380
+ stroke="#E0E0E0"
381
+ />
382
+ <path
383
+ d="M16.8975 11.3777L16.5547 11.7205L16.5547 11.7205L16.8975 11.3777ZM16.8975 12.0634L16.5547 11.7205L16.5547 11.7205L16.8975 12.0634ZM16.2119 11.3777L16.5547 11.7205L16.2119 11.3777ZM11.3634 16.2262L11.0205 15.8833L11.0205 15.8833L11.3634 16.2262ZM11.0205 16.569L10.6777
384
+ 16.2262L10.3349 16.569L10.6777 16.9118L11.0205 16.569ZM11.3634 16.9118L11.0205 17.2547L11.0205 17.2547L11.3634 16.9118ZM16.2119 21.7603L16.5547 21.4175L16.5547 21.4175L16.2119 21.7603ZM16.8975 21.7603L16.5547 21.4175L16.5547 21.4175L16.8975 21.7603ZM16.8975 21.0747L16.5547 21.4175L16.5547 21.4175L16.8975 21.0747ZM12.3919 16.569L12.0491 16.2262L11.7062 16.569L12.0491 16.9118L12.3919 16.569ZM22.8574 17.0545L22.8574 17.5394L22.8574 17.0545ZM22.8574 16.0848L22.8574 16.5697L22.8574
385
+ 16.0848ZM13.1605 16.0848L13.1605 15.6L13.1605 16.0848ZM13.1605 17.0545L13.1605 16.5697L13.1605 17.0545ZM16.5547 11.7205L16.5547 11.7205L17.2404 12.4062C17.6191 12.0275 17.6191 11.4135 17.2404 11.0348L16.5547 11.7205ZM16.5547 11.7205L17.2404 11.0348C16.8617 10.6562 16.2477 10.6562 15.869 11.0348L16.5547 11.7205ZM11.7062 16.569L16.5547 11.7205L15.869 11.0348L11.0205 15.8833L11.7062 16.569ZM11.3634 16.9118L11.7062 16.569L11.0205 15.8833L10.6777 16.2262L11.3634 16.9118ZM11.7062 16.569L11.3634 16.2262L10.6777
386
+ 16.9118L11.0205 17.2547L11.7062 16.569ZM16.5547 21.4175L11.7062 16.569L11.0205 17.2547L15.869 22.1032L16.5547 21.4175ZM16.5547 21.4175L15.869 22.1032C16.2477 22.4819 16.8617 22.4819 17.2404 22.1032L16.5547 21.4175ZM16.5547 21.4175L16.5547
387
+ 21.4175L17.2404 22.1032C17.6191 21.7245 17.6191 21.1105 17.2404 20.7318L16.5547 21.4175ZM12.0491 16.9118L16.5547 21.4175L17.2404 20.7318L12.7347 16.2262L12.0491 16.9118ZM16.5547 11.7205L12.0491 16.2262L12.7347 16.9118L17.2404 12.4062L16.5547 11.7205ZM22.8574 16.5697L22.8574 16.5697L22.8574 17.5394C23.393 17.5394 23.8271 17.1052 23.8271 16.5697L22.8574 16.5697ZM22.8574 16.5697L22.8574 16.5697L23.8271 16.5697C23.8271 16.0341 23.393 15.6 22.8574 15.6L22.8574
388
+ 16.5697ZM13.1605 16.5697L22.8574 16.5697L22.8574 15.6L13.1605 15.6L13.1605 16.5697ZM13.1605 16.5697L13.1605 15.6C12.6249 15.6 12.1908 16.0341 12.1908 16.5697L13.1605 16.5697ZM13.1605 16.5697L12.1908 16.5697C12.1908 17.1052 12.6249 17.5394 13.1605 17.5394L13.1605 16.5697ZM22.8574 16.5697L13.1605 16.5697L13.1605 17.5394L22.8574 17.5394L22.8574 16.5697Z"
389
+ fill="#4250F0"
390
+ />
391
+ </svg>`}
392
+ ${selectedApp &&
393
+ html`<img
394
+ src=${selectedApp.icon_url}
395
+ title="${selectedApp.title}"
396
+ />`}
397
+
398
+ <p class="${styles.backLabel}">
399
+ ${selectedApp ? selectedApp.title : 'Apps'}
400
+ </p>
401
+ </div>
402
+ `
403
+ : html`
404
+ <p id="appsHeaderTitle" class=${styles.appsHeaderTitle}>
405
+ ${(() => {
406
+ if (selectedApp) {
407
+ return selectedApp.title;
408
+ }
409
+ if (appName) {
410
+ return 'Loading...';
411
+ }
412
+ return 'Apps';
413
+ })()}
414
+ </p>
415
+ `}
416
+ ${!selectedApp &&
417
+ !appName &&
418
+ html`<div id="search-container" class=${styles.searchContainer}>
419
+ <svg
420
+ xmlns="http://www.w3.org/2000/svg"
421
+ width="15"
422
+ height="15"
423
+ viewBox="0 0 15 15"
424
+ fill="none"
425
+ >
426
+ <path
427
+ d="M14.7706 13.6638L11.148 10.0407C13.0421 7.59989 12.8712 4.06416 10.6303 1.82385C9.45395 0.647448 7.89024 0 6.2271 0C4.56335 0 2.99953 0.647997 1.82385 1.82385C0.647448 2.99965 0 4.56335 0 6.2271C0 7.89084 0.647996 9.45466 1.82385 10.6303C3.00025 11.8067 4.56396 12.4542 6.2271 12.4542C7.62663 12.4542 8.95411 11.9942 10.0413 11.1481L13.6638 14.7706C13.8168 14.9236 14.0167 14.9997 14.2172 14.9997C14.4172 14.9997 14.6177 14.9236 14.7706 14.7706C15.0765 14.4654 15.0765 13.9697 14.7706 13.6639L14.7706 13.6638ZM2.93043 9.52291C2.05038 8.64226 1.56482 7.47179 1.56482 6.22694C1.56482 4.98153 2.04978 3.81114 2.93043 2.93037C3.81049 2.04972 4.98156 1.56476 6.2264 1.56476C7.47124 1.56476 8.6422 2.04972 9.52297 2.93037C11.3409 4.74767 11.3409 7.705 9.52297 9.52276C8.64232 10.4034 7.47124 10.8884 6.2264 10.8884C4.98156 10.8884 3.8112 10.4034 2.93043 9.52276V9.52291Z"
428
+ fill="#BDBDBD"
429
+ />
430
+ </svg>
431
+ <input
432
+ id="search-apps-flow-lifecycle"
433
+ class=${styles.searchInput}
434
+ placeholder="${userConfig.searchPlaceholder || 'Search for apps'}"
435
+ value=${searchText}
436
+ oninput=${(e: any) => {
437
+ setSearchText(e.target.value);
438
+ filterApps(e.target.value, apps);
439
+ }}
440
+ />
441
+ ${searchText !== '' &&
442
+ html` <svg
443
+ class=${styles.clearCta}
444
+ onclick=${() => {
445
+ setSearchText('');
446
+ filterApps('', apps);
447
+ }}
448
+ xmlns="http://www.w3.org/2000/svg"
449
+ width="12"
450
+ height="12"
451
+ viewBox="0 0 12 12"
452
+ fill="none"
453
+ >
454
+ <path
455
+ d="M10.2426 10.2425L1.75732 1.75732"
456
+ stroke="#333333"
457
+ stroke-width="1.33333"
458
+ stroke-linecap="round"
459
+ />
460
+ <path
461
+ d="M10.2426 1.75732L1.75732 10.2425"
462
+ stroke="#333333"
463
+ stroke-width="1.33333"
464
+ stroke-linecap="round"
465
+ />
466
+ </svg>`}
467
+ </div>`}
468
+ </div>
469
+
470
+ ${true &&
471
+ filteredApps.length < 1 &&
472
+ !selectedApp &&
473
+ html` <div
474
+ id="appsForFlowsCardsNoAppFound"
475
+ class=${styles.appsForFlowsCardsNoAppFound}
476
+ >
477
+ ${searchText !== '' &&
478
+ html` ${isFetchingApps && html`<${LargeLoader} />`}
479
+ ${!searchInProgress && html`<p>Sorry, no apps found.</p>`}`}
480
+ ${searchText === '' &&
481
+ html` ${isFetchingApps && html`<${LargeLoader} />`}
482
+ ${!isFetchingApps && html`<p>Sorry, no apps found.</p>`}`}
483
+ </div>`}
484
+ ${true &&
485
+ (filteredApps.length > 0 || selectedApp) &&
486
+ html`
487
+ ${selectedApp
488
+ ? html`<div
489
+ class="${styles.marketplaceAuthSelectorWrap} integry-container__auth-selector"
490
+ >
491
+ <div class="${styles.heading}">Connected Accounts</div>
492
+ <div class=${styles.rows}>
493
+ ${selectedAppConnectedAccounts.map(
494
+ (el: any, index: number) => html`<${AuthorizationRow}
495
+ id=${el.id}
496
+ value=${el.display_name}
497
+ status=${`CONNECTED`}
498
+ handleDelete=${(shouldDelete: boolean) =>
499
+ shouldDelete
500
+ ? deleteAuth(index)
501
+ : setWillDeleteAuthWithIndex(null)}
502
+ handleWillDelete=${() => willDelete(index)}
503
+ willDelete=${willDeleteAuthWithIndex === index}
504
+ />`,
505
+ )}
506
+ </div>
507
+ ${true &&
508
+ html`
509
+ <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
510
+ <div
511
+ data-hint="${allowMultipleAuths
512
+ ? ''
513
+ : `You cannot connect more than one account for ${selectedApp.title}.`}"
514
+ class="${styles.checkboxRow} ${styles.buttonShadow} ${styles.marketplaceAddAccountBtn} ${allowMultipleAuths
515
+ ? ''
516
+ : styles.disabled}"
517
+ onclick=${openAuthWindow}
518
+ >
519
+ <span>+</span>
520
+ <p>Add account</p>
521
+ </div>
522
+ <//>
523
+ `}
524
+ </div>`
525
+ : html`<div
526
+ id="${`embed--appsForFlowsCardsComfortable__${renderMode}`}"
527
+ onscroll=${handleScroll}
528
+ class="${props.genericData.viewStyle === ViewStyles.COMPACT
529
+ ? styles.appsForFlowsCardsCompact
530
+ : styles.appsForFlowsCards}"
531
+ >
532
+ ${filteredApps.map(
533
+ (app: any) =>
534
+ html`
535
+ <${genericData.viewStyle === ViewStyles.COMPACT
536
+ ? AppCardCompact
537
+ : AppCard}
538
+ key=${app.id}
539
+ app=${app}
540
+ onAppClick=${(appClicked: any) => {
541
+ setSelectedApp(appClicked);
542
+ }}
543
+ />
544
+ `,
545
+ )}
546
+ ${cursor &&
547
+ html`<div
548
+ class="${styles.loadMore}"
549
+ onclick=${() => {
550
+ getApps({
551
+ currentApps: apps,
552
+ });
553
+ }}
554
+ >
555
+ ${loadingNextPage
556
+ ? html`<${ThreeDotLoader} color="#999" />`
557
+ : html``}
558
+ </div>`}
559
+ </div>`}
560
+ `}
561
+ ${!isFetchingApps &&
562
+ html`<${Footer}
563
+ style=${renderMode === 'INLINE'
564
+ ? 'padding-top: 12px;'
565
+ : 'padding-top: 12px; box-shadow: 0px -6px 10px 0px rgba(255, 255, 255, 0.8);'}
566
+ />`}
567
+ </div>
568
+ `;
569
+ };
570
+
571
+ export default connect<StoreType, unknown, StoreType, unknown>(
572
+ ['genericData', 'userConfig', 'showMarketplaceModal'],
573
+ actionFunctions,
574
+ )(MarketplaceApps);