@alveole/components 2.0.0-alpha → 2.0.0-alpha.1
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/generated/version.d.ts +1 -1
- package/dist/generated/version.d.ts.map +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/stories/index.d.ts +1 -1
- package/dist/stories/index.d.ts.map +1 -1
- package/dist/stories/index.js +1 -1
- package/dist/ui/Checkbox/Checkbox.js +2 -2
- package/dist/ui/FileDropZone/FileDropZone.d.ts +10 -0
- package/dist/ui/FileDropZone/FileDropZone.d.ts.map +1 -0
- package/dist/ui/FileDropZone/FileDropZone.js +3 -0
- package/dist/ui/FileDropZone/FileDropZone.stories.d.ts +50 -0
- package/dist/ui/FileDropZone/FileDropZone.stories.d.ts.map +1 -0
- package/dist/ui/FileDropZone/FileDropZone.stories.js +29 -0
- package/dist/ui/FileDropZone/FileDropZone.stories.sources.d.ts +10 -0
- package/dist/ui/FileDropZone/FileDropZone.stories.sources.d.ts.map +1 -0
- package/dist/ui/FileDropZone/FileDropZone.stories.sources.js +10 -0
- package/dist/ui/FileDropZone/FileDropZone.styles.d.ts +37 -0
- package/dist/ui/FileDropZone/FileDropZone.styles.d.ts.map +1 -0
- package/dist/ui/FileDropZone/FileDropZone.styles.js +35 -0
- package/dist/ui/FileDropZone/FileDropZone.web.d.ts +4 -0
- package/dist/ui/FileDropZone/FileDropZone.web.d.ts.map +1 -0
- package/dist/ui/FileDropZone/FileDropZone.web.js +11 -0
- package/dist/ui/FileDropZone/fichiersDuDataTransfer.d.ts.map +1 -0
- package/dist/ui/FileDropZone/index.d.ts +2 -0
- package/dist/ui/FileDropZone/index.d.ts.map +1 -0
- package/dist/ui/FileDropZone/index.js +1 -0
- package/dist/ui/FileDropZone/useDepotFichier.d.ts +17 -0
- package/dist/ui/FileDropZone/useDepotFichier.d.ts.map +1 -0
- package/dist/ui/FileDropZone/useDepotFichier.js +89 -0
- package/dist/ui/FormControl/FileInput.d.ts +10 -12
- package/dist/ui/FormControl/FileInput.d.ts.map +1 -1
- package/dist/ui/FormControl/FileInput.js +15 -53
- package/dist/ui/FormControl/FileInput.stories.d.ts +8 -40
- package/dist/ui/FormControl/FileInput.stories.d.ts.map +1 -1
- package/dist/ui/FormControl/FileInput.stories.js +46 -4
- package/dist/ui/FormControl/FileInput.stories.sources.d.ts +10 -0
- package/dist/ui/FormControl/FileInput.stories.sources.d.ts.map +1 -1
- package/dist/ui/FormControl/FileInput.stories.sources.js +11 -1
- package/dist/ui/FormControl/FileInput.styles.d.ts +2 -39
- package/dist/ui/FormControl/FileInput.styles.d.ts.map +1 -1
- package/dist/ui/FormControl/FileInput.styles.js +3 -32
- package/dist/ui/FormControl/FileInputListe.d.ts +11 -0
- package/dist/ui/FormControl/FileInputListe.d.ts.map +1 -0
- package/dist/ui/FormControl/FileInputListe.js +24 -0
- package/dist/ui/FormControl/fichierCorrespondAuType.d.ts +1 -0
- package/dist/ui/FormControl/fichierCorrespondAuType.d.ts.map +1 -1
- package/dist/ui/FormControl/fichierCorrespondAuType.js +5 -1
- package/dist/ui/FormControl/fichiersDuChamp.d.ts +43 -0
- package/dist/ui/FormControl/fichiersDuChamp.d.ts.map +1 -0
- package/dist/ui/FormControl/fichiersDuChamp.js +63 -0
- package/dist/ui/FormControl/useChoixDeFichier.d.ts +15 -0
- package/dist/ui/FormControl/useChoixDeFichier.d.ts.map +1 -0
- package/dist/ui/FormControl/useChoixDeFichier.js +87 -0
- package/dist/ui/FormControl/valideLeType.d.ts +1 -1
- package/dist/ui/FormControl/valideLeType.js +1 -1
- package/dist/ui/RadioGroup/RadioGroup.d.ts +3 -1
- package/dist/ui/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/dist/ui/RadioGroup/RadioGroup.js +5 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +9 -7
- package/dist/ui/DragAndDropFile/DragAndDropFile.d.ts +0 -10
- package/dist/ui/DragAndDropFile/DragAndDropFile.d.ts.map +0 -1
- package/dist/ui/DragAndDropFile/DragAndDropFile.js +0 -13
- package/dist/ui/DragAndDropFile/DragAndDropFile.stories.d.ts +0 -56
- package/dist/ui/DragAndDropFile/DragAndDropFile.stories.d.ts.map +0 -1
- package/dist/ui/DragAndDropFile/DragAndDropFile.stories.js +0 -17
- package/dist/ui/DragAndDropFile/DragAndDropFile.stories.sources.d.ts +0 -10
- package/dist/ui/DragAndDropFile/DragAndDropFile.stories.sources.d.ts.map +0 -1
- package/dist/ui/DragAndDropFile/DragAndDropFile.stories.sources.js +0 -10
- package/dist/ui/DragAndDropFile/DragAndDropFile.styles.d.ts +0 -43
- package/dist/ui/DragAndDropFile/DragAndDropFile.styles.d.ts.map +0 -1
- package/dist/ui/DragAndDropFile/DragAndDropFile.styles.js +0 -43
- package/dist/ui/DragAndDropFile/DragAndDropFile.web.d.ts +0 -3
- package/dist/ui/DragAndDropFile/DragAndDropFile.web.d.ts.map +0 -1
- package/dist/ui/DragAndDropFile/DragAndDropFile.web.js +0 -18
- package/dist/ui/DragAndDropFile/fichiersDuDataTransfer.d.ts.map +0 -1
- package/dist/ui/DragAndDropFile/index.d.ts +0 -2
- package/dist/ui/DragAndDropFile/index.d.ts.map +0 -1
- package/dist/ui/DragAndDropFile/index.js +0 -1
- package/dist/ui/DragAndDropFile/useDepotFichier.d.ts +0 -21
- package/dist/ui/DragAndDropFile/useDepotFichier.d.ts.map +0 -1
- package/dist/ui/DragAndDropFile/useDepotFichier.js +0 -77
- /package/dist/ui/{DragAndDropFile → FileDropZone}/fichiersDuDataTransfer.d.ts +0 -0
- /package/dist/ui/{DragAndDropFile → FileDropZone}/fichiersDuDataTransfer.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alveole/components",
|
|
3
|
-
"version": "2.0.0-alpha",
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "Shared UI components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,15 +33,16 @@
|
|
|
33
33
|
"@testing-library/react": "16.3.3",
|
|
34
34
|
"@testing-library/react-native": "14.0.1",
|
|
35
35
|
"@types/react-syntax-highlighter": "15.5.13",
|
|
36
|
-
"babel-preset-expo": "57.0.
|
|
36
|
+
"babel-preset-expo": "57.0.14",
|
|
37
37
|
"eslint": "10.10.0",
|
|
38
|
-
"expo": "57.0.
|
|
38
|
+
"expo": "57.0.27",
|
|
39
39
|
"expo-application": "57.0.3",
|
|
40
40
|
"expo-asset": "57.0.19",
|
|
41
41
|
"expo-document-picker": "57.0.3",
|
|
42
|
+
"expo-image-picker": "57.0.20",
|
|
42
43
|
"expo-in-app-updates": "0.12.0",
|
|
43
|
-
"expo-modules-core": "57.0.
|
|
44
|
-
"expo-router": "57.0.
|
|
44
|
+
"expo-modules-core": "57.0.21",
|
|
45
|
+
"expo-router": "57.0.25",
|
|
45
46
|
"expo-system-ui": "57.0.4",
|
|
46
47
|
"expo-web-browser": "57.0.3",
|
|
47
48
|
"jest": "29.7.0",
|
|
@@ -53,9 +54,9 @@
|
|
|
53
54
|
"react-native": "0.86.3",
|
|
54
55
|
"react-native-keyboard-controller": "1.21.9",
|
|
55
56
|
"react-native-otp-entry": "1.8.6",
|
|
56
|
-
"react-native-web": "0.21.
|
|
57
|
+
"react-native-web": "0.21.4",
|
|
57
58
|
"react-select": "5.10.2",
|
|
58
|
-
"react-syntax-highlighter": "16.1.
|
|
59
|
+
"react-syntax-highlighter": "16.1.2",
|
|
59
60
|
"tamagui": "1.144.4",
|
|
60
61
|
"test-renderer": "1.2.0"
|
|
61
62
|
},
|
|
@@ -90,6 +91,7 @@
|
|
|
90
91
|
"expo-constants": "*",
|
|
91
92
|
"expo-document-picker": "*",
|
|
92
93
|
"expo-image": "*",
|
|
94
|
+
"expo-image-picker": "*",
|
|
93
95
|
"expo-in-app-updates": "*",
|
|
94
96
|
"expo-router": "*",
|
|
95
97
|
"expo-web-browser": "*",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileInputProps, FileInputValue, FormControlCaptionProps, FormControlHintProps } from '../FormControl';
|
|
3
|
-
import { Leading } from '../Leading';
|
|
4
|
-
export type DragAndDropFileValue = FileInputValue;
|
|
5
|
-
export type DragAndDropFileProps = FormControlHintProps & FormControlCaptionProps & FileInputProps & {
|
|
6
|
-
label: string;
|
|
7
|
-
leading?: Leading;
|
|
8
|
-
};
|
|
9
|
-
export declare const DragAndDropFile: (props: DragAndDropFileProps) => React.JSX.Element;
|
|
10
|
-
//# sourceMappingURL=DragAndDropFile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDropFile.d.ts","sourceRoot":"","sources":["../../../src/ui/DragAndDropFile/DragAndDropFile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAEL,cAAc,EACd,cAAc,EAEd,uBAAuB,EAEvB,oBAAoB,EAErB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AAGlD,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAClD,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GACrD,uBAAuB,GACvB,cAAc,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEJ,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,sBAuD1D,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Box } from '../../core/Box';
|
|
4
|
-
import { Image } from '../../core/Image';
|
|
5
|
-
import { FileInput, FormControlCaption, FormControlHint, FormControlLabel, } from '../FormControl';
|
|
6
|
-
import { LeadingSlot } from '../Leading';
|
|
7
|
-
import { useStyles } from './DragAndDropFile.styles';
|
|
8
|
-
export const DragAndDropFile = (props) => {
|
|
9
|
-
const { label, hint, leading, type, error, success, multiple } = props;
|
|
10
|
-
const styles = useStyles();
|
|
11
|
-
const [forceOpen, setForceOpen] = React.useState(false);
|
|
12
|
-
return (_jsxs(Box, { tag: "drag-and-drop-file", style: styles.container, display: "flex", flexDirection: "row", justify: "space-between", onPress: () => setForceOpen(true), children: [_jsxs(Box, { children: [_jsxs(Box, { tag: "drag-and-drop-file-icon", display: "flex", flexDirection: "row", justify: "center", gap: '050', children: [_jsx(LeadingSlot, { contenu: leading === undefined ? 'Upload' : leading, apparence: { size: 'md' } }), _jsx(Box, { mt: 'auto', mb: 'auto', children: _jsx(FormControlLabel, { label: label }) })] }), _jsx(Box, { tag: "drag-and-drop-file-hint", display: "flex", flexDirection: "row", justify: "center", children: hint && _jsx(FormControlHint, { hint: hint }) }), _jsx(Box, { tag: "drag-and-drop-file-input", children: _jsx(FileInput, { ...props, hideButton: true, hideFilename: true, canChange: false, reopen: forceOpen, onPickStart: () => setForceOpen(false), type: type, multiple: multiple }) }), (error || success) && (_jsx(Box, { tag: "drag-and-drop-file-error", mt: '075', display: "flex", flexDirection: "row", justify: "center", children: _jsx(Box, { p: 16, children: _jsx(FormControlCaption, { ...props }) }) }))] }), _jsx(Box, { children: props.previewURL && _jsx(Image, { source: { uri: props.previewURL }, height: 40, width: 30, contentFit: "cover" }) })] }));
|
|
13
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
title: string;
|
|
3
|
-
tags: "ui"[];
|
|
4
|
-
experimental: false;
|
|
5
|
-
webOnly: true;
|
|
6
|
-
description: string;
|
|
7
|
-
component: (props: import("./DragAndDropFile").DragAndDropFileProps) => import("react").JSX.Element;
|
|
8
|
-
styleFn: () => {
|
|
9
|
-
container: {
|
|
10
|
-
borderWidth: number;
|
|
11
|
-
borderStyle: "dashed";
|
|
12
|
-
borderColor: string;
|
|
13
|
-
padding: string | number;
|
|
14
|
-
borderRadius: import("@alveole/theme").Radius;
|
|
15
|
-
backgroundColor: string;
|
|
16
|
-
cursor: "pointer";
|
|
17
|
-
};
|
|
18
|
-
containerHover: {
|
|
19
|
-
borderStyle: "solid";
|
|
20
|
-
borderColor: string;
|
|
21
|
-
backgroundColor: string;
|
|
22
|
-
};
|
|
23
|
-
containerMouseHover: {
|
|
24
|
-
borderStyle: "dashed";
|
|
25
|
-
borderColor: string;
|
|
26
|
-
backgroundColor: string;
|
|
27
|
-
};
|
|
28
|
-
containerError: {
|
|
29
|
-
borderStyle: "dashed";
|
|
30
|
-
borderColor: string;
|
|
31
|
-
backgroundColor: string;
|
|
32
|
-
};
|
|
33
|
-
webError: {
|
|
34
|
-
width: "100%";
|
|
35
|
-
alignItems: "center";
|
|
36
|
-
};
|
|
37
|
-
icon: {
|
|
38
|
-
color: string;
|
|
39
|
-
backgroundColor: string;
|
|
40
|
-
padding: string | number;
|
|
41
|
-
borderRadius: import("@alveole/theme").Radius;
|
|
42
|
-
width: import("@alveole/theme").Spacing;
|
|
43
|
-
height: import("@alveole/theme").Spacing;
|
|
44
|
-
marginBottom: string | number;
|
|
45
|
-
};
|
|
46
|
-
fileName: {
|
|
47
|
-
fontWeight: "bold";
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
export default _default;
|
|
52
|
-
export declare const Default: () => import("react").JSX.Element;
|
|
53
|
-
export declare const Multiple: () => import("react").JSX.Element;
|
|
54
|
-
export declare const WithError: () => import("react").JSX.Element;
|
|
55
|
-
export * as Sources from './DragAndDropFile.stories.sources';
|
|
56
|
-
//# sourceMappingURL=DragAndDropFile.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDropFile.stories.d.ts","sourceRoot":"","sources":["../../../src/ui/DragAndDropFile/DragAndDropFile.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wBAQkB;AAElB,eAAO,MAAM,OAAO,mCAKnB,CAAC;AAEF,eAAO,MAAM,QAAQ,mCAEpB,CAAC;AAEF,eAAO,MAAM,SAAS,mCAErB,CAAC;AAEF,OAAO,KAAK,OAAO,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box } from '../../core/Box';
|
|
3
|
-
import { DragAndDropFile } from './DragAndDropFile';
|
|
4
|
-
import { useStyles } from './DragAndDropFile.styles';
|
|
5
|
-
export default {
|
|
6
|
-
title: 'DragAndDropFile',
|
|
7
|
-
tags: ['ui'],
|
|
8
|
-
experimental: false,
|
|
9
|
-
webOnly: true,
|
|
10
|
-
description: 'Zone de dépôt de fichiers par glisser-déposer ou clic.',
|
|
11
|
-
component: DragAndDropFile,
|
|
12
|
-
styleFn: useStyles,
|
|
13
|
-
};
|
|
14
|
-
export const Default = () => (_jsxs(Box, { display: "flex", flexDirection: "column", gap: 24, children: [_jsx(DragAndDropFile, { label: "Document", value: null, onChange: () => { } }), _jsx(DragAndDropFile, { label: "Image uniquement", type: "image/*", value: null, onChange: () => { } })] }));
|
|
15
|
-
export const Multiple = () => (_jsx(DragAndDropFile, { label: "Documents (plusieurs)", multiple: true, value: null, onChange: () => { } }));
|
|
16
|
-
export const WithError = () => (_jsx(DragAndDropFile, { label: "Document", error: "Format non support\u00E9", value: null, onChange: () => { } }));
|
|
17
|
-
export * as Sources from './DragAndDropFile.stories.sources';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const Default: () => string;
|
|
2
|
-
export declare const Multiple: () => string;
|
|
3
|
-
export declare const WithError: () => string;
|
|
4
|
-
export declare const storySources: {
|
|
5
|
-
readonly Default: () => string;
|
|
6
|
-
readonly Multiple: () => string;
|
|
7
|
-
readonly WithError: () => string;
|
|
8
|
-
};
|
|
9
|
-
export type StorySourceName = keyof typeof storySources;
|
|
10
|
-
//# sourceMappingURL=DragAndDropFile.stories.sources.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDropFile.stories.sources.d.ts","sourceRoot":"","sources":["../../../src/ui/DragAndDropFile/DragAndDropFile.stories.sources.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,cAAsS,CAAC;AAE3T,eAAO,MAAM,QAAQ,cAA+I,CAAC;AAErK,eAAO,MAAM,SAAS,cAAwJ,CAAC;AAE/K,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,YAAY,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// This file is generated. Do not edit manually.
|
|
2
|
-
// Source: src/ui/DragAndDropFile/DragAndDropFile.stories.tsx
|
|
3
|
-
export const Default = () => "export const Default = () => (\n <Box display=\"flex\" flexDirection=\"column\" gap={24}>\n <DragAndDropFile label=\"Document\" value={null} onChange={() => {}} />\n <DragAndDropFile label=\"Image uniquement\" type=\"image/*\" value={null} onChange={() => {}} />\n </Box>\n);";
|
|
4
|
-
export const Multiple = () => "export const Multiple = () => (\n <DragAndDropFile label=\"Documents (plusieurs)\" multiple value={null} onChange={() => {}} />\n);";
|
|
5
|
-
export const WithError = () => "export const WithError = () => (\n <DragAndDropFile label=\"Document\" error=\"Format non supporté\" value={null} onChange={() => {}} />\n);";
|
|
6
|
-
export const storySources = {
|
|
7
|
-
Default,
|
|
8
|
-
Multiple,
|
|
9
|
-
WithError,
|
|
10
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export declare const useStyles: () => {
|
|
2
|
-
container: {
|
|
3
|
-
borderWidth: number;
|
|
4
|
-
borderStyle: "dashed";
|
|
5
|
-
borderColor: string;
|
|
6
|
-
padding: string | number;
|
|
7
|
-
borderRadius: import("@alveole/theme").Radius;
|
|
8
|
-
backgroundColor: string;
|
|
9
|
-
cursor: "pointer";
|
|
10
|
-
};
|
|
11
|
-
containerHover: {
|
|
12
|
-
borderStyle: "solid";
|
|
13
|
-
borderColor: string;
|
|
14
|
-
backgroundColor: string;
|
|
15
|
-
};
|
|
16
|
-
containerMouseHover: {
|
|
17
|
-
borderStyle: "dashed";
|
|
18
|
-
borderColor: string;
|
|
19
|
-
backgroundColor: string;
|
|
20
|
-
};
|
|
21
|
-
containerError: {
|
|
22
|
-
borderStyle: "dashed";
|
|
23
|
-
borderColor: string;
|
|
24
|
-
backgroundColor: string;
|
|
25
|
-
};
|
|
26
|
-
webError: {
|
|
27
|
-
width: "100%";
|
|
28
|
-
alignItems: "center";
|
|
29
|
-
};
|
|
30
|
-
icon: {
|
|
31
|
-
color: string;
|
|
32
|
-
backgroundColor: string;
|
|
33
|
-
padding: string | number;
|
|
34
|
-
borderRadius: import("@alveole/theme").Radius;
|
|
35
|
-
width: import("@alveole/theme").Spacing;
|
|
36
|
-
height: import("@alveole/theme").Spacing;
|
|
37
|
-
marginBottom: string | number;
|
|
38
|
-
};
|
|
39
|
-
fileName: {
|
|
40
|
-
fontWeight: "bold";
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=DragAndDropFile.styles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDropFile.styles.d.ts","sourceRoot":"","sources":["../../../src/ui/DragAndDropFile/DragAndDropFile.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCnB,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from '@alveole/theme';
|
|
2
|
-
export const useStyles = makeStyles(({ color, spacing, spacingValue, radius }) => ({
|
|
3
|
-
container: {
|
|
4
|
-
borderWidth: 1,
|
|
5
|
-
borderStyle: 'dashed',
|
|
6
|
-
borderColor: color.border['contrast-grey'],
|
|
7
|
-
padding: spacing('4W'),
|
|
8
|
-
borderRadius: radius('lg'),
|
|
9
|
-
backgroundColor: color.alpha(color.background['alt-grey'], 0.3),
|
|
10
|
-
cursor: 'pointer',
|
|
11
|
-
},
|
|
12
|
-
containerHover: {
|
|
13
|
-
borderStyle: 'solid',
|
|
14
|
-
borderColor: color.border['disabled-grey'],
|
|
15
|
-
backgroundColor: color.alpha(color.background['alt-grey'], 0.25),
|
|
16
|
-
},
|
|
17
|
-
containerMouseHover: {
|
|
18
|
-
borderStyle: 'dashed',
|
|
19
|
-
borderColor: color.border['contrast-grey'],
|
|
20
|
-
backgroundColor: color.alpha(color.background['alt-grey'], 0.75),
|
|
21
|
-
},
|
|
22
|
-
containerError: {
|
|
23
|
-
borderStyle: 'dashed',
|
|
24
|
-
borderColor: color.alpha(color.border['plain-error'], 0.5),
|
|
25
|
-
backgroundColor: color.alpha(color.background['alt-grey'], 0.25),
|
|
26
|
-
},
|
|
27
|
-
webError: {
|
|
28
|
-
width: '100%',
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
},
|
|
31
|
-
icon: {
|
|
32
|
-
color: color.text.mention,
|
|
33
|
-
backgroundColor: color.background['alt-grey'],
|
|
34
|
-
padding: spacing('2W'),
|
|
35
|
-
borderRadius: radius('lg'),
|
|
36
|
-
width: spacingValue('200'),
|
|
37
|
-
height: spacingValue('200'),
|
|
38
|
-
marginBottom: spacing('2W'),
|
|
39
|
-
},
|
|
40
|
-
fileName: {
|
|
41
|
-
fontWeight: 'bold',
|
|
42
|
-
},
|
|
43
|
-
}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDropFile.web.d.ts","sourceRoot":"","sources":["../../../src/ui/DragAndDropFile/DragAndDropFile.web.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAIzD,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,gCA6D1D,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box } from '../../core/Box';
|
|
3
|
-
import { FileInput, FormControlCaption, FormControlHint, FormControlLabel } from '../FormControl';
|
|
4
|
-
import { LeadingSlot } from '../Leading';
|
|
5
|
-
import { useStyles } from './DragAndDropFile.styles';
|
|
6
|
-
import { useDepotFichier } from './useDepotFichier';
|
|
7
|
-
export const DragAndDropFile = (props) => {
|
|
8
|
-
const { label, hint, leading, type, error, success, multiple } = props;
|
|
9
|
-
const styles = useStyles();
|
|
10
|
-
const depot = useDepotFichier(props);
|
|
11
|
-
const styleContainer = {
|
|
12
|
-
...styles.container,
|
|
13
|
-
...(depot.isMouseOver ? styles.containerMouseHover : {}),
|
|
14
|
-
...(depot.isOver ? styles.containerHover : {}),
|
|
15
|
-
...(error ? styles.containerError : {}),
|
|
16
|
-
};
|
|
17
|
-
return (_jsxs("div", { tabIndex: 0, onDrop: depot.onDrop, onDragOver: depot.onDragOver, onDragEnter: depot.onDragOver, onDragLeave: depot.onDragLeave, onMouseOver: depot.onMouseOver, onMouseEnter: depot.onMouseOver, onMouseLeave: depot.onMouseLeave, onClick: depot.ouvrir, style: styleContainer, children: [_jsx(Box, { tag: "drag-and-drop-file-icon", display: "flex", flexDirection: "row", justify: "center", children: _jsx(LeadingSlot, { contenu: leading === undefined ? 'Upload' : leading, apparence: { size: 'xl', style: styles.icon } }) }), _jsx(Box, { tag: "drag-and-drop-file-label", display: "flex", flexDirection: "row", justify: "center", children: _jsx(FormControlLabel, { label: label }) }), _jsx(Box, { tag: "drag-and-drop-file-hint", display: "flex", flexDirection: "row", justify: "center", children: hint && _jsx(FormControlHint, { hint: hint }) }), _jsx(Box, { tag: "drag-and-drop-file-input", display: "flex", flexDirection: "row", justify: "center", children: _jsx(Box, { pt: 16, children: _jsx(FileInput, { ...props, canChange: false, reopen: depot.forceOpen, onPickStart: depot.fermer, multiple: multiple, type: type }) }) }), (error || success) && (_jsx(Box, { tag: "drag-and-drop-file-error", style: styles.webError, children: _jsx(FormControlCaption, { ...props }) }))] }));
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fichiersDuDataTransfer.d.ts","sourceRoot":"","sources":["../../../src/ui/DragAndDropFile/fichiersDuDataTransfer.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,IAAI,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAE7D;;;;;GAKG;AACH,KAAK,eAAe,GAAG;IAAE,KAAK,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAQrG;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,IAAI,eAAe,KAAG,IAAI,EAIhE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/DragAndDropFile/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './DragAndDropFile';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileInputProps } from '../FormControl';
|
|
3
|
-
/**
|
|
4
|
-
* Tout ce que la zone de depot fait en plus du champ de fichier ordinaire : suivre le survol et
|
|
5
|
-
* le survol de glissement, convertir les fichiers laches en valeurs du champ, et liberer les URL
|
|
6
|
-
* d'objet. Ecrit dans le composant, ce comportement en occupait les cinq sixiemes et noyait le
|
|
7
|
-
* peu de rendu qu'il contient.
|
|
8
|
-
*/
|
|
9
|
-
export declare const useDepotFichier: ({ value, type, multiple, onChange, }: Pick<FileInputProps, "value" | "type" | "multiple" | "onChange">) => {
|
|
10
|
-
isOver: boolean;
|
|
11
|
-
isMouseOver: boolean;
|
|
12
|
-
forceOpen: boolean;
|
|
13
|
-
ouvrir: () => void;
|
|
14
|
-
fermer: () => void;
|
|
15
|
-
onDrop: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
16
|
-
onDragOver: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
17
|
-
onDragLeave: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
18
|
-
onMouseOver: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
19
|
-
onMouseLeave: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=useDepotFichier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDepotFichier.d.ts","sourceRoot":"","sources":["../../../src/ui/DragAndDropFile/useDepotFichier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAA2B,cAAc,EAAgC,MAAM,gBAAgB,CAAC;AA0BvG;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,sCAK7B,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;;;;;;gBAuB9C,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;oBAS0B,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;qBAA/B,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;qBAA/B,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;sBAA/B,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;CAmB5G,CAAC"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Alert } from '../../core/Alert';
|
|
3
|
-
import { fichierCorrespondAuType, valideLeType } from '../FormControl';
|
|
4
|
-
import { fichiersDuDataTransfer } from './fichiersDuDataTransfer';
|
|
5
|
-
const enAsset = (file) => ({
|
|
6
|
-
uri: URL.createObjectURL(file),
|
|
7
|
-
name: file.name,
|
|
8
|
-
size: file.size,
|
|
9
|
-
mimeType: file.type || 'application/octet-stream',
|
|
10
|
-
lastModified: file.lastModified,
|
|
11
|
-
file,
|
|
12
|
-
});
|
|
13
|
-
// Chaque fichier depose est publie derriere une URL d'objet, que le navigateur garde en memoire
|
|
14
|
-
// tant qu'on ne la revoque pas. Sans ce nettoyage au changement de valeur, un formulaire ou
|
|
15
|
-
// l'utilisateur hesite accumule les fichiers relaches dans l'onglet.
|
|
16
|
-
const revoquer = (value) => {
|
|
17
|
-
const uris = (Array.isArray(value) ? value : [value]).map(fichier => fichier?.uri);
|
|
18
|
-
uris.forEach(uri => {
|
|
19
|
-
if (!uri?.startsWith('blob:'))
|
|
20
|
-
return;
|
|
21
|
-
try {
|
|
22
|
-
URL.revokeObjectURL(uri);
|
|
23
|
-
}
|
|
24
|
-
catch { }
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Tout ce que la zone de depot fait en plus du champ de fichier ordinaire : suivre le survol et
|
|
29
|
-
* le survol de glissement, convertir les fichiers laches en valeurs du champ, et liberer les URL
|
|
30
|
-
* d'objet. Ecrit dans le composant, ce comportement en occupait les cinq sixiemes et noyait le
|
|
31
|
-
* peu de rendu qu'il contient.
|
|
32
|
-
*/
|
|
33
|
-
export const useDepotFichier = ({ value, type, multiple, onChange, }) => {
|
|
34
|
-
const [isOver, setIsOver] = React.useState(false);
|
|
35
|
-
const [isMouseOver, setIsMouseOver] = React.useState(false);
|
|
36
|
-
const [forceOpen, setForceOpen] = React.useState(false);
|
|
37
|
-
const onValueChange = valideLeType({ type, onChange });
|
|
38
|
-
// `deposer` et `onDrop` etaient memoises en omettant `onValueChange` de leurs dependances,
|
|
39
|
-
// pour ne pas recreer les gestionnaires de glisser-deposer a chaque frappe du formulaire. Le
|
|
40
|
-
// gain etait nul : `survol` reconstruit deja les quatre autres gestionnaires a chaque rendu.
|
|
41
|
-
// Le cout, lui, etait reel : la memoisation figeait le gestionnaire du premier rendu, et un
|
|
42
|
-
// formulaire controle deposait dans un `onChange` perime.
|
|
43
|
-
const deposer = (files) => {
|
|
44
|
-
const valides = files.filter(file => fichierCorrespondAuType(file.type || '', file.name, type));
|
|
45
|
-
if (valides.length < files.length) {
|
|
46
|
-
Alert.alert({ title: 'Type de fichier incorrect', message: 'Certains fichiers ne sont pas pris en charge' });
|
|
47
|
-
}
|
|
48
|
-
if (valides.length === 0)
|
|
49
|
-
return;
|
|
50
|
-
onValueChange(multiple ? valides.map(enAsset) : enAsset(valides[0]));
|
|
51
|
-
};
|
|
52
|
-
const onDrop = (e) => {
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
e.stopPropagation();
|
|
55
|
-
setIsOver(false);
|
|
56
|
-
const files = fichiersDuDataTransfer(e.dataTransfer);
|
|
57
|
-
if (files.length > 0)
|
|
58
|
-
deposer(multiple ? files : [files[0]]);
|
|
59
|
-
};
|
|
60
|
-
const survol = (actif, appliquer) => (e) => {
|
|
61
|
-
e.preventDefault();
|
|
62
|
-
appliquer(actif);
|
|
63
|
-
};
|
|
64
|
-
React.useEffect(() => () => revoquer(value), [value]);
|
|
65
|
-
return {
|
|
66
|
-
isOver,
|
|
67
|
-
isMouseOver,
|
|
68
|
-
forceOpen,
|
|
69
|
-
ouvrir: () => setForceOpen(true),
|
|
70
|
-
fermer: () => setForceOpen(false),
|
|
71
|
-
onDrop,
|
|
72
|
-
onDragOver: survol(true, setIsOver),
|
|
73
|
-
onDragLeave: survol(false, setIsOver),
|
|
74
|
-
onMouseOver: survol(true, setIsMouseOver),
|
|
75
|
-
onMouseLeave: survol(false, setIsMouseOver),
|
|
76
|
-
};
|
|
77
|
-
};
|
|
File without changes
|
|
File without changes
|