@dreamcommerce/aurora 2.5.3-1 → 2.5.3-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/build/cjs/packages/aurora/src/assets/icon_wrong_file_format.js +22 -0
- package/build/cjs/packages/aurora/src/assets/icon_wrong_file_format.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_image_picker/index.js +26 -0
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_image_picker/index.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/image_picker/components/image_input.js +32 -0
- package/build/cjs/packages/aurora/src/components/image_picker/components/image_input.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/image_picker/components/selected_image_preview.js +37 -0
- package/build/cjs/packages/aurora/src/components/image_picker/components/selected_image_preview.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/image_picker/css_classes.js +29 -0
- package/build/cjs/packages/aurora/src/components/image_picker/css_classes.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/image_picker/index.js +103 -0
- package/build/cjs/packages/aurora/src/components/image_picker/index.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/image_picker/utils.js +12 -0
- package/build/cjs/packages/aurora/src/components/image_picker/utils.js.map +1 -0
- package/build/cjs/packages/aurora/src/css/image_picker/main.module.less.js +12 -0
- package/build/cjs/packages/aurora/src/css/image_picker/main.module.less.js.map +1 -0
- package/build/cjs/packages/aurora/src/index.js +51 -47
- package/build/cjs/packages/aurora/src/index.js.map +1 -1
- package/build/esm/packages/aurora/src/assets/icon_wrong_file_format.js +11 -10
- package/build/esm/packages/aurora/src/assets/icon_wrong_file_format.js.map +1 -1
- package/build/esm/packages/aurora/src/components/controls/hoc/control_image_picker/index.js +15 -14
- package/build/esm/packages/aurora/src/components/controls/hoc/control_image_picker/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/components/image_input.js +23 -21
- package/build/esm/packages/aurora/src/components/image_picker/components/image_input.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/components/selected_image_preview.js +26 -25
- package/build/esm/packages/aurora/src/components/image_picker/components/selected_image_preview.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/css_classes.js +24 -22
- package/build/esm/packages/aurora/src/components/image_picker/css_classes.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/index.js +91 -90
- package/build/esm/packages/aurora/src/components/image_picker/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/utils.js +7 -4
- package/build/esm/packages/aurora/src/components/image_picker/utils.js.map +1 -1
- package/build/esm/packages/aurora/src/css/image_picker/main.module.less.js +8 -0
- package/build/esm/packages/aurora/src/css/image_picker/main.module.less.js.map +1 -0
- package/build/esm/packages/aurora/src/hooks/use_fixed_child_position.d.ts +1 -1
- package/build/esm/packages/aurora/src/index.d.ts +7 -4
- package/build/esm/packages/aurora/src/index.js +4 -2
- package/build/esm/packages/aurora/src/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import Control from '../../index';
|
|
2
|
-
import Hint from '@auroraComponents/hint';
|
|
3
|
-
import '../../types';
|
|
4
|
-
import ImagePicker from '@auroraComponents/image_picker';
|
|
5
1
|
import React from 'react';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import Control from '../../index.js';
|
|
3
|
+
import Hint from '../../../hint/index.js';
|
|
4
|
+
import ImagePicker from '../../../image_picker/index.js';
|
|
5
|
+
|
|
6
|
+
const ControlImagePicker = ({ label, isRequired, id, name, onChange, allowedExtensions, initialFile, className, errors, hint, labelAdditionalInfo, hasWidthInput, widthInputPostfix, widthInputLabel, widthInputHint }) => {
|
|
7
|
+
return (React.createElement(Control, { errors: errors, name: name, id: id },
|
|
8
|
+
(label || hint) && (React.createElement(Control.Label, { id: id, isRequired: isRequired, additionalInfo: labelAdditionalInfo },
|
|
9
|
+
label,
|
|
10
|
+
hint && React.createElement(Hint, { hint: hint, spacingLeft: true }))),
|
|
11
|
+
React.createElement(Control.Content, null,
|
|
12
|
+
React.createElement(Control.Element, null,
|
|
13
|
+
React.createElement(ImagePicker, { id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile, className: className, hasWidthInput: hasWidthInput, widthInputPostfix: widthInputPostfix, widthInputLabel: widthInputLabel, widthInputHint: widthInputHint }))),
|
|
14
|
+
React.createElement(Control.Errors, null)));
|
|
15
15
|
};
|
|
16
|
+
|
|
16
17
|
export default ControlImagePicker;
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/build/esm/packages/aurora/src/components/controls/hoc/control_image_picker/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import CSS_CLASSES from '@auroraComponents/image_picker/css_classes';
|
|
2
|
-
import '../types';
|
|
3
|
-
import IconUpload from '@auroraAssets/icon_upload';
|
|
4
1
|
import React from 'react';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
import { useTranslation } from '../../../../../../external/react-i18next/dist/es/useTranslation.js';
|
|
3
|
+
import withTranslation from '../../../utilities/translation/with_translation.js';
|
|
4
|
+
import IconUpload from '../../../assets/icon_upload.js';
|
|
5
|
+
import CSS_CLASSES from '../css_classes.js';
|
|
6
|
+
import styles from '../../../css/image_picker/main.module.less.js';
|
|
7
|
+
|
|
8
|
+
const ImageInput = ({ id, onDropFile, onDragOver, onDragLeave, allowedExtensions, isDragOver }) => {
|
|
9
|
+
const [t] = useTranslation();
|
|
10
|
+
return (React.createElement("label", { htmlFor: id, onDrop: onDropFile, onDragOver: onDragOver, onDragLeave: onDragLeave, className: styles[CSS_CLASSES.imagePickerLabel] },
|
|
11
|
+
React.createElement("div", { className: styles[CSS_CLASSES.imagePickerDescription] },
|
|
12
|
+
React.createElement(IconUpload, { className: styles[CSS_CLASSES.imagePickerUploadIcon] }),
|
|
13
|
+
React.createElement("p", null, t('Drag a file here or browse')),
|
|
14
|
+
React.createElement("span", null,
|
|
15
|
+
"(",
|
|
16
|
+
t('supported format'),
|
|
17
|
+
": ",
|
|
18
|
+
allowedExtensions.join(', '),
|
|
19
|
+
")"))));
|
|
20
|
+
};
|
|
21
|
+
var ImageInput$1 = withTranslation(ImageInput);
|
|
22
|
+
|
|
23
|
+
export default ImageInput$1;
|
|
24
|
+
//# sourceMappingURL=image_input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,oEAAwE;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/aurora/src/components/image_picker/components/selected_image_preview.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import CSS_CLASSES from '@auroraComponents/image_picker/css_classes';
|
|
2
|
-
import { FileUtils } from '@dreamcommerce/utilities';
|
|
3
|
-
import '../types';
|
|
4
|
-
import IconDelete from '@auroraAssets/icon_delete';
|
|
5
|
-
import IconWrongFileFormat from '@auroraAssets/icon_wrong_file_format';
|
|
6
1
|
import React from 'react';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
import { useTranslation } from '../../../../../../external/react-i18next/dist/es/useTranslation.js';
|
|
3
|
+
import { FileUtils } from '@dreamcommerce/utilities';
|
|
4
|
+
import IconDelete from '../../../assets/icon_delete.js';
|
|
5
|
+
import CSS_CLASSES from '../css_classes.js';
|
|
6
|
+
import styles from '../../../css/image_picker/main.module.less.js';
|
|
7
|
+
import IconWrongFileFormat from '../../../assets/icon_wrong_file_format.js';
|
|
8
|
+
|
|
9
|
+
const SelectedImagePreview = ({ file, isPreview, fileFormatIsCorrect, imageSize, onPreviewError, onFileDelete }) => {
|
|
10
|
+
const [t] = useTranslation();
|
|
11
|
+
const imageName = FileUtils.getFileName(file.fileName);
|
|
12
|
+
const imageExtension = FileUtils.getFileExtension(file.fileName);
|
|
13
|
+
const imageWidth = imageSize && imageSize.width;
|
|
14
|
+
const imageHeight = imageSize && imageSize.height;
|
|
15
|
+
const previewMarkupJsx = fileFormatIsCorrect ? (React.createElement("img", { alt: "", src: (file === null || file === void 0 ? void 0 : file.fileUrl) || '', onError: onPreviewError, className: styles[CSS_CLASSES.imagePickerImagePreview] })) : (React.createElement(IconWrongFileFormat, { className: styles[CSS_CLASSES.imagePickerWrongFileFormatIcon] }));
|
|
16
|
+
return (React.createElement("div", null,
|
|
17
|
+
isPreview ? (React.createElement("div", { className: styles[CSS_CLASSES.imagePickerImagePreviewWrapper] }, previewMarkupJsx)) : (React.createElement("div", null, t('No preview'))),
|
|
18
|
+
React.createElement("div", { className: styles[CSS_CLASSES.imagePickerSelectedFile] },
|
|
19
|
+
React.createElement("div", { className: styles[CSS_CLASSES.imagePickerSelectedFileNameWrapper] }, fileFormatIsCorrect && (React.createElement("span", { className: styles[CSS_CLASSES.imagePickerSelectedFileFullName] },
|
|
20
|
+
React.createElement("span", null, FileUtils.getFileNameShortenInMiddle(imageName, 10, 5, 1)),
|
|
21
|
+
React.createElement("span", null, `.${imageExtension} (${imageWidth}x${imageHeight}px)`)))),
|
|
22
|
+
React.createElement("div", { className: styles[CSS_CLASSES.imagePickerSelectedFileRemoveWrapper] },
|
|
23
|
+
React.createElement("span", { onClick: onFileDelete, className: styles[CSS_CLASSES.imagePickerDeleteButton] },
|
|
24
|
+
React.createElement(IconDelete, { className: styles[CSS_CLASSES.imagePickerDeleteIcon] }),
|
|
25
|
+
React.createElement("span", { className: styles[CSS_CLASSES.imagePickerDeleteLabel] }, t('Remove')))))));
|
|
26
26
|
};
|
|
27
|
+
|
|
27
28
|
export default SelectedImagePreview;
|
|
28
|
-
//# sourceMappingURL=selected_image_preview.js.map
|
|
29
|
+
//# sourceMappingURL=selected_image_preview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,oEAAwE;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
const imagePicker = 'image-picker';
|
|
2
|
-
|
|
3
|
-
imagePicker: `${imagePicker}`,
|
|
4
|
-
imagePickerWrapper: `${imagePicker}__wrapper`,
|
|
5
|
-
imagePickerWrapperError: `${imagePicker}__wrapper-error`,
|
|
6
|
-
imagePickerWrapperHasFile: `${imagePicker}__wrapper-has-file`,
|
|
7
|
-
imagePickerLabel: `${imagePicker}__label`,
|
|
8
|
-
imagePickerDescription: `${imagePicker}__description`,
|
|
9
|
-
imagePickerImagePreview: `${imagePicker}__image-preview`,
|
|
10
|
-
imagePickerImagePreviewWrapper: `${imagePicker}__image-preview-wrapper`,
|
|
11
|
-
imagePickerWrongFileFormatIcon: `${imagePicker}__wrong-file-format-icon`,
|
|
12
|
-
imagePickerErrorText: `${imagePicker}__error-text`,
|
|
13
|
-
imagePickerUploadIcon: `${imagePicker}__upload-icon`,
|
|
14
|
-
imagePickerDeleteButton: `${imagePicker}__delete-button`,
|
|
15
|
-
imagePickerDeleteLabel: `${imagePicker}__delete-label`,
|
|
16
|
-
imagePickerDeleteIcon: `${imagePicker}__delete-icon`,
|
|
17
|
-
imagePickerInput: `${imagePicker}__input`,
|
|
18
|
-
imagePickerSelectedFile: `${imagePicker}__selected-file`,
|
|
19
|
-
imagePickerSelectedFileNameWrapper: `${imagePicker}__selected-file-name-wrapper`,
|
|
20
|
-
imagePickerSelectedFileRemoveWrapper: `${imagePicker}__selected-file-remove-wrapper`,
|
|
21
|
-
imagePickerSelectedFileFullName: `${imagePicker}__selected-file-full-name`
|
|
1
|
+
const imagePicker = 'image-picker';
|
|
2
|
+
var CSS_CLASSES = {
|
|
3
|
+
imagePicker: `${imagePicker}`,
|
|
4
|
+
imagePickerWrapper: `${imagePicker}__wrapper`,
|
|
5
|
+
imagePickerWrapperError: `${imagePicker}__wrapper-error`,
|
|
6
|
+
imagePickerWrapperHasFile: `${imagePicker}__wrapper-has-file`,
|
|
7
|
+
imagePickerLabel: `${imagePicker}__label`,
|
|
8
|
+
imagePickerDescription: `${imagePicker}__description`,
|
|
9
|
+
imagePickerImagePreview: `${imagePicker}__image-preview`,
|
|
10
|
+
imagePickerImagePreviewWrapper: `${imagePicker}__image-preview-wrapper`,
|
|
11
|
+
imagePickerWrongFileFormatIcon: `${imagePicker}__wrong-file-format-icon`,
|
|
12
|
+
imagePickerErrorText: `${imagePicker}__error-text`,
|
|
13
|
+
imagePickerUploadIcon: `${imagePicker}__upload-icon`,
|
|
14
|
+
imagePickerDeleteButton: `${imagePicker}__delete-button`,
|
|
15
|
+
imagePickerDeleteLabel: `${imagePicker}__delete-label`,
|
|
16
|
+
imagePickerDeleteIcon: `${imagePicker}__delete-icon`,
|
|
17
|
+
imagePickerInput: `${imagePicker}__input`,
|
|
18
|
+
imagePickerSelectedFile: `${imagePicker}__selected-file`,
|
|
19
|
+
imagePickerSelectedFileNameWrapper: `${imagePicker}__selected-file-name-wrapper`,
|
|
20
|
+
imagePickerSelectedFileRemoveWrapper: `${imagePicker}__selected-file-remove-wrapper`,
|
|
21
|
+
imagePickerSelectedFileFullName: `${imagePicker}__selected-file-full-name`
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
export default CSS_CLASSES;
|
|
25
|
+
//# sourceMappingURL=css_classes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,93 +1,94 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import ControlInput from '@auroraComponents/controls/hoc/control_input';
|
|
5
|
-
import { FILE_PICKER_ERROR } from '@auroraComponents/file_picker/constants';
|
|
6
|
-
import ImageInput from '@auroraComponents/image_picker/components/image_input';
|
|
7
|
-
import SelectedImagePreview from '@auroraComponents/image_picker/components/selected_image_preview';
|
|
8
|
-
import Spacing from '@auroraComponents/spacing';
|
|
9
|
-
import { checkIfInvalideFileFormatErrorOccured } from './utils';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from '../../../../../external/react-i18next/dist/es/useTranslation.js';
|
|
3
|
+
import { createUseStyles } from '../../../../../external/react-jss/dist/react-jss.esm.js';
|
|
10
4
|
import classnames from 'classnames';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
imgElement
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
5
|
+
import { FILE_PICKER_ERROR } from '../file_picker/constants.js';
|
|
6
|
+
import { useFilePicker } from '../file_picker/use_file_picker.js';
|
|
7
|
+
import { getAcceptFilesParametersFromAllowedExtensions } from '../file_picker/utils.js';
|
|
8
|
+
import CSS_CLASSES from './css_classes.js';
|
|
9
|
+
import ControlInput from '../controls/hoc/control_input/index.js';
|
|
10
|
+
import styles from '../../css/image_picker/main.module.less.js';
|
|
11
|
+
import ImageInput from './components/image_input.js';
|
|
12
|
+
import SelectedImagePreview from './components/selected_image_preview.js';
|
|
13
|
+
import Spacing from '../spacing/index.js';
|
|
14
|
+
import { checkIfInvalideFileFormatErrorOccured } from './utils.js';
|
|
15
|
+
|
|
16
|
+
const ImagePicker = ({ id, onChange, allowedExtensions = ['WEBP', 'JPG', 'PNG', 'GIF'], initialFile, name, className = '', hasWidthInput, widthInputPostfix = 'px', widthInputLabel, widthInputHint }) => {
|
|
17
|
+
const [t] = useTranslation();
|
|
18
|
+
const [fileFormatIsCorrect, setFileFormatIsCorrect] = useState(true);
|
|
19
|
+
const [imageSize, setImageSize] = useState({ width: 0, height: 0 });
|
|
20
|
+
const [widthInputValue, setWidthInputValue] = useState();
|
|
21
|
+
const [isInputWidthTooBig, setIsInputWidthTooBig] = useState(false);
|
|
22
|
+
const { onDropFile, onFileChange, onDragOver, onDragLeave, onFileDelete, onPreviewError, file, errors, isPreview, isDragOver, isVectorImage } = useFilePicker({ initialFile, onChange, allowedExtensions });
|
|
23
|
+
const acceptFiles = getAcceptFilesParametersFromAllowedExtensions(allowedExtensions);
|
|
24
|
+
const showMaxWidthInput = hasWidthInput && file && fileFormatIsCorrect && !isVectorImage;
|
|
25
|
+
const imagePickerClassName = classnames(styles[CSS_CLASSES.imagePicker], className && className);
|
|
26
|
+
const imagePickerWrapperClassName = classnames(styles[CSS_CLASSES.imagePickerWrapper], file && styles[CSS_CLASSES.imagePickerWrapperHasFile], !fileFormatIsCorrect && styles[CSS_CLASSES.imagePickerWrapperError]);
|
|
27
|
+
const useStyles = createUseStyles({
|
|
28
|
+
imagePickerWrapper: {
|
|
29
|
+
border: ({ isDragOver }) => (isDragOver ? '1px solid #135cc8' : ''),
|
|
30
|
+
backgroundColor: ({ isDragOver }) => (isDragOver ? 'rgba(208, 230, 255, 0.5)' : ''),
|
|
31
|
+
'& svg': {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
fill: ({ isDragOver }) => (isDragOver ? '#3c83ec' : '')
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const dragOverStyles = useStyles({ isDragOver });
|
|
38
|
+
const getImageWidth = (event) => {
|
|
39
|
+
let selectedImage;
|
|
40
|
+
if (event.target instanceof HTMLInputElement) {
|
|
41
|
+
const { target: { files } } = event;
|
|
42
|
+
selectedImage = files[0];
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const { dataTransfer: { files } } = event;
|
|
46
|
+
selectedImage = files[0];
|
|
47
|
+
}
|
|
48
|
+
const imgElement = document.createElement('img');
|
|
49
|
+
const objectURL = URL.createObjectURL(selectedImage);
|
|
50
|
+
imgElement.onload = () => {
|
|
51
|
+
setImageSize({ width: imgElement.width, height: imgElement.height });
|
|
52
|
+
URL.revokeObjectURL(objectURL);
|
|
53
|
+
};
|
|
54
|
+
imgElement.src = objectURL;
|
|
55
|
+
};
|
|
56
|
+
const checkIfInputMaxWidthIsGreaterThenImageWidth = () => {
|
|
57
|
+
if (!widthInputValue || !imageSize.width)
|
|
58
|
+
return;
|
|
59
|
+
widthInputValue > imageSize.width ? setIsInputWidthTooBig(true) : setIsInputWidthTooBig(false);
|
|
60
|
+
};
|
|
61
|
+
const handleonDropFile = (event) => {
|
|
62
|
+
onDropFile(event);
|
|
63
|
+
getImageWidth(event);
|
|
64
|
+
};
|
|
65
|
+
const handleOnFileChange = (event) => {
|
|
66
|
+
onFileChange(event);
|
|
67
|
+
getImageWidth(event);
|
|
68
|
+
};
|
|
69
|
+
const handleOnFileDelete = () => {
|
|
70
|
+
setImageSize({ width: 0, height: 0 });
|
|
71
|
+
onFileDelete();
|
|
72
|
+
};
|
|
73
|
+
const handleOnWidthInputChange = (event) => {
|
|
74
|
+
setWidthInputValue(event.target.valueAsNumber);
|
|
75
|
+
};
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
checkIfInvalideFileFormatErrorOccured(errors) ? setFileFormatIsCorrect(false) : setFileFormatIsCorrect(true);
|
|
78
|
+
file && checkIfInputMaxWidthIsGreaterThenImageWidth();
|
|
79
|
+
}, [errors, file, widthInputValue]);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
setWidthInputValue(imageSize.width);
|
|
82
|
+
}, [imageSize]);
|
|
83
|
+
return (React.createElement("div", { className: imagePickerClassName },
|
|
84
|
+
React.createElement("div", { className: `${imagePickerWrapperClassName} ${dragOverStyles.imagePickerWrapper}` },
|
|
85
|
+
file && (React.createElement(SelectedImagePreview, { file: file, onFileDelete: handleOnFileDelete, onPreviewError: onPreviewError, isPreview: isPreview, fileFormatIsCorrect: fileFormatIsCorrect, imageSize: imageSize })),
|
|
86
|
+
React.createElement(ImageInput, { onDragLeave: onDragLeave, onDragOver: onDragOver, isDragOver: isDragOver, allowedExtensions: allowedExtensions, id: id, onDropFile: handleonDropFile }),
|
|
87
|
+
React.createElement("input", { onChange: handleOnFileChange, id: id, type: "file", name: name, className: styles[CSS_CLASSES.imagePickerInput], accept: acceptFiles })),
|
|
88
|
+
!fileFormatIsCorrect && React.createElement("p", { className: styles[CSS_CLASSES.imagePickerErrorText] }, t('Invalid file format')),
|
|
89
|
+
showMaxWidthInput && (React.createElement(Spacing, { as: "div", "mt-xs": 2 },
|
|
90
|
+
React.createElement(ControlInput, { id: `${id}-image-width`, type: "number", postfix: widthInputPostfix, value: widthInputValue, isRequired: true, label: widthInputLabel, hint: widthInputHint, onChange: handleOnWidthInputChange, errors: isInputWidthTooBig ? [`${t(FILE_PICKER_ERROR.invalidInputWidth)}`] : null })))));
|
|
91
91
|
};
|
|
92
|
+
|
|
92
93
|
export default ImagePicker;
|
|
93
|
-
//# sourceMappingURL=index.js.map
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,iEAAqE;AACpG,gCAAgC,yDAA6D;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { FILE_PICKER_ERROR } from '
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { FILE_PICKER_ERROR } from '../file_picker/constants.js';
|
|
2
|
+
|
|
3
|
+
const checkIfInvalideFileFormatErrorOccured = (errorsArray) => {
|
|
4
|
+
return errorsArray && errorsArray.includes(FILE_PICKER_ERROR.invalidFileFormat);
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
export { checkIfInvalideFileFormatErrorOccured };
|
|
8
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import styleInject from '../../../../../external/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = "/* font colors */\n/* actions */\n/* background */\n/* errors */\n/* borders */\n/* grid */\n/* scrollBar */\n/* sizes */\n.main-module_image-picker__wrapper__2RK3f {\n border: 1px dashed #abb4cd;\n border-radius: 2px;\n}\n.main-module_image-picker__wrapper-error__kCZeA {\n border-color: #e60c54;\n}\n.main-module_image-picker__wrapper-error__kCZeA:hover {\n border-color: #e60c54;\n}\n.main-module_image-picker__wrapper-has-file__2zmRc {\n position: relative;\n}\n.main-module_image-picker__wrapper-has-file__2zmRc .main-module_image-picker__label__1i_Fq {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 46px;\n left: 0;\n}\n.main-module_image-picker__wrapper-has-file__2zmRc .main-module_image-picker__description__1v13N {\n display: none;\n}\n.main-module_image-picker__wrapper__2RK3f:hover {\n border-color: #135cc8;\n}\n.main-module_image-picker__wrapper__2RK3f:hover .main-module_image-picker__upload-icon__3sMvN {\n fill: #3c83ec;\n}\n.main-module_image-picker__label__1i_Fq {\n cursor: pointer;\n}\n.main-module_image-picker__input__3Wu2I {\n display: none;\n}\n.main-module_image-picker__description__1v13N {\n padding: 2rem 0;\n text-align: center;\n}\n.main-module_image-picker__description__1v13N p {\n color: #3c83ec;\n}\n.main-module_image-picker__description__1v13N span {\n font-size: 12px;\n color: #59687e;\n}\n.main-module_image-picker__upload-icon__3sMvN {\n width: 1rem;\n height: auto;\n margin-bottom: 1rem;\n fill: #abb4cd;\n}\n.main-module_image-picker__delete-button__21_kT {\n display: flex;\n align-items: center;\n flex-shrink: 0;\n color: #3c83ec;\n cursor: pointer;\n}\n.main-module_image-picker__delete-button__21_kT:hover .main-module_image-picker__delete-label__3v2ot {\n text-decoration: underline;\n}\n.main-module_image-picker__wrong-file-format-icon__X-NL0 {\n margin: 2rem 0 0.5rem;\n fill: #ffffff;\n}\n.main-module_image-picker__delete-icon__30pkO {\n fill: #3c83ec;\n margin-right: 0.5rem;\n}\n.main-module_image-picker__selected-file__3bRqa {\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 46px;\n}\n.main-module_image-picker__selected-file-name-wrapper__37MKd,\n.main-module_image-picker__selected-file-remove-wrapper__2v4W2 {\n flex: 1;\n max-width: 50%;\n padding: 1rem;\n}\n.main-module_image-picker__selected-file-remove-wrapper__2v4W2 {\n display: flex;\n justify-content: flex-end;\n}\n.main-module_image-picker__selected-file-full-name__3fALB {\n color: #59687e;\n}\n.main-module_image-picker__image-preview-wrapper__1jPXU {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.main-module_image-picker__image-preview__12pRu {\n max-width: 100%;\n max-height: 100%;\n}\n.main-module_image-picker__error-text__rXAvw {\n margin-top: 0.5rem;\n color: #e60c54;\n}\n";
|
|
4
|
+
var styles = {"image-picker__wrapper":"main-module_image-picker__wrapper__2RK3f","image-picker__wrapper-error":"main-module_image-picker__wrapper-error__kCZeA","image-picker__wrapper-has-file":"main-module_image-picker__wrapper-has-file__2zmRc","image-picker__label":"main-module_image-picker__label__1i_Fq","image-picker__description":"main-module_image-picker__description__1v13N","image-picker__upload-icon":"main-module_image-picker__upload-icon__3sMvN","image-picker__input":"main-module_image-picker__input__3Wu2I","image-picker__delete-button":"main-module_image-picker__delete-button__21_kT","image-picker__delete-label":"main-module_image-picker__delete-label__3v2ot","image-picker__wrong-file-format-icon":"main-module_image-picker__wrong-file-format-icon__X-NL0","image-picker__delete-icon":"main-module_image-picker__delete-icon__30pkO","image-picker__selected-file":"main-module_image-picker__selected-file__3bRqa","image-picker__selected-file-name-wrapper":"main-module_image-picker__selected-file-name-wrapper__37MKd","image-picker__selected-file-remove-wrapper":"main-module_image-picker__selected-file-remove-wrapper__2v4W2","image-picker__selected-file-full-name":"main-module_image-picker__selected-file-full-name__3fALB","image-picker__image-preview-wrapper":"main-module_image-picker__image-preview-wrapper__1jPXU","image-picker__image-preview":"main-module_image-picker__image-preview__12pRu","image-picker__error-text":"main-module_image-picker__error-text__rXAvw"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export default styles;
|
|
8
|
+
//# sourceMappingURL=main.module.less.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,wBAAwB,8DAAkE;AAC1F;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { RefObject } from 'react';
|
|
2
2
|
export declare const useFixedChildPosition: ({ useFixed, childRef, vPosition, hPosition }: {
|
|
3
3
|
useFixed?: boolean | undefined;
|
|
4
|
-
vPosition?: "
|
|
4
|
+
vPosition?: "top" | "bottom" | undefined;
|
|
5
5
|
hPosition?: "left" | "right" | "center" | undefined;
|
|
6
6
|
childRef?: React.RefObject<HTMLDivElement> | undefined;
|
|
7
7
|
}) => {
|
|
@@ -20,6 +20,7 @@ import ControlCheckboxSwitch from "./components/controls/hoc/control_checkbox_sw
|
|
|
20
20
|
import ControlColorPicker from "./components/controls/hoc/control_color_picker";
|
|
21
21
|
import ControlDatepicker from "./components/controls/hoc/control_date_picker";
|
|
22
22
|
import ControlFilePicker from "./components/controls/hoc/control_file_picker";
|
|
23
|
+
import ControlImagePicker from "./components/controls/hoc/control_image_picker";
|
|
23
24
|
import ControlInput from "./components/controls/hoc/control_input";
|
|
24
25
|
import ControlMultiSelect from "./components/controls/hoc/control_multi_select";
|
|
25
26
|
import ControlRadio from "./components/controls/hoc/control_radio";
|
|
@@ -61,6 +62,7 @@ import IconMobile from "./assets/icon_mobile";
|
|
|
61
62
|
import IconTablet from "./assets/icon_tablet";
|
|
62
63
|
import IconTick from "./assets/icon_tick";
|
|
63
64
|
import IconWarning from "./assets/icon_warning";
|
|
65
|
+
import ImagePicker from "./components/image_picker";
|
|
64
66
|
import Label from "./components/label";
|
|
65
67
|
import Link from "./components/link";
|
|
66
68
|
import Loader from "./components/loader";
|
|
@@ -75,13 +77,14 @@ import SearchListInput from "./components/search_list/components/search_list_inp
|
|
|
75
77
|
import SearchListResults from "./components/search_list/components/search_list_results";
|
|
76
78
|
import Select from "./components/dropdown/hoc/select";
|
|
77
79
|
import Slide from "./components/slide";
|
|
78
|
-
import SlideHeader from "./components/slide/components/slide_header";
|
|
79
80
|
import SlideContent from "./components/slide/components/slide_content";
|
|
80
81
|
import SlideFooter from "./components/slide/components/slide_footer";
|
|
82
|
+
import SlideHeader from "./components/slide/components/slide_header";
|
|
81
83
|
import SlideWrapper from "./components/slide/components/slide_wrapper";
|
|
82
84
|
import Spacing from "./components/spacing";
|
|
83
85
|
import Stack from "./components/stack";
|
|
84
86
|
import { TFilePickerFile } from "./components/file_picker/types";
|
|
87
|
+
import { TImagePickerFile } from "./components/image_picker/types";
|
|
85
88
|
import { TMessageBoxType } from "./components/message-box/types";
|
|
86
89
|
import Table from "./components/table";
|
|
87
90
|
import Tabs from "./components/tabs/components/tabs";
|
|
@@ -93,20 +96,20 @@ import TabsWrapper from "./components/tabs/components/tabs_wrapper";
|
|
|
93
96
|
import Tag from "./components/tag";
|
|
94
97
|
import TagsSelector from "./components/tags_selector";
|
|
95
98
|
import Tooltip from "./components/tooltip";
|
|
99
|
+
import { Typography } from "./components/typography";
|
|
96
100
|
import WithLoader from "./components/with_loader";
|
|
97
101
|
import { useDropdownContext } from "./components/dropdown/context";
|
|
98
102
|
import { useFlashMessenger } from "./components/flash_messenger/context";
|
|
99
103
|
import { useSearchList } from "./components/search_list/use_search_list";
|
|
100
104
|
import { useToggle } from "./components/dropdown/hooks";
|
|
101
|
-
import { Typography } from "./components/typography";
|
|
102
105
|
/**
|
|
103
106
|
* export hooks
|
|
104
107
|
*/
|
|
105
108
|
/**
|
|
106
109
|
* export components
|
|
107
110
|
*/
|
|
108
|
-
export { Accordion, Button, Tooltip, ButtonsGroup, Dropdown, Select, MultiSelect, Label, Stack, Control, ControlInput, ControlCheckbox, ControlCheckboxSwitch, ControlRadio, ControlSelect, ControlRange, ControlMultiSelect, ControlTextarea, Gallery, Datepicker, ColorPicker, ControlColorPicker, ControlDatepicker, ControlFilePicker, Heading, Typography, Modal, ModalProvider, AbsoluteModal, RelativeModal, TabsWrapper, Tabs, TabsItem, TabsItemList, TabsPanel, TabsPanelList, SearchList, SearchListInput, SearchListResults, Tag, TagsSelector, ControlTagsSelector, Table, DataTable, Grid, DropdownContext, ModalContext, IconCalendar, Spacing, IconArrow, IconTick, FilePicker, ControlCellSelector, Hint, ControlRadioGroup, MessageBox, FlashMessenger, useFlashMessenger, Loader, WithLoader, useDropdownContext, FlashMessengerContext, FlashMessagesList, Link, IconTablet, IconMobile, IconLaptop, IconDesktop, IconWarning, useToggle, useSearchList, Slide, SlideWrapper, SlideHeader, SlideContent, SlideFooter };
|
|
111
|
+
export { Accordion, Button, Tooltip, ButtonsGroup, Dropdown, Select, MultiSelect, Label, Stack, Control, ControlInput, ControlCheckbox, ControlCheckboxSwitch, ControlRadio, ControlSelect, ControlRange, ControlMultiSelect, ControlTextarea, Gallery, Datepicker, ColorPicker, ControlColorPicker, ControlDatepicker, ControlFilePicker, ControlImagePicker, Heading, Typography, Modal, ModalProvider, AbsoluteModal, RelativeModal, TabsWrapper, Tabs, TabsItem, TabsItemList, TabsPanel, TabsPanelList, SearchList, SearchListInput, SearchListResults, Tag, TagsSelector, ControlTagsSelector, Table, DataTable, Grid, DropdownContext, ModalContext, IconCalendar, Spacing, IconArrow, IconTick, FilePicker, ImagePicker, ControlCellSelector, Hint, ControlRadioGroup, MessageBox, FlashMessenger, useFlashMessenger, Loader, WithLoader, useDropdownContext, FlashMessengerContext, FlashMessagesList, Link, IconTablet, IconMobile, IconLaptop, IconDesktop, IconWarning, useToggle, useSearchList, Slide, SlideWrapper, SlideHeader, SlideContent, SlideFooter };
|
|
109
112
|
/**
|
|
110
113
|
* export types
|
|
111
114
|
*/
|
|
112
|
-
export type { IDropdownProps, ISelectOption, IHeadingProps, ICellProps, IIRowProps, ITableProps, IDropdownContext, IControlRadioGroupOption, IColor, IDatepickerRange, TFilePickerFile, TMessageBoxType, ILoaderProps, IWithLoader, TFlashMessage, TFlashMessageExtended };
|
|
115
|
+
export type { IDropdownProps, ISelectOption, IHeadingProps, ICellProps, IIRowProps, ITableProps, IDropdownContext, IControlRadioGroupOption, IColor, IDatepickerRange, TFilePickerFile, TImagePickerFile, TMessageBoxType, ILoaderProps, IWithLoader, TFlashMessage, TFlashMessageExtended };
|
|
@@ -23,6 +23,9 @@ export { default as ControlDatepicker } from './components/controls/hoc/control_
|
|
|
23
23
|
export { default as FilePicker } from './components/file_picker/index.js';
|
|
24
24
|
export { default as ControlFilePicker } from './components/controls/hoc/control_file_picker/index.js';
|
|
25
25
|
export { default as ControlInput } from './components/controls/hoc/control_input/index.js';
|
|
26
|
+
export { default as Spacing } from './components/spacing/index.js';
|
|
27
|
+
export { default as ImagePicker } from './components/image_picker/index.js';
|
|
28
|
+
export { default as ControlImagePicker } from './components/controls/hoc/control_image_picker/index.js';
|
|
26
29
|
export { default as MultiSelect } from './components/dropdown/hoc/multiselect/index.js';
|
|
27
30
|
export { default as ControlMultiSelect } from './components/controls/hoc/control_multi_select/index.js';
|
|
28
31
|
export { default as ControlRadio } from './components/controls/hoc/control_radio/index.js';
|
|
@@ -59,11 +62,10 @@ export { useSearchList } from './components/search_list/use_search_list.js';
|
|
|
59
62
|
export { SearchListInput } from './components/search_list/components/search_list_input.js';
|
|
60
63
|
export { SearchListResults } from './components/search_list/components/search_list_results.js';
|
|
61
64
|
export { default as Slide } from './components/slide/index.js';
|
|
62
|
-
export { SlideHeader } from './components/slide/components/slide_header.js';
|
|
63
65
|
export { SlideContent } from './components/slide/components/slide_content.js';
|
|
64
66
|
export { SlideFooter } from './components/slide/components/slide_footer.js';
|
|
67
|
+
export { SlideHeader } from './components/slide/components/slide_header.js';
|
|
65
68
|
export { SlideWrapper } from './components/slide/components/slide_wrapper.js';
|
|
66
|
-
export { default as Spacing } from './components/spacing/index.js';
|
|
67
69
|
export { default as Tabs } from './components/tabs/components/tabs.js';
|
|
68
70
|
export { TabsItem } from './components/tabs/components/tabs_item.js';
|
|
69
71
|
export { TabsItemList } from './components/tabs/components/tabs_item_list.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|