@krosoft/react 0.0.238 → 0.0.239

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 (109) hide show
  1. package/dist/AppActions-C_0YI75w.js +60 -0
  2. package/dist/AppSubTitle-tqqV9nuT.js +19 -0
  3. package/dist/AppTitle-BR4JFZfp.js +19 -0
  4. package/dist/ErrorAlert-BDqDHUUc.js +27 -0
  5. package/dist/GenericForm-CWXT5wiv.js +310 -0
  6. package/dist/ImageInput-CN2ozjpc.js +80 -0
  7. package/dist/MultiSelect-BF0zL0B0.js +134 -0
  8. package/dist/SearchInput-BJPT0SbB.js +255 -0
  9. package/dist/alert-REQGK9bR.js +32 -0
  10. package/dist/behavior-BR_V9Rpe.js +76 -0
  11. package/dist/cards-Cta6x49J.js +126 -0
  12. package/dist/chart-Dq3AIrue.js +166 -0
  13. package/dist/charts-CXhVUqLH.js +328 -0
  14. package/dist/components/core/cards/index.js +2 -10
  15. package/dist/components/core/charts/index.js +2 -11
  16. package/dist/components/core/dialogs/index.js +4 -19
  17. package/dist/components/core/filters/index.js +426 -7
  18. package/dist/components/core/forms/index.js +2 -4
  19. package/dist/components/core/index.js +24 -97
  20. package/dist/components/core/inputs/index.js +4 -11
  21. package/dist/components/core/language/index.js +2 -4
  22. package/dist/components/core/layouts/index.js +50 -11
  23. package/dist/components/core/navbar/index.js +2 -9
  24. package/dist/components/core/states/index.js +3 -8
  25. package/dist/components/core/table/index.js +2 -15
  26. package/dist/components/core/tabs/index.js +188 -6
  27. package/dist/components/core/theme/index.js +2 -4
  28. package/dist/components/index.js +28 -322
  29. package/dist/components/ui/index.js +8 -240
  30. package/dist/contexts/index.js +2 -5
  31. package/dist/dialogs-BGHSClsq.js +208 -0
  32. package/dist/helpers/index.js +39 -46
  33. package/dist/hooks/behavior/index.js +2 -10
  34. package/dist/hooks/index.js +11 -30
  35. package/dist/hooks/ui/index.js +10 -22
  36. package/dist/i18n/index.js +2 -10
  37. package/dist/i18n-Dw99bRmg.js +190 -0
  38. package/dist/language-DxHhlpgN.js +58 -0
  39. package/dist/navbar-Bc5OQWRI.js +385 -0
  40. package/dist/providers/index.js +42 -49
  41. package/dist/pwa/index.js +32 -34
  42. package/dist/select-ULiTPOr5.js +81 -0
  43. package/dist/sheet-CRrYTZrl.js +226 -0
  44. package/dist/sidebar.context-BahtU6hE.js +5 -0
  45. package/dist/skeleton-D6Ga4BLw.js +11 -0
  46. package/dist/states-N8-LjFng.js +26 -0
  47. package/dist/table-muUyiaK6.js +571 -0
  48. package/dist/tailwind/index.js +126 -156
  49. package/dist/tailwind.helper-CJaRYBmL.js +8 -0
  50. package/dist/theme-B_n0F6R4.js +57 -0
  51. package/dist/tokens/index.js +37 -46
  52. package/dist/tooltip-B2dzyfs9.js +50 -0
  53. package/dist/types/forms/index.js +0 -1
  54. package/dist/types/index.js +1 -1
  55. package/dist/ui-CiX0E_bn.js +1165 -0
  56. package/dist/ui-DSVBO3iM.js +46 -0
  57. package/dist/useDocumentTitle-D7MywIeB.js +19 -0
  58. package/dist/useFixedColumns-DfAX30tT.js +147 -0
  59. package/dist/useLanguage-DN3CuBv5.js +19 -0
  60. package/dist/useMobile-pTQ8lWvt.js +16 -0
  61. package/dist/useNotifications-CyhTruIG.js +20 -0
  62. package/dist/useScrollFade-D9kqJBDh.js +27 -0
  63. package/dist/useTheme-DVfcJ-Qd.js +25 -0
  64. package/dist/useToast-UeDRLovh.js +103 -0
  65. package/package.json +2 -2
  66. package/dist/AppActions-BFwztl-1.js +0 -76
  67. package/dist/AppSubTitle-BTN0YAc7.js +0 -13
  68. package/dist/AppTitle-D15YXeMx.js +0 -13
  69. package/dist/AppVerticalTabs-B7XXtAVj.js +0 -103
  70. package/dist/ConfirmationDialog-Dj4WdnHg.js +0 -188
  71. package/dist/DataTable-CjrR27Di.js +0 -638
  72. package/dist/ErrorAlert-B99Xb_Hg.js +0 -23
  73. package/dist/ErrorState-CkeS_IBT.js +0 -14
  74. package/dist/GenericForm-CydibLHU.js +0 -343
  75. package/dist/ImageInput-DoOOvvth.js +0 -70
  76. package/dist/KpiCardsLayout-Bq4xQ3i8.js +0 -43
  77. package/dist/LanguageSelector-C7E51rCQ.js +0 -47
  78. package/dist/LoadingState-BN0YaPSs.js +0 -9
  79. package/dist/MetricCard-B0xnFyim.js +0 -53
  80. package/dist/MultiSelect-DbH7LrsD.js +0 -149
  81. package/dist/PieChart-uozNJtEx.js +0 -295
  82. package/dist/SearchInput-DIZ5Yt6L.js +0 -246
  83. package/dist/SkeletonCards-B9C4cNMr.js +0 -75
  84. package/dist/TableFilter-CmEVF5Bo.js +0 -422
  85. package/dist/ThemeSelector-CLi4_epH.js +0 -52
  86. package/dist/Topbar-Clby5_uj.js +0 -431
  87. package/dist/alert-B9F1N9Qk.js +0 -30
  88. package/dist/chart-DntJZGxB.js +0 -181
  89. package/dist/select-BpjFWqAY.js +0 -96
  90. package/dist/sheet-XYI-ezvY.js +0 -292
  91. package/dist/sidebar.context-D5nywlmP.js +0 -6
  92. package/dist/skeleton-BX4RcsiK.js +0 -8
  93. package/dist/tailwind.helper-B6yFEsav.js +0 -8
  94. package/dist/toaster-CyzB1m5z.js +0 -75
  95. package/dist/toggle-group-iZqnrTj7.js +0 -1276
  96. package/dist/tooltip-DVeqVwqV.js +0 -61
  97. package/dist/useDateFnsLocale-D6VExZ8U.js +0 -11
  98. package/dist/useDocumentTitle-WNwdPz-I.js +0 -14
  99. package/dist/useFixedColumns-CKZyu4PD.js +0 -161
  100. package/dist/useKrosoftTranslation-BTp46G94.js +0 -47
  101. package/dist/useLanguage-C9jI2nwn.js +0 -19
  102. package/dist/useMobile-DN1_OMDB.js +0 -16
  103. package/dist/useNotifications-zbUhCvF_.js +0 -12
  104. package/dist/usePage-BQm6tdJD.js +0 -84
  105. package/dist/useScrollFade-BA4KqJYp.js +0 -23
  106. package/dist/useServerTable-UvTY6L1N.js +0 -38
  107. package/dist/useSidebar-BJuALHqQ.js +0 -11
  108. package/dist/useTheme-DS6ZjdzM.js +0 -27
  109. package/dist/useToast-BFTk4lWz.js +0 -100
@@ -0,0 +1,255 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import { En as t } from "./ui-CiX0E_bn.js";
3
+ import { o as n, s as r } from "./tooltip-B2dzyfs9.js";
4
+ import { r as i, t as a } from "./i18n-Dw99bRmg.js";
5
+ import { C as o, S as s, _ as c, b as l, g as u, h as d, m as f, p, x as m, y as h } from "./sheet-CRrYTZrl.js";
6
+ import * as g from "react";
7
+ import { useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
8
+ import { jsx as x, jsxs as S } from "react/jsx-runtime";
9
+ import { CalendarIcon as C, CheckIcon as w, ChevronDownIcon as T, PlusIcon as E, SearchIcon as D, XIcon as O } from "lucide-react";
10
+ import { format as k } from "date-fns";
11
+ //#region src/components/core/inputs/DatePicker.tsx
12
+ var A = ({ date: n, onDateChange: a, placeholder: o }) => {
13
+ let s = i(), [c, l] = b(!1), u = y(null);
14
+ return _(() => {
15
+ if (!c) return;
16
+ let e = (e) => {
17
+ u.current !== null && !u.current.contains(e.target) && l(!1);
18
+ };
19
+ return document.addEventListener("mousedown", e), () => {
20
+ document.removeEventListener("mousedown", e);
21
+ };
22
+ }, [c]), /* @__PURE__ */ S("div", {
23
+ ref: u,
24
+ className: "relative w-full",
25
+ children: [/* @__PURE__ */ S(r, {
26
+ variant: "outline",
27
+ type: "button",
28
+ onClick: () => {
29
+ l((e) => !e);
30
+ },
31
+ className: e("w-full justify-start text-left font-normal focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", c && "ring-2 ring-ring ring-offset-2", n === void 0 && "text-muted-foreground"),
32
+ children: [/* @__PURE__ */ x(C, { className: "mr-2 size-4 shrink-0" }), n === void 0 ? /* @__PURE__ */ x("span", { children: o }) : k(n, "dd/MM/yyyy", { locale: s })]
33
+ }), c ? /* @__PURE__ */ x("div", {
34
+ className: "absolute left-0 top-[calc(100%+4px)] z-[100] rounded-surface border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 slide-in-from-top-2",
35
+ children: /* @__PURE__ */ x(t, {
36
+ mode: "single",
37
+ locale: s,
38
+ defaultMonth: n,
39
+ selected: n,
40
+ onSelect: (e) => {
41
+ a(e), l(!1);
42
+ }
43
+ })
44
+ }) : null]
45
+ });
46
+ }, j = ({ value: n, onChange: o, placeholder: s, className: c }) => {
47
+ let { t: l } = a(), u = i(), [m, h] = g.useState(!1), [_, v] = g.useState(n);
48
+ return g.useEffect(() => {
49
+ m && v(n);
50
+ }, [m, n]), /* @__PURE__ */ x("div", {
51
+ className: e("grid gap-2", c),
52
+ children: /* @__PURE__ */ S(p, {
53
+ open: m,
54
+ onOpenChange: h,
55
+ children: [/* @__PURE__ */ x(d, {
56
+ asChild: !0,
57
+ children: /* @__PURE__ */ S(r, {
58
+ id: "date",
59
+ variant: "outline",
60
+ className: e("w-[300px] justify-start text-left font-normal", !n?.from && "text-muted-foreground"),
61
+ children: [
62
+ /* @__PURE__ */ x(C, { className: "mr-2 size-4" }),
63
+ ((e) => e?.from ? !e.to || e.from.getTime() === e.to.getTime() ? k(e.from, "dd MMM yyyy", { locale: u }) : `${k(e.from, "dd MMM yyyy", { locale: u })} - ${k(e.to, "dd MMM yyyy", { locale: u })}` : s ?? l("date.pickPeriod"))(n),
64
+ n?.from && /* @__PURE__ */ x(r, {
65
+ type: "button",
66
+ variant: "ghost",
67
+ size: "icon",
68
+ "aria-label": l("date.clearPeriod"),
69
+ className: "ml-auto h-5 w-5 opacity-50 hover:opacity-100",
70
+ onClick: (e) => {
71
+ e.stopPropagation(), o(void 0), h(!1);
72
+ },
73
+ children: /* @__PURE__ */ x(O, { className: "size-4" })
74
+ })
75
+ ]
76
+ })
77
+ }), /* @__PURE__ */ S(f, {
78
+ className: "w-auto p-0",
79
+ align: "start",
80
+ side: "bottom",
81
+ sideOffset: 4,
82
+ children: [/* @__PURE__ */ x(t, {
83
+ mode: "range",
84
+ defaultMonth: _?.from,
85
+ selected: _,
86
+ onSelect: v,
87
+ numberOfMonths: 2,
88
+ locale: u,
89
+ className: "pointer-events-auto p-3"
90
+ }), /* @__PURE__ */ S("div", {
91
+ className: "flex items-center justify-between border-t border-border px-3 py-2",
92
+ children: [/* @__PURE__ */ x(r, {
93
+ variant: "ghost",
94
+ size: "sm",
95
+ onClick: () => {
96
+ v(void 0);
97
+ },
98
+ children: l("actions.clear")
99
+ }), /* @__PURE__ */ S("div", {
100
+ className: "flex gap-2",
101
+ children: [/* @__PURE__ */ x(r, {
102
+ variant: "ghost",
103
+ size: "sm",
104
+ onClick: () => {
105
+ v(n), h(!1);
106
+ },
107
+ children: l("actions.cancel")
108
+ }), /* @__PURE__ */ x(r, {
109
+ size: "sm",
110
+ onClick: () => {
111
+ o(_), h(!1);
112
+ },
113
+ children: l("actions.apply")
114
+ })]
115
+ })]
116
+ })]
117
+ })]
118
+ })
119
+ });
120
+ }, M = ({ options: t = [], value: r, onChange: i, onClear: u, onCreate: g, placeholder: _, searchPlaceholder: y, emptyLabel: C, createLabel: D, disabled: k = !1, modal: A = !0, className: j }) => {
121
+ let { t: M } = a(), [N, P] = b(!1), [F, I] = b(""), L = r !== void 0 && r !== "", R = v(() => L ? t.find((e) => e.value === r) : void 0, [
122
+ L,
123
+ t,
124
+ r
125
+ ]), z = L ? R?.label ?? r : void 0, B = F.trim(), V = g !== void 0 && B !== "" && !t.some((e) => e.label.toLowerCase() === B.toLowerCase()), H = (e) => {
126
+ P(e), e || I("");
127
+ }, U = (e) => {
128
+ i(e), H(!1);
129
+ };
130
+ return /* @__PURE__ */ S(p, {
131
+ open: N,
132
+ onOpenChange: H,
133
+ modal: A,
134
+ children: [/* @__PURE__ */ x(d, {
135
+ asChild: !0,
136
+ children: /* @__PURE__ */ S("button", {
137
+ type: "button",
138
+ role: "combobox",
139
+ "aria-expanded": N,
140
+ disabled: k,
141
+ className: e(n, "w-full", "data-[state=open]:ring-2 data-[state=open]:ring-ring data-[state=open]:ring-offset-2", !L && "text-muted-foreground", j),
142
+ children: [/* @__PURE__ */ S("span", {
143
+ className: "flex items-center truncate",
144
+ children: [
145
+ R?.color && /* @__PURE__ */ x("span", {
146
+ className: "mr-2 size-2.5 shrink-0 rounded-full",
147
+ style: { backgroundColor: R.color }
148
+ }),
149
+ /* @__PURE__ */ x("span", {
150
+ className: "truncate",
151
+ children: z ?? _ ?? M("select.placeholder")
152
+ }),
153
+ R?.description !== void 0 && /* @__PURE__ */ S("span", {
154
+ className: "ml-1 truncate text-muted-foreground",
155
+ children: [
156
+ "(",
157
+ R.description,
158
+ ")"
159
+ ]
160
+ })
161
+ ]
162
+ }), /* @__PURE__ */ S("div", {
163
+ className: "flex items-center gap-1",
164
+ children: [u && L && !k && /* @__PURE__ */ x("span", {
165
+ role: "button",
166
+ tabIndex: -1,
167
+ onClick: (e) => {
168
+ e.stopPropagation();
169
+ },
170
+ onPointerDown: (e) => {
171
+ e.preventDefault(), e.stopPropagation(), u();
172
+ },
173
+ className: "text-muted-foreground hover:text-foreground",
174
+ children: /* @__PURE__ */ x(O, { className: "size-4" })
175
+ }), /* @__PURE__ */ x(T, { className: e("size-4 shrink-0 opacity-50 transition-transform", N && "rotate-180") })]
176
+ })]
177
+ })
178
+ }), /* @__PURE__ */ x(f, {
179
+ className: "w-[var(--radix-popover-trigger-width)] p-0",
180
+ align: "start",
181
+ children: /* @__PURE__ */ S(c, {
182
+ filter: (e, t, n) => +!!(n ?? []).join(" ").toLowerCase().includes(t.trim().toLowerCase()),
183
+ children: [/* @__PURE__ */ x(m, {
184
+ placeholder: y ?? M("search.placeholder"),
185
+ value: F,
186
+ onValueChange: I
187
+ }), /* @__PURE__ */ S(o, { children: [!V && /* @__PURE__ */ x(h, { children: C ?? M("states.noResult") }), /* @__PURE__ */ S(l, { children: [t.map((t) => /* @__PURE__ */ S(s, {
188
+ value: t.value,
189
+ keywords: [t.label, t.description ?? ""],
190
+ onSelect: () => {
191
+ U(t.value);
192
+ },
193
+ children: [
194
+ /* @__PURE__ */ x(w, { className: e("mr-2 size-4 shrink-0", r === t.value ? "opacity-100" : "opacity-0") }),
195
+ t.color !== void 0 && /* @__PURE__ */ x("span", {
196
+ className: "mr-2 size-2.5 shrink-0 rounded-full",
197
+ style: { backgroundColor: t.color }
198
+ }),
199
+ /* @__PURE__ */ x("span", {
200
+ className: "truncate",
201
+ children: t.label
202
+ }),
203
+ t.description !== void 0 && /* @__PURE__ */ S("span", {
204
+ className: "ml-1 truncate text-muted-foreground",
205
+ children: [
206
+ "(",
207
+ t.description,
208
+ ")"
209
+ ]
210
+ })
211
+ ]
212
+ }, t.value)), V && /* @__PURE__ */ S(s, {
213
+ forceMount: !0,
214
+ value: "__create__",
215
+ onSelect: () => {
216
+ g?.(B), H(!1);
217
+ },
218
+ children: [/* @__PURE__ */ x(E, { className: "mr-2 size-4 shrink-0" }), /* @__PURE__ */ x("span", {
219
+ className: "truncate",
220
+ children: D ? D(B) : M("select.create", { search: B })
221
+ })]
222
+ })] })] })]
223
+ })
224
+ })]
225
+ });
226
+ }, N = ({ searchQuery: t, search: n, placeholder: r, onSearch: i, onSubmit: o, onClear: s, className: c }) => {
227
+ let { t: l } = a(), d = t ?? n ?? "";
228
+ return /* @__PURE__ */ S("div", {
229
+ className: e("relative h-fit w-full md:w-64", c),
230
+ children: [
231
+ /* @__PURE__ */ x(D, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4" }),
232
+ /* @__PURE__ */ x(u, {
233
+ placeholder: r ?? l("search.placeholder"),
234
+ value: d,
235
+ onChange: (e) => {
236
+ i(e.target.value);
237
+ },
238
+ className: "pl-8",
239
+ onKeyDown: (e) => {
240
+ e.key === "Enter" && o !== void 0 && (e.preventDefault(), o());
241
+ }
242
+ }),
243
+ d === "" ? null : /* @__PURE__ */ x("button", {
244
+ onClick: () => {
245
+ i(""), s !== void 0 && s();
246
+ },
247
+ className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",
248
+ type: "button",
249
+ children: /* @__PURE__ */ x(O, { className: "size-4" })
250
+ })
251
+ ]
252
+ });
253
+ };
254
+ //#endregion
255
+ export { A as i, M as n, j as r, N as t };
@@ -0,0 +1,32 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import * as t from "react";
3
+ import { jsx as n } from "react/jsx-runtime";
4
+ import { cva as r } from "class-variance-authority";
5
+ //#region src/components/ui/alert.tsx
6
+ var i = r("relative w-full rounded-surface border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground", {
7
+ variants: { variant: {
8
+ default: "bg-background text-foreground",
9
+ destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"
10
+ } },
11
+ defaultVariants: { variant: "default" }
12
+ }), a = t.forwardRef(({ className: t, variant: r, ...a }, o) => /* @__PURE__ */ n("div", {
13
+ ref: o,
14
+ role: "alert",
15
+ className: e(i({ variant: r }), t),
16
+ ...a
17
+ }));
18
+ a.displayName = "Alert";
19
+ var o = t.forwardRef(({ className: t, ...r }, i) => /* @__PURE__ */ n("h5", {
20
+ ref: i,
21
+ className: e("mb-1 font-medium leading-none tracking-tight", t),
22
+ ...r
23
+ }));
24
+ o.displayName = "AlertTitle";
25
+ var s = t.forwardRef(({ className: t, ...r }, i) => /* @__PURE__ */ n("div", {
26
+ ref: i,
27
+ className: e("text-sm [&_p]:leading-relaxed", t),
28
+ ...r
29
+ }));
30
+ s.displayName = "AlertDescription";
31
+ //#endregion
32
+ export { s as n, o as r, a as t };
@@ -0,0 +1,76 @@
1
+ import { t as e } from "./i18n-Dw99bRmg.js";
2
+ import { n as t, t as n } from "./sidebar.context-BahtU6hE.js";
3
+ import * as r from "react";
4
+ import { useContext as i, useState as a } from "react";
5
+ import { TrashIcon as o } from "lucide-react";
6
+ //#region src/hooks/behavior/useDialog.ts
7
+ var s = (e) => {
8
+ let [t, n] = a(null);
9
+ return {
10
+ id: t?.id ?? null,
11
+ name: t?.name ?? null,
12
+ isOpen: !!t,
13
+ openDialog: (t, r) => {
14
+ e?.onReset?.(), n({
15
+ id: t,
16
+ name: r
17
+ });
18
+ },
19
+ onClose: () => {
20
+ n(null);
21
+ }
22
+ };
23
+ }, c = ({ titleKey: e, descriptionKey: t, confirmKey: n = "Confirmer", onConfirm: r, onReset: i }) => {
24
+ let a = s({ onReset: i });
25
+ return {
26
+ isOpen: a.isOpen,
27
+ itemName: a.name,
28
+ title: e,
29
+ description: t,
30
+ confirmKey: n,
31
+ openDialog: a.openDialog,
32
+ onClose: a.onClose,
33
+ onConfirm: async () => {
34
+ if (a.id) try {
35
+ await r(a.id), a.onClose();
36
+ } catch (e) {
37
+ console.error("Error confirming action:", e);
38
+ }
39
+ }
40
+ };
41
+ }, l = ({ titleKey: t, descriptionKey: n, confirmKey: r, onConfirm: i, onReset: a }) => {
42
+ let { t: s } = e();
43
+ return {
44
+ ...c({
45
+ titleKey: t,
46
+ descriptionKey: n,
47
+ confirmKey: r ?? s("actions.delete"),
48
+ onConfirm: i,
49
+ onReset: a
50
+ }),
51
+ loadingKey: "Suppression...",
52
+ icon: o,
53
+ titleClassName: "flex items-center gap-2 text-destructive",
54
+ headerClassName: "bg-gradient-to-r from-slate-900 to-purple-700 rounded-t-surface shrink-0"
55
+ };
56
+ }, u = (e, t = 250) => {
57
+ let [n, i] = r.useState(e);
58
+ return r.useEffect(() => {
59
+ let n = setTimeout(() => {
60
+ i(e);
61
+ }, t);
62
+ return () => {
63
+ clearTimeout(n);
64
+ };
65
+ }, [e, t]), n;
66
+ }, d = () => {
67
+ let e = i(t);
68
+ if (e === void 0) throw Error("usePage must be used within an PageProvider");
69
+ return e;
70
+ }, f = () => {
71
+ let e = i(n);
72
+ if (e === void 0) throw Error("useSidebar must be used within a SidebarProvider");
73
+ return e;
74
+ };
75
+ //#endregion
76
+ export { c as a, l as i, d as n, s as o, u as r, f as t };
@@ -0,0 +1,126 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import { c as t, d as n, f as r, s as i } from "./chart-Dq3AIrue.js";
3
+ import "./ui-CiX0E_bn.js";
4
+ import { t as a } from "./skeleton-D6Ga4BLw.js";
5
+ import "react";
6
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ import { useTranslation as l } from "react-i18next";
8
+ import { formatNumber as u } from "@krosoft/core/helpers";
9
+ //#region src/components/core/cards/DashboardCard.tsx
10
+ var d = ({ titleKey: a, icon: o, className: u, children: d }) => {
11
+ let { t: f } = l();
12
+ return /* @__PURE__ */ c(i, {
13
+ className: e("bg-gray-50 dark:bg-gray-950", u),
14
+ children: [/* @__PURE__ */ s(n, { children: /* @__PURE__ */ c(r, {
15
+ className: "flex items-center gap-2",
16
+ children: [o && /* @__PURE__ */ s(o, { className: "mr-2 size-4" }), /* @__PURE__ */ s("span", { children: f(a) })]
17
+ }) }), /* @__PURE__ */ s(t, { children: d })]
18
+ });
19
+ }, f = ({ titleKey: d, value: f, valueClassName: p, icon: m, iconClassName: h, description: g, descriptionClassName: _, onClick: v, isLoading: y, error: b }) => {
20
+ let { t: x } = l();
21
+ return /* @__PURE__ */ c(i, {
22
+ className: e(v === void 0 ? "" : "hover:border-primary cursor-pointer"),
23
+ onClick: v,
24
+ children: [/* @__PURE__ */ c(n, {
25
+ className: "flex flex-row items-center justify-between space-y-0 pb-2",
26
+ children: [/* @__PURE__ */ s(r, {
27
+ className: "text-sm font-medium",
28
+ children: x(d)
29
+ }), /* @__PURE__ */ s(m, { className: e("size-6 text-muted-foreground", h) })]
30
+ }), /* @__PURE__ */ s(t, { children: y ? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(a, { className: "h-8 w-24 mb-1" }), /* @__PURE__ */ s(a, { className: "h-3 w-32" })] }) : b ? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("div", {
31
+ className: "text-2xl font-bold text-destructive",
32
+ children: "—"
33
+ }), /* @__PURE__ */ s("p", {
34
+ className: "text-xs text-destructive",
35
+ children: b
36
+ })] }) : /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("div", {
37
+ className: e("text-2xl font-bold", p),
38
+ children: typeof f == "number" ? u(f) : f instanceof Date ? f.toLocaleDateString() : f
39
+ }), /* @__PURE__ */ s("p", {
40
+ className: e("text-xs text-muted-foreground", _),
41
+ children: g
42
+ })] }) })]
43
+ });
44
+ }, p = ({ stats: e, isLoading: t, error: n }) => /* @__PURE__ */ s("div", {
45
+ className: "grid gap-6 md:grid-cols-2 lg:grid-cols-4",
46
+ children: e.map((e) => /* @__PURE__ */ s(f, {
47
+ titleKey: e.titleKey,
48
+ value: e.value,
49
+ valueClassName: e.valueClassName,
50
+ icon: e.icon,
51
+ iconClassName: e.iconClassName,
52
+ description: e.description,
53
+ descriptionClassName: e.descriptionClassName,
54
+ onClick: e.onClick,
55
+ isLoading: t,
56
+ error: n
57
+ }, e.titleKey))
58
+ }), m = {
59
+ blue: "bg-gradient-to-br from-blue-500 to-cyan-500 text-white",
60
+ green: "bg-gradient-to-br from-green-500 to-emerald-500 text-white",
61
+ orange: "bg-gradient-to-br from-orange-500 to-yellow-500 text-white",
62
+ red: "bg-gradient-to-br from-red-500 to-pink-500 text-white",
63
+ purple: "bg-gradient-to-br from-purple-500 to-indigo-500 text-white",
64
+ accent: "bg-accent/10 text-accent",
65
+ success: "bg-success/10 text-success",
66
+ info: "bg-info/10 text-info",
67
+ warning: "bg-warning/10 text-warning",
68
+ destructive: "bg-destructive/10 text-destructive"
69
+ }, h = {
70
+ sm: "size-4",
71
+ md: "size-5",
72
+ lg: "size-6"
73
+ }, g = (e) => e === "up" ? "↑" : e === "down" ? "↓" : "", _ = (e) => e === "up" ? "text-green-600" : e === "down" ? "text-red-600" : "text-muted-foreground", v = ({ title: e, value: n, unit: a, subtitle: o, icon: l, iconSize: u = "md", trend: d, trendValue: f, color: p = "blue", children: v }) => {
74
+ let y = l;
75
+ return /* @__PURE__ */ s(i, {
76
+ className: "relative overflow-hidden bg-card border shadow-lg hover:shadow-xl transition-all duration-300",
77
+ children: /* @__PURE__ */ c(t, {
78
+ className: "pt-6",
79
+ children: [/* @__PURE__ */ c("div", {
80
+ className: "flex items-start justify-between",
81
+ children: [/* @__PURE__ */ c("div", { children: [
82
+ /* @__PURE__ */ s(r, {
83
+ className: "text-sm font-medium text-muted-foreground",
84
+ children: e
85
+ }),
86
+ /* @__PURE__ */ c("div", {
87
+ className: "flex items-baseline space-x-2 mt-1",
88
+ children: [/* @__PURE__ */ s("div", {
89
+ className: "text-2xl font-bold text-card-foreground",
90
+ children: typeof n == "number" ? n.toFixed(1) : n
91
+ }), a && /* @__PURE__ */ s("div", {
92
+ className: "text-sm text-muted-foreground font-medium",
93
+ children: a
94
+ })]
95
+ }),
96
+ o && /* @__PURE__ */ s("div", {
97
+ className: "mt-1 text-xs text-muted-foreground",
98
+ children: o
99
+ }),
100
+ d && f && /* @__PURE__ */ c("div", {
101
+ className: `flex items-center space-x-1 mt-2 text-xs ${_(d)}`,
102
+ children: [/* @__PURE__ */ s("span", { children: g(d) }), /* @__PURE__ */ s("span", { children: f })]
103
+ })
104
+ ] }), /* @__PURE__ */ s("div", {
105
+ className: `p-2 rounded-control ${m[p]} shadow-lg`,
106
+ children: /* @__PURE__ */ s(y, { className: h[u] })
107
+ })]
108
+ }), v && /* @__PURE__ */ s("div", {
109
+ className: "mt-4",
110
+ children: v
111
+ })]
112
+ })
113
+ });
114
+ }, y = () => /* @__PURE__ */ c(i, {
115
+ className: "animate-pulse",
116
+ children: [/* @__PURE__ */ s(n, { children: /* @__PURE__ */ s("div", { className: "h-6 bg-muted rounded w-1/4" }) }), /* @__PURE__ */ s(t, { children: /* @__PURE__ */ c("div", {
117
+ className: "space-y-2",
118
+ children: [/* @__PURE__ */ s("div", { className: "h-4 bg-muted rounded" }), /* @__PURE__ */ s("div", { className: "h-4 bg-muted rounded w-3/4" })]
119
+ }) })]
120
+ }), b = ({ count: e = 1 }) => /* @__PURE__ */ s("div", {
121
+ className: "grid gap-6",
122
+ style: { gridTemplateColumns: `repeat(${e}, minmax(0, 1fr))` },
123
+ children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ s(y, {}, t))
124
+ });
125
+ //#endregion
126
+ export { f as a, p as i, y as n, d as o, v as r, b as t };
@@ -0,0 +1,166 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import "./helpers/index.js";
3
+ import * as t from "react";
4
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ import * as a from "recharts";
6
+ //#region src/components/ui/card.tsx
7
+ var o = t.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r("div", {
8
+ ref: i,
9
+ className: e("rounded-surface border bg-card text-card-foreground shadow-sm", t),
10
+ ...n
11
+ }));
12
+ o.displayName = "Card";
13
+ var s = t.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r("div", {
14
+ ref: i,
15
+ className: e("flex flex-col space-y-1.5 p-6", t),
16
+ ...n
17
+ }));
18
+ s.displayName = "CardHeader";
19
+ var c = t.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r("h3", {
20
+ ref: i,
21
+ className: e("text-2xl font-semibold leading-none tracking-tight", t),
22
+ ...n
23
+ }));
24
+ c.displayName = "CardTitle";
25
+ var l = t.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r("p", {
26
+ ref: i,
27
+ className: e("text-sm text-muted-foreground", t),
28
+ ...n
29
+ }));
30
+ l.displayName = "CardDescription";
31
+ var u = t.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r("div", {
32
+ ref: i,
33
+ className: e("p-6 pt-0", t),
34
+ ...n
35
+ }));
36
+ u.displayName = "CardContent";
37
+ var d = t.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r("div", {
38
+ ref: i,
39
+ className: e("flex items-center p-6 pt-0", t),
40
+ ...n
41
+ }));
42
+ d.displayName = "CardFooter";
43
+ //#endregion
44
+ //#region src/components/ui/chart.tsx
45
+ var f = {
46
+ light: "",
47
+ dark: ".dark"
48
+ }, p = t.createContext(null);
49
+ function m() {
50
+ let e = t.useContext(p);
51
+ if (!e) throw Error("useChart must be used within a <ChartContainer />");
52
+ return e;
53
+ }
54
+ var h = t.forwardRef(({ id: n, className: o, children: s, config: c, ...l }, u) => {
55
+ let d = t.useId(), f = `chart-${n || d.replace(/:/g, "")}`;
56
+ return /* @__PURE__ */ r(p.Provider, {
57
+ value: { config: c },
58
+ children: /* @__PURE__ */ i("div", {
59
+ "data-chart": f,
60
+ ref: u,
61
+ className: e("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none", o),
62
+ ...l,
63
+ children: [/* @__PURE__ */ r(g, {
64
+ id: f,
65
+ config: c
66
+ }), /* @__PURE__ */ r(a.ResponsiveContainer, { children: s })]
67
+ })
68
+ });
69
+ });
70
+ h.displayName = "Chart";
71
+ var g = ({ id: e, config: t }) => {
72
+ let n = Object.entries(t).filter(([e, t]) => t.theme || t.color);
73
+ return n.length ? /* @__PURE__ */ r("style", { dangerouslySetInnerHTML: { __html: Object.entries(f).map(([t, r]) => `
74
+ ${r} [data-chart=${e}] {
75
+ ${n.map(([e, n]) => {
76
+ let r = n.theme?.[t] || n.color;
77
+ return r ? ` --color-${e}: ${r};` : null;
78
+ }).join("\n")}
79
+ }
80
+ `).join("\n") } }) : null;
81
+ }, _ = a.Tooltip, v = t.forwardRef(({ active: a, payload: o = [], className: s, indicator: c = "dot", hideLabel: l = !1, hideIndicator: u = !1, label: d = "", labelFormatter: f, labelClassName: p, formatter: h, color: g, nameKey: _, labelKey: v }, y) => {
82
+ let { config: b } = m(), S = t.useMemo(() => {
83
+ if (l || !o?.length) return null;
84
+ let [t] = o, n = `${v || t.dataKey || t.name || "value"}`, i = x(b, t, n), a = !v && typeof d == "string" ? b[d]?.label || d : i?.label;
85
+ return f ? /* @__PURE__ */ r("div", {
86
+ className: e("font-medium", p),
87
+ children: f(a, o)
88
+ }) : a ? /* @__PURE__ */ r("div", {
89
+ className: e("font-medium", p),
90
+ children: a
91
+ }) : null;
92
+ }, [
93
+ d,
94
+ f,
95
+ o,
96
+ l,
97
+ p,
98
+ b,
99
+ v
100
+ ]);
101
+ if (!a || !o?.length) return null;
102
+ let C = o.length === 1 && c !== "dot";
103
+ return /* @__PURE__ */ i("div", {
104
+ ref: y,
105
+ className: e("grid min-w-[8rem] items-start gap-1.5 rounded-surface border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl", s),
106
+ children: [C ? null : S, /* @__PURE__ */ r("div", {
107
+ className: "grid gap-1.5",
108
+ children: o.map((t, a) => {
109
+ let o = `${_ || t.name || t.dataKey || "value"}`, s = x(b, t, o), l = g || t.payload.fill || t.color;
110
+ return /* @__PURE__ */ r("div", {
111
+ className: e("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", c === "dot" && "items-center"),
112
+ children: h && t?.value !== void 0 && t.name ? h(t.value, t.name, t, a, t.payload) : /* @__PURE__ */ i(n, { children: [s?.icon ? /* @__PURE__ */ r(s.icon, {}) : !u && /* @__PURE__ */ r("div", {
113
+ className: e("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
114
+ "h-2.5 w-2.5": c === "dot",
115
+ "w-1": c === "line",
116
+ "w-0 border-[1.5px] border-dashed bg-transparent": c === "dashed",
117
+ "my-0.5": C && c === "dashed"
118
+ }),
119
+ style: {
120
+ "--color-bg": l,
121
+ "--color-border": l
122
+ }
123
+ }), /* @__PURE__ */ i("div", {
124
+ className: e("flex flex-1 justify-between leading-none", C ? "items-end" : "items-center"),
125
+ children: [/* @__PURE__ */ i("div", {
126
+ className: "grid gap-1.5",
127
+ children: [C ? S : null, /* @__PURE__ */ r("span", {
128
+ className: "text-muted-foreground",
129
+ children: s?.label || t.name
130
+ })]
131
+ }), t.value && /* @__PURE__ */ r("span", {
132
+ className: "font-mono font-medium tabular-nums text-foreground",
133
+ children: t.value.toLocaleString()
134
+ })]
135
+ })] })
136
+ }, t.dataKey);
137
+ })
138
+ })]
139
+ });
140
+ });
141
+ v.displayName = "ChartTooltip";
142
+ var y = a.Legend, b = t.forwardRef(({ className: t, hideIcon: n = !1, payload: a, verticalAlign: o = "bottom", nameKey: s }, c) => {
143
+ let { config: l } = m();
144
+ return !a || !Array.isArray(a) || !a.length ? null : /* @__PURE__ */ r("div", {
145
+ ref: c,
146
+ className: e("flex items-center justify-center gap-4", o === "top" ? "pb-3" : "pt-3", t),
147
+ children: Array.isArray(a) && a.map((t) => {
148
+ let a = `${s || t.dataKey || "value"}`, o = x(l, t, a);
149
+ return /* @__PURE__ */ i("div", {
150
+ className: e("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),
151
+ children: [o?.icon && !n ? /* @__PURE__ */ r(o.icon, {}) : /* @__PURE__ */ r("div", {
152
+ className: "h-2 w-2 shrink-0 rounded-[2px]",
153
+ style: { backgroundColor: t.color }
154
+ }), o?.label]
155
+ }, t.value);
156
+ })
157
+ });
158
+ });
159
+ b.displayName = "ChartLegend";
160
+ function x(e, t, n) {
161
+ if (typeof t != "object" || !t) return;
162
+ let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
163
+ return n in t && typeof t[n] == "string" ? i = t[n] : r && n in r && typeof r[n] == "string" && (i = r[n]), i in e ? e[i] : e[n];
164
+ }
165
+ //#endregion
166
+ export { _ as a, u as c, s as d, c as f, g as i, l, y as n, v as o, b as r, o as s, h as t, d as u };