allaw-ui 3.1.2 → 3.1.4
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/components/atoms/checkboxes/Checkbox.css +12 -0
- package/dist/components/atoms/checkboxes/Checkbox.d.ts +1 -1
- package/dist/components/atoms/checkboxes/Checkbox.js +1 -1
- package/dist/components/atoms/checkboxes/Checkbox.stories.js +1 -1
- package/dist/components/molecules/checkboxForm/CheckboxForm.d.ts +1 -1
- package/dist/components/molecules/checkboxForm/CheckboxForm.js +7 -4
- package/dist/components/molecules/checkboxForm/CheckboxForm.stories.d.ts +4 -0
- package/dist/components/molecules/checkboxForm/CheckboxForm.stories.js +9 -1
- package/dist/components/molecules/fileUploader/FileUploader.d.ts +1 -0
- package/dist/components/molecules/fileUploader/FileUploader.js +12 -6
- package/package.json +1 -1
|
@@ -130,3 +130,15 @@
|
|
|
130
130
|
.checkbox-icon-light-pressed {
|
|
131
131
|
padding-left: 5px;
|
|
132
132
|
}
|
|
133
|
+
|
|
134
|
+
.checkbox-style-form {
|
|
135
|
+
border: 2px solid var(--grey-venom, #e6edf5);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.checkbox-style-form:hover {
|
|
139
|
+
border-color: var(--venom-grey-dark, #d1dce8);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.checkbox-style-form.checkbox-pressed {
|
|
143
|
+
border-color: var(--venom-grey-dark, #d1dce8);
|
|
144
|
+
}
|
|
@@ -7,7 +7,7 @@ export interface CheckboxProps {
|
|
|
7
7
|
onChange?: (checked: boolean) => void;
|
|
8
8
|
color?: string;
|
|
9
9
|
size?: "default" | "small";
|
|
10
|
-
style?: "default" | "light";
|
|
10
|
+
style?: "default" | "light" | "form";
|
|
11
11
|
markType?: "cross" | "check";
|
|
12
12
|
}
|
|
13
13
|
declare const Checkbox: React.FC<CheckboxProps>;
|
|
@@ -14,6 +14,6 @@ var Checkbox = function (_a) {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
var checkboxColor = style === "light" ? "light" : color;
|
|
17
|
-
return (React.createElement("button", { id: id, className: "checkbox ".concat(isChecked ? "checkbox-pressed" : "checkbox-default", " ").concat("checkbox-".concat(checkboxColor), " ").concat(size === "small" ? "checkbox-small" : "", " ").concat(style === "light" ? "checkbox-light" : ""), onClick: handleClick, "data-cy": "checkbox-".concat(id) }, isChecked && (React.createElement("span", { className: "checkbox-icon ".concat(markType === "cross" ? "allaw-icon-close" : "allaw-icon-check", " ").concat("checkbox-icon-".concat(checkboxColor), " ").concat(style === "light" ? "checkbox-icon-light" : "") }))));
|
|
17
|
+
return (React.createElement("button", { id: id, className: "checkbox ".concat(isChecked ? "checkbox-pressed" : "checkbox-default", " ").concat("checkbox-".concat(checkboxColor), " ").concat(size === "small" ? "checkbox-small" : "", " ").concat(style === "light" ? "checkbox-light" : "", " ").concat(style === "form" ? "checkbox-style-form" : ""), onClick: handleClick, "data-cy": "checkbox-".concat(id) }, isChecked && (React.createElement("span", { className: "checkbox-icon ".concat(markType === "cross" ? "allaw-icon-close" : "allaw-icon-check", " ").concat("checkbox-icon-".concat(checkboxColor), " ").concat(style === "light" ? "checkbox-icon-light" : "") }))));
|
|
18
18
|
};
|
|
19
19
|
export default Checkbox;
|
|
@@ -12,7 +12,7 @@ export interface CheckboxFormProps {
|
|
|
12
12
|
linkUrl?: string;
|
|
13
13
|
onLinkClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
14
14
|
size?: "default" | "small";
|
|
15
|
-
style?: "default" | "light";
|
|
15
|
+
style?: "default" | "light" | "form";
|
|
16
16
|
markType?: "cross" | "check";
|
|
17
17
|
}
|
|
18
18
|
declare const CheckboxForm: React.FC<CheckboxFormProps>;
|
|
@@ -3,18 +3,21 @@ import Checkbox from "../../atoms/checkboxes/Checkbox";
|
|
|
3
3
|
import Paragraph from "../../atoms/typography/Paragraph";
|
|
4
4
|
import "./CheckboxForm.css";
|
|
5
5
|
var CheckboxForm = function (_a) {
|
|
6
|
-
var id = _a.id, _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange,
|
|
6
|
+
var id = _a.id, _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange, color = _a.color, label = _a.label, _c = _a.isRequired, isRequired = _c === void 0 ? false : _c, linkText = _a.linkText, linkUrl = _a.linkUrl, onLinkClick = _a.onLinkClick, _d = _a.size, size = _d === void 0 ? "default" : _d, _e = _a.style, style = _e === void 0 ? "default" : _e, _f = _a.markType, markType = _f === void 0 ? "cross" : _f;
|
|
7
7
|
var checkboxId = id || "checkbox-".concat(Math.random().toString(36).substr(2, 9));
|
|
8
8
|
var handleCheckboxChange = function (checked) {
|
|
9
9
|
if (onChange) {
|
|
10
10
|
onChange(checked);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// Ne pas appliquer de couleur par défaut si style="form"
|
|
14
|
+
var defaultColor = style === "form" ? undefined : "noir";
|
|
15
|
+
// Appliquer la couleur light si style="light", sinon utiliser la couleur fournie ou la couleur par défaut
|
|
16
|
+
var checkboxColor = style === "light" ? "light" : color || defaultColor;
|
|
17
|
+
return (React.createElement("div", { className: "checkbox-form checkbox-form-".concat(checkboxColor || "noir", " ").concat(size === "small" ? "checkbox-form-small" : "") },
|
|
15
18
|
React.createElement(Checkbox, { id: checkboxId, checked: checked, onChange: handleCheckboxChange, color: checkboxColor, size: size, style: style, markType: markType }),
|
|
16
19
|
label && (React.createElement("label", { htmlFor: checkboxId, className: "checkbox-form-label-container" },
|
|
17
|
-
React.createElement(Paragraph, { variant: "semiBold", color: color, text: React.createElement(React.Fragment, null,
|
|
20
|
+
React.createElement(Paragraph, { variant: style === "form" ? "medium" : "semiBold", color: color || defaultColor, text: React.createElement(React.Fragment, null,
|
|
18
21
|
React.createElement("span", null, label),
|
|
19
22
|
linkText && linkUrl && (React.createElement("a", { href: linkUrl, target: "_blank", rel: "noopener noreferrer", className: "checkbox-form-link", onClick: onLinkClick }, linkText))), size: size }),
|
|
20
23
|
isRequired && (React.createElement("span", { className: "checkbox-form-required" },
|
|
@@ -87,4 +87,8 @@ export const Light: any;
|
|
|
87
87
|
export const LightChecked: any;
|
|
88
88
|
export const LightCheckMark: any;
|
|
89
89
|
export const LightCheckedCheckMark: any;
|
|
90
|
+
export const Form: any;
|
|
91
|
+
export const FormChecked: any;
|
|
92
|
+
export const FormCheckMark: any;
|
|
93
|
+
export const FormCheckedCheckMark: any;
|
|
90
94
|
import CheckboxForm from "./CheckboxForm";
|
|
@@ -58,7 +58,7 @@ export default {
|
|
|
58
58
|
style: {
|
|
59
59
|
control: {
|
|
60
60
|
type: "select",
|
|
61
|
-
options: ["default", "light"],
|
|
61
|
+
options: ["default", "light", "form"],
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
markType: {
|
|
@@ -147,3 +147,11 @@ export var LightCheckMark = Template.bind({});
|
|
|
147
147
|
LightCheckMark.args = __assign(__assign({}, Light.args), { label: "Light CheckboxForm with check mark", markType: "check" });
|
|
148
148
|
export var LightCheckedCheckMark = Template.bind({});
|
|
149
149
|
LightCheckedCheckMark.args = __assign(__assign({}, LightCheckMark.args), { checked: true, label: "Light Checked CheckboxForm with check mark" });
|
|
150
|
+
export var Form = Template.bind({});
|
|
151
|
+
Form.args = __assign(__assign({}, Default.args), { label: "Form CheckboxForm", style: "form" });
|
|
152
|
+
export var FormChecked = Template.bind({});
|
|
153
|
+
FormChecked.args = __assign(__assign({}, Form.args), { checked: true, label: "Form Checked CheckboxForm" });
|
|
154
|
+
export var FormCheckMark = Template.bind({});
|
|
155
|
+
FormCheckMark.args = __assign(__assign({}, Form.args), { label: "Form CheckboxForm with check mark", markType: "check" });
|
|
156
|
+
export var FormCheckedCheckMark = Template.bind({});
|
|
157
|
+
FormCheckedCheckMark.args = __assign(__assign({}, FormCheckMark.args), { checked: true, label: "Form Checked CheckboxForm with check mark" });
|
|
@@ -41,7 +41,7 @@ import ImageCropperModal from "./ImageCropperModal";
|
|
|
41
41
|
import IconButton from "../../atoms/buttons/IconButton";
|
|
42
42
|
import TertiaryButton from "../../atoms/buttons/TertiaryButton";
|
|
43
43
|
var FileUploader = function (_a) {
|
|
44
|
-
var acceptedExtensions = _a.acceptedExtensions, maxFileSizeMB = _a.maxFileSizeMB, _b = _a.enableDragAndDrop, enableDragAndDrop = _b === void 0 ? true : _b, _c = _a.enableCropping, enableCropping = _c === void 0 ? false : _c, _d = _a.cropShape, cropShape = _d === void 0 ? "square" : _d, iconUrl = _a.iconUrl, descriptionParts = _a.descriptionParts, onFileRead = _a.onFileRead, onFileRemove = _a.onFileRemove, _e = _a.uploadProgress, uploadProgress = _e === void 0 ? 0 : _e, _f = _a.isLoading, isLoading = _f === void 0 ? false : _f, _g = _a.autoManageProgress, autoManageProgress = _g === void 0 ? false : _g, _h = _a.progressSteps, progressSteps = _h === void 0 ? 10 : _h, _j = _a.progressInterval, progressInterval = _j === void 0 ? 500 : _j, _k = _a.errorMessage, errorMessage = _k === void 0 ? null : _k, _l = _a.buttonLabel, buttonLabel = _l === void 0 ? "Choisir un fichier" : _l, _m = _a.acceptedLabel, acceptedLabel = _m === void 0 ? "Format accepté :" : _m, _o = _a.maxSizeLabel, maxSizeLabel = _o === void 0 ? "Taille maximale :" : _o, fileName = _a.fileName, fileSize = _a.fileSize, _p = _a.filePresentationLabel, filePresentationLabel = _p === void 0 ? "Voici votre fichier." : _p, initialFile = _a.initialFile, initialPreviewUrl = _a.initialPreviewUrl, initialCropMetadata = _a.initialCropMetadata;
|
|
44
|
+
var acceptedExtensions = _a.acceptedExtensions, maxFileSizeMB = _a.maxFileSizeMB, _b = _a.enableDragAndDrop, enableDragAndDrop = _b === void 0 ? true : _b, _c = _a.enableCropping, enableCropping = _c === void 0 ? false : _c, _d = _a.cropShape, cropShape = _d === void 0 ? "square" : _d, iconUrl = _a.iconUrl, descriptionParts = _a.descriptionParts, onFileRead = _a.onFileRead, onFileRemove = _a.onFileRemove, _e = _a.uploadProgress, uploadProgress = _e === void 0 ? 0 : _e, _f = _a.isLoading, isLoading = _f === void 0 ? false : _f, _g = _a.autoManageProgress, autoManageProgress = _g === void 0 ? false : _g, _h = _a.progressSteps, progressSteps = _h === void 0 ? 10 : _h, _j = _a.progressInterval, progressInterval = _j === void 0 ? 500 : _j, _k = _a.errorMessage, errorMessage = _k === void 0 ? null : _k, _l = _a.buttonLabel, buttonLabel = _l === void 0 ? "Choisir un fichier" : _l, _m = _a.acceptedLabel, acceptedLabel = _m === void 0 ? "Format accepté :" : _m, _o = _a.maxSizeLabel, maxSizeLabel = _o === void 0 ? "Taille maximale :" : _o, fileName = _a.fileName, fileSize = _a.fileSize, _p = _a.filePresentationLabel, filePresentationLabel = _p === void 0 ? "Voici votre fichier." : _p, initialFile = _a.initialFile, initialPreviewUrl = _a.initialPreviewUrl, initialCropMetadata = _a.initialCropMetadata, originalFileName = _a.originalFileName;
|
|
45
45
|
var _q = useState(initialFile || null), selectedFile = _q[0], setSelectedFile = _q[1];
|
|
46
46
|
var _r = useState(null), fileContent = _r[0], setFileContent = _r[1];
|
|
47
47
|
var _s = useState(false), isHovering = _s[0], setIsHovering = _s[1];
|
|
@@ -51,6 +51,7 @@ var FileUploader = function (_a) {
|
|
|
51
51
|
var _w = useState(0), internalProgress = _w[0], setInternalProgress = _w[1];
|
|
52
52
|
var progressIntervalRef = useRef(null);
|
|
53
53
|
var fileInputRef = useRef(null);
|
|
54
|
+
var _x = useState(originalFileName), currentFileName = _x[0], setCurrentFileName = _x[1];
|
|
54
55
|
useEffect(function () {
|
|
55
56
|
if (initialFile) {
|
|
56
57
|
setSelectedFile(initialFile);
|
|
@@ -64,7 +65,10 @@ var FileUploader = function (_a) {
|
|
|
64
65
|
if (initialCropMetadata) {
|
|
65
66
|
setCropMetadata(initialCropMetadata);
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
+
if (originalFileName) {
|
|
69
|
+
setCurrentFileName(originalFileName);
|
|
70
|
+
}
|
|
71
|
+
}, [initialFile, initialPreviewUrl, initialCropMetadata, originalFileName]);
|
|
68
72
|
useEffect(function () {
|
|
69
73
|
return function () {
|
|
70
74
|
if (previewUrl && !initialPreviewUrl) {
|
|
@@ -147,6 +151,7 @@ var FileUploader = function (_a) {
|
|
|
147
151
|
setSelectedFile(null);
|
|
148
152
|
setPreviewUrl(null);
|
|
149
153
|
setCropMetadata(null);
|
|
154
|
+
setCurrentFileName(undefined);
|
|
150
155
|
return [2 /*return*/];
|
|
151
156
|
}
|
|
152
157
|
_a.label = 1;
|
|
@@ -156,6 +161,7 @@ var FileUploader = function (_a) {
|
|
|
156
161
|
case 2:
|
|
157
162
|
content = _a.sent();
|
|
158
163
|
setFileContent(content);
|
|
164
|
+
setCurrentFileName(file.name);
|
|
159
165
|
if (isImageFile(file)) {
|
|
160
166
|
url = URL.createObjectURL(file);
|
|
161
167
|
setPreviewUrl(url);
|
|
@@ -190,6 +196,7 @@ var FileUploader = function (_a) {
|
|
|
190
196
|
setSelectedFile(null);
|
|
191
197
|
setPreviewUrl(null);
|
|
192
198
|
setCropMetadata(null);
|
|
199
|
+
setCurrentFileName(undefined);
|
|
193
200
|
return [3 /*break*/, 4];
|
|
194
201
|
case 4: return [2 /*return*/];
|
|
195
202
|
}
|
|
@@ -214,7 +221,7 @@ var FileUploader = function (_a) {
|
|
|
214
221
|
}
|
|
215
222
|
};
|
|
216
223
|
var handleFileDelete = function () {
|
|
217
|
-
if (previewUrl) {
|
|
224
|
+
if (previewUrl && !initialPreviewUrl) {
|
|
218
225
|
URL.revokeObjectURL(previewUrl);
|
|
219
226
|
}
|
|
220
227
|
if (autoManageProgress) {
|
|
@@ -225,6 +232,7 @@ var FileUploader = function (_a) {
|
|
|
225
232
|
setFileContent(null);
|
|
226
233
|
setPreviewUrl(null);
|
|
227
234
|
setCropMetadata(null);
|
|
235
|
+
setCurrentFileName(undefined);
|
|
228
236
|
resetFileInput();
|
|
229
237
|
onFileRemove === null || onFileRemove === void 0 ? void 0 : onFileRemove();
|
|
230
238
|
};
|
|
@@ -317,9 +325,7 @@ var FileUploader = function (_a) {
|
|
|
317
325
|
React.createElement("div", { className: styles.uploaded_file_icon }, iconUrl ? (React.createElement(Image, { src: iconUrl, alt: "File icon", className: styles.file_icon, width: 20, height: 20 })) : (React.createElement("i", { className: "allaw-icon-file" }))),
|
|
318
326
|
React.createElement("div", { className: styles.uploaded_file_name_size },
|
|
319
327
|
React.createElement("div", { className: styles.uploaded_file_name },
|
|
320
|
-
React.createElement("span", { className: styles.file_name }, displayFileName ||
|
|
321
|
-
(selectedFile === null || selectedFile === void 0 ? void 0 : selectedFile.name) ||
|
|
322
|
-
"Analyse en cours..."),
|
|
328
|
+
React.createElement("span", { className: styles.file_name }, displayFileName || currentFileName || "Analyse en cours..."),
|
|
323
329
|
selectedFile && (React.createElement("i", { className: "allaw-icon-check ".concat(styles.success_icon) }))),
|
|
324
330
|
React.createElement("div", { className: styles.uploaded_file_size },
|
|
325
331
|
React.createElement("span", { className: styles.file_size }, displayFileSize > 0
|