@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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const ALVEOLE_COMPONENTS_VERSION: "2.0.0-alpha";
|
|
1
|
+
export declare const ALVEOLE_COMPONENTS_VERSION: "2.0.0-alpha.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/generated/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,EAAG,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/generated/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,EAAG,eAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ALVEOLE_COMPONENTS_VERSION = "2.0.0-alpha";
|
|
1
|
+
export const ALVEOLE_COMPONENTS_VERSION = "2.0.0-alpha.1";
|
package/dist/stories/index.d.ts
CHANGED
|
@@ -31,9 +31,9 @@ export * as DataTableStory from '../ui/DataTable/DataTable.stories';
|
|
|
31
31
|
export * as DateInputStory from '../ui/DateInput/DateInput.stories';
|
|
32
32
|
export * as DividerStory from '../ui/Divider/Divider.stories';
|
|
33
33
|
export * as DocumentViewerStory from '../ui/DocumentViewer/DocumentViewer.stories';
|
|
34
|
-
export * as DragAndDropFileStory from '../ui/DragAndDropFile/DragAndDropFile.stories';
|
|
35
34
|
export * as DurationInputStory from '../ui/DurationInput/DurationInput.stories';
|
|
36
35
|
export * as EmptyStateStory from '../ui/EmptyState/EmptyState.stories';
|
|
36
|
+
export * as FileDropZoneStory from '../ui/FileDropZone/FileDropZone.stories';
|
|
37
37
|
export * as FilterDateStory from '../ui/FilterDate/FilterDate.stories';
|
|
38
38
|
export * as FileInputStory from '../ui/FormControl/FileInput.stories';
|
|
39
39
|
export * as FormControlStory from '../ui/FormControl/FormControl.stories';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stories/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,kBAAkB,MAAM,6CAA6C,CAAC;AAClF,OAAO,KAAK,wBAAwB,M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AAqC,CAAC;AACvE,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,gBAAgB,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,iBAAiB,MAAM,yCAAyC,CAAC;AAC7E,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,aAAa,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,kBAAkB,MAAM,2CAA2C,CAAC;AAChF,OAAO,KAAK,mBAAmB,MAAM,6CAA6C,CAAC;AACnF,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,qBAAqB,MAAM,iDAAiD,CAAC;AACzF,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC"}
|
package/dist/stories/index.js
CHANGED
|
@@ -33,9 +33,9 @@ export * as DataTableStory from '../ui/DataTable/DataTable.stories';
|
|
|
33
33
|
export * as DateInputStory from '../ui/DateInput/DateInput.stories';
|
|
34
34
|
export * as DividerStory from '../ui/Divider/Divider.stories';
|
|
35
35
|
export * as DocumentViewerStory from '../ui/DocumentViewer/DocumentViewer.stories';
|
|
36
|
-
export * as DragAndDropFileStory from '../ui/DragAndDropFile/DragAndDropFile.stories';
|
|
37
36
|
export * as DurationInputStory from '../ui/DurationInput/DurationInput.stories';
|
|
38
37
|
export * as EmptyStateStory from '../ui/EmptyState/EmptyState.stories';
|
|
38
|
+
export * as FileDropZoneStory from '../ui/FileDropZone/FileDropZone.stories';
|
|
39
39
|
export * as FilterDateStory from '../ui/FilterDate/FilterDate.stories';
|
|
40
40
|
export * as FileInputStory from '../ui/FormControl/FileInput.stories';
|
|
41
41
|
export * as FormControlStory from '../ui/FormControl/FormControl.stories';
|
|
@@ -8,8 +8,8 @@ import { CheckboxContainer } from './CheckboxContainer';
|
|
|
8
8
|
import { CheckboxIndicator } from './CheckboxIndicator';
|
|
9
9
|
import { CheckboxLabel } from './CheckboxLabel';
|
|
10
10
|
export const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
11
|
-
const { size, variant, label, error, success, disabled
|
|
12
|
-
const baseProps = { size, variant, label, error, success, disabled
|
|
11
|
+
const { size, variant, label, error, success, disabled } = props;
|
|
12
|
+
const baseProps = { size, variant, label, error, success, disabled };
|
|
13
13
|
const { spacingValue } = useTheme();
|
|
14
14
|
const styles = useStyles();
|
|
15
15
|
const id = useId();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FileInputProps } from '../FormControl';
|
|
3
|
+
export type FileDropZoneProps = Pick<FileInputProps, 'value' | 'onChange' | 'type' | 'multiple' | 'disabled'> & {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** Le texte de la surcouche pendant le survol. */
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Le glisser-deposer de fichiers n'existe que sur le web : hors web, la zone rend ses enfants. */
|
|
9
|
+
export declare const FileDropZone: ({ children }: FileDropZoneProps) => React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=FileDropZone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDropZone.d.ts","sourceRoot":"","sources":["../../../src/ui/FileDropZone/FileDropZone.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC,GAAG;IAC9G,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,YAAY,GAAI,cAAc,iBAAiB,sBAAoB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
title: string;
|
|
3
|
+
tags: "ui"[];
|
|
4
|
+
experimental: false;
|
|
5
|
+
webOnly: true;
|
|
6
|
+
description: string;
|
|
7
|
+
component: ({ children }: import("./FileDropZone").FileDropZoneProps) => import("react").JSX.Element;
|
|
8
|
+
styleFn: () => {
|
|
9
|
+
conteneur: {
|
|
10
|
+
position: "relative";
|
|
11
|
+
};
|
|
12
|
+
surcouche: {
|
|
13
|
+
position: "absolute";
|
|
14
|
+
top: number;
|
|
15
|
+
right: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
left: number;
|
|
18
|
+
borderWidth: number;
|
|
19
|
+
borderStyle: "dashed";
|
|
20
|
+
borderColor: string;
|
|
21
|
+
borderRadius: import("@alveole/theme").Radius;
|
|
22
|
+
backgroundColor: string;
|
|
23
|
+
alignItems: "center";
|
|
24
|
+
justifyContent: "center";
|
|
25
|
+
pointerEvents: "none";
|
|
26
|
+
};
|
|
27
|
+
pastille: {
|
|
28
|
+
backgroundColor: string;
|
|
29
|
+
borderRadius: import("@alveole/theme").Radius;
|
|
30
|
+
paddingLeft: string | number;
|
|
31
|
+
paddingRight: string | number;
|
|
32
|
+
paddingTop: string | number;
|
|
33
|
+
paddingBottom: string | number;
|
|
34
|
+
};
|
|
35
|
+
message: {
|
|
36
|
+
color: string;
|
|
37
|
+
fontSize: 16;
|
|
38
|
+
lineHeight: 24;
|
|
39
|
+
letterSpacing: 0;
|
|
40
|
+
fontFamily: string;
|
|
41
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export default _default;
|
|
46
|
+
export declare const Formulaire: () => import("react").JSX.Element;
|
|
47
|
+
export declare const Desactivee: () => import("react").JSX.Element;
|
|
48
|
+
export declare const MessagePersonnalise: () => import("react").JSX.Element;
|
|
49
|
+
export * as Sources from './FileDropZone.stories.sources';
|
|
50
|
+
//# sourceMappingURL=FileDropZone.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDropZone.stories.d.ts","sourceRoot":"","sources":["../../../src/ui/FileDropZone/FileDropZone.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wBASkB;AAElB,eAAO,MAAM,UAAU,mCAetB,CAAC;AAEF,eAAO,MAAM,UAAU,mCAWtB,CAAC;AAEF,eAAO,MAAM,mBAAmB,mCAW/B,CAAC;AAEF,OAAO,KAAK,OAAO,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Box } from '../../core/Box';
|
|
4
|
+
import { FileInput, FormControl, TextInput } from '../FormControl';
|
|
5
|
+
import { FileDropZone } from './FileDropZone';
|
|
6
|
+
import { useStyles } from './FileDropZone.styles';
|
|
7
|
+
export default {
|
|
8
|
+
title: 'FileDropZone',
|
|
9
|
+
tags: ['ui'],
|
|
10
|
+
experimental: false,
|
|
11
|
+
webOnly: true,
|
|
12
|
+
description: "Zone de dépôt : enveloppe une région (souvent tout un formulaire) sur laquelle on peut glisser-déposer des fichiers. Se branche sur le même état que le FileInput du formulaire. À réserver aux formulaires qui n'ont qu'un seul champ de fichier : avec plusieurs FileInput, l'utilisateur ne peut pas savoir lequel recevra le fichier déposé.",
|
|
13
|
+
component: FileDropZone,
|
|
14
|
+
styleFn: useStyles,
|
|
15
|
+
};
|
|
16
|
+
export const Formulaire = () => {
|
|
17
|
+
const [titre, setTitre] = useState('');
|
|
18
|
+
const [fichiers, setFichiers] = useState(null);
|
|
19
|
+
return (_jsx(FileDropZone, { value: fichiers, onChange: setFichiers, multiple: true, children: _jsxs(Box, { display: "flex", flexDirection: "column", gap: 16, p: 16, children: [_jsx(FormControl, { label: "Titre", children: _jsx(TextInput, { value: titre, onChangeText: setTitre }) }), _jsx(FormControl, { label: "Pi\u00E8ces jointes", hint: "Glissez des fichiers n'importe o\u00F9 sur le formulaire.", children: _jsx(FileInput, { value: fichiers, onChange: setFichiers, multiple: true }) })] }) }));
|
|
20
|
+
};
|
|
21
|
+
export const Desactivee = () => {
|
|
22
|
+
const [fichiers, setFichiers] = useState(null);
|
|
23
|
+
return (_jsx(FileDropZone, { value: fichiers, onChange: setFichiers, multiple: true, disabled: true, children: _jsx(Box, { p: 16, children: _jsx(FormControl, { label: "Pi\u00E8ces jointes", disabled: true, children: _jsx(FileInput, { value: fichiers, onChange: setFichiers, multiple: true, disabled: true }) }) }) }));
|
|
24
|
+
};
|
|
25
|
+
export const MessagePersonnalise = () => {
|
|
26
|
+
const [photo, setPhoto] = useState(null);
|
|
27
|
+
return (_jsx(FileDropZone, { value: photo, onChange: setPhoto, type: "image/*", message: "L\u00E2chez la photo pour l'ajouter", children: _jsx(Box, { p: 16, children: _jsx(FormControl, { label: "Photo", children: _jsx(FileInput, { value: photo, onChange: setPhoto, type: "image/*" }) }) }) }));
|
|
28
|
+
};
|
|
29
|
+
export * as Sources from './FileDropZone.stories.sources';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const Formulaire: () => string;
|
|
2
|
+
export declare const Desactivee: () => string;
|
|
3
|
+
export declare const MessagePersonnalise: () => string;
|
|
4
|
+
export declare const storySources: {
|
|
5
|
+
readonly Formulaire: () => string;
|
|
6
|
+
readonly Desactivee: () => string;
|
|
7
|
+
readonly MessagePersonnalise: () => string;
|
|
8
|
+
};
|
|
9
|
+
export type StorySourceName = keyof typeof storySources;
|
|
10
|
+
//# sourceMappingURL=FileDropZone.stories.sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDropZone.stories.sources.d.ts","sourceRoot":"","sources":["../../../src/ui/FileDropZone/FileDropZone.stories.sources.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,cAA6qB,CAAC;AAErsB,eAAO,MAAM,UAAU,cAA8a,CAAC;AAEtc,eAAO,MAAM,mBAAmB,cAA4b,CAAC;AAE7d,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file is generated. Do not edit manually.
|
|
2
|
+
// Source: src/ui/FileDropZone/FileDropZone.stories.tsx
|
|
3
|
+
export const Formulaire = () => "export const Formulaire = () => {\n const [titre, setTitre] = useState('');\n const [fichiers, setFichiers] = useState<FileInputValue>(null);\n return (\n <FileDropZone value={fichiers} onChange={setFichiers} multiple>\n <Box display=\"flex\" flexDirection=\"column\" gap={16} p={16}>\n <FormControl label=\"Titre\">\n <TextInput value={titre} onChangeText={setTitre} />\n </FormControl>\n <FormControl label=\"Pièces jointes\" hint=\"Glissez des fichiers n'importe où sur le formulaire.\">\n <FileInput value={fichiers} onChange={setFichiers} multiple />\n </FormControl>\n </Box>\n </FileDropZone>\n );\n};";
|
|
4
|
+
export const Desactivee = () => "export const Desactivee = () => {\n const [fichiers, setFichiers] = useState<FileInputValue>(null);\n return (\n <FileDropZone value={fichiers} onChange={setFichiers} multiple disabled>\n <Box p={16}>\n <FormControl label=\"Pièces jointes\" disabled>\n <FileInput value={fichiers} onChange={setFichiers} multiple disabled />\n </FormControl>\n </Box>\n </FileDropZone>\n );\n};";
|
|
5
|
+
export const MessagePersonnalise = () => "export const MessagePersonnalise = () => {\n const [photo, setPhoto] = useState<FileInputValue>(null);\n return (\n <FileDropZone value={photo} onChange={setPhoto} type=\"image/*\" message=\"Lâchez la photo pour l'ajouter\">\n <Box p={16}>\n <FormControl label=\"Photo\">\n <FileInput value={photo} onChange={setPhoto} type=\"image/*\" />\n </FormControl>\n </Box>\n </FileDropZone>\n );\n};";
|
|
6
|
+
export const storySources = {
|
|
7
|
+
Formulaire,
|
|
8
|
+
Desactivee,
|
|
9
|
+
MessagePersonnalise,
|
|
10
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
conteneur: {
|
|
3
|
+
position: "relative";
|
|
4
|
+
};
|
|
5
|
+
surcouche: {
|
|
6
|
+
position: "absolute";
|
|
7
|
+
top: number;
|
|
8
|
+
right: number;
|
|
9
|
+
bottom: number;
|
|
10
|
+
left: number;
|
|
11
|
+
borderWidth: number;
|
|
12
|
+
borderStyle: "dashed";
|
|
13
|
+
borderColor: string;
|
|
14
|
+
borderRadius: import("@alveole/theme").Radius;
|
|
15
|
+
backgroundColor: string;
|
|
16
|
+
alignItems: "center";
|
|
17
|
+
justifyContent: "center";
|
|
18
|
+
pointerEvents: "none";
|
|
19
|
+
};
|
|
20
|
+
pastille: {
|
|
21
|
+
backgroundColor: string;
|
|
22
|
+
borderRadius: import("@alveole/theme").Radius;
|
|
23
|
+
paddingLeft: string | number;
|
|
24
|
+
paddingRight: string | number;
|
|
25
|
+
paddingTop: string | number;
|
|
26
|
+
paddingBottom: string | number;
|
|
27
|
+
};
|
|
28
|
+
message: {
|
|
29
|
+
color: string;
|
|
30
|
+
fontSize: 16;
|
|
31
|
+
lineHeight: 24;
|
|
32
|
+
letterSpacing: 0;
|
|
33
|
+
fontFamily: string;
|
|
34
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=FileDropZone.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDropZone.styles.d.ts","sourceRoot":"","sources":["../../../src/ui/FileDropZone/FileDropZone.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCnB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { makeStyles } from '@alveole/theme';
|
|
2
|
+
export const useStyles = makeStyles(({ color, radius, spacing, text }) => ({
|
|
3
|
+
conteneur: {
|
|
4
|
+
position: 'relative',
|
|
5
|
+
},
|
|
6
|
+
// Posee sur le contenu sans le deplacer ni capter les clics : le formulaire reste lisible dessous.
|
|
7
|
+
surcouche: {
|
|
8
|
+
position: 'absolute',
|
|
9
|
+
top: 0,
|
|
10
|
+
right: 0,
|
|
11
|
+
bottom: 0,
|
|
12
|
+
left: 0,
|
|
13
|
+
borderWidth: 2,
|
|
14
|
+
borderStyle: 'dashed',
|
|
15
|
+
borderColor: color.light.border['plain-info'],
|
|
16
|
+
borderRadius: radius('lg'),
|
|
17
|
+
backgroundColor: color.alpha(color.light.background['flat-info'], 0.1),
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
justifyContent: 'center',
|
|
20
|
+
pointerEvents: 'none',
|
|
21
|
+
},
|
|
22
|
+
// Pastille opaque : le message reste lisible quel que soit le champ qu'il recouvre.
|
|
23
|
+
pastille: {
|
|
24
|
+
backgroundColor: color.light.background['default-grey'],
|
|
25
|
+
borderRadius: radius('lg'),
|
|
26
|
+
paddingLeft: spacing('2W'),
|
|
27
|
+
paddingRight: spacing('2W'),
|
|
28
|
+
paddingTop: spacing('1W'),
|
|
29
|
+
paddingBottom: spacing('1W'),
|
|
30
|
+
},
|
|
31
|
+
message: {
|
|
32
|
+
...text['Corps de texte'].MD.Bold,
|
|
33
|
+
color: color.light.text['default-info'],
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDropZone.web.d.ts","sourceRoot":"","sources":["../../../src/ui/FileDropZone/FileDropZone.web.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAInD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,gCAwBpD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '../../core/Box';
|
|
3
|
+
import { Typography } from '../../core/Typography';
|
|
4
|
+
import { useStyles } from './FileDropZone.styles';
|
|
5
|
+
import { useDepotFichier } from './useDepotFichier';
|
|
6
|
+
export const FileDropZone = (props) => {
|
|
7
|
+
const { children, message = 'Déposez vos fichiers ici' } = props;
|
|
8
|
+
const styles = useStyles();
|
|
9
|
+
const depot = useDepotFichier(props);
|
|
10
|
+
return (_jsxs("div", { "data-testid": "file-drop-zone", style: styles.conteneur, onDragEnter: depot.onDragEnter, onDragOver: depot.onDragOver, onDragLeave: depot.onDragLeave, onDrop: depot.onDrop, children: [children, depot.actif && (_jsx(Box, { tag: "file-drop-zone-overlay", style: styles.surcouche, children: _jsx(Box, { tag: "file-drop-zone-message", style: styles.pastille, children: _jsx(Typography, { style: styles.message, children: message }) }) }))] }));
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fichiersDuDataTransfer.d.ts","sourceRoot":"","sources":["../../../src/ui/FileDropZone/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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/FileDropZone/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FileDropZone';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FileInputProps } from '../FormControl';
|
|
3
|
+
type Options = Pick<FileInputProps, 'value' | 'type' | 'multiple' | 'onChange' | 'disabled'>;
|
|
4
|
+
/**
|
|
5
|
+
* Le comportement de la zone de depot : s'allumer quand un glissement de fichiers la survole,
|
|
6
|
+
* convertir les fichiers lâches en valeurs du champ, et liberer les URL d'objet. Chaque
|
|
7
|
+
* evenement traite s'arrete a la zone : entre zones imbriquees, seule la plus proche reagit.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useDepotFichier: ({ value, type, multiple, onChange, disabled }: Options) => {
|
|
10
|
+
actif: boolean;
|
|
11
|
+
onDragEnter: (e: React.DragEvent) => void;
|
|
12
|
+
onDragOver: (e: React.DragEvent) => void;
|
|
13
|
+
onDragLeave: (e: React.DragEvent) => void;
|
|
14
|
+
onDrop: (e: React.DragEvent) => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=useDepotFichier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDepotFichier.d.ts","sourceRoot":"","sources":["../../../src/ui/FileDropZone/useDepotFichier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAqD,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAwBnH,KAAK,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,+CAA+C,OAAO;;qBA4B5D,KAAK,CAAC,SAAS;oBAOhB,KAAK,CAAC,SAAS;qBAId,KAAK,CAAC,SAAS;gBAOpB,KAAK,CAAC,SAAS;CAsBnC,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Alert } from '../../core/Alert';
|
|
3
|
+
import { ajoute, fichierCorrespondAuType, fichiersVisibles } 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
|
+
const urisBlob = (value) => (Array.isArray(value) ? value : [value]).map(fichier => fichier?.uri).filter(uri => uri?.startsWith('blob:'));
|
|
14
|
+
const revoquer = (uris) => uris.forEach(uri => {
|
|
15
|
+
try {
|
|
16
|
+
URL.revokeObjectURL(uri);
|
|
17
|
+
}
|
|
18
|
+
catch { }
|
|
19
|
+
});
|
|
20
|
+
const contientDesFichiers = (e) => Array.from(e.dataTransfer?.types ?? []).includes('Files');
|
|
21
|
+
/**
|
|
22
|
+
* Le comportement de la zone de depot : s'allumer quand un glissement de fichiers la survole,
|
|
23
|
+
* convertir les fichiers lâches en valeurs du champ, et liberer les URL d'objet. Chaque
|
|
24
|
+
* evenement traite s'arrete a la zone : entre zones imbriquees, seule la plus proche reagit.
|
|
25
|
+
*/
|
|
26
|
+
export const useDepotFichier = ({ value, type, multiple, onChange, disabled }) => {
|
|
27
|
+
const [actif, setActif] = React.useState(false);
|
|
28
|
+
// `dragenter`/`dragleave` se declenchent a chaque enfant traverse : on compte les entrees pour
|
|
29
|
+
// ne s'eteindre qu'en quittant vraiment la zone.
|
|
30
|
+
const entreesRef = React.useRef(0);
|
|
31
|
+
// Meme regle que le bouton du champ : un champ simple qui montre deja un fichier n'en recoit pas.
|
|
32
|
+
const accepte = !disabled && (!!multiple || fichiersVisibles(value).length === 0);
|
|
33
|
+
const concerne = (e) => accepte && contientDesFichiers(e);
|
|
34
|
+
// Les gestionnaires ne sont pas memoises : un formulaire controle passe un `onChange` neuf a
|
|
35
|
+
// chaque rendu, et une memoisation figerait celui du premier rendu.
|
|
36
|
+
const deposer = (files) => {
|
|
37
|
+
const valides = files.filter(file => fichierCorrespondAuType(file.type || '', file.name, type));
|
|
38
|
+
if (valides.length < files.length) {
|
|
39
|
+
Alert.alert({ title: 'Type de fichier incorrect', message: 'Certains fichiers ne sont pas pris en charge' });
|
|
40
|
+
}
|
|
41
|
+
if (valides.length === 0)
|
|
42
|
+
return;
|
|
43
|
+
onChange(ajoute(value, (multiple ? valides : [valides[0]]).map(enAsset), !!multiple));
|
|
44
|
+
};
|
|
45
|
+
const arreter = (e) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
};
|
|
49
|
+
const onDragEnter = (e) => {
|
|
50
|
+
if (!concerne(e))
|
|
51
|
+
return;
|
|
52
|
+
arreter(e);
|
|
53
|
+
entreesRef.current += 1;
|
|
54
|
+
setActif(true);
|
|
55
|
+
};
|
|
56
|
+
const onDragOver = (e) => {
|
|
57
|
+
if (concerne(e))
|
|
58
|
+
arreter(e);
|
|
59
|
+
};
|
|
60
|
+
const onDragLeave = (e) => {
|
|
61
|
+
if (!concerne(e))
|
|
62
|
+
return;
|
|
63
|
+
arreter(e);
|
|
64
|
+
entreesRef.current = Math.max(0, entreesRef.current - 1);
|
|
65
|
+
if (entreesRef.current === 0)
|
|
66
|
+
setActif(false);
|
|
67
|
+
};
|
|
68
|
+
const onDrop = (e) => {
|
|
69
|
+
if (!concerne(e))
|
|
70
|
+
return;
|
|
71
|
+
arreter(e);
|
|
72
|
+
entreesRef.current = 0;
|
|
73
|
+
setActif(false);
|
|
74
|
+
const files = fichiersDuDataTransfer(e.dataTransfer);
|
|
75
|
+
if (files.length > 0)
|
|
76
|
+
deposer(multiple ? files : [files[0]]);
|
|
77
|
+
};
|
|
78
|
+
// Chaque fichier depose est publie derriere une URL d'objet, que le navigateur garde en memoire
|
|
79
|
+
// tant qu'on ne la revoque pas. La valeur s'accumule : on ne libere que les URL qui en sortent,
|
|
80
|
+
// et toutes au demontage.
|
|
81
|
+
const urisRef = React.useRef([]);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
const actuelles = urisBlob(value);
|
|
84
|
+
revoquer(urisRef.current.filter(uri => !actuelles.includes(uri)));
|
|
85
|
+
urisRef.current = actuelles;
|
|
86
|
+
}, [value]);
|
|
87
|
+
React.useEffect(() => () => revoquer(urisRef.current), []);
|
|
88
|
+
return { actif, onDragEnter, onDragOver, onDragLeave, onDrop };
|
|
89
|
+
};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import * as DocumentPicker from 'expo-document-picker';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
3
|
+
import { FileInputLabels, FileInputValue } from './fichiersDuChamp';
|
|
4
|
+
export * from './fichiersDuChamp';
|
|
4
5
|
export type FileInputProps = {
|
|
5
6
|
value: FileInputValue;
|
|
6
|
-
|
|
7
|
-
placeholder?: string;
|
|
8
|
-
forcePlaceholder?: boolean;
|
|
9
|
-
hideButton?: boolean;
|
|
10
|
-
hideFilename?: boolean;
|
|
11
|
-
canChange?: boolean;
|
|
12
|
-
disabled?: boolean;
|
|
7
|
+
onChange: (value: FileInputValue) => void;
|
|
13
8
|
type?: DocumentPicker.DocumentPickerOptions['type'];
|
|
14
9
|
multiple?: boolean;
|
|
15
|
-
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
removable?: boolean;
|
|
12
|
+
hideButton?: boolean;
|
|
13
|
+
labels?: Partial<FileInputLabels>;
|
|
14
|
+
/** Qualite des photos prises avec l'appareil photo, de 0 a 1. */
|
|
15
|
+
cameraQuality?: number;
|
|
16
16
|
reopen?: boolean;
|
|
17
17
|
onPickStart?: () => void;
|
|
18
18
|
};
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const choisis: (assets: DocumentPicker.DocumentPickerAsset[] | null, multiple: boolean) => DocumentPicker.DocumentPickerAsset | DocumentPicker.DocumentPickerAsset[] | null;
|
|
21
|
-
export declare const FileInput: (props: FileInputProps) => React.JSX.Element | null;
|
|
19
|
+
export declare const FileInput: (props: FileInputProps) => React.JSX.Element;
|
|
22
20
|
//# sourceMappingURL=FileInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,eAAe,EAAE,cAAc,EAA+C,MAAM,mBAAmB,CAAC;AAKjH,cAAc,mBAAmB,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,IAAI,CAAC,EAAE,cAAc,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,sBAmC9C,CAAC"}
|
|
@@ -1,62 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import * as DocumentPicker from 'expo-document-picker';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import {
|
|
3
|
+
import { Platform } from 'react-native';
|
|
5
4
|
import { Box } from '../../core/Box';
|
|
6
|
-
import {
|
|
5
|
+
import { Button } from '../Button';
|
|
6
|
+
import { fichiersVisibles, libellesParDefaut, retire } from './fichiersDuChamp';
|
|
7
7
|
import { useStyles } from './FileInput.styles';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// depend que de la valeur.
|
|
12
|
-
export const nomAffiche = (value, placeholder, forcePlaceholder) => {
|
|
13
|
-
if (value == null || forcePlaceholder)
|
|
14
|
-
return placeholder;
|
|
15
|
-
if (!Array.isArray(value))
|
|
16
|
-
return value.name || '1 fichier';
|
|
17
|
-
if (value.length === 0)
|
|
18
|
-
return placeholder;
|
|
19
|
-
if (value.length === 1)
|
|
20
|
-
return value[0].name ?? '1 fichier';
|
|
21
|
-
return `${value.length} fichiers`;
|
|
22
|
-
};
|
|
23
|
-
// Le selecteur rend toujours une liste ; le champ simple n'en veut que le premier element, et
|
|
24
|
-
// une liste vide vaut une absence de choix dans les deux cas.
|
|
25
|
-
export const choisis = (assets, multiple) => {
|
|
26
|
-
if (!multiple)
|
|
27
|
-
return assets?.[0] ?? null;
|
|
28
|
-
return assets && assets.length > 0 ? assets : null;
|
|
29
|
-
};
|
|
8
|
+
import { FileInputListe } from './FileInputListe';
|
|
9
|
+
import { useChoixDeFichier } from './useChoixDeFichier';
|
|
10
|
+
export * from './fichiersDuChamp';
|
|
30
11
|
export const FileInput = (props) => {
|
|
31
|
-
const { value, disabled, onChange,
|
|
12
|
+
const { value, disabled, onChange, reopen = false, multiple = false, hideButton = false, removable = true } = props;
|
|
32
13
|
const styles = useStyles();
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
onPickStart?.();
|
|
39
|
-
if (disabled)
|
|
40
|
-
return;
|
|
41
|
-
isPickingRef.current = true;
|
|
42
|
-
try {
|
|
43
|
-
const result = await DocumentPicker.getDocumentAsync({ copyToCacheDirectory: true, multiple, type });
|
|
44
|
-
valideLeType({ type, onChange })(choisis(result.assets, multiple));
|
|
45
|
-
}
|
|
46
|
-
finally {
|
|
47
|
-
isPickingRef.current = false;
|
|
48
|
-
}
|
|
49
|
-
}, [onPickStart, disabled, multiple, type, onChange]);
|
|
14
|
+
const labels = React.useMemo(() => ({ ...libellesParDefaut, ...props.labels }), [props.labels]);
|
|
15
|
+
const choisir = useChoixDeFichier({ ...props, multiple, cameraQuality: props.cameraQuality ?? 0.8, labels });
|
|
16
|
+
// Le champ simple ne remplace pas un fichier en silence : il faut d'abord retirer celui qu'il montre.
|
|
17
|
+
const visibles = fichiersVisibles(value);
|
|
18
|
+
const boutonDesactive = disabled || (!multiple && visibles.length > 0);
|
|
50
19
|
React.useEffect(() => {
|
|
51
20
|
if (reopen)
|
|
52
|
-
|
|
53
|
-
}, [reopen,
|
|
54
|
-
|
|
55
|
-
return null;
|
|
56
|
-
return (_jsx(Pressable, { accessibilityRole: "button", onPress: handlePickFile, children: _jsxs(Box, { tag: "form-control-file-input-inner", style: {
|
|
57
|
-
...styles.fileInputContainer,
|
|
58
|
-
}, children: [_jsx(Box, { tag: "file-input-button", hoverStyle: { ...(!disabled && styles.fileInputButtonHovered) }, style: {
|
|
59
|
-
...styles.fileInputButton,
|
|
60
|
-
...(disabled && styles.fileInputButtonDisabled),
|
|
61
|
-
}, children: _jsx(Typography, { style: styles.inputFileText, children: "Choisir un fichier" }) }), _jsx(Box, { tag: "file-input-text", children: _jsx(Typography, { mt: 'auto', mb: 'auto', style: styles.placeholderText, children: displayValue }) })] }) }));
|
|
21
|
+
choisir();
|
|
22
|
+
}, [reopen, choisir]);
|
|
23
|
+
return (_jsxs(Box, { tag: "file-input", style: styles.container, children: [!hideButton && (_jsx(Button, { fullWidth: Platform.OS !== 'web', onPress: choisir, disabled: boutonDesactive, variant: "secondary", title: labels.addFile, leading: "Paperclip" })), _jsx(FileInputListe, { fichiers: visibles, labels: labels, retirable: !disabled && removable, onRetirer: fichier => onChange(retire(value, fichier)) })] }));
|
|
62
24
|
};
|
|
@@ -3,54 +3,22 @@ declare const _default: {
|
|
|
3
3
|
tags: "ui"[];
|
|
4
4
|
experimental: false;
|
|
5
5
|
description: string;
|
|
6
|
-
component: (props: import("./FileInput").FileInputProps) => import("react").JSX.Element
|
|
6
|
+
component: (props: import("./FileInput").FileInputProps) => import("react").JSX.Element;
|
|
7
7
|
styleFn: () => {
|
|
8
|
-
|
|
8
|
+
container: {
|
|
9
9
|
display: "flex";
|
|
10
|
-
flexDirection: "
|
|
10
|
+
flexDirection: "column";
|
|
11
11
|
gap: string | number;
|
|
12
|
-
alignItems: "center";
|
|
13
|
-
};
|
|
14
|
-
fileInputButton: {
|
|
15
|
-
borderWidth: number;
|
|
16
|
-
borderColor: string;
|
|
17
|
-
backgroundColor: string;
|
|
18
|
-
transition: "background-color 0.1s ease-in-out";
|
|
19
|
-
display: "flex";
|
|
20
|
-
alignItems: "center";
|
|
21
|
-
justifyContent: "center";
|
|
22
|
-
paddingLeft: string | number;
|
|
23
|
-
paddingRight: string | number;
|
|
24
|
-
paddingTop: string | number;
|
|
25
|
-
paddingBottom: string | number;
|
|
26
|
-
};
|
|
27
|
-
fileInputButtonHovered: {
|
|
28
|
-
backgroundColor: string;
|
|
29
|
-
};
|
|
30
|
-
fileInputButtonDisabled: {
|
|
31
|
-
cursor: "not-allowed";
|
|
32
|
-
backgroundColor: string;
|
|
33
|
-
};
|
|
34
|
-
inputFileText: {
|
|
35
|
-
color: string;
|
|
36
|
-
fontSize: 12;
|
|
37
|
-
lineHeight: 20;
|
|
38
|
-
letterSpacing: 0;
|
|
39
|
-
fontFamily: string;
|
|
40
|
-
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
41
|
-
};
|
|
42
|
-
placeholderText: {
|
|
43
|
-
color: string;
|
|
44
|
-
fontSize: 12;
|
|
45
|
-
lineHeight: 20;
|
|
46
|
-
letterSpacing: 0;
|
|
47
|
-
fontFamily: string;
|
|
48
|
-
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
49
12
|
};
|
|
50
13
|
};
|
|
51
14
|
};
|
|
52
15
|
export default _default;
|
|
53
16
|
export declare const Default: () => import("react").JSX.Element;
|
|
54
17
|
export declare const Multiple: () => import("react").JSX.Element;
|
|
18
|
+
export declare const ImagesSeulement: () => import("react").JSX.Element;
|
|
19
|
+
export declare const AvecFichiersEnregistres: () => import("react").JSX.Element;
|
|
20
|
+
export declare const LibellesPersonnalises: () => import("react").JSX.Element;
|
|
21
|
+
export declare const Desactive: () => import("react").JSX.Element;
|
|
22
|
+
export declare const NonRetirable: () => import("react").JSX.Element;
|
|
55
23
|
export * as Sources from './FileInput.stories.sources';
|
|
56
24
|
//# sourceMappingURL=FileInput.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.stories.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FileInput.stories.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileInput.stories.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FileInput.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,wBAQkB;AAElB,eAAO,MAAM,OAAO,mCAOnB,CAAC;AAEF,eAAO,MAAM,QAAQ,mCAOpB,CAAC;AAEF,eAAO,MAAM,eAAe,mCAO3B,CAAC;AAEF,eAAO,MAAM,uBAAuB,mCAwBnC,CAAC;AAEF,eAAO,MAAM,qBAAqB,mCAWjC,CAAC;AAEF,eAAO,MAAM,SAAS,mCAarB,CAAC;AAEF,eAAO,MAAM,YAAY,mCAexB,CAAC;AAEF,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC"}
|