@integry/sdk 4.5.2 → 4.5.3

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 +1790 -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,537 @@
1
+ import { html, Component } from 'htm/preact';
2
+ import { connect } from 'unistore/preact';
3
+
4
+ import { Loader } from '@/components/Loader';
5
+ import { IntegryAPI } from '@/modules/api';
6
+ import { Radio } from '@/components/RadioGroup/Radio';
7
+ import { Button, ButtonTypes } from '@/components/Button';
8
+ import { ErrorMessage } from '@/components/ErrorMessage';
9
+ import { Label } from '@/components/Label';
10
+ import { Hint } from '@/components/Tooltip';
11
+ import { Authorization, StoreType } from '@/types/store';
12
+ import { actionFunctions } from '@/store';
13
+ import isBrowser from '@/utils/isBrowser';
14
+ import AppContext from '@/contexts/AppContext';
15
+
16
+ import { openPopupWindow } from '@/utils/popup';
17
+ import { AuthData, isAuthMessage } from '@/utils/isAuthMessage';
18
+
19
+ import styles from './styles.module.scss';
20
+
21
+ interface AuthSelectorPropsType extends StoreType {
22
+ stepId: number;
23
+ apiHandler: IntegryAPI;
24
+ showErrors?: boolean;
25
+ onAuthSelected(
26
+ authId: number | null,
27
+ isVerified: boolean,
28
+ override: boolean,
29
+ ): void;
30
+ forcedLoading?: boolean;
31
+ isReadOnly?: boolean;
32
+ }
33
+
34
+ interface AuthSelectorStateType {
35
+ isLoading: boolean;
36
+ fetched: boolean;
37
+ willDeleteAuthWithIndex: number | null;
38
+ }
39
+
40
+ const Confirmation = (props: { callback(shouldDelete: boolean): void }) => {
41
+ const { callback } = props;
42
+ return html`
43
+ <div class=${styles.confirmation}>
44
+ <div class=${styles.confirmationText}>Are you sure?</div>
45
+ <button onclick=${() => callback(false)}>No</button>
46
+ <button onclick=${() => callback(true)}>Yes</button>
47
+ </div>
48
+ `;
49
+ };
50
+
51
+ const Resend = () => html`
52
+ <svg
53
+ class=${styles.resend}
54
+ width="13"
55
+ height="15"
56
+ viewBox="0 0 13 15"
57
+ fill="none"
58
+ xmlns="http://www.w3.org/2000/svg"
59
+ >
60
+ <path
61
+ d="M11.8403 5.34L10.1453 6.345C10.5053 6.96 10.7003 7.68 10.7003 8.445C10.7003 10.77 8.81031 12.645 6.50031 12.645C4.19031 12.645 2.30031 10.755 2.30031 8.445C2.30031 6.135 4.19031 4.245 6.50031 4.245V6.15L11.1053 3.27L6.50031 0.375V2.28C3.09531 2.28 0.320312 5.055 0.320312 8.46C0.320313 11.85 3.09531 14.625 6.50031 14.625C9.90531 14.625 12.6803 11.85 12.6803 8.445C12.6803 7.32 12.3653 6.255 11.8403 5.34Z"
62
+ fill="#8D8D8D"
63
+ />
64
+ </svg>
65
+ `;
66
+
67
+ const AuthorizationRow = (props: {
68
+ id: string;
69
+ value: string;
70
+ isChecked?: boolean;
71
+ isLoading: boolean;
72
+ willDelete?: boolean;
73
+ isDeleting?: boolean;
74
+ error?: string;
75
+ status: 'VERIFYING' | 'CONNECTED' | 'ERROR' | 'IDLE' | null;
76
+ handleChange?: (id: string) => void;
77
+ handleReverify?: () => void;
78
+ handleDelete?: (shouldDelete: boolean) => void;
79
+ handleWillDelete?: () => void;
80
+ isReadOnly?: boolean;
81
+ forcedLoading?: boolean;
82
+ }) => {
83
+ const {
84
+ id,
85
+ value,
86
+ isChecked,
87
+ status = 'IDLE',
88
+ isDeleting = false,
89
+ willDelete = false,
90
+ handleChange,
91
+ handleReverify,
92
+ handleDelete = () => null,
93
+ handleWillDelete = () => null,
94
+ error,
95
+ isReadOnly,
96
+ } = props;
97
+ return html`
98
+ <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
99
+ <div class=${styles.checkboxRow}>
100
+ ${isReadOnly &&
101
+ html`<span
102
+ class=${styles.readonlyHint}
103
+ data-hint=${isReadOnly ? `Cannot modify user selection` : ''}
104
+ ></span>`}
105
+ <div class=${`${styles.radio} ${isReadOnly ? styles.readonly : ''}`}>
106
+ <${Radio}
107
+ id=${id}
108
+ value=${value}
109
+ isChecked=${isChecked}
110
+ onChange=${handleChange}
111
+ isDisabled=${isReadOnly}
112
+ className="authRadio"
113
+ />
114
+ </div>
115
+ <div
116
+ class=${`${styles.statusWrap} ${isReadOnly ? styles.readonly : ''}`}
117
+ >
118
+ <div class=${styles.status}>
119
+ ${isReadOnly
120
+ ? html`
121
+ ${isChecked &&
122
+ html`<div>
123
+ <div class=${styles.statusGreen} />
124
+ Connected
125
+ </div>`}
126
+ `
127
+ : html`
128
+ <div>
129
+ ${status === 'VERIFYING' &&
130
+ !isDeleting &&
131
+ html`<div class=${styles.statusOrange} />
132
+ Verifying <${Loader} /> `}
133
+ </div>
134
+ <div>
135
+ ${status === 'CONNECTED' &&
136
+ !error &&
137
+ !isDeleting &&
138
+ html`<div class=${styles.statusGreen} />
139
+ Connected`}
140
+ </div>
141
+ <div>
142
+ ${status === 'ERROR' &&
143
+ !isDeleting &&
144
+ html`<div class=${styles.statusRed} />
145
+ Failed
146
+ ${!isReadOnly &&
147
+ html`<div onclick=${handleReverify}>
148
+ <${Resend} />
149
+ </div>`} `}
150
+ </div>
151
+ ${isDeleting && html`<${Loader} />`}
152
+ ${error &&
153
+ !isDeleting &&
154
+ !(status === 'VERIFYING') &&
155
+ html`<div class=${styles.error}>${error}</div>`}
156
+ `}
157
+ </div>
158
+ </div>
159
+ ${willDelete &&
160
+ !isDeleting &&
161
+ html` <${Confirmation} callback=${handleDelete} /> `}
162
+ ${!(status === 'VERIFYING' || isDeleting || willDelete) &&
163
+ !isReadOnly &&
164
+ html`
165
+ <div class=${styles.deleteIcon} onclick=${handleWillDelete}>
166
+ <svg
167
+ width="15"
168
+ height="15"
169
+ viewBox="0 0 15 15"
170
+ fill="none"
171
+ xmlns="http://www.w3.org/2000/svg"
172
+ >
173
+ <path d="M1.5 4.1999H13.65" stroke="#F05C42" />
174
+ <path
175
+ d="M11.6254 5.5498V6.2248L10.9504 13.6498H4.20039L3.52539 6.2248V5.5498"
176
+ stroke="#F05C42"
177
+ stroke-linejoin="round"
178
+ />
179
+ <path
180
+ 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"
181
+ stroke="#F05C42"
182
+ />
183
+ </svg>
184
+ </div>
185
+ `}
186
+ </div>
187
+ <//>
188
+ `;
189
+ };
190
+
191
+ class AuthSelector extends Component<
192
+ AuthSelectorPropsType,
193
+ AuthSelectorStateType
194
+ > {
195
+ static contextType = AppContext;
196
+
197
+ constructor(props: AuthSelectorPropsType) {
198
+ super(props);
199
+ this.state = {
200
+ isLoading: false,
201
+ fetched: false,
202
+ willDeleteAuthWithIndex: null,
203
+ };
204
+ }
205
+
206
+ componentDidMount() {
207
+ if (isBrowser())
208
+ window.addEventListener('message', this.onAuthResponseReceived);
209
+
210
+ // in preview mode, auto-verify the auth we pass
211
+ const { stepId, stepMapping } = this.props;
212
+ let auth = stepMapping[stepId].selectedAuthId;
213
+ if (!auth && stepMapping[stepId].authorizations.length > 0) {
214
+ auth = stepMapping[stepId].authorizations[0].authorizationId;
215
+ }
216
+ let authIndex = stepMapping[stepId].authorizations.findIndex(
217
+ (el) => el.authorizationId === auth,
218
+ );
219
+ if(stepMapping[stepId].authorizations.length > 0 && authIndex === -1) {
220
+ authIndex = 0;
221
+ }
222
+ const authStatus = this.getAuthStatus(
223
+ stepMapping[stepId].authorizations[authIndex] || auth,
224
+ );
225
+ // auth is selected but is in idle state
226
+ if (stepMapping[stepId].selectedAuthId && authStatus === 'IDLE') {
227
+ this.verifyAuth(authIndex, true);
228
+ } else if (!stepMapping[stepId].selectedAuthId && authIndex !== -1) {
229
+ this.verifyAuth(authIndex, true);
230
+ } else if (auth) {
231
+ this.verifyAuth(0, true);
232
+ }
233
+ }
234
+
235
+ componentDidUpdate(prevProps: AuthSelectorPropsType) {
236
+ const { stepId, stepMapping } = this.props;
237
+ const step = stepMapping[stepId];
238
+ const authId = step.selectedAuthId;
239
+
240
+ const authIndex = stepMapping[stepId].authorizations.findIndex(
241
+ (el) => el.authorizationId === authId,
242
+ );
243
+
244
+ const auth = stepMapping[stepId].authorizations[authIndex];
245
+
246
+ const authStatus = this.getAuthStatus(
247
+ stepMapping[stepId].authorizations[authIndex],
248
+ );
249
+
250
+ // verify auth whenever we select a new one
251
+ // if (authId !== prevProps.stepMapping[stepId].selectedAuthId && authIndex) {
252
+ // console.log('verifying 1');
253
+
254
+ // this.verifyAuth(authIndex);
255
+ // }
256
+ if (
257
+ step.authorizations.length ===
258
+ prevProps.stepMapping[stepId].authorizations.length + 1
259
+ ) {
260
+ // auth was added so we verify
261
+ this.verifyAuth(step.authorizations.length - 1);
262
+ }
263
+ // verify auth in edit mode when step changes
264
+ if (
265
+ authStatus === 'IDLE' &&
266
+ !auth.isVerifying &&
267
+ !auth.isVerified &&
268
+ !this.state.isLoading
269
+ ) {
270
+ this.verifyAuth(authIndex, true);
271
+ }
272
+ }
273
+
274
+ componentWillUnmount() {
275
+ if (isBrowser())
276
+ window.removeEventListener('message', this.onAuthResponseReceived);
277
+ }
278
+
279
+ private verifyAuth = (authIndex: number, override?: boolean) => {
280
+ const { stepId } = this.props;
281
+ const auth = this.props.stepMapping[stepId].authorizations[authIndex];
282
+
283
+ if (!auth) return;
284
+
285
+ const isAuthVerifiedInPreviewMode =
286
+ !this.props.genericData.isPreviewMode && auth.isVerified;
287
+ const hideAuhtorizationStatus = !this.props.stepMapping[stepId]
288
+ .isUserinfoRequired;
289
+
290
+ if (isAuthVerifiedInPreviewMode || hideAuhtorizationStatus) {
291
+ this.props.onAuthSelected(auth.authorizationId, true, !!override);
292
+ this.context.eventEmitter.emit('did-select-authorization', {
293
+ authorizationId: Number(auth.authorizationId),
294
+ });
295
+ return;
296
+ }
297
+
298
+ this.setState({ isLoading: true });
299
+ this.props.toggleVerifyAuthorizationFlag({
300
+ stepId,
301
+ authId: auth.authorizationId,
302
+ isVerifying: true,
303
+ });
304
+
305
+ this.props.apiHandler
306
+ .verifyOAuth(auth.authorizationId)
307
+ .then((res) => {
308
+ if (res) {
309
+ this.props.onAuthSelected(auth.authorizationId, true, !!override);
310
+ this.context.eventEmitter.emit('did-select-authorization', {
311
+ authorizationId: Number(auth.authorizationId),
312
+ });
313
+ } else {
314
+ this.props.onAuthSelected(auth.authorizationId, false, !!override);
315
+ }
316
+ })
317
+ .catch((err) => console.error(err))
318
+ .finally(() => {
319
+ this.props.toggleVerifyAuthorizationFlag({
320
+ stepId,
321
+ authId: auth.authorizationId,
322
+ isVerifying: false,
323
+ });
324
+ this.setState({ isLoading: false });
325
+ });
326
+ };
327
+
328
+ private willDelete = (authIndex: number) => {
329
+ this.setState({
330
+ willDeleteAuthWithIndex: authIndex,
331
+ });
332
+ };
333
+
334
+ private deleteAuth = (authIndex: number) => {
335
+ const { stepId } = this.props;
336
+ const auth = this.props.stepMapping[stepId].authorizations[authIndex];
337
+
338
+ this.props.toggleDeleteAuthorizationFlag({
339
+ stepId,
340
+ authId: auth.authorizationId,
341
+ isDeleting: true,
342
+ error: '',
343
+ });
344
+
345
+ this.context.eventEmitter.emit('did-begin-remove-authorization', {
346
+ authorizationId: Number(auth.authorizationId),
347
+ });
348
+
349
+ this.props.apiHandler
350
+ .deleteAuth(auth.authorizationId)
351
+ .then((res) => {
352
+ if (res?.status === 200) {
353
+ this.props.removeAuthorization({
354
+ stepId,
355
+ authId: auth.authorizationId,
356
+ });
357
+ this.context.eventEmitter.emit('did-remove-authorization', {
358
+ authorizationId: Number(auth.authorizationId),
359
+ appId: this.props.genericData.app_id || '',
360
+ });
361
+ } else if (res?.status === 405) {
362
+ // we have a deletion error
363
+ this.props.toggleDeleteAuthorizationFlag({
364
+ stepId,
365
+ authId: auth.authorizationId,
366
+ isDeleting: false,
367
+ error: `${res.data}`,
368
+ });
369
+ } else {
370
+ this.props.toggleDeleteAuthorizationFlag({
371
+ stepId,
372
+ authId: auth.authorizationId,
373
+ isDeleting: false,
374
+ error: 'An unexpected error occurred',
375
+ });
376
+ }
377
+ })
378
+ .catch((err) => {
379
+ console.error(err);
380
+ })
381
+ .finally(() => this.setState({ willDeleteAuthWithIndex: null }));
382
+ };
383
+
384
+ private onAuthResponseReceived = (messageEvent: MessageEvent<AuthData>) => {
385
+ if (isAuthMessage(messageEvent) && messageEvent.data.activity_name) {
386
+ console.info(messageEvent.data);
387
+ if (this.props.stepId) {
388
+ const { stepId } = this.props;
389
+ const authApp = this.props.stepMapping[stepId]?.step?.activity?.app;
390
+ if (!messageEvent.data.already_exists) {
391
+ this.props.addAuthorization({
392
+ stepId: this.props.stepId,
393
+ authData: {
394
+ authorizationId: messageEvent.data.authorization_id,
395
+ userIdentity: messageEvent.data.user_identity,
396
+ disableLink: '',
397
+ authType: '',
398
+ isVerified: false,
399
+ didFetchStatus: false,
400
+ isVerifying: false,
401
+ isDeleting: false,
402
+ error: '',
403
+ },
404
+ });
405
+ } else {
406
+ this.props.setStepAuthId({
407
+ stepId: this.props.stepId,
408
+ authId: Number(messageEvent.data.authorization_id),
409
+ });
410
+ }
411
+ this.context.eventEmitter.emit('did-add-authorization', {
412
+ identity: messageEvent.data.user_identity,
413
+ authorizationId: Number(messageEvent.data.authorization_id),
414
+ flowId: this.props.genericData.templateId,
415
+ appId: authApp.id || '',
416
+ appName: authApp?.name,
417
+ appIcon: authApp?.icon_url,
418
+ alreadyExists: messageEvent.data.already_exists,
419
+ externalId: messageEvent.data.external_id,
420
+ });
421
+ }
422
+ }
423
+ };
424
+
425
+ private getAuthStatus = (auth: Authorization) => {
426
+ const { stepId } = this.props;
427
+ if (!auth) return null;
428
+ let status = 'IDLE';
429
+ const hideAuhtorizationStatus = !this.props.stepMapping[stepId]
430
+ .isUserinfoRequired;
431
+ if (hideAuhtorizationStatus) {
432
+ return status;
433
+ }
434
+ if (auth.isVerified && auth.didFetchStatus) status = 'CONNECTED';
435
+ if (!auth.isVerified && auth.didFetchStatus) status = 'ERROR';
436
+ if (auth.isVerifying) status = 'VERIFYING';
437
+ return status;
438
+ };
439
+
440
+ private getError = () => {
441
+ const { stepId } = this.props;
442
+ const step = this.props.stepMapping[stepId];
443
+ if (!step.authorizations) {
444
+ return `Please add a valid ${
445
+ step.step.authorization_type.app?.name || step.step.activity.app.name
446
+ } account`;
447
+ }
448
+ return `Please select a valid ${
449
+ step.step.authorization_type.app?.name || step.step.activity.app.name
450
+ } account`;
451
+ };
452
+
453
+ public openAuthWindow = () => {
454
+ const { stepMapping, stepId } = this.props;
455
+ const selectedStep = stepMapping[stepId].step;
456
+ if (selectedStep) {
457
+ const url = this.context.apiHandler.getAuthUrl(
458
+ selectedStep.authorization_type.id,
459
+ );
460
+ openPopupWindow(url, 'Auth Window', window, 800, 600);
461
+ }
462
+ };
463
+
464
+ render() {
465
+ const { stepId, showErrors = false, forcedLoading = false } = this.props;
466
+ const step = this.props.stepMapping[stepId];
467
+ const { authorizations } = step;
468
+ const isReadOnly = this.context?.isReadOnly || this.props.isReadOnly;
469
+ if (forcedLoading) {
470
+ return html`
471
+ <div style="margin-top:-74px; display: flex; justify-content: center;">
472
+ <${Loader} />
473
+ </div>
474
+ `;
475
+ }
476
+ return html`
477
+ <div class="${styles.authSelectorWrap} integry-container__auth-selector">
478
+ <${Label}
479
+ title="Connect account"
480
+ description=${`Select your ${
481
+ step.step.authorization_type.app?.name ||
482
+ step.step.activity.app.name
483
+ } account`}
484
+ isRequired=${true}
485
+ />
486
+ <div class=${styles.rows}>
487
+ ${authorizations.map(
488
+ (el, index) => html`<${AuthorizationRow}
489
+ id=${el.authorizationId}
490
+ value=${el.userIdentity}
491
+ status=${this.getAuthStatus(el)}
492
+ isChecked=${el.authorizationId === step.selectedAuthId}
493
+ isDeleting=${el.isDeleting}
494
+ willDelete=${this.state.willDeleteAuthWithIndex === index}
495
+ error=${el.error}
496
+ handleChange=${() => this.verifyAuth(index)}
497
+ handleReverify=${() => this.verifyAuth(index)}
498
+ handleDelete=${(shouldDelete: boolean) =>
499
+ shouldDelete
500
+ ? this.deleteAuth(index)
501
+ : this.setState({ willDeleteAuthWithIndex: null })}
502
+ handleWillDelete=${() => this.willDelete(index)}
503
+ isReadOnly=${isReadOnly}
504
+ />`,
505
+ )}
506
+ </div>
507
+ ${!isReadOnly &&
508
+ html`
509
+ <div class=${showErrors ? `${styles.error}` : ''}>
510
+ <${Button}
511
+ onClick=${() =>
512
+ !this.props.genericData.isPreviewMode && this.openAuthWindow()}
513
+ label=${`Add ${step.step.authorization_type.app.name} account`}
514
+ type=${ButtonTypes.SECONDARY}
515
+ disabled=${this.state.isLoading ||
516
+ this.props.genericData.isPreviewMode}
517
+ tooltip=${this.props.genericData.isPreviewMode &&
518
+ 'New accounts cannot be added in preview mode'}
519
+ >
520
+ <//>
521
+ </div>
522
+ ${showErrors && html`<${ErrorMessage}>${this.getError()}<//>`}
523
+ `}
524
+ </div>
525
+ `;
526
+ }
527
+ }
528
+
529
+ export default connect<
530
+ AuthSelectorPropsType,
531
+ AuthSelectorStateType,
532
+ StoreType,
533
+ unknown
534
+ >(
535
+ ['stepMapping', 'genericData'],
536
+ actionFunctions,
537
+ )(AuthSelector);
@@ -0,0 +1,161 @@
1
+ .authSelectorWrap {
2
+ .label {
3
+ font-weight: 800;
4
+ font-size: 14px;
5
+ color: #333333;
6
+ line-height: 20px;
7
+ margin-bottom: 5px;
8
+
9
+ span {
10
+ color: #ff4d34;
11
+ margin-left: 2px;
12
+ font-size: 16px;
13
+ }
14
+ }
15
+
16
+ .confirmation {
17
+ display: flex;
18
+ align-items: center;
19
+ width: 35%;
20
+ button {
21
+ cursor: pointer;
22
+ -webkit-appearance: button;
23
+ font-weight: 500;
24
+ font-size: 12px;
25
+ line-height: 15px;
26
+ /* identical to box height */
27
+ padding: 4px 12px;
28
+
29
+ text-align: center;
30
+ border-radius: 12px;
31
+ border: 0;
32
+ outline: none;
33
+
34
+ color: #7e7a8f;
35
+ background-color: #f1f1f1;
36
+
37
+ &:nth-child(2) {
38
+ color: #ffffff;
39
+ margin-left: 10px;
40
+ margin-right: 10px;
41
+ background-color: #f05c42;
42
+ }
43
+ }
44
+ }
45
+ .rows {
46
+ margin-top: 24px;
47
+ margin-bottom: 24px;
48
+ }
49
+
50
+ .error {
51
+ color: #f05c42;
52
+ button {
53
+ color: #f05c42;
54
+ border-color: #f05c42;
55
+ }
56
+ }
57
+
58
+ .errorMessage {
59
+ margin-top: 4px;
60
+ font-size: 12px;
61
+ line-height: 15px;
62
+ letter-spacing: -0.197647px;
63
+ color: #f05c42;
64
+ }
65
+
66
+ .description {
67
+ font-size: 14px;
68
+ line-height: 20px;
69
+ color: #8c8c8c;
70
+ margin-bottom: 10px;
71
+ }
72
+
73
+ .checkboxRow {
74
+ display: flex;
75
+ align-items: center;
76
+ color: #333;
77
+ font-size: 14px;
78
+ margin-bottom: 16px;
79
+
80
+ .radio {
81
+ width: 45%;
82
+ overflow: hidden;
83
+ text-overflow: ellipsis;
84
+ white-space: nowrap;
85
+ &.readonly {
86
+ width: 70%;
87
+ }
88
+ }
89
+ .deleteIcon {
90
+ width: 200px;
91
+ padding-left: 8px;
92
+ padding-right: 8px;
93
+ display: flex;
94
+ align-items: center;
95
+ cursor: pointer;
96
+ svg {
97
+ cursor: pointer;
98
+ visibility: hidden;
99
+ user-select: none;
100
+ }
101
+ }
102
+ .statusWrap {
103
+ display: flex;
104
+ align-items: center;
105
+ font-size: 12px;
106
+ width: 20%;
107
+ &.readonly {
108
+ width: 30%;
109
+ }
110
+ .status {
111
+ position: relative;
112
+ width: 200px;
113
+ div {
114
+ display: flex;
115
+ align-items: center;
116
+ }
117
+ svg {
118
+ margin-left: 8px;
119
+ }
120
+ .statusRed,
121
+ .statusOrange,
122
+ .statusGreen {
123
+ width: 5px;
124
+ height: 5px;
125
+ border-radius: 9999px;
126
+ margin: 0 8px;
127
+ }
128
+ .statusRed {
129
+ background: #e26154;
130
+ }
131
+ .statusOrange {
132
+ background: #fcc700;
133
+ }
134
+
135
+ .statusGreen {
136
+ background: #2ecc71;
137
+ }
138
+
139
+ span {
140
+ margin-left: 10px;
141
+ }
142
+ .resend {
143
+ cursor: pointer;
144
+ }
145
+ }
146
+ }
147
+ &:hover {
148
+ .deleteIcon svg {
149
+ visibility: visible;
150
+ user-select: auto;
151
+ }
152
+ }
153
+ .readonlyHint {
154
+ position: absolute;
155
+ width: 40%;
156
+ height: -webkit-fill-available;
157
+ z-index: 99;
158
+ margin: 10px 0px;
159
+ }
160
+ }
161
+ }