@react-magma/dropzone 14.0.1 → 15.0.0-next.0

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.
@@ -1,101 +1,101 @@
1
- /**
2
- * HELPFUL NOTE!
3
- * SINCE THIS PACKAGE USES `FILE` WE MUST USE `Object.assign` IN LIEU OF SPREADING
4
- * `{...file}` WILL NOT COPY ALL OF THE FILE PROPERTIES
5
- */
6
- import React from 'react';
7
- import { DropzoneOptions } from 'react-dropzone';
8
- import { FormFieldContainerBaseProps } from 'react-magma-dom';
9
- import { FilePreview, FileError } from './FilePreview';
10
- export interface OnSendFileProps {
11
- file: FilePreview;
12
- onError?: ({}: {
13
- errors: FileError[];
14
- file: FilePreview;
15
- }) => void;
16
- onFinish?: ({}: {
17
- file: FilePreview;
18
- }) => void;
19
- onProgress?: ({}: {
20
- percent: number;
21
- file: FilePreview;
22
- }) => void;
23
- }
24
- export interface DropzoneProps extends Omit<FormFieldContainerBaseProps, 'fieldId' | 'errorMessage'> {
25
- /**
26
- * Set accepted file types. See https://github.com/okonet/attr-accept for more information. Keep in mind that mime type determination is not reliable across platforms. CSV files, for example, are reported as text/plain under macOS but as application/vnd.ms-excel under Windows. In some cases there might not be a mime type set at all. See: https://github.com/react-dropzone/react-dropzone/issues/276
27
- */
28
- accept?: string | string[];
29
- /**
30
- * Enable/Disable the input
31
- */
32
- disabled?: boolean;
33
- /**
34
- * Additional props to pass to the dropzone, see https://react-dropzone.js.org/#src
35
- */
36
- dropzoneOptions?: Partial<Omit<DropzoneOptions, 'onDrop'>>;
37
- /**
38
- * Content of the helper message.
39
- */
40
- helperMessage?: string;
41
- /**
42
- * @internal
43
- */
44
- id?: string;
45
- /**
46
- * Maximum accepted number of files The default value is 0 which means there is no limitation to how many files are accepted.
47
- * @default 0
48
- */
49
- maxFiles?: number;
50
- /**
51
- * Minimum accepted number of files.
52
- */
53
- minFiles?: number;
54
- /**
55
- * Maximum file size (in bytes)
56
- * @default Infinity
57
- */
58
- maxSize?: number;
59
- /**
60
- * Minimum file size (in bytes)
61
- * @default 0
62
- */
63
- minSize?: number;
64
- /**
65
- * Allow drag 'n' drop (or selection from the file dialog) of multiple files.
66
- * @default true
67
- */
68
- multiple?: boolean;
69
- /**
70
- * If true, disables drag 'n' drop
71
- * @default false
72
- */
73
- noDrag?: boolean;
74
- /**
75
- * Callback for when a file is deleted
76
- */
77
- onDeleteFile?: (file: FilePreview) => void;
78
- /**
79
- * Callback for when a file is deleted
80
- */
81
- onRemoveFile?: (file: FilePreview) => void;
82
- /**
83
- * Callback for when a file is added to the preview list via dropping or selecting. Will be ran on new files when `sendFiles` is true.
84
- */
85
- onSendFile?: (props: OnSendFileProps) => void;
86
- /**
87
- * Run `onSendFile` on any new files. Delay processing by setting to `false` until processing is desired.
88
- * @default false
89
- */
90
- sendFiles?: boolean;
91
- /**
92
- * @internal
93
- */
94
- testId?: string;
95
- /**
96
- * Show thumbnails for images in lieu of the file icon.
97
- * @default true
98
- */
99
- thumbnails?: boolean;
100
- }
101
- export declare const Dropzone: React.ForwardRefExoticComponent<DropzoneProps & React.RefAttributes<HTMLInputElement>>;
1
+ /**
2
+ * HELPFUL NOTE!
3
+ * SINCE THIS PACKAGE USES `FILE` WE MUST USE `Object.assign` IN LIEU OF SPREADING
4
+ * `{...file}` WILL NOT COPY ALL OF THE FILE PROPERTIES
5
+ */
6
+ import React from 'react';
7
+ import { DropzoneOptions } from 'react-dropzone';
8
+ import { FormFieldContainerBaseProps } from 'react-magma-dom';
9
+ import { FilePreview, FileError } from './FilePreview';
10
+ export interface OnSendFileProps {
11
+ file: FilePreview;
12
+ onError?: ({}: {
13
+ errors: FileError[];
14
+ file: FilePreview;
15
+ }) => void;
16
+ onFinish?: ({}: {
17
+ file: FilePreview;
18
+ }) => void;
19
+ onProgress?: ({}: {
20
+ percent: number;
21
+ file: FilePreview;
22
+ }) => void;
23
+ }
24
+ export interface DropzoneProps extends Omit<FormFieldContainerBaseProps, 'fieldId' | 'errorMessage'> {
25
+ /**
26
+ * Set accepted file types. See https://github.com/okonet/attr-accept for more information. Keep in mind that mime type determination is not reliable across platforms. CSV files, for example, are reported as text/plain under macOS but as application/vnd.ms-excel under Windows. In some cases there might not be a mime type set at all. See: https://github.com/react-dropzone/react-dropzone/issues/276
27
+ */
28
+ accept?: string | string[];
29
+ /**
30
+ * Enable/Disable the input
31
+ */
32
+ disabled?: boolean;
33
+ /**
34
+ * Additional props to pass to the dropzone, see https://react-dropzone.js.org/#src
35
+ */
36
+ dropzoneOptions?: Partial<Omit<DropzoneOptions, 'onDrop'>>;
37
+ /**
38
+ * Content of the helper message.
39
+ */
40
+ helperMessage?: string;
41
+ /**
42
+ * @internal
43
+ */
44
+ id?: string;
45
+ /**
46
+ * Maximum accepted number of files The default value is 0 which means there is no limitation to how many files are accepted.
47
+ * @default 0
48
+ */
49
+ maxFiles?: number;
50
+ /**
51
+ * Minimum accepted number of files.
52
+ */
53
+ minFiles?: number;
54
+ /**
55
+ * Maximum file size (in bytes)
56
+ * @default Infinity
57
+ */
58
+ maxSize?: number;
59
+ /**
60
+ * Minimum file size (in bytes)
61
+ * @default 0
62
+ */
63
+ minSize?: number;
64
+ /**
65
+ * Allow drag 'n' drop (or selection from the file dialog) of multiple files.
66
+ * @default true
67
+ */
68
+ multiple?: boolean;
69
+ /**
70
+ * If true, disables drag 'n' drop
71
+ * @default false
72
+ */
73
+ noDrag?: boolean;
74
+ /**
75
+ * Callback for when a file is deleted
76
+ */
77
+ onDeleteFile?: (file: FilePreview) => void;
78
+ /**
79
+ * Callback for when a file is deleted
80
+ */
81
+ onRemoveFile?: (file: FilePreview) => void;
82
+ /**
83
+ * Callback for when a file is added to the preview list via dropping or selecting. Will be ran on new files when `sendFiles` is true.
84
+ */
85
+ onSendFile?: (props: OnSendFileProps) => void;
86
+ /**
87
+ * Run `onSendFile` on any new files. Delay processing by setting to `false` until processing is desired.
88
+ * @default false
89
+ */
90
+ sendFiles?: boolean;
91
+ /**
92
+ * @internal
93
+ */
94
+ testId?: string;
95
+ /**
96
+ * Show thumbnails for images in lieu of the file icon.
97
+ * @default true
98
+ */
99
+ thumbnails?: boolean;
100
+ }
101
+ export declare const Dropzone: React.ForwardRefExoticComponent<DropzoneProps & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { DropzoneProps } from './Dropzone';
3
+ declare const _default: {
4
+ component: React.ForwardRefExoticComponent<DropzoneProps & React.RefAttributes<HTMLInputElement>>;
5
+ title: string;
6
+ argTypes: {
7
+ noDrag: {
8
+ control: {
9
+ type: string;
10
+ };
11
+ defaultValue: boolean;
12
+ };
13
+ isInverse: {
14
+ control: {
15
+ type: string;
16
+ };
17
+ defaultValue: boolean;
18
+ };
19
+ sendFiles: {
20
+ control: {
21
+ type: string;
22
+ };
23
+ defaultValue: boolean;
24
+ };
25
+ thumbnails: {
26
+ control: {
27
+ type: string;
28
+ };
29
+ defaultValue: boolean;
30
+ };
31
+ };
32
+ };
33
+ export default _default;
34
+ export declare const Default: {
35
+ render: (args: DropzoneProps) => JSX.Element;
36
+ };
37
+ export declare const NoLimits: {
38
+ render: (args: DropzoneProps) => JSX.Element;
39
+ };
40
+ export declare const Image: {
41
+ render: (args: DropzoneProps) => JSX.Element;
42
+ };
43
+ export declare const Text: {
44
+ render: (args: DropzoneProps) => JSX.Element;
45
+ };
46
+ export declare const Csv: {
47
+ render: (args: DropzoneProps) => JSX.Element;
48
+ };
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,7 +1,8 @@
1
- import { IconProps } from 'react-magma-icons';
2
- import { FilePreview } from './FilePreview';
3
- export interface FileIconProps extends IconProps {
4
- file: FilePreview;
5
- isInverse?: boolean;
6
- }
7
- export declare const FileIcon: ({ file, isInverse }: FileIconProps) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import { IconProps } from 'react-magma-icons';
3
+ import { FilePreview } from './FilePreview';
4
+ export interface FileIconProps extends IconProps {
5
+ file: FilePreview;
6
+ isInverse?: boolean;
7
+ }
8
+ export declare const FileIcon: ({ file, isInverse }: FileIconProps) => JSX.Element;
@@ -1,15 +1,15 @@
1
- import { FileWithPath } from 'react-dropzone';
2
- export interface FileError {
3
- header?: string;
4
- message: string;
5
- code: 'file-too-large' | 'file-too-small' | 'too-many-files' | 'file-invalid-type' | string;
6
- }
7
- export interface FilePreview extends FileWithPath {
8
- preview?: string;
9
- errors?: FileError[];
10
- processor?: {
11
- percent?: string;
12
- status?: string;
13
- error?: string;
14
- };
15
- }
1
+ import { FileWithPath } from 'react-dropzone';
2
+ export interface FileError {
3
+ header?: string;
4
+ message: string;
5
+ code: 'file-too-large' | 'file-too-small' | 'too-many-files' | 'file-invalid-type' | string;
6
+ }
7
+ export interface FilePreview extends FileWithPath {
8
+ preview?: string;
9
+ errors?: FileError[];
10
+ processor?: {
11
+ percent?: string;
12
+ status?: string;
13
+ error?: string;
14
+ };
15
+ }
@@ -1,18 +1,18 @@
1
- import React from 'react';
2
- import { FlexProps } from 'react-magma-dom';
3
- import { FilePreview } from './FilePreview';
4
- export interface PreviewProps extends Omit<FlexProps, 'behavior'> {
5
- accept?: string | string[];
6
- file: FilePreview;
7
- isInverse?: boolean;
8
- maxSize?: number;
9
- minSize?: number;
10
- onDeleteFile?: (file: FilePreview) => void;
11
- onRemoveFile?: (file: FilePreview) => void;
12
- /**
13
- * @internal
14
- */
15
- testId?: string;
16
- thumbnails: boolean;
17
- }
18
- export declare const Preview: React.ForwardRefExoticComponent<Omit<PreviewProps, "children"> & React.RefAttributes<HTMLDivElement>>;
1
+ import React from 'react';
2
+ import { FlexProps } from 'react-magma-dom';
3
+ import { FilePreview } from './FilePreview';
4
+ export interface PreviewProps extends Omit<FlexProps, 'behavior'> {
5
+ accept?: string | string[];
6
+ file: FilePreview;
7
+ isInverse?: boolean;
8
+ maxSize?: number;
9
+ minSize?: number;
10
+ onDeleteFile?: (file: FilePreview) => void;
11
+ onRemoveFile?: (file: FilePreview) => void;
12
+ /**
13
+ * @internal
14
+ */
15
+ testId?: string;
16
+ thumbnails: boolean;
17
+ }
18
+ export declare const Preview: React.ForwardRefExoticComponent<PreviewProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,4 +1,4 @@
1
- export * from './FileIcon';
2
- export * from './FilePreview';
3
- export * from './Dropzone';
4
- export * from './FilePreview';
1
+ export * from './FileIcon';
2
+ export * from './FilePreview';
3
+ export * from './Dropzone';
4
+ export * from './FilePreview';
@@ -1 +1 @@
1
- export declare const formatFileSize: (bytes: number | undefined, decimalPoint?: number, bytesLabel?: string) => string;
1
+ export declare const formatFileSize: (bytes: number | undefined, decimalPoint?: number, bytesLabel?: string) => string | undefined;
@@ -1 +1 @@
1
- export * from './components/dropzone';
1
+ export * from './components/dropzone';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-magma/dropzone",
3
- "version": "14.0.1",
3
+ "version": "15.0.0-next.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,30 +20,27 @@
20
20
  "build": "microbundle build --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx",
21
21
  "build-watch": "microbundle watch --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx",
22
22
  "lint": "eslint ./src",
23
- "lint:fix": "eslint ./src --fix",
24
- "lint:check": "eslint ./src --max-warnings=0",
25
23
  "test": "jest",
26
- "test-watch": "jest --watch",
27
- "compiler-checks": "tsc --noEmit --project ./tsconfig.json"
24
+ "test-watch": "jest --watch"
28
25
  },
29
26
  "dependencies": {
30
- "polished": "3.7.2",
27
+ "polished": "^3.7.2",
31
28
  "react-dropzone": "11.3.2"
32
29
  },
33
30
  "devDependencies": {
34
- "@emotion/react": "11.14.0",
35
- "@emotion/styled": "11.14.0",
36
- "react": "18.3.1",
37
- "react-dom": "18.3.1",
38
- "react-magma-dom": "^5.2.0",
31
+ "@emotion/react": "^11.13.0",
32
+ "@emotion/styled": "^11.13.0",
33
+ "react": "^17.0.2",
34
+ "react-dom": "^17.0.2",
35
+ "react-magma-dom": "^6.0.0-next.0",
39
36
  "react-magma-icons": "^3.2.5"
40
37
  },
41
38
  "peerDependencies": {
42
- "@emotion/react": "11.14.0",
43
- "@emotion/styled": "11.14.0",
44
- "react": "18.3.1",
45
- "react-dom": "18.3.1",
46
- "react-magma-dom": "^5.0.0",
39
+ "@emotion/react": "^11.13.0",
40
+ "@emotion/styled": "^11.13.0",
41
+ "react": "^17.0.2",
42
+ "react-dom": "^17.0.2",
43
+ "react-magma-dom": "^6.0.0",
47
44
  "react-magma-icons": "^3.2.5"
48
45
  },
49
46
  "engines": {
@@ -138,7 +138,6 @@ export const Image = {
138
138
  const onSendFile = (props: OnSendFileProps) => {
139
139
  const { file, onFinish } = props;
140
140
  const reader = new FileReader();
141
-
142
141
  reader.onload = function (evt) {
143
142
  setFile(
144
143
  (evt &&
@@ -184,7 +183,6 @@ export const Text = {
184
183
  const onSendFile = (props: OnSendFileProps) => {
185
184
  const { file, onFinish } = props;
186
185
  const reader = new FileReader();
187
-
188
186
  reader.onload = function (evt) {
189
187
  setFile(
190
188
  (evt &&
@@ -231,7 +229,6 @@ export const Csv = {
231
229
  const onSendFile = (props: OnSendFileProps) => {
232
230
  const { file, onFinish } = props;
233
231
  const reader = new FileReader();
234
-
235
232
  reader.onload = function (evt) {
236
233
  const [columns, rows] =
237
234
  (evt &&
@@ -239,7 +236,6 @@ export const Csv = {
239
236
  evt.target.result &&
240
237
  csvJSON(evt.target.result.toString())) ||
241
238
  [];
242
-
243
239
  setColumns(columns);
244
240
  setFile(rows);
245
241
  onFinish && onFinish({ file });