@alveole/components 0.42.2 → 0.43.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/core/Form/Form.d.ts +7 -0
- package/dist/core/Form/Form.d.ts.map +1 -0
- package/dist/core/Form/Form.js +30 -0
- package/dist/core/Form/Form.stories.d.ts +21 -0
- package/dist/core/Form/Form.stories.d.ts.map +1 -0
- package/dist/core/Form/Form.stories.js +18 -0
- package/dist/core/Form/Form.stories.sources.d.ts +8 -0
- package/dist/core/Form/Form.stories.sources.d.ts.map +1 -0
- package/dist/core/Form/Form.stories.sources.js +8 -0
- package/dist/core/Form/Form.styles.d.ts +10 -0
- package/dist/core/Form/Form.styles.d.ts.map +1 -0
- package/dist/core/Form/Form.styles.js +10 -0
- package/dist/core/Form/Form.web.d.ts +4 -0
- package/dist/core/Form/Form.web.d.ts.map +1 -0
- package/dist/core/Form/Form.web.js +18 -0
- package/dist/core/Form/index.d.ts +2 -0
- package/dist/core/Form/index.d.ts.map +1 -0
- package/dist/core/Form/index.js +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/stories/index.d.ts +2 -0
- package/dist/stories/index.d.ts.map +1 -1
- package/dist/stories/index.js +2 -0
- package/dist/ui/FormControl/FormControl.d.ts +12 -0
- package/dist/ui/FormControl/FormControl.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControl.js +9 -0
- package/dist/ui/FormControl/FormControl.stories.d.ts +225 -0
- package/dist/ui/FormControl/FormControl.stories.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControl.stories.js +57 -0
- package/dist/ui/FormControl/FormControl.stories.sources.d.ts +30 -0
- package/dist/ui/FormControl/FormControl.stories.sources.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControl.stories.sources.js +30 -0
- package/dist/ui/FormControl/FormControl.styles.d.ts +199 -0
- package/dist/ui/FormControl/FormControl.styles.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControl.styles.js +185 -0
- package/dist/ui/FormControl/FormControlCaption.d.ts +6 -0
- package/dist/ui/FormControl/FormControlCaption.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlCaption.js +10 -0
- package/dist/ui/FormControl/FormControlDateInput.d.ts +11 -0
- package/dist/ui/FormControl/FormControlDateInput.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlDateInput.js +46 -0
- package/dist/ui/FormControl/FormControlFileInput.d.ts +20 -0
- package/dist/ui/FormControl/FormControlFileInput.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlFileInput.js +54 -0
- package/dist/ui/FormControl/FormControlFileInput.styles.d.ts +45 -0
- package/dist/ui/FormControl/FormControlFileInput.styles.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlFileInput.styles.js +37 -0
- package/dist/ui/FormControl/FormControlHint.d.ts +6 -0
- package/dist/ui/FormControl/FormControlHint.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlHint.js +8 -0
- package/dist/ui/FormControl/FormControlLabel.d.ts +8 -0
- package/dist/ui/FormControl/FormControlLabel.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlLabel.js +13 -0
- package/dist/ui/FormControl/FormControlModal.d.ts +12 -0
- package/dist/ui/FormControl/FormControlModal.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlModal.js +12 -0
- package/dist/ui/FormControl/FormControlNumberInput.d.ts +17 -0
- package/dist/ui/FormControl/FormControlNumberInput.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlNumberInput.js +22 -0
- package/dist/ui/FormControl/FormControlOtpInput.d.ts +10 -0
- package/dist/ui/FormControl/FormControlOtpInput.d.ts.map +1 -0
- package/dist/ui/FormControl/FormControlOtpInput.js +8 -0
- package/dist/ui/FormControl/TextInput.d.ts +20 -0
- package/dist/ui/FormControl/TextInput.d.ts.map +1 -0
- package/dist/ui/FormControl/TextInput.js +118 -0
- package/dist/ui/FormControl/index.d.ts +11 -0
- package/dist/ui/FormControl/index.d.ts.map +1 -0
- package/dist/ui/FormControl/index.js +10 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// This file is generated. Do not edit manually.
|
|
2
|
+
// Source: src/ui/FormControl/FormControl.stories.tsx
|
|
3
|
+
export const WithTextInput = () => "export const WithTextInput = () => (\n <FormControl>\n <FormControlLabel label=\"Adresse email\" />\n <TextInput placeholder=\"jean@exemple.fr\" keyboardType=\"email-address\" />\n <FormControlHint hint=\"Votre email professionnel\" />\n </FormControl>\n);";
|
|
4
|
+
export const WithError = () => "export const WithError = () => (\n <FormControl>\n <FormControlLabel label=\"Adresse email\" error=\"Format invalide\" />\n <TextInput placeholder=\"jean@exemple.fr\" />\n <FormControlCaption error=\"Format invalide\" />\n </FormControl>\n);";
|
|
5
|
+
export const WithSuccess = () => "export const WithSuccess = () => (\n <FormControl>\n <FormControlLabel label=\"Adresse email\" success=\"Email valide\" />\n <TextInput placeholder=\"jean@exemple.fr\" />\n <FormControlCaption success=\"Email valide\" />\n </FormControl>\n);";
|
|
6
|
+
export const Multiline = () => "export const Multiline = () => (\n <FormControl>\n <FormControlLabel label=\"Message\" />\n <TextInput placeholder=\"Votre message...\" multiline numberOfLines={4} />\n </FormControl>\n);";
|
|
7
|
+
export const MultilineWithModal = () => "export const MultilineWithModal = () => {\n const [text, setText] = useState('');\n return (\n <FormControl>\n <FormControlLabel label=\"Description\" />\n <TextInput\n value={text}\n onChangeText={setText}\n placeholder=\"Taper pour ouvrir la modale de saisie...\"\n multiline\n openModal\n modalSubmitLabel=\"Confirmer\"\n />\n </FormControl>\n );\n};";
|
|
8
|
+
export const Label = () => "export const Label = () => (\n <Box display=\"flex\" flexDirection=\"column\" gap={8}>\n <FormControlLabel label=\"Label par defaut\" />\n <FormControlLabel label=\"Desactive\" disabled />\n <FormControlLabel label=\"Erreur\" error=\"Message erreur\" />\n <FormControlLabel label=\"Succes\" success=\"Message succes\" />\n <FormControlLabel label=\"Avec badge\" labelRight={<Typography>Optionnel</Typography>} />\n </Box>\n);";
|
|
9
|
+
export const Caption = () => "export const Caption = () => (\n <Box display=\"flex\" flexDirection=\"column\" gap={8}>\n <FormControlCaption error=\"Champ requis\" />\n <FormControlCaption success=\"Valeur correcte\" />\n </Box>\n);";
|
|
10
|
+
export const Hint = () => "export const Hint = () => (\n <Box display=\"flex\" flexDirection=\"column\" gap={8}>\n <FormControlHint hint=\"Texte descriptif du champ\" />\n <FormControlHint hint=\"Texte desactive\" disabled />\n </Box>\n);";
|
|
11
|
+
export const Modal = () => "export const Modal = () => {\n const [open, setOpen] = useState(false);\n return (\n <Box>\n <Button variant=\"secondary\" title=\"Ouvrir la modale\" onPress={() => setOpen(true)} />\n <FormControlModal\n open={open}\n onClose={() => setOpen(false)}\n submitLabel=\"Valider\"\n onSubmit={() => setOpen(false)}\n >\n <TextInput placeholder=\"Saisir un texte...\" multiline numberOfLines={6} />\n </FormControlModal>\n </Box>\n );\n};";
|
|
12
|
+
export const NumberInput = () => "export const NumberInput = () => {\n const [value, setValue] = useState<number | null>(null);\n return (\n <Box display=\"flex\" flexDirection=\"column\" gap={12}>\n <FormControl>\n <FormControlLabel label=\"Montant\" />\n <FormControlNumberInput value={value} onChange={setValue} placeholder=\"0\" />\n </FormControl>\n <FormControl>\n <FormControlLabel label=\"Avec unites\" />\n <FormControlNumberInput\n value={value}\n onChange={setValue}\n startAdornment={\n <Box style={{ paddingLeft: 8, paddingRight: 4 }}>\n <Typography>€</Typography>\n </Box>\n }\n endAdornment={\n <Box style={{ paddingLeft: 4, paddingRight: 8 }}>\n <Typography>TTC</Typography>\n </Box>\n }\n />\n </FormControl>\n <FormControl>\n <FormControlLabel label=\"Desactive\" />\n <FormControlNumberInput value={42} onChange={() => {}} disabled />\n </FormControl>\n </Box>\n );\n};";
|
|
13
|
+
export const DateInput = () => "export const DateInput = () => {\n const [date, setDate] = useState('');\n const [time, setTime] = useState('');\n const [month, setMonth] = useState('');\n return (\n <Box display=\"flex\" flexDirection=\"column\" gap={12}>\n <FormControl>\n <FormControlLabel label=\"Date\" />\n <FormControlDateInput type=\"date\" value={date} onChange={setDate} />\n </FormControl>\n <FormControl>\n <FormControlLabel label=\"Heure\" />\n <FormControlDateInput type=\"time\" value={time} onChange={setTime} />\n </FormControl>\n <FormControl>\n <FormControlLabel label=\"Mois\" />\n <FormControlDateInput type=\"month\" value={month} onChange={setMonth} />\n </FormControl>\n </Box>\n );\n};";
|
|
14
|
+
export const FileInput = () => "export const FileInput = () => {\n const [file, setFile] = useState<FormControlFileInputValue>(null);\n return (\n <Box display=\"flex\" flexDirection=\"column\" gap={12}>\n <FormControl>\n <FormControlLabel label=\"Piece jointe\" />\n <FormControlFileInput value={file} onChange={setFile} />\n </FormControl>\n <FormControl>\n <FormControlLabel label=\"Plusieurs fichiers\" />\n <FormControlFileInput value={file} onChange={setFile} multiple />\n </FormControl>\n <FormControl>\n <FormControlLabel label=\"Desactive\" disabled />\n <FormControlFileInput value={null} onChange={() => {}} disabled />\n </FormControl>\n </Box>\n );\n};";
|
|
15
|
+
export const OtpInput = () => "export const OtpInput = () => {\n const [code, setCode] = useState('');\n return (\n <FormControl>\n <FormControlLabel label=\"Code de verification\" />\n <FormControlOtpInput numberOfDigits={6} onTextChange={setCode} />\n {code.length === 6 && <FormControlCaption success={`Code saisi : ${code}`} />}\n </FormControl>\n );\n};";
|
|
16
|
+
export const storySources = {
|
|
17
|
+
WithTextInput,
|
|
18
|
+
WithError,
|
|
19
|
+
WithSuccess,
|
|
20
|
+
Multiline,
|
|
21
|
+
MultilineWithModal,
|
|
22
|
+
Label,
|
|
23
|
+
Caption,
|
|
24
|
+
Hint,
|
|
25
|
+
Modal,
|
|
26
|
+
NumberInput,
|
|
27
|
+
DateInput,
|
|
28
|
+
FileInput,
|
|
29
|
+
OtpInput,
|
|
30
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
formControl: {
|
|
3
|
+
display: "flex";
|
|
4
|
+
flexDirection: "column";
|
|
5
|
+
gap: import("@alveole/theme").Spacing;
|
|
6
|
+
width: "100%";
|
|
7
|
+
};
|
|
8
|
+
labelContainer: {
|
|
9
|
+
display: "flex";
|
|
10
|
+
flexDirection: "row";
|
|
11
|
+
justifyContent: "space-between";
|
|
12
|
+
};
|
|
13
|
+
label: {
|
|
14
|
+
color: "#373A3F";
|
|
15
|
+
fontSize: 14;
|
|
16
|
+
lineHeight: 20;
|
|
17
|
+
letterSpacing: 0;
|
|
18
|
+
fontFamily: string;
|
|
19
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
20
|
+
};
|
|
21
|
+
labelDisabled: {
|
|
22
|
+
color: "#8D97AC";
|
|
23
|
+
};
|
|
24
|
+
hintContainer: {
|
|
25
|
+
display: "flex";
|
|
26
|
+
flexDirection: "row";
|
|
27
|
+
justifyContent: "space-between";
|
|
28
|
+
};
|
|
29
|
+
hint: {
|
|
30
|
+
color: "#5F6571";
|
|
31
|
+
fontSize: 12;
|
|
32
|
+
lineHeight: 20;
|
|
33
|
+
letterSpacing: 0;
|
|
34
|
+
fontFamily: string;
|
|
35
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
36
|
+
};
|
|
37
|
+
hintDisabled: {
|
|
38
|
+
color: "#8D97AC";
|
|
39
|
+
};
|
|
40
|
+
inputContainer: {
|
|
41
|
+
width: "100%";
|
|
42
|
+
};
|
|
43
|
+
inputInner: {
|
|
44
|
+
display: "flex";
|
|
45
|
+
flexDirection: "row";
|
|
46
|
+
gap: import("@alveole/theme").Spacing;
|
|
47
|
+
padding: number;
|
|
48
|
+
borderRadius: number;
|
|
49
|
+
borderWidth: number;
|
|
50
|
+
borderColor: "#DEE3EC";
|
|
51
|
+
backgroundColor: "#FFFFFF";
|
|
52
|
+
overflow: "hidden";
|
|
53
|
+
width: "100%";
|
|
54
|
+
minHeight: number;
|
|
55
|
+
};
|
|
56
|
+
input: {
|
|
57
|
+
display: "flex";
|
|
58
|
+
flexDirection: "row";
|
|
59
|
+
outline: string;
|
|
60
|
+
color: "#373A3F";
|
|
61
|
+
fontFamily: string;
|
|
62
|
+
fontSize: 14;
|
|
63
|
+
marginTop: import("@alveole/theme").Spacing;
|
|
64
|
+
marginBottom: import("@alveole/theme").Spacing;
|
|
65
|
+
paddingLeft: import("@alveole/theme").Spacing;
|
|
66
|
+
paddingRight: import("@alveole/theme").Spacing;
|
|
67
|
+
minHeight: number | undefined;
|
|
68
|
+
flex: number;
|
|
69
|
+
};
|
|
70
|
+
inputError: {
|
|
71
|
+
borderColor: "#C62416";
|
|
72
|
+
};
|
|
73
|
+
inputSuccess: {
|
|
74
|
+
borderColor: "#1B7440";
|
|
75
|
+
};
|
|
76
|
+
inputDisabled: {
|
|
77
|
+
borderColor: "#E6EAF1";
|
|
78
|
+
};
|
|
79
|
+
inputFocused: {
|
|
80
|
+
outlineStyle: "solid";
|
|
81
|
+
outlineWidth: number;
|
|
82
|
+
outlineColor: "#0A76F6";
|
|
83
|
+
outlineOffset: number;
|
|
84
|
+
borderColor: "#0A76F6" | undefined;
|
|
85
|
+
};
|
|
86
|
+
inputFile: {
|
|
87
|
+
margin: number;
|
|
88
|
+
};
|
|
89
|
+
inputFileText: {
|
|
90
|
+
fontSize: 14;
|
|
91
|
+
lineHeight: 20;
|
|
92
|
+
letterSpacing: 0;
|
|
93
|
+
fontFamily: string;
|
|
94
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
95
|
+
color: "#373A3F";
|
|
96
|
+
};
|
|
97
|
+
inputFileClear: {
|
|
98
|
+
position: "absolute";
|
|
99
|
+
right: number;
|
|
100
|
+
};
|
|
101
|
+
inputFileIcon: {
|
|
102
|
+
marginTop: string;
|
|
103
|
+
marginBottom: string;
|
|
104
|
+
};
|
|
105
|
+
inputWeb: {
|
|
106
|
+
borderWidth: number;
|
|
107
|
+
borderStyle: "none";
|
|
108
|
+
outline: string;
|
|
109
|
+
backgroundColor: "transparent";
|
|
110
|
+
lineHeight: string;
|
|
111
|
+
};
|
|
112
|
+
modalOverlay: {
|
|
113
|
+
flex: number;
|
|
114
|
+
backgroundColor: `rgba${string}`;
|
|
115
|
+
};
|
|
116
|
+
modalSheet: {
|
|
117
|
+
width: "100%";
|
|
118
|
+
flex: number;
|
|
119
|
+
};
|
|
120
|
+
modalContent: {
|
|
121
|
+
flex: number;
|
|
122
|
+
backgroundColor: "#FFFFFF";
|
|
123
|
+
borderTopLeftRadius: number;
|
|
124
|
+
borderTopRightRadius: number;
|
|
125
|
+
padding: import("@alveole/theme").Spacing;
|
|
126
|
+
paddingTop: import("@alveole/theme").Spacing;
|
|
127
|
+
paddingBottom: import("@alveole/theme").Spacing;
|
|
128
|
+
};
|
|
129
|
+
modalHeader: {
|
|
130
|
+
display: "flex";
|
|
131
|
+
flexDirection: "row";
|
|
132
|
+
justifyContent: "space-between";
|
|
133
|
+
alignItems: "center";
|
|
134
|
+
marginBottom: import("@alveole/theme").Spacing;
|
|
135
|
+
};
|
|
136
|
+
modalHeaderLeft: {
|
|
137
|
+
display: "flex";
|
|
138
|
+
flexDirection: "row";
|
|
139
|
+
alignItems: "center";
|
|
140
|
+
};
|
|
141
|
+
modalHeaderRight: {
|
|
142
|
+
display: "flex";
|
|
143
|
+
flexDirection: "row";
|
|
144
|
+
alignItems: "center";
|
|
145
|
+
};
|
|
146
|
+
modalFooter: {
|
|
147
|
+
marginTop: import("@alveole/theme").Spacing;
|
|
148
|
+
};
|
|
149
|
+
modalInputContainer: {
|
|
150
|
+
borderRadius: number;
|
|
151
|
+
borderWidth: number;
|
|
152
|
+
borderColor: "#DEE3EC";
|
|
153
|
+
backgroundColor: "#FFFFFF";
|
|
154
|
+
minHeight: number;
|
|
155
|
+
};
|
|
156
|
+
modalInput: {
|
|
157
|
+
color: "#373A3F";
|
|
158
|
+
paddingLeft: import("@alveole/theme").Spacing;
|
|
159
|
+
paddingRight: import("@alveole/theme").Spacing;
|
|
160
|
+
paddingTop: import("@alveole/theme").Spacing;
|
|
161
|
+
paddingBottom: import("@alveole/theme").Spacing;
|
|
162
|
+
minHeight: number;
|
|
163
|
+
flex: number;
|
|
164
|
+
fontSize: 14;
|
|
165
|
+
lineHeight: 20;
|
|
166
|
+
letterSpacing: 0;
|
|
167
|
+
fontFamily: string;
|
|
168
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
169
|
+
};
|
|
170
|
+
caption: {
|
|
171
|
+
display: "flex";
|
|
172
|
+
flexDirection: "row";
|
|
173
|
+
gap: import("@alveole/theme").Spacing;
|
|
174
|
+
alignItems: "flex-start";
|
|
175
|
+
marginTop: import("@alveole/theme").Spacing;
|
|
176
|
+
width: "100%";
|
|
177
|
+
};
|
|
178
|
+
captionIcon: {
|
|
179
|
+
flexShrink: number;
|
|
180
|
+
marginTop: number;
|
|
181
|
+
};
|
|
182
|
+
captionText: {
|
|
183
|
+
flex: number;
|
|
184
|
+
flexShrink: number;
|
|
185
|
+
minWidth: number;
|
|
186
|
+
fontSize: 12;
|
|
187
|
+
lineHeight: 20;
|
|
188
|
+
letterSpacing: 0;
|
|
189
|
+
fontFamily: string;
|
|
190
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
191
|
+
};
|
|
192
|
+
errorText: {
|
|
193
|
+
color: "#C62416";
|
|
194
|
+
};
|
|
195
|
+
successText: {
|
|
196
|
+
color: "#1C7F54";
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
//# sourceMappingURL=FormControl.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormControl.styles.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FormControl.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2LnB,CAAC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { makeStyles } from '@alveole/theme';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
export const useStyles = makeStyles(({ text, color, spacing }) => ({
|
|
4
|
+
formControl: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
gap: spacing('025'),
|
|
8
|
+
width: '100%',
|
|
9
|
+
},
|
|
10
|
+
// Label
|
|
11
|
+
labelContainer: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'row',
|
|
14
|
+
justifyContent: 'space-between',
|
|
15
|
+
},
|
|
16
|
+
label: {
|
|
17
|
+
...text['Corps de texte'].SM.Medium,
|
|
18
|
+
color: color.text['default-grey'],
|
|
19
|
+
},
|
|
20
|
+
labelDisabled: {
|
|
21
|
+
color: color.text['disabled-grey'],
|
|
22
|
+
},
|
|
23
|
+
// Hint
|
|
24
|
+
hintContainer: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
justifyContent: 'space-between',
|
|
28
|
+
},
|
|
29
|
+
hint: {
|
|
30
|
+
...text['Corps de texte'].XS.Regular,
|
|
31
|
+
color: color.text.mention,
|
|
32
|
+
},
|
|
33
|
+
hintDisabled: {
|
|
34
|
+
color: color.text['disabled-grey'],
|
|
35
|
+
},
|
|
36
|
+
// Input
|
|
37
|
+
inputContainer: {
|
|
38
|
+
width: '100%',
|
|
39
|
+
},
|
|
40
|
+
inputInner: {
|
|
41
|
+
display: 'flex',
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
gap: spacing('050'),
|
|
44
|
+
padding: 0,
|
|
45
|
+
borderRadius: 8,
|
|
46
|
+
borderWidth: 1,
|
|
47
|
+
borderColor: color.border['default-grey'],
|
|
48
|
+
backgroundColor: '#FFFFFF',
|
|
49
|
+
overflow: 'hidden',
|
|
50
|
+
width: '100%',
|
|
51
|
+
minHeight: 42,
|
|
52
|
+
},
|
|
53
|
+
input: {
|
|
54
|
+
display: 'flex',
|
|
55
|
+
flexDirection: 'row',
|
|
56
|
+
outline: 'none',
|
|
57
|
+
color: color.text['default-grey'],
|
|
58
|
+
fontFamily: text['Corps de texte'].SM.Regular.fontFamily,
|
|
59
|
+
fontSize: text['Corps de texte'].SM.Regular.fontSize,
|
|
60
|
+
marginTop: Platform.OS === 'web' ? spacing('050') : spacing('025'),
|
|
61
|
+
marginBottom: Platform.OS === 'web' ? spacing('050') : spacing('025'),
|
|
62
|
+
paddingLeft: spacing('100'),
|
|
63
|
+
paddingRight: spacing('100'),
|
|
64
|
+
minHeight: Platform.OS === 'web' ? undefined : 42,
|
|
65
|
+
flex: 1,
|
|
66
|
+
},
|
|
67
|
+
inputError: {
|
|
68
|
+
borderColor: color.border['plain-error'],
|
|
69
|
+
},
|
|
70
|
+
inputSuccess: {
|
|
71
|
+
borderColor: color.border['plain-success'],
|
|
72
|
+
},
|
|
73
|
+
inputDisabled: {
|
|
74
|
+
borderColor: color.border['disabled-grey'],
|
|
75
|
+
},
|
|
76
|
+
inputFocused: {
|
|
77
|
+
outlineStyle: 'solid',
|
|
78
|
+
outlineWidth: 2,
|
|
79
|
+
outlineColor: color.system.focus,
|
|
80
|
+
outlineOffset: 2,
|
|
81
|
+
borderColor: Platform.OS === 'ios' ? color.system.focus : undefined,
|
|
82
|
+
},
|
|
83
|
+
inputFile: {
|
|
84
|
+
margin: 0,
|
|
85
|
+
},
|
|
86
|
+
inputFileText: {
|
|
87
|
+
color: color.text['default-grey'],
|
|
88
|
+
...text['Corps de texte'].SM.Regular,
|
|
89
|
+
},
|
|
90
|
+
inputFileClear: {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
right: 0,
|
|
93
|
+
},
|
|
94
|
+
inputFileIcon: {
|
|
95
|
+
marginTop: 'auto',
|
|
96
|
+
marginBottom: 'auto',
|
|
97
|
+
},
|
|
98
|
+
inputWeb: {
|
|
99
|
+
borderWidth: 0,
|
|
100
|
+
borderStyle: 'none',
|
|
101
|
+
outline: 'none',
|
|
102
|
+
backgroundColor: 'transparent',
|
|
103
|
+
lineHeight: 'auto',
|
|
104
|
+
},
|
|
105
|
+
// Modal (multiline)
|
|
106
|
+
modalOverlay: {
|
|
107
|
+
flex: 1,
|
|
108
|
+
backgroundColor: color.alpha(color.background['alt-grey'], 0.75),
|
|
109
|
+
},
|
|
110
|
+
modalSheet: {
|
|
111
|
+
width: '100%',
|
|
112
|
+
flex: 1,
|
|
113
|
+
},
|
|
114
|
+
modalContent: {
|
|
115
|
+
flex: 1,
|
|
116
|
+
backgroundColor: '#FFFFFF',
|
|
117
|
+
borderTopLeftRadius: 8,
|
|
118
|
+
borderTopRightRadius: 8,
|
|
119
|
+
padding: spacing('150'),
|
|
120
|
+
paddingTop: spacing('075'),
|
|
121
|
+
paddingBottom: spacing('075'),
|
|
122
|
+
},
|
|
123
|
+
modalHeader: {
|
|
124
|
+
display: 'flex',
|
|
125
|
+
flexDirection: 'row',
|
|
126
|
+
justifyContent: 'space-between',
|
|
127
|
+
alignItems: 'center',
|
|
128
|
+
marginBottom: spacing('100'),
|
|
129
|
+
},
|
|
130
|
+
modalHeaderLeft: {
|
|
131
|
+
display: 'flex',
|
|
132
|
+
flexDirection: 'row',
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
},
|
|
135
|
+
modalHeaderRight: {
|
|
136
|
+
display: 'flex',
|
|
137
|
+
flexDirection: 'row',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
},
|
|
140
|
+
modalFooter: {
|
|
141
|
+
marginTop: spacing('100'),
|
|
142
|
+
},
|
|
143
|
+
modalInputContainer: {
|
|
144
|
+
borderRadius: 6,
|
|
145
|
+
borderWidth: 1,
|
|
146
|
+
borderColor: color.border['default-grey'],
|
|
147
|
+
backgroundColor: '#FFFFFF',
|
|
148
|
+
minHeight: 200,
|
|
149
|
+
},
|
|
150
|
+
modalInput: {
|
|
151
|
+
...text['Corps de texte'].SM.Regular,
|
|
152
|
+
color: color.text['default-grey'],
|
|
153
|
+
paddingLeft: spacing('100'),
|
|
154
|
+
paddingRight: spacing('100'),
|
|
155
|
+
paddingTop: spacing('100'),
|
|
156
|
+
paddingBottom: spacing('100'),
|
|
157
|
+
minHeight: 180,
|
|
158
|
+
flex: 1,
|
|
159
|
+
},
|
|
160
|
+
// Caption
|
|
161
|
+
caption: {
|
|
162
|
+
display: 'flex',
|
|
163
|
+
flexDirection: 'row',
|
|
164
|
+
gap: spacing('025'),
|
|
165
|
+
alignItems: 'flex-start',
|
|
166
|
+
marginTop: spacing('050'),
|
|
167
|
+
width: '100%',
|
|
168
|
+
},
|
|
169
|
+
captionIcon: {
|
|
170
|
+
flexShrink: 0,
|
|
171
|
+
marginTop: 2,
|
|
172
|
+
},
|
|
173
|
+
captionText: {
|
|
174
|
+
...text['Corps de texte'].XS.Regular,
|
|
175
|
+
flex: 1,
|
|
176
|
+
flexShrink: 1,
|
|
177
|
+
minWidth: 0,
|
|
178
|
+
},
|
|
179
|
+
errorText: {
|
|
180
|
+
color: color.danger,
|
|
181
|
+
},
|
|
182
|
+
successText: {
|
|
183
|
+
color: color.success,
|
|
184
|
+
},
|
|
185
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormControlCaption.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FormControlCaption.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,gCAuBhE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Typography } from '../../core';
|
|
3
|
+
import { LucideIcon } from '../LucideIcon';
|
|
4
|
+
import { useStyles } from './FormControl.styles';
|
|
5
|
+
export const FormControlCaption = (props) => {
|
|
6
|
+
const { error, success } = props;
|
|
7
|
+
const styles = useStyles();
|
|
8
|
+
return (_jsxs(Box, { tag: "form-control-caption", style: styles.caption, children: [(error != null || success != null) &&
|
|
9
|
+
(success ? (_jsx(Box, { style: styles.captionIcon, children: _jsx(LucideIcon, { name: "CircleCheck", size: "sm", color: styles.successText.color }) })) : (_jsx(Box, { style: styles.captionIcon, children: _jsx(LucideIcon, { name: "OctagonX", size: "sm", color: styles.errorText.color }) }))), _jsx(Typography, { style: styles.captionText, color: error ? styles.errorText.color : styles.successText.color, children: error ?? success })] }));
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type FormControlDateInputElement = HTMLInputElement;
|
|
3
|
+
export type FormControlDateInputProps = {
|
|
4
|
+
value?: string;
|
|
5
|
+
type?: 'date' | 'time' | 'datetime' | 'month';
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
onChange?: (value: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const FormControlDateInput: React.ForwardRefExoticComponent<FormControlDateInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
11
|
+
//# sourceMappingURL=FormControlDateInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormControlDateInput.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FormControlDateInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,2BAA2B,GAAG,gBAAgB,CAAC;AAC3D,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AAaF,eAAO,MAAM,oBAAoB,oGA6ChC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Box } from '../../core';
|
|
4
|
+
import { useStyles } from './FormControl.styles';
|
|
5
|
+
function formatForInput(value, type) {
|
|
6
|
+
const d = new Date(value);
|
|
7
|
+
if (isNaN(d.getTime()))
|
|
8
|
+
return value;
|
|
9
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
10
|
+
if (type === 'datetime')
|
|
11
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
12
|
+
if (type === 'time')
|
|
13
|
+
return `${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
14
|
+
if (type === 'month')
|
|
15
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}`;
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
export const FormControlDateInput = React.forwardRef(function DateInput(props, ref) {
|
|
19
|
+
const { value, type, onChange, ...inputProps } = props;
|
|
20
|
+
const styles = useStyles();
|
|
21
|
+
const parsed = React.useMemo(() => {
|
|
22
|
+
if (value == null)
|
|
23
|
+
return value;
|
|
24
|
+
if (type === 'datetime') {
|
|
25
|
+
const d = new Date(value);
|
|
26
|
+
if (isNaN(d.getTime()))
|
|
27
|
+
return '';
|
|
28
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
29
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
30
|
+
}
|
|
31
|
+
if (type === 'time')
|
|
32
|
+
return formatForInput(value, 'time');
|
|
33
|
+
if (type === 'month')
|
|
34
|
+
return formatForInput(value, 'month');
|
|
35
|
+
return value;
|
|
36
|
+
}, [type, value]);
|
|
37
|
+
return (_jsx(Box, { tag: "form-control-text-input", style: styles.inputContainer, children: _jsx(Box, { tag: "form-control-text-input-inner", style: {
|
|
38
|
+
...styles.inputInner,
|
|
39
|
+
...(props.disabled ? styles.inputDisabled : {}),
|
|
40
|
+
}, children: _jsx("input", { ref: ref, onChange: e => {
|
|
41
|
+
const newDate = e.target.value;
|
|
42
|
+
if (type === 'month')
|
|
43
|
+
return onChange?.(newDate + '-01');
|
|
44
|
+
return onChange?.(newDate);
|
|
45
|
+
}, autoComplete: undefined, style: { ...styles.input, ...styles.inputWeb }, type: type === 'datetime' ? 'datetime-local' : (type ?? 'date'), ...inputProps, value: parsed }) }) }));
|
|
46
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as DocumentPicker from 'expo-document-picker';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type FormControlFileInputValue = DocumentPicker.DocumentPickerAsset | DocumentPicker.DocumentPickerAsset[] | null;
|
|
4
|
+
export type FormControlFileInputProps = {
|
|
5
|
+
value: FormControlFileInputValue;
|
|
6
|
+
previewURL?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
forcePlaceholder?: boolean;
|
|
9
|
+
hideButton?: boolean;
|
|
10
|
+
hideFilename?: boolean;
|
|
11
|
+
canChange?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
type?: DocumentPicker.DocumentPickerOptions['type'];
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
onChange: (value: FormControlFileInputValue) => void;
|
|
16
|
+
reopen?: boolean;
|
|
17
|
+
onPickStart?: () => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const FormControlFileInput: (props: FormControlFileInputProps) => React.JSX.Element | null;
|
|
20
|
+
//# sourceMappingURL=FormControlFileInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormControlFileInput.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FormControlFileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,MAAM,yBAAyB,GACjC,cAAc,CAAC,mBAAmB,GAClC,cAAc,CAAC,mBAAmB,EAAE,GACpC,IAAI,CAAC;AAET,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,yBAAyB,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,cAAc,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACrD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,OAAO,yBAAyB,6BA6EpE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as DocumentPicker from 'expo-document-picker';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Pressable } from 'react-native';
|
|
5
|
+
import { Box, Typography } from '../../core';
|
|
6
|
+
import { useStyles } from './FormControlFileInput.styles';
|
|
7
|
+
export const FormControlFileInput = (props) => {
|
|
8
|
+
const { value, disabled, onChange, onPickStart, placeholder = 'Aucun fichier choisi.', type, forcePlaceholder, reopen = false, multiple = false, hideButton = false, } = props;
|
|
9
|
+
const styles = useStyles();
|
|
10
|
+
const displayValue = React.useMemo(() => {
|
|
11
|
+
if (value == null || forcePlaceholder)
|
|
12
|
+
return placeholder;
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
if (value.length === 0)
|
|
15
|
+
return placeholder;
|
|
16
|
+
if (value.length === 1)
|
|
17
|
+
return value[0].name ?? '1 fichier';
|
|
18
|
+
return `${value.length} fichiers`;
|
|
19
|
+
}
|
|
20
|
+
if (value.name)
|
|
21
|
+
return value.name;
|
|
22
|
+
return '1 fichier';
|
|
23
|
+
}, [placeholder, value, forcePlaceholder]);
|
|
24
|
+
const handlePickFile = React.useCallback(async () => {
|
|
25
|
+
onPickStart?.();
|
|
26
|
+
if (disabled)
|
|
27
|
+
return;
|
|
28
|
+
const result = await DocumentPicker.getDocumentAsync({
|
|
29
|
+
copyToCacheDirectory: true,
|
|
30
|
+
multiple: multiple ?? false,
|
|
31
|
+
type: type,
|
|
32
|
+
});
|
|
33
|
+
if (multiple) {
|
|
34
|
+
const newValue = result.assets && result.assets.length > 0 ? result.assets : null;
|
|
35
|
+
onChange?.(newValue);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const newValue = result.assets?.[0] ?? null;
|
|
39
|
+
onChange?.(newValue);
|
|
40
|
+
}
|
|
41
|
+
}, [onPickStart, disabled, multiple, type, onChange]);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (reopen)
|
|
44
|
+
handlePickFile();
|
|
45
|
+
}, [reopen, handlePickFile]);
|
|
46
|
+
if (hideButton)
|
|
47
|
+
return null;
|
|
48
|
+
return (_jsx(Pressable, { onPress: handlePickFile, children: _jsxs(Box, { tag: "form-control-file-input-inner", style: {
|
|
49
|
+
...styles.fileInputContainer,
|
|
50
|
+
}, children: [_jsx(Box, { tag: "file-input-button", hoverStyle: { ...(!disabled && styles.fileInputButtonHovered) }, style: {
|
|
51
|
+
...styles.fileInputButton,
|
|
52
|
+
...(disabled && styles.fileInputButtonDisabled),
|
|
53
|
+
}, 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 }) })] }) }));
|
|
54
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
fileInputContainer: {
|
|
3
|
+
display: "flex";
|
|
4
|
+
flexDirection: "row";
|
|
5
|
+
gap: import("@alveole/theme").Spacing;
|
|
6
|
+
alignItems: "center";
|
|
7
|
+
};
|
|
8
|
+
fileInputButton: {
|
|
9
|
+
borderWidth: number;
|
|
10
|
+
borderColor: "#DEE3EC";
|
|
11
|
+
backgroundColor: "#F6F7F8";
|
|
12
|
+
transition: "background-color 0.1s ease-in-out";
|
|
13
|
+
display: "flex";
|
|
14
|
+
alignItems: "center";
|
|
15
|
+
justifyContent: "center";
|
|
16
|
+
paddingLeft: import("@alveole/theme").Spacing;
|
|
17
|
+
paddingRight: import("@alveole/theme").Spacing;
|
|
18
|
+
paddingTop: import("@alveole/theme").Spacing;
|
|
19
|
+
paddingBottom: import("@alveole/theme").Spacing;
|
|
20
|
+
};
|
|
21
|
+
fileInputButtonHovered: {
|
|
22
|
+
backgroundColor: "#E6EAF1";
|
|
23
|
+
};
|
|
24
|
+
fileInputButtonDisabled: {
|
|
25
|
+
cursor: "not-allowed";
|
|
26
|
+
backgroundColor: "#E6EAF1";
|
|
27
|
+
};
|
|
28
|
+
inputFileText: {
|
|
29
|
+
color: "#373A3F";
|
|
30
|
+
fontSize: 12;
|
|
31
|
+
lineHeight: 20;
|
|
32
|
+
letterSpacing: 0;
|
|
33
|
+
fontFamily: string;
|
|
34
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
35
|
+
};
|
|
36
|
+
placeholderText: {
|
|
37
|
+
color: "#373A3F";
|
|
38
|
+
fontSize: 12;
|
|
39
|
+
lineHeight: 20;
|
|
40
|
+
letterSpacing: 0;
|
|
41
|
+
fontFamily: string;
|
|
42
|
+
fontWeight?: import("react-native").TextStyle["fontWeight"];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=FormControlFileInput.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormControlFileInput.styles.d.ts","sourceRoot":"","sources":["../../../src/ui/FormControl/FormControlFileInput.styles.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCnB,CAAC"}
|