@gen-epix/ui-client-casedb 4.0.2 → 4.1.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.
- package/dist/_chunks/AddCasesToEventDialog.js.map +1 -1
- package/dist/_chunks/CaseDbDownloadUtil.js +1 -1
- package/dist/_chunks/CaseDbDownloadUtil.js.map +1 -1
- package/dist/_chunks/CaseInfoDialog.js +4 -4
- package/dist/_chunks/CaseInfoDialog.js.map +1 -1
- package/dist/_chunks/CaseSetInfoDialog.js +4 -4
- package/dist/_chunks/CaseSetInfoDialog.js.map +1 -1
- package/dist/_chunks/CasesAlreadyInCaseSetWarning.js.map +1 -1
- package/dist/_chunks/Dashboard.js +3 -2
- package/dist/_chunks/Dashboard.js.map +1 -1
- package/dist/_chunks/FindSimilarCasesDialog.js +6 -6
- package/dist/_chunks/FindSimilarCasesDialog.js.map +1 -1
- package/dist/_chunks/HomePageTrends.js.map +1 -1
- package/dist/_chunks/LineListWidget.js +46 -45
- package/dist/_chunks/LineListWidget.js.map +1 -1
- package/dist/_chunks/Upload.js +308 -304
- package/dist/_chunks/Upload.js.map +1 -1
- package/dist/_chunks/UploadUtil.js +44 -40
- package/dist/_chunks/UploadUtil.js.map +1 -1
- package/dist/_chunks/dashboardStore.js.map +1 -1
- package/dist/classes/services/EventBusService/EventBusService.d.ts +9 -2
- package/dist/classes/services/EventBusService/index.js.map +1 -1
- package/dist/components/ui/MapWidget/index.js.map +1 -1
- package/dist/components/ui/RemoveCasesFromEventDialog/index.js.map +1 -1
- package/dist/components/ui/SequenceDownloadDialog/index.js +53 -40
- package/dist/components/ui/SequenceDownloadDialog/index.js.map +1 -1
- package/dist/components/ui/TreeWidget/index.js +8 -2
- package/dist/components/ui/TreeWidget/index.js.map +1 -1
- package/dist/locale/en.json +0 -11
- package/dist/locale/nl.json +0 -11
- package/dist/models/config.d.ts +2 -0
- package/dist/utils/UploadUtil/UploadUtil.d.ts +1 -0
- package/package.json +15 -23
- package/dist/components/ui/FileSelector/FileSelector.d.ts +0 -7
- package/dist/components/ui/FileSelector/index.d.ts +0 -1
- package/dist/components/ui/FileSelector/index.js +0 -206
- package/dist/components/ui/FileSelector/index.js.map +0 -1
- package/dist/utils/FileUtil/FileUtil.d.ts +0 -5
- package/dist/utils/FileUtil/index.d.ts +0 -1
- package/dist/utils/FileUtil/index.js +0 -15
- package/dist/utils/FileUtil/index.js.map +0 -1
package/dist/locale/en.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"translation": {
|
|
3
|
-
"(last modified: {{lastModified}})": "(last modified: {{lastModified}})",
|
|
4
|
-
"(size: {{size}})": "(size: {{size}})",
|
|
5
3
|
"{{caseTypeName}} cases": "{{caseTypeName}} cases",
|
|
6
4
|
"{{columnLabel}}: Identifier issuer": "{{columnLabel}}: Identifier issuer",
|
|
7
5
|
"{{count}} similar cases can be added to the line list.": "{{count}} similar cases can be added to the line list.",
|
|
@@ -103,11 +101,7 @@
|
|
|
103
101
|
"Centroid longitude": "Centroid longitude",
|
|
104
102
|
"Change dashboard layout": "Change dashboard layout",
|
|
105
103
|
"Change tree filter to nearest ancestor": "Change tree filter to nearest ancestor",
|
|
106
|
-
"Clear {{fileName}}": "Clear {{fileName}}",
|
|
107
104
|
"Clear all {{dimension}} fields": "Clear all {{dimension}} fields",
|
|
108
|
-
"Clear all selected files": "Clear all selected files",
|
|
109
|
-
"Click or drag to upload file ({{accept}})": "Click or drag to upload file ({{accept}})",
|
|
110
|
-
"Click or drag to upload files ({{accept}})": "Click or drag to upload files ({{accept}})",
|
|
111
105
|
"Close": "Close",
|
|
112
106
|
"Close download": "Close download",
|
|
113
107
|
"Close search": "Close search",
|
|
@@ -208,8 +202,6 @@
|
|
|
208
202
|
"Download Excel template": "Download Excel template",
|
|
209
203
|
"Download FASTA": "Download FASTA",
|
|
210
204
|
"Download sequences": "Download sequences",
|
|
211
|
-
"Drop file here": "Drop file here",
|
|
212
|
-
"Drop files here": "Drop files here",
|
|
213
205
|
"Dutch": "Dutch",
|
|
214
206
|
"Edit": "Edit",
|
|
215
207
|
"Edit case": "Edit case",
|
|
@@ -304,7 +296,6 @@
|
|
|
304
296
|
"Indicates if the case is owned by the current user (the case is in a private data collection that is owned by the user's organization).": "Indicates if the case is owned by the current user (the case is in a private data collection that is owned by the user's organization).",
|
|
305
297
|
"Indicates if there are any issues with the case": "Indicates if there are any issues with the case",
|
|
306
298
|
"Information for the press": "Information for the press",
|
|
307
|
-
"Invalid file type. Accepted types: {{accept}}": "Invalid file type. Accepted types: {{accept}}",
|
|
308
299
|
"Invalid value for pattern \"{{pattern}}\"": "Invalid value for pattern \"{{pattern}}\"",
|
|
309
300
|
"Is active": "Is active",
|
|
310
301
|
"Is created in": "Is created in",
|
|
@@ -518,7 +509,6 @@
|
|
|
518
509
|
"Select rows": "Select rows",
|
|
519
510
|
"Select sequence files": "Select sequence files",
|
|
520
511
|
"Selected": "Selected",
|
|
521
|
-
"Selected files: {{numFiles}}": "Selected files: {{numFiles}}",
|
|
522
512
|
"selected rows": "selected rows",
|
|
523
513
|
"Selected rows": "Selected rows",
|
|
524
514
|
"Selected tree node ({{nodeName}})": "Selected tree node ({{nodeName}})",
|
|
@@ -589,7 +579,6 @@
|
|
|
589
579
|
"This will navigate to the \"{{caseSetName}}\"-event. You will loose your current selection of cases and all applied filters. Do you want to continue?": "This will navigate to the \"{{caseSetName}}\"-event. You will loose your current selection of cases and all applied filters. Do you want to continue?",
|
|
590
580
|
"To Concept": "To Concept",
|
|
591
581
|
"To Region": "To Region",
|
|
592
|
-
"Too many files selected. Maximum allowed: {{numFilesAllowed}}": "Too many files selected. Maximum allowed: {{numFilesAllowed}}",
|
|
593
582
|
"Tree": "Tree",
|
|
594
583
|
"Tree algorithm": "Tree algorithm",
|
|
595
584
|
"Tree algorithm codes": "Tree algorithm codes",
|
package/dist/locale/nl.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"translation": {
|
|
3
|
-
"(last modified: {{lastModified}})": "(laatst gewijzigd: {{lastModified}})",
|
|
4
|
-
"(size: {{size}})": "(grootte: {{size}})",
|
|
5
3
|
"{{caseTypeName}} cases": "{{caseTypeName}} casussen",
|
|
6
4
|
"{{columnLabel}}: Identifier issuer": "{{columnLabel}}: Identificatie uitgever",
|
|
7
5
|
"{{count}} similar cases can be added to the line list.": "{{count}} vergelijkbare casussen kunnen worden toegevoegd aan de lijnlijst.",
|
|
@@ -103,11 +101,7 @@
|
|
|
103
101
|
"Centroid longitude": "Centroid lengtegraad",
|
|
104
102
|
"Change dashboard layout": "Dashboard-indeling wijzigen",
|
|
105
103
|
"Change tree filter to nearest ancestor": "Wijzig boom filter naar dichtstbijzijnde voorouder",
|
|
106
|
-
"Clear {{fileName}}": "Wis {{fileName}}",
|
|
107
104
|
"Clear all {{dimension}} fields": "Wis alle {{dimension}} velden",
|
|
108
|
-
"Clear all selected files": "Wis alle geselecteerde bestanden",
|
|
109
|
-
"Click or drag to upload file ({{accept}})": "Klik of sleep om bestand te uploaden ({{accept}})",
|
|
110
|
-
"Click or drag to upload files ({{accept}})": "Klik of sleep om bestanden te uploaden ({{accept}})",
|
|
111
105
|
"Close": "Sluiten",
|
|
112
106
|
"Close download": "Download sluiten",
|
|
113
107
|
"Close search": "Zoeken sluiten",
|
|
@@ -208,8 +202,6 @@
|
|
|
208
202
|
"Download Excel template": "Download Excel sjabloon",
|
|
209
203
|
"Download FASTA": "Download FASTA",
|
|
210
204
|
"Download sequences": "Download sequenties",
|
|
211
|
-
"Drop file here": "Sleep bestand hierheen",
|
|
212
|
-
"Drop files here": "Sleep bestanden hierheen",
|
|
213
205
|
"Dutch": "Nederlands",
|
|
214
206
|
"Edit": "Bewerken",
|
|
215
207
|
"Edit case": "Casus bewerken",
|
|
@@ -304,7 +296,6 @@
|
|
|
304
296
|
"Indicates if the case is owned by the current user (the case is in a private data collection that is owned by the user's organization).": "Geeft aan of de casus eigendom is van de huidige gebruiker (de casus zit in een privégegevensverzameling waarvan de organisatie van de gebruiker eigenaar is).",
|
|
305
297
|
"Indicates if there are any issues with the case": "Geeft aan of er problemen zijn met de casus",
|
|
306
298
|
"Information for the press": "Informatie voor de pers",
|
|
307
|
-
"Invalid file type. Accepted types: {{accept}}": "Ongeldig bestandstype. Geaccepteerde typen: {{accept}}",
|
|
308
299
|
"Invalid value for pattern \"{{pattern}}\"": "Ongeldige waarde voor patroon \"{{pattern}}\"",
|
|
309
300
|
"Is active": "Is actief",
|
|
310
301
|
"Is created in": "Is aangemaakt in",
|
|
@@ -518,7 +509,6 @@
|
|
|
518
509
|
"Select rows": "Selecteer rijen",
|
|
519
510
|
"Select sequence files": "Sequentiebestanden selecteren",
|
|
520
511
|
"Selected": "Geselecteerd",
|
|
521
|
-
"Selected files: {{numFiles}}": "Geselecteerde bestanden: {{numFiles}}",
|
|
522
512
|
"selected rows": "geselecteerde rijen",
|
|
523
513
|
"Selected rows": "Geselecteerde rijen",
|
|
524
514
|
"Selected tree node ({{nodeName}})": "Geselecteerd boom knooppunt ({{nodeName}})",
|
|
@@ -589,7 +579,6 @@
|
|
|
589
579
|
"This will navigate to the \"{{caseSetName}}\"-event. You will loose your current selection of cases and all applied filters. Do you want to continue?": "Dit navigeert naar de \"{{caseSetName}}\"-event. U verliest uw huidige selectie van casussen en alle toegepaste filters. Wilt u doorgaan?",
|
|
590
580
|
"To Concept": "Naar Concept",
|
|
591
581
|
"To Region": "Naar Regio",
|
|
592
|
-
"Too many files selected. Maximum allowed: {{numFilesAllowed}}": "Te veel bestanden geselecteerd. Maximum toegestaan: {{numFilesAllowed}}",
|
|
593
582
|
"Tree": "Boom",
|
|
594
583
|
"Tree algorithm": "Boom algoritme",
|
|
595
584
|
"Tree algorithm codes": "Boom algoritme codes",
|
package/dist/models/config.d.ts
CHANGED
|
@@ -3,12 +3,14 @@ import { CaseDbColType } from '@gen-epix/api-casedb';
|
|
|
3
3
|
import { ConfigBase } from '@gen-epix/ui-client-common/models/config';
|
|
4
4
|
import { Range } from 'colorjs.io';
|
|
5
5
|
import { FieldValues } from 'react-hook-form';
|
|
6
|
+
import { ReactElement } from 'react';
|
|
6
7
|
import { DashboardArrangement, DashboardArrangementWidgetAssignments, WidgetDataBase, WidgetsConfig } from './dashboard';
|
|
7
8
|
export interface CaseDbConfig extends ConfigBase {
|
|
8
9
|
dashboard: {
|
|
9
10
|
ARRANGEMENT_OPTIONS: {
|
|
10
11
|
[key: string]: DashboardArrangement;
|
|
11
12
|
};
|
|
13
|
+
DASHBOARD_INJECTED_COMPONENT?: () => ReactElement;
|
|
12
14
|
DEFAULT_ARRANGEMENT_KEY: string;
|
|
13
15
|
DEFAULT_WIDGET_ASSIGNMENTS: {
|
|
14
16
|
[key: string]: DashboardArrangementWidgetAssignments;
|
|
@@ -100,6 +100,7 @@ export declare class UploadUtil {
|
|
|
100
100
|
signal: AbortSignal;
|
|
101
101
|
startPercentage: number;
|
|
102
102
|
}): Promise<void>;
|
|
103
|
+
private static getFileCompressionFromFileName;
|
|
103
104
|
private static idToRegex;
|
|
104
105
|
private static mapExcelCellToString;
|
|
105
106
|
private static mapExcelSheetData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gen-epix/ui-client-casedb",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -120,10 +120,6 @@
|
|
|
120
120
|
"types": "./dist/components/ui/EpiCurveWidget/index.d.ts",
|
|
121
121
|
"import": "./dist/components/ui/EpiCurveWidget/index.js"
|
|
122
122
|
},
|
|
123
|
-
"./components/ui/FileSelector": {
|
|
124
|
-
"types": "./dist/components/ui/FileSelector/index.d.ts",
|
|
125
|
-
"import": "./dist/components/ui/FileSelector/index.js"
|
|
126
|
-
},
|
|
127
123
|
"./components/ui/FindSimilarCasesDialog": {
|
|
128
124
|
"types": "./dist/components/ui/FindSimilarCasesDialog/index.d.ts",
|
|
129
125
|
"import": "./dist/components/ui/FindSimilarCasesDialog/index.js"
|
|
@@ -648,10 +644,6 @@
|
|
|
648
644
|
"types": "./dist/utils/EpiCurveUtil/index.d.ts",
|
|
649
645
|
"import": "./dist/utils/EpiCurveUtil/index.js"
|
|
650
646
|
},
|
|
651
|
-
"./utils/FileUtil": {
|
|
652
|
-
"types": "./dist/utils/FileUtil/index.d.ts",
|
|
653
|
-
"import": "./dist/utils/FileUtil/index.js"
|
|
654
|
-
},
|
|
655
647
|
"./utils/FilterUtil": {
|
|
656
648
|
"types": "./dist/utils/FilterUtil/index.d.ts",
|
|
657
649
|
"import": "./dist/utils/FilterUtil/index.js"
|
|
@@ -685,13 +677,13 @@
|
|
|
685
677
|
"@emotion/cache": "*",
|
|
686
678
|
"@emotion/react": "*",
|
|
687
679
|
"@emotion/styled": "*",
|
|
688
|
-
"@gen-epix/api-casedb": "^4.
|
|
689
|
-
"@gen-epix/api-commondb": "^4.
|
|
690
|
-
"@gen-epix/ui-core": "^3.0
|
|
691
|
-
"@gen-epix/ui-core-components": "^4.0
|
|
692
|
-
"@gen-epix/ui-client-common": "^4.0
|
|
693
|
-
"@gen-epix/ui-phylogenetic-tree": "^3.0
|
|
694
|
-
"@gen-epix/ui-core-form": "^4.0
|
|
680
|
+
"@gen-epix/api-casedb": "^4.1.0",
|
|
681
|
+
"@gen-epix/api-commondb": "^4.1.0",
|
|
682
|
+
"@gen-epix/ui-core": "^3.1.0",
|
|
683
|
+
"@gen-epix/ui-core-components": "^4.1.0",
|
|
684
|
+
"@gen-epix/ui-client-common": "^4.1.0",
|
|
685
|
+
"@gen-epix/ui-phylogenetic-tree": "^3.1.0",
|
|
686
|
+
"@gen-epix/ui-core-form": "^4.1.0",
|
|
695
687
|
"@mui/icons-material": "*",
|
|
696
688
|
"@mui/material": "*",
|
|
697
689
|
"@mui/styled-engine": "*",
|
|
@@ -732,15 +724,15 @@
|
|
|
732
724
|
"@emotion/cache": "11.14.0",
|
|
733
725
|
"@emotion/react": "11.14.0",
|
|
734
726
|
"@emotion/styled": "11.14.1",
|
|
735
|
-
"@gen-epix/api-casedb": "^4.
|
|
736
|
-
"@gen-epix/api-commondb": "^4.
|
|
737
|
-
"@gen-epix/ui-core": "^3.0
|
|
738
|
-
"@gen-epix/ui-core-components": "^4.0
|
|
739
|
-
"@gen-epix/ui-phylogenetic-tree": "^3.0
|
|
740
|
-
"@gen-epix/ui-core-form": "^4.0
|
|
727
|
+
"@gen-epix/api-casedb": "^4.1.0",
|
|
728
|
+
"@gen-epix/api-commondb": "^4.1.0",
|
|
729
|
+
"@gen-epix/ui-core": "^3.1.0",
|
|
730
|
+
"@gen-epix/ui-core-components": "^4.1.0",
|
|
731
|
+
"@gen-epix/ui-phylogenetic-tree": "^3.1.0",
|
|
732
|
+
"@gen-epix/ui-core-form": "^4.1.0",
|
|
741
733
|
"@gen-epix/eslint-config": "0.5.0",
|
|
742
734
|
"@gen-epix/translation-util": "0.2.0",
|
|
743
|
-
"@gen-epix/ui-client-common": "^4.0
|
|
735
|
+
"@gen-epix/ui-client-common": "^4.1.0",
|
|
744
736
|
"@hookform/resolvers": "5.9.1",
|
|
745
737
|
"@mui/icons-material": "9.4.0",
|
|
746
738
|
"@mui/material": "9.4.0",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type FileSelectorProps = {
|
|
2
|
-
readonly accept: string;
|
|
3
|
-
readonly initialDataTransfer?: DataTransfer;
|
|
4
|
-
readonly numFilesAllowed?: number;
|
|
5
|
-
readonly onDataTransferChange: (dataTransfer: DataTransfer) => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const FileSelector: ({ accept, initialDataTransfer: initialDataTransferProp, numFilesAllowed, onDataTransferChange, }: FileSelectorProps) => import("react").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './FileSelector';
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { t as e } from "../../../_chunks/format.js";
|
|
2
|
-
import { FileUtil as t } from "../../../utils/FileUtil/index.js";
|
|
3
|
-
import { DATE_FORMAT as n } from "@gen-epix/ui-core/constants/date";
|
|
4
|
-
import { Box as r, Chip as i, IconButton as a, Stack as o, Typography as s } from "@mui/material";
|
|
5
|
-
import { useCallback as c, useEffect as l, useId as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
6
|
-
import { useTranslation as m } from "react-i18next";
|
|
7
|
-
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
8
|
-
import v from "@mui/icons-material/Delete";
|
|
9
|
-
import y from "@mui/icons-material/InsertDriveFile";
|
|
10
|
-
import b from "@mui/icons-material/CloudUpload";
|
|
11
|
-
//#region src/components/ui/FileSelector/FileSelector.tsx
|
|
12
|
-
var x = ({ accept: x, initialDataTransfer: S, numFilesAllowed: C = 1, onDataTransferChange: w }) => {
|
|
13
|
-
let { t: T } = m(), E = T(C === 1 ? "Click or drag to upload file ({{accept}})" : "Click or drag to upload files ({{accept}})", { accept: x.split(",").join(", ") }), D = C === 1 ? T`Drop file here` : T`Drop files here`, O = u(), k = f(null), A = d(() => S ?? new DataTransfer(), [S]), [j, M] = p(A), [N, P] = p(E), [F, I] = p(null), [L, R] = p(!1), z = f(!0);
|
|
14
|
-
l(() => {
|
|
15
|
-
if (z.current) {
|
|
16
|
-
z.current = !1;
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
w(j);
|
|
20
|
-
}, [j, w]);
|
|
21
|
-
let B = c((e) => {
|
|
22
|
-
e.stopPropagation(), e.preventDefault();
|
|
23
|
-
}, []), V = c((e) => {
|
|
24
|
-
I(null), B(e), R(!0), P(D);
|
|
25
|
-
}, [B, D]), H = c((e) => {
|
|
26
|
-
B(e), R(!1), P(E);
|
|
27
|
-
}, [B, E]), U = c((e) => {
|
|
28
|
-
B(e);
|
|
29
|
-
}, [B]), W = c((e) => {
|
|
30
|
-
for (let t of e) if (!x.split(",").some((e) => {
|
|
31
|
-
let n = e.trim();
|
|
32
|
-
return n === t.type || n.startsWith(".") && t.name.endsWith(n);
|
|
33
|
-
})) return !1;
|
|
34
|
-
return !0;
|
|
35
|
-
}, [x]), G = c((e) => {
|
|
36
|
-
I(null), M((t) => {
|
|
37
|
-
let n = new DataTransfer();
|
|
38
|
-
return Array.from(t.files).filter((t) => t.name !== e).forEach((e) => n.items.add(e)), n;
|
|
39
|
-
});
|
|
40
|
-
}, []), K = c((e) => {
|
|
41
|
-
I(null), M((t) => {
|
|
42
|
-
if (!e || e.length === 0) return t;
|
|
43
|
-
if (!W(e)) return I(T("Invalid file type. Accepted types: {{accept}}", { accept: x })), t;
|
|
44
|
-
let n = Array.from(e).map((e) => e.name), r = new Set(Array.from(t.files).map((e) => e.name)), i = n.filter((e) => r.has(e)).length;
|
|
45
|
-
if (r.size + (n.length - i) > C) return I(T("Too many files selected. Maximum allowed: {{numFilesAllowed}}", { numFilesAllowed: C })), t;
|
|
46
|
-
let a = new DataTransfer();
|
|
47
|
-
return Array.from(t.files).forEach((e) => {
|
|
48
|
-
n.includes(e.name) || a.items.add(e);
|
|
49
|
-
}), Array.from(e).forEach((e) => {
|
|
50
|
-
a.items.add(e);
|
|
51
|
-
}), a;
|
|
52
|
-
});
|
|
53
|
-
}, [
|
|
54
|
-
x,
|
|
55
|
-
W,
|
|
56
|
-
C,
|
|
57
|
-
T
|
|
58
|
-
]), q = c((e) => {
|
|
59
|
-
B(e), P(E), R(!1);
|
|
60
|
-
let t = e.dataTransfer.files;
|
|
61
|
-
K(t);
|
|
62
|
-
}, [
|
|
63
|
-
B,
|
|
64
|
-
E,
|
|
65
|
-
K
|
|
66
|
-
]), J = c((e) => {
|
|
67
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), k.current?.click());
|
|
68
|
-
}, []), Y = c((e) => {
|
|
69
|
-
K(e.target.files);
|
|
70
|
-
}, [K]), X = c(() => {
|
|
71
|
-
I(null), M(new DataTransfer());
|
|
72
|
-
}, []);
|
|
73
|
-
return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(r, {
|
|
74
|
-
accept: x,
|
|
75
|
-
component: "input",
|
|
76
|
-
id: O,
|
|
77
|
-
multiple: C > 1,
|
|
78
|
-
onChange: Y,
|
|
79
|
-
ref: k,
|
|
80
|
-
sx: { display: "none" },
|
|
81
|
-
type: "file"
|
|
82
|
-
}), /* @__PURE__ */ _(r, {
|
|
83
|
-
sx: {
|
|
84
|
-
display: "grid",
|
|
85
|
-
gridTemplateRows: "auto fit-content(50%)",
|
|
86
|
-
height: "100%"
|
|
87
|
-
},
|
|
88
|
-
children: [/* @__PURE__ */ g(r, {
|
|
89
|
-
component: "label",
|
|
90
|
-
htmlFor: O,
|
|
91
|
-
onDragEnter: V,
|
|
92
|
-
onDragLeave: H,
|
|
93
|
-
onDragOver: U,
|
|
94
|
-
onDrop: q,
|
|
95
|
-
onKeyDown: J,
|
|
96
|
-
sx: {
|
|
97
|
-
"&:hover *": { opacity: 1 },
|
|
98
|
-
"& p, & svg": { opacity: L ? 1 : .4 },
|
|
99
|
-
cursor: "pointer",
|
|
100
|
-
display: "flex",
|
|
101
|
-
height: "100%",
|
|
102
|
-
position: "relative",
|
|
103
|
-
textAlign: "center",
|
|
104
|
-
width: "100%"
|
|
105
|
-
},
|
|
106
|
-
tabIndex: 0,
|
|
107
|
-
children: /* @__PURE__ */ g(r, {
|
|
108
|
-
sx: {
|
|
109
|
-
height: "100%",
|
|
110
|
-
pointerEvents: "none",
|
|
111
|
-
position: "relative",
|
|
112
|
-
width: "100%"
|
|
113
|
-
},
|
|
114
|
-
children: /* @__PURE__ */ _(r, {
|
|
115
|
-
sx: {
|
|
116
|
-
alignItems: "center",
|
|
117
|
-
display: "flex",
|
|
118
|
-
flexDirection: "column",
|
|
119
|
-
height: "100%",
|
|
120
|
-
justifyContent: "center",
|
|
121
|
-
position: "absolute",
|
|
122
|
-
width: "100%"
|
|
123
|
-
},
|
|
124
|
-
children: [
|
|
125
|
-
/* @__PURE__ */ g(b, {
|
|
126
|
-
color: "primary",
|
|
127
|
-
fontSize: "large"
|
|
128
|
-
}),
|
|
129
|
-
F && /* @__PURE__ */ g(s, {
|
|
130
|
-
sx: {
|
|
131
|
-
color: "error.main",
|
|
132
|
-
fontWeight: "bold"
|
|
133
|
-
},
|
|
134
|
-
children: F
|
|
135
|
-
}),
|
|
136
|
-
/* @__PURE__ */ g(s, { children: N })
|
|
137
|
-
]
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
}), /* @__PURE__ */ g(r, {
|
|
141
|
-
sx: {
|
|
142
|
-
overflow: "auto",
|
|
143
|
-
position: "relative"
|
|
144
|
-
},
|
|
145
|
-
children: /* @__PURE__ */ g(r, { children: j.files.length > 0 && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _(r, {
|
|
146
|
-
sx: {
|
|
147
|
-
alignItems: "center",
|
|
148
|
-
backgroundColor: (e) => e.palette.background.paper,
|
|
149
|
-
display: "flex",
|
|
150
|
-
gap: 1,
|
|
151
|
-
paddingY: 1,
|
|
152
|
-
position: "sticky",
|
|
153
|
-
top: 0,
|
|
154
|
-
zIndex: (e) => e.zIndex.tooltip - 1
|
|
155
|
-
},
|
|
156
|
-
children: [/* @__PURE__ */ g(s, {
|
|
157
|
-
variant: "h5",
|
|
158
|
-
children: T("Selected files: {{numFiles}}", { numFiles: j.files.length })
|
|
159
|
-
}), /* @__PURE__ */ g(a, {
|
|
160
|
-
"aria-label": T("Clear all selected files"),
|
|
161
|
-
onClick: X,
|
|
162
|
-
size: "small",
|
|
163
|
-
children: /* @__PURE__ */ g(v, { fontSize: "small" })
|
|
164
|
-
})]
|
|
165
|
-
}), /* @__PURE__ */ g(o, {
|
|
166
|
-
direction: "row",
|
|
167
|
-
sx: { flexWrap: "wrap" },
|
|
168
|
-
children: Array.from(j.files).map((a) => /* @__PURE__ */ g(i, {
|
|
169
|
-
deleteIcon: /* @__PURE__ */ g(v, {
|
|
170
|
-
"aria-hidden": !1,
|
|
171
|
-
"aria-label": T("Clear {{fileName}}", { fileName: a.name }),
|
|
172
|
-
focusable: !0,
|
|
173
|
-
onKeyDown: (e) => {
|
|
174
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), G(a.name));
|
|
175
|
-
},
|
|
176
|
-
tabIndex: 0
|
|
177
|
-
}),
|
|
178
|
-
icon: /* @__PURE__ */ g(y, {}),
|
|
179
|
-
label: /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(r, {
|
|
180
|
-
component: "span",
|
|
181
|
-
sx: { fontWeight: "bold" },
|
|
182
|
-
children: a.name
|
|
183
|
-
}), /* @__PURE__ */ _(r, {
|
|
184
|
-
component: "span",
|
|
185
|
-
children: [
|
|
186
|
-
" ",
|
|
187
|
-
T("(size: {{size}})", { size: t.getReadableFileSize(a.size) }),
|
|
188
|
-
" ",
|
|
189
|
-
T("(last modified: {{lastModified}})", { lastModified: e(new Date(a.lastModified), n.DATE_TIME) })
|
|
190
|
-
]
|
|
191
|
-
})] }),
|
|
192
|
-
onDelete: () => {
|
|
193
|
-
G(a.name);
|
|
194
|
-
},
|
|
195
|
-
sx: { margin: .25 },
|
|
196
|
-
tabIndex: -1,
|
|
197
|
-
variant: "outlined"
|
|
198
|
-
}, `${a.name}-${a.size}-${a.lastModified}`))
|
|
199
|
-
})] }) })
|
|
200
|
-
})]
|
|
201
|
-
})] });
|
|
202
|
-
};
|
|
203
|
-
//#endregion
|
|
204
|
-
export { x as FileSelector };
|
|
205
|
-
|
|
206
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/ui/FileSelector/FileSelector.tsx"],"sourcesContent":["import {\n Box,\n Chip,\n IconButton,\n Stack,\n Typography,\n} from '@mui/material';\nimport DeleteIcon from '@mui/icons-material/Delete';\nimport InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';\nimport type {\n ChangeEvent,\n DragEvent,\n KeyboardEvent as ReactKeyboardEvent,\n} from 'react';\nimport {\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport CloudUploadIcon from '@mui/icons-material/CloudUpload';\nimport { useTranslation } from 'react-i18next';\nimport { format } from 'date-fns';\nimport { DATE_FORMAT } from '@gen-epix/ui-core/constants/date';\n\nimport { FileUtil } from '../../../utils/FileUtil';\n\n\nexport type FileSelectorProps = {\n readonly accept: string;\n readonly initialDataTransfer?: DataTransfer;\n readonly numFilesAllowed?: number;\n readonly onDataTransferChange: (dataTransfer: DataTransfer) => void;\n};\n\nexport const FileSelector = ({\n accept,\n initialDataTransfer: initialDataTransferProp,\n numFilesAllowed = 1,\n onDataTransferChange,\n}: FileSelectorProps) => {\n const { t } = useTranslation();\n const hoverLabel = numFilesAllowed === 1\n ? t('Click or drag to upload file ({{accept}})', { accept: accept.split(',').join(', ') })\n : t('Click or drag to upload files ({{accept}})', { accept: accept.split(',').join(', ') });\n const dropLabel = numFilesAllowed === 1\n ? t`Drop file here`\n : t`Drop files here`;\n\n const inputId = useId();\n const inputRef = useRef<HTMLInputElement>(null);\n\n const initialDataTransfer = useMemo(() => {\n return initialDataTransferProp ?? new DataTransfer();\n }, [initialDataTransferProp]);\n\n const [dataTransfer, setDataTransfer] = useState<DataTransfer>(initialDataTransfer);\n const [labelText, setLabelText] = useState<string>(hoverLabel);\n const [errorText, setErrorText] = useState<string>(null);\n const [isDragOver, setIsDragOver] = useState<boolean>(false);\n const initialDataTransferEffectRef = useRef(true);\n\n useEffect(() => {\n if (initialDataTransferEffectRef.current) {\n initialDataTransferEffectRef.current = false;\n return;\n }\n onDataTransferChange(dataTransfer);\n }, [dataTransfer, onDataTransferChange]);\n\n const stopDefaults = useCallback((e: DragEvent) => {\n e.stopPropagation();\n e.preventDefault();\n }, []);\n\n const onLabelDragEnter = useCallback((event: DragEvent) => {\n setErrorText(null);\n stopDefaults(event);\n setIsDragOver(true);\n setLabelText(dropLabel);\n }, [stopDefaults, dropLabel]);\n\n const onLabelDragLeave = useCallback((event: DragEvent) => {\n stopDefaults(event);\n setIsDragOver(false);\n setLabelText(hoverLabel);\n }, [stopDefaults, hoverLabel]);\n\n const onLabelDragOver = useCallback((event: DragEvent) => {\n stopDefaults(event);\n }, [stopDefaults]);\n\n const areFileTypesValid = useCallback((fileList: FileList) => {\n for (const file of fileList) {\n const isValid = accept.split(',').some(type => {\n const trimmedType = type.trim();\n return (\n trimmedType === file.type ||\n (trimmedType.startsWith('.') && file.name.endsWith(trimmedType))\n );\n });\n if (!isValid) {\n return false;\n }\n }\n return true;\n }, [accept]);\n\n const removeFile = useCallback((fileName: string) => {\n setErrorText(null);\n setDataTransfer((oldDataTransfer) => {\n const newDataTransfer = new DataTransfer();\n Array.from(oldDataTransfer.files)\n .filter(f => f.name !== fileName)\n .forEach(f => newDataTransfer.items.add(f));\n return newDataTransfer;\n });\n }, []);\n\n const addFileList = useCallback((fileList: FileList) => {\n setErrorText(null);\n setDataTransfer((oldDataTransfer) => {\n if (!fileList || fileList.length === 0) {\n return oldDataTransfer;\n }\n if (!areFileTypesValid(fileList)) {\n setErrorText(t('Invalid file type. Accepted types: {{accept}}', { accept }));\n return oldDataTransfer;\n }\n\n const fileNamesToAppend = Array.from(fileList).map(f => f.name);\n const uniqueOldFileNames = new Set(Array.from(oldDataTransfer.files).map(f => f.name));\n const numDuplicates = fileNamesToAppend.filter(name => uniqueOldFileNames.has(name)).length;\n const numNewFileNames = uniqueOldFileNames.size + (fileNamesToAppend.length - numDuplicates);\n\n if (numNewFileNames > numFilesAllowed) {\n setErrorText(t('Too many files selected. Maximum allowed: {{numFilesAllowed}}', { numFilesAllowed }));\n return oldDataTransfer;\n }\n\n const newDataTransfer = new DataTransfer();\n Array.from(oldDataTransfer.files).forEach(file => {\n if (!fileNamesToAppend.includes(file.name)) {\n newDataTransfer.items.add(file);\n }\n });\n Array.from(fileList).forEach(file => {\n newDataTransfer.items.add(file);\n });\n\n return newDataTransfer;\n\n });\n }, [accept, areFileTypesValid, numFilesAllowed, t]);\n\n const onDrop = useCallback((event: DragEvent<HTMLElement>) => {\n stopDefaults(event);\n setLabelText(hoverLabel);\n setIsDragOver(false);\n\n const fileList = event.dataTransfer.files;\n addFileList(fileList);\n\n }, [stopDefaults, hoverLabel, addFileList]);\n\n const onLabelKeyDown = useCallback((event: ReactKeyboardEvent<HTMLElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n inputRef.current?.click();\n }\n }, []);\n\n const onFileInputChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {\n addFileList(event.target.files);\n }, [addFileList]);\n\n const onClearAllButtonClick = useCallback(() => {\n setErrorText(null);\n setDataTransfer(new DataTransfer());\n }, []);\n\n return (\n <>\n <Box\n accept={accept}\n component={'input'}\n id={inputId}\n multiple={numFilesAllowed > 1}\n onChange={onFileInputChange}\n ref={inputRef}\n sx={{\n display: 'none',\n }}\n type={'file'}\n />\n <Box\n sx={{\n display: 'grid',\n gridTemplateRows: 'auto fit-content(50%)',\n height: '100%',\n }}\n >\n <Box\n component={'label'}\n htmlFor={inputId}\n onDragEnter={onLabelDragEnter}\n onDragLeave={onLabelDragLeave}\n onDragOver={onLabelDragOver}\n onDrop={onDrop}\n onKeyDown={onLabelKeyDown}\n sx={{\n '&:hover *': {\n opacity: 1,\n },\n '& p, & svg': {\n opacity: isDragOver ? 1 : 0.4,\n },\n cursor: 'pointer',\n display: 'flex',\n height: '100%',\n position: 'relative',\n textAlign: 'center',\n width: '100%',\n }}\n tabIndex={0}\n >\n <Box\n sx={{\n height: '100%',\n pointerEvents: 'none',\n position: 'relative',\n width: '100%',\n }}\n >\n <Box\n sx={{\n alignItems: 'center',\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n justifyContent: 'center',\n position: 'absolute',\n width: '100%',\n }}\n >\n <CloudUploadIcon\n color={'primary'}\n fontSize={'large'}\n />\n {errorText && (\n <Typography\n sx={{\n color: 'error.main',\n fontWeight: 'bold',\n }}\n >\n {errorText}\n </Typography>\n )}\n <Typography>\n {labelText}\n </Typography>\n\n </Box>\n </Box>\n </Box>\n <Box\n sx={{\n overflow: 'auto',\n position: 'relative',\n }}\n >\n <Box>\n {dataTransfer.files.length > 0 && (\n <>\n <Box\n sx={{\n alignItems: 'center',\n backgroundColor: (theme) => theme.palette.background.paper,\n display: 'flex',\n gap: 1,\n paddingY: 1,\n position: 'sticky',\n top: 0,\n zIndex: (theme) => theme.zIndex.tooltip - 1,\n }}\n >\n <Typography\n variant={'h5'}\n >\n {t('Selected files: {{numFiles}}', { numFiles: dataTransfer.files.length })}\n </Typography>\n <IconButton\n aria-label={t('Clear all selected files')}\n onClick={onClearAllButtonClick}\n size={'small'}\n >\n <DeleteIcon fontSize={'small'} />\n </IconButton>\n </Box>\n <Stack\n direction={'row'}\n sx={{\n flexWrap: 'wrap',\n }}\n >\n {Array.from(dataTransfer.files).map(file => (\n <Chip\n deleteIcon={(\n <DeleteIcon\n aria-hidden={false}\n aria-label={t('Clear {{fileName}}', { fileName: file.name })}\n focusable\n // eslint-disable-next-line @eslint-react/kit/jsx-no-bind\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n removeFile(file.name);\n }\n }}\n tabIndex={0}\n />\n )}\n icon={<InsertDriveFileIcon />}\n key={`${file.name}-${file.size}-${file.lastModified}`}\n label={\n (\n <>\n <Box\n component={'span'}\n sx={{ fontWeight: 'bold' }}\n >\n {file.name}\n </Box>\n <Box component={'span'}>\n {' '}\n {t('(size: {{size}})', { size: FileUtil.getReadableFileSize(file.size) })}\n {' '}\n {t('(last modified: {{lastModified}})', { lastModified: format(new Date(file.lastModified), DATE_FORMAT.DATE_TIME) })}\n </Box>\n </>\n )\n }\n // eslint-disable-next-line @eslint-react/kit/jsx-no-bind\n onDelete={() => {\n removeFile(file.name);\n }}\n sx={{\n margin: 0.25,\n }}\n tabIndex={-1}\n variant={'outlined'}\n />\n ))}\n </Stack>\n </>\n )}\n </Box>\n </Box>\n </Box>\n </>\n );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C,EAAM,eAAe,GACrB,EAAW,EAAK,IAAI;MAExB;MACA,UAAU;KACX,CAAA;KAEH,MAAM,kBAAC,GAAD,CAAsB,CAAA;KAE5B,OAEI,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;MACE,WAAW;MACX,IAAI,EAAE,YAAY,OAAO;MAExB,UAAA,EAAK;KACH,CAAA,GACL,kBAAC,GAAD;MAAK,WAAW;MAAhB,UAAA;OACG;OACA,EAAE,oBAAoB,EAAE,MAAM,EAAS,oBAAoB,EAAK,IAAI,EAAE,CAAC;OACvE;OACA,EAAE,qCAAqC,EAAE,cAAc,EAAO,IAAI,KAAK,EAAK,YAAY,GAAG,EAAY,SAAS,EAAE,CAAC;MACjH;KACL,CAAA,CAAA,EAAA,CAAA;KAIN,gBAAgB;MACd,EAAW,EAAK,IAAI;KACtB;KACA,IAAI,EACF,QAAQ,IACV;KACA,UAAU;KACV,SAAS;IACV,GA5BM,GAAG,EAAK,KAAK,GAAG,EAAK,KAAK,GAAG,EAAK,cA4BxC,CACF;GACI,CAAA,CACP,EAAA,CAAA,EAED,CAAA;EACF,CAAA,CACF;CACL,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './FileUtil';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { CaseDbFileCompression as e } from "@gen-epix/api-casedb";
|
|
2
|
-
//#region src/utils/FileUtil/FileUtil.ts
|
|
3
|
-
var t = class {
|
|
4
|
-
static getFileCompressionFromFileName(t) {
|
|
5
|
-
let n = t.toLowerCase();
|
|
6
|
-
return n.endsWith(".gz") || n.endsWith(".gzip") ? e.GZIP : e.NONE;
|
|
7
|
-
}
|
|
8
|
-
static getReadableFileSize(e) {
|
|
9
|
-
return e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(2)} KB` : e < 1073741824 ? `${(e / 1048576).toFixed(2)} MB` : `${(e / 1073741824).toFixed(2)} GB`;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { t as FileUtil };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/utils/FileUtil/FileUtil.ts"],"sourcesContent":["import { CaseDbFileCompression } from '@gen-epix/api-casedb';\n\nexport class FileUtil {\n public static getFileCompressionFromFileName(fileName: string): CaseDbFileCompression {\n const lowerFileName = fileName.toLowerCase();\n if (lowerFileName.endsWith('.gz') || lowerFileName.endsWith('.gzip')) {\n return CaseDbFileCompression.GZIP;\n }\n return CaseDbFileCompression.NONE;\n }\n\n public static getReadableFileSize(sizeInBytes: number): string {\n if (sizeInBytes < 1024) {\n return `${sizeInBytes} B`;\n } else if (sizeInBytes < 1024 * 1024) {\n return `${(sizeInBytes / 1024).toFixed(2)} KB`;\n } else if (sizeInBytes < 1024 * 1024 * 1024) {\n return `${(sizeInBytes / (1024 * 1024)).toFixed(2)} MB`;\n }\n return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n }\n}\n"],"mappings":";;AAEA,IAAa,IAAb,MAAsB;CACpB,OAAc,+BAA+B,GAAyC;EACpF,IAAM,IAAgB,EAAS,YAAY;EAI3C,OAHI,EAAc,SAAS,KAAK,KAAK,EAAc,SAAS,OAAO,IAC1D,EAAsB,OAExB,EAAsB;CAC/B;CAEA,OAAc,oBAAoB,GAA6B;EAQ7D,OAPI,IAAc,OACT,GAAG,EAAY,MACb,IAAc,UAChB,IAAI,IAAc,KAAA,CAAM,QAAQ,CAAC,EAAE,OACjC,IAAc,aAChB,IAAI,IAAe,QAAA,CAAc,QAAQ,CAAC,EAAE,OAE9C,IAAI,IAAe,WAAA,CAAqB,QAAQ,CAAC,EAAE;CAC5D;AACF"}
|