@entur/fileupload 0.3.50-RC.1 → 0.3.50-RC.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/CHANGELOG.md +4 -0
- package/dist/FileUpload.d.ts +1 -1
- package/dist/fileupload.cjs.development.js +29 -38
- package/dist/fileupload.cjs.development.js.map +1 -1
- package/dist/fileupload.cjs.production.min.js +1 -1
- package/dist/fileupload.cjs.production.min.js.map +1 -1
- package/dist/fileupload.esm.js +29 -38
- package/dist/fileupload.esm.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.3.50-RC.2](https://bitbucket.org/enturas/design-system/compare/@entur/fileupload@0.3.50-RC.1...@entur/fileupload@0.3.50-RC.2) (2022-11-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @entur/fileupload
|
|
9
|
+
|
|
6
10
|
## [0.3.50-RC.1](https://bitbucket.org/enturas/design-system/compare/@entur/fileupload@0.3.50-RC.0...@entur/fileupload@0.3.50-RC.1) (2022-11-21)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @entur/fileupload
|
package/dist/FileUpload.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DropzoneOptions, FileRejection, DropEvent, FileWithPath } from 'react-dropzone';
|
|
3
3
|
import './FileUpload.scss';
|
|
4
|
-
|
|
4
|
+
type FileUploadProps = DropzoneOptions & {
|
|
5
5
|
/** Tekst som vises ved fullført opplasting
|
|
6
6
|
* @default "Opplasting fullført"
|
|
7
7
|
*/
|
|
@@ -17,72 +17,64 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
17
17
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
18
18
|
|
|
19
19
|
function _extends() {
|
|
20
|
-
_extends = Object.assign
|
|
20
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
21
21
|
for (var i = 1; i < arguments.length; i++) {
|
|
22
22
|
var source = arguments[i];
|
|
23
|
-
|
|
24
23
|
for (var key in source) {
|
|
25
24
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
26
25
|
target[key] = source[key];
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
return target;
|
|
32
30
|
};
|
|
33
|
-
|
|
34
31
|
return _extends.apply(this, arguments);
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
38
34
|
if (source == null) return {};
|
|
39
35
|
var target = {};
|
|
40
36
|
var sourceKeys = Object.keys(source);
|
|
41
37
|
var key, i;
|
|
42
|
-
|
|
43
38
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
44
39
|
key = sourceKeys[i];
|
|
45
40
|
if (excluded.indexOf(key) >= 0) continue;
|
|
46
41
|
target[key] = source[key];
|
|
47
42
|
}
|
|
48
|
-
|
|
49
43
|
return target;
|
|
50
44
|
}
|
|
51
45
|
|
|
52
46
|
var _excluded = ["standbyText", "errorText", "successText", "errorUpload", "onDrop", "onDelete", "accept", "files", "label", "removeFileButtonDescription", "style"];
|
|
53
47
|
var FileUpload = function FileUpload(_ref) {
|
|
54
48
|
var _ref$standbyText = _ref.standbyText,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
49
|
+
standbyText = _ref$standbyText === void 0 ? 'Dra fil eller klikk for å laste opp' : _ref$standbyText,
|
|
50
|
+
_ref$errorText = _ref.errorText,
|
|
51
|
+
errorText = _ref$errorText === void 0 ? 'Feil ved opplasting av fil' : _ref$errorText,
|
|
52
|
+
_ref$successText = _ref.successText,
|
|
53
|
+
successText = _ref$successText === void 0 ? 'Opplasting fullført' : _ref$successText,
|
|
54
|
+
_ref$errorUpload = _ref.errorUpload,
|
|
55
|
+
errorUpload = _ref$errorUpload === void 0 ? false : _ref$errorUpload,
|
|
56
|
+
onDrop = _ref.onDrop,
|
|
57
|
+
_ref$onDelete = _ref.onDelete,
|
|
58
|
+
onDelete = _ref$onDelete === void 0 ? function (file) {
|
|
59
|
+
return console.log(file);
|
|
60
|
+
} : _ref$onDelete,
|
|
61
|
+
_ref$accept = _ref.accept,
|
|
62
|
+
accept = _ref$accept === void 0 ? '' : _ref$accept,
|
|
63
|
+
_ref$files = _ref.files,
|
|
64
|
+
files = _ref$files === void 0 ? [] : _ref$files,
|
|
65
|
+
label = _ref.label,
|
|
66
|
+
_ref$removeFileButton = _ref.removeFileButtonDescription,
|
|
67
|
+
removeFileButtonDescription = _ref$removeFileButton === void 0 ? 'Fjern fil' : _ref$removeFileButton,
|
|
68
|
+
style = _ref.style,
|
|
69
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
77
70
|
var _useDropzone = reactDropzone.useDropzone(_extends({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
onDrop: onDrop,
|
|
72
|
+
accept: accept
|
|
73
|
+
}, rest)),
|
|
74
|
+
getRootProps = _useDropzone.getRootProps,
|
|
75
|
+
getInputProps = _useDropzone.getInputProps,
|
|
76
|
+
isDragActive = _useDropzone.isDragActive,
|
|
77
|
+
isDragReject = _useDropzone.isDragReject;
|
|
86
78
|
var success = files.length > 0;
|
|
87
79
|
return React__default["default"].createElement("div", _extends({
|
|
88
80
|
className: "eds-file-upload__wrapper"
|
|
@@ -119,7 +111,6 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
119
111
|
}, React__default["default"].createElement(a11y.VisuallyHidden, null, removeFileButtonDescription, ", ", file.name), React__default["default"].createElement(icons.DeleteIcon, null)));
|
|
120
112
|
})));
|
|
121
113
|
};
|
|
122
|
-
|
|
123
114
|
function convertSizeToHuman(size) {
|
|
124
115
|
if (size < 1000) {
|
|
125
116
|
return size + 'bytes;';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileupload.cjs.development.js","sources":["../src/FileUpload.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport {\n useDropzone,\n DropzoneOptions,\n FileRejection,\n DropEvent,\n FileWithPath,\n} from 'react-dropzone';\nimport classNames from 'classnames';\n\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport { VisuallyHidden } from '@entur/a11y';\n\nimport './FileUpload.scss';\n\ntype FileUploadProps = DropzoneOptions & {\n /** Tekst som vises ved fullført opplasting\n * @default \"Opplasting fullført\"\n */\n successText?: string;\n /** Tekst som vises om opplasting feilet\n * @default \"Feil ved opplasting av fil\"\n */\n errorText?: string;\n /** Tekst som vises før man laster opp noe\n * @default \"Dra fil eller klikk for å laste opp\"\n */\n standbyText?: string;\n /** Boolean for hvis opplastingen feiler.\n * @default false\n */\n errorUpload?: boolean;\n /** Callback for når en fil legges til */\n onDrop?<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ): void;\n /** Callback for når en fil slettes fra lista */\n onDelete: (file: FileWithPath) => void;\n /** Hvilken filtyper som skal aksepteres */\n accept?: string | string[];\n /** Filene som er aktive i komponenten */\n files: File[];\n /** Beskrivende tekst som forklarer feltet */\n label?: string;\n /** Mulighet for å laste opp flere filer */\n multiple?: boolean;\n /**Minste filstørrelse */\n minSize?: number;\n /**Største filstørrelse */\n maxSize?: number;\n /**Tekst som leses opp av skjermleser på søppelbøtte-ikonet\n * @default \"Fjern fil\"\n */\n removeFileButtonDescription?: string;\n [key: string]: any;\n};\n\nexport const FileUpload: React.FC<FileUploadProps> = ({\n standbyText = 'Dra fil eller klikk for å laste opp',\n errorText = 'Feil ved opplasting av fil',\n successText = 'Opplasting fullført',\n errorUpload = false,\n onDrop,\n onDelete = file => console.log(file),\n accept = '',\n files = [],\n label,\n removeFileButtonDescription = 'Fjern fil',\n style,\n ...rest\n}) => {\n const { getRootProps, getInputProps, isDragActive, isDragReject } =\n useDropzone({\n onDrop,\n accept: accept,\n ...rest,\n });\n\n const success = files.length > 0;\n\n return (\n <div className=\"eds-file-upload__wrapper\" {...style}>\n <div className=\"eds-file-upload__input\" {...getRootProps()}>\n {label && <Label style={{ display: 'flex' }}>{label}</Label>}\n <input {...getInputProps()} />\n <span\n className={classNames(\n 'eds-file-upload__dropzone',\n {\n 'eds-file-upload__dropzone--success': success,\n },\n { 'eds-file-upload__dropzone--active': isDragActive },\n { 'eds-file-upload__dropzone--reject': isDragReject },\n { 'eds-file-upload__dropzone--error': errorUpload },\n )}\n >\n {success ? successText : errorUpload ? errorText : standbyText}\n </span>\n </div>\n <div className=\"eds-file-upload__file-list\">\n {files.map((file: FileWithPath, index) => (\n <div className=\"eds-file-upload__file-name\" key={index}>\n <FileIcon className=\"eds-file-upload__file-name-icon\" />\n <span className=\"eds-field-upload__file-name-path\">\n {file.path} - {convertSizeToHuman(file.size)}{' '}\n </span>\n <IconButton onClick={() => onDelete(file)}>\n <VisuallyHidden>\n {removeFileButtonDescription}, {file.name}\n </VisuallyHidden>\n <DeleteIcon />\n </IconButton>\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nfunction convertSizeToHuman(size: number) {\n if (size < 1000) {\n return size + 'bytes;';\n } else if (size < 1000000) {\n return `${size / 1000} KB`;\n } else {\n return `${(size / 1000000).toPrecision(4)} MB`;\n }\n}\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('fileupload');\n\nexport * from './FileUpload';\n"],"names":["FileUpload","standbyText","errorText","successText","errorUpload","onDrop","onDelete","file","console","log","accept","files","label","removeFileButtonDescription","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","convertSizeToHuman","size","IconButton","onClick","VisuallyHidden","name","DeleteIcon","toPrecision","warnAboutMissingStyles"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fileupload.cjs.development.js","sources":["../src/FileUpload.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport {\n useDropzone,\n DropzoneOptions,\n FileRejection,\n DropEvent,\n FileWithPath,\n} from 'react-dropzone';\nimport classNames from 'classnames';\n\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport { VisuallyHidden } from '@entur/a11y';\n\nimport './FileUpload.scss';\n\ntype FileUploadProps = DropzoneOptions & {\n /** Tekst som vises ved fullført opplasting\n * @default \"Opplasting fullført\"\n */\n successText?: string;\n /** Tekst som vises om opplasting feilet\n * @default \"Feil ved opplasting av fil\"\n */\n errorText?: string;\n /** Tekst som vises før man laster opp noe\n * @default \"Dra fil eller klikk for å laste opp\"\n */\n standbyText?: string;\n /** Boolean for hvis opplastingen feiler.\n * @default false\n */\n errorUpload?: boolean;\n /** Callback for når en fil legges til */\n onDrop?<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ): void;\n /** Callback for når en fil slettes fra lista */\n onDelete: (file: FileWithPath) => void;\n /** Hvilken filtyper som skal aksepteres */\n accept?: string | string[];\n /** Filene som er aktive i komponenten */\n files: File[];\n /** Beskrivende tekst som forklarer feltet */\n label?: string;\n /** Mulighet for å laste opp flere filer */\n multiple?: boolean;\n /**Minste filstørrelse */\n minSize?: number;\n /**Største filstørrelse */\n maxSize?: number;\n /**Tekst som leses opp av skjermleser på søppelbøtte-ikonet\n * @default \"Fjern fil\"\n */\n removeFileButtonDescription?: string;\n [key: string]: any;\n};\n\nexport const FileUpload: React.FC<FileUploadProps> = ({\n standbyText = 'Dra fil eller klikk for å laste opp',\n errorText = 'Feil ved opplasting av fil',\n successText = 'Opplasting fullført',\n errorUpload = false,\n onDrop,\n onDelete = file => console.log(file),\n accept = '',\n files = [],\n label,\n removeFileButtonDescription = 'Fjern fil',\n style,\n ...rest\n}) => {\n const { getRootProps, getInputProps, isDragActive, isDragReject } =\n useDropzone({\n onDrop,\n accept: accept,\n ...rest,\n });\n\n const success = files.length > 0;\n\n return (\n <div className=\"eds-file-upload__wrapper\" {...style}>\n <div className=\"eds-file-upload__input\" {...getRootProps()}>\n {label && <Label style={{ display: 'flex' }}>{label}</Label>}\n <input {...getInputProps()} />\n <span\n className={classNames(\n 'eds-file-upload__dropzone',\n {\n 'eds-file-upload__dropzone--success': success,\n },\n { 'eds-file-upload__dropzone--active': isDragActive },\n { 'eds-file-upload__dropzone--reject': isDragReject },\n { 'eds-file-upload__dropzone--error': errorUpload },\n )}\n >\n {success ? successText : errorUpload ? errorText : standbyText}\n </span>\n </div>\n <div className=\"eds-file-upload__file-list\">\n {files.map((file: FileWithPath, index) => (\n <div className=\"eds-file-upload__file-name\" key={index}>\n <FileIcon className=\"eds-file-upload__file-name-icon\" />\n <span className=\"eds-field-upload__file-name-path\">\n {file.path} - {convertSizeToHuman(file.size)}{' '}\n </span>\n <IconButton onClick={() => onDelete(file)}>\n <VisuallyHidden>\n {removeFileButtonDescription}, {file.name}\n </VisuallyHidden>\n <DeleteIcon />\n </IconButton>\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nfunction convertSizeToHuman(size: number) {\n if (size < 1000) {\n return size + 'bytes;';\n } else if (size < 1000000) {\n return `${size / 1000} KB`;\n } else {\n return `${(size / 1000000).toPrecision(4)} MB`;\n }\n}\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('fileupload');\n\nexport * from './FileUpload';\n"],"names":["FileUpload","standbyText","errorText","successText","errorUpload","onDrop","onDelete","file","console","log","accept","files","label","removeFileButtonDescription","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","createElement","className","Label","display","classNames","map","index","key","FileIcon","path","convertSizeToHuman","size","IconButton","onClick","VisuallyHidden","name","DeleteIcon","toPrecision","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DaA,IAAAA,UAAU,GAA8B,SAAxCA,UAAU,CAalB,IAAA,EAAA;AAAA,EAAA,IAAA,gBAAA,GAAA,IAAA,CAZHC,WAAW;AAAXA,IAAAA,WAAW,iCAAG,qCAAqC,GAAA,gBAAA;AAAA,IAAA,cAAA,GAAA,IAAA,CACnDC,SAAS;AAATA,IAAAA,SAAS,+BAAG,4BAA4B,GAAA,cAAA;AAAA,IAAA,gBAAA,GAAA,IAAA,CACxCC,WAAW;AAAXA,IAAAA,WAAW,iCAAG,qBAAqB,GAAA,gBAAA;AAAA,IAAA,gBAAA,GAAA,IAAA,CACnCC,WAAW;AAAXA,IAAAA,WAAW,iCAAG,KAAK,GAAA,gBAAA;AACnBC,IAAAA,MAAM,QAANA,MAAM;AAAA,IAAA,aAAA,GAAA,IAAA,CACNC,QAAQ;IAARA,QAAQ,GAAA,aAAA,KAAA,KAAA,CAAA,GAAG,UAAAC,IAAI,EAAA;AAAA,MAAA,OAAIC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAA;AAAA,KAAA,GAAA,aAAA;AAAA,IAAA,WAAA,GAAA,IAAA,CACpCG,MAAM;AAANA,IAAAA,MAAM,4BAAG,EAAE,GAAA,WAAA;AAAA,IAAA,UAAA,GAAA,IAAA,CACXC,KAAK;AAALA,IAAAA,KAAK,2BAAG,EAAE,GAAA,UAAA;AACVC,IAAAA,KAAK,QAALA,KAAK;AAAA,IAAA,qBAAA,GAAA,IAAA,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AA;AACvB,GAAA,MAAM,IAAIA,IAAI,GAAG,OAAO,EAAE;IACzB,OAAUA,IAAI,GAAG,IAAI,GAAA,MAAA,CAAA;AACtB,GAAA,MAAM;IACL,OAAU,CAACA,IAAI,GAAG,OAAO,EAAEM,WAAW,CAAC,CAAC,CAAC,GAAA,KAAA,CAAA;AAC1C,GAAA;AACH;;AChIAC,4BAAsB,CAAC,YAAY,CAAC;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),l=require("react-dropzone"),r=require("classnames"),a=require("@entur/icons"),n=require("@entur/button"),o=require("@entur/typography"),i=require("@entur/a11y");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(t),d=s(r);function c(){return c=Object.assign
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),l=require("react-dropzone"),r=require("classnames"),a=require("@entur/icons"),n=require("@entur/button"),o=require("@entur/typography"),i=require("@entur/a11y");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(t),d=s(r);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var r in l)Object.prototype.hasOwnProperty.call(l,r)&&(e[r]=l[r])}return e},c.apply(this,arguments)}var p=["standbyText","errorText","successText","errorUpload","onDrop","onDelete","accept","files","label","removeFileButtonDescription","style"];e.warnAboutMissingStyles("fileupload"),exports.FileUpload=function(e){var t=e.standbyText,r=void 0===t?"Dra fil eller klikk for å laste opp":t,s=e.errorText,f=void 0===s?"Feil ved opplasting av fil":s,v=e.successText,m=void 0===v?"Opplasting fullført":v,_=e.errorUpload,y=void 0!==_&&_,b=e.onDrop,g=e.onDelete,D=void 0===g?function(e){return console.log(e)}:g,E=e.accept,x=void 0===E?"":E,j=e.files,h=void 0===j?[]:j,q=e.label,z=e.removeFileButtonDescription,O=void 0===z?"Fjern fil":z,N=e.style,k=function(e,t){if(null==e)return{};var l,r,a={},n=Object.keys(e);for(r=0;r<n.length;r++)t.indexOf(l=n[r])>=0||(a[l]=e[l]);return a}(e,p),F=l.useDropzone(c({onDrop:b,accept:x},k)),T=F.getRootProps,B=F.getInputProps,P=F.isDragActive,I=F.isDragReject,w=h.length>0;return u.default.createElement("div",c({className:"eds-file-upload__wrapper"},N),u.default.createElement("div",c({className:"eds-file-upload__input"},T()),q&&u.default.createElement(o.Label,{style:{display:"flex"}},q),u.default.createElement("input",c({},B())),u.default.createElement("span",{className:d.default("eds-file-upload__dropzone",{"eds-file-upload__dropzone--success":w},{"eds-file-upload__dropzone--active":P},{"eds-file-upload__dropzone--reject":I},{"eds-file-upload__dropzone--error":y})},w?m:y?f:r)),u.default.createElement("div",{className:"eds-file-upload__file-list"},h.map((function(e,t){return u.default.createElement("div",{className:"eds-file-upload__file-name",key:t},u.default.createElement(a.FileIcon,{className:"eds-file-upload__file-name-icon"}),u.default.createElement("span",{className:"eds-field-upload__file-name-path"},e.path," - ",(l=e.size)<1e3?l+"bytes;":l<1e6?l/1e3+" KB":(l/1e6).toPrecision(4)+" MB"," "),u.default.createElement(n.IconButton,{onClick:function(){return D(e)}},u.default.createElement(i.VisuallyHidden,null,O,", ",e.name),u.default.createElement(a.DeleteIcon,null)));var l}))))};
|
|
2
2
|
//# sourceMappingURL=fileupload.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileupload.cjs.production.min.js","sources":["../src/index.tsx","../src/FileUpload.tsx"],"sourcesContent":["import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('fileupload');\n\nexport * from './FileUpload';\n","import React from 'react';\nimport {\n useDropzone,\n DropzoneOptions,\n FileRejection,\n DropEvent,\n FileWithPath,\n} from 'react-dropzone';\nimport classNames from 'classnames';\n\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport { VisuallyHidden } from '@entur/a11y';\n\nimport './FileUpload.scss';\n\ntype FileUploadProps = DropzoneOptions & {\n /** Tekst som vises ved fullført opplasting\n * @default \"Opplasting fullført\"\n */\n successText?: string;\n /** Tekst som vises om opplasting feilet\n * @default \"Feil ved opplasting av fil\"\n */\n errorText?: string;\n /** Tekst som vises før man laster opp noe\n * @default \"Dra fil eller klikk for å laste opp\"\n */\n standbyText?: string;\n /** Boolean for hvis opplastingen feiler.\n * @default false\n */\n errorUpload?: boolean;\n /** Callback for når en fil legges til */\n onDrop?<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ): void;\n /** Callback for når en fil slettes fra lista */\n onDelete: (file: FileWithPath) => void;\n /** Hvilken filtyper som skal aksepteres */\n accept?: string | string[];\n /** Filene som er aktive i komponenten */\n files: File[];\n /** Beskrivende tekst som forklarer feltet */\n label?: string;\n /** Mulighet for å laste opp flere filer */\n multiple?: boolean;\n /**Minste filstørrelse */\n minSize?: number;\n /**Største filstørrelse */\n maxSize?: number;\n /**Tekst som leses opp av skjermleser på søppelbøtte-ikonet\n * @default \"Fjern fil\"\n */\n removeFileButtonDescription?: string;\n [key: string]: any;\n};\n\nexport const FileUpload: React.FC<FileUploadProps> = ({\n standbyText = 'Dra fil eller klikk for å laste opp',\n errorText = 'Feil ved opplasting av fil',\n successText = 'Opplasting fullført',\n errorUpload = false,\n onDrop,\n onDelete = file => console.log(file),\n accept = '',\n files = [],\n label,\n removeFileButtonDescription = 'Fjern fil',\n style,\n ...rest\n}) => {\n const { getRootProps, getInputProps, isDragActive, isDragReject } =\n useDropzone({\n onDrop,\n accept: accept,\n ...rest,\n });\n\n const success = files.length > 0;\n\n return (\n <div className=\"eds-file-upload__wrapper\" {...style}>\n <div className=\"eds-file-upload__input\" {...getRootProps()}>\n {label && <Label style={{ display: 'flex' }}>{label}</Label>}\n <input {...getInputProps()} />\n <span\n className={classNames(\n 'eds-file-upload__dropzone',\n {\n 'eds-file-upload__dropzone--success': success,\n },\n { 'eds-file-upload__dropzone--active': isDragActive },\n { 'eds-file-upload__dropzone--reject': isDragReject },\n { 'eds-file-upload__dropzone--error': errorUpload },\n )}\n >\n {success ? successText : errorUpload ? errorText : standbyText}\n </span>\n </div>\n <div className=\"eds-file-upload__file-list\">\n {files.map((file: FileWithPath, index) => (\n <div className=\"eds-file-upload__file-name\" key={index}>\n <FileIcon className=\"eds-file-upload__file-name-icon\" />\n <span className=\"eds-field-upload__file-name-path\">\n {file.path} - {convertSizeToHuman(file.size)}{' '}\n </span>\n <IconButton onClick={() => onDelete(file)}>\n <VisuallyHidden>\n {removeFileButtonDescription}, {file.name}\n </VisuallyHidden>\n <DeleteIcon />\n </IconButton>\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nfunction convertSizeToHuman(size: number) {\n if (size < 1000) {\n return size + 'bytes;';\n } else if (size < 1000000) {\n return `${size / 1000} KB`;\n } else {\n return `${(size / 1000000).toPrecision(4)} MB`;\n }\n}\n"],"names":["warnAboutMissingStyles","standbyText","errorText","successText","errorUpload","onDrop","onDelete","file","console","log","accept","files","label","removeFileButtonDescription","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","size","toPrecision","IconButton","onClick","VisuallyHidden","name","DeleteIcon"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fileupload.cjs.production.min.js","sources":["../src/index.tsx","../src/FileUpload.tsx"],"sourcesContent":["import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('fileupload');\n\nexport * from './FileUpload';\n","import React from 'react';\nimport {\n useDropzone,\n DropzoneOptions,\n FileRejection,\n DropEvent,\n FileWithPath,\n} from 'react-dropzone';\nimport classNames from 'classnames';\n\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport { VisuallyHidden } from '@entur/a11y';\n\nimport './FileUpload.scss';\n\ntype FileUploadProps = DropzoneOptions & {\n /** Tekst som vises ved fullført opplasting\n * @default \"Opplasting fullført\"\n */\n successText?: string;\n /** Tekst som vises om opplasting feilet\n * @default \"Feil ved opplasting av fil\"\n */\n errorText?: string;\n /** Tekst som vises før man laster opp noe\n * @default \"Dra fil eller klikk for å laste opp\"\n */\n standbyText?: string;\n /** Boolean for hvis opplastingen feiler.\n * @default false\n */\n errorUpload?: boolean;\n /** Callback for når en fil legges til */\n onDrop?<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ): void;\n /** Callback for når en fil slettes fra lista */\n onDelete: (file: FileWithPath) => void;\n /** Hvilken filtyper som skal aksepteres */\n accept?: string | string[];\n /** Filene som er aktive i komponenten */\n files: File[];\n /** Beskrivende tekst som forklarer feltet */\n label?: string;\n /** Mulighet for å laste opp flere filer */\n multiple?: boolean;\n /**Minste filstørrelse */\n minSize?: number;\n /**Største filstørrelse */\n maxSize?: number;\n /**Tekst som leses opp av skjermleser på søppelbøtte-ikonet\n * @default \"Fjern fil\"\n */\n removeFileButtonDescription?: string;\n [key: string]: any;\n};\n\nexport const FileUpload: React.FC<FileUploadProps> = ({\n standbyText = 'Dra fil eller klikk for å laste opp',\n errorText = 'Feil ved opplasting av fil',\n successText = 'Opplasting fullført',\n errorUpload = false,\n onDrop,\n onDelete = file => console.log(file),\n accept = '',\n files = [],\n label,\n removeFileButtonDescription = 'Fjern fil',\n style,\n ...rest\n}) => {\n const { getRootProps, getInputProps, isDragActive, isDragReject } =\n useDropzone({\n onDrop,\n accept: accept,\n ...rest,\n });\n\n const success = files.length > 0;\n\n return (\n <div className=\"eds-file-upload__wrapper\" {...style}>\n <div className=\"eds-file-upload__input\" {...getRootProps()}>\n {label && <Label style={{ display: 'flex' }}>{label}</Label>}\n <input {...getInputProps()} />\n <span\n className={classNames(\n 'eds-file-upload__dropzone',\n {\n 'eds-file-upload__dropzone--success': success,\n },\n { 'eds-file-upload__dropzone--active': isDragActive },\n { 'eds-file-upload__dropzone--reject': isDragReject },\n { 'eds-file-upload__dropzone--error': errorUpload },\n )}\n >\n {success ? successText : errorUpload ? errorText : standbyText}\n </span>\n </div>\n <div className=\"eds-file-upload__file-list\">\n {files.map((file: FileWithPath, index) => (\n <div className=\"eds-file-upload__file-name\" key={index}>\n <FileIcon className=\"eds-file-upload__file-name-icon\" />\n <span className=\"eds-field-upload__file-name-path\">\n {file.path} - {convertSizeToHuman(file.size)}{' '}\n </span>\n <IconButton onClick={() => onDelete(file)}>\n <VisuallyHidden>\n {removeFileButtonDescription}, {file.name}\n </VisuallyHidden>\n <DeleteIcon />\n </IconButton>\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nfunction convertSizeToHuman(size: number) {\n if (size < 1000) {\n return size + 'bytes;';\n } else if (size < 1000000) {\n return `${size / 1000} KB`;\n } else {\n return `${(size / 1000000).toPrecision(4)} MB`;\n }\n}\n"],"names":["warnAboutMissingStyles","_ref","_ref$standbyText","standbyText","_ref$errorText","errorText","_ref$successText","successText","_ref$errorUpload","errorUpload","onDrop","_ref$onDelete","onDelete","file","console","log","_ref$accept","accept","_ref$files","files","label","_ref$removeFileButton","removeFileButtonDescription","style","rest","_objectWithoutPropertiesLoose","_excluded","_useDropzone","useDropzone","_extends","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","createElement","className","Label","display","classNames","map","index","key","FileIcon","path","size","toPrecision","IconButton","onClick","VisuallyHidden","name","DeleteIcon"],"mappings":"quBAGAA,EAAsBA,uBAAC,iCC0D8B,SAahDC,GAAA,IAAAC,EAAAD,EAZHE,YAAAA,aAAc,sCAAqCD,EAAAE,EAAAH,EACnDI,UAAAA,aAAY,6BAA4BD,EAAAE,EAAAL,EACxCM,YAAAA,aAAc,sBAAqBD,EAAAE,EAAAP,EACnCQ,YAAAA,cAAmBD,EACnBE,IAAAA,OAAMC,EAAAV,EACNW,SAAAA,OAAQ,IAAAD,EAAG,SAAAE,GAAI,OAAIC,QA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,WAAA,OAAMtC,EAASC,EAAK,GACvCuB,EAAAA,QAAAC,cAACc,EAAAA,eAAc,KACZ7B,OAA+BT,EAAKuC,MAEvChB,EAAC,QAAAC,cAAAgB,EAAUA,mBASzB,IAA4BN,CANnB,KAIT"}
|
package/dist/fileupload.esm.js
CHANGED
|
@@ -8,72 +8,64 @@ import { Label } from '@entur/typography';
|
|
|
8
8
|
import { VisuallyHidden } from '@entur/a11y';
|
|
9
9
|
|
|
10
10
|
function _extends() {
|
|
11
|
-
_extends = Object.assign
|
|
11
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
12
12
|
for (var i = 1; i < arguments.length; i++) {
|
|
13
13
|
var source = arguments[i];
|
|
14
|
-
|
|
15
14
|
for (var key in source) {
|
|
16
15
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
17
16
|
target[key] = source[key];
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
return target;
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
return _extends.apply(this, arguments);
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
29
25
|
if (source == null) return {};
|
|
30
26
|
var target = {};
|
|
31
27
|
var sourceKeys = Object.keys(source);
|
|
32
28
|
var key, i;
|
|
33
|
-
|
|
34
29
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
35
30
|
key = sourceKeys[i];
|
|
36
31
|
if (excluded.indexOf(key) >= 0) continue;
|
|
37
32
|
target[key] = source[key];
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
return target;
|
|
41
35
|
}
|
|
42
36
|
|
|
43
37
|
var _excluded = ["standbyText", "errorText", "successText", "errorUpload", "onDrop", "onDelete", "accept", "files", "label", "removeFileButtonDescription", "style"];
|
|
44
38
|
var FileUpload = function FileUpload(_ref) {
|
|
45
39
|
var _ref$standbyText = _ref.standbyText,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
standbyText = _ref$standbyText === void 0 ? 'Dra fil eller klikk for å laste opp' : _ref$standbyText,
|
|
41
|
+
_ref$errorText = _ref.errorText,
|
|
42
|
+
errorText = _ref$errorText === void 0 ? 'Feil ved opplasting av fil' : _ref$errorText,
|
|
43
|
+
_ref$successText = _ref.successText,
|
|
44
|
+
successText = _ref$successText === void 0 ? 'Opplasting fullført' : _ref$successText,
|
|
45
|
+
_ref$errorUpload = _ref.errorUpload,
|
|
46
|
+
errorUpload = _ref$errorUpload === void 0 ? false : _ref$errorUpload,
|
|
47
|
+
onDrop = _ref.onDrop,
|
|
48
|
+
_ref$onDelete = _ref.onDelete,
|
|
49
|
+
onDelete = _ref$onDelete === void 0 ? function (file) {
|
|
50
|
+
return console.log(file);
|
|
51
|
+
} : _ref$onDelete,
|
|
52
|
+
_ref$accept = _ref.accept,
|
|
53
|
+
accept = _ref$accept === void 0 ? '' : _ref$accept,
|
|
54
|
+
_ref$files = _ref.files,
|
|
55
|
+
files = _ref$files === void 0 ? [] : _ref$files,
|
|
56
|
+
label = _ref.label,
|
|
57
|
+
_ref$removeFileButton = _ref.removeFileButtonDescription,
|
|
58
|
+
removeFileButtonDescription = _ref$removeFileButton === void 0 ? 'Fjern fil' : _ref$removeFileButton,
|
|
59
|
+
style = _ref.style,
|
|
60
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
68
61
|
var _useDropzone = useDropzone(_extends({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
onDrop: onDrop,
|
|
63
|
+
accept: accept
|
|
64
|
+
}, rest)),
|
|
65
|
+
getRootProps = _useDropzone.getRootProps,
|
|
66
|
+
getInputProps = _useDropzone.getInputProps,
|
|
67
|
+
isDragActive = _useDropzone.isDragActive,
|
|
68
|
+
isDragReject = _useDropzone.isDragReject;
|
|
77
69
|
var success = files.length > 0;
|
|
78
70
|
return React.createElement("div", _extends({
|
|
79
71
|
className: "eds-file-upload__wrapper"
|
|
@@ -110,7 +102,6 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
110
102
|
}, React.createElement(VisuallyHidden, null, removeFileButtonDescription, ", ", file.name), React.createElement(DeleteIcon, null)));
|
|
111
103
|
})));
|
|
112
104
|
};
|
|
113
|
-
|
|
114
105
|
function convertSizeToHuman(size) {
|
|
115
106
|
if (size < 1000) {
|
|
116
107
|
return size + 'bytes;';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileupload.esm.js","sources":["../src/FileUpload.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport {\n useDropzone,\n DropzoneOptions,\n FileRejection,\n DropEvent,\n FileWithPath,\n} from 'react-dropzone';\nimport classNames from 'classnames';\n\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport { VisuallyHidden } from '@entur/a11y';\n\nimport './FileUpload.scss';\n\ntype FileUploadProps = DropzoneOptions & {\n /** Tekst som vises ved fullført opplasting\n * @default \"Opplasting fullført\"\n */\n successText?: string;\n /** Tekst som vises om opplasting feilet\n * @default \"Feil ved opplasting av fil\"\n */\n errorText?: string;\n /** Tekst som vises før man laster opp noe\n * @default \"Dra fil eller klikk for å laste opp\"\n */\n standbyText?: string;\n /** Boolean for hvis opplastingen feiler.\n * @default false\n */\n errorUpload?: boolean;\n /** Callback for når en fil legges til */\n onDrop?<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ): void;\n /** Callback for når en fil slettes fra lista */\n onDelete: (file: FileWithPath) => void;\n /** Hvilken filtyper som skal aksepteres */\n accept?: string | string[];\n /** Filene som er aktive i komponenten */\n files: File[];\n /** Beskrivende tekst som forklarer feltet */\n label?: string;\n /** Mulighet for å laste opp flere filer */\n multiple?: boolean;\n /**Minste filstørrelse */\n minSize?: number;\n /**Største filstørrelse */\n maxSize?: number;\n /**Tekst som leses opp av skjermleser på søppelbøtte-ikonet\n * @default \"Fjern fil\"\n */\n removeFileButtonDescription?: string;\n [key: string]: any;\n};\n\nexport const FileUpload: React.FC<FileUploadProps> = ({\n standbyText = 'Dra fil eller klikk for å laste opp',\n errorText = 'Feil ved opplasting av fil',\n successText = 'Opplasting fullført',\n errorUpload = false,\n onDrop,\n onDelete = file => console.log(file),\n accept = '',\n files = [],\n label,\n removeFileButtonDescription = 'Fjern fil',\n style,\n ...rest\n}) => {\n const { getRootProps, getInputProps, isDragActive, isDragReject } =\n useDropzone({\n onDrop,\n accept: accept,\n ...rest,\n });\n\n const success = files.length > 0;\n\n return (\n <div className=\"eds-file-upload__wrapper\" {...style}>\n <div className=\"eds-file-upload__input\" {...getRootProps()}>\n {label && <Label style={{ display: 'flex' }}>{label}</Label>}\n <input {...getInputProps()} />\n <span\n className={classNames(\n 'eds-file-upload__dropzone',\n {\n 'eds-file-upload__dropzone--success': success,\n },\n { 'eds-file-upload__dropzone--active': isDragActive },\n { 'eds-file-upload__dropzone--reject': isDragReject },\n { 'eds-file-upload__dropzone--error': errorUpload },\n )}\n >\n {success ? successText : errorUpload ? errorText : standbyText}\n </span>\n </div>\n <div className=\"eds-file-upload__file-list\">\n {files.map((file: FileWithPath, index) => (\n <div className=\"eds-file-upload__file-name\" key={index}>\n <FileIcon className=\"eds-file-upload__file-name-icon\" />\n <span className=\"eds-field-upload__file-name-path\">\n {file.path} - {convertSizeToHuman(file.size)}{' '}\n </span>\n <IconButton onClick={() => onDelete(file)}>\n <VisuallyHidden>\n {removeFileButtonDescription}, {file.name}\n </VisuallyHidden>\n <DeleteIcon />\n </IconButton>\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nfunction convertSizeToHuman(size: number) {\n if (size < 1000) {\n return size + 'bytes;';\n } else if (size < 1000000) {\n return `${size / 1000} KB`;\n } else {\n return `${(size / 1000000).toPrecision(4)} MB`;\n }\n}\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('fileupload');\n\nexport * from './FileUpload';\n"],"names":["FileUpload","standbyText","errorText","successText","errorUpload","onDrop","onDelete","file","console","log","accept","files","label","removeFileButtonDescription","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","convertSizeToHuman","size","IconButton","onClick","VisuallyHidden","name","DeleteIcon","toPrecision","warnAboutMissingStyles"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fileupload.esm.js","sources":["../src/FileUpload.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport {\n useDropzone,\n DropzoneOptions,\n FileRejection,\n DropEvent,\n FileWithPath,\n} from 'react-dropzone';\nimport classNames from 'classnames';\n\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport { VisuallyHidden } from '@entur/a11y';\n\nimport './FileUpload.scss';\n\ntype FileUploadProps = DropzoneOptions & {\n /** Tekst som vises ved fullført opplasting\n * @default \"Opplasting fullført\"\n */\n successText?: string;\n /** Tekst som vises om opplasting feilet\n * @default \"Feil ved opplasting av fil\"\n */\n errorText?: string;\n /** Tekst som vises før man laster opp noe\n * @default \"Dra fil eller klikk for å laste opp\"\n */\n standbyText?: string;\n /** Boolean for hvis opplastingen feiler.\n * @default false\n */\n errorUpload?: boolean;\n /** Callback for når en fil legges til */\n onDrop?<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ): void;\n /** Callback for når en fil slettes fra lista */\n onDelete: (file: FileWithPath) => void;\n /** Hvilken filtyper som skal aksepteres */\n accept?: string | string[];\n /** Filene som er aktive i komponenten */\n files: File[];\n /** Beskrivende tekst som forklarer feltet */\n label?: string;\n /** Mulighet for å laste opp flere filer */\n multiple?: boolean;\n /**Minste filstørrelse */\n minSize?: number;\n /**Største filstørrelse */\n maxSize?: number;\n /**Tekst som leses opp av skjermleser på søppelbøtte-ikonet\n * @default \"Fjern fil\"\n */\n removeFileButtonDescription?: string;\n [key: string]: any;\n};\n\nexport const FileUpload: React.FC<FileUploadProps> = ({\n standbyText = 'Dra fil eller klikk for å laste opp',\n errorText = 'Feil ved opplasting av fil',\n successText = 'Opplasting fullført',\n errorUpload = false,\n onDrop,\n onDelete = file => console.log(file),\n accept = '',\n files = [],\n label,\n removeFileButtonDescription = 'Fjern fil',\n style,\n ...rest\n}) => {\n const { getRootProps, getInputProps, isDragActive, isDragReject } =\n useDropzone({\n onDrop,\n accept: accept,\n ...rest,\n });\n\n const success = files.length > 0;\n\n return (\n <div className=\"eds-file-upload__wrapper\" {...style}>\n <div className=\"eds-file-upload__input\" {...getRootProps()}>\n {label && <Label style={{ display: 'flex' }}>{label}</Label>}\n <input {...getInputProps()} />\n <span\n className={classNames(\n 'eds-file-upload__dropzone',\n {\n 'eds-file-upload__dropzone--success': success,\n },\n { 'eds-file-upload__dropzone--active': isDragActive },\n { 'eds-file-upload__dropzone--reject': isDragReject },\n { 'eds-file-upload__dropzone--error': errorUpload },\n )}\n >\n {success ? successText : errorUpload ? errorText : standbyText}\n </span>\n </div>\n <div className=\"eds-file-upload__file-list\">\n {files.map((file: FileWithPath, index) => (\n <div className=\"eds-file-upload__file-name\" key={index}>\n <FileIcon className=\"eds-file-upload__file-name-icon\" />\n <span className=\"eds-field-upload__file-name-path\">\n {file.path} - {convertSizeToHuman(file.size)}{' '}\n </span>\n <IconButton onClick={() => onDelete(file)}>\n <VisuallyHidden>\n {removeFileButtonDescription}, {file.name}\n </VisuallyHidden>\n <DeleteIcon />\n </IconButton>\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nfunction convertSizeToHuman(size: number) {\n if (size < 1000) {\n return size + 'bytes;';\n } else if (size < 1000000) {\n return `${size / 1000} KB`;\n } else {\n return `${(size / 1000000).toPrecision(4)} MB`;\n }\n}\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('fileupload');\n\nexport * from './FileUpload';\n"],"names":["FileUpload","standbyText","errorText","successText","errorUpload","onDrop","onDelete","file","console","log","accept","files","label","removeFileButtonDescription","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","createElement","className","Label","display","classNames","map","index","key","FileIcon","path","convertSizeToHuman","size","IconButton","onClick","VisuallyHidden","name","DeleteIcon","toPrecision","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DaA,IAAAA,UAAU,GAA8B,SAAxCA,UAAU,CAalB,IAAA,EAAA;AAAA,EAAA,IAAA,gBAAA,GAAA,IAAA,CAZHC,WAAW;AAAXA,IAAAA,WAAW,iCAAG,qCAAqC,GAAA,gBAAA;AAAA,IAAA,cAAA,GAAA,IAAA,CACnDC,SAAS;AAATA,IAAAA,SAAS,+BAAG,4BAA4B,GAAA,cAAA;AAAA,IAAA,gBAAA,GAAA,IAAA,CACxCC,WAAW;AAAXA,IAAAA,WAAW,iCAAG,qBAAqB,GAAA,gBAAA;AAAA,IAAA,gBAAA,GAAA,IAAA,CACnCC,WAAW;AAAXA,IAAAA,WAAW,iCAAG,KAAK,GAAA,gBAAA;AACnBC,IAAAA,MAAM,QAANA,MAAM;AAAA,IAAA,aAAA,GAAA,IAAA,CACNC,QAAQ;IAARA,QAAQ,GAAA,aAAA,KAAA,KAAA,CAAA,GAAG,UAAAC,IAAI,EAAA;AAAA,MAAA,OAAIC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAA;AAAA,KAAA,GAAA,aAAA;AAAA,IAAA,WAAA,GAAA,IAAA,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A,CAAAgB,UAAU,OAAG,CACH,CACT,CAAA;GACP,CAAC,CACE,CACF,CAAA;AAEV,EAAC;AAED,SAASN,kBAAkB,CAACC,IAAY,EAAA;EACtC,IAAIA,IAAI,GAAG,IAAI,EAAE;IACf,OAAOA,IAAI,GAAG,QAAQ,CAAA;AACvB,GAAA,MAAM,IAAIA,IAAI,GAAG,OAAO,EAAE;IACzB,OAAUA,IAAI,GAAG,IAAI,GAAA,MAAA,CAAA;AACtB,GAAA,MAAM;IACL,OAAU,CAACA,IAAI,GAAG,OAAO,EAAEM,WAAW,CAAC,CAAC,CAAC,GAAA,KAAA,CAAA;AAC1C,GAAA;AACH;;AChIAC,sBAAsB,CAAC,YAAY,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/fileupload",
|
|
3
|
-
"version": "0.3.50-RC.
|
|
3
|
+
"version": "0.3.50-RC.2",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/fileupload.esm.js",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"lint": "dts lint"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@entur/a11y": "^0.2.50-RC.
|
|
27
|
-
"@entur/button": "^2.10.5-RC.
|
|
28
|
-
"@entur/icons": "^5.0.1-RC.
|
|
26
|
+
"@entur/a11y": "^0.2.50-RC.2",
|
|
27
|
+
"@entur/button": "^2.10.5-RC.2",
|
|
28
|
+
"@entur/icons": "^5.0.1-RC.2",
|
|
29
29
|
"@entur/tokens": "^3.4.1",
|
|
30
|
-
"@entur/typography": "^1.7.1-RC.
|
|
31
|
-
"@entur/utils": "^0.5.0-RC.
|
|
30
|
+
"@entur/typography": "^1.7.1-RC.2",
|
|
31
|
+
"@entur/utils": "^0.5.0-RC.2",
|
|
32
32
|
"classnames": "^2.3.1",
|
|
33
33
|
"react-dropzone": "^11.3.4"
|
|
34
34
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"react": ">=16.8.0",
|
|
37
37
|
"react-dom": ">=16.8.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "c994dd720e55fc4652ef5f05d7235d61b6bbfbf9"
|
|
40
40
|
}
|