@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,190 @@
1
+ import { html } from 'htm/preact';
2
+ import { useContext, useEffect, useRef, useState } from 'preact/hooks';
3
+
4
+ import AppContext from '@/contexts/AppContext';
5
+ import { Checkbox } from './Checkbox';
6
+ import { Label } from '../Label';
7
+
8
+ import styles from './styles.module.scss';
9
+ import { ErrorMessage } from '../ErrorMessage';
10
+ import { ThreeDotLoader } from '../ThreeDotLoader';
11
+
12
+ interface CheckboxItem {
13
+ id: string;
14
+ value: string;
15
+ }
16
+
17
+ export interface CheckboxGroupProps {
18
+ fieldId: string;
19
+ title: string;
20
+ description: string;
21
+ isDynamic: boolean;
22
+ dataSrcEndpoint?: string;
23
+ ariaLabel: string;
24
+ value: string;
25
+ initialOptions?: CheckboxItem[];
26
+ selectedItems?: string[];
27
+ endpointData: string;
28
+ isRequired?: boolean;
29
+ showStepValidation?: boolean;
30
+ onChange?: (data: string) => void;
31
+ isReadOnly?: boolean;
32
+ isChanged?: boolean;
33
+ }
34
+
35
+ /**
36
+ * RadioGroup component
37
+ *
38
+ */
39
+ export const CheckboxGroup = (props: CheckboxGroupProps) => {
40
+ const {
41
+ fieldId,
42
+ title,
43
+ description,
44
+ value,
45
+ ariaLabel,
46
+ selectedItems = [],
47
+ isDynamic,
48
+ endpointData,
49
+ initialOptions = [],
50
+ dataSrcEndpoint,
51
+ isRequired = false,
52
+ showStepValidation = false,
53
+ onChange = () => null,
54
+ isReadOnly = false,
55
+ isChanged = false,
56
+ } = props;
57
+
58
+ const indicesRef = useRef(selectedItems);
59
+
60
+ const [loading, setLoading] = useState(isDynamic);
61
+ const [selectedItemIds, setSelectedItemIds] = useState<string[]>(
62
+ selectedItems,
63
+ );
64
+
65
+ const [error, setError] = useState<string | null>(null);
66
+
67
+ const [parsedOptions, setParsedOptions] = useState<CheckboxItem[]>(
68
+ Array.isArray(initialOptions) ? initialOptions : [],
69
+ );
70
+
71
+ const context = useContext(AppContext);
72
+
73
+ useEffect(() => {
74
+ if (value) {
75
+ if (value === '0' && parsedOptions.length === 1) return;
76
+ if (value === '1' && parsedOptions.length === 1) {
77
+ setSelectedItemIds([parsedOptions[0].id]);
78
+ } else {
79
+ setSelectedItemIds(value.split(',').map((el) => el.trim()));
80
+ }
81
+ }
82
+ }, []);
83
+
84
+ useEffect(() => {
85
+ if (indicesRef.current !== selectedItemIds) {
86
+ if (parsedOptions.length < 2) {
87
+ onChange(selectedItemIds.length === 1 ? '1' : '0');
88
+ } else {
89
+ onChange(selectedItemIds.join(','));
90
+ }
91
+ }
92
+ }, [selectedItemIds, parsedOptions]);
93
+
94
+ useEffect(() => {
95
+ if (isDynamic) {
96
+ if (dataSrcEndpoint) {
97
+ // eslint-disable-next-line no-use-before-define
98
+ fetchDynamicData();
99
+ } else {
100
+ setParsedOptions(initialOptions);
101
+ setLoading(false);
102
+ }
103
+ } else {
104
+ setParsedOptions(initialOptions);
105
+ }
106
+ }, []);
107
+
108
+ const handleChange = (itemId: string) => {
109
+ if (selectedItemIds.indexOf(itemId) > -1) {
110
+ setSelectedItemIds((prev) => prev.filter((el) => el !== itemId));
111
+ } else {
112
+ setSelectedItemIds([...selectedItemIds, itemId]);
113
+ }
114
+ };
115
+
116
+ const fetchDynamicData = (): void => {
117
+ if (dataSrcEndpoint) {
118
+ setLoading(true);
119
+ let data;
120
+ try {
121
+ data = JSON.parse(endpointData);
122
+ } catch (parseErr) {
123
+ data = '';
124
+ }
125
+ // call dynamic endpoint
126
+ context?.apiHandler
127
+ .callDynamicDataEndpoint<CheckboxItem[]>(new URL(dataSrcEndpoint), data)
128
+ .then((res) => {
129
+ if (res) setParsedOptions(res);
130
+ else setError(`Error loading options`);
131
+ })
132
+ .catch((err) => {
133
+ console.error(err);
134
+ setError('Error loading options');
135
+ })
136
+ .finally(() => setLoading(false));
137
+ }
138
+ };
139
+
140
+ const handleRefreshClick = (): void => {
141
+ fetchDynamicData();
142
+ setSelectedItemIds([]);
143
+ };
144
+
145
+ return html`
146
+ <div class="${styles.checkboxGroup}">
147
+ <fieldset>
148
+ <${Label} isRequired=${isRequired}
149
+ labelTag=${isReadOnly && isChanged ? 'Changed' : ''}
150
+ allowRefresh=${isDynamic && dataSrcEndpoint}
151
+ handleRefreshClick=${handleRefreshClick} //>
152
+ <div
153
+ class=${styles.checkboxGroupWrap}
154
+ role="group"
155
+ aria-labelledby=${ariaLabel}
156
+ >
157
+ ${loading
158
+ ? html`<div style="margin: 20px 0;">
159
+ <${ThreeDotLoader} color="#999" />
160
+ </div>`
161
+ : html`
162
+ ${error
163
+ ? html`<div style="margin: 20px 0;">
164
+ <${ErrorMessage}>${error}<//>
165
+ </div>`
166
+ : html`
167
+ ${parsedOptions?.map(
168
+ (el) => html`
169
+ <${Checkbox}
170
+ fieldId=${fieldId}
171
+ id=${el.id}
172
+ value=${el.value}
173
+ isChecked=${selectedItemIds.indexOf(el.id) > -1}
174
+ handleChange=${handleChange}
175
+ isReadOnly=${isReadOnly}
176
+ title=${title}
177
+ ><//>
178
+ `,
179
+ )}
180
+ `}
181
+ `}
182
+ </div>
183
+ </fieldset>
184
+ ${showStepValidation &&
185
+ selectedItemIds.length < 1 &&
186
+ isRequired &&
187
+ html` <${ErrorMessage}>Please select an option</${ErrorMessage}>`}
188
+ </div>
189
+ `;
190
+ };
@@ -0,0 +1,63 @@
1
+ .checkboxGroup {
2
+ fieldset {
3
+ border: none;
4
+ padding: 0;
5
+ }
6
+ .checkboxGroupWrap {
7
+ margin-top: 14px;
8
+ width: fit-content;
9
+ }
10
+ }
11
+
12
+ .checkboxWrap {
13
+ margin-bottom: 14px;
14
+ width: fit-content;
15
+ .readonlyHint {
16
+ width: 100%;
17
+ height: 100%;
18
+ z-index: 99;
19
+ position: absolute;
20
+ }
21
+ }
22
+
23
+ .checkbox {
24
+ position: relative;
25
+ display: flex;
26
+ margon-bottom: 2px;
27
+ align-items: center;
28
+ margin-top: 12px;
29
+ .button {
30
+ display: block;
31
+ height: 20px;
32
+ width: 20px;
33
+ background-color: transparent;
34
+ svg {
35
+ }
36
+ }
37
+ input[type='checkbox'] {
38
+ opacity: 0;
39
+ margin: 0;
40
+ display: none;
41
+ }
42
+ label {
43
+ display: flex;
44
+ flex: 1;
45
+ cursor: pointer;
46
+ font-size: 14px;
47
+ color: #333333;
48
+ }
49
+ .text {
50
+ display: flex;
51
+ color: #333;
52
+ font-size: 14px;
53
+ padding-left: 10px;
54
+ font-weight: 400;
55
+ line-height: 26px;
56
+ margin-top: -2px;
57
+ }
58
+ .description {
59
+ font-size: 12px;
60
+ color: #222;
61
+ margin-left: 12px;
62
+ }
63
+ }
@@ -0,0 +1,101 @@
1
+ import { useOnClickOutside } from '@/hooks/useOnClickOutside';
2
+ import { html } from 'htm/preact';
3
+ import { useCallback, useRef, useState } from 'preact/hooks';
4
+
5
+ import styles from './styles.module.scss';
6
+
7
+ interface Option {
8
+ id: string;
9
+ label: string;
10
+ }
11
+
12
+ interface CollapsedMenuProps {
13
+ options: Option[];
14
+ onOptionSelect(option: Option): void;
15
+ Icon?: preact.VNode;
16
+ className?: string;
17
+ verticalIcon?: boolean;
18
+ }
19
+
20
+ const CollapsedMenu = (props: CollapsedMenuProps) => {
21
+ const {
22
+ options = [],
23
+ onOptionSelect = () => null,
24
+ Icon = null,
25
+ className,
26
+ verticalIcon = false,
27
+ } = props;
28
+
29
+ const popupRef = useRef<HTMLDivElement>();
30
+
31
+ const [open, setOpen] = useState(false);
32
+
33
+ const onClickAway = useCallback(() => setOpen(false), []);
34
+
35
+ useOnClickOutside(popupRef, onClickAway);
36
+
37
+ const onClick = (option: Option) => {
38
+ setOpen(false);
39
+ onOptionSelect(option);
40
+ };
41
+
42
+ return html`
43
+ <div
44
+ ref=${popupRef}
45
+ class=${`${styles.collapsedMenu} ${className ? styles[className] : ''}`}
46
+ >
47
+ <div
48
+ class=${styles.trigger}
49
+ onclick=${(e: MouseEvent) => {
50
+ e.stopPropagation();
51
+ setOpen((prev) => !prev);
52
+ }}
53
+ >
54
+ ${Icon
55
+ ? html`<${Icon} />`
56
+ : html`<svg
57
+ style="${verticalIcon ? 'rotate: 90deg;' : ''}"
58
+ width="20"
59
+ height="20"
60
+ viewBox="0 0 20 20"
61
+ fill="none"
62
+ xmlns="http://www.w3.org/2000/svg"
63
+ >
64
+ <path
65
+ fill-rule="evenodd"
66
+ clip-rule="evenodd"
67
+ d="M4.5 11C5.32843 11 6 10.3284 6 9.5C6 8.67157 5.32843 8 4.5 8C3.67157 8 3 8.67157 3 9.5C3 10.3284 3.67157 11 4.5 11Z"
68
+ fill="#999999"
69
+ />
70
+ <path
71
+ fill-rule="evenodd"
72
+ clip-rule="evenodd"
73
+ d="M9.5 11C10.3284 11 11 10.3284 11 9.5C11 8.67157 10.3284 8 9.5 8C8.67157 8 8 8.67157 8 9.5C8 10.3284 8.67157 11 9.5 11Z"
74
+ fill="#999999"
75
+ />
76
+ <path
77
+ fill-rule="evenodd"
78
+ clip-rule="evenodd"
79
+ d="M14.5 11C15.3284 11 16 10.3284 16 9.5C16 8.67157 15.3284 8 14.5 8C13.6716 8 13 8.67157 13 9.5C13 10.3284 13.6716 11 14.5 11Z"
80
+ fill="#999999"
81
+ />
82
+ </svg>`}
83
+ </div>
84
+ <div class="${styles.popup} ${open ? styles.open : ''}">
85
+ <div class=${styles.optionWrap}>
86
+ ${options.map(
87
+ (el) =>
88
+ html`<div class=${styles.option} onclick=${(event: any) => {
89
+ event.stopPropagation();
90
+ onClick(el)
91
+ }}>
92
+ ${el.label}
93
+ </div>`,
94
+ )}
95
+ </div>
96
+ </div>
97
+ </div>
98
+ `;
99
+ };
100
+
101
+ export { CollapsedMenu, CollapsedMenuProps };
@@ -0,0 +1,46 @@
1
+ .collapsedMenu {
2
+ position: relative;
3
+ .trigger {
4
+ display: flex;
5
+ justify-content: center;
6
+ cursor: pointer;
7
+ width: max-content;
8
+ }
9
+ .popup {
10
+ display: none;
11
+ position: absolute;
12
+ width: 150px;
13
+ top: 20px;
14
+ left: auto;
15
+ margin-right: 20px;
16
+ right: 0;
17
+ z-index: 99;
18
+ color: #6d6f7b;
19
+ &.open {
20
+ display: block;
21
+ }
22
+ .optionWrap {
23
+ background: #fff;
24
+ padding: 4px 0;
25
+ border: 1px solid #f3f3f3;
26
+ box-shadow: 0px 2px 7px rgba(162, 162, 162, 0.25);
27
+ border-radius: 4px;
28
+ .option {
29
+ padding: 12px 14px;
30
+ font-size: 12px;
31
+ cursor: pointer;
32
+ overflow: hidden;
33
+ text-overflow: ellipsis;
34
+ &:hover {
35
+ background: #eeeeee;
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ .instanceMenu {
42
+ .popup {
43
+ right: -10px;
44
+ width: 109px;
45
+ }
46
+ }
@@ -0,0 +1,85 @@
1
+ import { html } from 'htm/preact';
2
+ import { StoreType } from '@/types/store';
3
+ import { actionFunctions } from '@/store/actionFunctions';
4
+ import { useContext } from 'preact/hooks';
5
+ import AppContext from '@/contexts/AppContext';
6
+ import { TemplateField } from '@/interfaces';
7
+
8
+ import { connect } from 'unistore/preact';
9
+ import styles from './styles.module.scss';
10
+
11
+ interface ConfigureFieldWrapperPropsType extends StoreType {
12
+ children: Element;
13
+ field: TemplateField;
14
+ genericData: StoreType['genericData'];
15
+ editFieldData: StoreType['editFieldData'];
16
+ stepId: string | number;
17
+ templateId: string | number;
18
+ }
19
+ // interface for GearIcon
20
+
21
+ const GearIcon = () => html`
22
+ <svg
23
+ width="12"
24
+ height="12"
25
+ viewBox="0 0 16 16"
26
+ fill="none"
27
+ xmlns="http://www.w3.org/2000/svg"
28
+ >
29
+ <path
30
+ d="M13.2333 10.6576C13.2668 10.5914 13.2957 10.5252 13.3269 10.4628C13.3581 10.4004 13.3794 10.354 13.403 10.2992L13.4182 10.2619V10.2406C13.4434 10.1782 13.4647 10.1157 13.4883 10.0457C13.5119 9.9757 13.537 9.91938 13.5606 9.85088V9.80826L16 9.36379V6.73109L13.598 6.23257L13.5843 6.19376V6.17854C13.5607 6.10851 13.5356 6.04002 13.5105 5.97228C13.4853 5.90378 13.4716 5.85735 13.448 5.80103L13.4328 5.76373V5.74242C13.4077 5.68001 13.378 5.62141 13.3506 5.56128C13.3232 5.50115 13.2958 5.43646 13.2646 5.36644L13.2532 5.34513V5.33143L14.6247 3.30995L12.76 1.44526L10.7103 2.79165L10.673 2.77415H10.6593C10.5931 2.74066 10.5268 2.71174 10.4644 2.68053C10.402 2.64932 10.3556 2.62802 10.3008 2.60442L10.2635 2.5892H10.2422C10.1798 2.56408 10.1174 2.54277 10.0473 2.51918C9.97733 2.49558 9.92253 2.47047 9.8525 2.44916H9.80988L9.36387 0H6.73115L6.23263 2.402L6.19381 2.4157H6.17859C6.10857 2.4393 6.04007 2.46441 5.97233 2.48953C5.90383 2.51465 5.8574 2.52835 5.80108 2.55194L5.76378 2.56716H5.74247C5.68006 2.59228 5.62146 2.62196 5.56133 2.64936C5.5012 2.67676 5.43651 2.70416 5.36649 2.73537L5.34137 2.74907H5.32767L3.31007 1.37528L1.44537 3.23997L2.79177 5.2897L2.77427 5.32699V5.34069C2.74078 5.40691 2.71186 5.47312 2.68065 5.53553C2.64945 5.59794 2.62814 5.64437 2.60302 5.70145L2.5878 5.73875V5.76006C2.56268 5.82247 2.54137 5.88488 2.51777 5.9549C2.49418 6.02492 2.46906 6.08124 2.44547 6.14974V6.19236L0 6.63608V9.26877L2.40202 9.76577L2.41572 9.80459V9.81981C2.43931 9.88983 2.46443 9.95833 2.48955 10.0261C2.51467 10.0946 2.52836 10.141 2.55196 10.1973L2.56718 10.2346V10.2559C2.5923 10.3183 2.62198 10.3769 2.64938 10.4394C2.67678 10.5018 2.70418 10.5642 2.7331 10.6342L2.74832 10.6616V10.6753L1.37529 12.6899L3.23999 14.5546L5.28973 13.2082L5.32703 13.2258H5.34073C5.40694 13.2592 5.47316 13.2882 5.53557 13.3194C5.59798 13.3506 5.64441 13.3719 5.70149 13.397L5.73879 13.4122H5.7601C5.82251 13.4373 5.88492 13.4586 5.95494 13.4822C6.02496 13.5058 6.08128 13.531 6.14978 13.5545H6.1924L6.63612 16H9.26884L9.76584 13.598L9.80466 13.5843H9.81988C9.8899 13.5607 9.9584 13.5356 10.0261 13.5105C10.0946 13.4854 10.1411 13.4717 10.1974 13.4481L10.2347 13.4328H10.256C10.3184 13.4077 10.377 13.378 10.4371 13.3506C10.4973 13.3232 10.562 13.2958 10.632 13.2646L10.6533 13.2532H10.667L12.69 14.6247L14.5547 12.76L13.2083 10.7103L13.2258 10.673L13.2333 10.6576ZM8.00002 11.4408C7.08745 11.4408 6.21218 11.0785 5.56682 10.4331C4.92146 9.7877 4.55911 8.91244 4.55911 7.99994C4.55911 7.08744 4.92141 6.21211 5.56682 5.56676C6.21224 4.9214 7.08751 4.55906 8.00002 4.55906C8.91252 4.55906 9.78785 4.92135 10.4332 5.56676C11.0786 6.21217 11.4409 7.08744 11.4409 7.99994C11.4409 8.91244 11.0786 9.78776 10.4332 10.4331C9.78779 11.0785 8.91252 11.4408 8.00002 11.4408Z"
31
+ fill="#4250F0"
32
+ />
33
+ </svg>
34
+ `;
35
+
36
+ const ConfigureFieldWrapper = (props: ConfigureFieldWrapperPropsType) => {
37
+ const context = useContext(AppContext);
38
+ const {
39
+ children,
40
+ field,
41
+ genericData,
42
+ editFieldData,
43
+ userConfig,
44
+ stepId,
45
+ templateId,
46
+ } = props;
47
+ const editField = () => {
48
+ props.setEditFieldData({ fieldId: field.id });
49
+ };
50
+ const editFieldId = editFieldData?.fieldId || 0;
51
+ const editingCurrentField = editFieldId === field.id;
52
+ const blurryOverlayClass =
53
+ !!editFieldId && editFieldId !== field.id ? `${styles.blur}` : '';
54
+ const disableConfigureButtonClass =
55
+ !!editFieldId && !editingCurrentField ? `${styles.disabled}` : '';
56
+
57
+ return userConfig?.viewAsIU
58
+ ? html`
59
+ <div class=${styles.configureFieldWrapper}>
60
+ <div class=${`${styles.fieldOverlay} ${blurryOverlayClass}`} />
61
+ ${userConfig.viewAsIU &&
62
+ html`${editingCurrentField
63
+ ? html`<div class=${styles.configuring}>Configuring...</div>`
64
+ : html`<div
65
+ class=${`${styles.configureButtonWrapper} ${disableConfigureButtonClass}`}
66
+ onClick=${editField}
67
+ >
68
+ <${GearIcon}//>
69
+ <div>Configure</div>
70
+ </div>`} `}
71
+ ${children}
72
+ </div>
73
+ `
74
+ : html`${children}`;
75
+ };
76
+
77
+ export default connect<
78
+ ConfigureFieldWrapperPropsType,
79
+ ConfigureFieldWrapperPropsType,
80
+ StoreType,
81
+ unknown
82
+ >(
83
+ ['genericData', 'editFieldData', 'userConfig'],
84
+ actionFunctions,
85
+ )(ConfigureFieldWrapper);
@@ -0,0 +1,57 @@
1
+ .configureFieldWrapper {
2
+ position: relative;
3
+ .configuring {
4
+ position: absolute;
5
+ right: 0;
6
+ font-weight: 500;
7
+ font-size: 12px;
8
+ line-height: 20px;
9
+ text-align: right;
10
+ color: #333333;
11
+ }
12
+ .configureButtonWrapper {
13
+ position: absolute;
14
+ right: 0;
15
+ z-index: 1;
16
+ display: flex;
17
+ gap: 4px;
18
+ cursor: pointer;
19
+ z-index: 1;
20
+ font-weight: 500;
21
+ font-size: 12px;
22
+ line-height: 20px;
23
+ color: #4250f0;
24
+ align-items: center;
25
+ .gearIcon {
26
+ width: 12px;
27
+ height: 12px;
28
+ }
29
+ &.disabled {
30
+ cursor: default;
31
+ opacity: 0.5;
32
+ pointer-events: none;
33
+ }
34
+ }
35
+
36
+ .fieldOverlay {
37
+ // center align text
38
+ background: #ffffff;
39
+ width: 100%;
40
+ height: 100%;
41
+ position: absolute;
42
+ z-index: 1;
43
+ opacity: 0;
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: center;
47
+ &.blur {
48
+ // #E6E6E6 rgba(230, 230, 230, 1)
49
+ background: #ffffff;
50
+ opacity: 0.5;
51
+ }
52
+ &.hidden {
53
+ background: rgba(230, 230, 230, 1);
54
+ opacity: 0.9;
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,121 @@
1
+ import { html } from 'htm/preact';
2
+ import { useEffect, useRef, useState } from 'preact/hooks';
3
+ import { OverflowTooltip } from '@/components/OverflowTooltip';
4
+ import { useOnClickOutside } from '@/hooks/useOnClickOutside';
5
+ import useHover from '@/hooks/useHover';
6
+
7
+ import styles from './styles.module.scss';
8
+
9
+ interface EditableTextProps {
10
+ value: string;
11
+ customStyles?: {
12
+ wrapperClassName?: string;
13
+ inputClassName?: string;
14
+ };
15
+ handleChange?: (value: string) => void;
16
+ handleBlur?: () => void;
17
+ }
18
+
19
+ /**
20
+ * EditableText component
21
+ *
22
+ */
23
+ const EditableText = (props: EditableTextProps) => {
24
+ const { value, customStyles, handleChange = () => null } = props;
25
+
26
+ const [isEditing, setIsEditing] = useState(false);
27
+ const inputRef = useRef<HTMLButtonElement | null>(null);
28
+ const containerRef = useRef<HTMLDivElement | null>(null);
29
+
30
+ const isHovered = useHover(containerRef, isEditing);
31
+
32
+ const determineChangedValue = () => {
33
+ const latestVal = inputRef.current?.value.trim() || '';
34
+ if (latestVal === '') {
35
+ // revert to original value
36
+ handleChange(value);
37
+ } else if (latestVal !== value) {
38
+ // let the update go through if value changed
39
+ handleChange(latestVal);
40
+ }
41
+ };
42
+
43
+ useOnClickOutside(containerRef, () => {
44
+ if (isEditing) {
45
+ setIsEditing(false);
46
+ determineChangedValue();
47
+ }
48
+ });
49
+
50
+ // If released key is our target key then set to false
51
+ const upHandler = ({ key }: { key: string }): void => {
52
+ if (key === 'Enter') {
53
+ // we need to set editable to false
54
+ setIsEditing(false);
55
+ determineChangedValue();
56
+ } else if (key === 'Escape') {
57
+ setIsEditing(false);
58
+ // revert to original value
59
+ // determineChangedValue();
60
+ }
61
+ };
62
+
63
+ useEffect(() => {
64
+ if (inputRef && inputRef.current && isEditing === true) {
65
+ inputRef.current.value = value;
66
+ inputRef.current.focus();
67
+ if (inputRef && inputRef.current) {
68
+ inputRef.current?.addEventListener('keyup', upHandler);
69
+ }
70
+ }
71
+ // Remove event listeners on cleanup
72
+ return () => {
73
+ if (inputRef && inputRef.current) {
74
+ inputRef.current.removeEventListener('keyup', upHandler);
75
+ }
76
+ };
77
+ }, [isEditing, inputRef]);
78
+
79
+ const handleEditClick = (e: MouseEvent) => {
80
+ if (e.currentTarget instanceof HTMLButtonElement) {
81
+ setIsEditing((prev) => !prev);
82
+ }
83
+ };
84
+
85
+ return html`
86
+ <div
87
+ ref=${containerRef}
88
+ class="${styles.editableTextWrapper} ${customStyles?.wrapperClassName}"
89
+ style="${isHovered ? 'grid-template-columns: minmax(20px, 1fr) 30px;' : ''}"
90
+ >
91
+ ${isEditing
92
+ ? html`<input
93
+ class="${styles.input} ${customStyles?.inputClassName}"
94
+ ref=${inputRef}
95
+ />`
96
+ : html` <${OverflowTooltip} text=${value} /> `}
97
+ ${!isEditing &&
98
+ isHovered &&
99
+ html`
100
+ <button class=${styles.editButton} onclick=${handleEditClick}>
101
+ <svg
102
+ width="12"
103
+ height="12"
104
+ viewBox="0 0 12 12"
105
+ fill="none"
106
+ xmlns="http://www.w3.org/2000/svg"
107
+ >
108
+ <path
109
+ fill-rule="evenodd"
110
+ clip-rule="evenodd"
111
+ d="M1.22758 11.3122C1.1985 11.327 1.15461 11.327 1.11071 11.327L1.1107 11.327C1.00864 11.327 0.891777 11.2831 0.803982 11.1953C0.687111 11.0784 0.643213 10.9034 0.687111 10.7574L1.57761 7.70745C1.63634 7.54667 1.72356 7.38648 1.84043 7.26961L8.11669 0.979047C8.51063 0.585109 9.16739 0.585109 9.56133 0.979047L11.006 2.42368C11.1958 2.61294 11.2978 2.86152 11.2978 3.13858C11.2978 3.41564 11.1958 3.67846 11.006 3.86831L4.71539 10.1589C4.59852 10.2906 4.43833 10.3778 4.27756 10.4217L1.22758 11.3122ZM8.72894 4.92028L7.0796 3.27095L2.74516 7.6054L4.39449 9.25473L8.72894 4.92028ZM8.75798 1.59257C8.78706 1.56349 8.83096 1.54867 8.86003 1.54867C8.90393 1.54867 8.933 1.56349 8.96208 1.59257L10.4067 3.0372C10.4358 3.0811 10.4506 3.12499 10.4506 3.13925C10.4506 3.15407 10.4506 3.21222 10.4067 3.2413L9.35659 4.29256L7.70725 2.64322L8.75798 1.59257ZM3.60653 9.69257L2.29302 8.37905L1.75316 10.2325L3.60653 9.69257Z"
112
+ fill="#4250f0"
113
+ />
114
+ </svg>
115
+ </button>
116
+ `}
117
+ </div>
118
+ `;
119
+ };
120
+
121
+ export { EditableText, EditableTextProps };
@@ -0,0 +1,38 @@
1
+ .editableTextWrapper {
2
+ display: flex;
3
+ width: 100%;
4
+ .input,
5
+ .value {
6
+ display: block;
7
+ display: flex;
8
+ align-items: center;
9
+ font-size: inherit;
10
+ line-height: inherit;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+ .input {
15
+ flex: 1;
16
+ overflow: visible;
17
+ font-family: inherit;
18
+ font-size: inherit;
19
+ line-height: inherit;
20
+ &:focus {
21
+ outline-offset: 0;
22
+ }
23
+ }
24
+ .input,
25
+ .editButton {
26
+ border: 0;
27
+ outline: 0;
28
+ background: none;
29
+ box-shadow: none;
30
+ text-shadow: none;
31
+ }
32
+ .editButton {
33
+ display: flex;
34
+ cursor: pointer;
35
+ align-items: center;
36
+ margin-left: 4px;
37
+ }
38
+ }