allaw-ui 2.4.9 → 2.5.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.
@@ -132,7 +132,9 @@ var VerificationCodeInput = function (_a) {
132
132
  ? "[0-9]*"
133
133
  : allowedChars === "alphabetic"
134
134
  ? "[a-zA-Z]*"
135
- : "[a-zA-Z0-9]*", ref: function (input) { return (inputRefs.current[index] = input); }, autoFocus: index === 0 && autoFocus, tabIndex: index === 0 ? 0 : undefined })); });
135
+ : "[a-zA-Z0-9]*", ref: function (input) { return (inputRefs.current[index] = input); }, autoFocus: index === 0 && autoFocus, tabIndex: index === 0 ? 0 : undefined, "data-lpignore": "true" // Empêche Dashlane d'intervenir
136
+ , "data-form-type": "other" // Indique que ce n'est pas un champ de mot de passe
137
+ })); });
136
138
  };
137
139
  return (React.createElement("div", { className: styles.container },
138
140
  React.createElement("div", { className: styles.inputsContainer }, renderInputs()),
@@ -50,39 +50,58 @@ function Select(_a, ref) {
50
50
  // Initialiser avec tous les tags visibles
51
51
  setVisibleTags(selected);
52
52
  setHiddenCount(0);
53
- // Attendre le prochain rendu pour mesurer les dimensions
54
53
  requestAnimationFrame(function () {
55
54
  var container = tagContainerRef.current;
56
55
  if (!container)
57
56
  return;
58
57
  var containerWidth = container.offsetWidth - 40; // Espace pour l'icône et les marges
59
- var totalWidth = 0;
60
- var visibleCount = selected.length;
61
- // Première passe : mesurer la taille réelle de chaque tag
62
- var tagWidths = Array.from(container.children)
63
- .filter(function (child) { return !child.classList.contains("hiddenTagCount"); })
64
- .map(function (tag) { return tag.offsetWidth + 6; }); // 6px pour le gap
65
- // Deuxième passe : calculer combien de tags peuvent tenir
66
- var counterWidth = 60; // Espace estimé pour "+ x autres"
67
- for (var i = 0; i < tagWidths.length; i++) {
68
- var currentTagWidth = tagWidths[i];
69
- var nextWidth = totalWidth + currentTagWidth;
70
- // Si on ajoute ce tag, aurons-nous assez d'espace pour le compteur ?
71
- var remainingTags = selected.length - (i + 1);
72
- var needsCounter = remainingTags > 0;
73
- var spaceNeeded = needsCounter ? counterWidth : 0;
74
- if (nextWidth + spaceNeeded <= containerWidth) {
75
- totalWidth = nextWidth;
76
- visibleCount = i + 1;
58
+ // Fonction pour calculer la largeur totale des tags
59
+ var calculateTagsWidth = function (tags) {
60
+ return tags.reduce(function (total, tag) { return total + tag.offsetWidth + 6; }, 0); // 6px pour le gap
61
+ };
62
+ // Fonction pour créer et mesurer le compteur
63
+ var measureCounter = function (count) {
64
+ var counter = document.createElement("span");
65
+ counter.className = styles.hiddenTagCount;
66
+ counter.textContent = "+ ".concat(count, " autre").concat(count > 1 ? "s" : "");
67
+ container.appendChild(counter);
68
+ var width = counter.offsetWidth;
69
+ container.removeChild(counter);
70
+ return width;
71
+ };
72
+ // Obtenir tous les tags (sans le compteur)
73
+ var allTags = Array.from(container.children).filter(function (child) { return !child.classList.contains("hiddenTagCount"); });
74
+ // Si tous les tags tiennent, on les affiche tous
75
+ var totalWidth = calculateTagsWidth(allTags);
76
+ if (totalWidth <= containerWidth) {
77
+ setVisibleTags(selected);
78
+ setHiddenCount(0);
79
+ return;
80
+ }
81
+ // Sinon, on cherche le nombre optimal de tags à afficher
82
+ var bestVisibleCount = 0;
83
+ // On teste chaque combinaison possible
84
+ for (var i = 1; i <= allTags.length; i++) {
85
+ var visibleTags_1 = allTags.slice(0, i);
86
+ var hiddenCount_1 = selected.length - i;
87
+ var counterWidth = hiddenCount_1 > 0 ? measureCounter(hiddenCount_1) + 6 : 0;
88
+ var totalWidth_1 = calculateTagsWidth(visibleTags_1) + counterWidth;
89
+ if (totalWidth_1 <= containerWidth) {
90
+ bestVisibleCount = i;
77
91
  }
78
92
  else {
79
- break;
93
+ break; // On sort dès qu'on dépasse la largeur disponible
80
94
  }
81
95
  }
82
- // Mettre à jour les états
83
- if (visibleCount < selected.length) {
84
- setVisibleTags(selected.slice(0, visibleCount));
85
- setHiddenCount(selected.length - visibleCount);
96
+ // Mettre à jour avec la meilleure combinaison trouvée
97
+ if (bestVisibleCount > 0) {
98
+ setVisibleTags(selected.slice(0, bestVisibleCount));
99
+ setHiddenCount(selected.length - bestVisibleCount);
100
+ }
101
+ else {
102
+ // Fallback : afficher au moins un tag
103
+ setVisibleTags(selected.slice(0, 1));
104
+ setHiddenCount(selected.length - 1);
86
105
  }
87
106
  });
88
107
  }
@@ -16,6 +16,12 @@
16
16
  letter-spacing: 0.5px;
17
17
  }
18
18
 
19
+ .tiny-info.semiBold14 {
20
+ font-size: 14px;
21
+ font-weight: 600;
22
+ color: var(--Primary-Blanc, #fff);
23
+ }
24
+
19
25
  .tiny-info.medium14 {
20
26
  font-size: 14px;
21
27
  font-weight: 400;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import "./TinyInfo.css";
3
3
  export interface TinyInfoProps {
4
- variant: "bold14" | "medium14" | "semiBold12" | "medium12";
4
+ variant: "bold14" | "medium14" | "semiBold14" | "semiBold12" | "medium12";
5
5
  color?: "bleu-allaw" | "mid-grey" | "dark-grey" | "noir" | "pure-white" | "actions-error" | "actions-valid";
6
6
  text: string;
7
7
  href?: string;
@@ -10,6 +10,7 @@ export interface SelectFormProps {
10
10
  placeHolder?: string;
11
11
  width?: number;
12
12
  selectedItem?: string | string[];
13
+ maxItems?: number;
13
14
  onChange?: (selected: string | string[]) => void;
14
15
  variant?: "bold" | "semiBold" | "medium";
15
16
  color?: "bleu-allaw" | "mid-grey" | "dark-grey" | "noir" | "pure-white" | "grey-venom" | "venom-grey-dark";
@@ -4,12 +4,12 @@ import "../../../styles/global.css";
4
4
  import Paragraph from "../../atoms/typography/Paragraph";
5
5
  import Select from "../../atoms/selects/Select";
6
6
  var SelectForm = function (_a) {
7
- var label = _a.label, isRequired = _a.isRequired, options = _a.options, isMultiple = _a.isMultiple, _b = _a.placeHolder, placeHolder = _b === void 0 ? "Sélectionner une valeur" : _b, _c = _a.width, width = _c === void 0 ? 100 : _c, selectedItem = _a.selectedItem, onChange = _a.onChange, _d = _a.variant, variant = _d === void 0 ? "medium" : _d, _e = _a.color, color = _e === void 0 ? "noir" : _e;
7
+ var label = _a.label, isRequired = _a.isRequired, options = _a.options, isMultiple = _a.isMultiple, _b = _a.placeHolder, placeHolder = _b === void 0 ? "Sélectionner une valeur" : _b, _c = _a.width, width = _c === void 0 ? 100 : _c, selectedItem = _a.selectedItem, maxItems = _a.maxItems, onChange = _a.onChange, _d = _a.variant, variant = _d === void 0 ? "medium" : _d, _e = _a.color, color = _e === void 0 ? "noir" : _e;
8
8
  return (React.createElement("div", { className: "select-form" },
9
9
  React.createElement(Paragraph, { variant: variant, color: color, text: React.createElement(React.Fragment, null,
10
10
  label,
11
11
  " ",
12
12
  isRequired && React.createElement("span", { className: "select-form-required" }, "*")), size: "default" }),
13
- React.createElement(Select, { items: options, multiple: isMultiple, isRequired: isRequired, width: width, placeholder: placeHolder, selectedItem: selectedItem, onChange: onChange })));
13
+ React.createElement(Select, { items: options, multiple: isMultiple, isRequired: isRequired, width: width, placeholder: placeHolder, selectedItem: selectedItem, maxItems: maxItems, onChange: onChange })));
14
14
  };
15
15
  export default SelectForm;
@@ -18,35 +18,49 @@ declare namespace _default {
18
18
  let control_3: string;
19
19
  export { control_3 as control };
20
20
  }
21
- namespace width {
21
+ namespace maxItems {
22
22
  export namespace control_4 {
23
23
  let type: string;
24
24
  let min: number;
25
- let max: number;
26
25
  }
27
26
  export { control_4 as control };
27
+ export namespace _if {
28
+ let arg: string;
29
+ let truthy: boolean;
30
+ }
31
+ export { _if as if };
28
32
  }
29
- namespace selectedItem {
30
- let control_5: string;
31
- export { control_5 as control };
32
- }
33
- namespace variant {
34
- export namespace control_6 {
33
+ namespace width {
34
+ export namespace control_5 {
35
35
  let type_1: string;
36
36
  export { type_1 as type };
37
- let options_1: string[];
38
- export { options_1 as options };
37
+ let min_1: number;
38
+ export { min_1 as min };
39
+ export let max: number;
39
40
  }
41
+ export { control_5 as control };
42
+ }
43
+ namespace selectedItem {
44
+ let control_6: string;
40
45
  export { control_6 as control };
41
46
  }
42
- namespace color {
47
+ namespace variant {
43
48
  export namespace control_7 {
44
49
  let type_2: string;
45
50
  export { type_2 as type };
51
+ let options_1: string[];
52
+ export { options_1 as options };
53
+ }
54
+ export { control_7 as control };
55
+ }
56
+ namespace color {
57
+ export namespace control_8 {
58
+ let type_3: string;
59
+ export { type_3 as type };
46
60
  let options_2: string[];
47
61
  export { options_2 as options };
48
62
  }
49
- export { control_7 as control };
63
+ export { control_8 as control };
50
64
  }
51
65
  }
52
66
  }
@@ -21,6 +21,13 @@ export default {
21
21
  isRequired: { control: "boolean" },
22
22
  options: { control: "object" },
23
23
  isMultiple: { control: "boolean" },
24
+ maxItems: {
25
+ control: {
26
+ type: "number",
27
+ min: 1,
28
+ },
29
+ if: { arg: "isMultiple", truthy: true },
30
+ },
24
31
  width: {
25
32
  control: {
26
33
  type: "number",
@@ -89,6 +96,7 @@ Multiple.args = {
89
96
  isMultiple: true,
90
97
  width: 100,
91
98
  selectedItem: [],
99
+ maxItems: 3,
92
100
  };
93
101
  export var CustomWidth = Template.bind({});
94
102
  CustomWidth.args = __assign(__assign({}, Default.args), { width: 50 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "2.4.9",
3
+ "version": "2.5.1",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",