@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,208 @@
1
+ .listboxGroupWrapper {
2
+ fieldset {
3
+ margin: 0;
4
+ padding: 0;
5
+ border: none;
6
+ margin-bottom: 16px !important;
7
+ }
8
+ }
9
+
10
+ .listbox {
11
+ position: relative;
12
+ max-width: 100%;
13
+ user-select: none;
14
+ .customSelect {
15
+ position: relative;
16
+ display: flex;
17
+ flex-direction: column;
18
+ font-size: 14px;
19
+ font-family: inherit;
20
+ letter-spacing: -0.2px;
21
+ color: #999999;
22
+
23
+ &.open .customOptions {
24
+ opacity: 1;
25
+ visibility: visible;
26
+ pointer-events: auto;
27
+ }
28
+ .readonlyHint {
29
+ width: 100%;
30
+ height: 100%;
31
+ z-index: 99;
32
+ position: absolute;
33
+ }
34
+ }
35
+ .disabled {
36
+ background: #eee;
37
+ }
38
+ .customSelectTrigger {
39
+ position: relative;
40
+ display: flex;
41
+ align-items: center;
42
+ box-sizing: border-box;
43
+ height: 40px;
44
+ padding: 0 10px;
45
+ justify-content: space-between;
46
+ cursor: pointer;
47
+ font-size: 12px;
48
+ font-family: inherit;
49
+ border: 1px solid #e2e0db;
50
+ border-radius: 4px;
51
+ span {
52
+ display: flex;
53
+ flex: 1;
54
+ align-items: center;
55
+ height: 100%;
56
+ padding-right: 10px;
57
+ white-space: nowrap;
58
+ overflow: hidden;
59
+ text-overflow: ellipsis;
60
+ &.selected {
61
+ color: #333333;
62
+ }
63
+ }
64
+ &:focus {
65
+ outline: none;
66
+ }
67
+ // &.error {
68
+ // border-color: #f05c42;
69
+ // }
70
+ /* &.searchable {
71
+ // cursor: text;
72
+ } */
73
+ .arrow {
74
+ transform: rotate(0);
75
+ cursor: pointer;
76
+ transition-property: transform;
77
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
78
+ transition-duration: 150ms;
79
+ &.close {
80
+ transform: rotate(180deg);
81
+ }
82
+ &.readonly {
83
+ cursor: auto;
84
+ }
85
+ &.isTagged {
86
+ margin-right: 40px;
87
+ }
88
+ }
89
+ .searchInput {
90
+ border: 0;
91
+ outline: none;
92
+ width: 100%;
93
+ color: #333;
94
+ font-size: 12px;
95
+ font-family: inherit;
96
+ padding: 0;
97
+ margin: 0;
98
+ height: 100%;
99
+ &::placeholder {
100
+ color: #999999;
101
+ }
102
+ }
103
+ &.readonly {
104
+ cursor: auto;
105
+ }
106
+
107
+ button {
108
+ margin-bottom: -1px;
109
+ margin-right: -1px;
110
+ }
111
+ }
112
+ .customOptions {
113
+ position: absolute;
114
+ top: 100%;
115
+ left: 0px;
116
+ right: 0px;
117
+ z-index: 10;
118
+ margin-top: 10px;
119
+ display: block;
120
+ overflow: hidden;
121
+ background-color: #fff;
122
+ font-family: inherit;
123
+ font-size: 14px;
124
+ line-height: 20px;
125
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
126
+ transition-property: all;
127
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
128
+ transition-duration: 150ms;
129
+ pointer-events: none;
130
+ visibility: hidden;
131
+ max-height: 132px;
132
+ min-height: 100%;
133
+ overflow-y: auto;
134
+ border-width: 1px;
135
+ border-style: solid;
136
+ border-color: #e2e0db;
137
+ opacity: 0;
138
+ border-radius: 4px;
139
+ &::-webkit-scrollbar {
140
+ width: 7px;
141
+ }
142
+
143
+ /* Track */
144
+ &::-webkit-scrollbar-track {
145
+ // background: #f1f1f1;
146
+ background: transparent;
147
+ border-radius: 10px;
148
+ }
149
+
150
+ /* Handle */
151
+ &::-webkit-scrollbar-thumb {
152
+ background: #ededed;
153
+ border: 1px solid #e7e7e7;
154
+ border-radius: 10px;
155
+ }
156
+
157
+ /* Handle on hover */
158
+ &::-webkit-scrollbar-thumb:hover {
159
+ background: rgb(116, 116, 116);
160
+ }
161
+ }
162
+ }
163
+
164
+ .noResults {
165
+ padding-top: 0.5rem;
166
+ padding-bottom: 0.5rem;
167
+ padding-left: 0.5rem;
168
+ }
169
+
170
+ .listboxItem {
171
+ position: relative;
172
+ display: block;
173
+ cursor: pointer;
174
+ border-width: 0px;
175
+ border-bottom-width: 1px;
176
+ border-style: solid;
177
+ border-color: #e2e0db;
178
+ transition-property: all;
179
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
180
+ transition-duration: 150ms;
181
+ white-space: nowrap;
182
+ text-overflow: ellipsis;
183
+ overflow: hidden;
184
+ padding: 8px 10px;
185
+ svg {
186
+ position: absolute;
187
+ height: 100%;
188
+ width: 12px;
189
+ left: 16px;
190
+ top: 0;
191
+ }
192
+ &:last-child {
193
+ border: none;
194
+ }
195
+ &:hover {
196
+ color: #333;
197
+ background: #ececec;
198
+ }
199
+ &.selected {
200
+ color: #333;
201
+ font-weight: 500;
202
+ background: #ececec;
203
+ }
204
+ &.highlighted {
205
+ color: #333;
206
+ background: #ececec;
207
+ }
208
+ }
@@ -0,0 +1,384 @@
1
+ /* eslint-disable no-nested-ternary */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { NestedObject } from '@/interfaces';
4
+ import { html } from 'htm/preact';
5
+ import { createRef } from 'preact';
6
+ import { useEffect, useRef, useState } from 'preact/hooks';
7
+ import { isScrolledIntoView } from '@/utils/common';
8
+ import { searchJSON } from '@/utils/searchJson';
9
+ import { Input } from '@/components/Input';
10
+ import { TagOptions } from '../TagOptions';
11
+ import { ThreeDotLoader } from '../../ThreeDotLoader';
12
+ import styles from './styles.module.scss';
13
+
14
+ // component to show tags in the tag menu
15
+
16
+ // enum for active tab
17
+ export enum Tabs {
18
+ Values = 'values',
19
+ AppFields = 'AppFields',
20
+ }
21
+ interface Option {
22
+ value: string;
23
+ id: string;
24
+ isSelected?: boolean;
25
+ }
26
+ interface FieldMenuProps {
27
+ tags: NestedObject;
28
+ options?: Option[];
29
+ appName?: string;
30
+ onTagClick?: (tag: string) => void;
31
+ onOptionClick?: (option: Option) => void;
32
+ hideTabs?: boolean;
33
+ defaultTab?: Tabs.AppFields | Tabs.Values;
34
+ fieldId?: string;
35
+ value?: string;
36
+ onTabSelect?: (tab: Tabs) => void;
37
+ isMappable?: boolean;
38
+ isEditable?: boolean;
39
+ enableSearch?: boolean;
40
+ refreshRootStepData?: (callback?: any) => void;
41
+ handleRefreshClick?: (callback?: any, nextPage?: string) => void;
42
+ isErrorOnLoadingOptions?: boolean;
43
+ isMultiSelect?: boolean;
44
+ loadingOptions?: boolean;
45
+ nextPage?: string;
46
+ }
47
+
48
+ const FieldDropdown = (props: FieldMenuProps) => {
49
+ const {
50
+ appName = '',
51
+ tags = {},
52
+ options = [],
53
+ hideTabs = false,
54
+ defaultTab = Tabs.AppFields,
55
+ onTagClick = () => null,
56
+ onOptionClick = () => null,
57
+ fieldId = '',
58
+ value,
59
+ onTabSelect,
60
+ isEditable = false,
61
+ enableSearch = false,
62
+ refreshRootStepData,
63
+ handleRefreshClick,
64
+ isErrorOnLoadingOptions = false,
65
+ isMultiSelect = false,
66
+ loadingOptions = false,
67
+ nextPage = '',
68
+ } = props;
69
+
70
+ // Set active tab in state
71
+ const [activeTab, setActiveTab] = useState(defaultTab);
72
+ const menuItemRefs = useRef<any>([]);
73
+ const tagMenyStyleRef = useRef(null);
74
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
75
+ const [renderAgain, setRenderAgain] = useState(false);
76
+ const [searchValue, setSearchValue] = useState('');
77
+ const [isLoadingRootStepData, setisLoadingRootStepData] = useState(false);
78
+ const [
79
+ isErrorOnLoadingRootStepData,
80
+ setIsErrorOnLoadingRootStepData,
81
+ ] = useState(false);
82
+ const [isLoadingOptions, setisLoadingOptions] = useState(loadingOptions);
83
+ const [isLoadingMoreOptions, setIsLoadingMoreOptions] = useState(false);
84
+
85
+ useEffect(() => {
86
+ let optionsToProcess = options;
87
+ if (!Array.isArray(options)) {
88
+ optionsToProcess = [];
89
+ }
90
+ menuItemRefs.current = (optionsToProcess || []).map(
91
+ (element, i) => menuItemRefs.current[i] ?? createRef(),
92
+ );
93
+ }, [options]);
94
+
95
+ const isContentOverflowing = (menuItemRef: any): boolean => {
96
+ if (menuItemRef && menuItemRef.current) {
97
+ return menuItemRef.current.clientWidth < menuItemRef.current.scrollWidth;
98
+ }
99
+ return false;
100
+ };
101
+
102
+ /* set menu position relative to parent container,
103
+ as the menu position is fixed to make it visible outside the scrollable area */
104
+ const parentContainer = document.getElementById(fieldId);
105
+ const getDynamicTagMenuPosition = (): any => {
106
+ const top = parentContainer
107
+ ? parentContainer.getBoundingClientRect().bottom
108
+ : '';
109
+ let tagMenuStyle = {
110
+ top: parentContainer ? `${top}px` : '',
111
+ left: parentContainer
112
+ ? `${parentContainer.getBoundingClientRect().left}px`
113
+ : '',
114
+ display:
115
+ parentContainer &&
116
+ !isScrolledIntoView(parentContainer, 'steps-body-container')
117
+ ? 'none'
118
+ : 'block',
119
+ maxWidth: parentContainer
120
+ ? `${parentContainer.getBoundingClientRect().width}px`
121
+ : '342px',
122
+ } as any;
123
+ if (
124
+ parentContainer &&
125
+ parentContainer.getBoundingClientRect().bottom +
126
+ 210 /* 210 is maxheight of tagMenu */ >
127
+ window.innerHeight - 8
128
+ ) {
129
+ // if tagMenu is overflowing window, display it above the field
130
+ tagMenuStyle = {
131
+ bottom: `${
132
+ window.innerHeight - parentContainer.getBoundingClientRect().top
133
+ }px`,
134
+ left: parentContainer
135
+ ? `${parentContainer.getBoundingClientRect().left}px`
136
+ : '',
137
+ display:
138
+ parentContainer &&
139
+ !isScrolledIntoView(parentContainer, 'steps-body-container')
140
+ ? 'none'
141
+ : 'block',
142
+ maxWidth: parentContainer
143
+ ? `${parentContainer.getBoundingClientRect().width}px`
144
+ : '342px',
145
+ };
146
+ }
147
+ return tagMenuStyle;
148
+ };
149
+ tagMenyStyleRef.current = getDynamicTagMenuPosition();
150
+
151
+ const onScroll = (): void => {
152
+ tagMenyStyleRef.current = getDynamicTagMenuPosition();
153
+ setRenderAgain((prev) => !prev);
154
+ };
155
+
156
+ const getFilteredOptions = (
157
+ optionsToFilter: Option[] = [],
158
+ searchText = '',
159
+ ): Option[] => {
160
+ if (searchText.trim().length === 0) {
161
+ return optionsToFilter;
162
+ }
163
+ return optionsToFilter.filter((obj) =>
164
+ obj.value.toLowerCase().includes(searchText.trim().toLowerCase()),
165
+ );
166
+ };
167
+ const handleTabSelection = (tab: Tabs): void => {
168
+ setActiveTab(tab);
169
+ if (onTabSelect) {
170
+ onTabSelect(tab);
171
+ }
172
+ };
173
+ useEffect(() => {
174
+ if (value && !hideTabs) {
175
+ if (value.startsWith('{') && value.endsWith('}')) {
176
+ handleTabSelection(Tabs.AppFields);
177
+ }
178
+ }
179
+ window.addEventListener('scroll', onScroll, true);
180
+ return () => window.removeEventListener('scroll', onScroll);
181
+ }, []);
182
+
183
+ const handleOnSearch = (val: string) => {
184
+ setSearchValue(val);
185
+ };
186
+
187
+ const refreshCallback = (error = false) => {
188
+ setisLoadingRootStepData(false);
189
+ setIsErrorOnLoadingRootStepData(error);
190
+ };
191
+
192
+ const handleRefresh = () => {
193
+ if (refreshRootStepData) {
194
+ setisLoadingRootStepData(true);
195
+ refreshRootStepData(refreshCallback);
196
+ }
197
+ };
198
+ let selectedValues: any = [];
199
+ if (value) {
200
+ if (isMultiSelect) {
201
+ selectedValues = JSON.parse(value);
202
+ } else {
203
+ selectedValues = [value];
204
+ }
205
+ }
206
+ return html` <div
207
+ class=${`${styles.tagMenu} ${enableSearch ? styles.tagMenuWithSearch : ''}`}
208
+ style=${parentContainer && tagMenyStyleRef?.current
209
+ ? tagMenyStyleRef.current
210
+ : ''}
211
+ >
212
+ ${enableSearch &&
213
+ html`
214
+ <div class=${styles.tagMenuSearch}>
215
+ <${Input}
216
+ id="search_${fieldId}"
217
+ placeholder="Search for a field"
218
+ value="${searchValue}"
219
+ onChange="${handleOnSearch}"
220
+ />
221
+ </div>
222
+ `}
223
+ ${!hideTabs &&
224
+ html`<div class=${styles.tagMenuHeader}>
225
+ <div
226
+ class=${`${styles.tagMenuHeaderItem} ${
227
+ activeTab === Tabs.Values ? styles.active : ''
228
+ }`}
229
+ onClick=${() => handleTabSelection(Tabs.Values)}
230
+ >
231
+ Values
232
+ </div>
233
+ <div
234
+ class=${`${styles.tagMenuHeaderItem} ${
235
+ activeTab === Tabs.AppFields ? styles.active : ''
236
+ }`}
237
+ onClick=${() => handleTabSelection(Tabs.AppFields)}
238
+ >
239
+ ${appName ? `${appName} fields` : 'Fields'}
240
+ </div>
241
+ </div>`}
242
+ <div
243
+ class=${`${styles.tagMenuBody} ${
244
+ enableSearch ? styles.tagMenuBodyWithSearch : ''
245
+ }`}
246
+ >
247
+ ${activeTab === Tabs.Values
248
+ ? html`<div className=${styles.tagMenuBodyItem} id="tag-menu-body-item">
249
+ ${options.length > 0
250
+ ? getFilteredOptions(options, searchValue).length > 0
251
+ ? getFilteredOptions(options, searchValue).map(
252
+ (option, i, arr) => {
253
+ if (i === arr.length - 1) {
254
+ setisLoadingOptions(false);
255
+ }
256
+ return html`
257
+ <div
258
+ class=${`${styles.value} ${
259
+ selectedValues.includes(option.id)
260
+ ? styles.selected
261
+ : ''
262
+ }`}
263
+ onClick=${(e: Event) => {
264
+ e.stopPropagation();
265
+ onOptionClick(option);
266
+ }}
267
+ ref=${menuItemRefs.current[i]}
268
+ data-hint=${`${
269
+ isContentOverflowing(menuItemRefs.current[i])
270
+ ? option.value
271
+ : ''
272
+ }`}
273
+ >
274
+ ${option.value}
275
+ </div>
276
+
277
+ ${i !== arr.length - 1
278
+ ? ''
279
+ : html`<span>
280
+ ${isLoadingOptions || isLoadingMoreOptions
281
+ ? html`<${ThreeDotLoader} color="#999" />`
282
+ : html` <a
283
+ className=${styles.optionsRefreshProminent}
284
+ href="#"
285
+ onclick=${() => {
286
+ if (handleRefreshClick) {
287
+ setIsLoadingMoreOptions(true);
288
+ handleRefreshClick(
289
+ () => setIsLoadingMoreOptions(false),
290
+ nextPage,
291
+ );
292
+ }
293
+ }}
294
+ >${nextPage
295
+ ? `Load more options`
296
+ : `Reload options?`}</a
297
+ >`}
298
+ </span>`}
299
+ `;
300
+ },
301
+ )
302
+ : html`<div className=${styles.noOptions}>
303
+ Your search did not match any values
304
+ </div>`
305
+ : html`<div className=${styles.noOptions}>
306
+ <span className=${styles.noOptionsRetry}>
307
+ ${isLoadingOptions
308
+ ? html`<${ThreeDotLoader} color="#999" />`
309
+ : html`${isErrorOnLoadingOptions
310
+ ? 'Could not load options.'
311
+ : 'No options found.'}
312
+ <a
313
+ className=${styles.optionsRefresh}
314
+ href="#"
315
+ onclick=${() => {
316
+ if (handleRefreshClick) {
317
+ setisLoadingOptions(true);
318
+ handleRefreshClick(() =>
319
+ setisLoadingOptions(false),
320
+ );
321
+ }
322
+ }}
323
+ >
324
+ ${' '}Try again?</a
325
+ >`}
326
+ </span>
327
+ </div>`}
328
+ </div>`
329
+ : html` <div className="${styles.mappedFieldMenu}">
330
+ ${Object.keys(!isEditable ? searchJSON(tags, searchValue) : tags)
331
+ .length > 0
332
+ ? Object.keys(
333
+ !isEditable ? searchJSON(tags, searchValue) : tags,
334
+ ).map(
335
+ (objKey, index, arr) => html`
336
+ <${TagOptions}
337
+ objectKey="${objKey}"
338
+ keyValue="${objKey}"
339
+ objectData="${!isEditable
340
+ ? searchJSON(tags, searchValue)[objKey]
341
+ : tags[objKey]}"
342
+ onSelect=${onTagClick}
343
+ isRoot="${true}"
344
+ />
345
+ ${index !== arr.length - 1
346
+ ? ''
347
+ : html`<span>
348
+ ${isLoadingRootStepData
349
+ ? html`<${ThreeDotLoader} color="#999" />`
350
+ : html` <a
351
+ className=${styles.optionsRefreshProminent}
352
+ href="#"
353
+ onclick=${handleRefresh}
354
+ >Reload fields?</a
355
+ >`}
356
+ </span>`}
357
+ `,
358
+ )
359
+ : html`<div className=${styles.noOptions}>
360
+ ${!isEditable && searchValue !== ''
361
+ ? 'Your search did not match any fields'
362
+ : html`
363
+ <span className=${styles.noOptionsRetry}>
364
+ ${isLoadingRootStepData
365
+ ? html`<${ThreeDotLoader} color="#999" />`
366
+ : html`${isErrorOnLoadingRootStepData
367
+ ? 'Could not load fields.'
368
+ : 'No fields found.'}
369
+ <a
370
+ className=${styles.optionsRefresh}
371
+ href="#"
372
+ onclick=${handleRefresh}
373
+ >
374
+ ${' '}Try again?</a
375
+ >`}
376
+ </span>
377
+ `}
378
+ </div>`}
379
+ </div>`}
380
+ </div>
381
+ </div>`;
382
+ };
383
+
384
+ export { FieldDropdown, FieldMenuProps };