@krosoft/react 0.0.262 → 0.0.264

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.
@@ -0,0 +1,5 @@
1
+ import { i as e, n as t, r as n, t as r } from "../datatable-COQcYUrk.js";
2
+ //#region src/constants/search.ts
3
+ var i = 300;
4
+ //#endregion
5
+ export { r as pageDefault, t as pageSizeDefault, n as pagesSizes, e as pagesSizesForCard, i as searchDebounceMs };
@@ -0,0 +1,2 @@
1
+ export declare const searchDebounceMs = 300;
2
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/constants/search.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,MAAM,CAAC"}
@@ -0,0 +1,14 @@
1
+ //#region src/constants/datatable.ts
2
+ var e = [
3
+ 5,
4
+ 10,
5
+ 30,
6
+ 50,
7
+ 100
8
+ ], t = e[1], n = 1, r = [
9
+ 6,
10
+ 9,
11
+ 12
12
+ ];
13
+ //#endregion
14
+ export { r as i, t as n, e as r, n as t };
@@ -6,6 +6,6 @@ import { t as a } from "../useLanguage-DdVIzhME.js";
6
6
  import { t as o } from "../useDocumentTitle-C5TsEDqh.js";
7
7
  import { a as s, c, d as l, f as u, i as d, l as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y } from "../behavior-C4WdfbR1.js";
8
8
  import { n as b, t as x } from "../useFixedColumns-BVZs3wbh.js";
9
- import { t as S } from "../ui-IEH46J4v.js";
9
+ import { t as S } from "../ui-CnhA3ntY.js";
10
10
  import { t as C } from "../useTheme-ZzPZl0MM.js";
11
11
  export { v as URL_DATE_FORMAT, p as parseDateRange, g as serializeDateRange, n as toast, l as useConfirmDeleteDialog, u as useConfirmationDialog, b as useDataTable, y as useDebouncedValue, h as useDialog, o as useDocumentTitle, x as useFixedColumns, a as useLanguage, r as useMobile, i as useNotifications, f as usePage, e as useScrollFade, S as useServerTable, c as useSidebar, C as useTheme, t as useToast, d as useUrlArrayState, s as useUrlDateRangeState, m as useUrlNumberState, _ as useUrlState };
@@ -5,6 +5,6 @@ import { t as i } from "../../useNotifications-CyhTruIG.js";
5
5
  import { t as a } from "../../useLanguage-DdVIzhME.js";
6
6
  import { t as o } from "../../useDocumentTitle-C5TsEDqh.js";
7
7
  import { n as s, t as c } from "../../useFixedColumns-BVZs3wbh.js";
8
- import { t as l } from "../../ui-IEH46J4v.js";
8
+ import { t as l } from "../../ui-CnhA3ntY.js";
9
9
  import { t as u } from "../../useTheme-ZzPZl0MM.js";
10
10
  export { n as toast, s as useDataTable, o as useDocumentTitle, c as useFixedColumns, a as useLanguage, r as useMobile, i as useNotifications, e as useScrollFade, l as useServerTable, u as useTheme, t as useToast };
@@ -1 +1 @@
1
- {"version":3,"file":"useServerTable.d.ts","sourceRoot":"","sources":["../../../src/hooks/ui/useServerTable.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB,CAAC,QAAQ;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,KAAK,GAAG,MAAM,CAAC;IAC9B,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,cAAc,EAAE,QAAQ,CAAC;IACzB,eAAe,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC9C;AAED,wBAAgB,cAAc,CAAC,QAAQ,EACrC,cAAc,EAAE,QAAQ,EACxB,iBAAiB,GAAE,MAAM,GAAG,IAAY,EACxC,OAAO,GAAE;IACP,oBAAoB,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,GACL,oBAAoB,CAAC,QAAQ,CAAC,CAqDhC"}
1
+ {"version":3,"file":"useServerTable.d.ts","sourceRoot":"","sources":["../../../src/hooks/ui/useServerTable.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB,CAAC,QAAQ;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,KAAK,GAAG,MAAM,CAAC;IAC9B,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,cAAc,EAAE,QAAQ,CAAC;IACzB,eAAe,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC9C;AAED,wBAAgB,cAAc,CAAC,QAAQ,EACrC,cAAc,EAAE,QAAQ,EACxB,iBAAiB,GAAE,MAAM,GAAG,IAAY,EACxC,OAAO,GAAE;IACP,oBAAoB,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,GACL,oBAAoB,CAAC,QAAQ,CAAC,CAqDhC"}
@@ -5,6 +5,7 @@ import "./useNotifications-CyhTruIG.js";
5
5
  import "./useLanguage-DdVIzhME.js";
6
6
  import "./useDocumentTitle-C5TsEDqh.js";
7
7
  import "./useFixedColumns-BVZs3wbh.js";
8
+ import "./constants/index.js";
8
9
  import "./useTheme-ZzPZl0MM.js";
9
10
  import { useCallback as e, useEffect as t, useState as n } from "react";
10
11
  //#region src/hooks/ui/useServerTable.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krosoft/react",
3
- "version": "0.0.262",
3
+ "version": "0.0.264",
4
4
  "description": "Krosoft shared React package",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -96,7 +96,7 @@
96
96
  },
97
97
  "devDependencies": {
98
98
  "@krosoft/core": "^0.0.62",
99
- "@krosoft/tooling-eslint": "^0.0.27",
99
+ "@krosoft/tooling-eslint": "^0.0.28",
100
100
  "@krosoft/tooling-eslint-react": "^0.0.29",
101
101
  "@krosoft/tooling-prettier": "^0.0.18",
102
102
  "@krosoft/tooling-tsconfig-react": "^0.0.10",
@@ -1,607 +0,0 @@
1
- import { ACTIONS_COLUMN_KEY as e, SELECTION_COLUMN_KEY as t, getAlignmentClass as n, getColumnAlignment as r, getFixedCellProps as i } from "./helpers/index.js";
2
- import { t as a } from "./i18n-CevI9Cgk.js";
3
- import { At as o, C as s, D as c, Ft as l, Gt as u, Mt as d, Nt as f, O as p, S as m, T as h, bn as g, jt as _, k as v, v as y } from "./ui-D7YSs2kF.js";
4
- import { s as b } from "./tooltip-BmZ9Bfou.js";
5
- import { i as x, l as S, n as C, t as w, u as T } from "./select-DmLScQKX.js";
6
- import { n as E, t as D } from "./useFixedColumns-BVZs3wbh.js";
7
- import { useState as O } from "react";
8
- import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
9
- import { formatJsonValue as M, isRecord as N, tryParseJson as P } from "@krosoft/core/helpers";
10
- import { AlertTriangleIcon as F, ArrowDownIcon as I, ArrowUpDownIcon as L, ArrowUpIcon as R, ChevronLeftIcon as z, ChevronRightIcon as B, GripVerticalIcon as V, Loader2Icon as H, MoreVerticalIcon as U, SettingsIcon as W } from "lucide-react";
11
- import { useNavigate as G } from "react-router-dom";
12
- //#region src/constants/datatable.ts
13
- var K = [
14
- 5,
15
- 10,
16
- 30,
17
- 50,
18
- 100
19
- ], ee = K[1];
20
- //#endregion
21
- //#region src/components/core/table/TableActions.tsx
22
- function q({ actions: e, row: t }) {
23
- let { t: n } = a(), r = e.filter((e) => e.visible === void 0 || e.visible(t));
24
- if (r.length === 0) return null;
25
- let i = r.filter((e) => e.overflow !== !0), o = r.filter((e) => e.overflow === !0);
26
- return /* @__PURE__ */ j("div", {
27
- className: "flex items-center justify-end gap-1",
28
- children: [i.map((e, r) => {
29
- let i = e.icon;
30
- return /* @__PURE__ */ j(b, {
31
- variant: e.variant ?? "ghost",
32
- size: "sm",
33
- disabled: e.disabled?.(t) ?? !1,
34
- className: `h-7 px-2 text-muted-foreground hover:text-foreground ${e.className ?? ""}`,
35
- onClick: (n) => {
36
- n.stopPropagation(), e.onClick(t);
37
- },
38
- children: [i !== void 0 && /* @__PURE__ */ A(i, { className: "size-3.5" }), n(e.labelKey)]
39
- }, r);
40
- }), o.length > 0 && /* @__PURE__ */ j(_, { children: [/* @__PURE__ */ A(u, {
41
- asChild: !0,
42
- children: /* @__PURE__ */ A(b, {
43
- variant: "ghost",
44
- size: "icon",
45
- className: "h-7 w-7 text-muted-foreground hover:text-foreground",
46
- children: /* @__PURE__ */ A(U, { className: "size-3.5" })
47
- })
48
- }), /* @__PURE__ */ A(f, {
49
- align: "end",
50
- onClick: (e) => {
51
- e.stopPropagation();
52
- },
53
- children: o.map((e, r) => {
54
- let i = e.icon;
55
- return /* @__PURE__ */ j(l, {
56
- disabled: e.disabled?.(t) ?? !1,
57
- onClick: () => {
58
- e.onClick(t);
59
- },
60
- className: e.className,
61
- children: [i !== void 0 && /* @__PURE__ */ A("span", {
62
- className: "mr-2 size-4 flex items-center justify-center",
63
- children: /* @__PURE__ */ A(i, { className: "size-4" })
64
- }), n(e.labelKey)]
65
- }, r);
66
- })
67
- })] })]
68
- });
69
- }
70
- //#endregion
71
- //#region src/components/core/table/TableBody.tsx
72
- function J({ isLoading: o, error: s, colSpanCount: c, messages: l, paginatedData: u, rowKey: d, onRowClick: f, onRowNavigate: p, hasBulkActions: m, selectedRows: h, toggleRowSelection: _, visibleColumnsArray: v, columnWidths: y, hasActions: b, actions: x, columns: S, bordered: C = !1, dense: w = !1, resizableColumns: T = !1, fixedColumns: E = {} }) {
73
- let { t: D } = a(), O = D(l?.loadingKey ?? "states.loading"), k = D(l?.emptyKey ?? "states.noResult"), M = G(), N = (e, t) => {
74
- let n = S.find((e) => e.key === t);
75
- if (n?.renderCell !== void 0) return n.renderCell(e);
76
- let r = e[t];
77
- return /* @__PURE__ */ A("span", {
78
- className: "text-sm truncate",
79
- children: r == null ? "-" : String(r)
80
- });
81
- };
82
- if (o) return /* @__PURE__ */ A("tbody", {
83
- className: "divide-y divide-border",
84
- children: /* @__PURE__ */ A("tr", { children: /* @__PURE__ */ A("td", {
85
- colSpan: c,
86
- className: "py-8 text-center",
87
- children: /* @__PURE__ */ j("div", {
88
- className: "flex flex-col items-center justify-center gap-2 text-muted-foreground",
89
- children: [/* @__PURE__ */ A(H, { className: "h-6 w-6 animate-spin text-primary" }), /* @__PURE__ */ A("span", {
90
- className: "text-sm",
91
- children: O
92
- })]
93
- })
94
- }) })
95
- });
96
- if (s) return /* @__PURE__ */ A("tbody", {
97
- className: "divide-y divide-border",
98
- children: /* @__PURE__ */ A("tr", { children: /* @__PURE__ */ A("td", {
99
- colSpan: c,
100
- className: "py-8 text-center",
101
- children: /* @__PURE__ */ j("div", {
102
- className: "flex flex-col items-center justify-center gap-2 text-destructive",
103
- children: [/* @__PURE__ */ A(F, { className: "h-6 w-6" }), /* @__PURE__ */ A("span", {
104
- className: "text-sm",
105
- children: s
106
- })]
107
- })
108
- }) })
109
- });
110
- if (u.length === 0) return /* @__PURE__ */ A("tbody", {
111
- className: "divide-y divide-border",
112
- children: /* @__PURE__ */ A("tr", { children: /* @__PURE__ */ A("td", {
113
- colSpan: c,
114
- className: "py-8 text-center text-sm text-muted-foreground",
115
- children: k
116
- }) })
117
- });
118
- let P = i(E[t], "body"), I = i(E[e], "body"), L = p !== void 0 || f !== void 0, R = (e, t) => {
119
- if (p !== void 0) {
120
- let n = p(e);
121
- t.ctrlKey || t.metaKey ? window.open(n, "_blank") : M(n);
122
- } else f?.(e, t);
123
- };
124
- return /* @__PURE__ */ A("tbody", {
125
- className: "divide-y divide-border",
126
- children: u.map((e) => {
127
- let t = d(e);
128
- return /* @__PURE__ */ j("tr", {
129
- className: `group hover:bg-muted/50 transition-colors ${L ? "cursor-pointer" : ""}`,
130
- onClick: (t) => {
131
- R(e, t);
132
- },
133
- children: [
134
- m ? /* @__PURE__ */ A("td", {
135
- className: `p-1 text-center align-middle ${P.className}`,
136
- style: {
137
- width: "48px",
138
- minWidth: "48px",
139
- maxWidth: "48px",
140
- ...P.style
141
- },
142
- onClick: (e) => {
143
- e.stopPropagation();
144
- },
145
- children: /* @__PURE__ */ A("div", {
146
- className: "flex items-center justify-center",
147
- children: /* @__PURE__ */ A(g, {
148
- checked: h.includes(t),
149
- onCheckedChange: () => {
150
- _(t);
151
- }
152
- })
153
- })
154
- }) : null,
155
- v.map((t, a) => {
156
- let o = a === v.length - 1, s = i(E[t.key], "body");
157
- return /* @__PURE__ */ A("td", {
158
- className: `${`${a === 0 && !m ? "pl-4" : "pl-2"} ${o && !b ? "pr-4" : "pr-2"}`} ${w ? "py-2" : "py-4"} text-sm ${n(r(t))} ${s.className} ${C && !o ? "border-r border-border" : ""} ${t.className ?? ""}`,
159
- style: {
160
- ...T ? { width: y[t.key] } : { minWidth: y[t.key] },
161
- ...s.style
162
- },
163
- children: /* @__PURE__ */ A("div", {
164
- className: "w-full h-full",
165
- children: N(e, t.key)
166
- })
167
- }, t.key);
168
- }),
169
- b ? /* @__PURE__ */ A("td", {
170
- className: `py-1 pl-1 pr-4 text-right align-middle whitespace-nowrap ${I.className}`,
171
- style: {
172
- minWidth: "32px",
173
- ...I.style
174
- },
175
- onClick: (e) => {
176
- e.stopPropagation();
177
- },
178
- children: x !== void 0 && x.length > 0 ? /* @__PURE__ */ A("div", {
179
- className: "flex items-center justify-end",
180
- children: /* @__PURE__ */ A(q, {
181
- actions: x,
182
- row: e
183
- })
184
- }) : null
185
- }) : null
186
- ]
187
- }, t);
188
- })
189
- });
190
- }
191
- //#endregion
192
- //#region src/components/core/table/TableBulkActions.tsx
193
- function Y({ selectedRows: e, setSelectedRows: t, bulkActions: n }) {
194
- let { t: r } = a();
195
- return /* @__PURE__ */ j("div", {
196
- className: "bg-muted/60 border border-border px-3 py-1.5 flex items-center justify-between rounded-surface",
197
- children: [/* @__PURE__ */ j("div", {
198
- className: "flex items-center gap-4",
199
- children: [/* @__PURE__ */ A("span", {
200
- className: "text-sm font-medium text-primary ml-1",
201
- children: r("table.selectedCount", { count: e.length })
202
- }), /* @__PURE__ */ A("div", {
203
- className: "flex items-center gap-2",
204
- children: n.map((n, i) => {
205
- let a = n.icon;
206
- return /* @__PURE__ */ j(b, {
207
- variant: "outline",
208
- size: "sm",
209
- onClick: () => {
210
- n.onClick(e, () => {
211
- t([]);
212
- });
213
- },
214
- className: `h-7 bg-background shadow-sm text-xs px-2.5 ${n.variant === "destructive" ? "text-destructive border-destructive/30 hover:bg-destructive/10 hover:text-destructive" : "text-foreground"}`,
215
- children: [a !== void 0 && /* @__PURE__ */ A("span", {
216
- className: "mr-1.5 flex items-center justify-center",
217
- children: /* @__PURE__ */ A(a, { className: "h-3.5 w-3.5" })
218
- }), r(n.labelKey)]
219
- }, i);
220
- })
221
- })]
222
- }), /* @__PURE__ */ A(b, {
223
- variant: "ghost",
224
- size: "sm",
225
- onClick: () => {
226
- t([]);
227
- },
228
- className: "text-xs text-muted-foreground hover:text-foreground h-7 px-2",
229
- children: r("table.clearSelection")
230
- })]
231
- });
232
- }
233
- //#endregion
234
- //#region src/components/core/table/TableHeader.tsx
235
- var X = {
236
- left: "justify-start",
237
- center: "justify-center",
238
- right: "justify-end"
239
- };
240
- function te({ hasBulkActions: o, selectedRows: s, totalItems: c, toggleSelectAll: l, visibleColumnsArray: u, draggableColumns: d, resizableColumns: f, columnWidths: p, sortColumn: m, sortDirection: h, handleSort: _, handleDragStart: v, handleDragOver: y, handleDrop: b, handleMouseDown: x, hasActions: S, settingsNode: C, bordered: w = !1, dense: T = !1, fixedColumns: E = {}, fixedSelection: D = !1, fixedActions: O = !1 }) {
241
- let { t: k } = a(), M = !1;
242
- s.length === c && c > 0 ? M = !0 : s.length > 0 && (M = "indeterminate");
243
- let N = (e) => e.sortable === !0 ? m === e.key ? A(h === "asc" ? R : I, { className: "size-3.5 text-foreground" }) : /* @__PURE__ */ A(L, { className: "size-3.5 text-muted-foreground/50 group-hover:text-muted-foreground transition-colors" }) : null, P = (e, t, a) => {
244
- let s = a !== !1 && e.fixed === void 0, c = e.sortable === !0, l = i(E[e.key], "header"), d = r(e), m = N(e), h = t === 0 && !o, g = t === u.length - 1 && !(S || C !== void 0), D = `${h ? "pl-4" : "pl-2"} ${g ? "pr-4" : "pr-2"}`;
245
- return /* @__PURE__ */ j("th", {
246
- "data-column-key": e.key,
247
- "data-fixed-side": e.fixed,
248
- className: [
249
- `${D} ${T ? "py-2" : "py-4"} text-sm font-medium text-foreground group`,
250
- n(d),
251
- l.className,
252
- w ? "border-r border-border" : "",
253
- c ? "cursor-pointer select-none" : "",
254
- e.className ?? ""
255
- ].filter(Boolean).join(" "),
256
- style: {
257
- ...f ? { width: p[e.key] } : { minWidth: p[e.key] },
258
- ...l.style
259
- },
260
- draggable: s,
261
- onClick: () => {
262
- _(e.key);
263
- },
264
- onDragStart: (t) => {
265
- s ? v(t, e.key) : t.preventDefault();
266
- },
267
- onDragOver: (t) => {
268
- y(t, e.key);
269
- },
270
- onDrop: (t) => {
271
- b(t, e.key);
272
- },
273
- children: [/* @__PURE__ */ j("div", {
274
- className: `flex items-center gap-1 ${X[d]} ${f ? "pr-2" : ""}`,
275
- children: [
276
- s ? /* @__PURE__ */ A(V, { className: "size-4 text-muted-foreground cursor-grab shrink-0" }) : null,
277
- /* @__PURE__ */ A("span", {
278
- className: "truncate",
279
- children: k(e.headerKey)
280
- }),
281
- m === null ? null : /* @__PURE__ */ A("span", {
282
- className: "ml-1 shrink-0",
283
- children: m
284
- })
285
- ]
286
- }), f ? /* @__PURE__ */ A("div", {
287
- className: "absolute right-0 top-0 bottom-0 w-2 cursor-col-resize hover:bg-blue-500 opacity-0 group-hover:opacity-50 transition-opacity",
288
- onMouseDown: (t) => {
289
- x(t, e.key);
290
- }
291
- }) : null]
292
- }, e.key);
293
- }, F = i(E[t], "header"), z = i(E[e], "header");
294
- return /* @__PURE__ */ A("thead", {
295
- className: "bg-muted/50 border-b border-border",
296
- children: /* @__PURE__ */ j("tr", { children: [
297
- o ? /* @__PURE__ */ A("th", {
298
- "data-column-key": t,
299
- "data-fixed-side": D ? "left" : void 0,
300
- className: `p-1 text-center align-middle ${F.className}`,
301
- style: {
302
- width: "48px",
303
- minWidth: "48px",
304
- maxWidth: "48px",
305
- ...F.style
306
- },
307
- children: /* @__PURE__ */ A("div", {
308
- className: "flex items-center justify-center",
309
- children: /* @__PURE__ */ A(g, {
310
- checked: M,
311
- onCheckedChange: l
312
- })
313
- })
314
- }) : null,
315
- u.map((e, t) => P(e, t, d)),
316
- S || C !== void 0 ? /* @__PURE__ */ A("th", {
317
- "data-column-key": e,
318
- "data-fixed-side": O ? "right" : void 0,
319
- className: `py-1 pl-1 pr-4 text-right align-middle ${z.className}`,
320
- style: {
321
- minWidth: "32px",
322
- ...z.style
323
- },
324
- children: C
325
- }) : null
326
- ] })
327
- });
328
- }
329
- //#endregion
330
- //#region src/components/core/table/TablePagination.tsx
331
- var Z = "…";
332
- function Q(e, t) {
333
- return Array.from({ length: t - e + 1 }, (t, n) => e + n);
334
- }
335
- function ne(e, t, n = 1) {
336
- if (n * 2 + 5 >= t) return Q(1, t);
337
- let r = Math.max(e - n, 1), i = Math.min(e + n, t), a = r > 2, o = i < t - 1;
338
- return !a && o ? [
339
- ...Q(1, n + 2),
340
- Z,
341
- t
342
- ] : a && !o ? [
343
- 1,
344
- Z,
345
- ...Q(t - (n + 2) + 1, t)
346
- ] : [
347
- 1,
348
- Z,
349
- ...Q(r, i),
350
- Z,
351
- t
352
- ];
353
- }
354
- function re({ totalItems: e, startIndex: t, endIndex: n, pageSize: r, setPageSize: i, currentPage: o, setCurrentPage: s, pageSizeOptions: c, totalPages: l }) {
355
- let { t: u } = a(), d = ne(o, l);
356
- return /* @__PURE__ */ j("div", {
357
- className: "px-4 py-2 border-t border-border flex flex-col sm:grid sm:grid-cols-3 items-center gap-2 bg-muted/50",
358
- children: [
359
- /* @__PURE__ */ A("div", {
360
- className: "text-sm text-muted-foreground justify-self-start",
361
- children: u("table.rangeOfTotal", {
362
- range: e === 0 ? "0" : `${String(t + 1)} - ${String(n)}`,
363
- total: e
364
- })
365
- }),
366
- /* @__PURE__ */ A("div", {
367
- className: "flex items-center justify-center gap-1",
368
- children: l > 1 && /* @__PURE__ */ j(k, { children: [
369
- /* @__PURE__ */ A(b, {
370
- variant: "ghost",
371
- size: "icon",
372
- className: "h-8 w-8 rounded-control",
373
- onClick: () => {
374
- s((e) => Math.max(1, e - 1));
375
- },
376
- disabled: o === 1,
377
- "aria-label": u("table.previousPage"),
378
- children: /* @__PURE__ */ A(z, { className: "size-4" })
379
- }),
380
- d.map((e, t) => e === Z ? /* @__PURE__ */ A("span", {
381
- className: "flex h-8 w-8 items-center justify-center text-sm text-muted-foreground",
382
- children: Z
383
- }, `dots-${String(t)}`) : /* @__PURE__ */ A(b, {
384
- variant: e === o ? "default" : "ghost",
385
- size: "icon",
386
- className: "h-8 w-8 rounded-control text-sm",
387
- onClick: () => {
388
- s(e);
389
- },
390
- "aria-current": e === o ? "page" : void 0,
391
- children: e
392
- }, e)),
393
- /* @__PURE__ */ A(b, {
394
- variant: "ghost",
395
- size: "icon",
396
- className: "h-8 w-8 rounded-control",
397
- onClick: () => {
398
- s((e) => Math.min(l, e + 1));
399
- },
400
- disabled: o === l,
401
- "aria-label": u("table.nextPage"),
402
- children: /* @__PURE__ */ A(B, { className: "size-4" })
403
- })
404
- ] })
405
- }),
406
- /* @__PURE__ */ A("div", {
407
- className: "justify-self-end",
408
- children: /* @__PURE__ */ j(w, {
409
- value: String(r),
410
- onValueChange: (e) => {
411
- i(Number(e)), s(1);
412
- },
413
- children: [/* @__PURE__ */ A(S, {
414
- className: "h-8 w-[110px] text-sm",
415
- children: /* @__PURE__ */ A(T, {})
416
- }), /* @__PURE__ */ A(C, { children: c.map((e) => /* @__PURE__ */ A(x, {
417
- value: String(e),
418
- children: u("table.perPage", { count: e })
419
- }, e)) })]
420
- })
421
- })
422
- ]
423
- });
424
- }
425
- //#endregion
426
- //#region src/components/core/table/TableSettings.tsx
427
- function ie({ columns: e, visibleColumns: t, toggleColumnVisibility: n }) {
428
- let { t: r } = a();
429
- return /* @__PURE__ */ j(_, { children: [/* @__PURE__ */ A(u, {
430
- asChild: !0,
431
- children: /* @__PURE__ */ A(b, {
432
- variant: "outline",
433
- size: "sm",
434
- className: "size-7 p-0 bg-background hover:bg-muted shadow-sm border-border",
435
- children: /* @__PURE__ */ A(W, { className: "size-3.5 text-muted-foreground" })
436
- })
437
- }), /* @__PURE__ */ A(f, {
438
- align: "end",
439
- className: "w-56",
440
- children: e.map((e) => /* @__PURE__ */ A(d, {
441
- checked: t.has(e.key),
442
- onCheckedChange: () => {
443
- n(e.key);
444
- },
445
- children: r(e.headerKey)
446
- }, e.key))
447
- })] });
448
- }
449
- //#endregion
450
- //#region src/components/core/table/DataTable.tsx
451
- function $({ data: e, isLoading: t = !1, error: n = null, config: r, server: i }) {
452
- let { columns: a, rowKey: o, onRowClick: s, onRowNavigate: c, actions: l, bulkActions: u } = r, d = r.pageSizeDefault ?? ee, f = r.pageSizeOptions ?? K, p = r.dense ?? !1, m = r.bordered ?? !1, h = r.draggableColumns ?? !1, g = r.resizableColumns ?? !1, _ = r.columnVisibility ?? !1, v = r.fixedActions ?? !1, { sortColumn: y, sortDirection: b, selectedRows: x, setSelectedRows: S, visibleColumns: C, columnWidths: w, safeCurrentPage: T, totalPages: O, startIndex: k, endIndex: M, tableRef: N, hasActions: P, hasBulkActions: F, visibleColumnsArray: I, colSpanCount: L, paginatedData: R, handleSort: z, handleMouseDown: B, handleDragStart: V, handleDragOver: H, handleDrop: U, toggleColumnVisibility: W, toggleRowSelection: G, toggleSelectAll: q, pageSize: X, setPageSize: Z, setCurrentPage: Q } = E({
453
- data: e,
454
- columns: a,
455
- rowKey: o,
456
- pageSizeDefault: d,
457
- actions: l,
458
- bulkActions: u,
459
- columnVisibility: _,
460
- server: i
461
- }), ne = F && I.some((e) => e.fixed === "left"), $ = D(N);
462
- return /* @__PURE__ */ j("div", {
463
- className: "space-y-4 [--k-radius-control:var(--k-radius-control-dense,0.5rem)] [--k-radius-surface:var(--k-radius-surface-dense,0.75rem)]",
464
- children: [x.length > 0 && u !== void 0 && u.length > 0 && /* @__PURE__ */ A(Y, {
465
- selectedRows: x,
466
- setSelectedRows: S,
467
- bulkActions: u
468
- }), /* @__PURE__ */ j("div", {
469
- className: "w-full bg-card rounded-surface border border-border overflow-hidden",
470
- children: [/* @__PURE__ */ A("div", {
471
- className: "overflow-x-auto",
472
- children: /* @__PURE__ */ j("table", {
473
- ref: N,
474
- className: "w-full",
475
- children: [/* @__PURE__ */ A(te, {
476
- hasBulkActions: F,
477
- selectedRows: x,
478
- totalItems: e.length,
479
- toggleSelectAll: q,
480
- visibleColumnsArray: I,
481
- draggableColumns: h,
482
- resizableColumns: g,
483
- columnWidths: w,
484
- sortColumn: y,
485
- sortDirection: b,
486
- handleSort: z,
487
- handleDragStart: V,
488
- handleDragOver: H,
489
- handleDrop: U,
490
- handleMouseDown: B,
491
- hasActions: P,
492
- bordered: m,
493
- dense: p,
494
- fixedColumns: $,
495
- fixedSelection: ne,
496
- fixedActions: v,
497
- settingsNode: _ ? /* @__PURE__ */ A(ie, {
498
- columns: a,
499
- visibleColumns: C,
500
- toggleColumnVisibility: W
501
- }) : void 0
502
- }), /* @__PURE__ */ A(J, {
503
- bordered: m,
504
- dense: p,
505
- isLoading: t,
506
- error: n,
507
- colSpanCount: L,
508
- messages: r.messages,
509
- paginatedData: R,
510
- rowKey: o,
511
- onRowClick: s,
512
- onRowNavigate: c,
513
- hasBulkActions: F,
514
- selectedRows: x,
515
- toggleRowSelection: G,
516
- visibleColumnsArray: I,
517
- columnWidths: w,
518
- hasActions: P || _,
519
- actions: l,
520
- columns: a,
521
- resizableColumns: g,
522
- fixedColumns: $
523
- })]
524
- })
525
- }), /* @__PURE__ */ A(re, {
526
- totalItems: i?.totalRows ?? e.length,
527
- startIndex: k,
528
- endIndex: M,
529
- pageSize: X,
530
- setPageSize: Z,
531
- currentPage: T,
532
- setCurrentPage: Q,
533
- pageSizeOptions: f,
534
- totalPages: O
535
- })]
536
- })]
537
- });
538
- }
539
- //#endregion
540
- //#region src/components/core/table/JsonTableOutput.tsx
541
- var ae = ({ header: e, output: t }) => {
542
- let [n, r] = O(!0), i = P(t), a = i !== null, l = () => /* @__PURE__ */ j("div", {
543
- className: "flex items-center justify-between mb-2",
544
- children: [/* @__PURE__ */ A("span", {
545
- className: "font-medium text-sm",
546
- children: e
547
- }), /* @__PURE__ */ j("div", {
548
- className: "flex items-center gap-2",
549
- children: [/* @__PURE__ */ A(y, {
550
- id: "table-mode",
551
- checked: n,
552
- onCheckedChange: r
553
- }), /* @__PURE__ */ A(o, {
554
- htmlFor: "table-mode",
555
- className: "text-xs",
556
- children: "Mode tableau"
557
- })]
558
- })]
559
- }), u = ({ children: e }) => /* @__PURE__ */ A("div", {
560
- className: "border rounded min-w-0 w-full",
561
- children: /* @__PURE__ */ A(m, { children: e })
562
- }), d = () => /* @__PURE__ */ A("pre", {
563
- className: "text-xs bg-muted p-4 rounded overflow-x-auto whitespace-pre-wrap",
564
- children: a && !n ? JSON.stringify(i, null, 2) : t
565
- });
566
- return t ? /* @__PURE__ */ j("div", {
567
- className: "min-w-0 w-full",
568
- children: [l(), (() => {
569
- if (!a || !n) return /* @__PURE__ */ A(d, {});
570
- if (Array.isArray(i) && i.length > 0 && N(i[0])) {
571
- let e = i, t = Object.keys(e[0]);
572
- return /* @__PURE__ */ j(u, { children: [/* @__PURE__ */ A(p, {
573
- className: "bg-muted/50",
574
- children: /* @__PURE__ */ A(v, { children: t.map((e) => /* @__PURE__ */ A(c, {
575
- className: "font-medium",
576
- children: e
577
- }, e)) })
578
- }), /* @__PURE__ */ A(s, { children: e.map((e, n) => /* @__PURE__ */ A(v, { children: t.map((t) => /* @__PURE__ */ A(h, {
579
- className: "text-sm whitespace-pre-wrap",
580
- children: M(e[t])
581
- }, t)) }, n)) })] });
582
- }
583
- if (N(i)) {
584
- let e = Object.entries(i);
585
- return /* @__PURE__ */ j(u, { children: [/* @__PURE__ */ A(p, {
586
- className: "bg-muted/50",
587
- children: /* @__PURE__ */ j(v, { children: [/* @__PURE__ */ A(c, {
588
- className: "font-medium",
589
- children: "Propriété"
590
- }), /* @__PURE__ */ A(c, {
591
- className: "font-medium",
592
- children: "Valeur"
593
- })] })
594
- }), /* @__PURE__ */ A(s, { children: e.map(([e, t]) => /* @__PURE__ */ j(v, { children: [/* @__PURE__ */ A(h, {
595
- className: "font-medium text-sm",
596
- children: e
597
- }), /* @__PURE__ */ A(h, {
598
- className: "text-sm whitespace-pre-wrap",
599
- children: M(t)
600
- })] }, e)) })] });
601
- }
602
- return /* @__PURE__ */ A(d, {});
603
- })()]
604
- }) : null;
605
- };
606
- //#endregion
607
- export { te as a, q as c, re as i, $ as n, Y as o, ie as r, J as s, ae as t };