allaw-ui 2.8.5 → 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.d.ts +15 -0
- package/dist/components/molecules/checkboxForm/ColoredCheckbox.js +58 -0
- package/dist/components/molecules/checkboxForm/ColoredCheckbox.module.css +83 -0
- package/dist/components/molecules/checkboxForm/ColoredCheckbox.stories.d.ts +84 -0
- package/dist/components/molecules/checkboxForm/ColoredCheckbox.stories.js +117 -0
- package/dist/components/molecules/checkboxForm/index.d.ts +2 -0
- package/dist/components/molecules/checkboxForm/index.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "../../../styles/global.css";
|
|
3
|
+
export interface ColoredCheckboxProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
onChange?: (checked: boolean) => void;
|
|
8
|
+
boxColor?: string;
|
|
9
|
+
markColor?: string;
|
|
10
|
+
textColor?: string;
|
|
11
|
+
size?: "default" | "small";
|
|
12
|
+
markType?: "cross" | "check";
|
|
13
|
+
}
|
|
14
|
+
declare const ColoredCheckbox: React.FC<ColoredCheckboxProps>;
|
|
15
|
+
export default ColoredCheckbox;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import styles from "./ColoredCheckbox.module.css";
|
|
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
|
+
};
|
|
21
|
+
var ColoredCheckbox = function (_a) {
|
|
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;
|
|
23
|
+
var _h = useState(checked), isChecked = _h[0], setIsChecked = _h[1];
|
|
24
|
+
// Generate a random ID if none is provided
|
|
25
|
+
var checkboxId = id || "checkbox-".concat(Math.random().toString(36).substr(2, 9));
|
|
26
|
+
var handleClick = function (e) {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
var newChecked = !isChecked;
|
|
30
|
+
setIsChecked(newChecked);
|
|
31
|
+
if (onChange) {
|
|
32
|
+
onChange(newChecked);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// Update internal state when checked prop changes
|
|
36
|
+
React.useEffect(function () {
|
|
37
|
+
setIsChecked(checked);
|
|
38
|
+
}, [checked]);
|
|
39
|
+
// Create custom styles for the checkbox and mark
|
|
40
|
+
var checkboxStyle = {
|
|
41
|
+
backgroundColor: isChecked ? boxColor : "transparent",
|
|
42
|
+
borderColor: boxColor,
|
|
43
|
+
};
|
|
44
|
+
var markStyle = {
|
|
45
|
+
color: markColor,
|
|
46
|
+
};
|
|
47
|
+
var labelStyle = {
|
|
48
|
+
color: textColor,
|
|
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;
|
|
54
|
+
return (React.createElement("div", { className: styles.container },
|
|
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 }))),
|
|
56
|
+
label && (React.createElement("label", { htmlFor: checkboxId, className: styles.label, style: labelStyle, onClick: handleClick }, formattedLabel))));
|
|
57
|
+
};
|
|
58
|
+
export default ColoredCheckbox;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 0.75rem;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
width: 100%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.checkbox {
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
width: 24px;
|
|
14
|
+
height: 24px;
|
|
15
|
+
border-radius: 4px;
|
|
16
|
+
border: 2px solid;
|
|
17
|
+
background: transparent;
|
|
18
|
+
padding: 0;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition: background-color 0.2s ease;
|
|
21
|
+
flex-shrink: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.checkbox.small {
|
|
25
|
+
width: 20px;
|
|
26
|
+
height: 20px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.checkbox.checked {
|
|
30
|
+
border: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.icon {
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
align-items: center;
|
|
37
|
+
font-size: 15px;
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.small .icon {
|
|
43
|
+
font-size: 11px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.label {
|
|
47
|
+
font-family: "Open Sans", sans-serif;
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
line-height: 1.5;
|
|
50
|
+
cursor: pointer;
|
|
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;
|
|
83
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export let title: string;
|
|
3
|
+
export { ColoredCheckbox as component };
|
|
4
|
+
export let tags: string[];
|
|
5
|
+
export namespace args {
|
|
6
|
+
let label: string;
|
|
7
|
+
}
|
|
8
|
+
export namespace argTypes {
|
|
9
|
+
export namespace checked {
|
|
10
|
+
namespace control {
|
|
11
|
+
let type: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export namespace onChange {
|
|
15
|
+
let action: string;
|
|
16
|
+
}
|
|
17
|
+
export namespace label_1 {
|
|
18
|
+
let control_1: string;
|
|
19
|
+
export { control_1 as control };
|
|
20
|
+
}
|
|
21
|
+
export { label_1 as label };
|
|
22
|
+
export namespace boxColor {
|
|
23
|
+
let control_2: string;
|
|
24
|
+
export { control_2 as control };
|
|
25
|
+
export let defaultValue: string;
|
|
26
|
+
}
|
|
27
|
+
export namespace markColor {
|
|
28
|
+
let control_3: string;
|
|
29
|
+
export { control_3 as control };
|
|
30
|
+
let defaultValue_1: string;
|
|
31
|
+
export { defaultValue_1 as defaultValue };
|
|
32
|
+
}
|
|
33
|
+
export namespace textColor {
|
|
34
|
+
let control_4: string;
|
|
35
|
+
export { control_4 as control };
|
|
36
|
+
let defaultValue_2: string;
|
|
37
|
+
export { defaultValue_2 as defaultValue };
|
|
38
|
+
}
|
|
39
|
+
export namespace size {
|
|
40
|
+
export namespace control_5 {
|
|
41
|
+
let type_1: string;
|
|
42
|
+
export { type_1 as type };
|
|
43
|
+
export let options: string[];
|
|
44
|
+
}
|
|
45
|
+
export { control_5 as control };
|
|
46
|
+
}
|
|
47
|
+
export namespace markType {
|
|
48
|
+
export namespace control_6 {
|
|
49
|
+
let type_2: string;
|
|
50
|
+
export { type_2 as type };
|
|
51
|
+
let options_1: string[];
|
|
52
|
+
export { options_1 as options };
|
|
53
|
+
}
|
|
54
|
+
export { control_6 as control };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export namespace parameters {
|
|
58
|
+
namespace backgrounds {
|
|
59
|
+
let _default: string;
|
|
60
|
+
export { _default as default };
|
|
61
|
+
export let values: {
|
|
62
|
+
name: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}[];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export default _default;
|
|
69
|
+
export const Default: any;
|
|
70
|
+
export const Checked: any;
|
|
71
|
+
export const CheckMark: any;
|
|
72
|
+
export const CheckedCheckMark: any;
|
|
73
|
+
export const Small: any;
|
|
74
|
+
export const SmallChecked: any;
|
|
75
|
+
export const CustomColors: any;
|
|
76
|
+
export const NoLabel: any;
|
|
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;
|
|
84
|
+
import ColoredCheckbox from "./ColoredCheckbox";
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
import React, { useState } from "react";
|
|
13
|
+
import ColoredCheckbox from "./ColoredCheckbox";
|
|
14
|
+
export default {
|
|
15
|
+
title: "Components/Molecules/ColoredCheckbox",
|
|
16
|
+
component: ColoredCheckbox,
|
|
17
|
+
tags: ["autodocs"],
|
|
18
|
+
args: {
|
|
19
|
+
label: "Sample label",
|
|
20
|
+
},
|
|
21
|
+
argTypes: {
|
|
22
|
+
checked: {
|
|
23
|
+
control: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
onChange: { action: "changed" },
|
|
28
|
+
label: {
|
|
29
|
+
control: "text",
|
|
30
|
+
},
|
|
31
|
+
boxColor: {
|
|
32
|
+
control: "color",
|
|
33
|
+
defaultValue: "#000000",
|
|
34
|
+
},
|
|
35
|
+
markColor: {
|
|
36
|
+
control: "color",
|
|
37
|
+
defaultValue: "#FFFFFF",
|
|
38
|
+
},
|
|
39
|
+
textColor: {
|
|
40
|
+
control: "color",
|
|
41
|
+
defaultValue: "#000000",
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
control: {
|
|
45
|
+
type: "select",
|
|
46
|
+
options: ["default", "small"],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
markType: {
|
|
50
|
+
control: {
|
|
51
|
+
type: "select",
|
|
52
|
+
options: ["cross", "check"],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
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
|
+
};
|
|
68
|
+
var Template = function (args) {
|
|
69
|
+
var _a = useState(args.checked), checked = _a[0], setChecked = _a[1];
|
|
70
|
+
var handleChange = function (newChecked) {
|
|
71
|
+
setChecked(newChecked);
|
|
72
|
+
};
|
|
73
|
+
return (React.createElement("div", { style: { width: args.containerWidth || "100%" } },
|
|
74
|
+
React.createElement(ColoredCheckbox, __assign({}, args, { checked: checked, onChange: handleChange }))));
|
|
75
|
+
};
|
|
76
|
+
export var Default = Template.bind({});
|
|
77
|
+
Default.args = {
|
|
78
|
+
checked: false,
|
|
79
|
+
label: "Default Checkbox",
|
|
80
|
+
boxColor: "#000000",
|
|
81
|
+
markColor: "#FFFFFF",
|
|
82
|
+
textColor: "#000000",
|
|
83
|
+
size: "default",
|
|
84
|
+
markType: "cross",
|
|
85
|
+
};
|
|
86
|
+
export var Checked = Template.bind({});
|
|
87
|
+
Checked.args = __assign(__assign({}, Default.args), { checked: true, label: "Checked Checkbox" });
|
|
88
|
+
export var CheckMark = Template.bind({});
|
|
89
|
+
CheckMark.args = __assign(__assign({}, Default.args), { label: "Checkbox with check mark", markType: "check" });
|
|
90
|
+
export var CheckedCheckMark = Template.bind({});
|
|
91
|
+
CheckedCheckMark.args = __assign(__assign({}, CheckMark.args), { checked: true, label: "Checked Checkbox with check mark" });
|
|
92
|
+
export var Small = Template.bind({});
|
|
93
|
+
Small.args = __assign(__assign({}, Default.args), { label: "Small Checkbox", size: "small" });
|
|
94
|
+
export var SmallChecked = Template.bind({});
|
|
95
|
+
SmallChecked.args = __assign(__assign({}, Small.args), { checked: true, label: "Small Checked Checkbox" });
|
|
96
|
+
export var CustomColors = Template.bind({});
|
|
97
|
+
CustomColors.args = __assign(__assign({}, Default.args), { checked: true, label: "Custom Colors Checkbox", boxColor: "#25beeb", markColor: "#FFFFFF", textColor: "#456073" });
|
|
98
|
+
export var NoLabel = Template.bind({});
|
|
99
|
+
NoLabel.args = __assign(__assign({}, Default.args), { label: undefined });
|
|
100
|
+
export var DarkBackground = Template.bind({});
|
|
101
|
+
DarkBackground.args = __assign(__assign({}, Default.args), { checked: true, boxColor: "#FFFFFF", markColor: "#000000", textColor: "#FFFFFF" });
|
|
102
|
+
DarkBackground.parameters = {
|
|
103
|
+
backgrounds: { default: "dark" },
|
|
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" });
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,9 @@ export { default as EmployeeCard } from "./components/molecules/employeeCard/Emp
|
|
|
62
62
|
export { default as Stepper } from "./components/molecules/stepper/Stepper";
|
|
63
63
|
export type { StepperProps } from "./components/molecules/stepper/Stepper";
|
|
64
64
|
export { default as CheckboxForm } from "./components/molecules/checkboxForm/CheckboxForm";
|
|
65
|
+
export type { CheckboxFormProps } from "./components/molecules/checkboxForm/CheckboxForm";
|
|
66
|
+
export { default as ColoredCheckbox } from "./components/molecules/checkboxForm/ColoredCheckbox";
|
|
67
|
+
export type { ColoredCheckboxProps } from "./components/molecules/checkboxForm/ColoredCheckbox";
|
|
65
68
|
export { default as RadioForm } from "./components/molecules/radioForm/RadioForm";
|
|
66
69
|
export { default as SelectForm } from "./components/molecules/selectForm/SelectForm";
|
|
67
70
|
export { default as Breadcrumb } from "./components/molecules/breadcrumb/Breadcrumb";
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,7 @@ export { default as EmployeeCard } from "./components/molecules/employeeCard/Emp
|
|
|
72
72
|
export { default as Stepper } from "./components/molecules/stepper/Stepper";
|
|
73
73
|
// CheckboxForm
|
|
74
74
|
export { default as CheckboxForm } from "./components/molecules/checkboxForm/CheckboxForm";
|
|
75
|
+
export { default as ColoredCheckbox } from "./components/molecules/checkboxForm/ColoredCheckbox";
|
|
75
76
|
// RadioForm
|
|
76
77
|
export { default as RadioForm } from "./components/molecules/radioForm/RadioForm";
|
|
77
78
|
// SelectForm
|