@etic-insa/ui 0.8.0 → 0.9.0
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/README.md +110 -63
- package/dist/components/etic/data-table.d.ts +13 -2
- package/dist/components/etic/data-table.js +227 -213
- package/dist/components/etic/data-table.js.map +1 -1
- package/dist/components/etic/empty-value.d.ts +17 -0
- package/dist/components/etic/empty-value.js +20 -0
- package/dist/components/etic/empty-value.js.map +1 -0
- package/dist/components/etic/external-link.d.ts +5 -2
- package/dist/components/etic/external-link.js +7 -3
- package/dist/components/etic/external-link.js.map +1 -1
- package/dist/components/etic/form-field.d.ts +6 -6
- package/dist/components/etic/form-field.js +40 -38
- package/dist/components/etic/form-field.js.map +1 -1
- package/dist/components/etic/lien.d.ts +22 -0
- package/dist/components/etic/lien.js +10 -1
- package/dist/components/etic/lien.js.map +1 -1
- package/dist/components/etic/save-bar.d.ts +16 -0
- package/dist/components/etic/save-bar.js +4 -1
- package/dist/components/etic/save-bar.js.map +1 -1
- package/dist/components/etic/search-select.js +77 -76
- package/dist/components/etic/search-select.js.map +1 -1
- package/dist/components/etic/unit-input.d.ts +25 -0
- package/dist/components/etic/unit-input.js +21 -0
- package/dist/components/etic/unit-input.js.map +1 -0
- package/dist/components/etic/use-unsaved-changes-guard.d.ts +32 -0
- package/dist/components/etic/use-unsaved-changes-guard.js +25 -0
- package/dist/components/etic/use-unsaved-changes-guard.js.map +1 -0
- package/dist/hooks/use-debounced-search.d.ts +2 -1
- package/dist/hooks/use-debounced-search.js.map +1 -1
- package/dist/hooks/use-debounced-value.js +8 -7
- package/dist/hooks/use-debounced-value.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +122 -118
- package/dist/lib/delai-frappe.d.ts +3 -0
- package/dist/lib/delai-frappe.js +15 -0
- package/dist/lib/delai-frappe.js.map +1 -0
- package/dist/lib/format.d.ts +18 -0
- package/dist/lib/format.js +31 -24
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/grouper.d.ts +20 -0
- package/dist/lib/grouper.js +16 -0
- package/dist/lib/grouper.js.map +1 -0
- package/dist/testing/controles.d.ts +35 -0
- package/dist/testing/controles.js +33 -0
- package/dist/testing/controles.js.map +1 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.js +21 -17
- package/dist/testing/index.js.map +1 -1
- package/package.json +9 -1
|
@@ -7,82 +7,83 @@ import { Table as c, TableBody as l, TableCell as u, TableHead as d, TableHeader
|
|
|
7
7
|
import { Tooltip as m, TooltipContent as h, TooltipTrigger as g } from "../ui/tooltip.js";
|
|
8
8
|
import { UNITE_PAR_DEFAUT as ee } from "./data-table-format.js";
|
|
9
9
|
import { useLien as _ } from "./lien.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
10
|
+
import { MarqueExterne as v, NOUVEL_ONGLET as y } from "./external-link.js";
|
|
11
|
+
import { rendreFocusApresLigne as b } from "./data-table-focus.js";
|
|
12
|
+
import { QueryErrorBanner as x } from "./query-boundary.js";
|
|
13
|
+
import { comparerFr as S, normaliser as C, normaliserRecherche as w } from "../../lib/normalize.js";
|
|
14
|
+
import { cn as T } from "cn";
|
|
15
|
+
import { memo as E, useCallback as te, useEffect as ne, useEffectEvent as D, useId as re, useLayoutEffect as O, useRef as k, useState as A } from "react";
|
|
16
|
+
import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
|
|
17
|
+
import { ArrowDownIcon as ie, ArrowUpIcon as P, ChevronRightIcon as F, ChevronsUpDownIcon as I, MoreHorizontalIcon as ae } from "lucide-react";
|
|
18
|
+
import { columnFilteringFeature as L, columnOrderingFeature as oe, columnVisibilityFeature as R, constructFilterFn as se, constructSortFn as z, createColumnHelper as B, createFilteredRowModel as V, createPaginatedRowModel as ce, createSortedRowModel as le, filterFn_arrIncludes as ue, filterFn_arrIncludesAll as H, filterFn_arrIncludesSome as U, filterFn_equals as W, filterFn_equalsString as G, filterFn_inDateRange as K, filterFn_inNumberRange as de, filterFn_includesString as q, filterFn_weakEquals as J, functionalUpdate as fe, globalFilteringFeature as pe, metaHelper as me, rowExpandingFeature as he, rowPaginationFeature as ge, rowSelectionFeature as _e, rowSortingFeature as ve, sortFn_alphanumeric as ye, sortFn_basic as be, sortFn_datetime as xe, sortFn_text as Se, tableFeatures as Ce, useTable as we } from "@tanstack/react-table";
|
|
18
19
|
// src/components/etic/data-table.tsx
|
|
19
|
-
var
|
|
20
|
-
function
|
|
21
|
-
let { data: t, columns: n } = e.table.options, r =
|
|
22
|
-
r ||
|
|
20
|
+
var Te = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
function Ee(e) {
|
|
22
|
+
let { data: t, columns: n } = e.table.options, r = Te.get(t);
|
|
23
|
+
r || Te.set(t, r = /* @__PURE__ */ new WeakMap());
|
|
23
24
|
let i = r.get(n);
|
|
24
25
|
return i || r.set(n, i = /* @__PURE__ */ new Map()), i;
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
let n =
|
|
27
|
+
function De(e, t) {
|
|
28
|
+
let n = Ee(e), r = `${e.id}\u0000${t}`;
|
|
28
29
|
if (n.has(r)) return n.get(r);
|
|
29
|
-
let i = e.getValue(t), a = i == null ? void 0 :
|
|
30
|
+
let i = e.getValue(t), a = i == null ? void 0 : C(String(i));
|
|
30
31
|
return n.set(r, a), a;
|
|
31
32
|
}
|
|
32
|
-
var
|
|
33
|
-
filter: (e, t, n, r) => t === "" || (
|
|
34
|
-
autoRemove: (e) =>
|
|
35
|
-
resolveFilterValue: (e) =>
|
|
36
|
-
}),
|
|
33
|
+
var Oe = se({
|
|
34
|
+
filter: (e, t, n, r) => t === "" || (De(n, r)?.includes(t) ?? !1),
|
|
35
|
+
autoRemove: (e) => w(String(e ?? "")) === "",
|
|
36
|
+
resolveFilterValue: (e) => w(String(e ?? ""))
|
|
37
|
+
}), ke = z({
|
|
37
38
|
resolveDataValue: (e) => e == null ? "" : String(e),
|
|
38
|
-
sort:
|
|
39
|
-
}),
|
|
40
|
-
columnFilteringFeature:
|
|
41
|
-
columnOrderingFeature:
|
|
42
|
-
columnVisibilityFeature:
|
|
43
|
-
globalFilteringFeature:
|
|
44
|
-
rowExpandingFeature:
|
|
45
|
-
rowPaginationFeature:
|
|
46
|
-
rowSelectionFeature:
|
|
47
|
-
rowSortingFeature:
|
|
48
|
-
filteredRowModel:
|
|
49
|
-
paginatedRowModel:
|
|
50
|
-
sortedRowModel:
|
|
39
|
+
sort: S
|
|
40
|
+
}), Ae = Ce({
|
|
41
|
+
columnFilteringFeature: L,
|
|
42
|
+
columnOrderingFeature: oe,
|
|
43
|
+
columnVisibilityFeature: R,
|
|
44
|
+
globalFilteringFeature: pe,
|
|
45
|
+
rowExpandingFeature: he,
|
|
46
|
+
rowPaginationFeature: ge,
|
|
47
|
+
rowSelectionFeature: _e,
|
|
48
|
+
rowSortingFeature: ve,
|
|
49
|
+
filteredRowModel: V(),
|
|
50
|
+
paginatedRowModel: ce(),
|
|
51
|
+
sortedRowModel: le(),
|
|
51
52
|
filterFns: {
|
|
52
|
-
arrIncludes:
|
|
53
|
-
arrIncludesAll:
|
|
54
|
-
arrIncludesSome:
|
|
55
|
-
equals:
|
|
56
|
-
equalsString:
|
|
57
|
-
inDateRange:
|
|
58
|
-
inNumberRange:
|
|
59
|
-
includesString:
|
|
60
|
-
texteFr:
|
|
61
|
-
weakEquals:
|
|
53
|
+
arrIncludes: ue,
|
|
54
|
+
arrIncludesAll: H,
|
|
55
|
+
arrIncludesSome: U,
|
|
56
|
+
equals: W,
|
|
57
|
+
equalsString: G,
|
|
58
|
+
inDateRange: K,
|
|
59
|
+
inNumberRange: de,
|
|
60
|
+
includesString: q,
|
|
61
|
+
texteFr: Oe,
|
|
62
|
+
weakEquals: J
|
|
62
63
|
},
|
|
63
64
|
sortFns: {
|
|
64
|
-
alphanumeric:
|
|
65
|
-
basic:
|
|
66
|
-
datetime:
|
|
67
|
-
text:
|
|
68
|
-
texteFr:
|
|
65
|
+
alphanumeric: ye,
|
|
66
|
+
basic: be,
|
|
67
|
+
datetime: xe,
|
|
68
|
+
text: Se,
|
|
69
|
+
texteFr: ke
|
|
69
70
|
},
|
|
70
|
-
columnMeta:
|
|
71
|
-
tableMeta:
|
|
71
|
+
columnMeta: me(),
|
|
72
|
+
tableMeta: me()
|
|
72
73
|
});
|
|
73
|
-
function
|
|
74
|
-
return
|
|
74
|
+
function Y() {
|
|
75
|
+
return B();
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
+
function je(e) {
|
|
77
78
|
let { meta: t, header: n } = e.columnDef;
|
|
78
79
|
return t?.libelle ? t.libelle : typeof n == "string" ? n : e.id;
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
+
function X(e) {
|
|
81
82
|
let t = e.options.meta;
|
|
82
83
|
if (!t) throw Error("DataTable : instance sans `meta`. Créez-la avec `useDataTable`.");
|
|
83
84
|
return t;
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function Me(e) {
|
|
86
87
|
let { pageIndex: t, pageSize: n } = e.state.pagination;
|
|
87
88
|
return {
|
|
88
89
|
manuelle: !!e.options.manualPagination,
|
|
@@ -92,36 +93,36 @@ function ke(e) {
|
|
|
92
93
|
nombre: e.getRowModel().rows.length
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
+
function Ne(n, r, i) {
|
|
96
97
|
return `Les ${e(n)} ${r.pluriel} sont ${t("sélectionné", 2, i)}.`;
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
-
let [r, i] =
|
|
99
|
+
function Z(e, t, n) {
|
|
100
|
+
let [r, i] = A(n), a = e === void 0 ? r : e;
|
|
100
101
|
return [a, (n) => {
|
|
101
102
|
Object.is(n, a) || (e === void 0 && i(n), t?.(n));
|
|
102
103
|
}];
|
|
103
104
|
}
|
|
104
|
-
var
|
|
105
|
-
function
|
|
105
|
+
var Pe = 25;
|
|
106
|
+
function Q(e, t) {
|
|
106
107
|
let n = Object.entries(e).filter(([e]) => t(e));
|
|
107
108
|
return n.length === Object.keys(e).length ? e : Object.fromEntries(n);
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
-
let [
|
|
110
|
+
function Fe({ donnees: e, colonnes: t, idLigne: n, tri: r, onTriChange: i, triManuel: a, paginationClient: o = !1, pagination: s, onPaginationChange: c, filtresColonnes: l, onFiltresColonnesChange: u, filtreGlobal: d, onFiltreGlobalChange: f, visibiliteColonnes: p, onVisibiliteColonnesChange: m, ordreColonnes: h, onOrdreColonnesChange: g, colonnesReglables: ee, selection: _, onSelectionChange: v, ligneSelectionnable: y, conserverSelection: b = !1, total: x, toutSelectionne: S, onToutSelectionneChange: C, lignesDepliees: w, onLignesDeplieesChange: T, ligneDepliable: E, uneSeuleLigneDepliee: te = !1, etatInitial: A }) {
|
|
111
|
+
let [j, M] = Z(S, C, !1), N = k(null), ie = re(), P = {}, F = {};
|
|
111
112
|
r !== void 0 && (P.sorting = r), i && (F.onSortingChange = i), p !== void 0 && (P.columnVisibility = p), m && (F.onColumnVisibilityChange = m), h !== void 0 && (P.columnOrder = h), g && (F.onColumnOrderChange = g), s !== void 0 && (P.pagination = s), c && (F.onPaginationChange = c), l !== void 0 && (P.columnFilters = l), u && (F.onColumnFiltersChange = u), d !== void 0 && (P.globalFilter = d), f && (F.onGlobalFilterChange = f);
|
|
112
|
-
let [I, ae] =
|
|
113
|
-
P.rowSelection = I, F.onRowSelectionChange = (e) => ae(
|
|
114
|
-
let [L, oe] =
|
|
113
|
+
let [I, ae] = Z(_, v, {});
|
|
114
|
+
P.rowSelection = I, F.onRowSelectionChange = (e) => ae(fe(e, I));
|
|
115
|
+
let [L, oe] = Z(w, T, A?.lignesDepliees ?? {});
|
|
115
116
|
P.expanded = L, F.onExpandedChange = (e) => {
|
|
116
|
-
let t =
|
|
117
|
-
if (
|
|
117
|
+
let t = fe(e, L), n = t === !0 ? Object.fromEntries(R.getCoreRowModel().rows.filter((e) => e.getCanExpand()).map((e) => [e.id, !0])) : t;
|
|
118
|
+
if (te) {
|
|
118
119
|
let e = Object.keys(n).filter((e) => n[e] && !L[e]).at(-1);
|
|
119
120
|
e && (n = { [e]: !0 });
|
|
120
121
|
}
|
|
121
122
|
oe(n);
|
|
122
123
|
};
|
|
123
|
-
let R =
|
|
124
|
-
features:
|
|
124
|
+
let R = we({
|
|
125
|
+
features: Ae,
|
|
125
126
|
data: e,
|
|
126
127
|
columns: t,
|
|
127
128
|
getRowId: n,
|
|
@@ -131,73 +132,73 @@ function Me({ donnees: e, colonnes: t, idLigne: n, tri: r, onTriChange: i, triMa
|
|
|
131
132
|
globalFilterFn: "texteFr",
|
|
132
133
|
enableMultiSort: !1,
|
|
133
134
|
enableRowSelection: y ? (e) => y(e.original) : !0,
|
|
134
|
-
getRowCanExpand:
|
|
135
|
+
getRowCanExpand: E ? (e) => E(e.original) : () => !0,
|
|
135
136
|
autoResetExpanded: !1,
|
|
136
137
|
initialState: {
|
|
137
|
-
sorting:
|
|
138
|
-
columnVisibility:
|
|
139
|
-
columnOrder:
|
|
138
|
+
sorting: A?.tri ?? [],
|
|
139
|
+
columnVisibility: A?.visibiliteColonnes ?? {},
|
|
140
|
+
columnOrder: A?.ordreColonnes ?? [],
|
|
140
141
|
pagination: {
|
|
141
142
|
pageIndex: 0,
|
|
142
|
-
pageSize:
|
|
143
|
-
...
|
|
143
|
+
pageSize: Pe,
|
|
144
|
+
...A?.pagination
|
|
144
145
|
},
|
|
145
|
-
columnFilters:
|
|
146
|
-
globalFilter:
|
|
146
|
+
columnFilters: A?.filtresColonnes ?? [],
|
|
147
|
+
globalFilter: A?.filtreGlobal ?? ""
|
|
147
148
|
},
|
|
148
149
|
state: P,
|
|
149
150
|
...F,
|
|
150
151
|
meta: {
|
|
151
152
|
total: x,
|
|
152
153
|
get toutSelectionne() {
|
|
153
|
-
return
|
|
154
|
+
return j && B;
|
|
154
155
|
},
|
|
155
156
|
get totalAProposer() {
|
|
156
|
-
if (x !== void 0 && !
|
|
157
|
+
if (x !== void 0 && !j && B) return x > R.getSelectedRowIds().length ? x : void 0;
|
|
157
158
|
},
|
|
158
159
|
changerToutSelectionne: (e) => {
|
|
159
|
-
e && R.toggleAllPageRowsSelected(!0),
|
|
160
|
+
e && R.toggleAllPageRowsSelected(!0), M(e);
|
|
160
161
|
},
|
|
161
162
|
toutDeselectionner: () => {
|
|
162
|
-
R.resetRowSelection(!0),
|
|
163
|
+
R.resetRowSelection(!0), M(!1);
|
|
163
164
|
},
|
|
164
165
|
deselectionner: (e) => {
|
|
165
166
|
let t = new Set(e);
|
|
166
|
-
R.setRowSelection((e) =>
|
|
167
|
+
R.setRowSelection((e) => Q(e, (e) => !t.has(e))), M(!1);
|
|
167
168
|
},
|
|
168
|
-
racine:
|
|
169
|
+
racine: N,
|
|
169
170
|
idDetail: (e) => `${ie}detail-${encodeURIComponent(e)}`,
|
|
170
171
|
colonnesReglables: ee
|
|
171
172
|
}
|
|
172
|
-
}), se = R.getCoreRowModel().rows, z = R.getRowModel().rows, B = R.getIsAllPageRowsSelected(), V =
|
|
173
|
+
}), se = R.getCoreRowModel().rows, z = R.getRowModel().rows, B = R.getIsAllPageRowsSelected(), V = k(null), ce = D(() => M(!1));
|
|
173
174
|
ne(() => {
|
|
174
175
|
let e = z.map((e) => e.id).sort().join("\0"), t = V.current !== null && V.current !== e;
|
|
175
|
-
V.current = e,
|
|
176
|
+
V.current = e, j && (t || !B) && ce();
|
|
176
177
|
}, [
|
|
177
178
|
z,
|
|
178
179
|
B,
|
|
179
|
-
|
|
180
|
+
j
|
|
180
181
|
]);
|
|
181
|
-
let le =
|
|
182
|
+
let le = D(() => {
|
|
182
183
|
if (b || Object.keys(I).length === 0) return;
|
|
183
184
|
let e = new Set(z.map((e) => e.id));
|
|
184
|
-
R.setRowSelection((t) =>
|
|
185
|
+
R.setRowSelection((t) => Q(t, (t) => e.has(t)));
|
|
185
186
|
});
|
|
186
|
-
|
|
187
|
+
O(() => {
|
|
187
188
|
le();
|
|
188
189
|
}, [z]);
|
|
189
|
-
let ue =
|
|
190
|
+
let ue = D(() => {
|
|
190
191
|
if (Object.keys(L).length === 0) return;
|
|
191
192
|
let { rowsById: e } = R.getCoreRowModel();
|
|
192
|
-
R.setExpanded((t) => t === !0 ? t :
|
|
193
|
+
R.setExpanded((t) => t === !0 ? t : Q(t, (t) => t in e));
|
|
193
194
|
});
|
|
194
|
-
|
|
195
|
+
O(() => {
|
|
195
196
|
ue();
|
|
196
197
|
}, [se]);
|
|
197
|
-
let { columnFilters: H, globalFilter: U, sorting: W, pagination: G } = R.state, K =
|
|
198
|
+
let { columnFilters: H, globalFilter: U, sorting: W, pagination: G } = R.state, K = k(null), de = D(() => {
|
|
198
199
|
o && R.state.pagination.pageIndex !== 0 && R.setPageIndex(0);
|
|
199
200
|
});
|
|
200
|
-
|
|
201
|
+
O(() => {
|
|
201
202
|
let e = JSON.stringify([
|
|
202
203
|
H,
|
|
203
204
|
U,
|
|
@@ -209,17 +210,17 @@ function Me({ donnees: e, colonnes: t, idLigne: n, tri: r, onTriChange: i, triMa
|
|
|
209
210
|
U,
|
|
210
211
|
W
|
|
211
212
|
]);
|
|
212
|
-
let
|
|
213
|
-
return
|
|
214
|
-
o &&
|
|
213
|
+
let q = R.getPageCount(), J = R.getRowCount(), pe = D(() => R.setPageIndex(Math.max(0, q - 1)));
|
|
214
|
+
return O(() => {
|
|
215
|
+
o && J > 0 && G.pageIndex > 0 && G.pageIndex >= q && pe();
|
|
215
216
|
}, [
|
|
216
217
|
o,
|
|
217
|
-
|
|
218
|
+
J,
|
|
218
219
|
G.pageIndex,
|
|
219
|
-
|
|
220
|
+
q
|
|
220
221
|
]), R;
|
|
221
222
|
}
|
|
222
|
-
var
|
|
223
|
+
var Ie = [
|
|
223
224
|
"a[href]",
|
|
224
225
|
"button",
|
|
225
226
|
"input",
|
|
@@ -248,48 +249,48 @@ var Ne = [
|
|
|
248
249
|
"menuitemradio"
|
|
249
250
|
].map((e) => `[role=${e}]`)
|
|
250
251
|
].join(", ");
|
|
251
|
-
function
|
|
252
|
+
function Le(e) {
|
|
252
253
|
let t = e.currentTarget, n = e.target;
|
|
253
254
|
if (!t.contains(n)) return !1;
|
|
254
|
-
let r = n.closest(
|
|
255
|
+
let r = n.closest(Ie);
|
|
255
256
|
return r && r !== t && t.contains(r) ? !1 : !window.getSelection()?.toString();
|
|
256
257
|
}
|
|
257
|
-
function
|
|
258
|
-
let v = n?.isError ?? !1 ? null : a,
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
function Re({ table: e, libelle: t, requete: n, enChargement: r = n?.isFetching ?? !1, lignesChargement: i = 10, vide: a = "Aucun résultat.", onActiverLigne: o, rendreDetail: m, unite: h = ee, feminin: g = !1, className: _ }) {
|
|
259
|
+
let v = n?.isError ?? !1 ? null : a, y = e.getRowModel().rows, b = e.getVisibleLeafColumns(), S = b.map((e) => e.id).join(" "), { racine: C } = X(e), w = k(null);
|
|
260
|
+
O(() => {
|
|
261
|
+
w.current = o ? (e) => o(e.original) : m ? (e) => e.toggleExpanded() : null;
|
|
261
262
|
});
|
|
262
|
-
let E = te((e) =>
|
|
263
|
+
let E = te((e) => w.current?.(e), []);
|
|
263
264
|
ne(() => {
|
|
264
|
-
let e =
|
|
265
|
+
let e = C.current, t = e?.querySelector("[data-slot=\"table-container\"]");
|
|
265
266
|
if (!e || !t || typeof ResizeObserver > "u") return;
|
|
266
267
|
let n = new ResizeObserver(() => e.style.setProperty("--data-table-largeur", `${t.clientWidth}px`));
|
|
267
268
|
return n.observe(t), () => n.disconnect();
|
|
268
|
-
}, [
|
|
269
|
-
let
|
|
269
|
+
}, [C]), ze(C, y.length > 0, S);
|
|
270
|
+
let D = Be(e, r && y.length === 0, {
|
|
270
271
|
unite: h,
|
|
271
272
|
feminin: g
|
|
272
273
|
});
|
|
273
|
-
return /* @__PURE__ */
|
|
274
|
-
ref:
|
|
274
|
+
return /* @__PURE__ */ N(j, { children: [n ? /* @__PURE__ */ M(x, { requete: n }) : null, /* @__PURE__ */ N("div", {
|
|
275
|
+
ref: C,
|
|
275
276
|
"data-slot": "data-table",
|
|
276
|
-
className:
|
|
277
|
-
children: [/* @__PURE__ */
|
|
277
|
+
className: T("min-w-0 overflow-hidden rounded-md border bg-tableau", _),
|
|
278
|
+
children: [/* @__PURE__ */ M("p", {
|
|
278
279
|
className: "sr-only",
|
|
279
280
|
"aria-live": "polite",
|
|
280
281
|
"aria-atomic": "true",
|
|
281
|
-
children:
|
|
282
|
-
}), /* @__PURE__ */
|
|
282
|
+
children: D
|
|
283
|
+
}), /* @__PURE__ */ N(c, {
|
|
283
284
|
"aria-label": t,
|
|
284
285
|
"aria-busy": r || void 0,
|
|
285
|
-
children: [/* @__PURE__ */
|
|
286
|
+
children: [/* @__PURE__ */ M(f, { children: e.getHeaderGroups().map((t) => /* @__PURE__ */ M(p, { children: t.headers.map((t) => /* @__PURE__ */ M(d, {
|
|
286
287
|
colSpan: t.colSpan,
|
|
287
|
-
"aria-sort":
|
|
288
|
+
"aria-sort": Ke(t.column),
|
|
288
289
|
className: t.column.columnDef.meta?.className,
|
|
289
|
-
children: t.isPlaceholder ? null : /* @__PURE__ */
|
|
290
|
-
}, t.id)) }, t.id)) }), /* @__PURE__ */
|
|
291
|
-
className:
|
|
292
|
-
children:
|
|
290
|
+
children: t.isPlaceholder ? null : /* @__PURE__ */ M(e.FlexRender, { header: t })
|
|
291
|
+
}, t.id)) }, t.id)) }), /* @__PURE__ */ M(l, {
|
|
292
|
+
className: T(r && y.length > 0 && "opacity-60 transition-opacity"),
|
|
293
|
+
children: y.length ? y.map((t) => /* @__PURE__ */ M(Ge, {
|
|
293
294
|
row: t,
|
|
294
295
|
selectionnee: t.getIsSelected(),
|
|
295
296
|
selectionnable: t.getCanSelect(),
|
|
@@ -300,16 +301,16 @@ function Fe({ table: e, libelle: t, requete: n, enChargement: r = n?.isFetching
|
|
|
300
301
|
cliquable: o !== void 0 || m !== void 0 && t.getCanExpand(),
|
|
301
302
|
activer: E,
|
|
302
303
|
rendreDetail: m
|
|
303
|
-
}, t.id)) : r ? Array.from({ length: i }, (e, t) => /* @__PURE__ */
|
|
304
|
+
}, t.id)) : r ? Array.from({ length: i }, (e, t) => /* @__PURE__ */ M(p, {
|
|
304
305
|
"data-slot": "data-table-skeleton",
|
|
305
306
|
"aria-hidden": !0,
|
|
306
|
-
children:
|
|
307
|
-
}, t)) : /* @__PURE__ */
|
|
307
|
+
children: b.map((e) => /* @__PURE__ */ M(u, { children: /* @__PURE__ */ M(s, { className: "h-4 w-full max-w-32" }) }, e.id))
|
|
308
|
+
}, t)) : /* @__PURE__ */ M(p, {
|
|
308
309
|
className: "hover:bg-transparent",
|
|
309
|
-
children: /* @__PURE__ */
|
|
310
|
-
colSpan:
|
|
310
|
+
children: /* @__PURE__ */ M(u, {
|
|
311
|
+
colSpan: b.length || 1,
|
|
311
312
|
className: "h-24 p-0 text-center whitespace-normal text-muted-foreground",
|
|
312
|
-
children: /* @__PURE__ */
|
|
313
|
+
children: /* @__PURE__ */ M("div", {
|
|
313
314
|
className: "sticky left-0 w-[var(--data-table-largeur,100%)] p-2",
|
|
314
315
|
children: v
|
|
315
316
|
})
|
|
@@ -319,16 +320,16 @@ function Fe({ table: e, libelle: t, requete: n, enChargement: r = n?.isFetching
|
|
|
319
320
|
})]
|
|
320
321
|
})] });
|
|
321
322
|
}
|
|
322
|
-
function
|
|
323
|
-
let r =
|
|
324
|
-
|
|
323
|
+
function ze(e, t, n) {
|
|
324
|
+
let r = k(/* @__PURE__ */ new WeakMap()), i = k(t), a = k(!1), o = () => e.current?.querySelectorAll("[data-slot=\"table-header\"] [data-slot=\"table-head\"]") ?? [];
|
|
325
|
+
O(() => {
|
|
325
326
|
if (typeof ResizeObserver > "u") return;
|
|
326
327
|
let e = new ResizeObserver((e) => {
|
|
327
328
|
if (i.current) for (let { target: t, borderBoxSize: n, contentRect: i } of e) r.current.set(t, n?.[0]?.inlineSize ?? i.width);
|
|
328
329
|
});
|
|
329
330
|
for (let t of o()) e.observe(t);
|
|
330
331
|
return () => e.disconnect();
|
|
331
|
-
}, [e, n]),
|
|
332
|
+
}, [e, n]), O(() => {
|
|
332
333
|
if (i.current = t, a.current) {
|
|
333
334
|
for (let e of o()) e.style.removeProperty("width");
|
|
334
335
|
a.current = !1;
|
|
@@ -339,122 +340,122 @@ function Ie(e, t, n) {
|
|
|
339
340
|
}
|
|
340
341
|
}, [t, n]);
|
|
341
342
|
}
|
|
342
|
-
function
|
|
343
|
-
let [i] = e.state.sorting ?? [], a = i ? e.getColumn(i.id) : void 0, o = a ? `Trié par ${
|
|
343
|
+
function Be(e, t, { unite: n, feminin: r }) {
|
|
344
|
+
let [i] = e.state.sorting ?? [], a = i ? e.getColumn(i.id) : void 0, o = a ? `Trié par ${je(a)}, ordre ${i.desc ? "décroissant" : "croissant"}.` : "", [s, c] = A(o), [l, u] = A("");
|
|
344
345
|
o !== s && (c(o), u(o));
|
|
345
|
-
let d =
|
|
346
|
-
return t ? "Chargement…" : d.toutSelectionne && d.total !== void 0 ?
|
|
346
|
+
let d = X(e);
|
|
347
|
+
return t ? "Chargement…" : d.toutSelectionne && d.total !== void 0 ? Ne(d.total, n, r) : l;
|
|
347
348
|
}
|
|
348
|
-
function
|
|
349
|
-
|
|
349
|
+
function Ve(e, t) {
|
|
350
|
+
O(() => () => {
|
|
350
351
|
let n = e.current;
|
|
351
|
-
n && t.current.actif &&
|
|
352
|
+
n && t.current.actif && b(n, t.current.rang);
|
|
352
353
|
}, [e, t]);
|
|
353
354
|
}
|
|
354
|
-
function
|
|
355
|
+
function He(e, t, n = !0) {
|
|
355
356
|
if (t.actif = !0, !n) return;
|
|
356
357
|
let r = e.target.closest("td, th");
|
|
357
358
|
r instanceof HTMLTableCellElement && e.currentTarget.contains(r) && (t.rang = r.cellIndex);
|
|
358
359
|
}
|
|
359
|
-
function
|
|
360
|
+
function Ue(e) {
|
|
360
361
|
e.actif = !1;
|
|
361
362
|
}
|
|
362
|
-
function
|
|
363
|
-
let o = e.table, s =
|
|
363
|
+
function We({ row: e, selectionnee: t, depliee: n, cliquable: r, activer: i, rendreDetail: a }) {
|
|
364
|
+
let o = e.table, s = k(null), c = k({
|
|
364
365
|
actif: !1,
|
|
365
366
|
rang: -1
|
|
366
367
|
});
|
|
367
|
-
|
|
368
|
+
Ve(s, c);
|
|
368
369
|
let l = e.getVisibleCells();
|
|
369
|
-
return /* @__PURE__ */
|
|
370
|
+
return /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(p, {
|
|
370
371
|
ref: s,
|
|
371
|
-
onFocus: (e) =>
|
|
372
|
-
onBlur: () =>
|
|
372
|
+
onFocus: (e) => He(e, c.current),
|
|
373
|
+
onBlur: () => Ue(c.current),
|
|
373
374
|
"data-state": t ? "selected" : void 0,
|
|
374
|
-
className:
|
|
375
|
+
className: T("group/ligne", r && "cursor-pointer", n && a && "border-b-0 bg-muted/50"),
|
|
375
376
|
onClick: r ? (t) => {
|
|
376
|
-
|
|
377
|
+
Le(t) && i(e);
|
|
377
378
|
} : void 0,
|
|
378
|
-
children: l.map((e) => /* @__PURE__ */
|
|
379
|
+
children: l.map((e) => /* @__PURE__ */ M(u, {
|
|
379
380
|
className: e.column.columnDef.meta?.className,
|
|
380
|
-
children: /* @__PURE__ */
|
|
381
|
+
children: /* @__PURE__ */ M(o.FlexRender, { cell: e })
|
|
381
382
|
}, e.id))
|
|
382
|
-
}), n && a ? /* @__PURE__ */
|
|
383
|
+
}), n && a ? /* @__PURE__ */ M(p, {
|
|
383
384
|
"data-slot": "data-table-detail",
|
|
384
385
|
className: t ? "bg-muted hover:bg-muted" : "bg-muted/50 hover:bg-muted/50",
|
|
385
|
-
onFocus: (e) =>
|
|
386
|
-
onBlur: () =>
|
|
387
|
-
children: /* @__PURE__ */
|
|
388
|
-
id:
|
|
386
|
+
onFocus: (e) => He(e, c.current, !1),
|
|
387
|
+
onBlur: () => Ue(c.current),
|
|
388
|
+
children: /* @__PURE__ */ M(u, {
|
|
389
|
+
id: X(o).idDetail(e.id),
|
|
389
390
|
colSpan: l.length,
|
|
390
391
|
className: "p-0 whitespace-normal",
|
|
391
|
-
children: /* @__PURE__ */
|
|
392
|
+
children: /* @__PURE__ */ M("div", {
|
|
392
393
|
className: "sticky left-0 w-[var(--data-table-largeur,100%)] p-3",
|
|
393
394
|
children: a(e.original)
|
|
394
395
|
})
|
|
395
396
|
})
|
|
396
397
|
}) : null] });
|
|
397
398
|
}
|
|
398
|
-
var
|
|
399
|
-
function
|
|
399
|
+
var Ge = E(We, (e, t) => e.row === t.row && e.selectionnee === t.selectionnee && e.selectionnable === t.selectionnable && e.depliee === t.depliee && e.depliable === t.depliable && e.cleColonnes === t.cleColonnes && e.colonnes === t.colonnes && e.cliquable === t.cliquable && e.activer === t.activer && (!t.depliee || e.rendreDetail === t.rendreDetail));
|
|
400
|
+
function Ke(e) {
|
|
400
401
|
let t = e.getIsSorted();
|
|
401
402
|
if (t === "asc") return "ascending";
|
|
402
403
|
if (t === "desc") return "descending";
|
|
403
404
|
}
|
|
404
|
-
function
|
|
405
|
-
if (!e.getCanSort()) return /* @__PURE__ */
|
|
405
|
+
function qe({ column: e, libelle: t, className: r }) {
|
|
406
|
+
if (!e.getCanSort()) return /* @__PURE__ */ M("div", {
|
|
406
407
|
className: r,
|
|
407
408
|
children: t
|
|
408
409
|
});
|
|
409
|
-
let i = e.getIsSorted(), a = i === "desc" ?
|
|
410
|
-
return /* @__PURE__ */
|
|
411
|
-
className:
|
|
412
|
-
children: /* @__PURE__ */
|
|
410
|
+
let i = e.getIsSorted(), a = i === "desc" ? ie : i === "asc" ? P : I;
|
|
411
|
+
return /* @__PURE__ */ M("div", {
|
|
412
|
+
className: T("flex items-center gap-2", r),
|
|
413
|
+
children: /* @__PURE__ */ N(n, {
|
|
413
414
|
variant: "ghost",
|
|
414
415
|
size: "sm",
|
|
415
416
|
className: "-ml-2.5 h-8 text-sm",
|
|
416
417
|
onClick: () => e.toggleSorting(i === "asc"),
|
|
417
|
-
children: [/* @__PURE__ */
|
|
418
|
+
children: [/* @__PURE__ */ M("span", { children: t }), /* @__PURE__ */ M(a, {
|
|
418
419
|
"data-icon": "inline-end",
|
|
419
|
-
className:
|
|
420
|
+
className: T(!i && "text-muted-foreground")
|
|
420
421
|
})]
|
|
421
422
|
})
|
|
422
423
|
});
|
|
423
424
|
}
|
|
424
|
-
function
|
|
425
|
-
return
|
|
425
|
+
function Je({ libelleLigne: e, libelleTout: t = "Sélectionner la page", verrouLigne: n } = {}) {
|
|
426
|
+
return Y().display({
|
|
426
427
|
id: "select",
|
|
427
428
|
header: ({ table: e }) => {
|
|
428
429
|
let n = e.getRowModel().rows.filter((e) => e.getCanSelect()), i = e.getIsAllPageRowsSelected();
|
|
429
|
-
return /* @__PURE__ */
|
|
430
|
+
return /* @__PURE__ */ M(r, {
|
|
430
431
|
checked: i,
|
|
431
432
|
indeterminate: e.getIsSomePageRowsSelected() && !i,
|
|
432
433
|
disabled: n.length === 0,
|
|
433
434
|
onCheckedChange: (t) => e.toggleAllPageRowsSelected(t),
|
|
434
435
|
"aria-label": t,
|
|
435
|
-
className:
|
|
436
|
+
className: Ye
|
|
436
437
|
});
|
|
437
438
|
},
|
|
438
|
-
cell: ({ row: t }) => /* @__PURE__ */
|
|
439
|
+
cell: ({ row: t }) => /* @__PURE__ */ M(Qe, {
|
|
439
440
|
row: t,
|
|
440
441
|
libelle: e?.(t.original) ?? "Sélectionner la ligne",
|
|
441
442
|
verrou: t.getCanSelect() ? void 0 : n?.(t.original)
|
|
442
443
|
}),
|
|
443
444
|
enableSorting: !1,
|
|
444
445
|
enableHiding: !1,
|
|
445
|
-
meta: { className:
|
|
446
|
+
meta: { className: Xe }
|
|
446
447
|
});
|
|
447
448
|
}
|
|
448
|
-
var
|
|
449
|
-
function
|
|
450
|
-
let i =
|
|
449
|
+
var Ye = "after:-inset-3", Xe = "w-10 px-3 [&:has([role=checkbox])]:pr-3", Ze = "aria-disabled:cursor-not-allowed aria-disabled:opacity-100 aria-disabled:not-data-checked:bg-muted aria-disabled:data-checked:border-muted-foreground aria-disabled:data-checked:bg-muted-foreground aria-disabled:data-checked:text-background";
|
|
450
|
+
function Qe({ row: e, libelle: t, verrou: n }) {
|
|
451
|
+
let i = re(), a = e.getToggleSelectedHandler(), o = e.getCanSelect(), s = /* @__PURE__ */ M(r, {
|
|
451
452
|
checked: e.getIsSelected(),
|
|
452
453
|
disabled: !o && !n,
|
|
453
454
|
readOnly: !o,
|
|
454
455
|
"aria-disabled": !o || void 0,
|
|
455
456
|
"aria-describedby": n ? i : void 0,
|
|
456
457
|
"aria-label": t,
|
|
457
|
-
className:
|
|
458
|
+
className: T(Ye, Ze),
|
|
458
459
|
onCheckedChange: (e, t) => a({
|
|
459
460
|
target: { checked: e },
|
|
460
461
|
shiftKey: t.event.shiftKey
|
|
@@ -463,33 +464,33 @@ function Ye({ row: e, libelle: t, verrou: n }) {
|
|
|
463
464
|
e.shiftKey && e.preventDefault();
|
|
464
465
|
}
|
|
465
466
|
});
|
|
466
|
-
return n ? /* @__PURE__ */
|
|
467
|
+
return n ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ N(m, { children: [/* @__PURE__ */ M(g, { render: s }), /* @__PURE__ */ M(h, { children: n })] }), /* @__PURE__ */ M("span", {
|
|
467
468
|
id: i,
|
|
468
469
|
hidden: !0,
|
|
469
470
|
children: n
|
|
470
471
|
})] }) : s;
|
|
471
472
|
}
|
|
472
|
-
function
|
|
473
|
-
return
|
|
473
|
+
function $e({ libelleLigne: e, libelle: t = "Détail" } = {}) {
|
|
474
|
+
return Y().display({
|
|
474
475
|
id: "expand",
|
|
475
|
-
header: () => /* @__PURE__ */
|
|
476
|
+
header: () => /* @__PURE__ */ M("span", {
|
|
476
477
|
className: "sr-only",
|
|
477
478
|
children: t
|
|
478
479
|
}),
|
|
479
|
-
cell: ({ row: t, table: n }) => t.getCanExpand() ? /* @__PURE__ */
|
|
480
|
+
cell: ({ row: t, table: n }) => t.getCanExpand() ? /* @__PURE__ */ M(et, {
|
|
480
481
|
deplie: t.getIsExpanded(),
|
|
481
482
|
onBasculer: () => t.toggleExpanded(),
|
|
482
483
|
libelle: e?.(t.original) ?? "Détail de la ligne",
|
|
483
|
-
idDetail: t.getIsExpanded() ?
|
|
484
|
+
idDetail: t.getIsExpanded() ? X(n).idDetail(t.id) : void 0
|
|
484
485
|
}) : null,
|
|
485
486
|
enableSorting: !1,
|
|
486
487
|
enableHiding: !1,
|
|
487
488
|
meta: { className: "w-8" }
|
|
488
489
|
});
|
|
489
490
|
}
|
|
490
|
-
function
|
|
491
|
-
return /* @__PURE__ */
|
|
492
|
-
render: /* @__PURE__ */
|
|
491
|
+
function et({ deplie: e, onBasculer: t, libelle: r, idDetail: i }) {
|
|
492
|
+
return /* @__PURE__ */ N(m, { children: [/* @__PURE__ */ M(g, {
|
|
493
|
+
render: /* @__PURE__ */ M(n, {
|
|
493
494
|
variant: "ghost",
|
|
494
495
|
size: "icon-xs",
|
|
495
496
|
"aria-label": r,
|
|
@@ -497,62 +498,75 @@ function Ze({ deplie: e, onBasculer: t, libelle: r, idDetail: i }) {
|
|
|
497
498
|
"aria-controls": e ? i : void 0,
|
|
498
499
|
onClick: t
|
|
499
500
|
}),
|
|
500
|
-
children: /* @__PURE__ */
|
|
501
|
-
}), /* @__PURE__ */
|
|
501
|
+
children: /* @__PURE__ */ M(F, { className: T("transition-transform motion-reduce:transition-none", e && "rotate-90") })
|
|
502
|
+
}), /* @__PURE__ */ M(h, { children: r })] });
|
|
502
503
|
}
|
|
503
|
-
function
|
|
504
|
-
return /* @__PURE__ */
|
|
505
|
-
render: /* @__PURE__ */
|
|
504
|
+
function tt({ children: e, libelle: t }) {
|
|
505
|
+
return /* @__PURE__ */ N(i, { children: [/* @__PURE__ */ N(m, { children: [/* @__PURE__ */ M(g, {
|
|
506
|
+
render: /* @__PURE__ */ M(o, { render: /* @__PURE__ */ M(n, {
|
|
506
507
|
variant: "ghost",
|
|
507
508
|
size: "icon-xs",
|
|
508
509
|
"aria-label": t
|
|
509
510
|
}) }),
|
|
510
|
-
children: /* @__PURE__ */
|
|
511
|
-
}), /* @__PURE__ */
|
|
511
|
+
children: /* @__PURE__ */ M(ae, {})
|
|
512
|
+
}), /* @__PURE__ */ M(h, { children: t })] }), /* @__PURE__ */ M(a, {
|
|
512
513
|
align: "end",
|
|
513
514
|
className: "w-44",
|
|
514
515
|
children: e
|
|
515
516
|
})] });
|
|
516
517
|
}
|
|
517
|
-
var
|
|
518
|
-
function
|
|
519
|
-
return
|
|
518
|
+
var nt = "opacity-0 transition-opacity group-hover/ligne:opacity-100 group-focus-within/ligne:opacity-100 has-aria-expanded:opacity-100 pointer-coarse:opacity-100";
|
|
519
|
+
function rt({ actions: e, libelle: t = "Actions", id: n = "actions", enableHiding: r = !1, className: i, toujoursVisibles: a = !1 }) {
|
|
520
|
+
return Y().display({
|
|
520
521
|
id: n,
|
|
521
|
-
header: () => /* @__PURE__ */
|
|
522
|
+
header: () => /* @__PURE__ */ M("span", {
|
|
522
523
|
className: "sr-only",
|
|
523
524
|
children: t
|
|
524
525
|
}),
|
|
525
|
-
cell: ({ row: t }) => /* @__PURE__ */
|
|
526
|
-
className:
|
|
526
|
+
cell: ({ row: t }) => /* @__PURE__ */ M("div", {
|
|
527
|
+
className: T("flex items-center justify-end gap-1", !a && nt),
|
|
527
528
|
children: e(t.original)
|
|
528
529
|
}),
|
|
529
530
|
enableSorting: !1,
|
|
530
531
|
enableHiding: r,
|
|
531
532
|
meta: {
|
|
532
533
|
libelle: t,
|
|
533
|
-
className:
|
|
534
|
+
className: T("w-px", i)
|
|
534
535
|
}
|
|
535
536
|
});
|
|
536
537
|
}
|
|
537
|
-
var
|
|
538
|
-
function
|
|
539
|
-
let { lien: t,
|
|
540
|
-
if (
|
|
541
|
-
let { className: e,
|
|
542
|
-
return /* @__PURE__ */
|
|
538
|
+
var $ = "rounded-sm text-left font-medium outline-none focus-visible:ring-3 focus-visible:ring-ring/50";
|
|
539
|
+
function it(e) {
|
|
540
|
+
let { lien: t, externe: n = !1, libelleExterne: r, ...i } = e, a = _(t);
|
|
541
|
+
if (i.href !== void 0 && n) {
|
|
542
|
+
let { className: e, children: t, ...n } = i;
|
|
543
|
+
return /* @__PURE__ */ N("a", {
|
|
544
|
+
"data-slot": "data-table-cell-link",
|
|
545
|
+
className: T($, "inline-flex items-center gap-1.5", e),
|
|
546
|
+
...n,
|
|
547
|
+
...y,
|
|
548
|
+
children: [t, /* @__PURE__ */ M(v, {
|
|
549
|
+
className: "size-3.5 shrink-0 text-muted-foreground",
|
|
550
|
+
libelle: r
|
|
551
|
+
})]
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
if (i.href !== void 0) {
|
|
555
|
+
let { className: e, ...t } = i;
|
|
556
|
+
return /* @__PURE__ */ M(a, {
|
|
543
557
|
"data-slot": "data-table-cell-link",
|
|
544
|
-
className:
|
|
558
|
+
className: T($, e),
|
|
545
559
|
...t
|
|
546
560
|
});
|
|
547
561
|
}
|
|
548
|
-
let { className:
|
|
549
|
-
return /* @__PURE__ */
|
|
562
|
+
let { className: o, type: s = "button", ...c } = i;
|
|
563
|
+
return /* @__PURE__ */ M("button", {
|
|
550
564
|
"data-slot": "data-table-cell-link",
|
|
551
|
-
type:
|
|
552
|
-
className:
|
|
553
|
-
...
|
|
565
|
+
type: s,
|
|
566
|
+
className: T($, "cursor-pointer", o),
|
|
567
|
+
...c
|
|
554
568
|
});
|
|
555
569
|
}
|
|
556
|
-
export {
|
|
570
|
+
export { Ze as CASE_VERROUILLEE, Re as DataTable, it as DataTableCellLink, qe as DataTableColumnHeader, tt as DataTableRowActions, Y as createDataTableColumnHelper, rt as dataTableActionsColumn, $e as dataTableExpandColumn, Ae as dataTableFeatures, Je as dataTableSelectionColumn, je as libelleColonne, X as metaDe, Me as paginationDuTableau, Fe as useDataTable };
|
|
557
571
|
|
|
558
572
|
//# sourceMappingURL=data-table.js.map
|