zuii 1.5.9 → 1.5.11

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.
@@ -27,6 +27,8 @@ interface FileInputProps {
27
27
  /** Si l'enregistrement vidéo est autorisé (défaut: true). */
28
28
  allowVideo?: boolean;
29
29
  };
30
+ /** Le champ est requis. */
31
+ required?: boolean;
30
32
  }
31
33
  /**
32
34
  * Composant FileInput utilisant Uppy.js pour le téléchargement de fichiers.
@@ -35,5 +37,5 @@ interface FileInputProps {
35
37
  * @param {FileInputProps} props - Les propriétés du composant.
36
38
  * @returns {JSX.Element} Le composant FileInput rendu.
37
39
  */
38
- export declare const FileInput: ({ name, lang, restrictions, onComplete, onError, files, webcam }: FileInputProps) => import("react/jsx-runtime").JSX.Element;
40
+ export declare const FileInput: ({ name, lang, restrictions, onComplete, onError, files, webcam, required }: FileInputProps) => import("react/jsx-runtime").JSX.Element;
39
41
  export {};
@@ -1,23 +1,24 @@
1
- import { jsx as p, jsxs as x } from "react/jsx-runtime";
2
- import { useRef as o, useState as b, useEffect as u } from "react";
3
- import { UppyContextProvider as v } from "@uppy/react";
1
+ import { jsx as r, jsxs as b } from "react/jsx-runtime";
2
+ import { useRef as f, useState as v, useEffect as u } from "react";
3
+ import { UppyContextProvider as w } from "@uppy/react";
4
4
  import F from "../../../node_modules/.pnpm/@uppy_react@5.2.0_@uppy_core@5.2.0_@uppy_dashboard@5.1.1_@uppy_core@5.2.0__@uppy_image-editor_4567vrulez5sapld32rywmrijm/node_modules/@uppy/react/lib/Dashboard.js";
5
- import { getUppyLocale as w, createUppyInstance as N, fetchRemoteFiles as R, setupFileOpenButtons as _, syncUppyToInput as B } from "../js/uppy.js";
6
- const j = ({
7
- name: i,
5
+ import { getUppyLocale as N, createUppyInstance as R, fetchRemoteFiles as _, setupFileOpenButtons as B, syncUppyToInput as D } from "../js/uppy.js";
6
+ const L = ({
7
+ name: p,
8
8
  lang: y,
9
9
  restrictions: l,
10
- onComplete: s,
10
+ onComplete: i,
11
11
  onError: t,
12
- files: r,
13
- webcam: g
12
+ files: s,
13
+ webcam: g,
14
+ required: x
14
15
  }) => {
15
- const c = o(null), f = o(null), U = o(/* @__PURE__ */ new Set()), a = w(y), [e] = b(() => N(l || {}, a, g));
16
+ const n = f(null), o = f(null), U = f(/* @__PURE__ */ new Set()), a = N(y), [e] = v(() => R(l || {}, a, g));
16
17
  u(() => {
17
- s && e.on("complete", s), t && e.on("error", t);
18
- const m = () => {
19
- c.current && B(e, c.current);
20
- }, h = [
18
+ i && e.on("complete", i), t && e.on("error", t);
19
+ const h = () => {
20
+ n.current && D(e, n.current);
21
+ }, m = [
21
22
  "file-added",
22
23
  "file-removed",
23
24
  "files-added",
@@ -25,18 +26,18 @@ const j = ({
25
26
  "preprocess-complete",
26
27
  "postprocess-complete"
27
28
  ];
28
- return h.forEach((n) => e.on(n, m)), () => {
29
- s && e.off("complete", s), t && e.off("error", t), h.forEach((n) => e.off(n, m));
29
+ return m.forEach((c) => e.on(c, h)), () => {
30
+ i && e.off("complete", i), t && e.off("error", t), m.forEach((c) => e.off(c, h));
30
31
  };
32
+ }, [e, i, t]), u(() => {
33
+ s && s.length > 0 && _(e, s, U.current, t);
31
34
  }, [e, s, t]), u(() => {
32
- r && r.length > 0 && R(e, r, U.current, t);
33
- }, [e, r, t]), u(() => {
34
- if (f.current)
35
- return _(f.current, e);
35
+ if (o.current)
36
+ return B(o.current, e);
36
37
  }, [e]);
37
38
  const d = !l?.maxNumberOfFiles || l.maxNumberOfFiles > 1;
38
- return /* @__PURE__ */ p(v, { uppy: e, children: /* @__PURE__ */ x("div", { className: "file-input__wrapper", id: i, children: [
39
- /* @__PURE__ */ p("div", { className: "file-input__content", ref: f, children: /* @__PURE__ */ p(
39
+ return /* @__PURE__ */ r(w, { uppy: e, children: /* @__PURE__ */ b("div", { className: "file-input__wrapper", id: p, children: [
40
+ /* @__PURE__ */ r("div", { className: "file-input__content", ref: o, children: /* @__PURE__ */ r(
40
41
  F,
41
42
  {
42
43
  uppy: e,
@@ -51,18 +52,25 @@ const j = ({
51
52
  }
52
53
  }
53
54
  ) }),
54
- i && /* @__PURE__ */ p(
55
+ p && /* @__PURE__ */ r(
55
56
  "input",
56
57
  {
57
- ref: c,
58
+ ref: n,
58
59
  type: "file",
59
- name: d ? `${i}[]` : i,
60
+ name: d ? `${p}[]` : p,
60
61
  multiple: d,
61
- style: { display: "none" }
62
+ style: {
63
+ position: "absolute",
64
+ opacity: "0",
65
+ width: "1px",
66
+ height: "1px",
67
+ pointerEvents: "none"
68
+ },
69
+ required: x
62
70
  }
63
71
  )
64
72
  ] }) });
65
73
  };
66
74
  export {
67
- j as FileInput
75
+ L as FileInput
68
76
  };
@@ -9,8 +9,8 @@ const q = {
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: (s) => `Appuyez sur Entrée pour ajouter **${s}**`,
13
- maxItemText: (s) => `Seulement ${s} options peuvent être sélectionnées`
12
+ addItemText: (n) => `Appuyez sur Entrée pour ajouter **${n}**`,
13
+ maxItemText: (n) => `Seulement ${n} options peuvent être sélectionnées`
14
14
  },
15
15
  en: {
16
16
  placeholder: "Select an option",
@@ -18,40 +18,40 @@ 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: (s) => `Press Enter to add **${s}**`,
22
- maxItemText: (s) => `Only ${s} options can be selected`
21
+ addItemText: (n) => `Press Enter to add **${n}**`,
22
+ maxItemText: (n) => `Only ${n} options can be selected`
23
23
  }
24
24
  }, J = ({
25
- required: s = !1,
26
- options: x,
25
+ required: n = !1,
26
+ options: h,
27
27
  value: t,
28
28
  onChange: a,
29
29
  multiple: i = !1,
30
- placeholder: h = "Sélectionnez une option",
30
+ placeholder: y = "Sélectionnez une option",
31
31
  disabled: v = !1,
32
- searchable: y = !0,
32
+ searchable: T = !0,
33
33
  className: I = "",
34
34
  name: N,
35
- variant: T = "default",
36
- icon: S,
35
+ variant: S = "default",
36
+ icon: A,
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 = h === "Sélectionnez une option" ? m.placeholder : h;
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
40
  u(() => {
41
41
  d.current = a;
42
42
  }, [a]), u(() => {
43
43
  f.current = t;
44
44
  }, [t]);
45
- const R = JSON.stringify(x);
45
+ const R = JSON.stringify(h);
46
46
  return u(() => {
47
47
  if (o.current) {
48
48
  o.current.innerHTML = "";
49
- const e = t ?? f.current, c = x.map((n) => ({
50
- value: n.value,
51
- label: n.text,
52
- selected: Array.isArray(e) ? e.includes(n.value) : e === n.value,
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,
53
53
  customProperties: {
54
- flag: n.flag
54
+ flag: s.flag
55
55
  }
56
56
  }));
57
57
  i || c.unshift({
@@ -63,22 +63,23 @@ const q = {
63
63
  choices: c,
64
64
  removeItemButton: i,
65
65
  placeholderValue: p,
66
- searchEnabled: y,
66
+ searchEnabled: T,
67
67
  silent: !0,
68
- variant: T,
68
+ variant: S,
69
69
  ...m
70
- }, (n) => {
71
- const A = o.current;
72
- A && (A.hidden = !1), f.current = n, d.current && d.current(n);
70
+ }, (s) => {
71
+ f.current = s, d.current && d.current(s);
73
72
  });
73
+ const x = o.current;
74
+ x.hidden = !1;
74
75
  }
75
76
  return () => {
76
77
  r.current && (r.current.destroy(), r.current = null);
77
78
  };
78
- }, [R, i, p, T, y, m]), u(() => {
79
+ }, [R, i, p, S, T, m]), u(() => {
79
80
  if (r.current && t !== void 0) {
80
- const e = r.current.getValue(!0), c = Array.isArray(t) ? t : [t], n = Array.isArray(e) ? e : [e];
81
- JSON.stringify(c.sort()) !== JSON.stringify(n.sort()) && r.current.setChoiceByValue(t);
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);
82
83
  }
83
84
  }, [t]), u(() => {
84
85
  const e = o.current?.closest("fieldset");
@@ -89,7 +90,7 @@ const q = {
89
90
  return c.observe(e, { attributes: !0 }), () => c.disconnect();
90
91
  }
91
92
  }, []), /* @__PURE__ */ E("div", { className: `form__input ${I}`.trim(), children: [
92
- S && /* @__PURE__ */ b(j, { name: S, size: "sm" }),
93
+ A && /* @__PURE__ */ b(j, { name: A, size: "sm" }),
93
94
  /* @__PURE__ */ b(
94
95
  "select",
95
96
  {
@@ -98,7 +99,7 @@ const q = {
98
99
  disabled: v,
99
100
  className: "select",
100
101
  name: N,
101
- required: s
102
+ required: n
102
103
  }
103
104
  )
104
105
  ] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zuii",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
4
4
  "description": "Bibliothèque de composants UI légère, intuitive et modulaire pour les interfaces web modernes.",
5
5
  "type": "module",
6
6
  "repository": {