@dreamcommerce/aurora 2.6.0-10 → 2.6.0-11
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/components/controls/hoc/control_xhr_image_picker/index.js +2 -7
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_xhr_image_picker/index.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/file_picker/use_file_picker.js +0 -5
- package/build/cjs/packages/aurora/src/components/file_picker/use_file_picker.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/image_picker/index.js +6 -3
- package/build/cjs/packages/aurora/src/components/image_picker/index.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/xhr_image_picker/index.js +4 -4
- package/build/esm/packages/aurora/src/components/controls/hoc/control_xhr_image_picker/index.js +2 -7
- package/build/esm/packages/aurora/src/components/controls/hoc/control_xhr_image_picker/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/controls/types.d.ts +3 -3
- package/build/esm/packages/aurora/src/components/controls/types.js.map +1 -1
- package/build/esm/packages/aurora/src/components/file_picker/use_file_picker.js +0 -5
- package/build/esm/packages/aurora/src/components/file_picker/use_file_picker.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/index.js +7 -4
- package/build/esm/packages/aurora/src/components/image_picker/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/types.d.ts +2 -2
- package/build/esm/packages/aurora/src/components/xhr_image_picker/index.js +4 -4
- package/build/esm/packages/aurora/src/components/xhr_image_picker/types.d.ts +2 -2
- package/build/esm/packages/aurora/src/components/xhr_image_picker/types.js.map +1 -1
- package/package.json +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/constants.d.ts +0 -1
- package/build/esm/packages/aurora/src/components/image_picker/constants.js +0 -2
- package/build/esm/packages/aurora/src/components/image_picker/constants.js.map +0 -1
package/build/cjs/packages/aurora/src/components/controls/hoc/control_xhr_image_picker/index.js
CHANGED
|
@@ -11,19 +11,14 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
13
|
|
|
14
|
-
const ControlXhrImagePicker = ({ url, label, isRequired, id, name, onChange, allowedExtensions, initialFile, className, errors, hint, labelAdditionalInfo, onUploaded
|
|
15
|
-
// hasWidthInput,
|
|
16
|
-
// widthInputPostfix,
|
|
17
|
-
// widthInputLabel,
|
|
18
|
-
// widthInputHint
|
|
19
|
-
}) => {
|
|
14
|
+
const ControlXhrImagePicker = ({ url, label, isRequired, id, name, onChange, allowedExtensions, initialFile, className, errors, hint, labelAdditionalInfo, onUploaded, onImageSizeUpdated }) => {
|
|
20
15
|
return (React__default['default'].createElement(index['default'], { errors: errors, name: name, id: id },
|
|
21
16
|
(label || hint) && (React__default['default'].createElement(index['default'].Label, { id: id, isRequired: isRequired, additionalInfo: labelAdditionalInfo },
|
|
22
17
|
label,
|
|
23
18
|
hint && React__default['default'].createElement(index$1['default'], { hint: hint, spacingLeft: true }))),
|
|
24
19
|
React__default['default'].createElement(index['default'].Content, null,
|
|
25
20
|
React__default['default'].createElement(index['default'].Element, null,
|
|
26
|
-
React__default['default'].createElement(index$2['default'], { url: url, id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile, className: className, errors: errors, onUploaded: onUploaded }))),
|
|
21
|
+
React__default['default'].createElement(index$2['default'], { url: url, id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile, className: className, errors: errors, onUploaded: onUploaded, onImageSizeUpdated: onImageSizeUpdated }))),
|
|
27
22
|
React__default['default'].createElement(index['default'].Errors, null)));
|
|
28
23
|
};
|
|
29
24
|
|
package/build/cjs/packages/aurora/src/components/controls/hoc/control_xhr_image_picker/index.js.map
CHANGED
|
@@ -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;
|
|
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;"}
|
|
@@ -29,13 +29,8 @@ const useFilePicker = ({ onChange, initialFile, allowedExtensions, inputRef, ini
|
|
|
29
29
|
if (!allowedExtensions)
|
|
30
30
|
return;
|
|
31
31
|
const isValid = allowedExtensions.reduce((acc, extension) => {
|
|
32
|
-
console.log('extension', extension);
|
|
33
|
-
console.log('MIME_TYPE_TO_FILE_EXTENSIONS', constants.MIME_TYPE_TO_FILE_EXTENSIONS);
|
|
34
|
-
console.log('MIME_TYPE_TO_FILE_EXTENSIONS[mimeType]', constants.MIME_TYPE_TO_FILE_EXTENSIONS[mimeType]);
|
|
35
32
|
return acc ? acc : constants.MIME_TYPE_TO_FILE_EXTENSIONS[mimeType] === extension;
|
|
36
33
|
}, false);
|
|
37
|
-
console.log('isValid', isValid);
|
|
38
|
-
console.log('mimeType', mimeType);
|
|
39
34
|
!isValid ? setErrors([...errors, i18n['default'].t(constants.FILE_PICKER_ERROR.invalidFileFormat)]) : setErrors([]);
|
|
40
35
|
};
|
|
41
36
|
const onFileChange = ({ target: { files } }) => {
|
|
@@ -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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -21,7 +21,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
21
21
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
22
|
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
23
23
|
|
|
24
|
-
const ImagePicker = ({ id, onChange, errors: initialErrors, allowedExtensions = [constants.FILES_EXTENSIONS.WEBP, constants.FILES_EXTENSIONS.JPG, constants.FILES_EXTENSIONS.PNG, constants.FILES_EXTENSIONS.GIF, constants.FILES_EXTENSIONS.SVG], initialFile, name, className = ''
|
|
24
|
+
const ImagePicker = ({ id, onChange, errors: initialErrors, allowedExtensions = [constants.FILES_EXTENSIONS.WEBP, constants.FILES_EXTENSIONS.JPG, constants.FILES_EXTENSIONS.PNG, constants.FILES_EXTENSIONS.GIF, constants.FILES_EXTENSIONS.SVG], initialFile, name, className = '', onImageSizeUpdated
|
|
25
25
|
// hasWidthInput,
|
|
26
26
|
// widthInputPostfix = 'px',
|
|
27
27
|
// widthInputLabel,
|
|
@@ -33,8 +33,8 @@ const ImagePicker = ({ id, onChange, errors: initialErrors, allowedExtensions =
|
|
|
33
33
|
const [imageSize, setImageSize] = React.useState(undefined);
|
|
34
34
|
// const [widthInputValue, setWidthInputValue] = useState<number | undefined>();
|
|
35
35
|
// const [isInputWidthTooBig, setIsInputWidthTooBig] = useState<boolean>(false);
|
|
36
|
-
const onImageFileChange = (
|
|
37
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(
|
|
36
|
+
const onImageFileChange = (fileList) => {
|
|
37
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(fileList);
|
|
38
38
|
};
|
|
39
39
|
const { onDropFile, onFileChange, onDragOver, onDragLeave, onFileDelete, onPreviewError, file, errors, isPreview, isDragOver } = use_file_picker.useFilePicker({ initialFile, onChange: onImageFileChange, allowedExtensions, initialErrors, inputRef });
|
|
40
40
|
const acceptFiles = utils.getAcceptFilesParametersFromAllowedExtensions(allowedExtensions);
|
|
@@ -43,6 +43,9 @@ const ImagePicker = ({ id, onChange, errors: initialErrors, allowedExtensions =
|
|
|
43
43
|
const imagePickerWrapperClassName = classnames__default['default'](main_module['default'][css_classes['default'].imagePickerWrapper], file && main_module['default'][css_classes['default'].imagePickerWrapperHasFile], {
|
|
44
44
|
[main_module['default'][css_classes['default'].imagePickerWrapperError]]: errors.length
|
|
45
45
|
});
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
onImageSizeUpdated === null || onImageSizeUpdated === void 0 ? void 0 : onImageSizeUpdated(imageSize);
|
|
48
|
+
}, [imageSize]);
|
|
46
49
|
const useStyles = reactJss_esm.createUseStyles({
|
|
47
50
|
imagePickerWrapper: {
|
|
48
51
|
border: ({ isDragOver }) => (isDragOver ? '1px solid #135cc8' : ''),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,6BAA6B,iEAAqE;AAClG,2BAA2B,yDAA6D;AACxF;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;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,6BAA6B,iEAAqE;AAClG,2BAA2B,yDAA6D;AACxF;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;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;"}
|
|
@@ -12,18 +12,18 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
12
|
|
|
13
13
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
14
|
|
|
15
|
-
const XhrImagePicker = ({ id, url, name, onUploaded, initialFile, errors, allowedExtensions = [constants.FILES_EXTENSIONS.WEBP, constants.FILES_EXTENSIONS.JPG, constants.FILES_EXTENSIONS.PNG, constants.FILES_EXTENSIONS.GIF, constants.FILES_EXTENSIONS.SVG] }) => {
|
|
15
|
+
const XhrImagePicker = ({ id, url, name, onUploaded, initialFile, errors, onImageSizeUpdated, allowedExtensions = [constants.FILES_EXTENSIONS.WEBP, constants.FILES_EXTENSIONS.JPG, constants.FILES_EXTENSIONS.PNG, constants.FILES_EXTENSIONS.GIF, constants.FILES_EXTENSIONS.SVG] }) => {
|
|
16
16
|
const httpApi = use_http_api.useHttpApi();
|
|
17
|
-
const onChange = async (fileList
|
|
17
|
+
const onChange = async (fileList) => {
|
|
18
18
|
const { response } = httpApi.fetch({
|
|
19
19
|
url,
|
|
20
20
|
method: http_requester_contants.REQUEST_TYPES.post,
|
|
21
21
|
data: fileList[0]
|
|
22
22
|
});
|
|
23
23
|
const data = await response;
|
|
24
|
-
onUploaded === null || onUploaded === void 0 ? void 0 : onUploaded(data, fileList[0]
|
|
24
|
+
onUploaded === null || onUploaded === void 0 ? void 0 : onUploaded(data, fileList[0]);
|
|
25
25
|
};
|
|
26
|
-
return (React__default['default'].createElement(index['default'], { id: id, name: name, onChange: onChange, errors: errors, allowedExtensions: allowedExtensions, initialFile: initialFile }));
|
|
26
|
+
return (React__default['default'].createElement(index['default'], { id: id, name: name, onChange: onChange, errors: errors, allowedExtensions: allowedExtensions, initialFile: initialFile, onImageSizeUpdated: onImageSizeUpdated }));
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
exports.default = XhrImagePicker;
|
package/build/esm/packages/aurora/src/components/controls/hoc/control_xhr_image_picker/index.js
CHANGED
|
@@ -3,19 +3,14 @@ import Control from '../../index.js';
|
|
|
3
3
|
import Hint from '../../../hint/index.js';
|
|
4
4
|
import XhrImagePicker from '../../../xhr_image_picker/index.js';
|
|
5
5
|
|
|
6
|
-
const ControlXhrImagePicker = ({ url, label, isRequired, id, name, onChange, allowedExtensions, initialFile, className, errors, hint, labelAdditionalInfo, onUploaded
|
|
7
|
-
// hasWidthInput,
|
|
8
|
-
// widthInputPostfix,
|
|
9
|
-
// widthInputLabel,
|
|
10
|
-
// widthInputHint
|
|
11
|
-
}) => {
|
|
6
|
+
const ControlXhrImagePicker = ({ url, label, isRequired, id, name, onChange, allowedExtensions, initialFile, className, errors, hint, labelAdditionalInfo, onUploaded, onImageSizeUpdated }) => {
|
|
12
7
|
return (React.createElement(Control, { errors: errors, name: name, id: id },
|
|
13
8
|
(label || hint) && (React.createElement(Control.Label, { id: id, isRequired: isRequired, additionalInfo: labelAdditionalInfo },
|
|
14
9
|
label,
|
|
15
10
|
hint && React.createElement(Hint, { hint: hint, spacingLeft: true }))),
|
|
16
11
|
React.createElement(Control.Content, null,
|
|
17
12
|
React.createElement(Control.Element, null,
|
|
18
|
-
React.createElement(XhrImagePicker, { url: url, id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile, className: className, errors: errors, onUploaded: onUploaded }))),
|
|
13
|
+
React.createElement(XhrImagePicker, { url: url, id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile, className: className, errors: errors, onUploaded: onUploaded, onImageSizeUpdated: onImageSizeUpdated }))),
|
|
19
14
|
React.createElement(Control.Errors, null)));
|
|
20
15
|
};
|
|
21
16
|
|
package/build/esm/packages/aurora/src/components/controls/hoc/control_xhr_image_picker/index.js.map
CHANGED
|
@@ -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;
|
|
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;"}
|
|
@@ -5,7 +5,7 @@ import { IFilePicker } from "../file_picker/types";
|
|
|
5
5
|
import { IRange } from "../range/types";
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { TVerticalPosition } from "../../typings/general";
|
|
8
|
-
import { TImageSize } from "../image_picker/types";
|
|
8
|
+
import { IImagePicker, TImageSize } from "../image_picker/types";
|
|
9
9
|
import { IRequestResponse } from '@dreamcommerce/star_core';
|
|
10
10
|
export declare type TControlErrors = string[] | null | undefined;
|
|
11
11
|
export interface IControlContext {
|
|
@@ -171,13 +171,13 @@ export interface IControlFilePicker extends IFilePicker, IControlCommonProps {
|
|
|
171
171
|
name?: string;
|
|
172
172
|
labelAdditionalInfo?: string | ReactNode;
|
|
173
173
|
}
|
|
174
|
-
export interface IControlXhrImagePicker extends
|
|
174
|
+
export interface IControlXhrImagePicker extends IImagePicker, IControlCommonProps {
|
|
175
175
|
url: string;
|
|
176
176
|
label?: string;
|
|
177
177
|
isRequired?: boolean;
|
|
178
178
|
onChange?: (fileList: FileList | null, size?: TImageSize) => void;
|
|
179
179
|
labelAdditionalInfo?: string | ReactNode;
|
|
180
|
-
onUploaded?: (resp: IRequestResponse<any>, file: File
|
|
180
|
+
onUploaded?: (resp: IRequestResponse<any>, file: File) => void;
|
|
181
181
|
}
|
|
182
182
|
export interface ICellSelector {
|
|
183
183
|
rows?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/controls/types.ts"],"names":[],"mappings":"AAAA,OAA0G,OAAO,CAAC;AAClH,OAAgD,kCAAkC,CAAC;AAEnF,OAAkC,sCAAsC,CAAC;AACzE,OAA4B,qCAAqC,CAAC;AAClE,OAAuB,+BAA+B,CAAC;AACvD,OAAkB,OAAO,CAAC;AAC1B,OAAkC,wBAAwB,CAAC;AAC3D,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/controls/types.ts"],"names":[],"mappings":"AAAA,OAA0G,OAAO,CAAC;AAClH,OAAgD,kCAAkC,CAAC;AAEnF,OAAkC,sCAAsC,CAAC;AACzE,OAA4B,qCAAqC,CAAC;AAClE,OAAuB,+BAA+B,CAAC;AACvD,OAAkB,OAAO,CAAC;AAC1B,OAAkC,wBAAwB,CAAC;AAC3D,OAAyC,sCAAsC,CAAC;AAChF,OAAiC,0BAA0B,CAAC"}
|
|
@@ -25,13 +25,8 @@ const useFilePicker = ({ onChange, initialFile, allowedExtensions, inputRef, ini
|
|
|
25
25
|
if (!allowedExtensions)
|
|
26
26
|
return;
|
|
27
27
|
const isValid = allowedExtensions.reduce((acc, extension) => {
|
|
28
|
-
console.log('extension', extension);
|
|
29
|
-
console.log('MIME_TYPE_TO_FILE_EXTENSIONS', MIME_TYPE_TO_FILE_EXTENSIONS);
|
|
30
|
-
console.log('MIME_TYPE_TO_FILE_EXTENSIONS[mimeType]', MIME_TYPE_TO_FILE_EXTENSIONS[mimeType]);
|
|
31
28
|
return acc ? acc : MIME_TYPE_TO_FILE_EXTENSIONS[mimeType] === extension;
|
|
32
29
|
}, false);
|
|
33
|
-
console.log('isValid', isValid);
|
|
34
|
-
console.log('mimeType', mimeType);
|
|
35
30
|
!isValid ? setErrors([...errors, i18n.t(FILE_PICKER_ERROR.invalidFileFormat)]) : setErrors([]);
|
|
36
31
|
};
|
|
37
32
|
const onFileChange = ({ target: { files } }) => {
|
|
@@ -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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createRef, useState } from 'react';
|
|
1
|
+
import React, { createRef, useState, useEffect } from 'react';
|
|
2
2
|
import { useTranslation } from '../../../../../external/react-i18next/dist/es/useTranslation.js';
|
|
3
3
|
import { createUseStyles } from '../../../../../external/react-jss/dist/react-jss.esm.js';
|
|
4
4
|
import classnames from 'classnames';
|
|
@@ -12,7 +12,7 @@ import ImageInput from './components/image_input.js';
|
|
|
12
12
|
import { ImagePreview } from './components/image_preview.js';
|
|
13
13
|
import { UploadedImageItem } from './components/uploaded_image_item.js';
|
|
14
14
|
|
|
15
|
-
const ImagePicker = ({ id, onChange, errors: initialErrors, allowedExtensions = [FILES_EXTENSIONS.WEBP, FILES_EXTENSIONS.JPG, FILES_EXTENSIONS.PNG, FILES_EXTENSIONS.GIF, FILES_EXTENSIONS.SVG], initialFile, name, className = ''
|
|
15
|
+
const ImagePicker = ({ id, onChange, errors: initialErrors, allowedExtensions = [FILES_EXTENSIONS.WEBP, FILES_EXTENSIONS.JPG, FILES_EXTENSIONS.PNG, FILES_EXTENSIONS.GIF, FILES_EXTENSIONS.SVG], initialFile, name, className = '', onImageSizeUpdated
|
|
16
16
|
// hasWidthInput,
|
|
17
17
|
// widthInputPostfix = 'px',
|
|
18
18
|
// widthInputLabel,
|
|
@@ -24,8 +24,8 @@ const ImagePicker = ({ id, onChange, errors: initialErrors, allowedExtensions =
|
|
|
24
24
|
const [imageSize, setImageSize] = useState(undefined);
|
|
25
25
|
// const [widthInputValue, setWidthInputValue] = useState<number | undefined>();
|
|
26
26
|
// const [isInputWidthTooBig, setIsInputWidthTooBig] = useState<boolean>(false);
|
|
27
|
-
const onImageFileChange = (
|
|
28
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(
|
|
27
|
+
const onImageFileChange = (fileList) => {
|
|
28
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(fileList);
|
|
29
29
|
};
|
|
30
30
|
const { onDropFile, onFileChange, onDragOver, onDragLeave, onFileDelete, onPreviewError, file, errors, isPreview, isDragOver } = useFilePicker({ initialFile, onChange: onImageFileChange, allowedExtensions, initialErrors, inputRef });
|
|
31
31
|
const acceptFiles = getAcceptFilesParametersFromAllowedExtensions(allowedExtensions);
|
|
@@ -34,6 +34,9 @@ const ImagePicker = ({ id, onChange, errors: initialErrors, allowedExtensions =
|
|
|
34
34
|
const imagePickerWrapperClassName = classnames(styles[CSS_CLASSES.imagePickerWrapper], file && styles[CSS_CLASSES.imagePickerWrapperHasFile], {
|
|
35
35
|
[styles[CSS_CLASSES.imagePickerWrapperError]]: errors.length
|
|
36
36
|
});
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
onImageSizeUpdated === null || onImageSizeUpdated === void 0 ? void 0 : onImageSizeUpdated(imageSize);
|
|
39
|
+
}, [imageSize]);
|
|
37
40
|
const useStyles = createUseStyles({
|
|
38
41
|
imagePickerWrapper: {
|
|
39
42
|
border: ({ isDragOver }) => (isDragOver ? '1px solid #135cc8' : ''),
|
|
@@ -1 +1 @@
|
|
|
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;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,+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;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;"}
|
|
@@ -4,8 +4,8 @@ export declare type TImagePickerFile = {
|
|
|
4
4
|
fileUrl: string;
|
|
5
5
|
fileName: string;
|
|
6
6
|
};
|
|
7
|
-
export interface IImagePicker extends
|
|
8
|
-
|
|
7
|
+
export interface IImagePicker extends IFilePicker {
|
|
8
|
+
onImageSizeUpdated?: (imageSize?: TImageSize) => void;
|
|
9
9
|
}
|
|
10
10
|
export interface ISelectedImagePreview {
|
|
11
11
|
file: TImagePickerFile;
|
|
@@ -4,18 +4,18 @@ import { REQUEST_TYPES } from '../../../../star_core/build/esm/packages/star_cor
|
|
|
4
4
|
import ImagePicker from '../image_picker/index.js';
|
|
5
5
|
import { useHttpApi } from '../../hooks/use_http_api.js';
|
|
6
6
|
|
|
7
|
-
const XhrImagePicker = ({ id, url, name, onUploaded, initialFile, errors, allowedExtensions = [FILES_EXTENSIONS.WEBP, FILES_EXTENSIONS.JPG, FILES_EXTENSIONS.PNG, FILES_EXTENSIONS.GIF, FILES_EXTENSIONS.SVG] }) => {
|
|
7
|
+
const XhrImagePicker = ({ id, url, name, onUploaded, initialFile, errors, onImageSizeUpdated, allowedExtensions = [FILES_EXTENSIONS.WEBP, FILES_EXTENSIONS.JPG, FILES_EXTENSIONS.PNG, FILES_EXTENSIONS.GIF, FILES_EXTENSIONS.SVG] }) => {
|
|
8
8
|
const httpApi = useHttpApi();
|
|
9
|
-
const onChange = async (fileList
|
|
9
|
+
const onChange = async (fileList) => {
|
|
10
10
|
const { response } = httpApi.fetch({
|
|
11
11
|
url,
|
|
12
12
|
method: REQUEST_TYPES.post,
|
|
13
13
|
data: fileList[0]
|
|
14
14
|
});
|
|
15
15
|
const data = await response;
|
|
16
|
-
onUploaded === null || onUploaded === void 0 ? void 0 : onUploaded(data, fileList[0]
|
|
16
|
+
onUploaded === null || onUploaded === void 0 ? void 0 : onUploaded(data, fileList[0]);
|
|
17
17
|
};
|
|
18
|
-
return (React.createElement(ImagePicker, { id: id, name: name, onChange: onChange, errors: errors, allowedExtensions: allowedExtensions, initialFile: initialFile }));
|
|
18
|
+
return (React.createElement(ImagePicker, { id: id, name: name, onChange: onChange, errors: errors, allowedExtensions: allowedExtensions, initialFile: initialFile, onImageSizeUpdated: onImageSizeUpdated }));
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export default XhrImagePicker;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IImagePicker
|
|
1
|
+
import { IImagePicker } from "../image_picker/types";
|
|
2
2
|
import { IRequestResponse } from '@dreamcommerce/star_core';
|
|
3
3
|
export interface IXhrImagePickerProps extends IImagePicker {
|
|
4
4
|
url: string;
|
|
5
|
-
onUploaded?: (resp: IRequestResponse<any>, file: File
|
|
5
|
+
onUploaded?: (resp: IRequestResponse<any>, file: File) => void;
|
|
6
6
|
onUploadError?: Function;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/xhr_image_picker/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/xhr_image_picker/types.ts"],"names":[],"mappings":"AAAA,OAA6B,sCAAsC,CAAC;AACpE,OAAiC,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../src/components/image_picker/constants.ts"],"names":[],"mappings":""}
|