@dreamcommerce/aurora 2.6.0-3 → 2.6.0-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ const ControlImagePicker = ({ label, isRequired, id, name, onChange, allowedExte
18
18
  hint && React__default['default'].createElement(index$1['default'], { hint: hint, spacingLeft: true }))),
19
19
  React__default['default'].createElement(index['default'].Content, null,
20
20
  React__default['default'].createElement(index['default'].Element, null,
21
- React__default['default'].createElement(index$2['default'], { id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile, className: className, hasWidthInput: hasWidthInput, widthInputPostfix: widthInputPostfix, widthInputLabel: widthInputLabel, widthInputHint: widthInputHint }))),
21
+ React__default['default'].createElement(index$2['default'], { id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile, className: className }))),
22
22
  React__default['default'].createElement(index['default'].Errors, null)));
23
23
  };
24
24
 
@@ -21,12 +21,17 @@ 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, allowedExtensions = [constants.FILES_EXTENSIONS.WEBP, constants.FILES_EXTENSIONS.JPG, constants.FILES_EXTENSIONS.PNG, constants.FILES_EXTENSIONS.GIF, constants.FILES_EXTENSIONS.SVG], initialFile, name, className = '', hasWidthInput, widthInputPostfix = 'px', widthInputLabel, widthInputHint }) => {
24
+ const ImagePicker = ({ id, onChange, allowedExtensions = [constants.FILES_EXTENSIONS.WEBP, constants.FILES_EXTENSIONS.JPG, constants.FILES_EXTENSIONS.PNG, constants.FILES_EXTENSIONS.GIF, constants.FILES_EXTENSIONS.SVG], initialFile, name, className = ''
25
+ // hasWidthInput,
26
+ // widthInputPostfix = 'px',
27
+ // widthInputLabel,
28
+ // widthInputHint
29
+ }) => {
25
30
  const [t] = useTranslation.useTranslation();
26
31
  const inputRef = React.createRef();
27
32
  // const [fileFormatIsCorrect, setFileFormatIsCorrect] = useState<boolean>(true);
28
33
  const [imageSize, setImageSize] = React.useState({ width: 0, height: 0 });
29
- const [widthInputValue, setWidthInputValue] = React.useState();
34
+ // const [widthInputValue, setWidthInputValue] = useState<number | undefined>();
30
35
  // const [isInputWidthTooBig, setIsInputWidthTooBig] = useState<boolean>(false);
31
36
  const { onDropFile, onFileChange, onDragOver, onDragLeave, onFileDelete, onPreviewError, file, errors, isPreview, isDragOver } = use_file_picker.useFilePicker({ initialFile, onChange, allowedExtensions, inputRef });
32
37
  const acceptFiles = utils.getAcceptFilesParametersFromAllowedExtensions(allowedExtensions);
@@ -98,9 +103,9 @@ const ImagePicker = ({ id, onChange, allowedExtensions = [constants.FILES_EXTENS
98
103
  // // checkIfInvalideFileFormatErrorOccured(errors) ? setFileFormatIsCorrect(false) : setFileFormatIsCorrect(true);
99
104
  // // file && checkIfInputMaxWidthIsGreaterThenImageWidth();
100
105
  // }, [errors, file, widthInputValue]);
101
- React.useEffect(() => {
102
- setWidthInputValue(imageSize.width);
103
- }, [imageSize]);
106
+ // useEffect(() => {
107
+ // setWidthInputValue(imageSize.width);
108
+ // }, [imageSize]);
104
109
  return (React__default['default'].createElement("div", { className: imagePickerClassName },
105
110
  React__default['default'].createElement("div", { className: `${imagePickerWrapperClassName} ${dragOverStyles.imagePickerWrapper}` },
106
111
  file &&
@@ -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;"}
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;"}
@@ -12,19 +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, 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, 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
17
  const onChange = async (fileList) => {
18
- console.warn('onChange', fileList[0]);
19
18
  const { response } = httpApi.fetch({
20
19
  url,
21
20
  method: http_requester_contants.REQUEST_TYPES.post,
22
21
  data: fileList[0]
23
22
  });
24
23
  const data = await response;
25
- onUploaded === null || onUploaded === void 0 ? void 0 : onUploaded(data);
24
+ onUploaded === null || onUploaded === void 0 ? void 0 : onUploaded(data, fileList[0]);
26
25
  };
27
- return (React__default['default'].createElement(index['default'], { id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile }));
26
+ return (React__default['default'].createElement(index['default'], { id: id, name: name, onChange: onChange, errors: errors, allowedExtensions: allowedExtensions, initialFile: initialFile }));
28
27
  };
29
28
 
30
29
  exports.default = XhrImagePicker;
@@ -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;"}
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;"}
@@ -10,7 +10,7 @@ const ControlImagePicker = ({ label, isRequired, id, name, onChange, allowedExte
10
10
  hint && React.createElement(Hint, { hint: hint, spacingLeft: true }))),
11
11
  React.createElement(Control.Content, null,
12
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 }))),
13
+ React.createElement(ImagePicker, { id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile, className: className }))),
14
14
  React.createElement(Control.Errors, null)));
15
15
  };
16
16
 
@@ -1,5 +1,6 @@
1
1
  import React, { ChangeEvent } from 'react';
2
2
  import { FILES_EXTENSIONS, MIME_FILE_EXTENSIONS } from "./constants";
3
+ import { TControlErrors } from "../controls/types";
3
4
  export declare type TFilePickerFile = {
4
5
  fileUrl: string;
5
6
  fileName: string;
@@ -11,6 +12,7 @@ export interface IFilePicker {
11
12
  onChange?: (fileList: FileList | null) => void;
12
13
  allowedExtensions?: TFilesExtension[];
13
14
  initialFile?: TFilePickerFile;
15
+ errors?: TControlErrors;
14
16
  }
15
17
  export interface ISelectedFilePreview {
16
18
  file: TFilePickerFile | null;
@@ -1,3 +1,4 @@
1
1
  import 'react';
2
2
  import '@auroraComponents/file_picker/constants';
3
+ import '@auroraComponents/controls/types';
3
4
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/file_picker/types.ts"],"names":[],"mappings":"AAAA,OAAmC,OAAO,CAAC;AAC3C,OAAuD,yCAAyC,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/file_picker/types.ts"],"names":[],"mappings":"AAAA,OAAmC,OAAO,CAAC;AAC3C,OAAuD,yCAAyC,CAAC;AACjG,OAA+B,kCAAkC,CAAC"}
@@ -1,4 +1,4 @@
1
- import React, { createRef, useState, useEffect } from 'react';
1
+ import React, { createRef, useState } 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,12 +12,17 @@ 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, allowedExtensions = [FILES_EXTENSIONS.WEBP, FILES_EXTENSIONS.JPG, FILES_EXTENSIONS.PNG, FILES_EXTENSIONS.GIF, FILES_EXTENSIONS.SVG], initialFile, name, className = '', hasWidthInput, widthInputPostfix = 'px', widthInputLabel, widthInputHint }) => {
15
+ const ImagePicker = ({ id, onChange, allowedExtensions = [FILES_EXTENSIONS.WEBP, FILES_EXTENSIONS.JPG, FILES_EXTENSIONS.PNG, FILES_EXTENSIONS.GIF, FILES_EXTENSIONS.SVG], initialFile, name, className = ''
16
+ // hasWidthInput,
17
+ // widthInputPostfix = 'px',
18
+ // widthInputLabel,
19
+ // widthInputHint
20
+ }) => {
16
21
  const [t] = useTranslation();
17
22
  const inputRef = createRef();
18
23
  // const [fileFormatIsCorrect, setFileFormatIsCorrect] = useState<boolean>(true);
19
24
  const [imageSize, setImageSize] = useState({ width: 0, height: 0 });
20
- const [widthInputValue, setWidthInputValue] = useState();
25
+ // const [widthInputValue, setWidthInputValue] = useState<number | undefined>();
21
26
  // const [isInputWidthTooBig, setIsInputWidthTooBig] = useState<boolean>(false);
22
27
  const { onDropFile, onFileChange, onDragOver, onDragLeave, onFileDelete, onPreviewError, file, errors, isPreview, isDragOver } = useFilePicker({ initialFile, onChange, allowedExtensions, inputRef });
23
28
  const acceptFiles = getAcceptFilesParametersFromAllowedExtensions(allowedExtensions);
@@ -89,9 +94,9 @@ const ImagePicker = ({ id, onChange, allowedExtensions = [FILES_EXTENSIONS.WEBP,
89
94
  // // checkIfInvalideFileFormatErrorOccured(errors) ? setFileFormatIsCorrect(false) : setFileFormatIsCorrect(true);
90
95
  // // file && checkIfInputMaxWidthIsGreaterThenImageWidth();
91
96
  // }, [errors, file, widthInputValue]);
92
- useEffect(() => {
93
- setWidthInputValue(imageSize.width);
94
- }, [imageSize]);
97
+ // useEffect(() => {
98
+ // setWidthInputValue(imageSize.width);
99
+ // }, [imageSize]);
95
100
  return (React.createElement("div", { className: imagePickerClassName },
96
101
  React.createElement("div", { className: `${imagePickerWrapperClassName} ${dragOverStyles.imagePickerWrapper}` },
97
102
  file &&
@@ -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;"}
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;"}
@@ -1,20 +1,10 @@
1
1
  import React from 'react';
2
- import { TFilesExtension } from "../file_picker/types";
2
+ import { IFilePicker, TFilesExtension } from "../file_picker/types";
3
3
  export declare type TImagePickerFile = {
4
4
  fileUrl: string;
5
5
  fileName: string;
6
6
  };
7
- export interface IImagePicker {
8
- id: string;
9
- name?: string;
10
- className?: string;
11
- onChange?: (imageList: FileList | null) => void;
12
- allowedExtensions?: TFilesExtension[];
13
- initialFile?: TImagePickerFile;
14
- hasWidthInput?: boolean;
15
- widthInputPostfix?: string;
16
- widthInputLabel?: string;
17
- widthInputHint?: string;
7
+ export interface IImagePicker extends IFilePicker {
18
8
  }
19
9
  export interface ISelectedImagePreview {
20
10
  file: TImagePickerFile;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/image_picker/types.ts"],"names":[],"mappings":"AAAA,OAAkB,OAAO,CAAC;AAC1B,OAAgC,qCAAqC,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/image_picker/types.ts"],"names":[],"mappings":"AAAA,OAAkB,OAAO,CAAC;AAC1B,OAA6C,qCAAqC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { TXhrImagePickerProps } from './types';
2
1
  import React from 'react';
3
- declare const XhrImagePicker: React.FC<TXhrImagePickerProps>;
2
+ import { IXhrImagePickerProps } from "./types";
3
+ declare const XhrImagePicker: React.FC<IXhrImagePickerProps>;
4
4
  export default XhrImagePicker;
@@ -4,19 +4,18 @@ import ImagePicker from '../image_picker/index.js';
4
4
  import { REQUEST_TYPES } from '../../../../star_core/build/esm/packages/star_core/src/features/http_requester/http_requester_contants.js';
5
5
  import { useHttpApi } from '../../hooks/use_http_api.js';
6
6
 
7
- const XhrImagePicker = ({ id, url, name, onUploaded, initialFile, 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, allowedExtensions = [FILES_EXTENSIONS.WEBP, FILES_EXTENSIONS.JPG, FILES_EXTENSIONS.PNG, FILES_EXTENSIONS.GIF, FILES_EXTENSIONS.SVG] }) => {
8
8
  const httpApi = useHttpApi();
9
9
  const onChange = async (fileList) => {
10
- console.warn('onChange', fileList[0]);
11
10
  const { response } = httpApi.fetch({
12
11
  url,
13
12
  method: REQUEST_TYPES.post,
14
13
  data: fileList[0]
15
14
  });
16
15
  const data = await response;
17
- onUploaded === null || onUploaded === void 0 ? void 0 : onUploaded(data);
16
+ onUploaded === null || onUploaded === void 0 ? void 0 : onUploaded(data, fileList[0]);
18
17
  };
19
- return (React.createElement(ImagePicker, { id: id, name: name, onChange: onChange, allowedExtensions: allowedExtensions, initialFile: initialFile }));
18
+ return (React.createElement(ImagePicker, { id: id, name: name, onChange: onChange, errors: errors, allowedExtensions: allowedExtensions, initialFile: initialFile }));
20
19
  };
21
20
 
22
21
  export default XhrImagePicker;
@@ -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;"}
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;"}
@@ -1,12 +1,7 @@
1
1
  import { IImagePicker } from "../image_picker/types";
2
2
  import { IRequestResponse } from '@dreamcommerce/star_core';
3
- export declare type TXhrImagePickerProps = {
4
- id: string;
3
+ export interface IXhrImagePickerProps extends IImagePicker {
5
4
  url: string;
6
- onUploaded?: (resp: IRequestResponse<any>) => void;
5
+ onUploaded?: (resp: IRequestResponse<any>, file: File) => void;
7
6
  onUploadError?: Function;
8
- } & Pick<IImagePicker, 'id' | 'name' | 'initialFile' | 'allowedExtensions'>;
9
- export interface TFetchXhrImageData {
10
- url: string;
11
- imageFile: File;
12
7
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dreamcommerce/aurora",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "2.6.0-3",
5
+ "version": "2.6.0-4",
6
6
  "description": "aurora",
7
7
  "author": "k0ssak",
8
8
  "license": "MIT",