@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.
- package/dist/AppActions-C_0YI75w.js +60 -0
- package/dist/AppSubTitle-tqqV9nuT.js +19 -0
- package/dist/AppTitle-BR4JFZfp.js +19 -0
- package/dist/ErrorAlert-BDqDHUUc.js +27 -0
- package/dist/GenericForm-CWXT5wiv.js +310 -0
- package/dist/ImageInput-CN2ozjpc.js +80 -0
- package/dist/MultiSelect-BF0zL0B0.js +134 -0
- package/dist/SearchInput-BJPT0SbB.js +255 -0
- package/dist/alert-REQGK9bR.js +32 -0
- package/dist/behavior-BR_V9Rpe.js +76 -0
- package/dist/cards-Cta6x49J.js +126 -0
- package/dist/chart-Dq3AIrue.js +166 -0
- package/dist/charts-CXhVUqLH.js +328 -0
- package/dist/components/core/cards/index.js +2 -10
- package/dist/components/core/charts/index.js +2 -11
- package/dist/components/core/dialogs/index.js +4 -19
- package/dist/components/core/filters/index.js +426 -7
- package/dist/components/core/forms/index.js +2 -4
- package/dist/components/core/index.js +24 -97
- package/dist/components/core/inputs/index.js +4 -11
- package/dist/components/core/language/index.js +2 -4
- package/dist/components/core/layouts/index.js +50 -11
- package/dist/components/core/navbar/index.js +2 -9
- package/dist/components/core/states/index.js +3 -8
- package/dist/components/core/table/index.js +2 -15
- package/dist/components/core/tabs/index.js +188 -6
- package/dist/components/core/theme/index.js +2 -4
- package/dist/components/index.js +28 -322
- package/dist/components/ui/index.js +8 -240
- package/dist/contexts/index.js +2 -5
- package/dist/dialogs-BGHSClsq.js +208 -0
- package/dist/helpers/index.js +39 -46
- package/dist/hooks/behavior/index.js +2 -10
- package/dist/hooks/index.js +11 -30
- package/dist/hooks/ui/index.js +10 -22
- package/dist/i18n/index.js +2 -10
- package/dist/i18n-Dw99bRmg.js +190 -0
- package/dist/language-DxHhlpgN.js +58 -0
- package/dist/navbar-Bc5OQWRI.js +385 -0
- package/dist/providers/index.js +42 -49
- package/dist/pwa/index.js +32 -34
- package/dist/select-ULiTPOr5.js +81 -0
- package/dist/sheet-CRrYTZrl.js +226 -0
- package/dist/sidebar.context-BahtU6hE.js +5 -0
- package/dist/skeleton-D6Ga4BLw.js +11 -0
- package/dist/states-N8-LjFng.js +26 -0
- package/dist/table-muUyiaK6.js +571 -0
- package/dist/tailwind/index.js +126 -156
- package/dist/tailwind.helper-CJaRYBmL.js +8 -0
- package/dist/theme-B_n0F6R4.js +57 -0
- package/dist/tokens/index.js +37 -46
- package/dist/tooltip-B2dzyfs9.js +50 -0
- package/dist/types/forms/index.js +0 -1
- package/dist/types/index.js +1 -1
- package/dist/ui-CiX0E_bn.js +1165 -0
- package/dist/ui-DSVBO3iM.js +46 -0
- package/dist/useDocumentTitle-D7MywIeB.js +19 -0
- package/dist/useFixedColumns-DfAX30tT.js +147 -0
- package/dist/useLanguage-DN3CuBv5.js +19 -0
- package/dist/useMobile-pTQ8lWvt.js +16 -0
- package/dist/useNotifications-CyhTruIG.js +20 -0
- package/dist/useScrollFade-D9kqJBDh.js +27 -0
- package/dist/useTheme-DVfcJ-Qd.js +25 -0
- package/dist/useToast-UeDRLovh.js +103 -0
- package/package.json +2 -2
- package/dist/AppActions-BFwztl-1.js +0 -76
- package/dist/AppSubTitle-BTN0YAc7.js +0 -13
- package/dist/AppTitle-D15YXeMx.js +0 -13
- package/dist/AppVerticalTabs-B7XXtAVj.js +0 -103
- package/dist/ConfirmationDialog-Dj4WdnHg.js +0 -188
- package/dist/DataTable-CjrR27Di.js +0 -638
- package/dist/ErrorAlert-B99Xb_Hg.js +0 -23
- package/dist/ErrorState-CkeS_IBT.js +0 -14
- package/dist/GenericForm-CydibLHU.js +0 -343
- package/dist/ImageInput-DoOOvvth.js +0 -70
- package/dist/KpiCardsLayout-Bq4xQ3i8.js +0 -43
- package/dist/LanguageSelector-C7E51rCQ.js +0 -47
- package/dist/LoadingState-BN0YaPSs.js +0 -9
- package/dist/MetricCard-B0xnFyim.js +0 -53
- package/dist/MultiSelect-DbH7LrsD.js +0 -149
- package/dist/PieChart-uozNJtEx.js +0 -295
- package/dist/SearchInput-DIZ5Yt6L.js +0 -246
- package/dist/SkeletonCards-B9C4cNMr.js +0 -75
- package/dist/TableFilter-CmEVF5Bo.js +0 -422
- package/dist/ThemeSelector-CLi4_epH.js +0 -52
- package/dist/Topbar-Clby5_uj.js +0 -431
- package/dist/alert-B9F1N9Qk.js +0 -30
- package/dist/chart-DntJZGxB.js +0 -181
- package/dist/select-BpjFWqAY.js +0 -96
- package/dist/sheet-XYI-ezvY.js +0 -292
- package/dist/sidebar.context-D5nywlmP.js +0 -6
- package/dist/skeleton-BX4RcsiK.js +0 -8
- package/dist/tailwind.helper-B6yFEsav.js +0 -8
- package/dist/toaster-CyzB1m5z.js +0 -75
- package/dist/toggle-group-iZqnrTj7.js +0 -1276
- package/dist/tooltip-DVeqVwqV.js +0 -61
- package/dist/useDateFnsLocale-D6VExZ8U.js +0 -11
- package/dist/useDocumentTitle-WNwdPz-I.js +0 -14
- package/dist/useFixedColumns-CKZyu4PD.js +0 -161
- package/dist/useKrosoftTranslation-BTp46G94.js +0 -47
- package/dist/useLanguage-C9jI2nwn.js +0 -19
- package/dist/useMobile-DN1_OMDB.js +0 -16
- package/dist/useNotifications-zbUhCvF_.js +0 -12
- package/dist/usePage-BQm6tdJD.js +0 -84
- package/dist/useScrollFade-BA4KqJYp.js +0 -23
- package/dist/useServerTable-UvTY6L1N.js +0 -38
- package/dist/useSidebar-BJuALHqQ.js +0 -11
- package/dist/useTheme-DS6ZjdzM.js +0 -27
- package/dist/useToast-BFTk4lWz.js +0 -100
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import "./useScrollFade-D9kqJBDh.js";
|
|
2
|
+
import "./useToast-UeDRLovh.js";
|
|
3
|
+
import "./useMobile-pTQ8lWvt.js";
|
|
4
|
+
import "./useNotifications-CyhTruIG.js";
|
|
5
|
+
import "./useLanguage-DN3CuBv5.js";
|
|
6
|
+
import "./useDocumentTitle-D7MywIeB.js";
|
|
7
|
+
import "./useFixedColumns-DfAX30tT.js";
|
|
8
|
+
import "./useTheme-DVfcJ-Qd.js";
|
|
9
|
+
import { useCallback as e, useEffect as t, useState as n } from "react";
|
|
10
|
+
//#region src/hooks/ui/useServerTable.ts
|
|
11
|
+
function r(r, i = "nom", a = {}) {
|
|
12
|
+
let [o, s] = n(a.initialPage ?? 1), [c, l] = n(a.initialPageSize ?? 10), [u, d] = n(i), [f, p] = n(a.initialSortDirection ?? "asc"), [m, h] = n(a.initialSearchText ?? ""), [g, _] = n(a.initialSearchText ?? ""), [v, y] = n(r);
|
|
13
|
+
t(() => {
|
|
14
|
+
let e = setTimeout(() => {
|
|
15
|
+
_(m);
|
|
16
|
+
}, a.debounceMs ?? 300);
|
|
17
|
+
return () => {
|
|
18
|
+
clearTimeout(e);
|
|
19
|
+
};
|
|
20
|
+
}, [m, a.debounceMs]);
|
|
21
|
+
let b = e((e) => {
|
|
22
|
+
h(e), s(1);
|
|
23
|
+
}, []), x = e((e) => {
|
|
24
|
+
y(e), s(1);
|
|
25
|
+
}, []), S = e((e, t) => {
|
|
26
|
+
d(e), p(t);
|
|
27
|
+
}, []);
|
|
28
|
+
return {
|
|
29
|
+
currentPage: o,
|
|
30
|
+
onPageChange: s,
|
|
31
|
+
pageSize: c,
|
|
32
|
+
onPageSizeChange: e((e) => {
|
|
33
|
+
l(e), s(1);
|
|
34
|
+
}, []),
|
|
35
|
+
sortColumn: u,
|
|
36
|
+
sortDirection: f,
|
|
37
|
+
onSortChange: S,
|
|
38
|
+
searchText: m,
|
|
39
|
+
debouncedSearchText: g,
|
|
40
|
+
onSearchChange: b,
|
|
41
|
+
appliedFilters: v,
|
|
42
|
+
onFiltersChange: x
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { r as t };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect as e } from "react";
|
|
2
|
+
import { useTranslation as t } from "react-i18next";
|
|
3
|
+
//#region src/hooks/ui/useDocumentTitle.ts
|
|
4
|
+
var n = (n, r, i) => {
|
|
5
|
+
let { t: a } = t();
|
|
6
|
+
e(() => {
|
|
7
|
+
let e = a(n), t = document.title, o = r ? `${e} - ${r}` : e, s = i ? `${o} | ${i}` : o;
|
|
8
|
+
return document.title = s, () => {
|
|
9
|
+
document.title = t;
|
|
10
|
+
};
|
|
11
|
+
}, [
|
|
12
|
+
i,
|
|
13
|
+
r,
|
|
14
|
+
a,
|
|
15
|
+
n
|
|
16
|
+
]);
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { n as t };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { useCallback as e, useLayoutEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
|
+
//#region src/hooks/ui/useDataTable.ts
|
|
3
|
+
function a({ data: t, columns: a, getRowId: o, defaultPageSize: s, actions: c, bulkActions: l, columnVisibility: ee = !0, totalRows: u, currentPage: d, pageSize: te, onPageChange: f, onPageSizeChange: p, sortColumn: m, sortDirection: h, onSortChange: g }) {
|
|
4
|
+
let [_, v] = i(a.find((e) => e.sortable === !0)?.key ?? null), y = m === void 0 ? _ : m, [b, x] = i("asc"), S = h ?? b, [C, w] = i([]), [T, ne] = i(new Set(a.filter((e) => e.defaultVisible !== !1).map((e) => e.key))), [E, re] = i(a.map((e) => e.key)), [D, ie] = i(a.reduce((e, t) => ({
|
|
5
|
+
...e,
|
|
6
|
+
[t.key]: t.minWidth ?? 100
|
|
7
|
+
}), {})), [O, k] = i(1), A = d ?? O, [ae, oe] = i(s), j = te ?? ae, M = r(null), N = r(null), P = r(0), F = r(0), I = r(null), L = r(null), R = c !== void 0 && c.length > 0, z = l !== void 0 && l.length > 0, B = n(() => E.map((e) => a.find((t) => t.key === e)).filter((e) => e !== void 0), [E, a]), V = n(() => B.filter((e) => T.has(e.key)), [B, T]), H = V.length + +!!z + (R || ee ? 1 : 0), U = u ?? t.length, W = Math.max(1, Math.ceil(U / j)), G = A > W ? W : A, K = U === 0 ? 0 : (G - 1) * j, q = u === void 0 ? Math.min(K + j, t.length) : Math.min(K + t.length, u), J = e((e) => {
|
|
8
|
+
f ? f(e) : k(e);
|
|
9
|
+
}, [f]), Y = e((e) => {
|
|
10
|
+
p ? p(e) : (oe(e), k(1));
|
|
11
|
+
}, [p]), se = e((e) => {
|
|
12
|
+
let t = typeof e == "function" ? e(A) : e;
|
|
13
|
+
J(t);
|
|
14
|
+
}, [A, J]), X = e((e) => {
|
|
15
|
+
let t = typeof e == "function" ? e(j) : e;
|
|
16
|
+
Y(t);
|
|
17
|
+
}, [j, Y]), ce = e((e) => {
|
|
18
|
+
if (a.find((t) => t.key === e)?.sortable !== !0) return;
|
|
19
|
+
let t = "asc";
|
|
20
|
+
y === e && (t = S === "asc" ? "desc" : "asc"), g ? g(e, t) : (v(e), x(t), J(1));
|
|
21
|
+
}, [
|
|
22
|
+
a,
|
|
23
|
+
y,
|
|
24
|
+
S,
|
|
25
|
+
g,
|
|
26
|
+
J
|
|
27
|
+
]), Z = e((e) => {
|
|
28
|
+
let t = N.current;
|
|
29
|
+
if (t === null) return;
|
|
30
|
+
let n = e.clientX - P.current, r = Math.max(80, F.current + n);
|
|
31
|
+
ie((e) => ({
|
|
32
|
+
...e,
|
|
33
|
+
[t]: r
|
|
34
|
+
}));
|
|
35
|
+
}, []), Q = e(function e() {
|
|
36
|
+
N.current = null, document.removeEventListener("mousemove", Z), document.removeEventListener("mouseup", e);
|
|
37
|
+
}, [Z]), le = e((e, t) => {
|
|
38
|
+
e.preventDefault(), e.stopPropagation(), N.current = t, P.current = e.clientX, F.current = D[t], document.addEventListener("mousemove", Z), document.addEventListener("mouseup", Q);
|
|
39
|
+
}, [
|
|
40
|
+
D,
|
|
41
|
+
Z,
|
|
42
|
+
Q
|
|
43
|
+
]), ue = (e, t) => {
|
|
44
|
+
I.current = t, e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/html", t);
|
|
45
|
+
}, de = (e, t) => {
|
|
46
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", L.current = t;
|
|
47
|
+
}, fe = (e, t) => {
|
|
48
|
+
if (e.preventDefault(), I.current === null || I.current === t) return;
|
|
49
|
+
let n = [...E], r = n.indexOf(I.current), i = n.indexOf(t);
|
|
50
|
+
n.splice(r, 1), n.splice(i, 0, I.current), re(n), I.current = null, L.current = null;
|
|
51
|
+
}, $ = n(() => g === void 0 ? [...t].sort((e, t) => {
|
|
52
|
+
if (y === null) return 0;
|
|
53
|
+
let n = a.find((e) => e.key === y), r = n?.getSortValue === void 0 ? e[y] : n.getSortValue(e), i = n?.getSortValue === void 0 ? t[y] : n.getSortValue(t);
|
|
54
|
+
if (typeof r == "string" && typeof i == "string") {
|
|
55
|
+
let e = r.localeCompare(i);
|
|
56
|
+
return S === "asc" ? e : -e;
|
|
57
|
+
}
|
|
58
|
+
return r === i ? 0 : r == null ? 1 : i == null ? -1 : r < i ? S === "asc" ? -1 : 1 : r > i ? S === "asc" ? 1 : -1 : 0;
|
|
59
|
+
}) : t, [
|
|
60
|
+
t,
|
|
61
|
+
y,
|
|
62
|
+
S,
|
|
63
|
+
a,
|
|
64
|
+
g
|
|
65
|
+
]);
|
|
66
|
+
return {
|
|
67
|
+
sortColumn: y,
|
|
68
|
+
sortDirection: S,
|
|
69
|
+
selectedRows: C,
|
|
70
|
+
setSelectedRows: w,
|
|
71
|
+
visibleColumns: T,
|
|
72
|
+
columnWidths: D,
|
|
73
|
+
currentPage: A,
|
|
74
|
+
setCurrentPage: se,
|
|
75
|
+
pageSize: j,
|
|
76
|
+
setPageSize: X,
|
|
77
|
+
totalPages: W,
|
|
78
|
+
safeCurrentPage: G,
|
|
79
|
+
startIndex: K,
|
|
80
|
+
endIndex: q,
|
|
81
|
+
tableRef: M,
|
|
82
|
+
hasActions: R,
|
|
83
|
+
hasBulkActions: z,
|
|
84
|
+
orderedColumns: B,
|
|
85
|
+
visibleColumnsArray: V,
|
|
86
|
+
colSpanCount: H,
|
|
87
|
+
paginatedData: n(() => u === void 0 ? $.slice(K, q) : $, [
|
|
88
|
+
$,
|
|
89
|
+
K,
|
|
90
|
+
q,
|
|
91
|
+
u
|
|
92
|
+
]),
|
|
93
|
+
handleSort: ce,
|
|
94
|
+
handleMouseDown: le,
|
|
95
|
+
handleDragStart: ue,
|
|
96
|
+
handleDragOver: de,
|
|
97
|
+
handleDrop: fe,
|
|
98
|
+
toggleColumnVisibility: (e) => {
|
|
99
|
+
let t = new Set(T);
|
|
100
|
+
t.has(e) ? t.delete(e) : t.add(e), ne(t);
|
|
101
|
+
},
|
|
102
|
+
toggleRowSelection: (e) => {
|
|
103
|
+
C.includes(e) ? w(C.filter((t) => t !== e)) : w([...C, e]);
|
|
104
|
+
},
|
|
105
|
+
toggleSelectAll: () => {
|
|
106
|
+
C.length === t.length ? w([]) : w(t.map((e) => o(e)));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/hooks/ui/useFixedColumns.ts
|
|
112
|
+
var o = (e, t) => {
|
|
113
|
+
let n = Object.keys(e);
|
|
114
|
+
return n.length === Object.keys(t).length && n.every((n) => {
|
|
115
|
+
let r = e[n], i = t[n];
|
|
116
|
+
return r.side === i?.side && r.offset === i.offset && r.isEdge === i.isEdge;
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
function s(e) {
|
|
120
|
+
let [n, r] = i({});
|
|
121
|
+
return t(() => {
|
|
122
|
+
let t = e.current;
|
|
123
|
+
if (!t) return;
|
|
124
|
+
let n = [], i = () => {
|
|
125
|
+
n = Array.from(t.querySelectorAll("thead th[data-fixed-side]"));
|
|
126
|
+
let e = {}, i = (t, n) => {
|
|
127
|
+
let r = 0;
|
|
128
|
+
t.forEach((i, a) => {
|
|
129
|
+
let o = i.dataset.columnKey;
|
|
130
|
+
o !== void 0 && (e[o] = {
|
|
131
|
+
side: n,
|
|
132
|
+
offset: r,
|
|
133
|
+
isEdge: a === t.length - 1
|
|
134
|
+
}, r += i.getBoundingClientRect().width);
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
i(n.filter((e) => e.dataset.fixedSide === "left"), "left"), i(n.filter((e) => e.dataset.fixedSide === "right").reverse(), "right"), r((t) => o(t, e) ? t : e);
|
|
138
|
+
};
|
|
139
|
+
i();
|
|
140
|
+
let a = typeof ResizeObserver > "u" ? null : new ResizeObserver(i);
|
|
141
|
+
return a?.observe(t), n.forEach((e) => a?.observe(e)), () => {
|
|
142
|
+
a?.disconnect();
|
|
143
|
+
};
|
|
144
|
+
}), n;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
export { a as n, s as t };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useTranslation as e } from "react-i18next";
|
|
2
|
+
//#region src/hooks/ui/useLanguage.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
let { i18n: n } = e(), r = n.language ?? "", i = r.split("-")[0], a = t.find((e) => e.value === r) ?? t.find((e) => e.value === i) ?? t[0], o = t.findIndex((e) => e.value === a?.value), s = t.length > 0 ? t[(o + 1) % t.length] : void 0, c = (e) => {
|
|
5
|
+
n.changeLanguage(e);
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
language: r,
|
|
9
|
+
languageOptions: t,
|
|
10
|
+
currentLanguageOption: a,
|
|
11
|
+
nextLanguageOption: s,
|
|
12
|
+
changeLanguage: c,
|
|
13
|
+
cycleLanguage: () => {
|
|
14
|
+
s && c(s.value);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
2
|
+
//#region src/hooks/ui/useMobile.tsx
|
|
3
|
+
var n = 768;
|
|
4
|
+
function r() {
|
|
5
|
+
let [r, i] = t(!1);
|
|
6
|
+
return e(() => {
|
|
7
|
+
let e = window.matchMedia("(max-width: 767px)"), t = () => {
|
|
8
|
+
i(window.innerWidth < n);
|
|
9
|
+
};
|
|
10
|
+
return e.addEventListener("change", t), i(window.innerWidth < n), () => {
|
|
11
|
+
e.removeEventListener("change", t);
|
|
12
|
+
};
|
|
13
|
+
}, []), r;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { r as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as e } from "./useToast-UeDRLovh.js";
|
|
2
|
+
//#region src/hooks/ui/useNotifications.ts
|
|
3
|
+
var t = () => ({
|
|
4
|
+
showSuccess: (t, n, r) => {
|
|
5
|
+
e({
|
|
6
|
+
title: t,
|
|
7
|
+
description: n,
|
|
8
|
+
action: r
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
showError: (t, n, r) => {
|
|
12
|
+
console.error(n, r), e({
|
|
13
|
+
title: t,
|
|
14
|
+
description: n,
|
|
15
|
+
variant: "destructive"
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
//#endregion
|
|
20
|
+
export { t };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useLayoutEffect as e, useState as t } from "react";
|
|
2
|
+
//#region src/hooks/ui/useScrollFade.ts
|
|
3
|
+
var n = "1.5rem";
|
|
4
|
+
function r(r) {
|
|
5
|
+
let [i, a] = t({
|
|
6
|
+
start: !1,
|
|
7
|
+
end: !1
|
|
8
|
+
});
|
|
9
|
+
return e(() => {
|
|
10
|
+
let e = r.current;
|
|
11
|
+
if (!e) return;
|
|
12
|
+
let t = () => {
|
|
13
|
+
let t = e.scrollWidth - e.clientWidth, n = e.scrollLeft > 1, r = e.scrollLeft < t - 1;
|
|
14
|
+
a((e) => e.start === n && e.end === r ? e : {
|
|
15
|
+
start: n,
|
|
16
|
+
end: r
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
t(), e.addEventListener("scroll", t, { passive: !0 });
|
|
20
|
+
let n = typeof ResizeObserver > "u" ? null : new ResizeObserver(t);
|
|
21
|
+
return n?.observe(e), () => {
|
|
22
|
+
e.removeEventListener("scroll", t), n?.disconnect();
|
|
23
|
+
};
|
|
24
|
+
}), !i.start && !i.end ? {} : { maskImage: `linear-gradient(to right, transparent 0, #000 ${i.start ? n : "0px"}, #000 calc(100% - ${i.end ? n : "0px"}), transparent 100%)` };
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { r as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { t as e } from "./i18n-Dw99bRmg.js";
|
|
2
|
+
import { t } from "./useNotifications-CyhTruIG.js";
|
|
3
|
+
import { useTheme as n } from "next-themes";
|
|
4
|
+
//#region src/hooks/ui/useTheme.ts
|
|
5
|
+
function r(r) {
|
|
6
|
+
let { t: i } = e(), { showSuccess: a } = t(), { theme: o, setTheme: s } = n(), c = (e) => {
|
|
7
|
+
s(e);
|
|
8
|
+
let t = r.find((t) => t.value === e);
|
|
9
|
+
a(i("theme.updatedTitle"), i("theme.updatedMessage", { theme: t?.label ?? e }));
|
|
10
|
+
}, l = r.filter((e) => !e.hideInMini), u = r.find((e) => e.value === o), d = l.findIndex((e) => e.value === o), f = l.length > 0 ? l[(d + 1) % l.length] : void 0;
|
|
11
|
+
return {
|
|
12
|
+
theme: o,
|
|
13
|
+
setTheme: s,
|
|
14
|
+
handleThemeChange: c,
|
|
15
|
+
themeOptions: r,
|
|
16
|
+
currentThemeOption: u,
|
|
17
|
+
nextThemeOption: f,
|
|
18
|
+
isDark: o?.startsWith("dark") ?? !1,
|
|
19
|
+
cycleTheme: () => {
|
|
20
|
+
f && c(f.value);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { r as t };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
//#region src/hooks/ui/useToast.ts
|
|
3
|
+
var t = 1, n = 1e6, r = 0;
|
|
4
|
+
function i() {
|
|
5
|
+
return r = (r + 1) % (2 ** 53 - 1), r.toString();
|
|
6
|
+
}
|
|
7
|
+
var a = /* @__PURE__ */ new Map(), o = (e) => {
|
|
8
|
+
if (a.has(e)) return;
|
|
9
|
+
let t = setTimeout(() => {
|
|
10
|
+
a.delete(e), u({
|
|
11
|
+
type: "REMOVE_TOAST",
|
|
12
|
+
toastId: e
|
|
13
|
+
});
|
|
14
|
+
}, n);
|
|
15
|
+
a.set(e, t);
|
|
16
|
+
}, s = (e, n) => {
|
|
17
|
+
switch (n.type) {
|
|
18
|
+
case "ADD_TOAST": return {
|
|
19
|
+
...e,
|
|
20
|
+
toasts: [n.toast, ...e.toasts].slice(0, t)
|
|
21
|
+
};
|
|
22
|
+
case "UPDATE_TOAST": return {
|
|
23
|
+
...e,
|
|
24
|
+
toasts: e.toasts.map((e) => e.id === n.toast.id ? {
|
|
25
|
+
...e,
|
|
26
|
+
...n.toast
|
|
27
|
+
} : e)
|
|
28
|
+
};
|
|
29
|
+
case "DISMISS_TOAST": {
|
|
30
|
+
let { toastId: t } = n;
|
|
31
|
+
return t === void 0 ? e.toasts.forEach((e) => {
|
|
32
|
+
o(e.id);
|
|
33
|
+
}) : o(t), {
|
|
34
|
+
...e,
|
|
35
|
+
toasts: e.toasts.map((e) => e.id === t || t === void 0 ? {
|
|
36
|
+
...e,
|
|
37
|
+
open: !1
|
|
38
|
+
} : e)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
case "REMOVE_TOAST": return n.toastId === void 0 ? {
|
|
42
|
+
...e,
|
|
43
|
+
toasts: []
|
|
44
|
+
} : {
|
|
45
|
+
...e,
|
|
46
|
+
toasts: e.toasts.filter((e) => e.id !== n.toastId)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}, c = [], l = { toasts: [] };
|
|
50
|
+
function u(e) {
|
|
51
|
+
l = s(l, e), c.forEach((e) => {
|
|
52
|
+
e(l);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function d({ ...e }) {
|
|
56
|
+
let t = i(), n = (e) => {
|
|
57
|
+
u({
|
|
58
|
+
type: "UPDATE_TOAST",
|
|
59
|
+
toast: {
|
|
60
|
+
...e,
|
|
61
|
+
id: t
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}, r = () => {
|
|
65
|
+
u({
|
|
66
|
+
type: "DISMISS_TOAST",
|
|
67
|
+
toastId: t
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return u({
|
|
71
|
+
type: "ADD_TOAST",
|
|
72
|
+
toast: {
|
|
73
|
+
...e,
|
|
74
|
+
id: t,
|
|
75
|
+
open: !0,
|
|
76
|
+
onOpenChange: (e) => {
|
|
77
|
+
e || r();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}), {
|
|
81
|
+
id: t,
|
|
82
|
+
dismiss: r,
|
|
83
|
+
update: n
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function f() {
|
|
87
|
+
let [t, n] = e.useState(l);
|
|
88
|
+
return e.useEffect(() => (c.push(n), () => {
|
|
89
|
+
let e = c.indexOf(n);
|
|
90
|
+
e > -1 && c.splice(e, 1);
|
|
91
|
+
}), [t]), {
|
|
92
|
+
...t,
|
|
93
|
+
toast: d,
|
|
94
|
+
dismiss: (e) => {
|
|
95
|
+
u({
|
|
96
|
+
type: "DISMISS_TOAST",
|
|
97
|
+
toastId: e
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { f as n, d as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krosoft/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.239",
|
|
4
4
|
"description": "Krosoft shared React package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"tailwindcss": "^3.4.19",
|
|
123
123
|
"tsc-alias": "^1.9.2",
|
|
124
124
|
"typescript": "^5.9.3",
|
|
125
|
-
"vite": "^
|
|
125
|
+
"vite": "^8.2.2",
|
|
126
126
|
"vite-plugin-pwa": "^1.3.0",
|
|
127
127
|
"vitest": "^4.1.11"
|
|
128
128
|
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { jsxs as n, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { a3 as u, ah as t, a5 as c, ac as g, a7 as d } from "./toggle-group-iZqnrTj7.js";
|
|
3
|
-
import "./alert-B9F1N9Qk.js";
|
|
4
|
-
import "@radix-ui/react-aspect-ratio";
|
|
5
|
-
import { B as p } from "./tooltip-DVeqVwqV.js";
|
|
6
|
-
import "./chart-DntJZGxB.js";
|
|
7
|
-
import "@radix-ui/react-collapsible";
|
|
8
|
-
import "./sheet-XYI-ezvY.js";
|
|
9
|
-
import { MoreVerticalIcon as h } from "lucide-react";
|
|
10
|
-
import "react-resizable-panels";
|
|
11
|
-
import { c as i } from "./tailwind.helper-B6yFEsav.js";
|
|
12
|
-
import "./select-BpjFWqAY.js";
|
|
13
|
-
import "next-themes";
|
|
14
|
-
import "sonner";
|
|
15
|
-
import "react";
|
|
16
|
-
import { useTranslation as v } from "react-i18next";
|
|
17
|
-
import { u as C } from "./useMobile-DN1_OMDB.js";
|
|
18
|
-
function G({ actions: o, className: b }) {
|
|
19
|
-
const { t: m } = v(), N = C();
|
|
20
|
-
return !o || o.length === 0 ? null : N ? /* @__PURE__ */ n(u, { children: [
|
|
21
|
-
/* @__PURE__ */ l(t, { asChild: !0, children: /* @__PURE__ */ l(p, { variant: "outline", size: "icon", children: /* @__PURE__ */ l(h, { className: "size-4" }) }) }),
|
|
22
|
-
/* @__PURE__ */ l(c, { align: "end", className: "min-w-48", children: o.map((r, e) => r ? r.children && r.children.length > 0 ? /* @__PURE__ */ n("div", { children: [
|
|
23
|
-
e > 0 && /* @__PURE__ */ l(g, {}),
|
|
24
|
-
r.children.map((s, a) => s ? /* @__PURE__ */ n(
|
|
25
|
-
d,
|
|
26
|
-
{
|
|
27
|
-
onClick: () => void s.onClick(),
|
|
28
|
-
disabled: s.disabled,
|
|
29
|
-
className: i("gap-2", s.className),
|
|
30
|
-
children: [
|
|
31
|
-
s.icon && /* @__PURE__ */ l(s.icon, { className: "size-4" }),
|
|
32
|
-
s.labelKey && m(s.labelKey)
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
a
|
|
36
|
-
) : null)
|
|
37
|
-
] }, e) : /* @__PURE__ */ n(d, { onClick: () => void r.onClick(), disabled: r.disabled, className: i("gap-2", r.className), children: [
|
|
38
|
-
r.icon && /* @__PURE__ */ l(r.icon, { className: "size-4" }),
|
|
39
|
-
r.labelKey && m(r.labelKey)
|
|
40
|
-
] }, e) : null) })
|
|
41
|
-
] }) : ((r) => /* @__PURE__ */ l("div", { className: i("flex gap-2", b), children: r.map((e, s) => e ? e.children && e.children.length > 0 ? /* @__PURE__ */ n(u, { children: [
|
|
42
|
-
/* @__PURE__ */ l(t, { asChild: !0, children: /* @__PURE__ */ n(p, { variant: e.variant, disabled: e.disabled, className: i("gap-2", e.className), children: [
|
|
43
|
-
e.icon && /* @__PURE__ */ l(e.icon, { className: "size-4" }),
|
|
44
|
-
e.labelKey && m(e.labelKey)
|
|
45
|
-
] }) }),
|
|
46
|
-
/* @__PURE__ */ l(c, { align: "end", children: e.children.map((a, f) => a ? /* @__PURE__ */ n(
|
|
47
|
-
d,
|
|
48
|
-
{
|
|
49
|
-
onClick: () => void a.onClick(),
|
|
50
|
-
disabled: a.disabled,
|
|
51
|
-
className: i("gap-2", a.className),
|
|
52
|
-
children: [
|
|
53
|
-
a.icon && /* @__PURE__ */ l(a.icon, { className: "size-4" }),
|
|
54
|
-
a.labelKey && m(a.labelKey)
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
|
-
f
|
|
58
|
-
) : null) })
|
|
59
|
-
] }, s) : /* @__PURE__ */ n(
|
|
60
|
-
p,
|
|
61
|
-
{
|
|
62
|
-
variant: e.variant,
|
|
63
|
-
onClick: () => void e.onClick(),
|
|
64
|
-
disabled: e.disabled,
|
|
65
|
-
className: i("gap-2", e.className),
|
|
66
|
-
children: [
|
|
67
|
-
e.icon && /* @__PURE__ */ l(e.icon, { className: "size-4" }),
|
|
68
|
-
e.labelKey && m(e.labelKey)
|
|
69
|
-
]
|
|
70
|
-
},
|
|
71
|
-
s
|
|
72
|
-
) : null) }))(o);
|
|
73
|
-
}
|
|
74
|
-
export {
|
|
75
|
-
G as A
|
|
76
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useTranslation as l } from "react-i18next";
|
|
3
|
-
import { A as m } from "./AppActions-BFwztl-1.js";
|
|
4
|
-
function f({ titleKey: s, actions: t, className: o }) {
|
|
5
|
-
const { t: r } = l();
|
|
6
|
-
return /* @__PURE__ */ i("div", { className: "flex flex-col sm:flex-row sm:items-center justify-between gap-4", children: [
|
|
7
|
-
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold", children: r(s) }),
|
|
8
|
-
/* @__PURE__ */ e(m, { actions: t, className: o })
|
|
9
|
-
] });
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
f as A
|
|
13
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsxs as n, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { c as x } from "./tailwind.helper-B6yFEsav.js";
|
|
3
|
-
import { useTranslation as r } from "react-i18next";
|
|
4
|
-
function c({ titleKey: m, descriptionKey: t, isSubTitle: e }) {
|
|
5
|
-
const { t: l } = r();
|
|
6
|
-
return /* @__PURE__ */ n("div", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
7
|
-
/* @__PURE__ */ o("h1", { className: e ? "text-xl md:text-2xl font-semibold" : "text-xl md:text-3xl font-bold", children: l(m) ?? "" }),
|
|
8
|
-
t ? /* @__PURE__ */ o("p", { className: x("hidden md:block text-muted-foreground", e && "text-sm"), children: l(t) }) : null
|
|
9
|
-
] });
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
c as A
|
|
13
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { jsxs as n, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { C as w, d as S, a as T } from "./chart-DntJZGxB.js";
|
|
3
|
-
import { A as C } from "./AppActions-BFwztl-1.js";
|
|
4
|
-
import { A as b } from "./AppTitle-D15YXeMx.js";
|
|
5
|
-
import { bd as A, bf as P, bg as k, be as j } from "./toggle-group-iZqnrTj7.js";
|
|
6
|
-
import { useRef as z, useEffect as K } from "react";
|
|
7
|
-
import { useTranslation as g } from "react-i18next";
|
|
8
|
-
import { useSearchParams as y } from "react-router-dom";
|
|
9
|
-
import { c as V } from "./tailwind.helper-B6yFEsav.js";
|
|
10
|
-
import { S as R } from "./sheet-XYI-ezvY.js";
|
|
11
|
-
import { S as q, h as I, i as L, a as H, c as U } from "./select-BpjFWqAY.js";
|
|
12
|
-
import { ConstructionIcon as v } from "lucide-react";
|
|
13
|
-
import "date-fns/locale";
|
|
14
|
-
import { u as D } from "./useKrosoftTranslation-BTp46G94.js";
|
|
15
|
-
function E({ titleKey: s, descriptionKey: t, actions: c = [], className: l }) {
|
|
16
|
-
return /* @__PURE__ */ n("div", { className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between", children: [
|
|
17
|
-
/* @__PURE__ */ a(b, { titleKey: s, descriptionKey: t, isSubTitle: !0 }),
|
|
18
|
-
/* @__PURE__ */ a(C, { actions: c, className: l })
|
|
19
|
-
] });
|
|
20
|
-
}
|
|
21
|
-
function ae({ titleKey: s, descriptionKey: t, actions: c = [], className: l, children: o, isSubTitle: p }) {
|
|
22
|
-
return /* @__PURE__ */ n(w, { children: [
|
|
23
|
-
/* @__PURE__ */ a(S, { children: /* @__PURE__ */ a(E, { titleKey: s, descriptionKey: t, actions: c, className: l }) }),
|
|
24
|
-
/* @__PURE__ */ a(T, { className: "space-y-4", children: o })
|
|
25
|
-
] });
|
|
26
|
-
}
|
|
27
|
-
function se({ tabs: s, itemId: t, item: c, fit: l }) {
|
|
28
|
-
var d, u;
|
|
29
|
-
const { t: o } = g(), [p, f] = y(), i = p.get("tab"), m = ((d = s.find((e) => e.value === i)) == null ? void 0 : d.value) ?? ((u = s[0]) == null ? void 0 : u.value), x = (e) => {
|
|
30
|
-
const r = new URLSearchParams();
|
|
31
|
-
r.set("tab", e), f(r);
|
|
32
|
-
}, h = z(null);
|
|
33
|
-
return K(() => {
|
|
34
|
-
var r, N;
|
|
35
|
-
const e = (r = h.current) == null ? void 0 : r.querySelector('[data-state="active"]');
|
|
36
|
-
(N = e == null ? void 0 : e.scrollIntoView) == null || N.call(e, { behavior: "smooth", block: "nearest", inline: "nearest" });
|
|
37
|
-
}, [m]), /* @__PURE__ */ n(A, { value: m, onValueChange: x, children: [
|
|
38
|
-
/* @__PURE__ */ a(P, { ref: h, className: V("w-full justify-start", l && "sm:w-fit"), children: s.map((e) => /* @__PURE__ */ n(k, { value: e.value, className: "gap-2", disabled: e.disabled, children: [
|
|
39
|
-
e.icon ? /* @__PURE__ */ a("span", { className: "hidden sm:inline", children: /* @__PURE__ */ a(e.icon, { className: "size-4" }) }) : null,
|
|
40
|
-
/* @__PURE__ */ a("span", { className: "text-xs sm:text-sm", children: o(e.titleKey) ?? "" }),
|
|
41
|
-
e.count ? /* @__PURE__ */ n("span", { className: "text-gray-500 text-xs", children: [
|
|
42
|
-
"(",
|
|
43
|
-
e.count(c),
|
|
44
|
-
")"
|
|
45
|
-
] }) : null
|
|
46
|
-
] }, e.value)) }),
|
|
47
|
-
s.map((e) => /* @__PURE__ */ a(j, { value: e.value, className: "mt-4", children: e.component ? e.component(t) : null }, e.value))
|
|
48
|
-
] });
|
|
49
|
-
}
|
|
50
|
-
const re = ({ tabs: s, item: t }) => {
|
|
51
|
-
var d, u;
|
|
52
|
-
const { t: c } = g(), { t: l } = D(), [o, p] = y(), f = o.get("tab"), i = ((d = s.find((e) => e.value === f)) == null ? void 0 : d.value) ?? ((u = s[0]) == null ? void 0 : u.value), m = (e) => {
|
|
53
|
-
const r = new URLSearchParams();
|
|
54
|
-
r.set("tab", e), p(r);
|
|
55
|
-
}, x = () => {
|
|
56
|
-
const e = s.find((r) => r.value === i);
|
|
57
|
-
return e ? e.component ? e.component() : h() : null;
|
|
58
|
-
}, h = () => /* @__PURE__ */ a("div", { className: "p-4 lg:p-6", children: /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-64 text-gray-500", children: /* @__PURE__ */ n("div", { className: "text-center", children: [
|
|
59
|
-
/* @__PURE__ */ a(v, { className: "h-12 w-12 mx-auto mb-4 text-amber-500" }),
|
|
60
|
-
/* @__PURE__ */ a("p", { className: "text-lg font-medium", children: l("states.underConstruction") }),
|
|
61
|
-
/* @__PURE__ */ a("p", { className: "text-sm text-gray-400", children: l("states.comingSoon") })
|
|
62
|
-
] }) }) });
|
|
63
|
-
return /* @__PURE__ */ n("div", { className: "flex flex-col md:flex-row h-full min-w-0 ", children: [
|
|
64
|
-
/* @__PURE__ */ a("div", { className: "w-64 lg:w-80 flex-shrink-0 hidden md:block border-r border-gray-200 dark:border-gray-700 pr-4", children: /* @__PURE__ */ a(R, { className: "h-full", children: /* @__PURE__ */ a("div", { className: "space-y-1", children: s.map((e, r) => /* @__PURE__ */ n(
|
|
65
|
-
"div",
|
|
66
|
-
{
|
|
67
|
-
className: `px-2 py-2 rounded-control text-sm transition-colors flex items-center gap-2 ${e.disabled ? "text-gray-400 cursor-not-allowed opacity-50" : i === e.value ? "crm-color-styled font-medium cursor-pointer" : "text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700 cursor-pointer"}`,
|
|
68
|
-
onClick: () => !e.disabled && m(e.value),
|
|
69
|
-
children: [
|
|
70
|
-
e.icon && /* @__PURE__ */ a(e.icon, { className: "size-4" }),
|
|
71
|
-
/* @__PURE__ */ a("span", { className: "flex-1", children: c(e.titleKey) }),
|
|
72
|
-
e.count && /* @__PURE__ */ n("span", { className: "text-xs text-gray-500", children: [
|
|
73
|
-
"(",
|
|
74
|
-
e.count(t),
|
|
75
|
-
")"
|
|
76
|
-
] }),
|
|
77
|
-
!e.component && /* @__PURE__ */ a(v, { className: "size-4 text-amber-500" })
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
r
|
|
81
|
-
)) }) }) }),
|
|
82
|
-
/* @__PURE__ */ a("div", { className: "md:hidden w-full border-b pb-4 mb-4", children: /* @__PURE__ */ n(q, { value: i, onValueChange: m, children: [
|
|
83
|
-
/* @__PURE__ */ a(I, { className: "w-full", children: /* @__PURE__ */ a(L, { placeholder: l("select.section") }) }),
|
|
84
|
-
/* @__PURE__ */ a(H, { children: s.map((e, r) => /* @__PURE__ */ a(U, { value: e.value, disabled: e.disabled, children: /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
|
|
85
|
-
e.icon && /* @__PURE__ */ a(e.icon, { className: "size-4" }),
|
|
86
|
-
/* @__PURE__ */ a("span", { children: c(e.titleKey) }),
|
|
87
|
-
e.count && /* @__PURE__ */ n("span", { className: "text-xs text-gray-500", children: [
|
|
88
|
-
"(",
|
|
89
|
-
e.count(t),
|
|
90
|
-
")"
|
|
91
|
-
] }),
|
|
92
|
-
!e.component && /* @__PURE__ */ a(v, { className: "size-4 text-amber-500" })
|
|
93
|
-
] }) }, r)) })
|
|
94
|
-
] }) }),
|
|
95
|
-
/* @__PURE__ */ a("div", { className: "flex-1 md:px-4 min-w-0 overflow-auto", children: x() })
|
|
96
|
-
] });
|
|
97
|
-
};
|
|
98
|
-
export {
|
|
99
|
-
ae as A,
|
|
100
|
-
E as a,
|
|
101
|
-
se as b,
|
|
102
|
-
re as c
|
|
103
|
-
};
|