allaw-ui 2.8.6 → 2.8.7
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/molecules/checkboxForm/ColoredCheckbox.js +22 -1
- package/dist/components/molecules/checkboxForm/ColoredCheckbox.module.css +33 -1
- package/dist/components/molecules/checkboxForm/ColoredCheckbox.stories.d.ts +6 -0
- package/dist/components/molecules/checkboxForm/ColoredCheckbox.stories.js +15 -1
- package/package.json +1 -1
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import styles from "./ColoredCheckbox.module.css";
|
|
3
3
|
import "../../../styles/global.css"; // Pour importer les icônes allaw
|
|
4
|
+
// Fonction pour formater l'email avec des ellipses intelligentes
|
|
5
|
+
var formatEmail = function (email) {
|
|
6
|
+
if (!email || typeof email !== "string" || !email.includes("@")) {
|
|
7
|
+
return email;
|
|
8
|
+
}
|
|
9
|
+
// Diviser l'email en parties
|
|
10
|
+
var _a = email.split("@"), localPart = _a[0], domainFull = _a[1];
|
|
11
|
+
// Diviser la partie domaine
|
|
12
|
+
var lastDotIndex = domainFull.lastIndexOf(".");
|
|
13
|
+
var domainPart = lastDotIndex > 0 ? domainFull.substring(0, lastDotIndex) : domainFull;
|
|
14
|
+
var tld = lastDotIndex > 0 ? domainFull.substring(lastDotIndex) : "";
|
|
15
|
+
return (React.createElement("div", { className: styles.emailContainer },
|
|
16
|
+
React.createElement("span", { className: "".concat(styles.emailPart, " ").concat(styles.emailLocalPart) }, localPart),
|
|
17
|
+
React.createElement("span", null, "@"),
|
|
18
|
+
React.createElement("span", { className: "".concat(styles.emailPart, " ").concat(styles.emailDomainPart) }, domainPart),
|
|
19
|
+
React.createElement("span", { className: styles.emailTLD }, tld)));
|
|
20
|
+
};
|
|
4
21
|
var ColoredCheckbox = function (_a) {
|
|
5
22
|
var id = _a.id, label = _a.label, _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.boxColor, boxColor = _c === void 0 ? "#000000" : _c, _d = _a.markColor, markColor = _d === void 0 ? "#FFFFFF" : _d, _e = _a.textColor, textColor = _e === void 0 ? "#000000" : _e, _f = _a.size, size = _f === void 0 ? "default" : _f, _g = _a.markType, markType = _g === void 0 ? "cross" : _g;
|
|
6
23
|
var _h = useState(checked), isChecked = _h[0], setIsChecked = _h[1];
|
|
@@ -30,8 +47,12 @@ var ColoredCheckbox = function (_a) {
|
|
|
30
47
|
var labelStyle = {
|
|
31
48
|
color: textColor,
|
|
32
49
|
};
|
|
50
|
+
// Formater le label s'il s'agit d'une chaîne de caractères qui ressemble à un email
|
|
51
|
+
var formattedLabel = typeof label === "string" && label.includes("@")
|
|
52
|
+
? formatEmail(label)
|
|
53
|
+
: label;
|
|
33
54
|
return (React.createElement("div", { className: styles.container },
|
|
34
55
|
React.createElement("button", { id: checkboxId, className: "".concat(styles.checkbox, " ").concat(isChecked ? styles.checked : "", " ").concat(size === "small" ? styles.small : ""), onClick: handleClick, style: checkboxStyle, "aria-checked": isChecked, role: "checkbox", "data-cy": "checkbox-".concat(checkboxId) }, isChecked && (React.createElement("span", { className: "".concat(styles.icon, " ").concat(markType === "cross" ? "allaw-icon-close" : "allaw-icon-check"), style: markStyle }))),
|
|
35
|
-
label && (React.createElement("label", { htmlFor: checkboxId, className: styles.label, style: labelStyle, onClick: handleClick },
|
|
56
|
+
label && (React.createElement("label", { htmlFor: checkboxId, className: styles.label, style: labelStyle, onClick: handleClick }, formattedLabel))));
|
|
36
57
|
};
|
|
37
58
|
export default ColoredCheckbox;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: 0.75rem;
|
|
5
5
|
cursor: pointer;
|
|
6
|
+
width: 100%;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
.checkbox {
|
|
@@ -43,9 +44,40 @@
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
.label {
|
|
46
|
-
font-family: sans-serif;
|
|
47
|
+
font-family: "Open Sans", sans-serif;
|
|
47
48
|
font-size: 14px;
|
|
48
49
|
line-height: 1.5;
|
|
49
50
|
cursor: pointer;
|
|
50
51
|
user-select: none;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
text-overflow: ellipsis;
|
|
54
|
+
white-space: nowrap;
|
|
55
|
+
min-width: 0;
|
|
56
|
+
flex: 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.emailContainer {
|
|
60
|
+
display: flex;
|
|
61
|
+
min-width: 0;
|
|
62
|
+
width: 100%;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.emailPart {
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
white-space: nowrap;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.emailLocalPart {
|
|
73
|
+
flex-shrink: 1;
|
|
74
|
+
min-width: 40px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.emailDomainPart {
|
|
78
|
+
flex-shrink: 2;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.emailTLD {
|
|
82
|
+
flex-shrink: 0;
|
|
51
83
|
}
|
|
@@ -75,4 +75,10 @@ export const SmallChecked: any;
|
|
|
75
75
|
export const CustomColors: any;
|
|
76
76
|
export const NoLabel: any;
|
|
77
77
|
export const DarkBackground: any;
|
|
78
|
+
export const EmailLabel: any;
|
|
79
|
+
export const EmailLabelSmallContainer: any;
|
|
80
|
+
export const EmailLabelVerySmallContainer: any;
|
|
81
|
+
export const LongEmailLabel: any;
|
|
82
|
+
export const LongEmailLabelSmallContainer: any;
|
|
83
|
+
export const LongEmailLabelVerySmallContainer: any;
|
|
78
84
|
import ColoredCheckbox from "./ColoredCheckbox";
|
|
@@ -70,7 +70,8 @@ var Template = function (args) {
|
|
|
70
70
|
var handleChange = function (newChecked) {
|
|
71
71
|
setChecked(newChecked);
|
|
72
72
|
};
|
|
73
|
-
return (React.createElement(
|
|
73
|
+
return (React.createElement("div", { style: { width: args.containerWidth || "100%" } },
|
|
74
|
+
React.createElement(ColoredCheckbox, __assign({}, args, { checked: checked, onChange: handleChange }))));
|
|
74
75
|
};
|
|
75
76
|
export var Default = Template.bind({});
|
|
76
77
|
Default.args = {
|
|
@@ -101,3 +102,16 @@ DarkBackground.args = __assign(__assign({}, Default.args), { checked: true, boxC
|
|
|
101
102
|
DarkBackground.parameters = {
|
|
102
103
|
backgrounds: { default: "dark" },
|
|
103
104
|
};
|
|
105
|
+
// Exemples avec des adresses email
|
|
106
|
+
export var EmailLabel = Template.bind({});
|
|
107
|
+
EmailLabel.args = __assign(__assign({}, Default.args), { checked: true, label: "vincent.desbrosses@hotmail.com", boxColor: "#25beeb" });
|
|
108
|
+
export var EmailLabelSmallContainer = Template.bind({});
|
|
109
|
+
EmailLabelSmallContainer.args = __assign(__assign({}, EmailLabel.args), { containerWidth: "300px" });
|
|
110
|
+
export var EmailLabelVerySmallContainer = Template.bind({});
|
|
111
|
+
EmailLabelVerySmallContainer.args = __assign(__assign({}, EmailLabel.args), { containerWidth: "200px" });
|
|
112
|
+
export var LongEmailLabel = Template.bind({});
|
|
113
|
+
LongEmailLabel.args = __assign(__assign({}, Default.args), { checked: true, label: "very.long.email.address.with.many.parts@some-company-with-long-domain-name.com", boxColor: "#25beeb" });
|
|
114
|
+
export var LongEmailLabelSmallContainer = Template.bind({});
|
|
115
|
+
LongEmailLabelSmallContainer.args = __assign(__assign({}, LongEmailLabel.args), { containerWidth: "300px" });
|
|
116
|
+
export var LongEmailLabelVerySmallContainer = Template.bind({});
|
|
117
|
+
LongEmailLabelVerySmallContainer.args = __assign(__assign({}, LongEmailLabel.args), { containerWidth: "200px" });
|