@integry/sdk 4.7.39 → 4.7.40

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 (267) hide show
  1. package/dist/esm/index.csm.js +1 -1
  2. package/dist/umd/index.umd.js +1 -1
  3. package/package.json +6 -1
  4. package/.eslintignore +0 -1
  5. package/.vscode/launch.json +0 -17
  6. package/CHANGELOG_INTERNAL.md +0 -134
  7. package/README_INTERNAL.md +0 -176
  8. package/THIRD_PARTY_LICENSES +0 -525
  9. package/generateTests.js +0 -80
  10. package/jest.config.cjs +0 -10
  11. package/src/components/AddTagButton/index.ts +0 -23
  12. package/src/components/BasicSelect/index.ts +0 -123
  13. package/src/components/BasicSelect/styles.module.scss +0 -44
  14. package/src/components/Button/index.ts +0 -97
  15. package/src/components/Button/styles.module.scss +0 -152
  16. package/src/components/CheckboxGroup/Checkbox.ts +0 -104
  17. package/src/components/CheckboxGroup/index.ts +0 -190
  18. package/src/components/CheckboxGroup/styles.module.scss +0 -63
  19. package/src/components/CollapsedMenu/index.ts +0 -104
  20. package/src/components/CollapsedMenu/styles.module.scss +0 -46
  21. package/src/components/ConfigureFieldWrapper/index.ts +0 -85
  22. package/src/components/ConfigureFieldWrapper/styles.module.scss +0 -57
  23. package/src/components/EditableText/index.ts +0 -121
  24. package/src/components/EditableText/styles.module.scss +0 -38
  25. package/src/components/EditableTextArea/index.ts +0 -143
  26. package/src/components/EditableTextArea/styles.module.scss +0 -91
  27. package/src/components/ErrorMessage/index.ts +0 -16
  28. package/src/components/ErrorMessage/styles.module.scss +0 -19
  29. package/src/components/ErrorPage/index.ts +0 -42
  30. package/src/components/ErrorPage/styles.module.scss +0 -26
  31. package/src/components/Footer/index.ts +0 -41
  32. package/src/components/Footer/styles.module.scss +0 -40
  33. package/src/components/HTMLContent/index.tsx +0 -205
  34. package/src/components/HTMLContent/styles.module.scss +0 -3
  35. package/src/components/InfoBox/index.ts +0 -48
  36. package/src/components/InfoBox/styles.module.scss +0 -21
  37. package/src/components/Input/BaseInput/index.ts +0 -170
  38. package/src/components/Input/BaseInput/styles.module.scss +0 -95
  39. package/src/components/Input/DateInput/index.ts +0 -103
  40. package/src/components/Input/DateInput/styles.module.scss +0 -50
  41. package/src/components/Input/Input/index.ts +0 -225
  42. package/src/components/Input/Input/styles.module.scss +0 -16
  43. package/src/components/Input/PasswordInput/index.ts +0 -164
  44. package/src/components/Input/PasswordInput/styles.module.scss +0 -37
  45. package/src/components/Input/index.ts +0 -7
  46. package/src/components/Label/index.ts +0 -61
  47. package/src/components/Label/styles.module.scss +0 -41
  48. package/src/components/LargeLoader/index.ts +0 -25
  49. package/src/components/LargeLoader/styles.module.scss +0 -16
  50. package/src/components/Listbox/ListBoxItem.ts +0 -57
  51. package/src/components/Listbox/index.ts +0 -488
  52. package/src/components/Listbox/styles.module.scss +0 -197
  53. package/src/components/Loader/index.ts +0 -25
  54. package/src/components/Loader/styles.module.scss +0 -16
  55. package/src/components/MediaGallery/MediaGalleryModal.ts +0 -82
  56. package/src/components/MediaGallery/MediaSlider.ts +0 -76
  57. package/src/components/MediaGallery/index.ts +0 -92
  58. package/src/components/MediaGallery/styles.module.scss +0 -156
  59. package/src/components/MediaUpload/index.ts +0 -233
  60. package/src/components/MediaUpload/styles.module.scss +0 -118
  61. package/src/components/Modal/index.ts +0 -87
  62. package/src/components/Modal/styles.module.scss +0 -441
  63. package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +0 -59
  64. package/src/components/MultipurposeField/Dropdown/index.tsx +0 -1202
  65. package/src/components/MultipurposeField/Dropdown/styles.module.scss +0 -215
  66. package/src/components/MultipurposeField/TagMenu/index.ts +0 -536
  67. package/src/components/MultipurposeField/TagMenu/styles.module.scss +0 -175
  68. package/src/components/MultipurposeField/TagOptions/index.tsx +0 -83
  69. package/src/components/MultipurposeField/TagOptions/styles.module.scss +0 -95
  70. package/src/components/MultipurposeField/index.tsx +0 -944
  71. package/src/components/MultipurposeField/styles.module.scss +0 -77
  72. package/src/components/NewModal/index.ts +0 -69
  73. package/src/components/NewModal/styles.module.scss +0 -70
  74. package/src/components/OverflowTooltip/index.tsx +0 -59
  75. package/src/components/PopUp/ConfirmationPopUp/index.ts +0 -58
  76. package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +0 -49
  77. package/src/components/PopUp/SuccessPopUp/index.ts +0 -62
  78. package/src/components/PopUp/SuccessPopUp/styles.module.scss +0 -38
  79. package/src/components/RadioGroup/Radio.ts +0 -128
  80. package/src/components/RadioGroup/index.ts +0 -169
  81. package/src/components/RadioGroup/styles.module.scss +0 -81
  82. package/src/components/Search/index.ts +0 -69
  83. package/src/components/Search/styles.module.scss +0 -149
  84. package/src/components/TabBar/Tab.ts +0 -33
  85. package/src/components/TabBar/index.ts +0 -64
  86. package/src/components/TabBar/styles.module.scss +0 -43
  87. package/src/components/Tag/index.ts +0 -29
  88. package/src/components/Tag/styles.module.scss +0 -57
  89. package/src/components/TagsMenu/index.ts +0 -1697
  90. package/src/components/TagsMenu/styles.module.scss +0 -350
  91. package/src/components/TestComponent/index.ts +0 -71
  92. package/src/components/TestComponent/styles.module.scss +0 -152
  93. package/src/components/TextArea/index.ts +0 -172
  94. package/src/components/TextArea/styles.module.scss +0 -72
  95. package/src/components/TextContent/index.tsx +0 -128
  96. package/src/components/TextContent/styles.module.scss +0 -6
  97. package/src/components/ThreeDotLoader/index.ts +0 -39
  98. package/src/components/ThreeDotLoader/styles.module.scss +0 -41
  99. package/src/components/TimeInput/index.ts +0 -129
  100. package/src/components/TimeInput/styles.module.scss +0 -16
  101. package/src/components/Toggle/index.ts +0 -34
  102. package/src/components/Toggle/styles.module.scss +0 -56
  103. package/src/components/Toggle-v2/index.ts +0 -40
  104. package/src/components/Toggle-v2/styles.module.scss +0 -86
  105. package/src/components/Tooltip/index.ts +0 -271
  106. package/src/components/Tooltip/styles.module.scss +0 -105
  107. package/src/components/form/FunctionField/index.ts +0 -816
  108. package/src/components/form/FunctionField/styles.module.scss +0 -478
  109. package/src/components/form/ObjectField/__snapshots__/index.ts.test.tsx.snap +0 -3
  110. package/src/components/form/ObjectField/index.ts +0 -593
  111. package/src/components/form/ObjectField/index.ts.test.tsx +0 -213
  112. package/src/components/form/ObjectField/styles.module.scss +0 -103
  113. package/src/components/form/index.ts +0 -4
  114. package/src/contexts/AppContext.ts +0 -12
  115. package/src/declaration.d.ts +0 -7
  116. package/src/extensions/HMAC.ts +0 -25
  117. package/src/extensions/IntegryAPIError.ts +0 -19
  118. package/src/features/common/AccountDropdown/index.ts +0 -291
  119. package/src/features/common/AccountDropdown/styles.module.scss +0 -19
  120. package/src/features/common/ActionForm/index.ts +0 -2602
  121. package/src/features/common/ActionForm/styles.module.scss +0 -35
  122. package/src/features/common/AppCard/index.ts +0 -207
  123. package/src/features/common/AppCard/styles.module.scss +0 -117
  124. package/src/features/common/AppCardCompact/index.ts +0 -189
  125. package/src/features/common/AppCardCompact/styles.module.scss +0 -141
  126. package/src/features/common/AuthSelector/index.ts +0 -537
  127. package/src/features/common/AuthSelector/styles.module.scss +0 -161
  128. package/src/features/common/AuthSelectorCompact/index.ts +0 -706
  129. package/src/features/common/AuthSelectorCompact/styles.module.scss +0 -219
  130. package/src/features/common/AuthSelectorDropdown/index.ts +0 -704
  131. package/src/features/common/AuthSelectorDropdown/styles.module.scss +0 -361
  132. package/src/features/common/AuthSelectorV2/index.ts +0 -336
  133. package/src/features/common/AuthSelectorV2/styles.module.scss +0 -235
  134. package/src/features/common/DynamicField/index.ts +0 -402
  135. package/src/features/common/DynamicField/styles.module.scss +0 -266
  136. package/src/features/common/DynamicTypedField/index.ts +0 -504
  137. package/src/features/common/DynamicTypedField/styles.module.scss +0 -135
  138. package/src/features/common/FunctionForm/index.ts +0 -1095
  139. package/src/features/common/FunctionForm/styles.module.scss +0 -225
  140. package/src/features/common/MappingUI/index.ts +0 -649
  141. package/src/features/common/MappingUI/styles.module.scss +0 -121
  142. package/src/features/common/MarketplaceAppCard/index.ts +0 -279
  143. package/src/features/common/MarketplaceAppCard/styles.module.scss +0 -231
  144. package/src/features/common/MarketplaceAppCardCompact/index.ts +0 -283
  145. package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +0 -255
  146. package/src/features/common/NewMappingUI/index.ts +0 -515
  147. package/src/features/common/NewMappingUI/styles.module.scss +0 -113
  148. package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +0 -67
  149. package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +0 -23
  150. package/src/features/common/RequestAppWidget/index.ts +0 -48
  151. package/src/features/common/RequestAppWidget/request-app-form.ts +0 -89
  152. package/src/features/common/RequestAppWidget/styles.module.scss +0 -43
  153. package/src/features/common/SectionField/index.ts +0 -272
  154. package/src/features/common/SectionField/styles.module.scss +0 -67
  155. package/src/features/common/Step/index.ts +0 -827
  156. package/src/features/common/Step/styles.module.scss +0 -12
  157. package/src/features/common/StepNavigation/CollapsedSteps.ts +0 -131
  158. package/src/features/common/StepNavigation/NavItem.ts +0 -111
  159. package/src/features/common/StepNavigation/index.ts +0 -261
  160. package/src/features/common/StepNavigation/styles.module.scss +0 -117
  161. package/src/features/common/Steps/index.ts +0 -1140
  162. package/src/features/common/Steps/styles.module.scss +0 -314
  163. package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +0 -404
  164. package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +0 -367
  165. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.test.tsx +0 -58
  166. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +0 -208
  167. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.test.tsx +0 -49
  168. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +0 -421
  169. package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +0 -577
  170. package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +0 -83
  171. package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +0 -233
  172. package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +0 -45
  173. package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +0 -1085
  174. package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +0 -465
  175. package/src/features/containers/AppFlowContainer/Authentication/index.ts +0 -610
  176. package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +0 -468
  177. package/src/features/containers/AppFlowContainer/index.ts +0 -114
  178. package/src/features/containers/AppPageContainer/AppPage/index.tsx +0 -262
  179. package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +0 -120
  180. package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +0 -165
  181. package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +0 -81
  182. package/src/features/containers/AppPageContainer/index.tsx +0 -93
  183. package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
  184. package/src/features/containers/AppsForFlows/index.ts +0 -161
  185. package/src/features/containers/AppsForFlows/styles.module.scss +0 -280
  186. package/src/features/containers/AppsForFlowsCompact/index.ts +0 -161
  187. package/src/features/containers/AppsForFlowsCompact/styles.module.scss +0 -279
  188. package/src/features/containers/AuthSetupContainer/AppSelection.ts +0 -73
  189. package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +0 -67
  190. package/src/features/containers/AuthSetupContainer/Footer.ts +0 -32
  191. package/src/features/containers/AuthSetupContainer/Header.ts +0 -39
  192. package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +0 -27
  193. package/src/features/containers/AuthSetupContainer/index.ts +0 -349
  194. package/src/features/containers/AuthSetupContainer/styles.module.scss +0 -229
  195. package/src/features/containers/FlowSetupContainer/index.ts +0 -391
  196. package/src/features/containers/FlowSetupContainer/styles.module.scss +0 -18
  197. package/src/features/containers/MarkeplaceApps/index.ts +0 -583
  198. package/src/features/containers/MarkeplaceApps/styles.module.scss +0 -558
  199. package/src/features/containers/MarketplaceAppsCompact/index.ts +0 -585
  200. package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +0 -563
  201. package/src/features/containers/MarketplaceAppsContainer/index.ts +0 -91
  202. package/src/features/containers/MarketplaceContainer/AppCard/index.ts +0 -91
  203. package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +0 -66
  204. package/src/features/containers/MarketplaceContainer/AppListing/index.ts +0 -34
  205. package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +0 -10
  206. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +0 -132
  207. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +0 -117
  208. package/src/features/containers/MarketplaceContainer/index.ts +0 -242
  209. package/src/features/containers/MarketplaceContainer/styles.module.scss +0 -84
  210. package/src/features/containers/SDKContainer/index.ts +0 -817
  211. package/src/features/containers/SDKContainer/styles.module.scss +0 -266
  212. package/src/features/containers/SDKDebugContainer/index.ts +0 -137
  213. package/src/features/containers/SDKDebugContainer/styles.module.scss +0 -37
  214. package/src/features/containers/SDKFailedContainer/index.ts +0 -117
  215. package/src/features/containers/SDKFailedContainer/styles.module.scss +0 -57
  216. package/src/features/integrations/IntegrationRow/Icons.ts +0 -77
  217. package/src/features/integrations/IntegrationRow/index.ts +0 -129
  218. package/src/features/integrations/IntegrationRow/styles.module.scss +0 -62
  219. package/src/features/integrations/IntegrationsHeader/index.ts +0 -34
  220. package/src/features/integrations/IntegrationsHeader/styles.module.scss +0 -47
  221. package/src/features/integrations/IntegrationsList/index.ts +0 -252
  222. package/src/features/integrations/IntegrationsList/styles.module.scss +0 -67
  223. package/src/features/templates/Template/index.ts +0 -295
  224. package/src/features/templates/Template/styles.module.scss +0 -226
  225. package/src/features/templates/TemplatesView/index.ts +0 -368
  226. package/src/features/templates/TemplatesView/styles.module.scss +0 -71
  227. package/src/features/templates/TemplatesViewCompact/index.ts +0 -364
  228. package/src/features/templates/TemplatesViewCompact/styles.module.scss +0 -141
  229. package/src/hooks/useAutosizeTextArea.ts +0 -22
  230. package/src/hooks/useCustomRef.ts +0 -13
  231. package/src/hooks/useDebounce.ts +0 -17
  232. package/src/hooks/useElementResize.ts +0 -40
  233. package/src/hooks/useEventListener.ts +0 -42
  234. package/src/hooks/useHover.ts +0 -40
  235. package/src/hooks/useOnClickOutside.ts +0 -32
  236. package/src/index.ts +0 -2244
  237. package/src/index.umd.ts +0 -13
  238. package/src/interfaces/index.ts +0 -938
  239. package/src/modules/api/index.ts +0 -1325
  240. package/src/modules/api/responseHandler.ts +0 -38
  241. package/src/modules/event-emitter/index.ts +0 -72
  242. package/src/modules/event-emitter/runners/abstract.ts +0 -21
  243. package/src/modules/event-emitter/runners/default.ts +0 -11
  244. package/src/modules/event-emitter/runners/ntimes.ts +0 -28
  245. package/src/modules/event-emitter/types.ts +0 -34
  246. package/src/store/actionFunctions.ts +0 -1578
  247. package/src/store/index.ts +0 -17
  248. package/src/store/initialState.ts +0 -58
  249. package/src/types/index.ts +0 -320
  250. package/src/types/preact-compat.d.ts +0 -4
  251. package/src/types/store.ts +0 -366
  252. package/src/types/utils.ts +0 -19
  253. package/src/utils/ActivityOutputUtils.ts +0 -176
  254. package/src/utils/common.ts +0 -20
  255. package/src/utils/copyToClipboard.ts +0 -24
  256. package/src/utils/datetime.ts +0 -101
  257. package/src/utils/getUrlParam.ts +0 -11
  258. package/src/utils/isAuthMessage.ts +0 -16
  259. package/src/utils/isBrowser.ts +0 -1
  260. package/src/utils/jsonEncodeDecode.ts +0 -15
  261. package/src/utils/objectUtils.ts +0 -117
  262. package/src/utils/popup.ts +0 -30
  263. package/src/utils/searchJson.ts +0 -51
  264. package/src/utils/stepUtils.ts +0 -45
  265. package/src/utils/truncate.ts +0 -6
  266. package/test/setup.ts +0 -1
  267. package/vitest.config.ts +0 -16
@@ -1,488 +0,0 @@
1
- /* eslint-disable no-use-before-define */
2
- import { html } from 'htm/preact';
3
- import { useCallback, useEffect, useMemo, useState } from 'preact/hooks';
4
- import fuzzysort from 'fuzzysort';
5
- import { createNewSortInstance } from 'fast-sort';
6
- import { Label } from '@/components/Label';
7
- import { Hint } from '@/components/Tooltip';
8
- import { useOnClickOutside } from '@/hooks/useOnClickOutside';
9
- import { ThreeDotLoader } from '@/components/ThreeDotLoader';
10
- import { IntegryAPI } from '@/modules/api';
11
- import { ErrorMessage } from '@/components/ErrorMessage';
12
- import useCustomRef from '@/hooks/useCustomRef';
13
- import { ListBoxItem, ListBoxItemProps } from './ListBoxItem';
14
-
15
- import styles from './styles.module.scss';
16
-
17
- interface ListBoxProps {
18
- title: string;
19
- description: string;
20
- items: Omit<ListBoxItemProps, 'onClick'>[];
21
- value?: string;
22
- onChange(val: string): void;
23
- isOpen?: boolean;
24
- isDynamic?: boolean;
25
- endpointUrl?: string;
26
- isSearchable?: boolean;
27
- placeholder: string | null;
28
- isRequired?: boolean;
29
- showStepValidation?: boolean;
30
- responseMapper?(input: unknown): Omit<ListBoxItemProps, 'onClick'>[];
31
- apiHandler: IntegryAPI;
32
- endpointData: string;
33
- isReadOnly?: boolean;
34
- isChanged?: boolean;
35
- isEditable?: boolean;
36
- }
37
-
38
- const ListBox = (props: ListBoxProps) => {
39
- const {
40
- title,
41
- description,
42
- items: passedItems = [],
43
- value = null,
44
- isOpen = false,
45
- isDynamic = false,
46
- endpointData,
47
- isSearchable = false,
48
- isRequired = false,
49
- placeholder,
50
- onChange = () => null,
51
- showStepValidation = false,
52
- responseMapper = (input: { id: string; value: string }[]) => input,
53
- isReadOnly = false,
54
- isChanged = false,
55
- endpointUrl,
56
- isEditable = false,
57
- } = props;
58
-
59
- const [query, setQuery] = useState<string>('');
60
- const [editableTextValue, setEditableTextValue] = useState<string>('');
61
-
62
- const [items, setItems] = useState<Omit<ListBoxItemProps, 'onClick'>[]>(
63
- passedItems,
64
- );
65
-
66
- const [highlightedIndex, setHighlightedIndex] = useState<number>(-1);
67
-
68
- const [filteredItems, setFilteredItems] = useState<
69
- Omit<ListBoxItemProps, 'onClick'>[]
70
- >(passedItems);
71
-
72
- const [loading, setLoading] = useState(
73
- isDynamic && !passedItems.length && !value,
74
- );
75
-
76
- const [isDropdownOpen, setIsDropdownOpen] = useState(isOpen);
77
-
78
- const [dropdownRef] = useCustomRef<HTMLDivElement>();
79
- const [inputRef] = useCustomRef<HTMLInputElement>();
80
-
81
- useOnClickOutside(dropdownRef, () => {
82
- if (isDropdownOpen) {
83
- setIsDropdownOpen(false);
84
- setHighlightedIndex(-1);
85
- }
86
- });
87
-
88
- useEffect(() => {
89
- if (highlightedIndex > -1 && isDropdownOpen) {
90
- const item = filteredItems[highlightedIndex];
91
- if (item) {
92
- const domEl = document.querySelector(`[data-value="${item.value}"]`);
93
- domEl?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
94
- }
95
- }
96
- }, [highlightedIndex, isDropdownOpen]);
97
-
98
- useEffect(() => {
99
- if (dropdownRef && dropdownRef.current && isDropdownOpen === true) {
100
- if (dropdownRef && dropdownRef.current) {
101
- dropdownRef.current?.addEventListener('keyup', upHandler);
102
- }
103
- }
104
- // Remove event listeners on cleanup
105
- return () => {
106
- if (dropdownRef && dropdownRef.current) {
107
- dropdownRef.current.removeEventListener('keyup', upHandler);
108
- }
109
- };
110
- }, [isDropdownOpen, dropdownRef, highlightedIndex]);
111
-
112
- useEffect(() => {
113
- let timer: null | ReturnType<typeof setTimeout> = null;
114
- const item = items.find((a) => a.id === value);
115
-
116
- if (!isDropdownOpen && query && !value) {
117
- setQuery('');
118
- timer = setTimeout(() => {
119
- setSortedFilteredItems(items);
120
- }, 250);
121
- } else if (!isDropdownOpen && value && item) {
122
- setQuery(item.value);
123
- }
124
- return () => {
125
- if (timer) clearTimeout(timer);
126
- };
127
- }, [isDropdownOpen]);
128
-
129
- useEffect(() => {
130
- if (query && isSearchable) {
131
- const filtered = fuzzysort
132
- .go(query, items, {
133
- keys: ['value'],
134
- scoreFn: (keysResult) => {
135
- const nameResult = keysResult[0];
136
- const tagsResult = keysResult[1];
137
- // assign higher score to name result
138
- const score = Math.max(
139
- nameResult ? nameResult.score + 100 : -Infinity,
140
- tagsResult ? tagsResult.score : -Infinity,
141
- );
142
- return score;
143
- },
144
- })
145
- .map((el) => el.obj);
146
- setHighlightedIndex(-1);
147
- setSortedFilteredItems(filtered);
148
- if (filtered.length === 1) setHighlightedIndex(0);
149
- } else if (isDropdownOpen) {
150
- setHighlightedIndex(-1);
151
- setSortedFilteredItems(items);
152
- }
153
- }, [query]);
154
-
155
- useEffect(() => {
156
- // eslint-disable-next-line @typescript-eslint/no-shadow
157
- const { isDynamic, endpointUrl } = props;
158
- if (isDynamic && endpointUrl) {
159
- fetchDynamicData();
160
- } else if (!isDynamic && endpointUrl) {
161
- // if isDynamic is false, endpointUrl will have JSON data instead of URL
162
- try {
163
- const data = JSON.parse(endpointUrl);
164
- setItems(responseMapper(data));
165
- setFilteredItems(responseMapper(data));
166
- setLoading(false);
167
- } catch (error) {
168
- console.error(error);
169
- }
170
- }
171
- }, [endpointData]);
172
-
173
- const fetchDynamicData = (): void => {
174
- const { apiHandler } = props;
175
- if (endpointUrl) {
176
- setLoading(true);
177
- let data;
178
- try {
179
- data = JSON.parse(endpointData);
180
- } catch (error) {
181
- data = '';
182
- }
183
- apiHandler
184
- .callDynamicDataEndpoint<
185
- {
186
- id: string;
187
- value: string;
188
- }[]
189
- >(new URL(endpointUrl), data)
190
- .then((res) => {
191
- if (res) {
192
- setItems(responseMapper(res));
193
- setSortedFilteredItems(responseMapper(res));
194
- // if value was selected before items were loaded, select it again
195
- if (value && isSearchable) {
196
- const item = responseMapper(res).find((a) => a.id === value);
197
- if (item) {
198
- setQuery(item.value);
199
- } else {
200
- setQuery('');
201
- }
202
- setLoading(false);
203
- } else {
204
- setQuery('');
205
- setLoading(false);
206
- }
207
- }
208
- });
209
- }
210
- };
211
-
212
- const setSortedFilteredItems = (
213
- data: { id: string; value: string }[],
214
- ): void => {
215
- const naturalSort = createNewSortInstance({
216
- comparer: new Intl.Collator(undefined, {
217
- numeric: true,
218
- sensitivity: 'base',
219
- }).compare,
220
- });
221
- const sorted = naturalSort(data).asc((item) => item.value);
222
- setFilteredItems(sorted);
223
- };
224
-
225
- // If released key is our target key then set to false
226
- const upHandler = useCallback(
227
- ({ key }: { key: string }): void => {
228
- switch (key) {
229
- case 'Enter': // item selected
230
- onDropdownItemClicked(filteredItems[highlightedIndex]);
231
- break;
232
- case 'Escape': // cancel selection
233
- setIsDropdownOpen(false);
234
- inputRef.current?.blur();
235
- break;
236
- case 'ArrowDown': {
237
- if (highlightedIndex < 0) {
238
- setHighlightedIndex(0); // first item
239
- } else if (highlightedIndex < filteredItems.length - 1) {
240
- setHighlightedIndex((idx) => idx + 1); // next item
241
- } else {
242
- setHighlightedIndex(0); // wrap around
243
- }
244
- break;
245
- }
246
- case 'ArrowUp': {
247
- if (highlightedIndex < 0) {
248
- setHighlightedIndex(filteredItems.length - 1); // last item
249
- } else if (
250
- highlightedIndex < filteredItems.length &&
251
- highlightedIndex > 0
252
- ) {
253
- setHighlightedIndex((idx) => idx - 1); // previous item
254
- } else {
255
- setHighlightedIndex(filteredItems.length - 1); // wrap around
256
- }
257
- break;
258
- }
259
- default:
260
- break;
261
- }
262
- },
263
- [highlightedIndex, filteredItems],
264
- );
265
-
266
- const toggleDropdown = () => {
267
- if (!isReadOnly) {
268
- if (!isDropdownOpen) {
269
- setQuery('');
270
- inputRef.current?.focus();
271
- }
272
- setIsDropdownOpen((prev) => !prev);
273
- }
274
- };
275
-
276
- const onDropdownItemClicked = (el: Omit<ListBoxItemProps, 'onClick'>) => {
277
- onChange(el.id);
278
- setIsDropdownOpen(false);
279
- if (isEditable) {
280
- setEditableTextValue(el.value);
281
- setQuery('');
282
- inputRef.current?.blur();
283
- }
284
- if (isSearchable) {
285
- setQuery(el.value);
286
- inputRef.current?.blur();
287
- }
288
- };
289
-
290
- const onInputClicked = (e: InputEvent) => {
291
- e.stopPropagation();
292
- if (!isDropdownOpen && !isReadOnly) {
293
- setQuery('');
294
- setIsDropdownOpen(true);
295
- }
296
- };
297
-
298
- const getSelectedItem = useMemo(() => {
299
- const index = items.findIndex((el) => el.id === value);
300
- return index > -1 ? items[index].value : 'Please Select...';
301
- }, [items, value]);
302
-
303
- const getItemFromText = (
304
- textValue: string,
305
- ): {
306
- id: string;
307
- value: string;
308
- } => {
309
- let tempItem = {
310
- id: textValue,
311
- value: textValue,
312
- };
313
- let itemFound = false;
314
- items.forEach((item) => {
315
- if (item.id === textValue && !itemFound) {
316
- tempItem = item;
317
- itemFound = true;
318
- }
319
- });
320
- if (!itemFound) {
321
- items.forEach((item) => {
322
- if (item.value === textValue && !itemFound) {
323
- tempItem = item;
324
- itemFound = true;
325
- }
326
- });
327
- }
328
- return tempItem;
329
- };
330
-
331
- const updateValue = (e: InputEvent) => {
332
- if (e.currentTarget instanceof HTMLInputElement) {
333
- const { value: newValue } = e.currentTarget;
334
-
335
- if (isEditable) {
336
- const tempItem = getItemFromText(newValue);
337
- onChange(tempItem.id);
338
- setEditableTextValue(tempItem.value);
339
- setQuery(tempItem.value.trim());
340
- } else if (newValue !== '') {
341
- setQuery(newValue.trim());
342
- }
343
- }
344
- };
345
-
346
- const handleRefreshClick = (): void => {
347
- fetchDynamicData();
348
- onChange('');
349
- setIsDropdownOpen(false);
350
- if (isSearchable) {
351
- setQuery('');
352
- inputRef.current?.blur();
353
- }
354
- };
355
-
356
- return html`
357
- <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
358
- <div ref=${dropdownRef} class="${styles.listboxGroupWrapper}">
359
- <fieldset>
360
- ${title &&
361
- html`
362
- <${Label}
363
- title=${title}
364
- description=${description}
365
- isRequired=${isRequired}
366
- labelTag=${isReadOnly && isChanged ? 'Changed' : ''}
367
- allowRefresh=${isDynamic && endpointUrl}
368
- handleRefreshClick=${handleRefreshClick}
369
- />
370
- `}
371
- <div class=${styles.listbox}>
372
- <div
373
- class=${`${styles.customSelect} ${
374
- isDropdownOpen ? styles.open : ''
375
- }`}
376
- >
377
- ${isReadOnly &&
378
- html`<span
379
- class=${styles.readonlyHint}
380
- data-hint=${isReadOnly ? `` : ''}
381
- ></span>`}
382
- <div
383
- class=${`${styles.customSelectTrigger} ${
384
- showStepValidation &&
385
- !value &&
386
- isRequired &&
387
- !isDropdownOpen &&
388
- styles.error
389
- } ${isSearchable && styles.searchable} ${
390
- isReadOnly ? styles.readonly : ''
391
- }`}
392
- role="button"
393
- tabindex=${0}
394
- onclick=${toggleDropdown}
395
- >
396
- <span class=${value && styles.selected}>
397
- ${loading
398
- ? html`Loading`
399
- : html` ${isSearchable || isEditable
400
- ? html`
401
- <input
402
- ref=${inputRef}
403
- class=${styles.searchInput}
404
- placeholder=${placeholder ||
405
- (isEditable
406
- ? 'Please select or enter value...'
407
- : 'Please Select or Search...')}
408
- value=${isEditable ? editableTextValue : query}
409
- oninput=${updateValue}
410
- onclick=${onInputClicked}
411
- readonly=${isReadOnly}
412
- />
413
- `
414
- : html`
415
- ${items.length > 0
416
- ? html`
417
- ${value
418
- ? html`${getSelectedItem}`
419
- : html`${placeholder || 'Please Select...'}`}
420
- `
421
- : html`No options`}
422
- `}`}
423
- </span>
424
-
425
- <div ref=${dropdownRef} style="display: flex;">
426
- ${loading
427
- ? html`<${ThreeDotLoader} color="#ababab"><//>`
428
- : html`
429
- <div
430
- class=${`${styles.arrow} ${
431
- isDropdownOpen ? styles.close : ''
432
- } ${isReadOnly ? styles.readonly : ''}`}
433
- >
434
- <svg
435
- width="12"
436
- height="8"
437
- viewBox="0 0 12 8"
438
- fill="none"
439
- xmlns="http://www.w3.org/2000/svg"
440
- >
441
- <path
442
- d="M11 1.5L6 6.5L1 1.5"
443
- stroke="#999999"
444
- stroke-width="2"
445
- stroke-linecap="round"
446
- />
447
- </svg>
448
- </div>
449
- `}
450
- </div>
451
- </div>
452
- <div class=${styles.customOptions}>
453
- ${items.length > 0 &&
454
- !loading &&
455
- html`
456
- ${filteredItems.map(
457
- (el, idx) => html`
458
- <${ListBoxItem}
459
- key=${el.id}
460
- id=${el.id}
461
- value=${el.value}
462
- isHighlighted=${highlightedIndex === idx}
463
- isSelected=${value === el.id}
464
- onClick=${() => onDropdownItemClicked(el)}
465
- ><//>
466
- `,
467
- )}
468
- `}
469
- ${isSearchable &&
470
- query &&
471
- !filteredItems.length &&
472
- !loading &&
473
- html`<div class=${styles.noResults}>No results found</div>`}
474
- </div>
475
- </div>
476
- ${showStepValidation &&
477
- !value &&
478
- !isDropdownOpen &&
479
- isRequired &&
480
- html` <${ErrorMessage}>Please select an option</${ErrorMessage}>`}
481
- </div>
482
- </fieldset>
483
- </div>
484
- <//>
485
- `;
486
- };
487
-
488
- export { ListBox, ListBoxProps };
@@ -1,197 +0,0 @@
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: 285px;
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.197647px;
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
- .customSelectTrigger {
36
- position: relative;
37
- display: flex;
38
- align-items: center;
39
- box-sizing: border-box;
40
- height: 35px;
41
- padding: 0 10px;
42
- justify-content: space-between;
43
- cursor: pointer;
44
- font-size: 14px;
45
- font-family: inherit;
46
- border: 1px solid #e2e0db;
47
- border-radius: 4px;
48
- span {
49
- display: flex;
50
- flex: 1;
51
- align-items: center;
52
- height: 100%;
53
- padding-right: 10px;
54
- white-space: nowrap;
55
- overflow: hidden;
56
- text-overflow: ellipsis;
57
- &.selected {
58
- color: #333333;
59
- }
60
- }
61
- &:focus {
62
- outline: none;
63
- }
64
- &.error {
65
- border-color: #f05c42;
66
- }
67
- &.searchable {
68
- // cursor: text;
69
- }
70
- .arrow {
71
- transform: rotate(0);
72
- cursor: pointer;
73
- transition-property: transform;
74
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
75
- transition-duration: 150ms;
76
- &.close {
77
- transform: rotate(180deg);
78
- }
79
- &.readonly {
80
- cursor: auto;
81
- }
82
- }
83
- .searchInput {
84
- border: 0;
85
- outline: none;
86
- width: 100%;
87
- color: #333;
88
- font-size: 12px;
89
- font-family: inherit;
90
- padding: 0;
91
- margin: 0;
92
- height: 100%;
93
- &::placeholder {
94
- color: #999999;
95
- }
96
- }
97
- &.readonly {
98
- cursor: auto;
99
- }
100
- }
101
- .customOptions {
102
- position: absolute;
103
- top: 100%;
104
- left: 0px;
105
- right: 0px;
106
- z-index: 10;
107
- margin-top: 10px;
108
- display: block;
109
- overflow: hidden;
110
- background-color: #fff;
111
- font-family: inherit;
112
- font-size: 14px;
113
- line-height: 20px;
114
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
115
- transition-property: all;
116
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
117
- transition-duration: 150ms;
118
- pointer-events: none;
119
- visibility: hidden;
120
- max-height: 132px;
121
- min-height: 100%;
122
- overflow-y: auto;
123
- border-width: 1px;
124
- border-style: solid;
125
- border-color: #e2e0db;
126
- opacity: 0;
127
- border-radius: 4px;
128
- &::-webkit-scrollbar {
129
- width: 7px;
130
- }
131
-
132
- /* Track */
133
- &::-webkit-scrollbar-track {
134
- // background: #f1f1f1;
135
- background: transparent;
136
- border-radius: 10px;
137
- }
138
-
139
- /* Handle */
140
- &::-webkit-scrollbar-thumb {
141
- background: #ededed;
142
- border: 1px solid #e7e7e7;
143
- border-radius: 10px;
144
- }
145
-
146
- /* Handle on hover */
147
- &::-webkit-scrollbar-thumb:hover {
148
- background: rgb(116, 116, 116);
149
- }
150
- }
151
- }
152
-
153
- .noResults {
154
- padding-top: 0.5rem;
155
- padding-bottom: 0.5rem;
156
- padding-left: 0.5rem;
157
- }
158
-
159
- .listboxItem {
160
- position: relative;
161
- display: block;
162
- cursor: pointer;
163
- border-width: 0px;
164
- border-bottom-width: 1px;
165
- border-style: solid;
166
- border-color: #e2e0db;
167
- transition-property: all;
168
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
169
- transition-duration: 150ms;
170
- white-space: nowrap;
171
- text-overflow: ellipsis;
172
- overflow: hidden;
173
- padding: 8px 10px;
174
- svg {
175
- position: absolute;
176
- height: 100%;
177
- width: 12px;
178
- left: 16px;
179
- top: 0;
180
- }
181
- &:last-child {
182
- border: none;
183
- }
184
- &:hover {
185
- color: #333;
186
- background: #ececec;
187
- }
188
- &.selected {
189
- color: #333;
190
- font-weight: 500;
191
- background: #ececec;
192
- }
193
- &.highlighted {
194
- color: #333;
195
- background: #ececec;
196
- }
197
- }
@@ -1,25 +0,0 @@
1
- import { html } from 'htm/preact';
2
-
3
- import styles from './styles.module.scss';
4
-
5
- const Loader = ({ fill = '#ADADAD', size='md' }) => html`
6
- <svg
7
- class=${styles.loader}
8
- width="${size === 'sm' ? '12' : '15'}"
9
- height="${size === 'sm' ? '12' : '15'}"
10
- viewBox="0 0 15 15"
11
- fill="none"
12
- xmlns="http://www.w3.org/2000/svg"
13
- >
14
- <path
15
- d="M9.13037 0.179352C7.57047 -0.168051 5.94039 -0.00810102 4.47777 0.635883C3.01515 1.27987 1.79647 2.37421 0.999409 3.75937C0.202348 5.14453 -0.131421 6.74808 0.0467641 8.33623C0.224949 9.92438 0.90577 11.4141 1.98997 12.5882C3.07417 13.7623 4.50506 14.5593 6.07402 14.8632C7.64298 15.167 9.26799 14.9618 10.7121 14.2773C12.1562 13.5929 13.344 12.4651 14.1022 11.0582C14.8604 9.65144 15.1494 8.03922 14.9271 6.45665L14.1844 6.56098C14.3845 7.9853 14.1243 9.43629 13.442 10.7024C12.7596 11.9685 11.6906 12.9836 10.3909 13.5996C9.09119 14.2156 7.62869 14.4003 6.21662 14.1269C4.80455 13.8534 3.51675 13.136 2.54097 12.0794C1.56519 11.0227 0.952454 9.68194 0.792088 8.2526C0.631721 6.82327 0.932113 5.38008 1.64947 4.13343C2.36682 2.88679 3.46363 1.90188 4.77999 1.32229C6.09635 0.742709 7.56343 0.598754 8.96733 0.911417L9.13037 0.179352Z"
16
- fill="#E0E0E0"
17
- />
18
- <path
19
- d="M14.93 6.47755C14.7207 4.95709 14.0501 3.53742 13.0085 2.41017C11.9669 1.28292 10.6046 0.50235 9.10537 0.173829L8.94483 0.906446C10.2941 1.20212 11.5202 1.90462 12.4577 2.91915C13.3951 3.93368 13.9987 5.21138 14.187 6.57979L14.93 6.47755Z"
20
- fill="${fill}"
21
- />
22
- </svg>
23
- `;
24
-
25
- export { Loader };