zuii 1.7.12 → 1.7.14

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.
@@ -1,16 +1,16 @@
1
- import { jsxs as E, jsx as b } from "react/jsx-runtime";
2
- import { useRef as l, useEffect as u } from "react";
3
- import { initSelect as V } from "../js/select.js";
4
- import { Icon as j } from "../../Icon/react/index.js";
5
- const q = {
1
+ import { jsxs as q, jsx as I } from "react/jsx-runtime";
2
+ import { useRef as i, useEffect as l } from "react";
3
+ import { initSelect as z } from "../js/select.js";
4
+ import { Icon as $ } from "../../Icon/react/index.js";
5
+ const L = {
6
6
  fr: {
7
7
  placeholder: "Sélectionnez une option",
8
8
  noResultsText: "Aucun résultat trouvé",
9
9
  noChoicesText: "Aucun choix disponible",
10
10
  uniqueItemText: "Seules les valeurs uniques peuvent être ajoutées",
11
11
  customAddItemText: "Seules les valeurs correspondant à un critère spécifique peuvent être ajoutées",
12
- addItemText: (n) => `Appuyez sur Entrée pour ajouter **${n}**`,
13
- maxItemText: (n) => `Seulement ${n} options peuvent être sélectionnées`
12
+ addItemText: (s) => `Appuyez sur Entrée pour ajouter **${s}**`,
13
+ maxItemText: (s) => `Seulement ${s} options peuvent être sélectionnées`
14
14
  },
15
15
  en: {
16
16
  placeholder: "Select an option",
@@ -18,92 +18,92 @@ const q = {
18
18
  noChoicesText: "No choices to choose from",
19
19
  uniqueItemText: "Only unique values can be added",
20
20
  customAddItemText: "Only values matching specific conditions can be added",
21
- addItemText: (n) => `Press Enter to add **${n}**`,
22
- maxItemText: (n) => `Only ${n} options can be selected`
21
+ addItemText: (s) => `Press Enter to add **${s}**`,
22
+ maxItemText: (s) => `Only ${s} options can be selected`
23
23
  }
24
- }, J = ({
25
- required: n = !1,
26
- options: h,
27
- value: t,
24
+ }, B = ({
25
+ required: s = !1,
26
+ options: T,
27
+ value: n,
28
28
  onChange: a,
29
- multiple: i = !1,
30
- placeholder: y = "Sélectionnez une option",
31
- disabled: v = !1,
32
- searchable: T = !0,
33
- className: I = "",
29
+ multiple: u = !1,
30
+ placeholder: A = "Sélectionnez une option",
31
+ disabled: g = !1,
32
+ searchable: S = !0,
33
+ className: R = "",
34
34
  name: N,
35
- variant: S = "default",
36
- icon: A,
35
+ variant: b = "default",
36
+ icon: v,
37
37
  lang: O
38
38
  }) => {
39
- const o = l(null), r = l(null), d = l(a), f = l(t), g = O || (typeof document < "u" ? document.documentElement.lang : "fr") || "fr", m = q[g.startsWith("en") ? "en" : "fr"], p = y === "Sélectionnez une option" ? m.placeholder : y;
40
- u(() => {
39
+ const o = i(null), t = i(null), d = i(a), f = i(n), m = i(!1), E = O || (typeof document < "u" ? document.documentElement.lang : "fr") || "fr", p = L[E.startsWith("en") ? "en" : "fr"], h = A === "Sélectionnez une option" ? p.placeholder : A;
40
+ l(() => {
41
41
  d.current = a;
42
- }, [a]), u(() => {
43
- f.current = t;
44
- }, [t]);
45
- const R = JSON.stringify(h);
46
- return u(() => {
42
+ }, [a]), l(() => {
43
+ f.current = n;
44
+ }, [n]);
45
+ const V = JSON.stringify(T);
46
+ return l(() => {
47
47
  if (o.current) {
48
48
  o.current.innerHTML = "";
49
- const e = t ?? f.current, c = h.map((s) => ({
50
- value: s.value,
51
- label: s.text,
52
- selected: Array.isArray(e) ? e.includes(s.value) : e === s.value,
49
+ const e = n ?? f.current, c = T.map((r) => ({
50
+ value: r.value,
51
+ label: r.text,
52
+ selected: Array.isArray(e) ? e.includes(r.value) : e === r.value,
53
53
  customProperties: {
54
- flag: s.flag
54
+ flag: r.flag
55
55
  }
56
56
  }));
57
- i || c.unshift({
57
+ u || c.unshift({
58
58
  value: "",
59
- label: p,
59
+ label: h,
60
60
  selected: e === void 0 || e === "",
61
61
  placeholder: !0
62
- }), r.current = V(o.current, {
62
+ }), t.current = z(o.current, {
63
63
  choices: c,
64
- removeItemButton: i,
65
- placeholderValue: p,
66
- searchEnabled: T,
64
+ removeItemButton: u,
65
+ placeholderValue: h,
66
+ searchEnabled: S,
67
67
  silent: !0,
68
- variant: S,
69
- ...m
70
- }, (s) => {
71
- f.current = s, d.current && d.current(s);
68
+ variant: b,
69
+ ...p
70
+ }, (r) => {
71
+ m.current || (f.current = r, d.current && d.current(r));
72
72
  });
73
73
  const x = o.current;
74
74
  x.hidden = !1;
75
75
  }
76
76
  return () => {
77
- r.current && (r.current.destroy(), r.current = null);
77
+ t.current && (t.current.destroy(), t.current = null);
78
78
  };
79
- }, [R, i, p, S, T, m]), u(() => {
80
- if (r.current && t !== void 0) {
81
- const e = r.current.getValue(!0), c = Array.isArray(t) ? t : [t], x = Array.isArray(e) ? e : [e];
82
- JSON.stringify(c.sort()) !== JSON.stringify(x.sort()) && r.current.setChoiceByValue(t);
79
+ }, [V, u, h, b, S, p]), l(() => {
80
+ if (t.current && n !== void 0) {
81
+ const e = t.current.getValue(!0), c = Array.isArray(n) ? n : n === null ? [] : [n], x = Array.isArray(e) ? e : [e], r = (j) => JSON.stringify(j.filter((y) => y != null && y !== "").map(String).sort());
82
+ r(c) !== r(x) && (m.current = !0, u && t.current.removeActiveItems(), c.length && t.current.setChoiceByValue(c), m.current = !1);
83
83
  }
84
- }, [t]), u(() => {
84
+ }, [n]), l(() => {
85
85
  const e = o.current?.closest("fieldset");
86
86
  if (e) {
87
87
  const c = new MutationObserver(() => {
88
- r && (e.disabled ? r.current.disable() : r.current.enable());
88
+ t && (e.disabled ? t.current.disable() : t.current.enable());
89
89
  });
90
90
  return c.observe(e, { attributes: !0 }), () => c.disconnect();
91
91
  }
92
- }, []), /* @__PURE__ */ E("div", { className: `form__input ${I}`.trim(), children: [
93
- A && /* @__PURE__ */ b(j, { name: A, size: "sm" }),
94
- /* @__PURE__ */ b(
92
+ }, []), /* @__PURE__ */ q("div", { className: `form__input ${R}`.trim(), children: [
93
+ v && /* @__PURE__ */ I($, { name: v, size: "sm" }),
94
+ /* @__PURE__ */ I(
95
95
  "select",
96
96
  {
97
97
  ref: o,
98
- multiple: i,
99
- disabled: v,
98
+ multiple: u,
99
+ disabled: g,
100
100
  className: "select",
101
101
  name: N,
102
- required: n
102
+ required: s
103
103
  }
104
104
  )
105
105
  ] });
106
106
  };
107
107
  export {
108
- J as Select
108
+ B as Select
109
109
  };