@uploadcare/file-uploader 0.50.1-alpha.2
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/LICENSE +21 -0
- package/README.md +165 -0
- package/abstract/ActivityBlock.d.ts +68 -0
- package/abstract/ActivityBlock.d.ts.map +1 -0
- package/abstract/ActivityBlock.js +207 -0
- package/abstract/Block.d.ts +99 -0
- package/abstract/Block.d.ts.map +1 -0
- package/abstract/Block.js +349 -0
- package/abstract/CTX.d.ts +31 -0
- package/abstract/CTX.d.ts.map +1 -0
- package/abstract/CTX.js +38 -0
- package/abstract/LocaleManager.d.ts +38 -0
- package/abstract/LocaleManager.d.ts.map +1 -0
- package/abstract/LocaleManager.js +127 -0
- package/abstract/SecureUploadsManager.d.ts +22 -0
- package/abstract/SecureUploadsManager.d.ts.map +1 -0
- package/abstract/SecureUploadsManager.js +87 -0
- package/abstract/SolutionBlock.d.ts +23 -0
- package/abstract/SolutionBlock.d.ts.map +1 -0
- package/abstract/SolutionBlock.js +23 -0
- package/abstract/TypedCollection.d.ts +127 -0
- package/abstract/TypedCollection.d.ts.map +1 -0
- package/abstract/TypedCollection.js +245 -0
- package/abstract/TypedData.d.ts +47 -0
- package/abstract/TypedData.d.ts.map +1 -0
- package/abstract/TypedData.js +77 -0
- package/abstract/UploaderBlock.d.ts +114 -0
- package/abstract/UploaderBlock.d.ts.map +1 -0
- package/abstract/UploaderBlock.js +444 -0
- package/abstract/UploaderPublicApi.d.ts +90 -0
- package/abstract/UploaderPublicApi.d.ts.map +1 -0
- package/abstract/UploaderPublicApi.js +316 -0
- package/abstract/ValidationManager.d.ts +31 -0
- package/abstract/ValidationManager.d.ts.map +1 -0
- package/abstract/ValidationManager.js +162 -0
- package/abstract/a11y.d.ts +20 -0
- package/abstract/a11y.d.ts.map +1 -0
- package/abstract/a11y.js +118 -0
- package/abstract/buildOutputCollectionState.d.ts +8 -0
- package/abstract/buildOutputCollectionState.d.ts.map +1 -0
- package/abstract/buildOutputCollectionState.js +136 -0
- package/abstract/connectBlocksFrom.d.ts +8 -0
- package/abstract/connectBlocksFrom.d.ts.map +1 -0
- package/abstract/connectBlocksFrom.js +34 -0
- package/abstract/l10nProcessor.d.ts +7 -0
- package/abstract/l10nProcessor.d.ts.map +1 -0
- package/abstract/l10nProcessor.js +80 -0
- package/abstract/localeRegistry.d.ts +5 -0
- package/abstract/localeRegistry.d.ts.map +1 -0
- package/abstract/localeRegistry.js +63 -0
- package/abstract/registerBlocks.d.ts +5 -0
- package/abstract/registerBlocks.d.ts.map +1 -0
- package/abstract/registerBlocks.js +31 -0
- package/abstract/sharedConfigKey.d.ts +2 -0
- package/abstract/sharedConfigKey.d.ts.map +1 -0
- package/abstract/sharedConfigKey.js +8 -0
- package/abstract/uploadEntrySchema.d.ts +64 -0
- package/abstract/uploadEntrySchema.d.ts.map +1 -0
- package/abstract/uploadEntrySchema.js +138 -0
- package/blocks/ActivityHeader/ActivityHeader.d.ts +4 -0
- package/blocks/ActivityHeader/ActivityHeader.d.ts.map +1 -0
- package/blocks/ActivityHeader/ActivityHeader.js +3 -0
- package/blocks/ActivityHeader/activity-header.css +14 -0
- package/blocks/CameraSource/CameraSource.d.ts +39 -0
- package/blocks/CameraSource/CameraSource.d.ts.map +1 -0
- package/blocks/CameraSource/CameraSource.js +253 -0
- package/blocks/CameraSource/camera-source.css +107 -0
- package/blocks/CloudImageEditor/index.css +1 -0
- package/blocks/CloudImageEditor/index.d.ts +2 -0
- package/blocks/CloudImageEditor/index.d.ts.map +1 -0
- package/blocks/CloudImageEditor/index.js +1 -0
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts +58 -0
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.js +228 -0
- package/blocks/CloudImageEditor/src/CropFrame.d.ts +146 -0
- package/blocks/CloudImageEditor/src/CropFrame.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/CropFrame.js +511 -0
- package/blocks/CloudImageEditor/src/EditorButtonControl.d.ts +10 -0
- package/blocks/CloudImageEditor/src/EditorButtonControl.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorButtonControl.js +44 -0
- package/blocks/CloudImageEditor/src/EditorCropButtonControl.d.ts +6 -0
- package/blocks/CloudImageEditor/src/EditorCropButtonControl.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorCropButtonControl.js +39 -0
- package/blocks/CloudImageEditor/src/EditorFilterControl.d.ts +18 -0
- package/blocks/CloudImageEditor/src/EditorFilterControl.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorFilterControl.js +155 -0
- package/blocks/CloudImageEditor/src/EditorImageCropper.d.ts +106 -0
- package/blocks/CloudImageEditor/src/EditorImageCropper.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorImageCropper.js +551 -0
- package/blocks/CloudImageEditor/src/EditorImageFader.d.ts +132 -0
- package/blocks/CloudImageEditor/src/EditorImageFader.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorImageFader.js +454 -0
- package/blocks/CloudImageEditor/src/EditorOperationControl.d.ts +9 -0
- package/blocks/CloudImageEditor/src/EditorOperationControl.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorOperationControl.js +39 -0
- package/blocks/CloudImageEditor/src/EditorScroller.d.ts +7 -0
- package/blocks/CloudImageEditor/src/EditorScroller.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorScroller.js +33 -0
- package/blocks/CloudImageEditor/src/EditorSlider.d.ts +24 -0
- package/blocks/CloudImageEditor/src/EditorSlider.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorSlider.js +118 -0
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +104 -0
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorToolbar.js +441 -0
- package/blocks/CloudImageEditor/src/crop-utils.d.ts +123 -0
- package/blocks/CloudImageEditor/src/crop-utils.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/crop-utils.js +729 -0
- package/blocks/CloudImageEditor/src/cropper-constants.d.ts +11 -0
- package/blocks/CloudImageEditor/src/cropper-constants.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/cropper-constants.js +11 -0
- package/blocks/CloudImageEditor/src/css/common.css +1157 -0
- package/blocks/CloudImageEditor/src/css/icons.css +12 -0
- package/blocks/CloudImageEditor/src/css/index.css +2 -0
- package/blocks/CloudImageEditor/src/elements/button/BtnUi.d.ts +20 -0
- package/blocks/CloudImageEditor/src/elements/button/BtnUi.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/elements/button/BtnUi.js +90 -0
- package/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.d.ts +11 -0
- package/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.js +52 -0
- package/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.d.ts +17 -0
- package/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.js +71 -0
- package/blocks/CloudImageEditor/src/elements/slider/SliderUi.d.ts +16 -0
- package/blocks/CloudImageEditor/src/elements/slider/SliderUi.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/elements/slider/SliderUi.js +178 -0
- package/blocks/CloudImageEditor/src/index.d.ts +15 -0
- package/blocks/CloudImageEditor/src/index.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/index.js +14 -0
- package/blocks/CloudImageEditor/src/lib/FocusVisible.d.ts +15 -0
- package/blocks/CloudImageEditor/src/lib/FocusVisible.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/FocusVisible.js +33 -0
- package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts +10 -0
- package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.js +256 -0
- package/blocks/CloudImageEditor/src/lib/classNames.d.ts +3 -0
- package/blocks/CloudImageEditor/src/lib/classNames.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/classNames.js +34 -0
- package/blocks/CloudImageEditor/src/lib/linspace.d.ts +8 -0
- package/blocks/CloudImageEditor/src/lib/linspace.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/linspace.js +14 -0
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +2 -0
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.js +14 -0
- package/blocks/CloudImageEditor/src/lib/parseTabs.d.ts +2 -0
- package/blocks/CloudImageEditor/src/lib/parseTabs.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/parseTabs.js +14 -0
- package/blocks/CloudImageEditor/src/lib/pick.d.ts +7 -0
- package/blocks/CloudImageEditor/src/lib/pick.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/pick.js +15 -0
- package/blocks/CloudImageEditor/src/lib/preloadImage.d.ts +11 -0
- package/blocks/CloudImageEditor/src/lib/preloadImage.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/preloadImage.js +38 -0
- package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts +14 -0
- package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/transformationUtils.js +167 -0
- package/blocks/CloudImageEditor/src/state.d.ts +38 -0
- package/blocks/CloudImageEditor/src/state.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/state.js +92 -0
- package/blocks/CloudImageEditor/src/svg-sprite.d.ts +3 -0
- package/blocks/CloudImageEditor/src/svg-sprite.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/svg-sprite.js +1 -0
- package/blocks/CloudImageEditor/src/template.d.ts +2 -0
- package/blocks/CloudImageEditor/src/template.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/template.js +36 -0
- package/blocks/CloudImageEditor/src/toolbar-constants.d.ts +58 -0
- package/blocks/CloudImageEditor/src/toolbar-constants.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/toolbar-constants.js +114 -0
- package/blocks/CloudImageEditor/src/types.d.ts +58 -0
- package/blocks/CloudImageEditor/src/types.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/types.js +61 -0
- package/blocks/CloudImageEditor/src/util.d.ts +2 -0
- package/blocks/CloudImageEditor/src/util.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/util.js +19 -0
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts +31 -0
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts.map +1 -0
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.js +113 -0
- package/blocks/CloudImageEditorActivity/index.css +13 -0
- package/blocks/CloudImageEditorActivity/test.d.ts +2 -0
- package/blocks/CloudImageEditorActivity/test.d.ts.map +1 -0
- package/blocks/CloudImageEditorActivity/test.js +9 -0
- package/blocks/Config/Config.d.ts +67 -0
- package/blocks/Config/Config.d.ts.map +1 -0
- package/blocks/Config/Config.js +246 -0
- package/blocks/Config/config.css +3 -0
- package/blocks/Config/initialConfig.d.ts +6 -0
- package/blocks/Config/initialConfig.d.ts.map +1 -0
- package/blocks/Config/initialConfig.js +69 -0
- package/blocks/Config/normalizeConfigValue.d.ts +3 -0
- package/blocks/Config/normalizeConfigValue.d.ts.map +1 -0
- package/blocks/Config/normalizeConfigValue.js +177 -0
- package/blocks/Copyright/Copyright.d.ts +4 -0
- package/blocks/Copyright/Copyright.d.ts.map +1 -0
- package/blocks/Copyright/Copyright.js +24 -0
- package/blocks/Copyright/copyright.css +31 -0
- package/blocks/DropArea/DropArea.d.ts +49 -0
- package/blocks/DropArea/DropArea.d.ts.map +1 -0
- package/blocks/DropArea/DropArea.js +273 -0
- package/blocks/DropArea/addDropzone.d.ts +21 -0
- package/blocks/DropArea/addDropzone.d.ts.map +1 -0
- package/blocks/DropArea/addDropzone.js +137 -0
- package/blocks/DropArea/drop-area.css +188 -0
- package/blocks/DropArea/getDropItems.d.ts +16 -0
- package/blocks/DropArea/getDropItems.d.ts.map +1 -0
- package/blocks/DropArea/getDropItems.js +167 -0
- package/blocks/ExternalSource/ExternalSource.d.ts +98 -0
- package/blocks/ExternalSource/ExternalSource.d.ts.map +1 -0
- package/blocks/ExternalSource/ExternalSource.js +268 -0
- package/blocks/ExternalSource/buildStyles.d.ts +27 -0
- package/blocks/ExternalSource/buildStyles.d.ts.map +1 -0
- package/blocks/ExternalSource/buildStyles.js +133 -0
- package/blocks/ExternalSource/external-source.css +65 -0
- package/blocks/ExternalSource/messages.d.ts +3 -0
- package/blocks/ExternalSource/messages.d.ts.map +1 -0
- package/blocks/ExternalSource/messages.js +35 -0
- package/blocks/ExternalSource/query-string.d.ts +8 -0
- package/blocks/ExternalSource/query-string.d.ts.map +1 -0
- package/blocks/ExternalSource/query-string.js +14 -0
- package/blocks/FileItem/FileItem.d.ts +97 -0
- package/blocks/FileItem/FileItem.d.ts.map +1 -0
- package/blocks/FileItem/FileItem.js +460 -0
- package/blocks/FileItem/file-item.css +140 -0
- package/blocks/FormInput/FormInput.d.ts +7 -0
- package/blocks/FormInput/FormInput.d.ts.map +1 -0
- package/blocks/FormInput/FormInput.js +92 -0
- package/blocks/Icon/Icon.d.ts +12 -0
- package/blocks/Icon/Icon.d.ts.map +1 -0
- package/blocks/Icon/Icon.js +44 -0
- package/blocks/Icon/icon.css +12 -0
- package/blocks/Img/Img.d.ts +4 -0
- package/blocks/Img/Img.d.ts.map +1 -0
- package/blocks/Img/Img.js +21 -0
- package/blocks/Img/ImgBase.d.ts +80 -0
- package/blocks/Img/ImgBase.d.ts.map +1 -0
- package/blocks/Img/ImgBase.js +408 -0
- package/blocks/Img/ImgConfig.d.ts +31 -0
- package/blocks/Img/ImgConfig.d.ts.map +1 -0
- package/blocks/Img/ImgConfig.js +102 -0
- package/blocks/Img/configurations.d.ts +12 -0
- package/blocks/Img/configurations.d.ts.map +1 -0
- package/blocks/Img/configurations.js +14 -0
- package/blocks/Img/props-map.d.ts +29 -0
- package/blocks/Img/props-map.d.ts.map +1 -0
- package/blocks/Img/props-map.js +34 -0
- package/blocks/Img/test.css +16 -0
- package/blocks/Img/utils/parseObjectToString.d.ts +2 -0
- package/blocks/Img/utils/parseObjectToString.d.ts.map +1 -0
- package/blocks/Img/utils/parseObjectToString.js +13 -0
- package/blocks/Modal/Modal.d.ts +24 -0
- package/blocks/Modal/Modal.d.ts.map +1 -0
- package/blocks/Modal/Modal.js +116 -0
- package/blocks/Modal/modal.css +92 -0
- package/blocks/ProgressBar/ProgressBar.d.ts +10 -0
- package/blocks/ProgressBar/ProgressBar.d.ts.map +1 -0
- package/blocks/ProgressBar/ProgressBar.js +38 -0
- package/blocks/ProgressBar/progress-bar.css +25 -0
- package/blocks/ProgressBarCommon/ProgressBarCommon.d.ts +8 -0
- package/blocks/ProgressBarCommon/ProgressBarCommon.d.ts.map +1 -0
- package/blocks/ProgressBarCommon/ProgressBarCommon.js +44 -0
- package/blocks/ProgressBarCommon/progress-bar-common.css +16 -0
- package/blocks/Range/Range.d.ts +16 -0
- package/blocks/Range/Range.d.ts.map +1 -0
- package/blocks/Range/Range.js +44 -0
- package/blocks/Range/range.css +65 -0
- package/blocks/Select/Select.d.ts +9 -0
- package/blocks/Select/Select.d.ts.map +1 -0
- package/blocks/Select/Select.js +35 -0
- package/blocks/Select/select.css +22 -0
- package/blocks/SimpleBtn/SimpleBtn.d.ts +26 -0
- package/blocks/SimpleBtn/SimpleBtn.d.ts.map +1 -0
- package/blocks/SimpleBtn/SimpleBtn.js +54 -0
- package/blocks/SimpleBtn/simple-btn.css +64 -0
- package/blocks/SourceBtn/SourceBtn.d.ts +58 -0
- package/blocks/SourceBtn/SourceBtn.d.ts.map +1 -0
- package/blocks/SourceBtn/SourceBtn.js +145 -0
- package/blocks/SourceBtn/source-btn.css +45 -0
- package/blocks/SourceList/SourceList.d.ts +4 -0
- package/blocks/SourceList/SourceList.d.ts.map +1 -0
- package/blocks/SourceList/SourceList.js +20 -0
- package/blocks/StartFrom/StartFrom.d.ts +7 -0
- package/blocks/StartFrom/StartFrom.d.ts.map +1 -0
- package/blocks/StartFrom/StartFrom.js +14 -0
- package/blocks/StartFrom/start-from.css +32 -0
- package/blocks/UploadCtxProvider/EventEmitter.d.ts +107 -0
- package/blocks/UploadCtxProvider/EventEmitter.d.ts.map +1 -0
- package/blocks/UploadCtxProvider/EventEmitter.js +132 -0
- package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts +35 -0
- package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts.map +1 -0
- package/blocks/UploadCtxProvider/UploadCtxProvider.js +45 -0
- package/blocks/UploadList/UploadList.d.ts +59 -0
- package/blocks/UploadList/UploadList.d.ts.map +1 -0
- package/blocks/UploadList/UploadList.js +237 -0
- package/blocks/UploadList/upload-list.css +74 -0
- package/blocks/UrlSource/UrlSource.d.ts +9 -0
- package/blocks/UrlSource/UrlSource.d.ts.map +1 -0
- package/blocks/UrlSource/UrlSource.js +61 -0
- package/blocks/UrlSource/url-source.css +24 -0
- package/blocks/svg-backgrounds/svg-backgrounds.d.ts +17 -0
- package/blocks/svg-backgrounds/svg-backgrounds.d.ts.map +1 -0
- package/blocks/svg-backgrounds/svg-backgrounds.js +45 -0
- package/blocks/themes/uc-basic/common.css +116 -0
- package/blocks/themes/uc-basic/config.css +4 -0
- package/blocks/themes/uc-basic/index.css +32 -0
- package/blocks/themes/uc-basic/svg-sprite.d.ts +3 -0
- package/blocks/themes/uc-basic/svg-sprite.d.ts.map +1 -0
- package/blocks/themes/uc-basic/svg-sprite.js +1 -0
- package/blocks/themes/uc-basic/theme.css +232 -0
- package/blocks/utils/UploadSource.d.ts +9 -0
- package/blocks/utils/UploadSource.d.ts.map +1 -0
- package/blocks/utils/UploadSource.js +8 -0
- package/blocks/utils/abilities.d.ts +2 -0
- package/blocks/utils/abilities.d.ts.map +1 -0
- package/blocks/utils/abilities.js +3 -0
- package/blocks/utils/comma-separated.d.ts +3 -0
- package/blocks/utils/comma-separated.d.ts.map +1 -0
- package/blocks/utils/comma-separated.js +19 -0
- package/blocks/utils/debounce.d.ts +10 -0
- package/blocks/utils/debounce.d.ts.map +1 -0
- package/blocks/utils/debounce.js +22 -0
- package/blocks/utils/resizeImage.d.ts +6 -0
- package/blocks/utils/resizeImage.d.ts.map +1 -0
- package/blocks/utils/resizeImage.js +40 -0
- package/blocks/utils/throttle.d.ts +4 -0
- package/blocks/utils/throttle.d.ts.map +1 -0
- package/blocks/utils/throttle.js +45 -0
- package/blocks/utils/userAgent.d.ts +6 -0
- package/blocks/utils/userAgent.d.ts.map +1 -0
- package/blocks/utils/userAgent.js +14 -0
- package/env.d.ts +4 -0
- package/env.d.ts.map +1 -0
- package/env.js +3 -0
- package/index.d.ts +39 -0
- package/index.d.ts.map +1 -0
- package/index.js +51 -0
- package/index.ssr.d.ts +961 -0
- package/index.ssr.d.ts.map +1 -0
- package/index.ssr.js +1461 -0
- package/locales/file-uploader/ar.d.ts +114 -0
- package/locales/file-uploader/ar.d.ts.map +1 -0
- package/locales/file-uploader/ar.js +113 -0
- package/locales/file-uploader/az.d.ts +106 -0
- package/locales/file-uploader/az.d.ts.map +1 -0
- package/locales/file-uploader/az.js +105 -0
- package/locales/file-uploader/ca.d.ts +108 -0
- package/locales/file-uploader/ca.d.ts.map +1 -0
- package/locales/file-uploader/ca.js +108 -0
- package/locales/file-uploader/cs.d.ts +110 -0
- package/locales/file-uploader/cs.d.ts.map +1 -0
- package/locales/file-uploader/cs.js +110 -0
- package/locales/file-uploader/da.d.ts +106 -0
- package/locales/file-uploader/da.d.ts.map +1 -0
- package/locales/file-uploader/da.js +106 -0
- package/locales/file-uploader/de.d.ts +106 -0
- package/locales/file-uploader/de.d.ts.map +1 -0
- package/locales/file-uploader/de.js +107 -0
- package/locales/file-uploader/el.d.ts +106 -0
- package/locales/file-uploader/el.d.ts.map +1 -0
- package/locales/file-uploader/el.js +107 -0
- package/locales/file-uploader/en.d.ts +106 -0
- package/locales/file-uploader/en.d.ts.map +1 -0
- package/locales/file-uploader/en.js +105 -0
- package/locales/file-uploader/es.d.ts +108 -0
- package/locales/file-uploader/es.d.ts.map +1 -0
- package/locales/file-uploader/es.js +108 -0
- package/locales/file-uploader/et.d.ts +106 -0
- package/locales/file-uploader/et.d.ts.map +1 -0
- package/locales/file-uploader/et.js +105 -0
- package/locales/file-uploader/fr.d.ts +108 -0
- package/locales/file-uploader/fr.d.ts.map +1 -0
- package/locales/file-uploader/fr.js +108 -0
- package/locales/file-uploader/he.d.ts +108 -0
- package/locales/file-uploader/he.d.ts.map +1 -0
- package/locales/file-uploader/he.js +107 -0
- package/locales/file-uploader/hy.d.ts +106 -0
- package/locales/file-uploader/hy.d.ts.map +1 -0
- package/locales/file-uploader/hy.js +105 -0
- package/locales/file-uploader/is.d.ts +106 -0
- package/locales/file-uploader/is.d.ts.map +1 -0
- package/locales/file-uploader/is.js +105 -0
- package/locales/file-uploader/it.d.ts +108 -0
- package/locales/file-uploader/it.d.ts.map +1 -0
- package/locales/file-uploader/it.js +108 -0
- package/locales/file-uploader/ja.d.ts +106 -0
- package/locales/file-uploader/ja.d.ts.map +1 -0
- package/locales/file-uploader/ja.js +105 -0
- package/locales/file-uploader/ka.d.ts +106 -0
- package/locales/file-uploader/ka.d.ts.map +1 -0
- package/locales/file-uploader/ka.js +105 -0
- package/locales/file-uploader/kk.d.ts +106 -0
- package/locales/file-uploader/kk.d.ts.map +1 -0
- package/locales/file-uploader/kk.js +105 -0
- package/locales/file-uploader/ko.d.ts +106 -0
- package/locales/file-uploader/ko.d.ts.map +1 -0
- package/locales/file-uploader/ko.js +104 -0
- package/locales/file-uploader/lv.d.ts +108 -0
- package/locales/file-uploader/lv.d.ts.map +1 -0
- package/locales/file-uploader/lv.js +107 -0
- package/locales/file-uploader/nb.d.ts +106 -0
- package/locales/file-uploader/nb.d.ts.map +1 -0
- package/locales/file-uploader/nb.js +105 -0
- package/locales/file-uploader/nl.d.ts +106 -0
- package/locales/file-uploader/nl.d.ts.map +1 -0
- package/locales/file-uploader/nl.js +106 -0
- package/locales/file-uploader/pl.d.ts +110 -0
- package/locales/file-uploader/pl.d.ts.map +1 -0
- package/locales/file-uploader/pl.js +109 -0
- package/locales/file-uploader/pt.d.ts +108 -0
- package/locales/file-uploader/pt.d.ts.map +1 -0
- package/locales/file-uploader/pt.js +108 -0
- package/locales/file-uploader/ro.d.ts +108 -0
- package/locales/file-uploader/ro.d.ts.map +1 -0
- package/locales/file-uploader/ro.js +108 -0
- package/locales/file-uploader/ru.d.ts +110 -0
- package/locales/file-uploader/ru.d.ts.map +1 -0
- package/locales/file-uploader/ru.js +109 -0
- package/locales/file-uploader/sk.d.ts +110 -0
- package/locales/file-uploader/sk.d.ts.map +1 -0
- package/locales/file-uploader/sk.js +109 -0
- package/locales/file-uploader/sr.d.ts +108 -0
- package/locales/file-uploader/sr.d.ts.map +1 -0
- package/locales/file-uploader/sr.js +107 -0
- package/locales/file-uploader/sv.d.ts +106 -0
- package/locales/file-uploader/sv.d.ts.map +1 -0
- package/locales/file-uploader/sv.js +105 -0
- package/locales/file-uploader/tr.d.ts +106 -0
- package/locales/file-uploader/tr.d.ts.map +1 -0
- package/locales/file-uploader/tr.js +105 -0
- package/locales/file-uploader/uk.d.ts +110 -0
- package/locales/file-uploader/uk.d.ts.map +1 -0
- package/locales/file-uploader/uk.js +109 -0
- package/locales/file-uploader/vi.d.ts +106 -0
- package/locales/file-uploader/vi.d.ts.map +1 -0
- package/locales/file-uploader/vi.js +105 -0
- package/locales/file-uploader/zh-TW.d.ts +106 -0
- package/locales/file-uploader/zh-TW.d.ts.map +1 -0
- package/locales/file-uploader/zh-TW.js +105 -0
- package/locales/file-uploader/zh.d.ts +106 -0
- package/locales/file-uploader/zh.d.ts.map +1 -0
- package/locales/file-uploader/zh.js +105 -0
- package/package.json +142 -0
- package/solutions/adaptive-image/index.d.ts +3 -0
- package/solutions/adaptive-image/index.d.ts.map +1 -0
- package/solutions/adaptive-image/index.js +5 -0
- package/solutions/cloud-image-editor/CloudImageEditor.d.ts +4 -0
- package/solutions/cloud-image-editor/CloudImageEditor.d.ts.map +1 -0
- package/solutions/cloud-image-editor/CloudImageEditor.js +12 -0
- package/solutions/cloud-image-editor/index.css +2 -0
- package/solutions/cloud-image-editor/index.d.ts +6 -0
- package/solutions/cloud-image-editor/index.d.ts.map +1 -0
- package/solutions/cloud-image-editor/index.js +11 -0
- package/solutions/file-uploader/inline/FileUploaderInline.d.ts +27 -0
- package/solutions/file-uploader/inline/FileUploaderInline.d.ts.map +1 -0
- package/solutions/file-uploader/inline/FileUploaderInline.js +75 -0
- package/solutions/file-uploader/inline/index.css +54 -0
- package/solutions/file-uploader/inline/index.d.ts +2 -0
- package/solutions/file-uploader/inline/index.d.ts.map +1 -0
- package/solutions/file-uploader/inline/index.js +1 -0
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +7 -0
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -0
- package/solutions/file-uploader/minimal/FileUploaderMinimal.js +46 -0
- package/solutions/file-uploader/minimal/index.css +137 -0
- package/solutions/file-uploader/minimal/index.d.ts +14 -0
- package/solutions/file-uploader/minimal/index.d.ts.map +1 -0
- package/solutions/file-uploader/minimal/index.js +13 -0
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +26 -0
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -0
- package/solutions/file-uploader/regular/FileUploaderRegular.js +66 -0
- package/solutions/file-uploader/regular/index.css +1 -0
- package/solutions/file-uploader/regular/index.d.ts +2 -0
- package/solutions/file-uploader/regular/index.d.ts.map +1 -0
- package/solutions/file-uploader/regular/index.js +1 -0
- package/types/events.d.ts +5 -0
- package/types/events.js +1 -0
- package/types/exported.d.ts +295 -0
- package/types/exported.js +1 -0
- package/types/global.d.ts +8 -0
- package/types/https.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.js +3 -0
- package/types/jsx.d.ts +63 -0
- package/types/jsx.js +1 -0
- package/utils/WindowHeightTracker.d.ts +24 -0
- package/utils/WindowHeightTracker.d.ts.map +1 -0
- package/utils/WindowHeightTracker.js +51 -0
- package/utils/cdn-utils.d.ts +59 -0
- package/utils/cdn-utils.d.ts.map +1 -0
- package/utils/cdn-utils.js +201 -0
- package/utils/cdn-utils.test.d.ts +2 -0
- package/utils/cdn-utils.test.d.ts.map +1 -0
- package/utils/cdn-utils.test.js +227 -0
- package/utils/delay.d.ts +2 -0
- package/utils/delay.d.ts.map +1 -0
- package/utils/delay.js +4 -0
- package/utils/fileTypes.d.ts +8 -0
- package/utils/fileTypes.d.ts.map +1 -0
- package/utils/fileTypes.js +95 -0
- package/utils/fileTypes.test.d.ts +2 -0
- package/utils/fileTypes.test.d.ts.map +1 -0
- package/utils/fileTypes.test.js +89 -0
- package/utils/getLocaleDirection.d.ts +2 -0
- package/utils/getLocaleDirection.d.ts.map +1 -0
- package/utils/getLocaleDirection.js +18 -0
- package/utils/getPluralForm.d.ts +3 -0
- package/utils/getPluralForm.d.ts.map +1 -0
- package/utils/getPluralForm.js +13 -0
- package/utils/getPluralForm.test.d.ts +2 -0
- package/utils/getPluralForm.test.d.ts.map +1 -0
- package/utils/getPluralForm.test.js +16 -0
- package/utils/ifRef.d.ts +7 -0
- package/utils/ifRef.d.ts.map +1 -0
- package/utils/ifRef.js +9 -0
- package/utils/isSecureTokenExpired.d.ts +4 -0
- package/utils/isSecureTokenExpired.d.ts.map +1 -0
- package/utils/isSecureTokenExpired.js +17 -0
- package/utils/isSecureTokenExpired.test.d.ts +2 -0
- package/utils/isSecureTokenExpired.test.d.ts.map +1 -0
- package/utils/isSecureTokenExpired.test.js +33 -0
- package/utils/memoize.d.ts +2 -0
- package/utils/memoize.d.ts.map +1 -0
- package/utils/memoize.js +23 -0
- package/utils/memoize.test.d.ts +2 -0
- package/utils/memoize.test.d.ts.map +1 -0
- package/utils/memoize.test.js +38 -0
- package/utils/mixinClass.d.ts +8 -0
- package/utils/mixinClass.d.ts.map +1 -0
- package/utils/mixinClass.js +18 -0
- package/utils/parseCdnUrl.d.ts +9 -0
- package/utils/parseCdnUrl.d.ts.map +1 -0
- package/utils/parseCdnUrl.js +20 -0
- package/utils/parseCdnUrl.test.d.ts +2 -0
- package/utils/parseCdnUrl.test.d.ts.map +1 -0
- package/utils/parseCdnUrl.test.js +78 -0
- package/utils/parseShrink.d.ts +5 -0
- package/utils/parseShrink.d.ts.map +1 -0
- package/utils/parseShrink.js +34 -0
- package/utils/parseShrink.test.d.ts +2 -0
- package/utils/parseShrink.test.d.ts.map +1 -0
- package/utils/parseShrink.test.js +26 -0
- package/utils/prettyBytes.d.ts +11 -0
- package/utils/prettyBytes.d.ts.map +1 -0
- package/utils/prettyBytes.js +64 -0
- package/utils/prettyBytes.test.d.ts +2 -0
- package/utils/prettyBytes.test.d.ts.map +1 -0
- package/utils/prettyBytes.test.js +99 -0
- package/utils/stringToArray.d.ts +2 -0
- package/utils/stringToArray.d.ts.map +1 -0
- package/utils/stringToArray.js +11 -0
- package/utils/stringToArray.test.d.ts +2 -0
- package/utils/stringToArray.test.d.ts.map +1 -0
- package/utils/stringToArray.test.js +20 -0
- package/utils/template-utils.d.ts +40 -0
- package/utils/template-utils.d.ts.map +1 -0
- package/utils/template-utils.js +50 -0
- package/utils/template-utils.test.d.ts +2 -0
- package/utils/template-utils.test.d.ts.map +1 -0
- package/utils/template-utils.test.js +56 -0
- package/utils/toKebabCase.d.ts +3 -0
- package/utils/toKebabCase.d.ts.map +1 -0
- package/utils/toKebabCase.js +15 -0
- package/utils/toKebabCase.test.d.ts +2 -0
- package/utils/toKebabCase.test.d.ts.map +1 -0
- package/utils/toKebabCase.test.js +11 -0
- package/utils/transparentPixelSrc.d.ts +2 -0
- package/utils/transparentPixelSrc.d.ts.map +1 -0
- package/utils/transparentPixelSrc.js +2 -0
- package/utils/uniqueArray.d.ts +2 -0
- package/utils/uniqueArray.d.ts.map +1 -0
- package/utils/uniqueArray.js +8 -0
- package/utils/uniqueArray.test.d.ts +2 -0
- package/utils/uniqueArray.test.d.ts.map +1 -0
- package/utils/uniqueArray.test.js +8 -0
- package/utils/validators/collection/index.d.ts +3 -0
- package/utils/validators/collection/index.d.ts.map +1 -0
- package/utils/validators/collection/index.js +2 -0
- package/utils/validators/collection/validateCollectionUploadError.d.ts +3 -0
- package/utils/validators/collection/validateCollectionUploadError.d.ts.map +1 -0
- package/utils/validators/collection/validateCollectionUploadError.js +11 -0
- package/utils/validators/collection/validateMultiple.d.ts +3 -0
- package/utils/validators/collection/validateMultiple.d.ts.map +1 -0
- package/utils/validators/collection/validateMultiple.js +43 -0
- package/utils/validators/file/index.d.ts +5 -0
- package/utils/validators/file/index.d.ts.map +1 -0
- package/utils/validators/file/index.js +4 -0
- package/utils/validators/file/validateFileType.d.ts +3 -0
- package/utils/validators/file/validateFileType.d.ts.map +1 -0
- package/utils/validators/file/validateFileType.js +30 -0
- package/utils/validators/file/validateIsImage.d.ts +3 -0
- package/utils/validators/file/validateIsImage.d.ts.map +1 -0
- package/utils/validators/file/validateIsImage.js +25 -0
- package/utils/validators/file/validateMaxSizeLimit.d.ts +3 -0
- package/utils/validators/file/validateMaxSizeLimit.d.ts.map +1 -0
- package/utils/validators/file/validateMaxSizeLimit.js +15 -0
- package/utils/validators/file/validateUploadError.d.ts +3 -0
- package/utils/validators/file/validateUploadError.d.ts.map +1 -0
- package/utils/validators/file/validateUploadError.js +48 -0
- package/utils/waitForAttribute.d.ts +8 -0
- package/utils/waitForAttribute.d.ts.map +1 -0
- package/utils/waitForAttribute.js +43 -0
- package/utils/waitForAttribute.test.d.ts +2 -0
- package/utils/waitForAttribute.test.d.ts.map +1 -0
- package/utils/waitForAttribute.test.js +78 -0
- package/utils/warnOnce.d.ts +3 -0
- package/utils/warnOnce.d.ts.map +1 -0
- package/utils/warnOnce.js +11 -0
- package/utils/wildcardRegexp.d.ts +2 -0
- package/utils/wildcardRegexp.d.ts.map +1 -0
- package/utils/wildcardRegexp.js +17 -0
- package/utils/wildcardRegexp.test.d.ts +2 -0
- package/utils/wildcardRegexp.test.d.ts.map +1 -0
- package/utils/wildcardRegexp.test.js +19 -0
- package/web/blocks.iife.min.js +29 -0
- package/web/blocks.min.js +29 -0
- package/web/lr-basic.min.css +1 -0
- package/web/lr-cloud-image-editor.min.css +1 -0
- package/web/lr-cloud-image-editor.min.js +29 -0
- package/web/lr-file-uploader-inline.min.css +1 -0
- package/web/lr-file-uploader-inline.min.js +29 -0
- package/web/lr-file-uploader-minimal.min.css +1 -0
- package/web/lr-file-uploader-minimal.min.js +28 -0
- package/web/lr-file-uploader-regular.min.css +1 -0
- package/web/lr-file-uploader-regular.min.js +29 -0
- package/web/lr-img.min.js +28 -0
- package/web/uc-basic.min.css +1 -0
- package/web/uc-cloud-image-editor.min.css +1 -0
- package/web/uc-cloud-image-editor.min.js +29 -0
- package/web/uc-file-uploader-inline.min.css +1 -0
- package/web/uc-file-uploader-inline.min.js +29 -0
- package/web/uc-file-uploader-minimal.min.css +1 -0
- package/web/uc-file-uploader-minimal.min.js +28 -0
- package/web/uc-file-uploader-regular.min.css +1 -0
- package/web/uc-file-uploader-regular.min.js +29 -0
- package/web/uc-img.min.js +28 -0
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { CancelError, uploadFile } from '@uploadcare/upload-client';
|
|
3
|
+
import { shrinkFile } from '@uploadcare/image-shrink';
|
|
4
|
+
import { ActivityBlock } from '../../abstract/ActivityBlock.js';
|
|
5
|
+
import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
6
|
+
import { createCdnUrl, createCdnUrlModifiers, createOriginalUrl } from '../../utils/cdn-utils.js';
|
|
7
|
+
import { fileCssBg } from '../svg-backgrounds/svg-backgrounds.js';
|
|
8
|
+
import { debounce } from '../utils/debounce.js';
|
|
9
|
+
import { generateThumb } from '../utils/resizeImage.js';
|
|
10
|
+
import { parseShrink } from '../../utils/parseShrink.js';
|
|
11
|
+
|
|
12
|
+
const FileItemState = Object.freeze({
|
|
13
|
+
FINISHED: Symbol(0),
|
|
14
|
+
FAILED: Symbol(1),
|
|
15
|
+
UPLOADING: Symbol(2),
|
|
16
|
+
IDLE: Symbol(3),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export class FileItem extends UploaderBlock {
|
|
20
|
+
couldBeCtxOwner = true;
|
|
21
|
+
pauseRender = true;
|
|
22
|
+
|
|
23
|
+
/** @private */
|
|
24
|
+
_entrySubs = new Set();
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
* @type {any} TODO: Add types for upload entry
|
|
28
|
+
*/
|
|
29
|
+
_entry = null;
|
|
30
|
+
/** @private */
|
|
31
|
+
_isIntersecting = false;
|
|
32
|
+
/** @private */
|
|
33
|
+
_debouncedGenerateThumb = debounce(this._generateThumbnail.bind(this), 100);
|
|
34
|
+
/** @private */
|
|
35
|
+
_debouncedCalculateState = debounce(this._calculateState.bind(this), 100);
|
|
36
|
+
|
|
37
|
+
/** @private */
|
|
38
|
+
_renderedOnce = false;
|
|
39
|
+
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
|
|
43
|
+
this.init$ = {
|
|
44
|
+
...this.init$,
|
|
45
|
+
uid: '',
|
|
46
|
+
itemName: '',
|
|
47
|
+
errorText: '',
|
|
48
|
+
thumbUrl: '',
|
|
49
|
+
progressValue: 0,
|
|
50
|
+
progressVisible: false,
|
|
51
|
+
badgeIcon: '',
|
|
52
|
+
isFinished: false,
|
|
53
|
+
isFailed: false,
|
|
54
|
+
isUploading: false,
|
|
55
|
+
isFocused: false,
|
|
56
|
+
isEditable: false,
|
|
57
|
+
state: FileItemState.IDLE,
|
|
58
|
+
onEdit: () => {
|
|
59
|
+
this.set$({
|
|
60
|
+
'*focusedEntry': this._entry,
|
|
61
|
+
});
|
|
62
|
+
if (this.hasBlockInCtx((b) => b.activityType === ActivityBlock.activities.DETAILS)) {
|
|
63
|
+
this.$['*currentActivity'] = ActivityBlock.activities.DETAILS;
|
|
64
|
+
} else {
|
|
65
|
+
this.$['*currentActivity'] = ActivityBlock.activities.CLOUD_IMG_EDIT;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
onRemove: () => {
|
|
69
|
+
this.uploadCollection.remove(this.$.uid);
|
|
70
|
+
},
|
|
71
|
+
onUpload: () => {
|
|
72
|
+
this.upload();
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_reset() {
|
|
78
|
+
for (let sub of this._entrySubs) {
|
|
79
|
+
sub.remove();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this._debouncedGenerateThumb.cancel();
|
|
83
|
+
this._debouncedCalculateState.cancel();
|
|
84
|
+
this._entrySubs = new Set();
|
|
85
|
+
this._entry = null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @private
|
|
90
|
+
* @param {IntersectionObserverEntry[]} entries
|
|
91
|
+
*/
|
|
92
|
+
_observerCallback(entries) {
|
|
93
|
+
let [entry] = entries;
|
|
94
|
+
this._isIntersecting = entry.isIntersecting;
|
|
95
|
+
|
|
96
|
+
if (entry.isIntersecting && !this._renderedOnce) {
|
|
97
|
+
this.render();
|
|
98
|
+
this._renderedOnce = true;
|
|
99
|
+
}
|
|
100
|
+
if (entry.intersectionRatio === 0) {
|
|
101
|
+
this._debouncedGenerateThumb.cancel();
|
|
102
|
+
} else {
|
|
103
|
+
this._debouncedGenerateThumb();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** @private */
|
|
108
|
+
_calculateState() {
|
|
109
|
+
if (!this._entry) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
let entry = this._entry;
|
|
113
|
+
let state = FileItemState.IDLE;
|
|
114
|
+
|
|
115
|
+
if (entry.getValue('errors').length > 0) {
|
|
116
|
+
state = FileItemState.FAILED;
|
|
117
|
+
} else if (entry.getValue('isUploading')) {
|
|
118
|
+
state = FileItemState.UPLOADING;
|
|
119
|
+
} else if (entry.getValue('fileInfo')) {
|
|
120
|
+
state = FileItemState.FINISHED;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.$.state = state;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** @private */
|
|
127
|
+
async _generateThumbnail() {
|
|
128
|
+
if (!this._entry) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
let entry = this._entry;
|
|
132
|
+
|
|
133
|
+
if (entry.getValue('fileInfo') && entry.getValue('isImage')) {
|
|
134
|
+
let size = this.cfg.thumbSize;
|
|
135
|
+
let thumbUrl = this.proxyUrl(
|
|
136
|
+
createCdnUrl(
|
|
137
|
+
createOriginalUrl(this.cfg.cdnCname, this._entry.getValue('uuid')),
|
|
138
|
+
createCdnUrlModifiers(entry.getValue('cdnUrlModifiers'), `scale_crop/${size}x${size}/center`),
|
|
139
|
+
),
|
|
140
|
+
);
|
|
141
|
+
let currentThumbUrl = entry.getValue('thumbUrl');
|
|
142
|
+
if (currentThumbUrl !== thumbUrl) {
|
|
143
|
+
entry.setValue('thumbUrl', thumbUrl);
|
|
144
|
+
currentThumbUrl?.startsWith('blob:') && URL.revokeObjectURL(currentThumbUrl);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (entry.getValue('thumbUrl')) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (entry.getValue('file')?.type.includes('image')) {
|
|
154
|
+
try {
|
|
155
|
+
let thumbUrl = await generateThumb(entry.getValue('file'), this.cfg.thumbSize);
|
|
156
|
+
entry.setValue('thumbUrl', thumbUrl);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
let color = window.getComputedStyle(this).getPropertyValue('--uc-muted-foreground');
|
|
159
|
+
entry.setValue('thumbUrl', fileCssBg(color));
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
let color = window.getComputedStyle(this).getPropertyValue('--uc-muted-foreground');
|
|
163
|
+
entry.setValue('thumbUrl', fileCssBg(color));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @private
|
|
169
|
+
* @param {string} prop
|
|
170
|
+
* @param {(value: any) => void} handler
|
|
171
|
+
*/
|
|
172
|
+
_subEntry(prop, handler) {
|
|
173
|
+
let sub = this._entry.subscribe(
|
|
174
|
+
prop,
|
|
175
|
+
/** @param {any} value */ (value) => {
|
|
176
|
+
if (this.isConnected) {
|
|
177
|
+
handler(value);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
this._entrySubs.add(sub);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @private
|
|
186
|
+
* @param {String} id
|
|
187
|
+
*/
|
|
188
|
+
_handleEntryId(id) {
|
|
189
|
+
this._reset();
|
|
190
|
+
|
|
191
|
+
/** @type {import('../../abstract/TypedData.js').TypedData} */
|
|
192
|
+
let entry = this.uploadCollection?.read(id);
|
|
193
|
+
this._entry = entry;
|
|
194
|
+
|
|
195
|
+
if (!entry) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this._subEntry('uploadProgress', (uploadProgress) => {
|
|
200
|
+
this.$.progressValue = uploadProgress;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
this._subEntry('fileName', (name) => {
|
|
204
|
+
this.$.itemName = name || entry.getValue('externalUrl') || this.l10n('file-no-name');
|
|
205
|
+
this._debouncedCalculateState();
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
this._subEntry('externalUrl', (externalUrl) => {
|
|
209
|
+
this.$.itemName = entry.getValue('fileName') || externalUrl || this.l10n('file-no-name');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
this._subEntry('fileInfo', (fileInfo) => {
|
|
213
|
+
this._debouncedCalculateState();
|
|
214
|
+
if (fileInfo && this._isIntersecting) {
|
|
215
|
+
this._debouncedGenerateThumb();
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
this._subEntry('cdnUrlModifiers', () => {
|
|
220
|
+
if (this._isIntersecting) {
|
|
221
|
+
this._debouncedGenerateThumb();
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
this._subEntry('thumbUrl', (thumbUrl) => {
|
|
226
|
+
this.$.thumbUrl = thumbUrl ? `url(${thumbUrl})` : '';
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
this._subEntry('errors', () => this._debouncedCalculateState());
|
|
230
|
+
this._subEntry('isUploading', () => this._debouncedCalculateState());
|
|
231
|
+
this._subEntry('fileSize', () => this._debouncedCalculateState());
|
|
232
|
+
this._subEntry('mimeType', () => this._debouncedCalculateState());
|
|
233
|
+
this._subEntry('isImage', () => this._debouncedCalculateState());
|
|
234
|
+
|
|
235
|
+
if (this._isIntersecting) {
|
|
236
|
+
this._debouncedGenerateThumb();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
initCallback() {
|
|
241
|
+
super.initCallback();
|
|
242
|
+
|
|
243
|
+
this.sub('uid', (uid) => {
|
|
244
|
+
this._handleEntryId(uid);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
this.sub('state', (state) => {
|
|
248
|
+
this._handleState(state);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
this.subConfigValue('useCloudImageEditor', () => this._debouncedCalculateState());
|
|
252
|
+
|
|
253
|
+
this.onclick = () => {
|
|
254
|
+
FileItem.activeInstances.forEach((inst) => {
|
|
255
|
+
if (inst === this) {
|
|
256
|
+
inst.setAttribute('focused', '');
|
|
257
|
+
} else {
|
|
258
|
+
inst.removeAttribute('focused');
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
this.sub(
|
|
264
|
+
'*uploadTrigger',
|
|
265
|
+
/** @param {Set<string>} itemsToUpload */
|
|
266
|
+
(itemsToUpload) => {
|
|
267
|
+
if (!itemsToUpload.has(this._entry.uid)) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
setTimeout(() => this.isConnected && this.upload());
|
|
271
|
+
},
|
|
272
|
+
);
|
|
273
|
+
FileItem.activeInstances.add(this);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** @param {(typeof FileItemState)[keyof typeof FileItemState]} state */
|
|
277
|
+
_handleState(state) {
|
|
278
|
+
if (state === FileItemState.FAILED) {
|
|
279
|
+
this.$.badgeIcon = 'badge-error';
|
|
280
|
+
} else if (state === FileItemState.FINISHED) {
|
|
281
|
+
this.$.badgeIcon = 'badge-success';
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (state === FileItemState.UPLOADING) {
|
|
285
|
+
this.$.isFocused = false;
|
|
286
|
+
} else {
|
|
287
|
+
this.$.progressValue = 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
this.set$({
|
|
291
|
+
isFailed: state === FileItemState.FAILED,
|
|
292
|
+
isUploading: state === FileItemState.UPLOADING,
|
|
293
|
+
isFinished: state === FileItemState.FINISHED,
|
|
294
|
+
progressVisible: state === FileItemState.UPLOADING,
|
|
295
|
+
isEditable: this.cfg.useCloudImageEditor && this._entry?.getValue('isImage') && this._entry?.getValue('cdnUrl'),
|
|
296
|
+
errorText: this._entry.getValue('errors')?.[0]?.message,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
destroyCallback() {
|
|
301
|
+
super.destroyCallback();
|
|
302
|
+
|
|
303
|
+
FileItem.activeInstances.delete(this);
|
|
304
|
+
|
|
305
|
+
this._reset();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
connectedCallback() {
|
|
309
|
+
super.connectedCallback();
|
|
310
|
+
|
|
311
|
+
/** @private */
|
|
312
|
+
this._observer = new window.IntersectionObserver(this._observerCallback.bind(this), {
|
|
313
|
+
threshold: [0, 1],
|
|
314
|
+
});
|
|
315
|
+
this._observer.observe(this);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
disconnectedCallback() {
|
|
319
|
+
super.disconnectedCallback();
|
|
320
|
+
|
|
321
|
+
this._debouncedGenerateThumb.cancel();
|
|
322
|
+
this._observer?.disconnect();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
_settingsOfShrink() {
|
|
326
|
+
return parseShrink(this.cfg.imageShrink);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* @private
|
|
331
|
+
* @param {File} file
|
|
332
|
+
*/
|
|
333
|
+
_processShrink(file) {
|
|
334
|
+
return shrinkFile(file, this._settingsOfShrink());
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async upload() {
|
|
338
|
+
let entry = this._entry;
|
|
339
|
+
|
|
340
|
+
if (!this.uploadCollection.read(entry.uid)) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (entry.getValue('fileInfo') || entry.getValue('isUploading') || entry.getValue('errors').length > 0) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const multipleMax = this.cfg.multiple ? this.cfg.multipleMax : 1;
|
|
348
|
+
if (multipleMax && this.uploadCollection.size > multipleMax) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
this._debouncedCalculateState();
|
|
353
|
+
entry.setValue('isUploading', true);
|
|
354
|
+
entry.setValue('errors', []);
|
|
355
|
+
|
|
356
|
+
try {
|
|
357
|
+
let abortController = new AbortController();
|
|
358
|
+
entry.setValue('abortController', abortController);
|
|
359
|
+
|
|
360
|
+
const uploadTask = async () => {
|
|
361
|
+
let file = entry.getValue('file');
|
|
362
|
+
if (file && this.cfg.imageShrink) {
|
|
363
|
+
file = await this._processShrink(file).catch(() => file);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const fileInput = file || entry.getValue('externalUrl') || entry.getValue('uuid');
|
|
367
|
+
const baseUploadClientOptions = await this.getUploadClientOptions();
|
|
368
|
+
/** @type {import('@uploadcare/upload-client').FileFromOptions} */
|
|
369
|
+
const uploadClientOptions = {
|
|
370
|
+
...baseUploadClientOptions,
|
|
371
|
+
fileName: entry.getValue('fileName'),
|
|
372
|
+
source: entry.getValue('source'),
|
|
373
|
+
onProgress: (progress) => {
|
|
374
|
+
if (progress.isComputable) {
|
|
375
|
+
let percentage = progress.value * 100;
|
|
376
|
+
entry.setValue('uploadProgress', percentage);
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
signal: abortController.signal,
|
|
380
|
+
metadata: await this.getMetadataFor(entry.uid),
|
|
381
|
+
};
|
|
382
|
+
this.debugPrint('upload options', fileInput, uploadClientOptions);
|
|
383
|
+
return uploadFile(fileInput, uploadClientOptions);
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/** @type {import('@uploadcare/upload-client').UploadcareFile} */
|
|
387
|
+
let fileInfo = await this.$['*uploadQueue'].add(uploadTask);
|
|
388
|
+
entry.setMultipleValues({
|
|
389
|
+
fileInfo,
|
|
390
|
+
isUploading: false,
|
|
391
|
+
fileName: fileInfo.originalFilename,
|
|
392
|
+
fileSize: fileInfo.size,
|
|
393
|
+
isImage: fileInfo.isImage,
|
|
394
|
+
mimeType: fileInfo.contentInfo?.mime?.mime ?? fileInfo.mimeType,
|
|
395
|
+
uuid: fileInfo.uuid,
|
|
396
|
+
cdnUrl: entry.getValue('cdnUrl') ?? fileInfo.cdnUrl,
|
|
397
|
+
cdnUrlModifiers: entry.getValue('cdnUrlModifiers') ?? '',
|
|
398
|
+
uploadProgress: 100,
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
if (entry === this._entry) {
|
|
402
|
+
this._debouncedCalculateState();
|
|
403
|
+
}
|
|
404
|
+
} catch (cause) {
|
|
405
|
+
if (cause instanceof CancelError && cause.isCancel) {
|
|
406
|
+
entry.setMultipleValues({
|
|
407
|
+
isUploading: false,
|
|
408
|
+
uploadProgress: 0,
|
|
409
|
+
});
|
|
410
|
+
} else {
|
|
411
|
+
entry.setMultipleValues({
|
|
412
|
+
isUploading: false,
|
|
413
|
+
uploadProgress: 0,
|
|
414
|
+
uploadError: cause,
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (entry === this._entry) {
|
|
419
|
+
this._debouncedCalculateState();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
FileItem.template = /* HTML */ `
|
|
426
|
+
<div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused">
|
|
427
|
+
<div class="uc-thumb" set="style.backgroundImage: thumbUrl">
|
|
428
|
+
<div class="uc-badge">
|
|
429
|
+
<uc-icon set="@name: badgeIcon"></uc-icon>
|
|
430
|
+
</div>
|
|
431
|
+
</div>
|
|
432
|
+
<div class="uc-file-name-wrapper">
|
|
433
|
+
<span class="uc-file-name" set="@title: itemName">{{itemName}}</span>
|
|
434
|
+
<span class="uc-file-error" set="@hidden: !errorText">{{errorText}}</span>
|
|
435
|
+
</div>
|
|
436
|
+
<div class="uc-file-actions">
|
|
437
|
+
<button
|
|
438
|
+
type="button"
|
|
439
|
+
l10n="@title:file-item-edit-button"
|
|
440
|
+
class="uc-edit-btn uc-mini-btn"
|
|
441
|
+
set="onclick: onEdit; @hidden: !isEditable"
|
|
442
|
+
>
|
|
443
|
+
<uc-icon name="edit-file"></uc-icon>
|
|
444
|
+
</button>
|
|
445
|
+
<button
|
|
446
|
+
type="button"
|
|
447
|
+
l10n="@title:file-item-remove-button"
|
|
448
|
+
class="uc-remove-btn uc-mini-btn"
|
|
449
|
+
set="onclick: onRemove;"
|
|
450
|
+
>
|
|
451
|
+
<uc-icon name="remove-file"></uc-icon>
|
|
452
|
+
</button>
|
|
453
|
+
<button type="button" class="uc-upload-btn uc-mini-btn" set="onclick: onUpload;">
|
|
454
|
+
<uc-icon name="upload"></uc-icon>
|
|
455
|
+
</button>
|
|
456
|
+
</div>
|
|
457
|
+
<uc-progress-bar class="uc-progress-bar" set="value: progressValue; visible: progressVisible;"> </uc-progress-bar>
|
|
458
|
+
</div>
|
|
459
|
+
`;
|
|
460
|
+
FileItem.activeInstances = new Set();
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
uc-file-item {
|
|
2
|
+
--uc-file-item-gap: 4px;
|
|
3
|
+
--uc-file-item-height: calc(var(--uc-preview-size) + var(--uc-padding) * 2 + var(--uc-file-item-gap));
|
|
4
|
+
|
|
5
|
+
display: block;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
min-height: var(--uc-file-item-height);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
uc-file-item:last-of-type {
|
|
11
|
+
--uc-file-item-gap: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
uc-file-item > .uc-inner {
|
|
15
|
+
position: relative;
|
|
16
|
+
display: grid;
|
|
17
|
+
grid-template-columns: var(--uc-preview-size) 1fr max-content;
|
|
18
|
+
gap: 2px;
|
|
19
|
+
align-items: center;
|
|
20
|
+
margin-bottom: var(--uc-file-item-gap);
|
|
21
|
+
padding: var(--uc-padding);
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
font-size: 0.925em;
|
|
24
|
+
background-color: var(--uc-muted);
|
|
25
|
+
border-radius: var(--uc-radius);
|
|
26
|
+
transition: background-color var(--uc-transition);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
uc-file-item > .uc-inner[focused] {
|
|
30
|
+
background-color: transparent;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
uc-file-item > .uc-inner[uploading] .uc-edit-btn {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
uc-file-item > :where(.uc-inner[failed], .uc-inner[limit-overflow]) {
|
|
38
|
+
background-color: var(--uc-destructive);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
uc-file-item .uc-thumb {
|
|
42
|
+
position: relative;
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
width: var(--uc-preview-size);
|
|
45
|
+
height: var(--uc-preview-size);
|
|
46
|
+
background-color: var(--uc-secondary);
|
|
47
|
+
background-position: center center;
|
|
48
|
+
background-size: cover;
|
|
49
|
+
border-radius: var(--uc-radius);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
uc-file-item .uc-file-name-wrapper {
|
|
53
|
+
text-align: left;
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
align-items: flex-start;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
max-width: 100%;
|
|
59
|
+
padding-right: var(--uc-padding);
|
|
60
|
+
padding-left: var(--uc-padding);
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
color: var(--uc-muted-foreground);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
uc-file-item .uc-file-name {
|
|
66
|
+
max-width: 100%;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
white-space: nowrap;
|
|
69
|
+
text-overflow: ellipsis;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
uc-file-item .uc-file-error {
|
|
73
|
+
display: none;
|
|
74
|
+
color: var(--uc-destructive-foreground);
|
|
75
|
+
font-size: 0.85em;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
uc-file-item button.uc-remove-btn,
|
|
79
|
+
uc-file-item button.uc-edit-btn {
|
|
80
|
+
color: var(--uc-muted-foreground);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
uc-file-item button svg {
|
|
84
|
+
pointer-events: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
uc-file-item button.uc-upload-btn {
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
uc-file-item .uc-badge {
|
|
92
|
+
position: absolute;
|
|
93
|
+
bottom: 2px;
|
|
94
|
+
right: 2px;
|
|
95
|
+
width: 14px;
|
|
96
|
+
height: 14px;
|
|
97
|
+
color: var(--uc-background);
|
|
98
|
+
background-color: var(--uc-foreground);
|
|
99
|
+
border-radius: 50%;
|
|
100
|
+
transform: scale(0.3);
|
|
101
|
+
opacity: 0;
|
|
102
|
+
transition:
|
|
103
|
+
opacity var(--uc-transition),
|
|
104
|
+
transform var(--uc-transition);
|
|
105
|
+
display: flex;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
align-items: center;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
uc-file-item > .uc-inner:where([failed], [limit-overflow], [finished]) .uc-badge {
|
|
111
|
+
transform: scale(1);
|
|
112
|
+
opacity: 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
uc-file-item > .uc-inner:where([failed], [limit-overflow]) .uc-badge {
|
|
116
|
+
background-color: var(--uc-destructive-foreground);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
uc-file-item > .uc-inner:where([failed], [limit-overflow]) .uc-file-error {
|
|
120
|
+
display: block;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
uc-file-item .uc-badge uc-icon,
|
|
124
|
+
uc-file-item .uc-badge uc-icon svg {
|
|
125
|
+
width: 100%;
|
|
126
|
+
height: 100%;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
uc-file-item .uc-progress-bar {
|
|
130
|
+
opacity: 0.5;
|
|
131
|
+
top: calc(100% - 2px);
|
|
132
|
+
height: 2px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
uc-file-item .uc-file-actions {
|
|
136
|
+
display: flex;
|
|
137
|
+
gap: 2px;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export class FormInput extends UploaderBlock {
|
|
2
|
+
_createValidationInput(): HTMLInputElement;
|
|
3
|
+
_validationInputElement: HTMLInputElement | null | undefined;
|
|
4
|
+
_dynamicInputsContainer: HTMLDivElement | undefined;
|
|
5
|
+
}
|
|
6
|
+
import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
7
|
+
//# sourceMappingURL=FormInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormInput.d.ts","sourceRoot":"","sources":["FormInput.js"],"names":[],"mappings":"AAIA;IAGE,2CAYC;IAKC,6DAA4D;IAQpD,oDAA4D;CA2DvE;8BAzF6B,iCAAiC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { applyStyles } from '@symbiotejs/symbiote';
|
|
3
|
+
import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
4
|
+
|
|
5
|
+
export class FormInput extends UploaderBlock {
|
|
6
|
+
requireCtxName = true;
|
|
7
|
+
|
|
8
|
+
_createValidationInput() {
|
|
9
|
+
const validationInput = document.createElement('input');
|
|
10
|
+
validationInput.type = 'text';
|
|
11
|
+
validationInput.name = this.ctxName;
|
|
12
|
+
validationInput.required = this.cfg.multipleMin > 0;
|
|
13
|
+
validationInput.tabIndex = -1;
|
|
14
|
+
applyStyles(validationInput, {
|
|
15
|
+
opacity: 0,
|
|
16
|
+
height: 0,
|
|
17
|
+
width: 0,
|
|
18
|
+
});
|
|
19
|
+
return validationInput;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
initCallback() {
|
|
23
|
+
super.initCallback();
|
|
24
|
+
|
|
25
|
+
this._validationInputElement = this._createValidationInput();
|
|
26
|
+
this.appendChild(this._validationInputElement);
|
|
27
|
+
|
|
28
|
+
this.sub(
|
|
29
|
+
'*collectionState',
|
|
30
|
+
(/** @type {import('../../types/index.js').OutputCollectionState} */ collectionState) => {
|
|
31
|
+
{
|
|
32
|
+
if (!this._dynamicInputsContainer) {
|
|
33
|
+
this._dynamicInputsContainer = document.createElement('div');
|
|
34
|
+
this.appendChild(this._dynamicInputsContainer);
|
|
35
|
+
}
|
|
36
|
+
if (!this._validationInputElement) {
|
|
37
|
+
const input = this._createValidationInput();
|
|
38
|
+
this.appendChild(input);
|
|
39
|
+
this._validationInputElement = input;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this._dynamicInputsContainer.innerHTML = '';
|
|
43
|
+
|
|
44
|
+
if (collectionState.status === 'uploading' || collectionState.status === 'idle') {
|
|
45
|
+
this._validationInputElement.value = '';
|
|
46
|
+
this._validationInputElement.setCustomValidity('');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (collectionState.status === 'failed') {
|
|
51
|
+
const errorMsg = collectionState.errors[0]?.message;
|
|
52
|
+
this._validationInputElement.value = '';
|
|
53
|
+
this._validationInputElement.setCustomValidity(errorMsg);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const group = collectionState.group ? collectionState.group : null;
|
|
58
|
+
if (group) {
|
|
59
|
+
this._validationInputElement.value = group.cdnUrl;
|
|
60
|
+
this._validationInputElement.setCustomValidity('');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const cdnUrls = collectionState.allEntries.map((entry) => entry.cdnUrl);
|
|
65
|
+
|
|
66
|
+
if (!this.cfg.multiple && cdnUrls.length === 1) {
|
|
67
|
+
this._validationInputElement.value = cdnUrls[0];
|
|
68
|
+
this._validationInputElement.setCustomValidity('');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Remove validation input to prevent it from being submitted
|
|
73
|
+
this._validationInputElement.remove();
|
|
74
|
+
this._validationInputElement = null;
|
|
75
|
+
|
|
76
|
+
const fr = new DocumentFragment();
|
|
77
|
+
|
|
78
|
+
for (let value of cdnUrls) {
|
|
79
|
+
const input = document.createElement('input');
|
|
80
|
+
input.type = 'hidden';
|
|
81
|
+
input.name = `${this.ctxName}[]`;
|
|
82
|
+
input.value = value;
|
|
83
|
+
fr.appendChild(input);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this._dynamicInputsContainer.replaceChildren(fr);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
false,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|