@entur/fileupload 0.3.27 → 0.3.31

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 CHANGED
@@ -3,6 +3,26 @@
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.31](https://bitbucket.org/enturas/design-system/compare/@entur/fileupload@0.3.30...@entur/fileupload@0.3.31) (2021-09-23)
7
+
8
+ **Note:** Version bump only for package @entur/fileupload
9
+
10
+ ## [0.3.30](https://bitbucket.org/enturas/design-system/compare/@entur/fileupload@0.3.29...@entur/fileupload@0.3.30) (2021-09-13)
11
+
12
+ **Note:** Version bump only for package @entur/fileupload
13
+
14
+ ## [0.3.29](https://bitbucket.org/enturas/design-system/compare/@entur/fileupload@0.3.28...@entur/fileupload@0.3.29) (2021-09-07)
15
+
16
+ ### Bug Fixes
17
+
18
+ - fix lint warning ([6d8d06e](https://bitbucket.org/enturas/design-system/commits/6d8d06e7f2a088d2e857d41d52aa08f4ab50a49f))
19
+ - update dependencies ([d99dbde](https://bitbucket.org/enturas/design-system/commits/d99dbde566107589902f7f19bde3286a7195a600))
20
+ - utilize reworked focus token ([586758f](https://bitbucket.org/enturas/design-system/commits/586758fc86eb5aa52116c63c14ef033eb2e8b12f))
21
+
22
+ ## [0.3.28](https://bitbucket.org/enturas/design-system/compare/@entur/fileupload@0.3.27...@entur/fileupload@0.3.28) (2021-08-13)
23
+
24
+ **Note:** Version bump only for package @entur/fileupload
25
+
6
26
  ## [0.3.27](https://bitbucket.org/enturas/design-system/compare/@entur/fileupload@0.3.26...@entur/fileupload@0.3.27) (2021-07-16)
7
27
 
8
28
  **Note:** Version bump only for package @entur/fileupload
@@ -65,7 +65,7 @@ var FileUpload = function FileUpload(_ref) {
65
65
  files = _ref$files === void 0 ? [] : _ref$files,
66
66
  label = _ref.label,
67
67
  style = _ref.style,
68
- rest = _objectWithoutPropertiesLoose(_ref, ["standbyText", "errorText", "successText", "errorUpload", "onDrop", "onDelete", "accept", "files", "options", "label", "style"]);
68
+ rest = _objectWithoutPropertiesLoose(_ref, ["standbyText", "errorText", "successText", "errorUpload", "onDrop", "onDelete", "accept", "files", "label", "style"]);
69
69
 
70
70
  var _useDropzone = reactDropzone.useDropzone(_extends({
71
71
  onDrop: onDrop,
@@ -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} from 'react-dropzone';\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport classNames from 'classnames';\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: File) => 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 [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 options = {},\n label,\n style,\n ...rest\n}) => {\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n 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-uploadg__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: any, 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 <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","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","convertSizeToHuman","size","IconButton","onClick","DeleteIcon","toPrecision","warnAboutMissingStyles"],"mappings":";;;;;;;;;;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,KAAK,CAACgB,GAAN,CAAU,UAACpB,IAAD,EAAYqB,KAAZ;AAAA,WACTN,mBAAA,MAAA;AAAKC,MAAAA,SAAS,EAAC;AAA6BM,MAAAA,GAAG,EAAED;KAAjD,EACEN,mBAAA,CAACQ,cAAD;AAAUP,MAAAA,SAAS,EAAC;KAApB,CADF,EAEED,mBAAA,OAAA;AAAMC,MAAAA,SAAS,EAAC;KAAhB,EACGhB,IAAI,CAACwB,IADR,OAAA,EACiBC,kBAAkB,CAACzB,IAAI,CAAC0B,IAAN,CADnC,EACgD,GADhD,CAFF,EAKEX,mBAAA,CAACY,iBAAD;AAAYC,MAAAA,OAAO,EAAE;AAAA,eAAM7B,QAAQ,CAACC,IAAD,CAAd;AAAA;KAArB,EACEe,mBAAA,CAACc,gBAAD,MAAA,CADF,CALF,CADS;AAAA,GAAV,CADH,CAlBF,CADF;AAkCD;;AAED,SAASJ,kBAAT,CAA4BC,IAA5B;AACE,MAAIA,IAAI,GAAG,IAAX,EAAiB;AACf,WAAOA,IAAI,GAAG,QAAd;AACD,GAFD,MAEO,IAAIA,IAAI,GAAG,OAAX,EAAoB;AACzB,WAAUA,IAAI,GAAG,IAAjB;AACD,GAFM,MAEA;AACL,WAAU,CAACA,IAAI,GAAG,OAAR,EAAiBI,WAAjB,CAA6B,CAA7B,CAAV;AACD;AACF;;ACzHDC,4BAAsB,CAAC,YAAD,CAAtB;;;;"}
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} from 'react-dropzone';\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport classNames from 'classnames';\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: File) => 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 [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 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-uploadg__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: any, 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 <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","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","convertSizeToHuman","size","IconButton","onClick","DeleteIcon","toPrecision","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqDaA,UAAU,GAA8B,SAAxCA,UAAwC;8BACnDC;MAAAA,4CAAc;4BACdC;MAAAA,wCAAY;8BACZC;MAAAA,4CAAc;8BACdC;MAAAA,4CAAc;MACdC,cAAAA;2BACAC;MAAAA,sCAAW,UAAAC,IAAI;AAAA,WAAIC,OAAO,CAACC,GAAR,CAAYF,IAAZ,CAAJ;AAAA;yBACfG;MAAAA,kCAAS;wBACTC;MAAAA,gCAAQ;MACRC,aAAAA;MACAC,aAAAA;MACGC;;qBAGDC,yBAAW;AACTV,IAAAA,MAAM,EAANA,MADS;AAETK,IAAAA,MAAM,EAAEA;AAFC,KAGNI,IAHM;MADLE,4BAAAA;MAAcC,6BAAAA;MAAeC,4BAAAA;MAAcC,4BAAAA;;AAOnD,MAAMC,OAAO,GAAGT,KAAK,CAACU,MAAN,GAAe,CAA/B;AAEA,SACEC,mBAAA,MAAA;AAAKC,IAAAA,SAAS,EAAC;KAA+BV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,WAAOA,IAAI,GAAG,QAAd;AACD,GAFD,MAEO,IAAIA,IAAI,GAAG,OAAX,EAAoB;AACzB,WAAUA,IAAI,GAAG,IAAjB;AACD,GAFM,MAEA;AACL,WAAU,CAACA,IAAI,GAAG,OAAR,EAAiBI,WAAjB,CAA6B,CAA7B,CAAV;AACD;AACF;;ACpHDC,4BAAsB,CAAC,YAAD,CAAtB;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@entur/utils"),r=e(require("react")),l=require("react-dropzone"),o=require("@entur/icons"),n=require("@entur/button"),a=require("@entur/typography"),s=e(require("classnames"));function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e}).apply(this,arguments)}t.warnAboutMissingStyles("fileupload"),exports.FileUpload=function(e){var t=e.standbyText,c=void 0===t?"Dra fil eller klikk for å laste opp":t,p=e.errorText,u=void 0===p?"Feil ved opplasting av fil":p,d=e.successText,f=void 0===d?"Opplasting fullført":d,_=e.errorUpload,m=void 0!==_&&_,v=e.onDrop,g=e.onDelete,y=void 0===g?function(e){return console.log(e)}:g,b=e.accept,E=void 0===b?"":b,j=e.files,x=void 0===j?[]:j,D=e.label,O=e.style,h=function(e,t){if(null==e)return{};var r,l,o={},n=Object.keys(e);for(l=0;l<n.length;l++)t.indexOf(r=n[l])>=0||(o[r]=e[r]);return o}(e,["standbyText","errorText","successText","errorUpload","onDrop","onDelete","accept","files","options","label","style"]),z=l.useDropzone(i({onDrop:v,accept:E},h)),q=z.getRootProps,N=z.getInputProps,k=z.isDragActive,T=z.isDragReject,P=x.length>0;return r.createElement("div",Object.assign({className:"eds-file-upload__wrapper"},O),r.createElement("div",Object.assign({className:"eds-file-upload__input"},q()),D&&r.createElement(a.Label,{style:{display:"flex"}},D),r.createElement("input",Object.assign({},N())),r.createElement("span",{className:s("eds-file-upload__dropzone",{"eds-file-upload__dropzone--success":P},{"eds-file-upload__dropzone--active":k},{"eds-file-upload__dropzone--reject":T},{"eds-file-uploadg__dropzone--error":m})},P?f:m?u:c)),r.createElement("div",{className:"eds-file-upload__file-list"},x.map((function(e,t){return r.createElement("div",{className:"eds-file-upload__file-name",key:t},r.createElement(o.FileIcon,{className:"eds-file-upload__file-name-icon"}),r.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"," "),r.createElement(n.IconButton,{onClick:function(){return y(e)}},r.createElement(o.DeleteIcon,null)));var l}))))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@entur/utils"),r=e(require("react")),l=require("react-dropzone"),n=require("@entur/icons"),o=require("@entur/button"),a=require("@entur/typography"),s=e(require("classnames"));function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e}).apply(this,arguments)}t.warnAboutMissingStyles("fileupload"),exports.FileUpload=function(e){var t=e.standbyText,c=void 0===t?"Dra fil eller klikk for å laste opp":t,u=e.errorText,p=void 0===u?"Feil ved opplasting av fil":u,d=e.successText,f=void 0===d?"Opplasting fullført":d,_=e.errorUpload,m=void 0!==_&&_,v=e.onDrop,g=e.onDelete,y=void 0===g?function(e){return console.log(e)}:g,b=e.accept,E=void 0===b?"":b,j=e.files,x=void 0===j?[]:j,D=e.label,O=e.style,h=function(e,t){if(null==e)return{};var r,l,n={},o=Object.keys(e);for(l=0;l<o.length;l++)t.indexOf(r=o[l])>=0||(n[r]=e[r]);return n}(e,["standbyText","errorText","successText","errorUpload","onDrop","onDelete","accept","files","label","style"]),z=l.useDropzone(i({onDrop:v,accept:E},h)),q=z.getRootProps,N=z.getInputProps,k=z.isDragActive,T=z.isDragReject,P=x.length>0;return r.createElement("div",Object.assign({className:"eds-file-upload__wrapper"},O),r.createElement("div",Object.assign({className:"eds-file-upload__input"},q()),D&&r.createElement(a.Label,{style:{display:"flex"}},D),r.createElement("input",Object.assign({},N())),r.createElement("span",{className:s("eds-file-upload__dropzone",{"eds-file-upload__dropzone--success":P},{"eds-file-upload__dropzone--active":k},{"eds-file-upload__dropzone--reject":T},{"eds-file-uploadg__dropzone--error":m})},P?f:m?p:c)),r.createElement("div",{className:"eds-file-upload__file-list"},x.map((function(e,t){return r.createElement("div",{className:"eds-file-upload__file-name",key:t},r.createElement(n.FileIcon,{className:"eds-file-upload__file-name-icon"}),r.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"," "),r.createElement(o.IconButton,{onClick:function(){return y(e)}},r.createElement(n.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} from 'react-dropzone';\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport classNames from 'classnames';\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: File) => 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 [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 options = {},\n label,\n style,\n ...rest\n}) => {\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n 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-uploadg__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: any, 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 <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","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","size","toPrecision","IconButton","onClick","DeleteIcon"],"mappings":"whBAGAA,yBAAuB,iCCkD8B,oBACnDC,YAAAA,aAAc,4CACdC,UAAAA,aAAY,mCACZC,YAAAA,aAAc,4BACdC,YAAAA,gBACAC,IAAAA,WACAC,SAAAA,aAAW,SAAAC,UAAQC,QAAQC,IAAIF,UAC/BG,OAAAA,aAAS,SACTC,MAAAA,aAAQ,KAERC,IAAAA,MACAC,IAAAA,MACGC,iQAOCC,iBACFV,OAAAA,EACAK,OAAQA,GACLI,IAPHE,IAAAA,aACAC,IAAAA,cACAC,IAAAA,aACAC,IAAAA,aAOIC,EAAUT,EAAMU,OAAS,SAG7BC,qCAAKC,UAAU,4BAA+BV,GAC5CS,qCAAKC,UAAU,0BAA6BP,KACzCJ,GAASU,gBAACE,SAAMX,MAAO,CAAEY,QAAS,SAAWb,GAC9CU,yCAAWL,MACXK,wBACEC,UAAWG,EACT,4BACA,sCACwCN,GAExC,qCAAuCF,GACvC,qCAAuCC,GACvC,qCAAuCf,KAGxCgB,EAAUjB,EAAcC,EAAcF,EAAYD,IAGvDqB,uBAAKC,UAAU,8BACZZ,EAAMgB,KAAI,SAACpB,EAAWqB,UACrBN,uBAAKC,UAAU,6BAA6BM,IAAKD,GAC/CN,gBAACQ,YAASP,UAAU,oCACpBD,wBAAMC,UAAU,oCACbhB,EAAKwB,YAYQC,EAZoBzB,EAAKyB,MAaxC,IACFA,EAAO,SACLA,EAAO,IACNA,EAAO,YAENA,EAAO,KAASC,YAAY,SAlBiB,KAEhDX,gBAACY,cAAWC,QAAS,kBAAM7B,EAASC,KAClCe,gBAACc,qBASf,IAA4BJ"}
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} from 'react-dropzone';\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport classNames from 'classnames';\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: File) => 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 [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 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-uploadg__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: any, 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 <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","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","size","toPrecision","IconButton","onClick","DeleteIcon"],"mappings":"whBAGAA,yBAAuB,iCCkD8B,oBACnDC,YAAAA,aAAc,4CACdC,UAAAA,aAAY,mCACZC,YAAAA,aAAc,4BACdC,YAAAA,gBACAC,IAAAA,WACAC,SAAAA,aAAW,SAAAC,UAAQC,QAAQC,IAAIF,UAC/BG,OAAAA,aAAS,SACTC,MAAAA,aAAQ,KACRC,IAAAA,MACAC,IAAAA,MACGC,uPAGDC,iBACEV,OAAAA,EACAK,OAAQA,GACLI,IAJCE,IAAAA,aAAcC,IAAAA,cAAeC,IAAAA,aAAcC,IAAAA,aAO7CC,EAAUT,EAAMU,OAAS,SAG7BC,qCAAKC,UAAU,4BAA+BV,GAC5CS,qCAAKC,UAAU,0BAA6BP,KACzCJ,GAASU,gBAACE,SAAMX,MAAO,CAAEY,QAAS,SAAWb,GAC9CU,yCAAWL,MACXK,wBACEC,UAAWG,EACT,4BACA,sCACwCN,GAExC,qCAAuCF,GACvC,qCAAuCC,GACvC,qCAAuCf,KAGxCgB,EAAUjB,EAAcC,EAAcF,EAAYD,IAGvDqB,uBAAKC,UAAU,8BACZZ,EAAMgB,KAAI,SAACpB,EAAWqB,UACrBN,uBAAKC,UAAU,6BAA6BM,IAAKD,GAC/CN,gBAACQ,YAASP,UAAU,oCACpBD,wBAAMC,UAAU,oCACbhB,EAAKwB,YAYQC,EAZoBzB,EAAKyB,MAaxC,IACFA,EAAO,SACLA,EAAO,IACNA,EAAO,YAENA,EAAO,KAASC,YAAY,SAlBiB,KAEhDX,gBAACY,cAAWC,QAAS,kBAAM7B,EAASC,KAClCe,gBAACc,qBASf,IAA4BJ"}
@@ -59,7 +59,7 @@ var FileUpload = function FileUpload(_ref) {
59
59
  files = _ref$files === void 0 ? [] : _ref$files,
60
60
  label = _ref.label,
61
61
  style = _ref.style,
62
- rest = _objectWithoutPropertiesLoose(_ref, ["standbyText", "errorText", "successText", "errorUpload", "onDrop", "onDelete", "accept", "files", "options", "label", "style"]);
62
+ rest = _objectWithoutPropertiesLoose(_ref, ["standbyText", "errorText", "successText", "errorUpload", "onDrop", "onDelete", "accept", "files", "label", "style"]);
63
63
 
64
64
  var _useDropzone = useDropzone(_extends({
65
65
  onDrop: onDrop,
@@ -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} from 'react-dropzone';\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport classNames from 'classnames';\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: File) => 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 [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 options = {},\n label,\n style,\n ...rest\n}) => {\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n 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-uploadg__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: any, 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 <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","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","convertSizeToHuman","size","IconButton","onClick","DeleteIcon","toPrecision","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqDaA,UAAU,GAA8B,SAAxCA,UAAwC;8BACnDC;MAAAA,4CAAc;4BACdC;MAAAA,wCAAY;8BACZC;MAAAA,4CAAc;8BACdC;MAAAA,4CAAc;MACdC,cAAAA;2BACAC;MAAAA,sCAAW,UAAAC,IAAI;AAAA,WAAIC,OAAO,CAACC,GAAR,CAAYF,IAAZ,CAAJ;AAAA;yBACfG;MAAAA,kCAAS;wBACTC;MAAAA,gCAAQ;M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0B,IAAN,CADnC,EACgD,GADhD,CAFF,EAKEX,mBAAA,CAACY,UAAD;AAAYC,MAAAA,OAAO,EAAE;AAAA,eAAM7B,QAAQ,CAACC,IAAD,CAAd;AAAA;KAArB,EACEe,mBAAA,CAACc,UAAD,MAAA,CADF,CALF,CADS;AAAA,GAAV,CADH,CAlBF,CADF;AAkCD;;AAED,SAASJ,kBAAT,CAA4BC,IAA5B;AACE,MAAIA,IAAI,GAAG,IAAX,EAAiB;AACf,WAAOA,IAAI,GAAG,QAAd;AACD,GAFD,MAEO,IAAIA,IAAI,GAAG,OAAX,EAAoB;AACzB,WAAUA,IAAI,GAAG,IAAjB;AACD,GAFM,MAEA;AACL,WAAU,CAACA,IAAI,GAAG,OAAR,EAAiBI,WAAjB,CAA6B,CAA7B,CAAV;AACD;AACF;;ACzHDC,sBAAsB,CAAC,YAAD,CAAtB;;;;"}
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} from 'react-dropzone';\nimport { FileIcon, DeleteIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport { Label } from '@entur/typography';\nimport classNames from 'classnames';\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: File) => 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 [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 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-uploadg__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: any, 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 <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","style","rest","useDropzone","getRootProps","getInputProps","isDragActive","isDragReject","success","length","React","className","Label","display","classNames","map","index","key","FileIcon","path","convertSizeToHuman","size","IconButton","onClick","DeleteIcon","toPrecision","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqDaA,UAAU,GAA8B,SAAxCA,UAAwC;8BACnDC;MAAAA,4CAAc;4BACdC;MAAAA,wCAAY;8BACZC;MAAAA,4CAAc;8BACdC;MAAAA,4CAAc;MACdC,cAAAA;2BACAC;MAAAA,sCAAW,UAAAC,IAAI;AAAA,WAAIC,OAAO,CAACC,GAAR,CAAYF,IAAZ,CAAJ;AAAA;yBACfG;MAAAA,kCAAS;wBACTC;MAAAA,gCAAQ;MACRC,aAAAA;MACAC,aAAAA;MACGC;;qBAGDC,WAAW;AACTV,IAAAA,MAAM,EAANA,MADS;AAETK,IAAAA,MAAM,EAAEA;AAFC,KAGNI,IAHM;MADLE,4BAAAA;MAAcC,6BAAAA;MAAeC,4BAAAA;MAAcC,4BAAAA;;AAOnD,MAAMC,OAAO,GAAGT,KAAK,CAACU,MAAN,GAAe,CAA/B;AAEA,SACEC,mBAAA,MAAA;AAAKC,IAAAA,SAAS,EAAC;KAA+BV,MAA9C,EACES,mBAAA,MAAA;AAAKC,IAAAA,SAAS,EAAC;KAA6BP,YAAY,GAAxD,EACGJ,KAAK,IAAIU,mBAAA,CAACE,KAAD;AAAOX,IAAAA,KAAK,EAAE;AAAEY,MAAAA,OAAO,EAAE;AAAX;GAAd,EAAoCb,KAApC,CADZ,EAEEU,mBAAA,QAAA,oBAAWL,aAAa,GAAxB,CAFF,EAGEK,mBAAA,OAAA;AACEC,IAAAA,SAAS,EAAEG,UAAU,CACnB,2BADmB,EAEnB;AACE,4CAAsCN;AADx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ds-file-upload__dropzone {
17
- outline: 2px solid #181c56;
17
+ outline: none;
18
+ box-shadow: 0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #181c56;
18
19
  }
19
20
  .eds-contrast .eds-file-upload__input:focus .eds-file-upload__dropzone {
20
- outline: 2px solid #ffffff;
21
+ box-shadow: 0 0 0 0.125rem #181c56, 0 0 0 0.25rem #ffffff;
21
22
  }
22
23
  .eds-file-upload__dropzone {
23
24
  border: 0.125rem #d1d3d3 dashed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/fileupload",
3
- "version": "0.3.27",
3
+ "version": "0.3.31",
4
4
  "license": "EUPL-1.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/fileupload.esm.js",
@@ -23,17 +23,17 @@
23
23
  "lint": "tsdx lint"
24
24
  },
25
25
  "dependencies": {
26
- "@entur/button": "^2.6.1",
27
- "@entur/icons": "^3.0.0",
28
- "@entur/tokens": "^3.1.0",
29
- "@entur/typography": "^1.6.7",
26
+ "@entur/button": "^2.7.3",
27
+ "@entur/icons": "^3.3.0",
28
+ "@entur/tokens": "^3.2.1",
29
+ "@entur/typography": "^1.6.9",
30
30
  "@entur/utils": "^0.4.2",
31
31
  "classnames": "^2.3.1",
32
- "react-dropzone": "^11.3.2"
32
+ "react-dropzone": "^11.3.4"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=16.8.0",
36
36
  "react-dom": ">=16.8.0"
37
37
  },
38
- "gitHead": "66c09280cdc58761035f7b75b9a9b36774708641"
38
+ "gitHead": "d3611d9b3374c6aafc0b95b9ebac011f7b1a7785"
39
39
  }