@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,576 @@
1
+ import { html } from 'htm/preact';
2
+ import { useEffect, useState, useContext, useRef } from 'preact/hooks';
3
+
4
+ import { Loader } from '@/components/Loader';
5
+ import { LargeLoader } from '@/components/LargeLoader';
6
+ import { ThreeDotLoader } from '@/components/ThreeDotLoader';
7
+ import AppCard from '@/features/common/MarketplaceAppCard';
8
+ import AppCardCompact from '@/features/common/MarketplaceAppCardCompact';
9
+ import Footer from '@/components/Footer';
10
+ import { Hint } from '@/components/Tooltip';
11
+ import isBrowser from '@/utils/isBrowser';
12
+ import { truncate, isTruncatable } from '@/utils/truncate';
13
+ import { AuthData, isAuthMessage } from '@/utils/isAuthMessage';
14
+ import { openPopupWindow } from '@/utils/popup';
15
+
16
+ import { connect } from 'unistore/preact';
17
+ import { StoreType } from '@/types/store';
18
+ import { actionFunctions } from '@/store';
19
+ import AppContext from '@/contexts/AppContext';
20
+ import { ViewStyles } from '@/types';
21
+
22
+ import styles from './styles.module.scss';
23
+
24
+ const Confirmation = (props: { callback(shouldDelete: boolean): void }) => {
25
+ const { callback } = props;
26
+ const [isProcessing, setIsProcessing] = useState(false);
27
+
28
+ const handleYesClick = () => {
29
+ setIsProcessing(true); // Update the state to show "..."
30
+ callback(true); // Trigger the callback function
31
+ };
32
+
33
+ return html`
34
+ <div class=${styles.confirmation}>
35
+ <div class=${styles.confirmationText}>Are you sure?</div>
36
+ <button disabled=${isProcessing} onclick=${() => callback(false)}>
37
+ No
38
+ </button>
39
+ <button onclick=${handleYesClick}>
40
+ ${isProcessing ? html`<${ThreeDotLoader} color="#fff" />` : 'Yes'}
41
+ </button>
42
+ </div>
43
+ `;
44
+ };
45
+
46
+ const AuthorizationRow = (props: {
47
+ id: string;
48
+ value: string;
49
+ isChecked?: boolean;
50
+ isLoading: boolean;
51
+ willDelete?: boolean;
52
+ isDeleting?: boolean;
53
+ error?: string;
54
+ status: 'VERIFYING' | 'CONNECTED' | 'ERROR' | 'IDLE' | null;
55
+ handleChange?: (id: string) => void;
56
+ handleReverify?: () => void;
57
+ handleDelete?: (shouldDelete: boolean) => void;
58
+ handleWillDelete?: () => void;
59
+ isReadOnly?: boolean;
60
+ forcedLoading?: boolean;
61
+ }) => {
62
+ const {
63
+ id,
64
+ value,
65
+ isChecked,
66
+ status = 'IDLE',
67
+ isDeleting = false,
68
+ willDelete = false,
69
+ handleChange,
70
+ handleReverify,
71
+ handleDelete = () => null,
72
+ handleWillDelete = () => null,
73
+ error,
74
+ isReadOnly,
75
+ } = props;
76
+ return html`
77
+ <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
78
+ <div class="${styles.checkboxRow} ${styles.buttonShadow}">
79
+ <div
80
+ class="${styles.connectedAccountRow} ${willDelete
81
+ ? styles.statusWrapShortWidth
82
+ : ''}"
83
+ >
84
+ <span class="${styles.connectedAccountValue}"
85
+ >${isTruncatable(value, 66) ? truncate(value, 66) : value}</span
86
+ >
87
+ <div class=${`${styles.statusWrap}`}>
88
+ <div class=${styles.status}>
89
+ <svg
90
+ width="12"
91
+ height="13"
92
+ viewBox="0 0 12 13"
93
+ fill="none"
94
+ xmlns="http://www.w3.org/2000/svg"
95
+ >
96
+ <circle cx="6" cy="6.5" r="6" fill="#C4E9D2" />
97
+ <path
98
+ d="M8.49951 4.5L5.22003 8.25L3.49951 6.28264"
99
+ stroke="#3BB568"
100
+ stroke-linecap="round"
101
+ />
102
+ </svg>
103
+ </div>
104
+ </div>
105
+ </div>
106
+
107
+ ${willDelete &&
108
+ !isDeleting &&
109
+ html` <${Confirmation} callback=${handleDelete} /> `}
110
+ ${!(status === 'VERIFYING' || isDeleting || willDelete) &&
111
+ !isReadOnly &&
112
+ html`
113
+ <div class=${styles.deleteIcon} onclick=${handleWillDelete}>
114
+ <svg
115
+ width="15"
116
+ height="15"
117
+ viewBox="0 0 15 15"
118
+ fill="none"
119
+ xmlns="http://www.w3.org/2000/svg"
120
+ >
121
+ <path d="M1.5 4.1999H13.65" stroke="#F05C42" />
122
+ <path
123
+ d="M11.6254 5.5498V6.2248L10.9504 13.6498H4.20039L3.52539 6.2248V5.5498"
124
+ stroke="#F05C42"
125
+ stroke-linejoin="round"
126
+ />
127
+ <path
128
+ 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"
129
+ stroke="#F05C42"
130
+ />
131
+ </svg>
132
+ </div>
133
+ `}
134
+ </div>
135
+ <//>
136
+ `;
137
+ };
138
+
139
+ const MarketplaceAppsCompact = (props: any) => {
140
+ const { genericData, renderMode, userConfig, appName } = props;
141
+ const context = useContext(AppContext);
142
+ const [apps, setApps] = useState<any[]>([]);
143
+ const [filteredApps, setFilteredApps] = useState<any[]>([]);
144
+ const [isFetchingApps, setIsFetchingApps] = useState<boolean>(true);
145
+ const [searchText, setSearchText] = useState<string>('');
146
+ const [totalApps, setTotalApps] = useState<number>(0);
147
+ const [cursor, setCursor] = useState<string>('');
148
+ const [filteredAppsCount, setFilteredAppsCount] = useState<number>(0);
149
+
150
+ const [loadingNextPage, setLoadingNextPage] = useState<boolean>(false);
151
+ const [searchInProgress, setSearchInProgress] = useState<boolean>(false);
152
+
153
+ const [selectedApp, setSelectedApp] = useState<any>(null);
154
+ const [
155
+ selectedAppConnectedAccounts,
156
+ setSelectedAppConnectedAccounts,
157
+ ] = useState<any[]>([]);
158
+ const [willDeleteAuthWithIndex, setWillDeleteAuthWithIndex] = useState<
159
+ number | null
160
+ >(null);
161
+ const [allowMultipleAuths, setAllowMultipleAuth] = useState<boolean>(true);
162
+
163
+ const DEBOUNCE_DELAY = 500;
164
+ const debounceTimeout = useRef<ReturnType<typeof setTimeout>>(0);
165
+
166
+ const getApps = ({
167
+ currentApps = <any>[],
168
+ search = '',
169
+ initialLoad = false,
170
+ nextCursor = '',
171
+ }) => {
172
+ setIsFetchingApps(true);
173
+
174
+ const cursorToUse = nextCursor || cursor;
175
+
176
+ context?.apiHandler
177
+ .getMarketplaceAppsV2({
178
+ cursor: search !== '' ? null : cursorToUse,
179
+ search,
180
+ })
181
+ .then((appsResponse) => {
182
+ const tempApps = appsResponse.apps.map((app: any) => ({
183
+ ...app,
184
+ }));
185
+ if (appsResponse._cursor || search === '') {
186
+ // we don't want to
187
+ setCursor(appsResponse._cursor);
188
+ }
189
+
190
+ setTotalApps(appsResponse.count || (tempApps || []).length);
191
+ if (search === '') {
192
+ setFilteredApps((prev) => [...prev, ...tempApps]);
193
+ } else {
194
+ setFilteredApps(tempApps);
195
+ }
196
+
197
+ if (initialLoad) {
198
+ setApps((prev) => [...prev, ...tempApps]);
199
+ }
200
+ setIsFetchingApps(false);
201
+ setLoadingNextPage(false);
202
+ setSearchInProgress(false);
203
+ })
204
+ .catch((error) => {
205
+ // eslint-disable-next-line no-console
206
+ console.log('error', { error });
207
+ setIsFetchingApps(false);
208
+ setLoadingNextPage(false);
209
+ setSearchInProgress(false);
210
+ });
211
+ };
212
+
213
+ const handleScroll = (e: any) => {
214
+ const bottom =
215
+ Math.floor(e.target.scrollHeight) ===
216
+ Math.floor(e.target.scrollTop + e.target.clientHeight);
217
+
218
+ if (bottom && !isFetchingApps && cursor && !loadingNextPage) {
219
+ // Trigger the next page load when at the bottom
220
+ setLoadingNextPage(true);
221
+ getApps({
222
+ currentApps: filteredApps,
223
+ search: searchText,
224
+ initialLoad: true, // we consider the next page to be part of the initial load
225
+ nextCursor: cursor, // Use the cursor for pagination
226
+ });
227
+ }
228
+ };
229
+
230
+ const filterApps = (inputString: string, items: any) => {
231
+ const cleanedInput = inputString.trim(); // Remove trailing spaces
232
+ setSearchInProgress(true);
233
+
234
+ if (cleanedInput === '') {
235
+ setFilteredApps(items); // Set the apps when there's no search input
236
+ return items;
237
+ }
238
+
239
+ setFilteredApps([]); // Clear the apps on each input change
240
+
241
+ // Clear the previous timeout to avoid executing the previous search
242
+ if (debounceTimeout.current) {
243
+ clearTimeout(debounceTimeout.current);
244
+ }
245
+
246
+ // Set a new debounce timeout to trigger the search after the delay
247
+ debounceTimeout.current = setTimeout(() => {
248
+ // Call the server-side function to fetch apps based on the search term
249
+ getApps({ currentApps: items, search: cleanedInput });
250
+ }, DEBOUNCE_DELAY); // Delay search until user stops typing
251
+
252
+ return [];
253
+ };
254
+
255
+ const handleGoBackToApps = () => {
256
+ setSelectedApp(null);
257
+ };
258
+
259
+ const onAuthResponseReceived = (messageEvent: MessageEvent<AuthData>) => {
260
+ if (isAuthMessage(messageEvent) && messageEvent.data.activity_name) {
261
+ const tempAccounts = [
262
+ ...selectedAppConnectedAccounts,
263
+ {
264
+ id: messageEvent.data.authorization_id,
265
+ display_name: messageEvent.data.user_identity,
266
+ },
267
+ ];
268
+ if (selectedApp && !selectedApp.allow_multiple_connected_accounts) {
269
+ setAllowMultipleAuth(false);
270
+ }
271
+ setSelectedAppConnectedAccounts(tempAccounts);
272
+ if (isBrowser())
273
+ window.removeEventListener('message', onAuthResponseReceived);
274
+ }
275
+ };
276
+
277
+ const openAuthWindow = () => {
278
+ if (isBrowser()) window.addEventListener('message', onAuthResponseReceived);
279
+ if (context && selectedApp && allowMultipleAuths) {
280
+ const url = selectedApp.login_url;
281
+ openPopupWindow(url, 'Auth Window', window, 800, 600);
282
+ }
283
+ };
284
+
285
+ const deleteAuth = (authIndex: number) => {
286
+ const auth = selectedAppConnectedAccounts[authIndex];
287
+
288
+ context?.apiHandler
289
+ .deleteAuth(auth.id)
290
+ .then((res) => {
291
+ if (res?.status === 200) {
292
+ if (selectedAppConnectedAccounts && authIndex >= 0) {
293
+ selectedAppConnectedAccounts.splice(authIndex, 1);
294
+ if (selectedAppConnectedAccounts.length === 0) {
295
+ setAllowMultipleAuth(true);
296
+ }
297
+ }
298
+
299
+ context.eventEmitter.emit('app-disconnected', selectedApp);
300
+ }
301
+ })
302
+ .catch((err) => {
303
+ console.error(err);
304
+ })
305
+ .finally(() => {
306
+ // setWillDeleteAuth(false);
307
+ // setIsDeletingAuth(false);
308
+ setWillDeleteAuthWithIndex(null);
309
+ });
310
+ };
311
+
312
+ const willDelete = (authIndex: number) => {
313
+ setWillDeleteAuthWithIndex(authIndex);
314
+ };
315
+
316
+ const getApp = (_appName: string) => {
317
+ context?.apiHandler.getApp(_appName).then((app) => {
318
+ setSelectedApp(app);
319
+ if (
320
+ app.allow_multiple_connected_accounts ||
321
+ app.connected_accounts.length === 0
322
+ ) {
323
+ setAllowMultipleAuth(true);
324
+ } else {
325
+ setAllowMultipleAuth(false);
326
+ }
327
+ setIsFetchingApps(false);
328
+ });
329
+ };
330
+
331
+ useEffect(() => {
332
+ if (appName && appName !== '') {
333
+ getApp(appName);
334
+ } else {
335
+ getApps({
336
+ currentApps: apps,
337
+ search: '',
338
+ initialLoad: true,
339
+ });
340
+ }
341
+ }, []);
342
+
343
+ useEffect(() => {
344
+ setSelectedAppConnectedAccounts(selectedApp?.connected_accounts || []);
345
+ }, [selectedApp]);
346
+ return html`
347
+ <div
348
+ id="embed--appsContainer"
349
+ class="${renderMode === 'INLINE'
350
+ ? styles.appsContainerInline
351
+ : styles.appsContainer}
352
+ ${genericData.viewStyle === ViewStyles.COMPACT
353
+ ? styles['compact-view']
354
+ : ''} embed--appsContainer--${renderMode}"
355
+ style="${renderMode === 'INLINE' && props.showMarketplaceModal
356
+ ? 'display: flex;'
357
+ : ''}"
358
+ >
359
+ <div
360
+ id="apps-header"
361
+ class="${styles.appsHeader} ${selectedApp
362
+ ? styles.appsHeaderWithBorder
363
+ : ''}"
364
+ >
365
+ ${selectedApp
366
+ ? html`
367
+ <div class="${styles.backLink} ${styles.appsHeaderTitle}">
368
+ ${!appName &&
369
+ html`<svg
370
+ width="33"
371
+ height="33"
372
+ viewBox="0 0 33 33"
373
+ fill="none"
374
+ xmlns="http://www.w3.org/2000/svg"
375
+ onclick=${handleGoBackToApps}
376
+ >
377
+ <circle
378
+ cx="16.6758"
379
+ cy="16.5684"
380
+ r="15.5"
381
+ fill="white"
382
+ stroke="#E0E0E0"
383
+ />
384
+ <path
385
+ 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
386
+ 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
387
+ 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
388
+ 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
389
+ 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
390
+ 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"
391
+ fill="#4250F0"
392
+ />
393
+ </svg>`}
394
+ ${selectedApp &&
395
+ html`<img
396
+ src=${selectedApp.icon_url}
397
+ title="${selectedApp.title}"
398
+ />`}
399
+
400
+ <p class="${styles.backLabel}">
401
+ ${selectedApp ? selectedApp.title : 'Apps'}
402
+ </p>
403
+ </div>
404
+ `
405
+ : html`
406
+ <p id="appsHeaderTitle" class=${styles.appsHeaderTitle}>
407
+ ${(() => {
408
+ if (selectedApp) {
409
+ return selectedApp.title;
410
+ }
411
+ if (appName) {
412
+ return 'Loading...';
413
+ }
414
+ return 'Apps';
415
+ })()}
416
+ </p>
417
+ `}
418
+ ${!selectedApp &&
419
+ !appName &&
420
+ html`<div id="search-container" class=${styles.searchContainer}>
421
+ <svg
422
+ xmlns="http://www.w3.org/2000/svg"
423
+ width="15"
424
+ height="15"
425
+ viewBox="0 0 15 15"
426
+ fill="none"
427
+ >
428
+ <path
429
+ 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"
430
+ fill="#BDBDBD"
431
+ />
432
+ </svg>
433
+ <input
434
+ id="search-apps-flow-lifecycle"
435
+ class=${styles.searchInput}
436
+ placeholder="${userConfig.searchPlaceholder || 'Search for apps'}"
437
+ value=${searchText}
438
+ oninput=${(e: any) => {
439
+ setSearchText(e.target.value);
440
+ filterApps(e.target.value, apps);
441
+ }}
442
+ />
443
+ ${searchText !== '' &&
444
+ html` <svg
445
+ class=${styles.clearCta}
446
+ onclick=${() => {
447
+ setSearchText('');
448
+ filterApps('', apps);
449
+ }}
450
+ xmlns="http://www.w3.org/2000/svg"
451
+ width="12"
452
+ height="12"
453
+ viewBox="0 0 12 12"
454
+ fill="none"
455
+ >
456
+ <path
457
+ d="M10.2426 10.2425L1.75732 1.75732"
458
+ stroke="#333333"
459
+ stroke-width="1.33333"
460
+ stroke-linecap="round"
461
+ />
462
+ <path
463
+ d="M10.2426 1.75732L1.75732 10.2425"
464
+ stroke="#333333"
465
+ stroke-width="1.33333"
466
+ stroke-linecap="round"
467
+ />
468
+ </svg>`}
469
+ </div>`}
470
+ </div>
471
+
472
+ ${true &&
473
+ filteredApps.length < 1 &&
474
+ !selectedApp &&
475
+ html` <div
476
+ id="appsForFlowsCardsNoAppFound"
477
+ class=${styles.appsForFlowsCardsNoAppFound}
478
+ >
479
+ ${searchText !== '' &&
480
+ html` ${isFetchingApps && html`<${LargeLoader} />`}
481
+ ${!searchInProgress && html`<p>Sorry, no apps found.</p>`}`}
482
+ ${searchText === '' &&
483
+ html` ${isFetchingApps && html`<${LargeLoader} />`}
484
+ ${!isFetchingApps && html`<p>Sorry, no apps found.</p>`}`}
485
+ </div>`}
486
+ ${true &&
487
+ (filteredApps.length > 0 || selectedApp) &&
488
+ html`
489
+ ${selectedApp
490
+ ? html`<div
491
+ class="${styles.marketplaceAuthSelectorWrap} integry-container__auth-selector"
492
+ >
493
+ <div class="${styles.heading}">Connected Accounts</div>
494
+ <div class=${styles.rows}>
495
+ ${selectedAppConnectedAccounts.map(
496
+ (el: any, index: number) => html`<${AuthorizationRow}
497
+ id=${el.id}
498
+ value=${el.display_name}
499
+ status=${`CONNECTED`}
500
+ handleDelete=${(shouldDelete: boolean) =>
501
+ shouldDelete
502
+ ? deleteAuth(index)
503
+ : setWillDeleteAuthWithIndex(null)}
504
+ handleWillDelete=${() => willDelete(index)}
505
+ willDelete=${willDeleteAuthWithIndex === index}
506
+ />`,
507
+ )}
508
+ </div>
509
+ ${true &&
510
+ html`
511
+ <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
512
+ <div
513
+ data-hint="${allowMultipleAuths
514
+ ? ''
515
+ : `You cannot connect more than one account for ${selectedApp.title}.`}"
516
+ class="${styles.checkboxRow} ${styles.buttonShadow} ${styles.marketplaceAddAccountBtn} ${allowMultipleAuths
517
+ ? ''
518
+ : styles.disabled}"
519
+ onclick=${openAuthWindow}
520
+ >
521
+ <span>+</span>
522
+ <p>Add account</p>
523
+ </div>
524
+ <//>
525
+ `}
526
+ </div>`
527
+ : html`<div
528
+ id="${`embed--appsForFlowsCardsComfortable__${renderMode}`}"
529
+ onscroll=${handleScroll}
530
+ class="${props.genericData.viewStyle === ViewStyles.COMPACT
531
+ ? styles.appsForFlowsCardsCompact
532
+ : styles.appsForFlowsCards}"
533
+ >
534
+ ${filteredApps.map(
535
+ (app: any) =>
536
+ html`
537
+ <${genericData.viewStyle === ViewStyles.COMPACT
538
+ ? AppCardCompact
539
+ : AppCard}
540
+ key=${app.id}
541
+ app=${app}
542
+ onAppClick=${(appClicked: any) => {
543
+ setSelectedApp(appClicked);
544
+ }}
545
+ />
546
+ `,
547
+ )}
548
+ ${cursor &&
549
+ html`<div
550
+ class="${styles.loadMore}"
551
+ onclick=${() => {
552
+ getApps({
553
+ currentApps: apps,
554
+ });
555
+ }}
556
+ >
557
+ ${loadingNextPage
558
+ ? html`<${ThreeDotLoader} color="#999" />`
559
+ : html``}
560
+ </div>`}
561
+ </div>`}
562
+ `}
563
+ ${!isFetchingApps &&
564
+ html`<${Footer}
565
+ style=${renderMode === 'INLINE'
566
+ ? 'padding-top: 12px;'
567
+ : 'padding-top: 12px; box-shadow: 0px -6px 10px 0px rgba(255, 255, 255, 0.8);'}
568
+ />`}
569
+ </div>
570
+ `;
571
+ };
572
+
573
+ export default connect<StoreType, unknown, StoreType, unknown>(
574
+ ['genericData', 'userConfig', 'showMarketplaceModal'],
575
+ actionFunctions,
576
+ )(MarketplaceAppsCompact);