@situaction/traq-ui-ste 1.2.13 → 1.2.15

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.
Files changed (32) hide show
  1. package/dist/X.es-BEJ-zMPl.mjs +146 -0
  2. package/dist/components/button/Button.js +36 -36
  3. package/dist/components/calendar/Calendar.js +210 -214
  4. package/dist/components/drag-and-drop/DragAndDrop.d.ts +31 -0
  5. package/dist/components/drag-and-drop/DragAndDrop.js +143 -0
  6. package/dist/components/icon/Icon.js +23729 -46405
  7. package/dist/components/icon-button/IconButton.js +27 -27
  8. package/dist/components/input/Input.js +49 -49
  9. package/dist/components/loading/Loading.d.ts +38 -0
  10. package/dist/components/loading/Loading.js +87 -0
  11. package/dist/components/menu/Menu.js +60 -63
  12. package/dist/components/panel/side-panel/SidePanel.js +18 -19
  13. package/dist/components/select/Select.js +67 -69
  14. package/dist/components/select-filter-input-tags/SelectFilterInputTags.js +8 -9
  15. package/dist/components/select-multi-items/SelectMultiItems.js +18 -18
  16. package/dist/components/tag/Tag.js +25 -25
  17. package/dist/components/theme/variables_dark.d.ts +11 -0
  18. package/dist/components/theme/variables_dark.js +12 -1
  19. package/dist/components/theme/variables_light.d.ts +11 -0
  20. package/dist/components/theme/variables_light.js +12 -1
  21. package/dist/components/toast/Toast.js +38 -38
  22. package/dist/main.d.ts +2 -0
  23. package/dist/main.js +29 -25
  24. package/dist/styles/Button.css +1 -1
  25. package/dist/styles/DragAndDrop.css +1 -0
  26. package/dist/styles/IconButton.css +1 -1
  27. package/dist/styles/Input.css +1 -1
  28. package/dist/styles/Loading.css +1 -0
  29. package/dist/styles/Tag.css +1 -1
  30. package/dist/styles/Toast.css +1 -1
  31. package/package.json +1 -1
  32. package/dist/X-Bd1VjKAF.mjs +0 -190
@@ -0,0 +1,31 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ export type DragAndDropErrorCode = "FILE_TOO_LARGE" | "FILE_TYPE_NOT_ALLOWED";
4
+ export type DragAndDropError = {
5
+ /** Stable code to translate on the consumer side (i18n) */
6
+ code: DragAndDropErrorCode;
7
+ /** Optional dynamic values to build a translated message */
8
+ meta?: {
9
+ maxSizeLabel?: string;
10
+ maxBytes?: number | null;
11
+ receivedBytes?: number;
12
+ accept?: string;
13
+ fileName?: string;
14
+ fileType?: string;
15
+ };
16
+ };
17
+ export interface DragAndDropProps {
18
+ /** Maximum allowed file size (display + validation). Example: "10 Mo", "500 Ko", "1 Go". */
19
+ sizeFile: string;
20
+ /** Accepted file types (input accept format). Example: "image/*,.pdf" or "application/pdf,.pdf". */
21
+ typeFile: string;
22
+ /** Content rendered inside the dropzone (icon, title, hint, etc.). */
23
+ children: ReactNode;
24
+ /** Called when a file is successfully selected/dropped and validated. */
25
+ onFile: (file: File) => void;
26
+ /** Optional fixed width for the dropzone container (CSS value). Example: "420px", "100%". */
27
+ width?: string;
28
+ /** Called when validation fails (size/type). Translate outside using error.code + error.meta. */
29
+ onError?: (error: DragAndDropError) => void;
30
+ }
31
+ export declare const DragAndDrop: ({ sizeFile, typeFile, children, onFile, onError, width }: DragAndDropProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,143 @@
1
+ import { jsx as y, jsxs as k } from "react/jsx-runtime";
2
+ import { useId as x, useRef as O, useState as j, useMemo as w, useCallback as r } from "react";
3
+ import '../../styles/DragAndDrop.css';const C = "_dropzone_jj8g2_30", I = "_dropzoneActive_jj8g2_48", E = "_input_jj8g2_53", h = {
4
+ dropzone: C,
5
+ dropzoneActive: I,
6
+ input: E
7
+ }, P = (n) => {
8
+ const a = n.trim().replace(",", ".").match(/^(\d+(?:\.\d+)?)\s*([a-zA-Z]+)$/);
9
+ if (!a) return null;
10
+ const i = Number(a[1]), t = a[2].toLowerCase();
11
+ if (Number.isNaN(i)) return null;
12
+ const o = {
13
+ b: 1,
14
+ ko: 1024,
15
+ kb: 1e3,
16
+ mo: 1024 ** 2,
17
+ mb: 1e3 ** 2,
18
+ go: 1024 ** 3,
19
+ gb: 1e3 ** 3,
20
+ mib: 1024 ** 2,
21
+ gib: 1024 ** 3
22
+ };
23
+ return o[t] ? Math.round(i * o[t]) : null;
24
+ }, W = (n, u) => {
25
+ const a = u.split(",").map((o) => o.trim()).filter(Boolean);
26
+ if (a.length === 0) return !0;
27
+ const i = n.name.toLowerCase(), t = (n.type || "").toLowerCase();
28
+ return a.some((o) => {
29
+ const s = o.toLowerCase();
30
+ if (s.startsWith(".")) return i.endsWith(s);
31
+ if (s.endsWith("/*")) {
32
+ const d = s.slice(0, s.indexOf("/"));
33
+ return t.startsWith(d + "/");
34
+ }
35
+ return t === s;
36
+ });
37
+ }, S = ({
38
+ sizeFile: n,
39
+ typeFile: u,
40
+ children: a,
41
+ onFile: i,
42
+ onError: t,
43
+ width: o = "auto"
44
+ }) => {
45
+ const s = x(), d = O(null), [b, g] = j(!1), f = w(() => P(n), [n]), p = u ?? "", v = r(
46
+ (e) => {
47
+ t == null || t(e);
48
+ },
49
+ [t]
50
+ ), D = r(() => {
51
+ var e;
52
+ (e = d.current) == null || e.click();
53
+ }, []), m = r(
54
+ (e) => {
55
+ if (f != null && e.size > f) {
56
+ v({
57
+ code: "FILE_TOO_LARGE",
58
+ meta: {
59
+ maxSizeLabel: n,
60
+ maxBytes: f,
61
+ receivedBytes: e.size,
62
+ fileName: e.name,
63
+ fileType: e.type
64
+ }
65
+ });
66
+ return;
67
+ }
68
+ if (p.trim() && !W(e, p)) {
69
+ v({
70
+ code: "FILE_TYPE_NOT_ALLOWED",
71
+ meta: {
72
+ accept: p,
73
+ fileName: e.name,
74
+ fileType: e.type
75
+ }
76
+ });
77
+ return;
78
+ }
79
+ i(e);
80
+ },
81
+ [v, f, i, p, n]
82
+ ), _ = r(
83
+ (e) => {
84
+ var l;
85
+ e.preventDefault(), e.stopPropagation(), g(!1);
86
+ const c = (l = e.dataTransfer.files) == null ? void 0 : l[0];
87
+ c && m(c);
88
+ },
89
+ [m]
90
+ ), L = r((e) => {
91
+ e.preventDefault(), e.stopPropagation(), e.dataTransfer.dropEffect = "copy";
92
+ }, []), T = r((e) => {
93
+ e.preventDefault(), e.stopPropagation(), g(!0);
94
+ }, []), z = r((e) => {
95
+ e.preventDefault(), e.stopPropagation();
96
+ const c = e.relatedTarget;
97
+ c && e.currentTarget.contains(c) || g(!1);
98
+ }, []), A = r(
99
+ (e) => {
100
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), D());
101
+ },
102
+ [D]
103
+ ), N = r(
104
+ (e) => {
105
+ var l;
106
+ const c = (l = e.target.files) == null ? void 0 : l[0];
107
+ c && (m(c), e.target.value = "");
108
+ },
109
+ [m]
110
+ );
111
+ return /* @__PURE__ */ y("div", { style: { width: o }, children: /* @__PURE__ */ k(
112
+ "div",
113
+ {
114
+ className: `${h.dropzone} ${b ? h.dropzoneActive : ""}`,
115
+ role: "button",
116
+ tabIndex: 0,
117
+ "aria-label": "Upload file",
118
+ onClick: D,
119
+ onKeyDown: A,
120
+ onDrop: _,
121
+ onDragOver: L,
122
+ onDragEnter: T,
123
+ onDragLeave: z,
124
+ children: [
125
+ a,
126
+ /* @__PURE__ */ y(
127
+ "input",
128
+ {
129
+ id: s,
130
+ ref: d,
131
+ className: h.input,
132
+ type: "file",
133
+ accept: p,
134
+ onChange: N
135
+ }
136
+ )
137
+ ]
138
+ }
139
+ ) });
140
+ };
141
+ export {
142
+ S as DragAndDrop
143
+ };