allaw-ui 2.8.8 → 2.9.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.
@@ -11,6 +11,9 @@ export interface ColoredCheckboxProps {
11
11
  size?: "default" | "small";
12
12
  markType?: "cross" | "check";
13
13
  isSignedIn?: boolean;
14
+ unlinkIconPath?: string | {
15
+ default: string;
16
+ };
14
17
  }
15
18
  declare const ColoredCheckbox: React.FC<ColoredCheckboxProps>;
16
19
  export default ColoredCheckbox;
@@ -1,6 +1,9 @@
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
+ // URL data en base64 pour l'icône de déconnexion (solution de secours)
5
+ // Cette icône représente un lien brisé/déconnecté en rouge
6
+ var DEFAULT_UNLINK_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTAuNjY3IDEwLjY2N0w4LjY2NyA4LjY2NyIgc3Ryb2tlPSIjRkYwMDAwIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PHBhdGggZD0iTTEyLjY2NyA0LjY2N0MxMy40MDMgNS40MDMgMTMuNDAzIDYuNTk3IDEyLjY2NyA3LjMzM0MxMS45MyA4LjA3IDEwLjczNyA4LjA3IDEwIDcuMzMzQzkuMjYzIDYuNTk3IDkuMjYzIDUuNDAzIDEwIDQuNjY3QzEwLjczNyAzLjkzIDExLjkzIDMuOTMgMTIuNjY3IDQuNjY3WiIgc3Ryb2tlPSIjRkYwMDAwIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PHBhdGggZD0iTTUuMzMzIDExLjMzM0M2LjA3IDEyLjA3IDcuMjYzIDEyLjA3IDggMTEuMzMzQzguNzM3IDEwLjU5NyA4LjczNyA5LjQwMyA4IDguNjY3QzcuMjYzIDcuOTMgNi4wNyA3LjkzIDUuMzMzIDguNjY3QzQuNTk3IDkuNDAzIDQuNTk3IDEwLjU5NyA1LjMzMyAxMS4zMzNaIiBzdHJva2U9IiNGRjAwMDAiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48cGF0aCBkPSJNNy4zMzMgNy4zMzNMNS4zMzMgNS4zMzMiIHN0cm9rZT0iI0ZGMDAwMCIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==";
4
7
  // Fonction pour formater l'email avec des ellipses intelligentes
5
8
  var formatEmail = function (email) {
6
9
  if (!email || typeof email !== "string" || !email.includes("@")) {
@@ -19,8 +22,9 @@ var formatEmail = function (email) {
19
22
  React.createElement("span", { className: styles.emailTLD }, tld)));
20
23
  };
21
24
  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, _h = _a.isSignedIn, isSignedIn = _h === void 0 ? true : _h;
23
- var _j = useState(checked), isChecked = _j[0], setIsChecked = _j[1];
25
+ var id = _a.id, _b = _a.label, label = _b === void 0 ? "mon-email@provider.com" : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, onChange = _a.onChange, _d = _a.boxColor, boxColor = _d === void 0 ? "#000000" : _d, _e = _a.markColor, markColor = _e === void 0 ? "#FFFFFF" : _e, _f = _a.textColor, textColor = _f === void 0 ? "#000000" : _f, _g = _a.size, size = _g === void 0 ? "default" : _g, _h = _a.markType, markType = _h === void 0 ? "cross" : _h, _j = _a.isSignedIn, isSignedIn = _j === void 0 ? true : _j, _k = _a.unlinkIconPath, unlinkIconPath = _k === void 0 ? "/assets/images/allaw-icon-unlink-red.svg" : _k;
26
+ var _l = useState(checked), isChecked = _l[0], setIsChecked = _l[1];
27
+ var _m = useState(false), iconError = _m[0], setIconError = _m[1];
24
28
  // Generate a random ID if none is provided
25
29
  var checkboxId = id || "checkbox-".concat(Math.random().toString(36).substr(2, 9));
26
30
  var handleClick = function (e) {
@@ -51,9 +55,20 @@ var ColoredCheckbox = function (_a) {
51
55
  var formattedLabel = typeof label === "string" && label.includes("@")
52
56
  ? formatEmail(label)
53
57
  : label;
58
+ // Gérer les différents formats d'importation d'image
59
+ var getIconPath = function () {
60
+ if (!unlinkIconPath)
61
+ return DEFAULT_UNLINK_ICON;
62
+ // Si c'est un objet importé (comme avec import x from 'y')
63
+ if (typeof unlinkIconPath === "object" && unlinkIconPath.default) {
64
+ return unlinkIconPath.default;
65
+ }
66
+ // Si c'est une chaîne de caractères
67
+ return unlinkIconPath;
68
+ };
54
69
  return (React.createElement("div", { className: styles.container },
55
70
  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
- isSignedIn === false && (React.createElement("img", { src: "/assets/allaw-icon-unlink-red.svg", alt: "Non connect\u00E9", className: styles.unlinkIcon })),
71
+ isSignedIn === false && (React.createElement("img", { src: iconError ? DEFAULT_UNLINK_ICON : getIconPath(), alt: "Non connect\u00E9", className: styles.unlinkIcon, width: "16", height: "16", style: { width: "16px", height: "16px" }, onError: function () { return setIconError(true); } })),
57
72
  label && (React.createElement("label", { htmlFor: checkboxId, className: styles.label, style: labelStyle, onClick: handleClick }, formattedLabel))));
58
73
  };
59
74
  export default ColoredCheckbox;
@@ -4,13 +4,17 @@ declare namespace _default {
4
4
  export let tags: string[];
5
5
  export namespace args {
6
6
  let label: string;
7
+ let checked: boolean;
8
+ let boxColor: string;
9
+ let markType: string;
7
10
  }
8
11
  export namespace argTypes {
9
- export namespace checked {
12
+ export namespace checked_1 {
10
13
  namespace control {
11
14
  let type: string;
12
15
  }
13
16
  }
17
+ export { checked_1 as checked };
14
18
  export namespace onChange {
15
19
  let action: string;
16
20
  }
@@ -19,11 +23,12 @@ declare namespace _default {
19
23
  export { control_1 as control };
20
24
  }
21
25
  export { label_1 as label };
22
- export namespace boxColor {
26
+ export namespace boxColor_1 {
23
27
  let control_2: string;
24
28
  export { control_2 as control };
25
29
  export let defaultValue: string;
26
30
  }
31
+ export { boxColor_1 as boxColor };
27
32
  export namespace markColor {
28
33
  let control_3: string;
29
34
  export { control_3 as control };
@@ -44,7 +49,7 @@ declare namespace _default {
44
49
  }
45
50
  export { control_5 as control };
46
51
  }
47
- export namespace markType {
52
+ export namespace markType_1 {
48
53
  export namespace control_6 {
49
54
  let type_2: string;
50
55
  export { type_2 as type };
@@ -53,6 +58,7 @@ declare namespace _default {
53
58
  }
54
59
  export { control_6 as control };
55
60
  }
61
+ export { markType_1 as markType };
56
62
  export namespace isSignedIn {
57
63
  export namespace control_7 {
58
64
  let type_3: string;
@@ -62,6 +68,11 @@ declare namespace _default {
62
68
  let defaultValue_3: boolean;
63
69
  export { defaultValue_3 as defaultValue };
64
70
  }
71
+ export namespace unlinkIconPath {
72
+ let control_8: string;
73
+ export { control_8 as control };
74
+ export let description: string;
75
+ }
65
76
  }
66
77
  export namespace parameters {
67
78
  namespace backgrounds {
@@ -93,4 +104,5 @@ export const LongEmailLabelVerySmallContainer: any;
93
104
  export const NotSignedIn: any;
94
105
  export const NotSignedInEmail: any;
95
106
  export const NotSignedInChecked: any;
107
+ export const CustomIconPath: any;
96
108
  import ColoredCheckbox from "./ColoredCheckbox";
@@ -16,7 +16,10 @@ export default {
16
16
  component: ColoredCheckbox,
17
17
  tags: ["autodocs"],
18
18
  args: {
19
- label: "Sample label",
19
+ label: "my-email-address@provider.com",
20
+ checked: true,
21
+ boxColor: "#25beeb",
22
+ markType: "check",
20
23
  },
21
24
  argTypes: {
22
25
  checked: {
@@ -30,7 +33,7 @@ export default {
30
33
  },
31
34
  boxColor: {
32
35
  control: "color",
33
- defaultValue: "#000000",
36
+ defaultValue: "#25beeb",
34
37
  },
35
38
  markColor: {
36
39
  control: "color",
@@ -58,6 +61,10 @@ export default {
58
61
  },
59
62
  defaultValue: true,
60
63
  },
64
+ unlinkIconPath: {
65
+ control: "text",
66
+ description: "Chemin vers l'icône de déconnexion",
67
+ },
61
68
  },
62
69
  parameters: {
63
70
  backgrounds: {
@@ -81,13 +88,13 @@ var Template = function (args) {
81
88
  };
82
89
  export var Default = Template.bind({});
83
90
  Default.args = {
84
- checked: false,
85
- label: "Default Checkbox",
86
- boxColor: "#000000",
91
+ checked: true,
92
+ label: "my-email-address@provider.com",
93
+ boxColor: "#25beeb",
87
94
  markColor: "#FFFFFF",
88
95
  textColor: "#000000",
89
96
  size: "default",
90
- markType: "cross",
97
+ markType: "check",
91
98
  isSignedIn: true,
92
99
  };
93
100
  export var Checked = Template.bind({});
@@ -129,3 +136,6 @@ export var NotSignedInEmail = Template.bind({});
129
136
  NotSignedInEmail.args = __assign(__assign({}, EmailLabel.args), { label: "vincent.desbrosses@hotmail.com", isSignedIn: false });
130
137
  export var NotSignedInChecked = Template.bind({});
131
138
  NotSignedInChecked.args = __assign(__assign({}, NotSignedIn.args), { checked: true });
139
+ // Exemple avec un chemin d'icône personnalisé
140
+ export var CustomIconPath = Template.bind({});
141
+ CustomIconPath.args = __assign({}, NotSignedIn.args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "2.8.8",
3
+ "version": "2.9.0",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",