@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.
- package/.vscode/launch.json +2 -2
- package/THIRD_PARTY_LICENSES +0 -37
- package/dist/esm/index.csm.d.ts +12 -2
- package/dist/esm/index.csm.js +7262 -1
- package/dist/umd/index.umd.d.ts +9 -1
- package/dist/umd/index.umd.js +7262 -1
- package/jest.config.cjs +10 -0
- package/package.json +10 -4
- package/src/components/AddTagButton/index.ts +23 -0
- package/src/components/BasicSelect/index.ts +114 -0
- package/src/components/BasicSelect/styles.module.scss +44 -0
- package/src/components/Button/index.ts +94 -0
- package/src/components/Button/styles.module.scss +152 -0
- package/src/components/CheckboxGroup/Checkbox.ts +104 -0
- package/src/components/CheckboxGroup/index.ts +190 -0
- package/src/components/CheckboxGroup/styles.module.scss +63 -0
- package/src/components/CollapsedMenu/index.ts +101 -0
- package/src/components/CollapsedMenu/styles.module.scss +46 -0
- package/src/components/ConfigureFieldWrapper/index.ts +85 -0
- package/src/components/ConfigureFieldWrapper/styles.module.scss +57 -0
- package/src/components/EditableText/index.ts +121 -0
- package/src/components/EditableText/styles.module.scss +38 -0
- package/src/components/EditableTextArea/index.ts +143 -0
- package/src/components/EditableTextArea/styles.module.scss +91 -0
- package/src/components/ErrorMessage/index.ts +16 -0
- package/src/components/ErrorMessage/styles.module.scss +19 -0
- package/src/components/ErrorPage/index.ts +42 -0
- package/src/components/ErrorPage/styles.module.scss +26 -0
- package/src/components/Footer/index.ts +41 -0
- package/src/components/Footer/styles.module.scss +40 -0
- package/src/components/HTMLContent/index.tsx +275 -0
- package/src/components/HTMLContent/styles.module.scss +3 -0
- package/src/components/InfoBox/index.ts +48 -0
- package/src/components/InfoBox/styles.module.scss +21 -0
- package/src/components/Input/BaseInput/index.ts +170 -0
- package/src/components/Input/BaseInput/styles.module.scss +94 -0
- package/src/components/Input/DateInput/index.ts +103 -0
- package/src/components/Input/DateInput/styles.module.scss +50 -0
- package/src/components/Input/Input/index.ts +206 -0
- package/src/components/Input/Input/styles.module.scss +14 -0
- package/src/components/Input/PasswordInput/index.ts +164 -0
- package/src/components/Input/PasswordInput/styles.module.scss +37 -0
- package/src/components/Input/index.ts +7 -0
- package/src/components/Label/index.ts +61 -0
- package/src/components/Label/styles.module.scss +41 -0
- package/src/components/LargeLoader/index.ts +25 -0
- package/src/components/LargeLoader/styles.module.scss +16 -0
- package/src/components/Listbox/ListBoxItem.ts +57 -0
- package/src/components/Listbox/index.ts +479 -0
- package/src/components/Listbox/styles.module.scss +197 -0
- package/src/components/Loader/index.ts +25 -0
- package/src/components/Loader/styles.module.scss +16 -0
- package/src/components/MediaGallery/MediaGalleryModal.ts +82 -0
- package/src/components/MediaGallery/MediaSlider.ts +76 -0
- package/src/components/MediaGallery/index.ts +92 -0
- package/src/components/MediaGallery/styles.module.scss +156 -0
- package/src/components/MediaUpload/index.ts +233 -0
- package/src/components/MediaUpload/styles.module.scss +118 -0
- package/src/components/Modal/index.ts +87 -0
- package/src/components/Modal/styles.module.scss +441 -0
- package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +58 -0
- package/src/components/MultipurposeField/Dropdown/index.tsx +981 -0
- package/src/components/MultipurposeField/Dropdown/styles.module.scss +208 -0
- package/src/components/MultipurposeField/TagMenu/index.ts +384 -0
- package/src/components/MultipurposeField/TagMenu/styles.module.scss +136 -0
- package/src/components/MultipurposeField/TagOptions/index.tsx +83 -0
- package/src/components/MultipurposeField/TagOptions/styles.module.scss +95 -0
- package/src/components/MultipurposeField/index.tsx +687 -0
- package/src/components/MultipurposeField/styles.module.scss +56 -0
- package/src/components/NewModal/index.ts +69 -0
- package/src/components/NewModal/styles.module.scss +70 -0
- package/src/components/OverflowTooltip/index.tsx +59 -0
- package/src/components/PopUp/ConfirmationPopUp/index.ts +58 -0
- package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +49 -0
- package/src/components/PopUp/SuccessPopUp/index.ts +62 -0
- package/src/components/PopUp/SuccessPopUp/styles.module.scss +38 -0
- package/src/components/RadioGroup/Radio.ts +129 -0
- package/src/components/RadioGroup/index.ts +169 -0
- package/src/components/RadioGroup/styles.module.scss +81 -0
- package/src/components/Search/index.ts +69 -0
- package/src/components/Search/styles.module.scss +149 -0
- package/src/components/TabBar/Tab.ts +33 -0
- package/src/components/TabBar/index.ts +64 -0
- package/src/components/TabBar/styles.module.scss +43 -0
- package/src/components/Tag/index.ts +29 -0
- package/src/components/Tag/styles.module.scss +57 -0
- package/src/components/TextArea/index.ts +172 -0
- package/src/components/TextArea/styles.module.scss +70 -0
- package/src/components/TextContent/index.tsx +128 -0
- package/src/components/TextContent/styles.module.scss +6 -0
- package/src/components/ThreeDotLoader/index.ts +39 -0
- package/src/components/ThreeDotLoader/styles.module.scss +41 -0
- package/src/components/TimeInput/index.ts +129 -0
- package/src/components/TimeInput/styles.module.scss +16 -0
- package/src/components/Toggle/index.ts +34 -0
- package/src/components/Toggle/styles.module.scss +56 -0
- package/src/components/Toggle-v2/index.ts +40 -0
- package/src/components/Toggle-v2/styles.module.scss +86 -0
- package/src/components/Tooltip/index.ts +271 -0
- package/src/components/Tooltip/styles.module.scss +105 -0
- package/src/components/form/ObjectField/index.ts +364 -0
- package/src/components/form/ObjectField/styles.module.scss +103 -0
- package/src/components/form/index.ts +3 -0
- package/src/contexts/AppContext.ts +12 -0
- package/src/declaration.d.ts +7 -0
- package/src/extensions/HMAC.ts +25 -0
- package/src/extensions/IntegryAPIError.ts +19 -0
- package/src/features/common/AccountDropdown/index.ts +291 -0
- package/src/features/common/AccountDropdown/styles.module.scss +19 -0
- package/src/features/common/ActionForm/index.ts +1818 -0
- package/src/features/common/ActionForm/styles.module.scss +23 -0
- package/src/features/common/AppCard/index.ts +207 -0
- package/src/features/common/AppCard/styles.module.scss +117 -0
- package/src/features/common/AppCardCompact/index.ts +189 -0
- package/src/features/common/AppCardCompact/styles.module.scss +141 -0
- package/src/features/common/AuthSelector/index.ts +537 -0
- package/src/features/common/AuthSelector/styles.module.scss +161 -0
- package/src/features/common/AuthSelectorCompact/index.ts +706 -0
- package/src/features/common/AuthSelectorCompact/styles.module.scss +219 -0
- package/src/features/common/AuthSelectorDropdown/index.ts +704 -0
- package/src/features/common/AuthSelectorDropdown/styles.module.scss +361 -0
- package/src/features/common/DynamicField/index.ts +229 -0
- package/src/features/common/DynamicField/styles.module.scss +67 -0
- package/src/features/common/DynamicTypedField/index.ts +217 -0
- package/src/features/common/DynamicTypedField/styles.module.scss +67 -0
- package/src/features/common/FunctionForm/index.ts +862 -0
- package/src/features/common/FunctionForm/styles.module.scss +163 -0
- package/src/features/common/MappingUI/index.ts +649 -0
- package/src/features/common/MappingUI/styles.module.scss +121 -0
- package/src/features/common/MarketplaceAppCard/index.ts +279 -0
- package/src/features/common/MarketplaceAppCard/styles.module.scss +231 -0
- package/src/features/common/MarketplaceAppCardCompact/index.ts +283 -0
- package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +255 -0
- package/src/features/common/NewMappingUI/index.ts +515 -0
- package/src/features/common/NewMappingUI/styles.module.scss +113 -0
- package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +67 -0
- package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +23 -0
- package/src/features/common/RequestAppWidget/index.ts +48 -0
- package/src/features/common/RequestAppWidget/request-app-form.ts +89 -0
- package/src/features/common/RequestAppWidget/styles.module.scss +43 -0
- package/src/features/common/SectionField/index.ts +272 -0
- package/src/features/common/SectionField/styles.module.scss +67 -0
- package/src/features/common/Step/index.ts +827 -0
- package/src/features/common/Step/styles.module.scss +12 -0
- package/src/features/common/StepNavigation/CollapsedSteps.ts +125 -0
- package/src/features/common/StepNavigation/NavItem.ts +111 -0
- package/src/features/common/StepNavigation/index.ts +257 -0
- package/src/features/common/StepNavigation/styles.module.scss +117 -0
- package/src/features/common/Steps/index.ts +1139 -0
- package/src/features/common/Steps/styles.module.scss +314 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +383 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +367 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +194 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +389 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +577 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +83 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +212 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +45 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +1081 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +452 -0
- package/src/features/containers/AppFlowContainer/Authentication/index.ts +610 -0
- package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +468 -0
- package/src/features/containers/AppFlowContainer/index.ts +114 -0
- package/src/features/containers/AppPageContainer/AppPage/index.tsx +262 -0
- package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +120 -0
- package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +165 -0
- package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +81 -0
- package/src/features/containers/AppPageContainer/index.tsx +93 -0
- package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
- package/src/features/containers/AppsForFlows/index.ts +161 -0
- package/src/features/containers/AppsForFlows/styles.module.scss +280 -0
- package/src/features/containers/AppsForFlowsCompact/index.ts +161 -0
- package/src/features/containers/AppsForFlowsCompact/styles.module.scss +279 -0
- package/src/features/containers/AuthSetupContainer/AppSelection.ts +73 -0
- package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +67 -0
- package/src/features/containers/AuthSetupContainer/Footer.ts +32 -0
- package/src/features/containers/AuthSetupContainer/Header.ts +39 -0
- package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +27 -0
- package/src/features/containers/AuthSetupContainer/index.ts +349 -0
- package/src/features/containers/AuthSetupContainer/styles.module.scss +229 -0
- package/src/features/containers/FlowSetupContainer/index.ts +390 -0
- package/src/features/containers/FlowSetupContainer/styles.module.scss +18 -0
- package/src/features/containers/MarkeplaceApps/index.ts +574 -0
- package/src/features/containers/MarkeplaceApps/styles.module.scss +559 -0
- package/src/features/containers/MarketplaceAppsCompact/index.ts +576 -0
- package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +546 -0
- package/src/features/containers/MarketplaceAppsContainer/index.ts +83 -0
- package/src/features/containers/MarketplaceContainer/AppCard/index.ts +91 -0
- package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +66 -0
- package/src/features/containers/MarketplaceContainer/AppListing/index.ts +34 -0
- package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +10 -0
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +132 -0
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +117 -0
- package/src/features/containers/MarketplaceContainer/index.ts +242 -0
- package/src/features/containers/MarketplaceContainer/styles.module.scss +84 -0
- package/src/features/containers/SDKContainer/index.ts +817 -0
- package/src/features/containers/SDKContainer/styles.module.scss +266 -0
- package/src/features/containers/SDKDebugContainer/index.ts +137 -0
- package/src/features/containers/SDKDebugContainer/styles.module.scss +37 -0
- package/src/features/containers/SDKFailedContainer/index.ts +117 -0
- package/src/features/containers/SDKFailedContainer/styles.module.scss +57 -0
- package/src/features/integrations/IntegrationRow/Icons.ts +77 -0
- package/src/features/integrations/IntegrationRow/index.ts +129 -0
- package/src/features/integrations/IntegrationRow/styles.module.scss +62 -0
- package/src/features/integrations/IntegrationsHeader/index.ts +34 -0
- package/src/features/integrations/IntegrationsHeader/styles.module.scss +47 -0
- package/src/features/integrations/IntegrationsList/index.ts +252 -0
- package/src/features/integrations/IntegrationsList/styles.module.scss +67 -0
- package/src/features/templates/Template/index.ts +295 -0
- package/src/features/templates/Template/styles.module.scss +226 -0
- package/src/features/templates/TemplatesView/index.ts +368 -0
- package/src/features/templates/TemplatesView/styles.module.scss +71 -0
- package/src/features/templates/TemplatesViewCompact/index.ts +364 -0
- package/src/features/templates/TemplatesViewCompact/styles.module.scss +141 -0
- package/src/hooks/useAutosizeTextArea.ts +22 -0
- package/src/hooks/useCustomRef.ts +13 -0
- package/src/hooks/useDebounce.ts +17 -0
- package/src/hooks/useElementResize.ts +40 -0
- package/src/hooks/useEventListener.ts +44 -0
- package/src/hooks/useHover.ts +40 -0
- package/src/hooks/useOnClickOutside.ts +32 -0
- package/src/index.ts +2051 -0
- package/src/index.umd.ts +13 -0
- package/src/interfaces/index.ts +924 -0
- package/src/modules/api/index.ts +1315 -0
- package/src/modules/api/responseHandler.ts +38 -0
- package/src/modules/event-emitter/index.ts +72 -0
- package/src/modules/event-emitter/runners/abstract.ts +21 -0
- package/src/modules/event-emitter/runners/default.ts +11 -0
- package/src/modules/event-emitter/runners/ntimes.ts +28 -0
- package/src/modules/event-emitter/types.ts +34 -0
- package/src/store/actionFunctions.ts +1573 -0
- package/src/store/index.ts +17 -0
- package/src/store/initialState.ts +58 -0
- package/src/stories/Button.stories.tsx +83 -0
- package/src/stories/Checkbox/Checkbox.stories.tsx +41 -0
- package/src/stories/Checkbox/CheckboxGroup.stories.tsx +46 -0
- package/src/stories/EditableText.stories.tsx +35 -0
- package/src/stories/Input/BaseInput.stories.tsx +48 -0
- package/src/stories/Input/DateInput.stories.tsx +28 -0
- package/src/stories/Input/Input.stories.tsx +24 -0
- package/src/stories/Input/PasswordInput.stories.tsx +26 -0
- package/src/stories/Introduction.stories.mdx +211 -0
- package/src/stories/Label.stories.tsx +27 -0
- package/src/stories/Listbox.stories.tsx +122 -0
- package/src/stories/Radio/Radio.stories.tsx +39 -0
- package/src/stories/Radio/RadioGroup.stories.tsx +46 -0
- package/src/stories/StepNavigation/NavItem.stories.tsx +31 -0
- package/src/stories/StepNavigation/StepNavigation.stories.tsx +50 -0
- package/src/stories/TabBar.stories.tsx +31 -0
- package/src/stories/TextArea.stories.tsx +23 -0
- package/src/stories/TimeInput.stories.tsx +37 -0
- package/src/stories/Toggle.stories.tsx +33 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/types/index.ts +293 -0
- package/src/types/store.ts +366 -0
- package/src/types/utils.ts +19 -0
- package/src/utils/ActivityOutputUtils.ts +163 -0
- package/src/utils/common.ts +20 -0
- package/src/utils/copyToClipboard.ts +24 -0
- package/src/utils/datetime.ts +101 -0
- package/src/utils/getUrlParam.ts +11 -0
- package/src/utils/isAuthMessage.ts +16 -0
- package/src/utils/isBrowser.ts +1 -0
- package/src/utils/jsonEncodeDecode.ts +15 -0
- package/src/utils/objectUtils.ts +116 -0
- package/src/utils/popup.ts +30 -0
- package/src/utils/searchJson.ts +51 -0
- package/src/utils/stepUtils.ts +45 -0
- package/src/utils/truncate.ts +6 -0
- package/test/setup.ts +1 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable no-use-before-define */
|
|
3
|
+
import { MediaObject, MediaType, UploadFileObj } from '@/interfaces';
|
|
4
|
+
import { html } from 'htm/preact';
|
|
5
|
+
import { useContext, useState, useRef, useEffect } from 'preact/hooks';
|
|
6
|
+
import AppContext from '@/contexts/AppContext';
|
|
7
|
+
import { Loader } from '../Loader';
|
|
8
|
+
import { Input } from '../Input';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
interface MediaUplaodProps {
|
|
13
|
+
media: MediaObject[];
|
|
14
|
+
allowedUploadMediaType?: string;
|
|
15
|
+
allowedMediaLabel?: string;
|
|
16
|
+
singleUpload?: boolean;
|
|
17
|
+
allowUploadViaURL?: boolean;
|
|
18
|
+
handleUploadMedia: (files: UploadFileObj[]) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const MediaUplaod = (props: MediaUplaodProps) => {
|
|
22
|
+
const {
|
|
23
|
+
media,
|
|
24
|
+
allowedUploadMediaType = 'image/png,image/jpg,image/jpeg',
|
|
25
|
+
allowedMediaLabel = 'Supports: JPG, JPEG, PNG',
|
|
26
|
+
singleUpload = false,
|
|
27
|
+
allowUploadViaURL = false,
|
|
28
|
+
handleUploadMedia,
|
|
29
|
+
} = props;
|
|
30
|
+
const context = useContext(AppContext);
|
|
31
|
+
const [uploadFiles, setUploadFiles] = useState<UploadFileObj[]>(media);
|
|
32
|
+
const fileInpuRef = useRef<HTMLInputElement>();
|
|
33
|
+
const newFiletoUploadRef = useRef(false);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (uploadFiles.length > 0) {
|
|
37
|
+
if (newFiletoUploadRef.current === true) {
|
|
38
|
+
const anyFileUploading = uploadFiles.findIndex((fileObj) => fileObj.uploading === true);
|
|
39
|
+
if (anyFileUploading === -1) {
|
|
40
|
+
handleUploadMedia(uploadFiles);
|
|
41
|
+
newFiletoUploadRef.current = false;
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
handleUploadMedia(uploadFiles);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
handleUploadMedia([]);
|
|
48
|
+
}
|
|
49
|
+
}, [uploadFiles]);
|
|
50
|
+
|
|
51
|
+
const triggerFileSelection = (): void => {
|
|
52
|
+
if (fileInpuRef.current) {
|
|
53
|
+
fileInpuRef.current.click();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const getFileType = (fileType: string): MediaType | null => {
|
|
58
|
+
if (fileType.split('/')[0] === 'image') {
|
|
59
|
+
return MediaType.IMAGE;
|
|
60
|
+
}
|
|
61
|
+
if (fileType.split('/')[0] === 'video') {
|
|
62
|
+
return MediaType.VIDEO;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const removeFile = (fileObj: UploadFileObj): void => {
|
|
68
|
+
const updatedUploadedFiles = uploadFiles.filter((tempFile) => {
|
|
69
|
+
if (fileObj.index) {
|
|
70
|
+
return tempFile.index !== fileObj.index
|
|
71
|
+
} if (fileObj.id) {
|
|
72
|
+
return tempFile.id !== fileObj.id
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
76
|
+
setUploadFiles([...updatedUploadedFiles]);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const setFileUploadingStatus = (
|
|
80
|
+
fileIndex: number,
|
|
81
|
+
uploading: boolean,
|
|
82
|
+
url: string
|
|
83
|
+
): void => {
|
|
84
|
+
setUploadFiles((prev) => {
|
|
85
|
+
const updatedUploadedFiles = prev.map((fileObj) =>
|
|
86
|
+
fileObj.index === fileIndex
|
|
87
|
+
? { ...fileObj, uploading, url: url || fileObj.url }
|
|
88
|
+
: fileObj
|
|
89
|
+
);
|
|
90
|
+
return [...updatedUploadedFiles];
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const sendFileUploadRequest = (fileObj: UploadFileObj): void => {
|
|
95
|
+
if (fileObj.file) {
|
|
96
|
+
const requestData = new FormData();
|
|
97
|
+
requestData.set('file', fileObj.file);
|
|
98
|
+
context?.apiHandler
|
|
99
|
+
.uploadFile(requestData)
|
|
100
|
+
.then((data) => {
|
|
101
|
+
if (data) {
|
|
102
|
+
if (fileObj.index) {
|
|
103
|
+
setFileUploadingStatus(fileObj.index, false, data.file_path);
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
console.error(`Failed to upload media`);
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const validateAndUploadFile = (fileObj: UploadFileObj): void => {
|
|
113
|
+
const allowedUploadMediaTypeArray = allowedUploadMediaType.split(',');
|
|
114
|
+
if (allowedUploadMediaTypeArray.includes(fileObj.file.type)) {
|
|
115
|
+
if (fileObj.file.type.includes('image')) {
|
|
116
|
+
const { url } = fileObj;
|
|
117
|
+
const image = new Image();
|
|
118
|
+
image.onload = () => {
|
|
119
|
+
newFiletoUploadRef.current = true;
|
|
120
|
+
if (singleUpload) {
|
|
121
|
+
setUploadFiles([fileObj]);
|
|
122
|
+
} else {
|
|
123
|
+
setUploadFiles((prev) => [...prev, fileObj]);
|
|
124
|
+
}
|
|
125
|
+
sendFileUploadRequest(fileObj);
|
|
126
|
+
};
|
|
127
|
+
image.src = url;
|
|
128
|
+
} else {
|
|
129
|
+
// handle other media types
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
// display error toast
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const handleFileSelection = (e: InputEvent): void => {
|
|
137
|
+
if (e.currentTarget instanceof HTMLInputElement) {
|
|
138
|
+
const selectedFilesRaw = Array.from(e.currentTarget.files || []);
|
|
139
|
+
processSelectedFiles(selectedFilesRaw);
|
|
140
|
+
if (fileInpuRef.current) {
|
|
141
|
+
fileInpuRef.current.value = '';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const processSelectedFiles = (selectedFilesRaw: File[]): void => {
|
|
147
|
+
selectedFilesRaw?.forEach((file, index) => {
|
|
148
|
+
const fileObj = {
|
|
149
|
+
index: Math.floor(Math.random() * 100 + 1) + index,
|
|
150
|
+
file,
|
|
151
|
+
url: URL.createObjectURL(file),
|
|
152
|
+
type: getFileType(file.type),
|
|
153
|
+
uploading: true,
|
|
154
|
+
} as UploadFileObj;
|
|
155
|
+
validateAndUploadFile(fileObj);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const handleRemoveMedia = (mediaItem: UploadFileObj): void => {
|
|
160
|
+
removeFile(mediaItem);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
164
|
+
const dropHandler = (ev: any): void => {
|
|
165
|
+
// Prevent default behavior (Prevent file from being opened)
|
|
166
|
+
ev.preventDefault();
|
|
167
|
+
// Use DataTransfer interface to access the file(s)
|
|
168
|
+
const selectedFilesRaw = [...ev.dataTransfer.files];
|
|
169
|
+
processSelectedFiles(selectedFilesRaw);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const dragOverHandler = (ev: any) => {
|
|
173
|
+
// Prevent default behavior (Prevent file from being opened)
|
|
174
|
+
ev.preventDefault();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return html`
|
|
178
|
+
<div class="${styles.mediaUploadWrap}">
|
|
179
|
+
<div class="${styles.mediaUploader}">
|
|
180
|
+
<div class="${styles.dropMedia}" ondrop=${dropHandler} ondragover=${dragOverHandler}>
|
|
181
|
+
<input
|
|
182
|
+
class="${styles.hiddenFileInput}"
|
|
183
|
+
type="file"
|
|
184
|
+
ref=${fileInpuRef}
|
|
185
|
+
multiple
|
|
186
|
+
accept=${allowedUploadMediaType}
|
|
187
|
+
onChange=${handleFileSelection}
|
|
188
|
+
/>
|
|
189
|
+
<img class="${styles.dropIcon}" />
|
|
190
|
+
<div class="${styles.dropText}">
|
|
191
|
+
Drop your images here
|
|
192
|
+
or <span class="${styles.link}" onclick=${triggerFileSelection}>browse</span>
|
|
193
|
+
<p class=${styles.allowedMediaLabel}>${allowedMediaLabel}</p>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
${allowUploadViaURL && html`
|
|
197
|
+
<div class="${styles.urlField}">
|
|
198
|
+
<${Input} value=""
|
|
199
|
+
className="media-url-field"
|
|
200
|
+
placeholder="Or paste a URL here" />
|
|
201
|
+
</div>
|
|
202
|
+
`}
|
|
203
|
+
</div>
|
|
204
|
+
${uploadFiles.length > 0 && html`
|
|
205
|
+
<div class="${styles.mediaListing}">
|
|
206
|
+
${uploadFiles.map((mediaItem, index) => {
|
|
207
|
+
const { url, type, uploading = false } = mediaItem;
|
|
208
|
+
if (type === MediaType.IMAGE) {
|
|
209
|
+
return html`
|
|
210
|
+
<div class="${styles.mediaPreview}" key=${`media_${mediaItem.id}_${index}}`}>
|
|
211
|
+
${uploading && html `<span class="${styles.uploadingImg}"><${Loader} fill="#4250F0" /></span>`}
|
|
212
|
+
<span class="${styles.backgroundOverlay} ${uploading ? styles.uploading : ''} " />
|
|
213
|
+
${!uploading && html`
|
|
214
|
+
<span class="${styles.delMediaSpan}" onclick=${() => { handleRemoveMedia(mediaItem) }}>
|
|
215
|
+
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
216
|
+
<path d="M1 4H14" stroke="#F05C42" stroke-width="1.4"/>
|
|
217
|
+
<path d="M11.4829 5.5V6.16667L10.8162 13.5H4.14958L3.48291 6.16667V5.5" stroke="#F05C42" stroke-width="1.4" stroke-linejoin="round"/>
|
|
218
|
+
<path d="M5.48291 3.5V2.16667C5.48291 1.79848 5.78139 1.5 6.14958 1.5H8.81624C9.18443 1.5 9.48291 1.79848 9.48291 2.16667V3.5" stroke="#F05C42" stroke-width="1.4"/>
|
|
219
|
+
</svg>
|
|
220
|
+
Delete
|
|
221
|
+
</span>`}
|
|
222
|
+
<img src=${url} alt="media-img" class="${styles.mediaImg}" />
|
|
223
|
+
</div>
|
|
224
|
+
`}
|
|
225
|
+
return html``;
|
|
226
|
+
})}
|
|
227
|
+
</div>
|
|
228
|
+
`}
|
|
229
|
+
</div>
|
|
230
|
+
`;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export default MediaUplaod;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
.mediaUploadWrap {
|
|
2
|
+
.mediaUploader {
|
|
3
|
+
.dropMedia {
|
|
4
|
+
background: rgba(242, 242, 242, 0.5);
|
|
5
|
+
border: 1px dashed #E0E0E0;
|
|
6
|
+
border-radius: 6px;
|
|
7
|
+
width: 288px;
|
|
8
|
+
height: 162px;
|
|
9
|
+
.dropIcon {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
.dropText {
|
|
13
|
+
font-family: inherit;
|
|
14
|
+
font-style: normal;
|
|
15
|
+
font-weight: 400;
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
line-height: 15px;
|
|
18
|
+
text-align: center;
|
|
19
|
+
color: #999999;
|
|
20
|
+
.link {
|
|
21
|
+
font-family: inherit;
|
|
22
|
+
font-style: normal;
|
|
23
|
+
font-weight: 400;
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
line-height: 15px;
|
|
26
|
+
text-align: center;
|
|
27
|
+
color: #4250F0;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
.allowedMediaLabel {
|
|
31
|
+
font-family: inherit;
|
|
32
|
+
font-style: normal;
|
|
33
|
+
font-weight: 400;
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
line-height: 15px;
|
|
36
|
+
text-align: center;
|
|
37
|
+
color: #999999;
|
|
38
|
+
margin-top: 8px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
.hiddenFileInput {
|
|
42
|
+
display: none;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
.urlField {
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
.mediaListing {
|
|
50
|
+
margin-top: 24px;
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-wrap: wrap;
|
|
53
|
+
gap: 7px;
|
|
54
|
+
max-width: 288px;
|
|
55
|
+
.mediaPreview {
|
|
56
|
+
width: 140px;
|
|
57
|
+
height: 77px;
|
|
58
|
+
position: relative;
|
|
59
|
+
.delMediaSpan {
|
|
60
|
+
position: absolute;
|
|
61
|
+
z-index: 999;
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
font-style: normal;
|
|
65
|
+
font-weight: 400;
|
|
66
|
+
font-size: 12px;
|
|
67
|
+
line-height: 15px;
|
|
68
|
+
text-align: center;
|
|
69
|
+
color: #EB5757;
|
|
70
|
+
font-family: inherit;
|
|
71
|
+
top: 32px;
|
|
72
|
+
gap: 8px;
|
|
73
|
+
left: 40px;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
display: none;
|
|
76
|
+
.delIcon {
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
.mediaImg {
|
|
81
|
+
border: 1px solid #E0E0E0;
|
|
82
|
+
filter: drop-shadow(0px 0px 8px rgba(0, 0, 0, 0.08));
|
|
83
|
+
border-radius: 6px;
|
|
84
|
+
width: 140px;
|
|
85
|
+
height: 77px;
|
|
86
|
+
}
|
|
87
|
+
.backgroundOverlay {
|
|
88
|
+
background: #FFFFFF;
|
|
89
|
+
opacity: 0.8;
|
|
90
|
+
display: none;
|
|
91
|
+
width: 140px;
|
|
92
|
+
height: 77px;
|
|
93
|
+
position: absolute;
|
|
94
|
+
top: 0px;
|
|
95
|
+
left: 0px;
|
|
96
|
+
&.uploading {
|
|
97
|
+
display: block;
|
|
98
|
+
z-index: 9;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
.uploadingImg {
|
|
102
|
+
position: absolute;
|
|
103
|
+
top: 32px;
|
|
104
|
+
left: 64px;
|
|
105
|
+
z-index: 99;
|
|
106
|
+
}
|
|
107
|
+
&:hover {
|
|
108
|
+
.backgroundOverlay {
|
|
109
|
+
display: block;
|
|
110
|
+
z-index: 9;
|
|
111
|
+
}
|
|
112
|
+
.delMediaSpan {
|
|
113
|
+
display: flex;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { html, Component } from 'htm/preact';
|
|
2
|
+
|
|
3
|
+
import styles from './styles.module.scss';
|
|
4
|
+
|
|
5
|
+
interface ModalProps {
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
CustomCloseElement?: any;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
isCompact?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class Modal extends Component<ModalProps> {
|
|
14
|
+
render() {
|
|
15
|
+
const { isOpen, CustomCloseElement, className, isCompact = false } = this.props;
|
|
16
|
+
return html`
|
|
17
|
+
<div
|
|
18
|
+
id="sdk-modal"
|
|
19
|
+
class=${`${styles.modal} ${isOpen ? `${styles.open}` : ''} ${
|
|
20
|
+
styles[className || '']
|
|
21
|
+
}`}
|
|
22
|
+
aria-labelledby="modal-title"
|
|
23
|
+
role="dialog"
|
|
24
|
+
aria-modal="true"
|
|
25
|
+
>
|
|
26
|
+
<div id="sdk-modal-container" class=${styles.modalContainer}>
|
|
27
|
+
<div
|
|
28
|
+
id="sdk-modal-container__inset"
|
|
29
|
+
class=${styles.inset}
|
|
30
|
+
aria-hidden="true"
|
|
31
|
+
></div>
|
|
32
|
+
|
|
33
|
+
<span class=${styles.span} aria-hidden="true"></span>
|
|
34
|
+
|
|
35
|
+
<div
|
|
36
|
+
id="integry-sdk-modal-container__content"
|
|
37
|
+
style="${isCompact ? 'min-width: 395px; width: 395px; overflow-x: hidden;' : ''}"
|
|
38
|
+
class=${`${isCompact ? styles.contentWrapCompact : styles.contentWrap} ${isOpen ? `${styles.open}` : ''}`}
|
|
39
|
+
>
|
|
40
|
+
<div class=${isCompact ? styles.contentCompact : styles.content}>
|
|
41
|
+
${CustomCloseElement
|
|
42
|
+
? html` <div
|
|
43
|
+
onclick=${this.props.onClose}
|
|
44
|
+
class="integry-sdk-modal-close-btn"
|
|
45
|
+
>
|
|
46
|
+
<${CustomCloseElement} />
|
|
47
|
+
</div>`
|
|
48
|
+
: this.props.onClose &&
|
|
49
|
+
html`
|
|
50
|
+
<div
|
|
51
|
+
onclick=${this.props.onClose}
|
|
52
|
+
class=${`integry-sdk-modal-close-btn ${isCompact ? styles.closeCompact : styles.close}`}
|
|
53
|
+
>
|
|
54
|
+
<svg
|
|
55
|
+
width="14"
|
|
56
|
+
height="14"
|
|
57
|
+
viewBox="0 0 14 14"
|
|
58
|
+
fill="none"
|
|
59
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
+
>
|
|
61
|
+
<path
|
|
62
|
+
d="M13 1L1 13"
|
|
63
|
+
stroke="#4F4F4F"
|
|
64
|
+
stroke-width="2"
|
|
65
|
+
stroke-linecap="round"
|
|
66
|
+
stroke-linejoin="round"
|
|
67
|
+
/>
|
|
68
|
+
<path
|
|
69
|
+
d="M1 1L13 13"
|
|
70
|
+
stroke="#4F4F4F"
|
|
71
|
+
stroke-width="2"
|
|
72
|
+
stroke-linecap="round"
|
|
73
|
+
stroke-linejoin="round"
|
|
74
|
+
/>
|
|
75
|
+
</svg>
|
|
76
|
+
</div>
|
|
77
|
+
`}
|
|
78
|
+
${this.props.isOpen && html` ${this.props.children} `}
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { Modal };
|