zuii 1.4.21 → 1.4.23

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,59 +1,31 @@
1
1
  /**
2
- * Props du composant FileInput.
2
+ * Propriétés du composant FileInput.
3
3
  */
4
- export interface FileInputProps {
5
- /**
6
- * ID unique pour l'instance Uppy.
7
- */
8
- id?: string;
9
- /**
10
- * Nom du champ pour le formulaire.
11
- */
4
+ interface FileInputProps {
5
+ /** Nom du champ. */
12
6
  name?: string;
13
- /**
14
- * Nombre maximum de fichiers autorisés.
15
- */
16
- maxNumberOfFiles?: number;
17
- /**
18
- * Taille maximale d'un fichier en octets.
19
- */
20
- maxFileSize?: number;
21
- /**
22
- * Types de fichiers autorisés (MIME types).
23
- */
24
- allowedFileTypes?: string[] | null;
25
- /**
26
- * Callback appelé lors de la complétion du téléchargement.
27
- * @param {any} result - Le résultat du téléchargement.
28
- */
7
+ /** Langue du composant ('fr' ou 'en'). */
8
+ lang?: 'fr' | 'en';
9
+ /** Restrictions de téléchargement. */
10
+ restrictions?: {
11
+ /** Nombre maximum de fichiers. */
12
+ maxNumberOfFiles?: number;
13
+ /** Taille maximum d'un fichier en octets. */
14
+ maxFileSize?: number;
15
+ /** Types de fichiers autorisés. */
16
+ allowedFileTypes?: string[];
17
+ };
18
+ /** Callback appelé lors de la fin du téléchargement. */
29
19
  onComplete?: (result: any) => void;
30
- /**
31
- * Callback appelé lors d'une erreur.
32
- * @param {Error} error - L'erreur survenue.
33
- */
34
- onError?: (error: Error) => void;
35
- /**
36
- * Hauteur du dashboard Uppy en pixels.
37
- */
38
- height?: number;
39
- /**
40
- * Classe CSS personnalisée.
41
- */
42
- className?: string;
43
- /**
44
- * Afficher les détails de progression.
45
- */
46
- hideProgressDetails?: boolean;
47
- /**
48
- * Afficher le logo Uppy.
49
- */
50
- proudlyDisplayPoweredByUppy?: boolean;
20
+ /** Callback appelé en cas d'erreur. */
21
+ onError?: (error: any) => void;
51
22
  }
52
23
  /**
53
- * Composant FileInput utilisant une instance stable et le Dashboard officiel d'Uppy.
54
- * Gère la synchronisation avec un input caché pour les soumissions de formulaire.
24
+ * Composant FileInput utilisant Uppy.js pour le téléchargement de fichiers.
25
+ * Affiche le Dashboard Uppy complet par défaut.
55
26
  *
56
27
  * @param {FileInputProps} props - Les propriétés du composant.
57
- * @returns {JSX.Element} Le composant FileInput.
28
+ * @returns {JSX.Element} Le composant FileInput rendu.
58
29
  */
59
- export declare const FileInput: ({ id, name, maxNumberOfFiles, maxFileSize, allowedFileTypes, onComplete, onError, height, className, hideProgressDetails, proudlyDisplayPoweredByUppy, }: FileInputProps) => import("react/jsx-runtime").JSX.Element;
30
+ export declare const FileInput: ({ name, lang, restrictions, onComplete, onError }: FileInputProps) => import("react/jsx-runtime").JSX.Element;
31
+ export {};
@@ -0,0 +1,84 @@
1
+ import { jsx as f, jsxs as y } from "react/jsx-runtime";
2
+ import { useRef as g, useState as F, useEffect as b } from "react";
3
+ import x from "@uppy/core";
4
+ import { UppyContextProvider as v } from "@uppy/react";
5
+ import w 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";
6
+ import N from "@uppy/compressor";
7
+ import _ from "@uppy/image-editor";
8
+ import U from "../../../node_modules/.pnpm/@uppy_locales@5.1.1/node_modules/@uppy/locales/lib/fr_FR.js";
9
+ import D from "../../../node_modules/.pnpm/@uppy_locales@5.1.1/node_modules/@uppy/locales/lib/en_US.js";
10
+ const M = ({
11
+ name: o,
12
+ lang: u,
13
+ restrictions: m,
14
+ onComplete: i,
15
+ onError: n
16
+ }) => {
17
+ const l = {
18
+ maxNumberOfFiles: null,
19
+ maxFileSize: null,
20
+ allowedFileTypes: null,
21
+ ...m
22
+ }, a = g(null), c = (u || (typeof document < "u" ? document.documentElement.lang : "fr") || "fr").startsWith("en") ? D : U, [e] = F(() => {
23
+ const r = new x({
24
+ locale: c,
25
+ restrictions: l
26
+ });
27
+ return r.use(N), r.use(_), r;
28
+ });
29
+ b(() => {
30
+ i && e.on("complete", i), n && e.on("error", n);
31
+ const r = () => {
32
+ if (!a.current) return;
33
+ const t = new DataTransfer();
34
+ e.getFiles().forEach((s) => {
35
+ if (s.data instanceof File)
36
+ t.items.add(s.data);
37
+ else if (s.data instanceof Blob) {
38
+ const h = new File([s.data], s.name, { type: s.data.type });
39
+ t.items.add(h);
40
+ }
41
+ }), a.current.files = t.files, a.current.dispatchEvent(new Event("change", { bubbles: !0 }));
42
+ }, d = [
43
+ "file-added",
44
+ "file-removed",
45
+ "files-added",
46
+ "file-editor:complete",
47
+ "preprocess-complete",
48
+ "postprocess-complete"
49
+ ];
50
+ return d.forEach((t) => e.on(t, r)), () => {
51
+ i && e.off("complete", i), n && e.off("error", n), d.forEach((t) => e.off(t, r));
52
+ };
53
+ }, [e, i, n]);
54
+ const p = l.maxNumberOfFiles === null || l.maxNumberOfFiles === void 0 || l.maxNumberOfFiles > 1;
55
+ return /* @__PURE__ */ f(v, { uppy: e, children: /* @__PURE__ */ y("div", { className: "file-input__wrapper", id: o, children: [
56
+ /* @__PURE__ */ f("div", { className: "file-input__content", children: /* @__PURE__ */ f(
57
+ w,
58
+ {
59
+ uppy: e,
60
+ width: "100%",
61
+ height: 300,
62
+ hideProgressDetails: !1,
63
+ hideUploadButton: !0,
64
+ proudlyDisplayPoweredByUppy: !1,
65
+ locale: {
66
+ strings: c.strings
67
+ }
68
+ }
69
+ ) }),
70
+ o && /* @__PURE__ */ f(
71
+ "input",
72
+ {
73
+ ref: a,
74
+ type: "file",
75
+ name: p ? `${o}[]` : o,
76
+ multiple: p,
77
+ style: { display: "none" }
78
+ }
79
+ )
80
+ ] }) });
81
+ };
82
+ export {
83
+ M as FileInput
84
+ };
@@ -3,35 +3,36 @@ import { Form as r, InputGroup as C } from "react-bootstrap";
3
3
  import { Icon as c } from "../../Icon/react/index.js";
4
4
  import d from "../../../node_modules/.pnpm/react-bootstrap@2.10.10_@types_react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-bootstrap/esm/FloatingLabel.js";
5
5
  import '../style/index.css';/* empty css */
6
- import { NumberInput as h } from "./NumberInput.js";
7
- import { TelInput as b } from "./TelInput.js";
8
- import { PasswordInput as F } from "./PasswordInput.js";
9
- import { PasswordConfirm as I } from "./PasswordConfirm.js";
6
+ import { NumberInput as F } from "./NumberInput.js";
7
+ import { TelInput as h } from "./TelInput.js";
8
+ import { PasswordInput as I } from "./PasswordInput.js";
9
+ import { PasswordConfirm as b } from "./PasswordConfirm.js";
10
10
  import { RangeInput as w } from "./RangeInput.js";
11
- import { Select as N } from "./Select.js";
12
- import { handleNumericKeyDown as _ } from "../js/number.js";
13
- import { FormColor as x } from "./FormColor.js";
14
- import { FormDate as y } from "./FormDate.js";
15
- const D = ({
11
+ import { FileInput as N } from "./FileInput.js";
12
+ import { Select as _ } from "./Select.js";
13
+ import { handleNumericKeyDown as x } from "../js/number.js";
14
+ import { FormColor as y } from "./FormColor.js";
15
+ import { FormDate as D } from "./FormDate.js";
16
+ const g = ({
16
17
  label: n,
17
- floating: l,
18
+ floating: a,
18
19
  icon: m,
19
- children: a,
20
+ children: l,
20
21
  onKeyDown: i,
21
22
  ...e
22
23
  }) => {
23
- const f = (p) => {
24
- e.type === "number" && _(p), i && i(p);
25
- }, u = e.type === "number" ? "decimal" : void 0;
26
- return l && n ? /* @__PURE__ */ t(d, { label: n, controlId: e.id || e.name, children: /* @__PURE__ */ s("div", { className: "form__input", children: [
24
+ const f = (u) => {
25
+ e.type === "number" && x(u), i && i(u);
26
+ }, p = e.type === "number" ? "decimal" : void 0;
27
+ return a && n ? /* @__PURE__ */ t(d, { label: n, controlId: e.id || e.name, children: /* @__PURE__ */ s("div", { className: "form__input", children: [
27
28
  m && /* @__PURE__ */ t(c, { name: m, size: "sm" }),
28
29
  /* @__PURE__ */ t(
29
30
  r.Control,
30
31
  {
31
32
  ...e,
32
33
  onKeyDown: f,
33
- inputMode: u,
34
- children: a
34
+ inputMode: p,
35
+ children: l
35
36
  }
36
37
  )
37
38
  ] }) }) : /* @__PURE__ */ s("div", { className: "form__input", children: [
@@ -41,38 +42,39 @@ const D = ({
41
42
  {
42
43
  ...e,
43
44
  onKeyDown: f,
44
- inputMode: u,
45
- children: a
45
+ inputMode: p,
46
+ children: l
46
47
  }
47
48
  )
48
49
  ] });
49
50
  }, o = ({
50
51
  titre: n,
51
- className: l = "",
52
+ className: a = "",
52
53
  children: m,
53
- ...a
54
+ ...l
54
55
  }) => {
55
56
  const i = "form";
56
- return /* @__PURE__ */ s(r, { className: `${i} ${l}`.trim(), ...a, children: [
57
+ return /* @__PURE__ */ s(r, { className: `${i} ${a}`.trim(), ...l, children: [
57
58
  n && /* @__PURE__ */ t("h1", { className: `${i}__title`, children: n }),
58
59
  m
59
60
  ] });
60
61
  };
61
62
  o.Group = r.Group;
62
- o.Control = D;
63
+ o.Control = g;
63
64
  o.Label = r.Label;
64
65
  o.Text = r.Text;
65
66
  o.Check = r.Check;
66
- o.Select = N;
67
+ o.Select = _;
67
68
  o.InputGroup = C;
68
- o.Number = h;
69
- o.Tel = b;
70
- o.Password = F;
71
- o.PasswordConfirm = I;
69
+ o.Number = F;
70
+ o.Tel = h;
71
+ o.Password = I;
72
+ o.PasswordConfirm = b;
72
73
  o.Range = w;
74
+ o.File = N;
73
75
  o.FloatingLabel = d;
74
- o.Color = x;
75
- o.Date = y;
76
+ o.Color = y;
77
+ o.Date = D;
76
78
  export {
77
79
  o as Form
78
80
  };