allaw-ui 2.9.9 → 3.0.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.
@@ -0,0 +1,5 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M14 2H6C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H18C19.1 22 20 21.1 20 20V8L14 2Z" fill="#E30000" />
3
+ <path d="M14 2V8H20L14 2Z" fill="#FF6666" />
4
+ <path d="M10.08 16.58C9.63 16.58 9.2 16.5 8.8 16.34V14.54C9.16 14.74 9.56 14.84 10 14.84C10.28 14.84 10.5 14.78 10.66 14.66C10.82 14.54 10.9 14.36 10.9 14.12C10.9 13.9 10.84 13.72 10.72 13.58C10.6 13.44 10.36 13.24 10 12.98C9.62 12.7 9.36 12.44 9.22 12.2C9.08 11.96 9 11.66 9 11.3C9 10.78 9.18 10.38 9.54 10.08C9.9 9.78 10.36 9.64 10.92 9.64C11.32 9.64 11.68 9.68 12 9.76V11.44C11.7 11.3 11.4 11.24 11.1 11.24C10.9 11.24 10.74 11.28 10.62 11.36C10.5 11.44 10.44 11.56 10.44 11.72C10.44 11.86 10.5 11.98 10.62 12.1C10.74 12.22 10.94 12.38 11.22 12.58C11.62 12.86 11.9 13.14 12.06 13.42C12.22 13.7 12.3 14.04 12.3 14.44C12.3 14.98 12.1 15.4 11.7 15.7C11.3 16 10.76 16.16 10.08 16.58Z" fill="white" />
5
+ </svg>
@@ -77,7 +77,6 @@
77
77
 
78
78
  .emailLocalPart {
79
79
  flex-shrink: 1;
80
- min-width: 40px;
81
80
  }
82
81
 
83
82
  .emailDomainPart {
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ export interface FileUploaderProps {
3
+ acceptedExtensions: string[];
4
+ maxFileSizeMB: number;
5
+ enableDragAndDrop?: boolean;
6
+ iconUrl?: string;
7
+ descriptionParts?: {
8
+ beforeLink: string;
9
+ linkLabel: string;
10
+ linkUrl: string;
11
+ afterLink: string;
12
+ };
13
+ onFileRead?: (file: File, fileContent: ArrayBuffer) => void;
14
+ onFileRemove?: () => void;
15
+ uploadProgress?: number;
16
+ isLoading?: boolean;
17
+ errorMessage?: string | null;
18
+ buttonLabel?: string;
19
+ acceptedLabel?: string;
20
+ maxSizeLabel?: string;
21
+ fileName?: string;
22
+ fileSize?: number;
23
+ }
24
+ declare const FileUploader: React.FC<FileUploaderProps>;
25
+ export default FileUploader;
@@ -0,0 +1,186 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import React, { useState, useRef } from "react";
38
+ import styles from "./FileUploader.module.css";
39
+ var FileUploader = function (_a) {
40
+ var acceptedExtensions = _a.acceptedExtensions, maxFileSizeMB = _a.maxFileSizeMB, _b = _a.enableDragAndDrop, enableDragAndDrop = _b === void 0 ? true : _b, iconUrl = _a.iconUrl, descriptionParts = _a.descriptionParts, onFileRead = _a.onFileRead, onFileRemove = _a.onFileRemove, _c = _a.uploadProgress, uploadProgress = _c === void 0 ? 0 : _c, _d = _a.isLoading, isLoading = _d === void 0 ? false : _d, _e = _a.errorMessage, errorMessage = _e === void 0 ? null : _e, _f = _a.buttonLabel, buttonLabel = _f === void 0 ? "Choisir un fichier" : _f, _g = _a.acceptedLabel, acceptedLabel = _g === void 0 ? "Format accepté :" : _g, _h = _a.maxSizeLabel, maxSizeLabel = _h === void 0 ? "Taille maximale :" : _h, fileName = _a.fileName, fileSize = _a.fileSize;
41
+ var _j = useState(null), selectedFile = _j[0], setSelectedFile = _j[1];
42
+ var _k = useState(false), isHovering = _k[0], setIsHovering = _k[1];
43
+ var fileInputRef = useRef(null);
44
+ var resetFileInput = function () {
45
+ if (fileInputRef.current) {
46
+ fileInputRef.current.value = "";
47
+ }
48
+ };
49
+ var validateFile = function (file) {
50
+ var _a;
51
+ // Vérifier l'extension
52
+ var fileExtension = ".".concat((_a = file.name.split(".").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase());
53
+ var isValidExtension = acceptedExtensions.includes(fileExtension);
54
+ // Vérifier la taille
55
+ var isValidSize = file.size <= maxFileSizeMB * 1024 * 1024;
56
+ return isValidExtension && isValidSize;
57
+ };
58
+ var handleFileSelect = function (event) { return __awaiter(void 0, void 0, void 0, function () {
59
+ var file;
60
+ return __generator(this, function (_a) {
61
+ if (event.target.files && event.target.files.length > 0) {
62
+ file = event.target.files[0];
63
+ processFile(file);
64
+ }
65
+ return [2 /*return*/];
66
+ });
67
+ }); };
68
+ var handleDragOver = function (event) {
69
+ event.preventDefault();
70
+ setIsHovering(true);
71
+ };
72
+ var handleDragLeave = function () {
73
+ setIsHovering(false);
74
+ };
75
+ var handleDrop = function (event) { return __awaiter(void 0, void 0, void 0, function () {
76
+ var file;
77
+ return __generator(this, function (_a) {
78
+ event.preventDefault();
79
+ setIsHovering(false);
80
+ if (event.dataTransfer.files && event.dataTransfer.files.length > 0) {
81
+ file = event.dataTransfer.files[0];
82
+ processFile(file);
83
+ }
84
+ return [2 /*return*/];
85
+ });
86
+ }); };
87
+ var processFile = function (file) { return __awaiter(void 0, void 0, void 0, function () {
88
+ var fileContent, error_1;
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0:
92
+ if (!validateFile(file)) {
93
+ setSelectedFile(null);
94
+ return [2 /*return*/];
95
+ }
96
+ _a.label = 1;
97
+ case 1:
98
+ _a.trys.push([1, 3, , 4]);
99
+ setSelectedFile(file);
100
+ return [4 /*yield*/, file.arrayBuffer()];
101
+ case 2:
102
+ fileContent = _a.sent();
103
+ onFileRead === null || onFileRead === void 0 ? void 0 : onFileRead(file, fileContent);
104
+ return [3 /*break*/, 4];
105
+ case 3:
106
+ error_1 = _a.sent();
107
+ console.error("Error reading file:", error_1);
108
+ setSelectedFile(null);
109
+ return [3 /*break*/, 4];
110
+ case 4: return [2 /*return*/];
111
+ }
112
+ });
113
+ }); };
114
+ var handleFileDelete = function () {
115
+ setSelectedFile(null);
116
+ resetFileInput();
117
+ onFileRemove === null || onFileRemove === void 0 ? void 0 : onFileRemove();
118
+ };
119
+ var formatFileSize = function (size) {
120
+ if (size < 1024) {
121
+ return "".concat(size, " octets");
122
+ }
123
+ else if (size < 1024 * 1024) {
124
+ return "".concat((size / 1024).toFixed(2), " Ko");
125
+ }
126
+ else {
127
+ return "".concat((size / (1024 * 1024)).toFixed(2), " Mo");
128
+ }
129
+ };
130
+ var displayFileSize = fileSize !== undefined ? fileSize : selectedFile ? selectedFile.size : 0;
131
+ var displayFileName = fileName || (selectedFile ? selectedFile.name : "");
132
+ return (React.createElement("div", { className: styles.upload_main_container },
133
+ enableDragAndDrop ? (React.createElement("div", { className: "".concat(styles.upload_container, " ").concat(isHovering ? styles.drag_over : ""), onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop },
134
+ React.createElement("div", { className: styles.upload_content },
135
+ React.createElement("div", { className: styles.upload_icons },
136
+ React.createElement("div", { className: styles.upload_file_icon },
137
+ React.createElement("i", { className: "allaw-icon-file" })),
138
+ React.createElement("div", { className: styles.upload_icon_container },
139
+ React.createElement("div", { className: styles.upload_icon },
140
+ React.createElement("i", { className: "allaw-icon-export" })))),
141
+ React.createElement("div", { className: styles.upload_description },
142
+ React.createElement("span", null,
143
+ "Glissez-d\u00E9posez votre fichier, ou",
144
+ " ",
145
+ React.createElement("label", { htmlFor: "file-upload", className: styles.file_upload_label },
146
+ React.createElement("span", { className: styles.btn_tertiary }, buttonLabel),
147
+ React.createElement("input", { id: "file-upload", ref: fileInputRef, type: "file", accept: acceptedExtensions.join(","), style: { display: "none" }, onChange: handleFileSelect }))))))) : (React.createElement("div", { className: styles.manual_upload_container },
148
+ React.createElement("label", { htmlFor: "file-upload", className: styles.file_upload_label },
149
+ React.createElement("span", { className: styles.btn_tertiary }, buttonLabel),
150
+ React.createElement("input", { id: "file-upload", ref: fileInputRef, type: "file", accept: acceptedExtensions.join(","), style: { display: "none" }, onChange: handleFileSelect })))),
151
+ React.createElement("div", { className: styles.limits },
152
+ React.createElement("div", { className: styles.format },
153
+ React.createElement("span", { className: styles.limit_text },
154
+ acceptedLabel,
155
+ " ",
156
+ acceptedExtensions.join(", "))),
157
+ React.createElement("div", { className: styles.size },
158
+ React.createElement("span", { className: styles.limit_text },
159
+ maxSizeLabel,
160
+ " ",
161
+ maxFileSizeMB,
162
+ " Mo"))),
163
+ descriptionParts && (React.createElement("p", { className: styles.description },
164
+ descriptionParts.beforeLink,
165
+ " ",
166
+ React.createElement("a", { href: descriptionParts.linkUrl, target: "_blank", rel: "noopener noreferrer", className: styles.description_link }, descriptionParts.linkLabel),
167
+ " ",
168
+ descriptionParts.afterLink)),
169
+ errorMessage && (React.createElement("div", { className: styles.uploaded_file_container },
170
+ React.createElement("div", { className: styles.uploaded_file_error },
171
+ React.createElement("span", { className: styles.error_message }, errorMessage)))),
172
+ (isLoading || selectedFile || fileName) && (React.createElement("div", { className: styles.uploaded_file_container },
173
+ React.createElement("div", { className: styles.uploaded_file_content },
174
+ React.createElement("div", { className: styles.uploaded_file_icon }, iconUrl ? (React.createElement("img", { src: iconUrl, alt: "File icon", className: styles.file_icon })) : (React.createElement("i", { className: "allaw-icon-file" }))),
175
+ React.createElement("div", { className: styles.uploaded_file_name_size },
176
+ React.createElement("div", { className: styles.uploaded_file_name },
177
+ React.createElement("span", { className: styles.file_name }, displayFileName || "Analyse en cours...")),
178
+ React.createElement("div", { className: styles.uploaded_file_size },
179
+ React.createElement("span", { className: styles.file_size }, displayFileSize > 0 ? formatFileSize(displayFileSize) : ""))),
180
+ selectedFile && (React.createElement("div", { className: styles.uploaded_file_delete_container },
181
+ React.createElement("div", { className: styles.uploaded_file_delete, onClick: handleFileDelete },
182
+ React.createElement("i", { className: "allaw-icon-close" }))))),
183
+ React.createElement("div", { className: styles.uploaded_file_progress_bar }, uploadProgress > 0 && (React.createElement("div", { className: styles.progress_bar_container },
184
+ React.createElement("div", { className: styles.progress_bar_fill, style: { width: "".concat((uploadProgress / 10) * 100, "%") } }))))))));
185
+ };
186
+ export default FileUploader;
@@ -0,0 +1,288 @@
1
+ .upload_main_container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ justify-content: center;
5
+ width: 100%;
6
+ gap: 0.5rem;
7
+ }
8
+
9
+ .upload_container {
10
+ display: flex;
11
+ flex-direction: row;
12
+ align-items: center;
13
+ justify-content: center;
14
+ border: 2px dashed var(--venom-grey-dark, #d1dce8);
15
+ border-radius: 16px;
16
+ padding: 4rem 2rem;
17
+ min-height: 150px;
18
+ margin-top: 1rem;
19
+ background-color: #ffffff;
20
+ width: 100%;
21
+ transition: all 0.2s ease-in-out;
22
+ }
23
+
24
+ .manual_upload_container {
25
+ display: flex;
26
+ justify-content: center;
27
+ margin-top: 1rem;
28
+ }
29
+
30
+ .upload_container:hover {
31
+ background-color: #f6fcfe;
32
+ border: 2px dashed var(--bleu-allaw, #25beeb);
33
+ cursor: pointer;
34
+ }
35
+
36
+ .upload_container:hover .upload_icon {
37
+ background-color: #171e25;
38
+ }
39
+
40
+ .upload_content {
41
+ display: flex;
42
+ flex-direction: column;
43
+ align-items: center;
44
+ gap: 1rem;
45
+ }
46
+
47
+ .upload_icons {
48
+ display: flex;
49
+ align-items: center;
50
+ position: relative;
51
+ }
52
+
53
+ .upload_file_icon {
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ font-size: 3rem;
58
+ color: var(--lightSteelBlue, #a2b5c8);
59
+ }
60
+
61
+ .upload_icon_container {
62
+ position: absolute;
63
+ bottom: -10px;
64
+ right: -10px;
65
+ }
66
+
67
+ .upload_icon {
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: center;
71
+ background-color: #25beeb;
72
+ color: white;
73
+ border-radius: 50%;
74
+ width: 32px;
75
+ height: 32px;
76
+ font-size: 1rem;
77
+ transition: all 0.2s ease-in-out;
78
+ }
79
+
80
+ .upload_description {
81
+ text-align: center;
82
+ }
83
+
84
+ .upload_description span {
85
+ font-family: var(--font-open-sans, sans-serif);
86
+ font-size: 14px;
87
+ font-style: normal;
88
+ font-weight: 400;
89
+ line-height: normal;
90
+ }
91
+
92
+ .file_upload_label {
93
+ cursor: pointer;
94
+ }
95
+
96
+ .btn_tertiary {
97
+ color: #25beeb;
98
+ font-weight: 600;
99
+ cursor: pointer;
100
+ }
101
+
102
+ .btn_tertiary:hover {
103
+ text-decoration: underline;
104
+ }
105
+
106
+ .limits {
107
+ display: flex;
108
+ flex-direction: row;
109
+ justify-content: space-between;
110
+ align-items: center;
111
+ gap: 1rem;
112
+ }
113
+
114
+ .limit_text {
115
+ color: var(--mid-grey, #728ea7);
116
+ font-size: 14px;
117
+ font-family: var(--font-open-sans, sans-serif);
118
+ }
119
+
120
+ .description {
121
+ color: var(--primary-dark-grey, #456073);
122
+ font-family: var(--font-open-sans, sans-serif);
123
+ font-size: 14px;
124
+ font-style: normal;
125
+ font-weight: 400;
126
+ line-height: normal;
127
+ padding-top: 0.5rem;
128
+ }
129
+
130
+ .description_link {
131
+ color: #25beeb;
132
+ text-decoration: underline;
133
+ }
134
+
135
+ .uploaded_file_container {
136
+ display: flex;
137
+ flex-direction: column;
138
+ align-items: center;
139
+ justify-content: center;
140
+ width: 100%;
141
+ border-radius: 16px;
142
+ border: 1px solid var(--grey-venom, #e6edf5);
143
+ background: var(--primary-blanc, #fff);
144
+ padding: 1rem 1rem 0.5rem 1rem;
145
+ gap: 0.5rem;
146
+ margin-top: 1rem;
147
+ }
148
+
149
+ .uploaded_file_content {
150
+ width: 100%;
151
+ display: flex;
152
+ flex-direction: row;
153
+ align-items: center;
154
+ justify-content: space-between;
155
+ min-height: 40px;
156
+ }
157
+
158
+ .uploaded_file_name_size {
159
+ display: flex;
160
+ flex-direction: column;
161
+ align-items: flex-start;
162
+ justify-content: center;
163
+ width: 100%;
164
+ padding-left: 1rem;
165
+ }
166
+
167
+ .file_name {
168
+ font-family: var(--font-open-sans, sans-serif);
169
+ font-weight: 600;
170
+ color: var(--noir, #171e25);
171
+ font-size: 14px;
172
+ }
173
+
174
+ .file_size {
175
+ font-family: var(--font-open-sans, sans-serif);
176
+ color: var(--mid-grey, #728ea7);
177
+ font-size: 12px;
178
+ }
179
+
180
+ .uploaded_file_delete_container {
181
+ display: flex;
182
+ flex-direction: row;
183
+ align-items: center;
184
+ justify-content: center;
185
+ height: 100%;
186
+ }
187
+
188
+ .uploaded_file_delete {
189
+ display: flex;
190
+ flex-direction: row;
191
+ align-items: center;
192
+ justify-content: center;
193
+ height: 30px;
194
+ width: 30px;
195
+ color: var(--mid-grey, #728ea7);
196
+ font-size: 0.8rem;
197
+ cursor: pointer;
198
+ transition: color 0.2s ease-in-out;
199
+ }
200
+
201
+ .uploaded_file_delete:hover {
202
+ color: var(--noir, #171e25);
203
+ }
204
+
205
+ .uploaded_file_icon {
206
+ display: flex;
207
+ flex-direction: row;
208
+ align-items: center;
209
+ justify-content: center;
210
+ border: 1px solid var(--grey-venom, #e6edf5);
211
+ border-radius: 8px;
212
+ padding: 0.75rem;
213
+ position: relative;
214
+ min-width: 40px;
215
+ min-height: 40px;
216
+ }
217
+
218
+ .file_icon {
219
+ width: 20px;
220
+ height: 20px;
221
+ object-fit: contain;
222
+ }
223
+
224
+ .uploaded_file_progress_bar {
225
+ display: flex;
226
+ flex-direction: row;
227
+ align-items: center;
228
+ justify-content: center;
229
+ width: 100%;
230
+ height: 40px;
231
+ }
232
+
233
+ .progress_bar_container {
234
+ width: 100%;
235
+ height: 4px;
236
+ background-color: #e6edf5;
237
+ border-radius: 2px;
238
+ overflow: hidden;
239
+ }
240
+
241
+ .progress_bar_fill {
242
+ height: 100%;
243
+ background-color: #25beeb;
244
+ transition: width 0.3s ease-in-out;
245
+ }
246
+
247
+ .drag_over {
248
+ background-color: #f6fcfe;
249
+ border: 2px dashed var(--bleu-allaw, #25beeb);
250
+ }
251
+
252
+ .drag_over .upload_icon {
253
+ background-color: #171e25;
254
+ }
255
+
256
+ .uploaded_file_error {
257
+ padding-bottom: 0.5rem;
258
+ width: 100%;
259
+ }
260
+
261
+ .error_message {
262
+ color: var(--actions-error, #eb4a4a);
263
+ font-family: var(--font-open-sans, sans-serif);
264
+ font-size: 14px;
265
+ font-weight: 600;
266
+ }
267
+
268
+ @media (max-width: 768px) {
269
+ .upload_container {
270
+ padding: 2rem 1rem;
271
+ }
272
+
273
+ .upload_file_icon {
274
+ font-size: 2.5rem;
275
+ }
276
+
277
+ .upload_icon {
278
+ width: 28px;
279
+ height: 28px;
280
+ font-size: 0.8rem;
281
+ }
282
+
283
+ .limits {
284
+ flex-direction: column;
285
+ align-items: flex-start;
286
+ gap: 0.25rem;
287
+ }
288
+ }
@@ -0,0 +1,88 @@
1
+ declare namespace _default {
2
+ export let title: string;
3
+ export { FileUploader as component };
4
+ export let tags: string[];
5
+ export namespace parameters {
6
+ namespace backgrounds {
7
+ let _default: string;
8
+ export { _default as default };
9
+ export let values: {
10
+ name: string;
11
+ value: string;
12
+ }[];
13
+ }
14
+ }
15
+ export namespace argTypes {
16
+ namespace acceptedExtensions {
17
+ let control: string;
18
+ let description: string;
19
+ }
20
+ namespace maxFileSizeMB {
21
+ let control_1: string;
22
+ export { control_1 as control };
23
+ let description_1: string;
24
+ export { description_1 as description };
25
+ }
26
+ namespace enableDragAndDrop {
27
+ let control_2: string;
28
+ export { control_2 as control };
29
+ let description_2: string;
30
+ export { description_2 as description };
31
+ }
32
+ namespace iconUrl {
33
+ let control_3: string;
34
+ export { control_3 as control };
35
+ let description_3: string;
36
+ export { description_3 as description };
37
+ }
38
+ namespace buttonLabel {
39
+ let control_4: string;
40
+ export { control_4 as control };
41
+ let description_4: string;
42
+ export { description_4 as description };
43
+ }
44
+ namespace acceptedLabel {
45
+ let control_5: string;
46
+ export { control_5 as control };
47
+ let description_5: string;
48
+ export { description_5 as description };
49
+ }
50
+ namespace maxSizeLabel {
51
+ let control_6: string;
52
+ export { control_6 as control };
53
+ let description_6: string;
54
+ export { description_6 as description };
55
+ }
56
+ namespace uploadProgress {
57
+ export namespace control_7 {
58
+ let type: string;
59
+ let min: number;
60
+ let max: number;
61
+ let step: number;
62
+ }
63
+ export { control_7 as control };
64
+ let description_7: string;
65
+ export { description_7 as description };
66
+ }
67
+ namespace isLoading {
68
+ let control_8: string;
69
+ export { control_8 as control };
70
+ let description_8: string;
71
+ export { description_8 as description };
72
+ }
73
+ namespace errorMessage {
74
+ let control_9: string;
75
+ export { control_9 as control };
76
+ let description_9: string;
77
+ export { description_9 as description };
78
+ }
79
+ }
80
+ }
81
+ export default _default;
82
+ export const Default: any;
83
+ export const WithDescription: any;
84
+ export const WithoutDragAndDrop: any;
85
+ export const WithError: any;
86
+ export const WithProgress: any;
87
+ export const MultipleExtensions: any;
88
+ import FileUploader from "./FileUploader";
@@ -0,0 +1,178 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import React, { useState } from "react";
49
+ import FileUploader from "./FileUploader";
50
+ import "../../../styles/global.css";
51
+ import pdfIcon from "../../../assets/allaw-icon-pdf.svg";
52
+ export default {
53
+ title: "Components/Molecules/FileUploader/FileUploader",
54
+ component: FileUploader,
55
+ tags: ["autodocs"],
56
+ parameters: {
57
+ backgrounds: {
58
+ default: "light",
59
+ values: [
60
+ { name: "light", value: "#ffffff" },
61
+ { name: "grey", value: "#728ea7" },
62
+ { name: "figma", value: "#404040" },
63
+ { name: "dark", value: "#171e25" },
64
+ ],
65
+ },
66
+ },
67
+ argTypes: {
68
+ acceptedExtensions: {
69
+ control: "array",
70
+ description: "Liste des extensions de fichiers acceptées",
71
+ },
72
+ maxFileSizeMB: {
73
+ control: "number",
74
+ description: "Taille maximale du fichier en MB",
75
+ },
76
+ enableDragAndDrop: {
77
+ control: "boolean",
78
+ description: "Active/désactive la zone de drag & drop",
79
+ },
80
+ iconUrl: {
81
+ control: "text",
82
+ description: "URL de l'icône du type de fichier",
83
+ },
84
+ buttonLabel: {
85
+ control: "text",
86
+ description: "Texte du bouton de sélection manuelle",
87
+ },
88
+ acceptedLabel: {
89
+ control: "text",
90
+ description: "Texte sur le format accepté",
91
+ },
92
+ maxSizeLabel: {
93
+ control: "text",
94
+ description: "Texte sur la taille maximale",
95
+ },
96
+ uploadProgress: {
97
+ control: { type: "range", min: 0, max: 10, step: 1 },
98
+ description: "Progression de l'upload (0-10)",
99
+ },
100
+ isLoading: {
101
+ control: "boolean",
102
+ description: "Affiche un loader pendant lecture ou traitement",
103
+ },
104
+ errorMessage: {
105
+ control: "text",
106
+ description: "Message d'erreur à afficher",
107
+ },
108
+ },
109
+ };
110
+ // Template de base avec gestion d'état intégré pour la démo
111
+ var Template = function (args) {
112
+ var _a = useState(null), file = _a[0], setFile = _a[1];
113
+ var _b = useState(null), fileContent = _b[0], setFileContent = _b[1];
114
+ var _c = useState(0), progress = _c[0], setProgress = _c[1];
115
+ var _d = useState(false), loading = _d[0], setLoading = _d[1];
116
+ var _e = useState(null), error = _e[0], setError = _e[1];
117
+ var handleFileRead = function (file, content) { return __awaiter(void 0, void 0, void 0, function () {
118
+ return __generator(this, function (_a) {
119
+ switch (_a.label) {
120
+ case 0:
121
+ setLoading(true);
122
+ setFile(file);
123
+ setFileContent(content);
124
+ // Simuler une progression
125
+ setProgress(2);
126
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })];
127
+ case 1:
128
+ _a.sent();
129
+ setProgress(5);
130
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })];
131
+ case 2:
132
+ _a.sent();
133
+ setProgress(8);
134
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })];
135
+ case 3:
136
+ _a.sent();
137
+ setProgress(10);
138
+ setLoading(false);
139
+ console.log("Fichier lu:", file.name, "Taille:", file.size);
140
+ return [2 /*return*/];
141
+ }
142
+ });
143
+ }); };
144
+ var handleFileRemove = function () {
145
+ setFile(null);
146
+ setFileContent(null);
147
+ setProgress(0);
148
+ setError(null);
149
+ console.log("Fichier supprimé");
150
+ };
151
+ return (React.createElement(FileUploader, __assign({}, args, { onFileRead: handleFileRead, onFileRemove: handleFileRemove, uploadProgress: progress, isLoading: loading, errorMessage: error })));
152
+ };
153
+ export var Default = Template.bind({});
154
+ Default.args = {
155
+ acceptedExtensions: [".pdf"],
156
+ maxFileSizeMB: 5,
157
+ enableDragAndDrop: true,
158
+ buttonLabel: "Choisir un fichier",
159
+ acceptedLabel: "Format accepté :",
160
+ maxSizeLabel: "Taille maximale :",
161
+ iconUrl: pdfIcon,
162
+ };
163
+ export var WithDescription = Template.bind({});
164
+ WithDescription.args = __assign(__assign({}, Default.args), { descriptionParts: {
165
+ beforeLink: "Une",
166
+ linkLabel: "page sera ajoutée",
167
+ linkUrl: "https://example.com",
168
+ afterLink: "à la fin de votre convention d'honoraire précisant les détails du rendez-vous.",
169
+ } });
170
+ export var WithoutDragAndDrop = Template.bind({});
171
+ WithoutDragAndDrop.args = __assign(__assign({}, Default.args), { enableDragAndDrop: false });
172
+ export var WithError = Template.bind({});
173
+ WithError.args = __assign(__assign({}, Default.args), { errorMessage: "Le format du fichier choisi n'est pas supporté ou sa taille dépasse 5 Mo." });
174
+ export var WithProgress = Template.bind({});
175
+ WithProgress.args = __assign(__assign({}, Default.args), { uploadProgress: 6, isLoading: true, fileName: "document.pdf", fileSize: 2 * 1024 * 1024 });
176
+ // Exemple avec des extensions multiples
177
+ export var MultipleExtensions = Template.bind({});
178
+ MultipleExtensions.args = __assign(__assign({}, Default.args), { acceptedExtensions: [".pdf", ".doc", ".docx"] });
@@ -0,0 +1,2 @@
1
+ export { default as FileUploader } from "./FileUploader";
2
+ export type { FileUploaderProps } from "./FileUploader";
@@ -0,0 +1 @@
1
+ export { default as FileUploader } from "./FileUploader";
package/dist/index.d.ts CHANGED
@@ -99,3 +99,5 @@ export { default as BlogText } from "./components/molecules/blogText/BlogText";
99
99
  export type { BlogTextProps } from "./components/molecules/blogText/BlogText";
100
100
  export { default as blogTextImageBlock } from "./components/molecules/blogTextImageBlock/BlogTextImageBlock";
101
101
  export type { BlogTextImageBlockProps } from "./components/molecules/blogTextImageBlock/BlogTextImageBlock";
102
+ export { default as FileUploader } from "./components/molecules/fileUploader/FileUploader";
103
+ export type { FileUploaderProps } from "./components/molecules/fileUploader/FileUploader";
package/dist/index.js CHANGED
@@ -100,3 +100,5 @@ export { default as blogFooter } from "./components/molecules/blogFooter/BlogFoo
100
100
  export { default as BlogCard } from "./components/molecules/blogCard/BlogCard";
101
101
  export { default as BlogText } from "./components/molecules/blogText/BlogText";
102
102
  export { default as blogTextImageBlock } from "./components/molecules/blogTextImageBlock/BlogTextImageBlock";
103
+ // File Uploader
104
+ export { default as FileUploader } from "./components/molecules/fileUploader/FileUploader";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "2.9.9",
3
+ "version": "3.0.1",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",