@chayns-components/core 5.0.0-beta.778 → 5.0.0-beta.781
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/lib/cjs/components/accordion/Accordion.js +1 -1
- package/lib/cjs/components/accordion/Accordion.js.map +1 -1
- package/lib/cjs/components/combobox/ComboBox.js +38 -35
- package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
- package/lib/cjs/components/expandable-content/ExpandableContent.js +1 -0
- package/lib/cjs/components/expandable-content/ExpandableContent.js.map +1 -1
- package/lib/cjs/components/expandable-content/ExpandableContent.styles.js +3 -1
- package/lib/cjs/components/expandable-content/ExpandableContent.styles.js.map +1 -1
- package/lib/cjs/components/file-input/FileInput.js +4 -2
- package/lib/cjs/components/file-input/FileInput.js.map +1 -1
- package/lib/cjs/utils/fileDialog.js +10 -5
- package/lib/cjs/utils/fileDialog.js.map +1 -1
- package/lib/esm/components/accordion/Accordion.js +1 -1
- package/lib/esm/components/accordion/Accordion.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.js +34 -30
- package/lib/esm/components/combobox/ComboBox.js.map +1 -1
- package/lib/esm/components/expandable-content/ExpandableContent.js +1 -0
- package/lib/esm/components/expandable-content/ExpandableContent.js.map +1 -1
- package/lib/esm/components/expandable-content/ExpandableContent.styles.js +6 -1
- package/lib/esm/components/expandable-content/ExpandableContent.styles.js.map +1 -1
- package/lib/esm/components/file-input/FileInput.js +4 -2
- package/lib/esm/components/file-input/FileInput.js.map +1 -1
- package/lib/esm/utils/fileDialog.js +10 -5
- package/lib/esm/utils/fileDialog.js.map +1 -1
- package/lib/types/components/expandable-content/ExpandableContent.styles.d.ts +6 -2
- package/lib/types/components/file-input/FileInput.d.ts +4 -0
- package/lib/types/utils/fileDialog.d.ts +2 -1
- package/package.json +6 -6
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { createDialog, DialogType } from 'chayns-api';
|
|
1
2
|
export const selectFiles = _ref => {
|
|
2
3
|
let {
|
|
3
4
|
type,
|
|
4
|
-
multiple
|
|
5
|
+
multiple,
|
|
6
|
+
maxFileSizeInMB
|
|
5
7
|
} = _ref;
|
|
6
8
|
return new Promise(resolve => {
|
|
7
9
|
const input = document.createElement('input');
|
|
@@ -34,16 +36,19 @@ export const selectFiles = _ref => {
|
|
|
34
36
|
const fileArray = Object.values(files);
|
|
35
37
|
const filteredFileArray = fileArray.filter(file => {
|
|
36
38
|
const sizeInMB = file.size / 1024 / 1024;
|
|
39
|
+
if (maxFileSizeInMB && maxFileSizeInMB < sizeInMB) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
37
42
|
if (file.type.includes('video/') && sizeInMB > 500) {
|
|
38
43
|
return false;
|
|
39
44
|
}
|
|
40
45
|
return !(file.type.includes('image/') && sizeInMB > 64);
|
|
41
46
|
});
|
|
42
47
|
if (fileArray.length !== filteredFileArray.length) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
void createDialog({
|
|
49
|
+
type: DialogType.ALERT,
|
|
50
|
+
text: 'Einige Deiner ausgewählten Dateien sind zu groß.'
|
|
51
|
+
}).open();
|
|
47
52
|
}
|
|
48
53
|
resolve(filteredFileArray);
|
|
49
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDialog.js","names":["selectFiles","_ref","type","multiple","Promise","resolve","input","document","createElement","style","visibility","width","height","display","accept","body","appendChild","addEventListener","event","removeChild","target","files","fileArray","Object","values","filteredFileArray","filter","file","sizeInMB","size","includes","length","click","getFileAsArrayBuffer","reject","reader","FileReader","onload","e","result","Error","onerror","readAsArrayBuffer"],"sources":["../../../src/utils/fileDialog.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"fileDialog.js","names":["createDialog","DialogType","selectFiles","_ref","type","multiple","maxFileSizeInMB","Promise","resolve","input","document","createElement","style","visibility","width","height","display","accept","body","appendChild","addEventListener","event","removeChild","target","files","fileArray","Object","values","filteredFileArray","filter","file","sizeInMB","size","includes","length","ALERT","text","open","click","getFileAsArrayBuffer","reject","reader","FileReader","onload","e","result","Error","onerror","readAsArrayBuffer"],"sources":["../../../src/utils/fileDialog.ts"],"sourcesContent":["import { createDialog, DialogType } from 'chayns-api';\n\ninterface SelectFilesOptions {\n type?: string;\n multiple: boolean;\n maxFileSizeInMB?: number;\n}\n\nexport const selectFiles = ({\n type,\n multiple,\n maxFileSizeInMB,\n}: SelectFilesOptions): Promise<File[]> =>\n new Promise((resolve) => {\n const input = document.createElement('input');\n\n input.type = 'file';\n input.style.visibility = 'none';\n input.style.width = '0';\n input.style.height = '0';\n input.style.display = 'none';\n\n if (type !== '*/*' && type) {\n input.accept = type;\n }\n\n if (multiple) {\n input.multiple = true;\n }\n\n document.body.appendChild(input);\n\n input.addEventListener('change', (event) => {\n document.body.removeChild(input);\n\n if (!event.target) {\n resolve([]);\n\n return;\n }\n\n const target = event.target as HTMLInputElement;\n\n const { files } = target;\n\n if (!files) {\n resolve([]);\n\n return;\n }\n\n const fileArray = Object.values(files);\n\n const filteredFileArray = fileArray.filter((file) => {\n const sizeInMB = file.size / 1024 / 1024;\n\n if (maxFileSizeInMB && maxFileSizeInMB < sizeInMB) {\n return false;\n }\n\n if (file.type.includes('video/') && sizeInMB > 500) {\n return false;\n }\n\n return !(file.type.includes('image/') && sizeInMB > 64);\n });\n\n if (fileArray.length !== filteredFileArray.length) {\n void createDialog({\n type: DialogType.ALERT,\n text: 'Einige Deiner ausgewählten Dateien sind zu groß.',\n }).open();\n }\n\n resolve(filteredFileArray);\n });\n\n input.click();\n });\n\nexport const getFileAsArrayBuffer = (file: File): Promise<string | ArrayBuffer> =>\n new Promise((resolve, reject) => {\n const reader = new FileReader();\n\n reader.onload = (e) => {\n if (e.target?.result) {\n resolve(e.target.result);\n } else {\n reject(Error('Could not get array buffer.'));\n }\n };\n\n reader.onerror = reject;\n\n reader.readAsArrayBuffer(file);\n });\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,U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
|
-
|
|
1
|
+
type StyledMotionExpandableContentProps = {
|
|
2
|
+
$isOpen: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare const StyledMotionExpandableContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<{
|
|
2
5
|
slot?: string | undefined;
|
|
3
6
|
title?: string | undefined;
|
|
4
7
|
color?: string | undefined;
|
|
@@ -260,4 +263,5 @@ export declare const StyledMotionExpandableContent: import("styled-components/di
|
|
|
260
263
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
|
|
261
264
|
} & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
262
265
|
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
263
|
-
},
|
|
266
|
+
}, StyledMotionExpandableContentProps>> & string & Omit<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
267
|
+
export {};
|
|
@@ -29,6 +29,10 @@ export type FileInputProps = {
|
|
|
29
29
|
* The maximum amount of Files that can be uploaded.
|
|
30
30
|
*/
|
|
31
31
|
maxFiles?: number;
|
|
32
|
+
/**
|
|
33
|
+
* The maximum size of a file in MB.
|
|
34
|
+
*/
|
|
35
|
+
maxFileSizeInMB?: number;
|
|
32
36
|
/**
|
|
33
37
|
* A function to be executed when files are added.
|
|
34
38
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
interface SelectFilesOptions {
|
|
2
2
|
type?: string;
|
|
3
3
|
multiple: boolean;
|
|
4
|
+
maxFileSizeInMB?: number;
|
|
4
5
|
}
|
|
5
|
-
export declare const selectFiles: ({ type, multiple }: SelectFilesOptions) => Promise<File[]>;
|
|
6
|
+
export declare const selectFiles: ({ type, multiple, maxFileSizeInMB, }: SelectFilesOptions) => Promise<File[]>;
|
|
6
7
|
export declare const getFileAsArrayBuffer: (file: File) => Promise<string | ArrayBuffer>;
|
|
7
8
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.781",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -54,22 +54,22 @@
|
|
|
54
54
|
"@babel/preset-env": "^7.25.4",
|
|
55
55
|
"@babel/preset-react": "^7.24.7",
|
|
56
56
|
"@babel/preset-typescript": "^7.24.7",
|
|
57
|
-
"@types/react": "^18.3.
|
|
57
|
+
"@types/react": "^18.3.6",
|
|
58
58
|
"@types/react-dom": "^18.3.0",
|
|
59
59
|
"@types/react-helmet": "^6.1.11",
|
|
60
60
|
"@types/styled-components": "^5.1.34",
|
|
61
61
|
"@types/uuid": "^10.0.0",
|
|
62
|
-
"babel-loader": "^9.1
|
|
62
|
+
"babel-loader": "^9.2.1",
|
|
63
63
|
"cross-env": "^7.0.3",
|
|
64
64
|
"lerna": "^8.1.8",
|
|
65
65
|
"react": "^18.3.1",
|
|
66
66
|
"react-dom": "^18.3.1",
|
|
67
67
|
"styled-components": "^6.1.13",
|
|
68
|
-
"typescript": "^5.
|
|
68
|
+
"typescript": "^5.6.2"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@chayns/colors": "^2.0.0",
|
|
72
|
-
"@chayns/uac-service": "^0.0.
|
|
72
|
+
"@chayns/uac-service": "^0.0.50",
|
|
73
73
|
"@react-hook/resize-observer": "^2.0.2",
|
|
74
74
|
"clsx": "^2.1.1",
|
|
75
75
|
"react-helmet": "^6.1.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "c9d5ad057f0127fe583d7bc84deb09aeab0630c4"
|
|
89
89
|
}
|