@etic-insa/ui 0.1.0 → 0.3.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 +897 -12
- package/dist/components/etic/action.d.ts +42 -0
- package/dist/components/etic/action.js +43 -0
- package/dist/components/etic/action.js.map +1 -0
- package/dist/components/etic/app-shell.d.ts +23 -11
- package/dist/components/etic/app-shell.js +133 -88
- package/dist/components/etic/app-shell.js.map +1 -1
- package/dist/components/etic/auth-image.d.ts +71 -0
- package/dist/components/etic/auth-image.js +67 -0
- package/dist/components/etic/auth-image.js.map +1 -0
- package/dist/components/etic/button-link.d.ts +19 -0
- package/dist/components/etic/button-link.js +19 -0
- package/dist/components/etic/button-link.js.map +1 -0
- package/dist/components/etic/centered-screen.d.ts +13 -0
- package/dist/components/etic/centered-screen.js +13 -0
- package/dist/components/etic/centered-screen.js.map +1 -0
- package/dist/components/etic/checkbox-list.d.ts +30 -0
- package/dist/components/etic/checkbox-list.js +56 -0
- package/dist/components/etic/checkbox-list.js.map +1 -0
- package/dist/components/etic/confirm-dialog.d.ts +93 -0
- package/dist/components/etic/confirm-dialog.js +109 -0
- package/dist/components/etic/confirm-dialog.js.map +1 -0
- package/dist/components/etic/copy-button.d.ts +25 -0
- package/dist/components/etic/copy-button.js +46 -0
- package/dist/components/etic/copy-button.js.map +1 -0
- package/dist/components/etic/data-table-bulk-actions.d.ts +53 -0
- package/dist/components/etic/data-table-bulk-actions.js +104 -0
- package/dist/components/etic/data-table-bulk-actions.js.map +1 -0
- package/dist/components/etic/data-table-focus.d.ts +17 -0
- package/dist/components/etic/data-table-focus.js +29 -0
- package/dist/components/etic/data-table-focus.js.map +1 -0
- package/dist/components/etic/data-table-format.d.ts +5 -0
- package/dist/components/etic/data-table-format.js +9 -0
- package/dist/components/etic/data-table-format.js.map +1 -0
- package/dist/components/etic/data-table-pagination.d.ts +36 -0
- package/dist/components/etic/data-table-pagination.js +134 -0
- package/dist/components/etic/data-table-pagination.js.map +1 -0
- package/dist/components/etic/data-table-toolbar.d.ts +90 -0
- package/dist/components/etic/data-table-toolbar.js +131 -0
- package/dist/components/etic/data-table-toolbar.js.map +1 -0
- package/dist/components/etic/data-table-view-options.d.ts +56 -0
- package/dist/components/etic/data-table-view-options.js +198 -0
- package/dist/components/etic/data-table-view-options.js.map +1 -0
- package/dist/components/etic/data-table.d.ts +421 -0
- package/dist/components/etic/data-table.js +582 -0
- package/dist/components/etic/data-table.js.map +1 -0
- package/dist/components/etic/date-picker.d.ts +36 -0
- package/dist/components/etic/date-picker.js +175 -0
- package/dist/components/etic/date-picker.js.map +1 -0
- package/dist/components/etic/delete-button.d.ts +65 -0
- package/dist/components/etic/delete-button.js +37 -0
- package/dist/components/etic/delete-button.js.map +1 -0
- package/dist/components/etic/detail-list.d.ts +26 -0
- package/dist/components/etic/detail-list.js +46 -0
- package/dist/components/etic/detail-list.js.map +1 -0
- package/dist/components/etic/disclosure.d.ts +52 -0
- package/dist/components/etic/disclosure.js +70 -0
- package/dist/components/etic/disclosure.js.map +1 -0
- package/dist/components/etic/draft-resume-dialog.d.ts +42 -0
- package/dist/components/etic/draft-resume-dialog.js +60 -0
- package/dist/components/etic/draft-resume-dialog.js.map +1 -0
- package/dist/components/etic/empty-state.d.ts +20 -0
- package/dist/components/etic/empty-state.js +20 -0
- package/dist/components/etic/empty-state.js.map +1 -0
- package/dist/components/etic/error-banner.d.ts +50 -0
- package/dist/components/etic/error-banner.js +85 -0
- package/dist/components/etic/error-banner.js.map +1 -0
- package/dist/components/etic/error-boundary.d.ts +53 -0
- package/dist/components/etic/error-boundary.js +83 -0
- package/dist/components/etic/error-boundary.js.map +1 -0
- package/dist/components/etic/explained-badge.d.ts +26 -0
- package/dist/components/etic/explained-badge.js +17 -0
- package/dist/components/etic/explained-badge.js.map +1 -0
- package/dist/components/etic/file-upload.d.ts +52 -0
- package/dist/components/etic/file-upload.js +137 -0
- package/dist/components/etic/file-upload.js.map +1 -0
- package/dist/components/etic/form-dialog.d.ts +68 -0
- package/dist/components/etic/form-dialog.js +154 -0
- package/dist/components/etic/form-dialog.js.map +1 -0
- package/dist/components/etic/form-field-context.d.ts +66 -0
- package/dist/components/etic/form-field-context.js +28 -0
- package/dist/components/etic/form-field-context.js.map +1 -0
- package/dist/components/etic/form-field.d.ts +53 -0
- package/dist/components/etic/form-field.js +105 -0
- package/dist/components/etic/form-field.js.map +1 -0
- package/dist/components/etic/icon-toggle.d.ts +51 -0
- package/dist/components/etic/icon-toggle.js +40 -0
- package/dist/components/etic/icon-toggle.js.map +1 -0
- package/dist/components/etic/lien.d.ts +34 -0
- package/dist/components/etic/lien.js +17 -0
- package/dist/components/etic/lien.js.map +1 -0
- package/dist/components/etic/loading.d.ts +37 -0
- package/dist/components/etic/loading.js +74 -0
- package/dist/components/etic/loading.js.map +1 -0
- package/dist/components/etic/page-container.d.ts +27 -0
- package/dist/components/etic/page-container.js +24 -0
- package/dist/components/etic/page-container.js.map +1 -0
- package/dist/components/etic/page-header.d.ts +64 -0
- package/dist/components/etic/page-header.js +109 -0
- package/dist/components/etic/page-header.js.map +1 -0
- package/dist/components/etic/phone-input.d.ts +47 -0
- package/dist/components/etic/phone-input.js +139 -0
- package/dist/components/etic/phone-input.js.map +1 -0
- package/dist/components/etic/query-boundary.d.ts +73 -0
- package/dist/components/etic/query-boundary.js +37 -0
- package/dist/components/etic/query-boundary.js.map +1 -0
- package/dist/components/etic/removable-badge.d.ts +30 -0
- package/dist/components/etic/removable-badge.js +31 -0
- package/dist/components/etic/removable-badge.js.map +1 -0
- package/dist/components/etic/save-bar.d.ts +31 -0
- package/dist/components/etic/save-bar.js +45 -0
- package/dist/components/etic/save-bar.js.map +1 -0
- package/dist/components/etic/search-select.d.ts +41 -0
- package/dist/components/etic/search-select.js +126 -0
- package/dist/components/etic/search-select.js.map +1 -0
- package/dist/components/etic/section-card.d.ts +12 -0
- package/dist/components/etic/section-card.js +23 -0
- package/dist/components/etic/section-card.js.map +1 -0
- package/dist/components/etic/segmented-control.d.ts +33 -0
- package/dist/components/etic/segmented-control.js +45 -0
- package/dist/components/etic/segmented-control.js.map +1 -0
- package/dist/components/etic/stat-grid.d.ts +15 -0
- package/dist/components/etic/stat-grid.js +17 -0
- package/dist/components/etic/stat-grid.js.map +1 -0
- package/dist/components/etic/stat-tile.d.ts +18 -0
- package/dist/components/etic/stat-tile.js +33 -0
- package/dist/components/etic/stat-tile.js.map +1 -0
- package/dist/components/etic/status-badge.d.ts +14 -0
- package/dist/components/etic/status-badge.js +20 -0
- package/dist/components/etic/status-badge.js.map +1 -0
- package/dist/components/etic/tailles-dialogue.d.ts +8 -0
- package/dist/components/etic/tailles-dialogue.js +10 -0
- package/dist/components/etic/tailles-dialogue.js.map +1 -0
- package/dist/components/etic/theme-menu.d.ts +6 -5
- package/dist/components/etic/theme-menu.js +46 -36
- package/dist/components/etic/theme-menu.js.map +1 -1
- package/dist/components/etic/toggletip.d.ts +36 -0
- package/dist/components/etic/toggletip.js +59 -0
- package/dist/components/etic/toggletip.js.map +1 -0
- package/dist/components/etic/tooltip-button.d.ts +39 -0
- package/dist/components/etic/tooltip-button.js +39 -0
- package/dist/components/etic/tooltip-button.js.map +1 -0
- package/dist/components/etic/unsaved-changes.d.ts +41 -0
- package/dist/components/etic/unsaved-changes.js +17 -0
- package/dist/components/etic/unsaved-changes.js.map +1 -0
- package/dist/components/etic/use-draft-autosave.d.ts +70 -0
- package/dist/components/etic/use-draft-autosave.js +98 -0
- package/dist/components/etic/use-draft-autosave.js.map +1 -0
- package/dist/components/etic/use-unsaved-changes-warning.d.ts +10 -0
- package/dist/components/etic/use-unsaved-changes-warning.js +20 -0
- package/dist/components/etic/use-unsaved-changes-warning.js.map +1 -0
- package/dist/components/ui/alert-dialog.js +33 -33
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/alert.js +47 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +5 -1
- package/dist/components/ui/avatar.js +20 -11
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +8 -0
- package/dist/components/ui/badge.js +45 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +10 -0
- package/dist/components/ui/breadcrumb.js +73 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/button-group.d.ts +10 -0
- package/dist/components/ui/button-group.js +42 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button.d.ts +16 -3
- package/dist/components/ui/button.js +28 -16
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.d.ts +10 -0
- package/dist/components/ui/calendar.js +96 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +57 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +3 -0
- package/dist/components/ui/checkbox.js +20 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +25 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/combobox.d.ts +24 -0
- package/dist/components/ui/combobox.js +178 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +26 -0
- package/dist/components/ui/dialog.js +99 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dropdown-menu.js +36 -36
- package/dist/components/ui/empty.d.ts +11 -0
- package/dist/components/ui/empty.js +60 -0
- package/dist/components/ui/empty.js.map +1 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/field.js +108 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/input-group.d.ts +18 -0
- package/dist/components/ui/input-group.js +79 -0
- package/dist/components/ui/input-group.js.map +1 -0
- package/dist/components/ui/item.d.ts +22 -0
- package/dist/components/ui/item.js +122 -0
- package/dist/components/ui/item.js.map +1 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +20 -0
- package/dist/components/ui/kbd.js.map +1 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/label.js +14 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/native-select.d.ts +8 -0
- package/dist/components/ui/native-select.js +39 -0
- package/dist/components/ui/native-select.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +17 -0
- package/dist/components/ui/pagination.js +81 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/popover.js +56 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +21 -0
- package/dist/components/ui/progress.js +53 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +27 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/scroll-area.d.ts +4 -0
- package/dist/components/ui/scroll-area.js +36 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/select.d.ts +23 -0
- package/dist/components/ui/select.js +119 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +6 -1
- package/dist/components/ui/sidebar.js +92 -92
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/slider.d.ts +3 -0
- package/dist/components/ui/slider.js +36 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +8 -0
- package/dist/components/ui/spinner.js +24 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.js +20 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +67 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +10 -0
- package/dist/components/ui/tabs.js +46 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +14 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/toggle-group.d.ts +11 -0
- package/dist/components/ui/toggle-group.js +54 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +8 -0
- package/dist/components/ui/toggle.js +36 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +7 -2
- package/dist/components/ui/tooltip.js +27 -19
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/hooks/use-column-prefs.d.ts +84 -0
- package/dist/hooks/use-column-prefs.js +71 -0
- package/dist/hooks/use-column-prefs.js.map +1 -0
- package/dist/hooks/use-debounced-value.d.ts +13 -0
- package/dist/hooks/use-debounced-value.js +12 -0
- package/dist/hooks/use-debounced-value.js.map +1 -0
- package/dist/hooks/use-document-title.d.ts +5 -0
- package/dist/hooks/use-document-title.js +13 -0
- package/dist/hooks/use-document-title.js.map +1 -0
- package/dist/hooks/use-persisted-state.d.ts +43 -0
- package/dist/hooks/use-persisted-state.js +40 -0
- package/dist/hooks/use-persisted-state.js.map +1 -0
- package/dist/index.d.ts +91 -1
- package/dist/index.js +99 -13
- package/dist/lib/autofill.d.ts +18 -0
- package/dist/lib/autofill.js +10 -0
- package/dist/lib/autofill.js.map +1 -0
- package/dist/lib/dates.d.ts +20 -0
- package/dist/lib/dates.js +16 -0
- package/dist/lib/dates.js.map +1 -0
- package/dist/lib/focus-rendu.d.ts +24 -0
- package/dist/lib/focus-rendu.js +14 -0
- package/dist/lib/focus-rendu.js.map +1 -0
- package/dist/lib/format.d.ts +54 -0
- package/dist/lib/format.js +80 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/normalize.d.ts +28 -0
- package/dist/lib/normalize.js +21 -0
- package/dist/lib/normalize.js.map +1 -0
- package/dist/lib/ordre-colonnes.d.ts +15 -0
- package/dist/lib/ordre-colonnes.js +14 -0
- package/dist/lib/ordre-colonnes.js.map +1 -0
- package/dist/lib/ton.d.ts +23 -0
- package/dist/lib/ton.js +51 -0
- package/dist/lib/ton.js.map +1 -0
- package/dist/styles.css +140 -58
- package/dist/theme.d.ts +34 -0
- package/dist/theme.js +45 -0
- package/dist/theme.js.map +1 -0
- package/package.json +21 -8
- package/src/theme-boot.js +22 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TooltipButton as e } from "./tooltip-button.js";
|
|
2
|
+
import { cn as t } from "cn";
|
|
3
|
+
import { useEffect as n, useRef as r, useState as i } from "react";
|
|
4
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
import { CheckIcon as c, CopyIcon as l, XIcon as u } from "lucide-react";
|
|
6
|
+
// src/components/etic/copy-button.tsx
|
|
7
|
+
async function d(e) {
|
|
8
|
+
if (navigator.clipboard?.writeText) try {
|
|
9
|
+
return await navigator.clipboard.writeText(e), !0;
|
|
10
|
+
} catch {}
|
|
11
|
+
let t = document.createElement("textarea");
|
|
12
|
+
try {
|
|
13
|
+
return t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select(), document.execCommand("copy");
|
|
14
|
+
} catch {
|
|
15
|
+
return !1;
|
|
16
|
+
} finally {
|
|
17
|
+
t.remove();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function f({ valeur: f, libelle: p = "Copier", libelleCopie: m = "Copié !", libelleEchec: h = "Copie impossible\xA0: copiez le texte à la main", onCopie: g, onEchec: _, variant: v = "outline", size: y, className: b, ...x }) {
|
|
21
|
+
let [S, C] = i(null), w = r(void 0);
|
|
22
|
+
n(() => () => clearTimeout(w.current), []);
|
|
23
|
+
let T = async () => {
|
|
24
|
+
let e = await d(f);
|
|
25
|
+
C(e ? "copie" : "echec"), e ? g?.() : _?.(), clearTimeout(w.current), w.current = setTimeout(() => C(null), e ? 2e3 : 4e3);
|
|
26
|
+
}, E = S === "copie" ? m : S === "echec" ? h : "";
|
|
27
|
+
return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(e, {
|
|
28
|
+
variant: v,
|
|
29
|
+
size: y ?? "icon-sm",
|
|
30
|
+
"aria-label": p,
|
|
31
|
+
infobulle: E || p,
|
|
32
|
+
"data-copie": S === "copie" || void 0,
|
|
33
|
+
"data-echec": S === "echec" || void 0,
|
|
34
|
+
className: t(y === void 0 && "in-data-[slot=input-group-addon]:size-6 in-data-[slot=input-group-addon]:rounded-[calc(var(--radius)-3px)]", S === "copie" && "text-success", S === "echec" && "text-destructive", b),
|
|
35
|
+
onClick: T,
|
|
36
|
+
...x,
|
|
37
|
+
children: o(S === "copie" ? c : S === "echec" ? u : l, {})
|
|
38
|
+
}), /* @__PURE__ */ o("span", {
|
|
39
|
+
className: "sr-only",
|
|
40
|
+
role: "status",
|
|
41
|
+
children: E
|
|
42
|
+
})] });
|
|
43
|
+
}
|
|
44
|
+
export { f as CopyButton };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=copy-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-button.js","names":["_Fragment","Fragment$1","copier","texte","champ","CopyButton","tailleDemandee","props","etat","setEtat","useState","minuterie","useRef","surClic","reussi","valeur","onCopie","onEchec","annonce","libelleCopie","libelleEchec","TooltipButton","libelle","cn","className","jsx","CheckIcon","XIcon","CopyIcon"],"sources":["../../../src/components/etic/copy-button.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\"\nimport { cn } from \"cn\"\nimport { CheckIcon, CopyIcon, XIcon } from \"lucide-react\"\n\nimport {\n TooltipButton,\n type TooltipButtonProps,\n} from \"@etic-ui/components/etic/tooltip-button\"\n\n/** Écrit dans le presse-papiers : l'API asynchrone si elle est là, sinon un\n * champ caché et `execCommand` (contexte non sécurisé, vieux navigateur). */\nasync function copier(texte: string): Promise<boolean> {\n if (navigator.clipboard?.writeText) {\n try {\n await navigator.clipboard.writeText(texte)\n return true\n } catch {\n // On tente l'ancienne méthode.\n }\n }\n const champ = document.createElement(\"textarea\")\n try {\n champ.value = texte\n champ.setAttribute(\"readonly\", \"\")\n champ.style.position = \"fixed\"\n champ.style.opacity = \"0\"\n document.body.appendChild(champ)\n champ.select()\n return document.execCommand(\"copy\")\n } catch {\n return false\n } finally {\n // Retiré même si execCommand lève (absent ou refusé).\n champ.remove()\n }\n}\n\nexport interface CopyButtonProps extends Omit<\n TooltipButtonProps,\n \"value\" | \"onClick\" | \"children\" | \"infobulle\"\n> {\n /** Texte copié. */\n valeur: string\n /** Infobulle et nom accessible : ce qui est copié. « Copier » par défaut. */\n libelle?: string\n /** Après la copie, deux secondes. « Copié ! » par défaut. */\n libelleCopie?: string\n /** Quand le navigateur refuse la copie, quatre secondes. « Copie\n * impossible : copiez le texte à la main » par défaut. */\n libelleEchec?: string\n /** Appelé après une copie réussie (un secret montré une seule fois…). */\n onCopie?: () => void\n /** Appelé quand la copie est refusée (permission, contexte non sûr). */\n onEchec?: () => void\n}\n\n/**\n * Bouton de copie : une icône seule, son libellé dans l'infobulle et le nom\n * accessible. Après la copie, une coche et « Copié ! » pendant deux\n * secondes ; si le navigateur la refuse, une croix et « Copie impossible ».\n * Les deux sont annoncés aux lecteurs d'écran. `verrou` comme pour\n * `TooltipButton`. Dans un `InputGroupAddon`, il passe à 24 px, sauf `size`\n * donnée.\n */\nexport function CopyButton({\n valeur,\n libelle = \"Copier\",\n libelleCopie = \"Copié !\",\n libelleEchec = \"Copie impossible : copiez le texte à la main\",\n onCopie,\n onEchec,\n variant = \"outline\",\n size: tailleDemandee,\n className,\n ...props\n}: CopyButtonProps) {\n const [etat, setEtat] = useState<\"copie\" | \"echec\" | null>(null)\n const minuterie = useRef<ReturnType<typeof setTimeout>>(undefined)\n\n useEffect(() => () => clearTimeout(minuterie.current), [])\n\n const surClic = async () => {\n const reussi = await copier(valeur)\n setEtat(reussi ? \"copie\" : \"echec\")\n if (reussi) onCopie?.()\n else onEchec?.()\n clearTimeout(minuterie.current)\n minuterie.current = setTimeout(() => setEtat(null), reussi ? 2000 : 4000)\n }\n\n const annonce =\n etat === \"copie\" ? libelleCopie : etat === \"echec\" ? libelleEchec : \"\"\n return (\n <>\n <TooltipButton\n variant={variant}\n size={tailleDemandee ?? \"icon-sm\"}\n // Nom constant : le résultat est annoncé par la zone ci-dessous.\n aria-label={libelle}\n infobulle={annonce || libelle}\n data-copie={etat === \"copie\" || undefined}\n data-echec={etat === \"echec\" || undefined}\n className={cn(\n // Dans un groupe de saisie (`InputGroupAddon`), 24 px comme\n // l'`InputGroupButton` `icon-xs` de shadcn : à 28 px, le bouton\n // touchait presque la bordure du champ (1 px) et son anneau de\n // focus en sortait. Une taille donnée par l'application prime.\n // Écrites en entier : le bouton ignore où il est rendu (pas de\n // `render={<InputGroupButton />}` possible), et Tailwind ne voit\n // pas une classe préfixée au rendu (`inputGroupButtonVariants`).\n tailleDemandee === undefined &&\n \"in-data-[slot=input-group-addon]:size-6 in-data-[slot=input-group-addon]:rounded-[calc(var(--radius)-3px)]\",\n etat === \"copie\" && \"text-success\",\n etat === \"echec\" && \"text-destructive\",\n className\n )}\n onClick={surClic}\n {...props}\n >\n {etat === \"copie\" ? (\n <CheckIcon />\n ) : etat === \"echec\" ? (\n <XIcon />\n ) : (\n <CopyIcon />\n )}\n </TooltipButton>\n {/* Hors du bouton (ses enfants ne sont pas exposés) et montée en\n permanence : une zone insérée avec son texte n'est pas toujours lue. */}\n <span className=\"sr-only\" role=\"status\">\n {annonce}\n </span>\n </>\n )\n}\n"],"mappings":";;;;;;AAWA,eAAeE,EAAO,GAAiC;CACrD,IAAI,UAAU,WAAW,WACvB,IAAI;EAEF,OADA,MAAM,UAAU,UAAU,UAAUC,CAAK,GAClC;CACT,QAAQ,CAER;CAEF,IAAMC,IAAQ,SAAS,cAAc,UAAU;CAC/C,IAAI;EAOF,OANA,EAAM,QAAQD,GACdC,EAAM,aAAa,YAAY,EAAE,GACjC,EAAM,MAAM,WAAW,SACvB,EAAM,MAAM,UAAU,KACtB,SAAS,KAAK,YAAYA,CAAK,GAC/BA,EAAM,OAAO,GACN,SAAS,YAAY,MAAM;CACpC,QAAQ;EACN,OAAO;CACT,UAAU;EAER,EAAM,OAAO;CACf;AACF;AA6BA,SAAgBC,EAAW,EACzB,WACA,aAAU,UACV,kBAAe,WACf,kBAAe,mDACf,YACA,YACA,aAAU,WACV,MAAMC,GACN,cACA,GAAGC,KACe;CAClB,IAAM,CAACC,GAAMC,KAAWC,EAAmC,IAAI,GACzDC,IAAYC,EAAsC,KAAA,CAAS;CAEjE,cAAsB,aAAaD,EAAU,OAAO,GAAG,CAAC,CAAC;CAEzD,IAAME,IAAU,YAAY;EAC1B,IAAMC,IAAS,MAAMZ,EAAOa,CAAM;EAKlC,AAJAN,EAAQK,IAAS,UAAU,OAAO,GAC9BA,IAAQE,IAAU,IACjBC,IAAU,GACf,aAAaN,EAAU,OAAO,GAC9B,EAAU,UAAU,iBAAiBF,EAAQ,IAAI,GAAGK,IAAS,MAAO,GAAI;CAC1E,GAEMI,IACJV,MAAS,UAAUW,IAAeX,MAAS,UAAUY,IAAe;CACtE,OACE,kBAAApB,GAAA,EAAA,UAAA,CACE,kBAACqB,GAAD;EACW;EACT,MAAMf,KAAkB;EAExB,cAAYgB;EACZ,WAAWJ,KAAWI;EACtB,cAAYd,MAAS,WAAW,KAAA;EAChC,cAAYA,MAAS,WAAW,KAAA;EAChC,WAAWe,EAQTjB,MAAmB,KAAA,KACjB,8GACFE,MAAS,WAAW,gBACpBA,MAAS,WAAW,oBACpBgB,CACF;EACA,SAASX;EACT,GAAIN;EAEH,UACCkB,EADDjB,MAAS,UACPkB,IACClB,MAAS,UACVmB,IAEAC,GAJD,CAAY,CAID;CAEA,CAAA,GAGf,kBAAC,QAAD;EAAM,WAAU;EAAU,MAAK;EAC5B,UAAAV;CACG,CAAA,CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { RowData } from '@tanstack/react-table';
|
|
3
|
+
import { DataTableInstance } from './data-table';
|
|
4
|
+
import { DataTableUnite } from './data-table-format';
|
|
5
|
+
interface DataTableBulkActionsCommun {
|
|
6
|
+
/** Nom des éléments : « 3 personnes sélectionnées ». « élément »,
|
|
7
|
+
* « éléments » par défaut. */
|
|
8
|
+
unite?: DataTableUnite;
|
|
9
|
+
/** Accorde « sélectionnées » au féminin. */
|
|
10
|
+
feminin?: boolean;
|
|
11
|
+
/** Les actions : boutons `size="sm"`. Les lignes visées viennent de
|
|
12
|
+
* `table.getSelectedRowModel()` (ou `getSelectedRowIds()`) ; quand
|
|
13
|
+
* `toutSelectionne` est vrai, l'action porte sur tous les éléments. */
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Barre branchée sur l'instance d'un `DataTable`. */
|
|
18
|
+
export interface DataTableBulkActionsTableProps<TData extends RowData> extends DataTableBulkActionsCommun {
|
|
19
|
+
table: DataTableInstance<TData>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Barre d'un tableau rendu à la main, sans instance `useDataTable` : la
|
|
23
|
+
* sélection est celle de l'application.
|
|
24
|
+
*/
|
|
25
|
+
export interface DataTableBulkActionsSelectionProps extends DataTableBulkActionsCommun {
|
|
26
|
+
table?: never;
|
|
27
|
+
/** Nombre d'éléments sélectionnés ; la barre s'affiche dès 1. */
|
|
28
|
+
nombre: number;
|
|
29
|
+
/** « Tout désélectionner » et Échap. */
|
|
30
|
+
onToutDeselectionner: () => void;
|
|
31
|
+
/** Cadre du tableau : Échap y vide la sélection, et le focus y revient
|
|
32
|
+
* (sa case d'en-tête, sinon le cadre) quand la barre disparaît. */
|
|
33
|
+
racine?: RefObject<HTMLElement | null>;
|
|
34
|
+
}
|
|
35
|
+
export type DataTableBulkActionsProps<TData extends RowData = RowData> = DataTableBulkActionsTableProps<TData> | DataTableBulkActionsSelectionProps;
|
|
36
|
+
/**
|
|
37
|
+
* Barre d'actions groupées : apparaît avec la sélection, dit combien
|
|
38
|
+
* d'éléments sont sélectionnés, porte les actions et « Tout désélectionner »
|
|
39
|
+
* (aussi Échap, quand le focus est dans le tableau ou dans la barre). À
|
|
40
|
+
* placer une fois, après le tableau : collante en bas de l'écran, elle reste
|
|
41
|
+
* à portée au-dessus d'un long tableau sans le décaler.
|
|
42
|
+
*
|
|
43
|
+
* Quand elle disparaît avec le focus dedans (« Tout désélectionner », Échap,
|
|
44
|
+
* action qui vide la sélection), le focus passe à la case d'en-tête du
|
|
45
|
+
* tableau plutôt que de tomber sur `<body>`.
|
|
46
|
+
*
|
|
47
|
+
* Avec `table`, elle suit la sélection d'un `DataTable` ; avec `nombre`,
|
|
48
|
+
* `onToutDeselectionner` et `racine`, celle d'un tableau rendu à la main.
|
|
49
|
+
* Sur téléphone, le compte et « × » restent ensemble sur la première ligne,
|
|
50
|
+
* les actions passent dessous.
|
|
51
|
+
*/
|
|
52
|
+
export declare function DataTableBulkActions<TData extends RowData>(props: DataTableBulkActionsProps<TData>): import("react").JSX.Element;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { nombreFr as e, participe as t, uniteAccordee as n } from "../../lib/format.js";
|
|
2
|
+
import { Button as r } from "../ui/button.js";
|
|
3
|
+
import { Separator as i } from "../ui/separator.js";
|
|
4
|
+
import { metaDe as a } from "./data-table.js";
|
|
5
|
+
import { focaliserTableau as o } from "./data-table-focus.js";
|
|
6
|
+
import { UNITE_PAR_DEFAUT as s } from "./data-table-format.js";
|
|
7
|
+
import { cn as c } from "cn";
|
|
8
|
+
import { useEffect as l, useEffectEvent as u, useId as d, useLayoutEffect as f, useRef as p, useState as m } from "react";
|
|
9
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
10
|
+
import { XIcon as v } from "lucide-react";
|
|
11
|
+
// src/components/etic/data-table-bulk-actions.tsx
|
|
12
|
+
function y(e) {
|
|
13
|
+
if (e.defaultPrevented) return !0;
|
|
14
|
+
let t = e.target;
|
|
15
|
+
return t instanceof HTMLElement && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)) && !(t instanceof HTMLInputElement && t.type === "checkbox");
|
|
16
|
+
}
|
|
17
|
+
function b(e) {
|
|
18
|
+
if (!e.table) return {
|
|
19
|
+
nombre: e.nombre,
|
|
20
|
+
toutDeselectionner: e.onToutDeselectionner,
|
|
21
|
+
racine: () => e.racine?.current ?? null
|
|
22
|
+
};
|
|
23
|
+
let { table: t } = e, n = a(t);
|
|
24
|
+
return {
|
|
25
|
+
nombre: n.toutSelectionne && n.total !== void 0 ? n.total : t.getSelectedRowIds().length,
|
|
26
|
+
toutDeselectionner: n.toutDeselectionner,
|
|
27
|
+
racine: () => n.racine.current
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function x(a) {
|
|
31
|
+
let { unite: x = s, feminin: S = !1, children: C, className: w } = a, T = d(), E = p(null), { nombre: D, toutDeselectionner: O, racine: k } = b(a), A = D > 0, j = `${n(D, x)} ${t("sélectionné", D, S)}`, M = p(null), N = () => {
|
|
32
|
+
E.current?.contains(document.activeElement) && o(k()), O();
|
|
33
|
+
};
|
|
34
|
+
f(() => {
|
|
35
|
+
if (A) return;
|
|
36
|
+
let e = M.current;
|
|
37
|
+
M.current = null, !e || e.isConnected || document.activeElement && document.activeElement !== document.body || o(k());
|
|
38
|
+
});
|
|
39
|
+
let [P, F] = m(A);
|
|
40
|
+
A && !P && F(!0);
|
|
41
|
+
let I = u((e) => {
|
|
42
|
+
if (e.key !== "Escape" || y(e)) return;
|
|
43
|
+
let t = e.target;
|
|
44
|
+
((k()?.contains(t) ?? !1) || E.current?.contains(t)) && N();
|
|
45
|
+
});
|
|
46
|
+
return l(() => {
|
|
47
|
+
if (A) return document.addEventListener("keydown", I), () => document.removeEventListener("keydown", I);
|
|
48
|
+
}, [A]), /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", {
|
|
49
|
+
"data-slot": "data-table-bulk-actions-status",
|
|
50
|
+
className: "sr-only",
|
|
51
|
+
"aria-live": "polite",
|
|
52
|
+
"aria-atomic": "true",
|
|
53
|
+
children: A ? `${e(D)} ${j}` : P ? "Sélection effacée" : null
|
|
54
|
+
}), A ? /* @__PURE__ */ _("div", {
|
|
55
|
+
ref: E,
|
|
56
|
+
"data-slot": "data-table-bulk-actions",
|
|
57
|
+
role: "toolbar",
|
|
58
|
+
"aria-labelledby": T,
|
|
59
|
+
onFocus: (e) => {
|
|
60
|
+
M.current = e.target;
|
|
61
|
+
},
|
|
62
|
+
onBlur: (e) => {
|
|
63
|
+
let t = e.relatedTarget;
|
|
64
|
+
t && !e.currentTarget.contains(t) && (M.current = null);
|
|
65
|
+
},
|
|
66
|
+
className: c("sticky bottom-4 z-20 mx-auto flex w-fit max-w-full flex-wrap items-center gap-2 rounded-xl border bg-popover p-1.5 pl-3 text-sm text-popover-foreground shadow-lg", w),
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ _("span", {
|
|
69
|
+
id: T,
|
|
70
|
+
className: "whitespace-nowrap",
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ g("strong", {
|
|
73
|
+
className: "font-medium tabular-nums",
|
|
74
|
+
children: e(D)
|
|
75
|
+
}),
|
|
76
|
+
" ",
|
|
77
|
+
j
|
|
78
|
+
]
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ g(i, {
|
|
81
|
+
orientation: "vertical",
|
|
82
|
+
className: "h-5 self-center! max-sm:hidden"
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ g("div", {
|
|
85
|
+
className: "flex flex-wrap items-center gap-1.5 max-sm:order-last max-sm:basis-full",
|
|
86
|
+
children: C
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ _(r, {
|
|
89
|
+
variant: "ghost",
|
|
90
|
+
size: "sm",
|
|
91
|
+
onClick: N,
|
|
92
|
+
"aria-keyshortcuts": "Escape",
|
|
93
|
+
className: "max-sm:ml-auto",
|
|
94
|
+
children: [/* @__PURE__ */ g(v, { "data-icon": "inline-start" }), /* @__PURE__ */ g("span", {
|
|
95
|
+
className: "max-sm:sr-only",
|
|
96
|
+
children: "Tout désélectionner"
|
|
97
|
+
})]
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
}) : null] });
|
|
101
|
+
}
|
|
102
|
+
export { x as DataTableBulkActions };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=data-table-bulk-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-bulk-actions.js","names":["_Fragment","Fragment$1","echapPourUnChamp","event","cible","selectionDe","props","meta","metaDe","table","DataTableBulkActions","UNITE_PAR_DEFAUT","idResume","useId","barreRef","useRef","vider","visible","nombre","resume","uniteAccordee","unite","participe","feminin","focusDansBarre","toutDeselectionner","focaliserTableau","racine","perdu","dejaVisible","setDejaVisible","useState","surTouche","useEffectEvent","useEffect","nombreFr","vers","cn","className","Separator","Button","XIcon"],"sources":["../../../src/components/etic/data-table-bulk-actions.tsx"],"sourcesContent":["import {\n useEffect,\n useEffectEvent,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ReactNode,\n type RefObject,\n} from \"react\"\nimport type { RowData } from \"@tanstack/react-table\"\nimport { cn } from \"cn\"\nimport { XIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport { Separator } from \"@etic-ui/components/ui/separator\"\nimport {\n metaDe,\n type DataTableInstance,\n} from \"@etic-ui/components/etic/data-table\"\nimport { focaliserTableau } from \"@etic-ui/components/etic/data-table-focus\"\nimport {\n UNITE_PAR_DEFAUT,\n nombreFr,\n participe,\n uniteAccordee,\n type DataTableUnite,\n} from \"@etic-ui/components/etic/data-table-format\"\n\n/** Un Échap tapé dans un champ (recherche dans une cellule…) lui revient. */\nfunction echapPourUnChamp(event: KeyboardEvent): boolean {\n if (event.defaultPrevented) return true\n const cible = event.target\n return (\n cible instanceof HTMLElement &&\n (cible.isContentEditable ||\n /^(INPUT|TEXTAREA|SELECT)$/.test(cible.tagName)) &&\n !(cible instanceof HTMLInputElement && cible.type === \"checkbox\")\n )\n}\n\ninterface DataTableBulkActionsCommun {\n /** Nom des éléments : « 3 personnes sélectionnées ». « élément »,\n * « éléments » par défaut. */\n unite?: DataTableUnite\n /** Accorde « sélectionnées » au féminin. */\n feminin?: boolean\n /** Les actions : boutons `size=\"sm\"`. Les lignes visées viennent de\n * `table.getSelectedRowModel()` (ou `getSelectedRowIds()`) ; quand\n * `toutSelectionne` est vrai, l'action porte sur tous les éléments. */\n children: ReactNode\n className?: string\n}\n\n/** Barre branchée sur l'instance d'un `DataTable`. */\nexport interface DataTableBulkActionsTableProps<\n TData extends RowData,\n> extends DataTableBulkActionsCommun {\n table: DataTableInstance<TData>\n}\n\n/**\n * Barre d'un tableau rendu à la main, sans instance `useDataTable` : la\n * sélection est celle de l'application.\n */\nexport interface DataTableBulkActionsSelectionProps extends DataTableBulkActionsCommun {\n table?: never\n /** Nombre d'éléments sélectionnés ; la barre s'affiche dès 1. */\n nombre: number\n /** « Tout désélectionner » et Échap. */\n onToutDeselectionner: () => void\n /** Cadre du tableau : Échap y vide la sélection, et le focus y revient\n * (sa case d'en-tête, sinon le cadre) quand la barre disparaît. */\n racine?: RefObject<HTMLElement | null>\n}\n\nexport type DataTableBulkActionsProps<TData extends RowData = RowData> =\n DataTableBulkActionsTableProps<TData> | DataTableBulkActionsSelectionProps\n\n/** Nombre, remise à zéro et cadre, lus dans le tableau ou donnés. */\nfunction selectionDe<TData extends RowData>(\n props: DataTableBulkActionsProps<TData>\n): {\n nombre: number\n toutDeselectionner: () => void\n racine: () => HTMLElement | null\n} {\n if (!props.table)\n return {\n nombre: props.nombre,\n toutDeselectionner: props.onToutDeselectionner,\n racine: () => props.racine?.current ?? null,\n }\n const { table } = props\n const meta = metaDe(table)\n return {\n // « Tous sélectionnés » : le total, pas seulement les lignes de la page.\n nombre:\n meta.toutSelectionne && meta.total !== undefined\n ? meta.total\n : table.getSelectedRowIds().length,\n toutDeselectionner: meta.toutDeselectionner,\n racine: () => meta.racine.current,\n }\n}\n\n/**\n * Barre d'actions groupées : apparaît avec la sélection, dit combien\n * d'éléments sont sélectionnés, porte les actions et « Tout désélectionner »\n * (aussi Échap, quand le focus est dans le tableau ou dans la barre). À\n * placer une fois, après le tableau : collante en bas de l'écran, elle reste\n * à portée au-dessus d'un long tableau sans le décaler.\n *\n * Quand elle disparaît avec le focus dedans (« Tout désélectionner », Échap,\n * action qui vide la sélection), le focus passe à la case d'en-tête du\n * tableau plutôt que de tomber sur `<body>`.\n *\n * Avec `table`, elle suit la sélection d'un `DataTable` ; avec `nombre`,\n * `onToutDeselectionner` et `racine`, celle d'un tableau rendu à la main.\n * Sur téléphone, le compte et « × » restent ensemble sur la première ligne,\n * les actions passent dessous.\n */\nexport function DataTableBulkActions<TData extends RowData>(\n props: DataTableBulkActionsProps<TData>\n) {\n const {\n unite = UNITE_PAR_DEFAUT,\n feminin = false,\n children,\n className,\n } = props\n const idResume = useId()\n const barreRef = useRef<HTMLDivElement>(null)\n const { nombre, toutDeselectionner: vider, racine } = selectionDe(props)\n const visible = nombre > 0\n const resume = `${uniteAccordee(nombre, unite)} ${participe(\"sélectionné\", nombre, feminin)}`\n\n // Dernier élément de la barre qui a eu le focus, tant que le focus n'est\n // pas parti ailleurs : s'il disparaît avec la barre, on rattrape le focus.\n const focusDansBarre = useRef<HTMLElement | null>(null)\n const toutDeselectionner = () => {\n if (barreRef.current?.contains(document.activeElement))\n focaliserTableau(racine())\n vider()\n }\n useLayoutEffect(() => {\n if (visible) return\n const perdu = focusDansBarre.current\n focusDansBarre.current = null\n if (\n perdu &&\n !perdu.isConnected &&\n (!document.activeElement || document.activeElement === document.body)\n )\n focaliserTableau(racine())\n })\n\n // Une sélection effacée est dite : la zone garderait sinon le dernier\n // compte. Rien avant la première sélection.\n const [dejaVisible, setDejaVisible] = useState(visible)\n if (visible && !dejaVisible) setDejaVisible(true)\n\n const surTouche = useEffectEvent((event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || echapPourUnChamp(event)) return\n // Échap ne s'adresse à la barre que depuis le tableau ou la barre : pas\n // depuis la navigation, ni depuis un dialogue ou un menu (rendus hors du\n // tableau, dans un portail).\n const cible = event.target as Node\n const dansTableau = racine()?.contains(cible) ?? false\n if (!dansTableau && !barreRef.current?.contains(cible)) return\n toutDeselectionner()\n })\n useEffect(() => {\n if (!visible) return\n document.addEventListener(\"keydown\", surTouche)\n return () => document.removeEventListener(\"keydown\", surTouche)\n }, [visible])\n\n return (\n <>\n {/* Toujours montée : une zone annoncée insérée avec son texte n'est\n pas lue de façon fiable, la première case cochée passerait sous\n silence. */}\n <div\n data-slot=\"data-table-bulk-actions-status\"\n className=\"sr-only\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {visible\n ? `${nombreFr(nombre)} ${resume}`\n : dejaVisible\n ? \"Sélection effacée\"\n : null}\n </div>\n {visible ? (\n <div\n ref={barreRef}\n data-slot=\"data-table-bulk-actions\"\n role=\"toolbar\"\n aria-labelledby={idResume}\n onFocus={(event) => {\n focusDansBarre.current = event.target\n }}\n onBlur={(event) => {\n const vers = event.relatedTarget\n if (vers && !event.currentTarget.contains(vers))\n focusDansBarre.current = null\n }}\n className={cn(\n \"sticky bottom-4 z-20 mx-auto flex w-fit max-w-full flex-wrap items-center gap-2 rounded-xl border bg-popover p-1.5 pl-3 text-sm text-popover-foreground shadow-lg\",\n className\n )}\n >\n <span id={idResume} className=\"whitespace-nowrap\">\n <strong className=\"font-medium tabular-nums\">\n {nombreFr(nombre)}\n </strong>{\" \"}\n {resume}\n </span>\n <Separator\n orientation=\"vertical\"\n className=\"h-5 self-center! max-sm:hidden\"\n />\n {/* Sur mobile, le compte et « Tout désélectionner » forment la\n première ligne, les actions la suivante : la barre ne finit\n plus sur une croix seule. L'ordre du DOM (celui de la\n tabulation) reste celui du bureau. */}\n <div className=\"flex flex-wrap items-center gap-1.5 max-sm:order-last max-sm:basis-full\">\n {children}\n </div>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={toutDeselectionner}\n aria-keyshortcuts=\"Escape\"\n className=\"max-sm:ml-auto\"\n >\n <XIcon data-icon=\"inline-start\" />\n {/* Sur mobile, l'icône seule garde la barre sur une ligne. */}\n <span className=\"max-sm:sr-only\">Tout désélectionner</span>\n </Button>\n </div>\n ) : null}\n </>\n )\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rend le focus à un élément stable du tableau avant qu'un contrôle qui l'a
|
|
3
|
+
* ne disparaisse (bandeau ou barre de sélection) : la case d'en-tête, sinon
|
|
4
|
+
* le cadre lui-même.
|
|
5
|
+
*/
|
|
6
|
+
export declare function focaliserTableau(racine: HTMLElement | null): void;
|
|
7
|
+
/**
|
|
8
|
+
* À appeler juste avant qu'une ligne qui avait le focus (elle, ou un
|
|
9
|
+
* dialogue ou un menu ouvert depuis elle) quitte le document : une fois la
|
|
10
|
+
* ligne retirée, si personne n'a repris le focus, il va à la même cellule de
|
|
11
|
+
* la ligne suivante (ou précédente), sinon au tableau. Sans cela, il tombe
|
|
12
|
+
* sur la page.
|
|
13
|
+
*
|
|
14
|
+
* `rang` : l'index de la cellule qui avait le focus (`cellIndex`), -1 si
|
|
15
|
+
* inconnu (la première commande de la ligne voisine).
|
|
16
|
+
*/
|
|
17
|
+
export declare function rendreFocusApresLigne(ligne: HTMLTableRowElement, rang: number): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/components/etic/data-table-focus.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!e) return;
|
|
4
|
+
let t = e.querySelector("thead [role=\"checkbox\"]:not([data-disabled])");
|
|
5
|
+
if (t) return t.focus();
|
|
6
|
+
e.hasAttribute("tabindex") || (e.tabIndex = -1), e.focus();
|
|
7
|
+
}
|
|
8
|
+
function t(e, t) {
|
|
9
|
+
let n = e[t];
|
|
10
|
+
for (; n instanceof HTMLTableRowElement && n.dataset.slot === "data-table-detail";) n = n[t];
|
|
11
|
+
return n instanceof HTMLTableRowElement ? n : null;
|
|
12
|
+
}
|
|
13
|
+
function n(n, r) {
|
|
14
|
+
let i = [t(n, "nextElementSibling"), t(n, "previousElementSibling")], a = n.closest("[data-slot=\"data-table\"]") ?? n.closest("[data-slot=\"table-container\"]");
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
let t = document.activeElement;
|
|
17
|
+
if (!(t && t !== document.body)) {
|
|
18
|
+
for (let e of i) {
|
|
19
|
+
if (!e?.isConnected) continue;
|
|
20
|
+
let t = (e.cells[r] ?? e).querySelector("button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex=\"-1\"])");
|
|
21
|
+
if (t) return t.focus();
|
|
22
|
+
}
|
|
23
|
+
a?.isConnected && e(a);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { e as focaliserTableau, n as rendreFocusApresLigne };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=data-table-focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-focus.js","names":["focaliserTableau","racine","caseEntete","ligneVoisine","voisine","ligne","cle","rendreFocusApresLigne","voisines","focus","cible","rang"],"sources":["../../../src/components/etic/data-table-focus.ts"],"sourcesContent":["// Focus d'un tableau quand ce qui l'avait disparaît (bandeau, barre de\n// sélection, ligne supprimée). Sans dépendance à TanStack Table : utilisable\n// pour un tableau rendu à la main avec les primitives `Table`.\n\n/**\n * Rend le focus à un élément stable du tableau avant qu'un contrôle qui l'a\n * ne disparaisse (bandeau ou barre de sélection) : la case d'en-tête, sinon\n * le cadre lui-même.\n */\nexport function focaliserTableau(racine: HTMLElement | null) {\n if (!racine) return\n const caseEntete = racine.querySelector<HTMLElement>(\n 'thead [role=\"checkbox\"]:not([data-disabled])'\n )\n if (caseEntete) return caseEntete.focus()\n if (!racine.hasAttribute(\"tabindex\")) racine.tabIndex = -1\n racine.focus()\n}\n\n/** Ce qui peut recevoir le focus dans une cellule. */\nconst FOCALISABLE =\n 'button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex=\"-1\"])'\n\n/** Ligne de données voisine, en sautant les détails dépliés (qui n'ont pas\n * les mêmes cellules). */\nfunction ligneVoisine(\n ligne: HTMLTableRowElement,\n cle: \"nextElementSibling\" | \"previousElementSibling\"\n): HTMLTableRowElement | null {\n let voisine = ligne[cle]\n while (\n voisine instanceof HTMLTableRowElement &&\n voisine.dataset.slot === \"data-table-detail\"\n )\n voisine = voisine[cle]\n return voisine instanceof HTMLTableRowElement ? voisine : null\n}\n\n/**\n * À appeler juste avant qu'une ligne qui avait le focus (elle, ou un\n * dialogue ou un menu ouvert depuis elle) quitte le document : une fois la\n * ligne retirée, si personne n'a repris le focus, il va à la même cellule de\n * la ligne suivante (ou précédente), sinon au tableau. Sans cela, il tombe\n * sur la page.\n *\n * `rang` : l'index de la cellule qui avait le focus (`cellIndex`), -1 si\n * inconnu (la première commande de la ligne voisine).\n */\nexport function rendreFocusApresLigne(\n ligne: HTMLTableRowElement,\n rang: number\n) {\n const voisines = [\n ligneVoisine(ligne, \"nextElementSibling\"),\n ligneVoisine(ligne, \"previousElementSibling\"),\n ]\n const racine =\n ligne.closest<HTMLElement>('[data-slot=\"data-table\"]') ??\n ligne.closest<HTMLElement>('[data-slot=\"table-container\"]')\n // Après le retrait de la ligne et le retour de focus d'un dialogue fermé.\n setTimeout(() => {\n const focus = document.activeElement\n if (focus && focus !== document.body) return\n for (const voisine of voisines) {\n if (!voisine?.isConnected) continue\n const cellule = voisine.cells[rang] ?? voisine\n const cible = cellule.querySelector<HTMLElement>(FOCALISABLE)\n if (cible) return cible.focus()\n }\n if (racine?.isConnected) focaliserTableau(racine)\n })\n}\n"],"mappings":";AASA,SAAgBA,EAAiB,GAA4B;CAC3D,IAAI,CAACC,GAAQ;CACb,IAAMC,IAAaD,EAAO,cACxB,gDACF;CACA,IAAIC,GAAY,OAAOA,EAAW,MAAM;CAExC,AADKD,EAAO,aAAa,UAAU,MAAG,EAAO,WAAW,KACxDA,EAAO,MAAM;AACf;AAQA,SAASE,EACP,GACA,GAC4B;CAC5B,IAAIC,IAAUC,EAAMC;CACpB,OACEF,aAAmB,uBACnBA,EAAQ,QAAQ,SAAS,sBAEzB,IAAUA,EAAQE;CACpB,OAAOF,aAAmB,sBAAsBA,IAAU;AAC5D;AAYA,SAAgBG,EACd,GACA,GACA;CACA,IAAMC,IAAW,CACfL,EAAaE,GAAO,oBAAoB,GACxCF,EAAaE,GAAO,wBAAwB,CAC9C,GACMJ,IACJI,EAAM,QAAqB,4BAA0B,KACrDA,EAAM,QAAqB,iCAA+B;CAE5D,iBAAiB;EACf,IAAMI,IAAQ,SAAS;EACvB,IAAI,OAASA,MAAU,SAAS,OAChC;QAAK,IAAML,KAAWI,GAAU;IAC9B,IAAI,CAACJ,GAAS,aAAa;IAE3B,IAAMM,KADUN,EAAQ,MAAMO,MAASP,EAAA,CACjB,cAA2B,2FAAW;IAC5D,IAAIM,GAAO,OAAOA,EAAM,MAAM;GAChC;GACA,AAAIT,GAAQ,eAAaD,EAAiBC,CAAM;EADhD;CAEF,CAAC;AACH"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Unite } from '../../lib/format';
|
|
2
|
+
export { nombreFr, participe, uniteAccordee } from '../../lib/format';
|
|
3
|
+
/** Nom des éléments d'une liste, au singulier et au pluriel. */
|
|
4
|
+
export type DataTableUnite = Unite;
|
|
5
|
+
export declare const UNITE_PAR_DEFAUT: DataTableUnite;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { nombreFr as e, participe as t, uniteAccordee as n } from "../../lib/format.js";
|
|
2
|
+
// src/components/etic/data-table-format.ts
|
|
3
|
+
var r = {
|
|
4
|
+
singulier: "élément",
|
|
5
|
+
pluriel: "éléments"
|
|
6
|
+
};
|
|
7
|
+
export { r as UNITE_PAR_DEFAUT, e as nombreFr, t as participe, n as uniteAccordee };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=data-table-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-format.js","names":["UNITE_PAR_DEFAUT","nombreFr","participe","uniteAccordee"],"sources":["../../../src/components/etic/data-table-format.ts"],"sourcesContent":["// Textes chiffrés de la famille DataTable (compteur, proposition « tout\n// sélectionner », barre d'actions groupées). Les accords et le format des\n// nombres viennent du module commun `lib/format`, exporté aux applications.\n\nimport type { Unite } from \"@etic-ui/lib/format\"\n\nexport { nombreFr, participe, uniteAccordee } from \"@etic-ui/lib/format\"\n\n/** Nom des éléments d'une liste, au singulier et au pluriel. */\nexport type DataTableUnite = Unite\n\nexport const UNITE_PAR_DEFAUT: DataTableUnite = {\n singulier: \"élément\",\n pluriel: \"éléments\",\n}\n"],"mappings":";;AAWA,IAAaA,IAAmC;CAC9C,WAAW;CACX,SAAS;AACX"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RowData } from '@tanstack/react-table';
|
|
2
|
+
import { DataTableInstance } from './data-table';
|
|
3
|
+
interface DataTablePaginationCommun {
|
|
4
|
+
/** Nombres d'éléments par page proposés. 10, 25, 50 et 100 par défaut. */
|
|
5
|
+
limites?: readonly number[];
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Pagination par décalage, aux nombres de l'application (côté serveur). */
|
|
9
|
+
export interface DataTablePaginationDecalageProps extends DataTablePaginationCommun {
|
|
10
|
+
table?: never;
|
|
11
|
+
/** Nombre total d'éléments, toutes pages comprises. */
|
|
12
|
+
total: number;
|
|
13
|
+
/** Rang (à partir de 0) du premier élément de la page. */
|
|
14
|
+
decalage: number;
|
|
15
|
+
/** Nombre d'éléments par page. */
|
|
16
|
+
limite: number;
|
|
17
|
+
onDecalageChange: (decalage: number) => void;
|
|
18
|
+
/** Sans lui, pas de choix du nombre par page. Changer de taille ramène à
|
|
19
|
+
* la première page (`onDecalageChange(0)`). */
|
|
20
|
+
onLimiteChange?: (limite: number) => void;
|
|
21
|
+
}
|
|
22
|
+
/** Pagination côté client d'un `useDataTable({ paginationClient: true })` :
|
|
23
|
+
* elle lit et règle la page du tableau, sur les lignes filtrées. */
|
|
24
|
+
export interface DataTablePaginationTableProps<TData extends RowData> extends DataTablePaginationCommun {
|
|
25
|
+
table: DataTableInstance<TData>;
|
|
26
|
+
}
|
|
27
|
+
export type DataTablePaginationProps<TData extends RowData = RowData> = DataTablePaginationDecalageProps | DataTablePaginationTableProps<TData>;
|
|
28
|
+
/**
|
|
29
|
+
* Pagination par décalage (offset/limit, total connu) sur la Pagination de
|
|
30
|
+
* shadcn : précédente, fenêtre de pages, suivante, et le nombre de lignes par
|
|
31
|
+
* page (Select). Rien ne s'affiche quand tout tient sur une page de la plus
|
|
32
|
+
* petite taille. Avec `table`, celle d'une pagination côté client, comme la
|
|
33
|
+
* pagination du guide Data Table de shadcn.
|
|
34
|
+
*/
|
|
35
|
+
export declare function DataTablePagination<TData extends RowData>(props: DataTablePaginationProps<TData>): import("react").JSX.Element | null;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Button as e } from "../ui/button.js";
|
|
2
|
+
import { Pagination as t, PaginationContent as n, PaginationEllipsis as r, PaginationItem as i } from "../ui/pagination.js";
|
|
3
|
+
import { Select as a, SelectContent as o, SelectItem as s, SelectTrigger as c, SelectValue as l } from "../ui/select.js";
|
|
4
|
+
import { paginationDuTableau as u } from "./data-table.js";
|
|
5
|
+
import { cn as d } from "cn";
|
|
6
|
+
import { useEffect as f, useEffectEvent as p, useId as m } from "react";
|
|
7
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
8
|
+
import { ChevronLeftIcon as _, ChevronRightIcon as v } from "lucide-react";
|
|
9
|
+
// src/components/etic/data-table-pagination.tsx
|
|
10
|
+
function y(e, t) {
|
|
11
|
+
let n = [.../* @__PURE__ */ new Set([
|
|
12
|
+
1,
|
|
13
|
+
t,
|
|
14
|
+
e,
|
|
15
|
+
e - 1,
|
|
16
|
+
e + 1
|
|
17
|
+
])].filter((e) => e >= 1 && e <= t).sort((e, t) => e - t), r = [], i = 0;
|
|
18
|
+
for (let e of n) e - i > 1 && r.push("…"), r.push(e), i = e;
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
function b(e) {
|
|
22
|
+
if (!e.table) return /* @__PURE__ */ h(C, { ...e });
|
|
23
|
+
let { table: t, ...n } = e, r = u(t);
|
|
24
|
+
if (r.manuelle) return S(), null;
|
|
25
|
+
let { decalage: i, limite: a, total: o } = r;
|
|
26
|
+
return /* @__PURE__ */ h(C, {
|
|
27
|
+
...n,
|
|
28
|
+
total: o,
|
|
29
|
+
decalage: i,
|
|
30
|
+
limite: a,
|
|
31
|
+
onDecalageChange: (e) => t.setPageIndex(Math.floor(e / a)),
|
|
32
|
+
onLimiteChange: (e) => t.setPageSize(e),
|
|
33
|
+
changerTaille: (e) => t.setPagination({
|
|
34
|
+
pageIndex: 0,
|
|
35
|
+
pageSize: e
|
|
36
|
+
}),
|
|
37
|
+
ramenerAuDela: !1
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
var x = !1;
|
|
41
|
+
function S() {
|
|
42
|
+
x || (x = !0, console.warn("DataTablePagination : `table` sans `paginationClient` ne pagine rien. Passez `paginationClient: true` à useDataTable, ou les nombres (`total`, `decalage`, `limite`) d'une pagination côté serveur."));
|
|
43
|
+
}
|
|
44
|
+
function C({ total: u, decalage: b, limite: x, onDecalageChange: S, onLimiteChange: C, limites: w = [
|
|
45
|
+
10,
|
|
46
|
+
25,
|
|
47
|
+
50,
|
|
48
|
+
100
|
|
49
|
+
], className: T, ramenerAuDela: E = !0, changerTaille: D }) {
|
|
50
|
+
let O = m(), k = Math.max(1, Math.ceil(u / x)), A = Math.min(Math.floor(b / x) + 1, k), j = [.../* @__PURE__ */ new Set([...w, x])].sort((e, t) => e - t), M = C !== void 0 && u > j[0], N = (k - 1) * x, P = p(() => S(N));
|
|
51
|
+
if (f(() => {
|
|
52
|
+
E && u > 0 && b >= u && P();
|
|
53
|
+
}, [
|
|
54
|
+
E,
|
|
55
|
+
b,
|
|
56
|
+
u
|
|
57
|
+
]), k <= 1 && !M) return null;
|
|
58
|
+
let F = (e) => S((Math.min(Math.max(1, e), k) - 1) * x);
|
|
59
|
+
return /* @__PURE__ */ g("div", {
|
|
60
|
+
"data-slot": "data-table-pagination",
|
|
61
|
+
className: d("flex flex-wrap items-center justify-between gap-x-6 gap-y-2", T),
|
|
62
|
+
children: [M ? /* @__PURE__ */ g("div", {
|
|
63
|
+
className: "flex items-center gap-2",
|
|
64
|
+
children: [/* @__PURE__ */ h("span", {
|
|
65
|
+
id: O,
|
|
66
|
+
className: "text-sm font-medium",
|
|
67
|
+
children: "Lignes par page"
|
|
68
|
+
}), /* @__PURE__ */ g(a, {
|
|
69
|
+
value: String(x),
|
|
70
|
+
onValueChange: (e) => {
|
|
71
|
+
if (e !== null) {
|
|
72
|
+
if (D) return D(Number(e));
|
|
73
|
+
C(Number(e)), S(0);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
children: [/* @__PURE__ */ h(c, {
|
|
77
|
+
className: "w-[4.5rem]",
|
|
78
|
+
"aria-labelledby": O,
|
|
79
|
+
children: /* @__PURE__ */ h(l, {})
|
|
80
|
+
}), /* @__PURE__ */ h(o, {
|
|
81
|
+
side: "top",
|
|
82
|
+
children: j.map((e) => /* @__PURE__ */ h(s, {
|
|
83
|
+
value: String(e),
|
|
84
|
+
children: e
|
|
85
|
+
}, e))
|
|
86
|
+
})]
|
|
87
|
+
})]
|
|
88
|
+
}) : null, k > 1 ? /* @__PURE__ */ g(t, {
|
|
89
|
+
className: "mx-0 ml-auto w-auto",
|
|
90
|
+
children: [/* @__PURE__ */ g(n, { children: [
|
|
91
|
+
/* @__PURE__ */ h(i, { children: /* @__PURE__ */ g(e, {
|
|
92
|
+
variant: "ghost",
|
|
93
|
+
className: "pl-1.5!",
|
|
94
|
+
"aria-label": "Page précédente",
|
|
95
|
+
disabled: A === 1,
|
|
96
|
+
focusableWhenDisabled: !0,
|
|
97
|
+
onClick: () => F(A - 1),
|
|
98
|
+
children: [/* @__PURE__ */ h(_, { "data-icon": "inline-start" }), /* @__PURE__ */ h("span", {
|
|
99
|
+
className: "hidden sm:block",
|
|
100
|
+
children: "Précédente"
|
|
101
|
+
})]
|
|
102
|
+
}) }),
|
|
103
|
+
y(A, k).map((t, n) => /* @__PURE__ */ h(i, { children: t === "…" ? /* @__PURE__ */ h(r, {}) : /* @__PURE__ */ h(e, {
|
|
104
|
+
variant: t === A ? "outline" : "ghost",
|
|
105
|
+
size: "icon",
|
|
106
|
+
"aria-current": t === A ? "page" : void 0,
|
|
107
|
+
"aria-label": `Page ${t}`,
|
|
108
|
+
onClick: () => F(t),
|
|
109
|
+
children: t
|
|
110
|
+
}) }, t === "…" ? `…${n}` : t)),
|
|
111
|
+
/* @__PURE__ */ h(i, { children: /* @__PURE__ */ g(e, {
|
|
112
|
+
variant: "ghost",
|
|
113
|
+
className: "pr-1.5!",
|
|
114
|
+
"aria-label": "Page suivante",
|
|
115
|
+
disabled: A === k,
|
|
116
|
+
focusableWhenDisabled: !0,
|
|
117
|
+
onClick: () => F(A + 1),
|
|
118
|
+
children: [/* @__PURE__ */ h("span", {
|
|
119
|
+
className: "hidden sm:block",
|
|
120
|
+
children: "Suivante"
|
|
121
|
+
}), /* @__PURE__ */ h(v, { "data-icon": "inline-end" })]
|
|
122
|
+
}) })
|
|
123
|
+
] }), /* @__PURE__ */ h("p", {
|
|
124
|
+
className: "sr-only",
|
|
125
|
+
"aria-live": "polite",
|
|
126
|
+
"aria-atomic": "true",
|
|
127
|
+
children: `Page ${A} sur ${k}`
|
|
128
|
+
})]
|
|
129
|
+
}) : null]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
export { b as DataTablePagination };
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=data-table-pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-pagination.js","names":["fenetre","pages","nombre","courante","p","a","b","sortie","precedente","page","DataTablePagination","props","PaginationParDecalage","reste","pagination","paginationDuTableau","table","avertirPaginationManuelle","suivant","limite","suivante","averti","idTaille","useId","nombrePages","total","decalage","tailles","limites","choixTaille","onLimiteChange","decalageMax","ramener","useEffectEvent","onDecalageChange","useEffect","ramenerAuDela","allerA","cible","cn","className","Select","valeur","changerTaille","SelectTrigger","SelectValue","SelectContent","SelectItem","taille","Pagination","PaginationContent","PaginationItem","Button","ChevronLeftIcon","PaginationEllipsis","i","ChevronRightIcon"],"sources":["../../../src/components/etic/data-table-pagination.tsx"],"sourcesContent":["import { useEffect, useEffectEvent, useId } from \"react\"\nimport type { RowData } from \"@tanstack/react-table\"\nimport { cn } from \"cn\"\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\"\n\nimport { Button } from \"@etic-ui/components/ui/button\"\nimport {\n Pagination,\n PaginationContent,\n PaginationEllipsis,\n PaginationItem,\n} from \"@etic-ui/components/ui/pagination\"\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@etic-ui/components/ui/select\"\nimport {\n paginationDuTableau,\n type DataTableInstance,\n} from \"@etic-ui/components/etic/data-table\"\n\n/** Fenêtre de pages : la première, la dernière, la courante et ses voisines,\n * « … » pour les pages sautées. Page 6 sur 20 : 1 … 5 6 7 … 20. */\nfunction fenetre(courante: number, nombre: number): (number | \"…\")[] {\n const pages = [...new Set([1, nombre, courante, courante - 1, courante + 1])]\n .filter((p) => p >= 1 && p <= nombre)\n .sort((a, b) => a - b)\n const sortie: (number | \"…\")[] = []\n let precedente = 0\n for (const page of pages) {\n if (page - precedente > 1) sortie.push(\"…\")\n sortie.push(page)\n precedente = page\n }\n return sortie\n}\n\ninterface DataTablePaginationCommun {\n /** Nombres d'éléments par page proposés. 10, 25, 50 et 100 par défaut. */\n limites?: readonly number[]\n className?: string\n}\n\n/** Pagination par décalage, aux nombres de l'application (côté serveur). */\nexport interface DataTablePaginationDecalageProps extends DataTablePaginationCommun {\n table?: never\n /** Nombre total d'éléments, toutes pages comprises. */\n total: number\n /** Rang (à partir de 0) du premier élément de la page. */\n decalage: number\n /** Nombre d'éléments par page. */\n limite: number\n onDecalageChange: (decalage: number) => void\n /** Sans lui, pas de choix du nombre par page. Changer de taille ramène à\n * la première page (`onDecalageChange(0)`). */\n onLimiteChange?: (limite: number) => void\n}\n\n/** Pagination côté client d'un `useDataTable({ paginationClient: true })` :\n * elle lit et règle la page du tableau, sur les lignes filtrées. */\nexport interface DataTablePaginationTableProps<\n TData extends RowData,\n> extends DataTablePaginationCommun {\n table: DataTableInstance<TData>\n}\n\nexport type DataTablePaginationProps<TData extends RowData = RowData> =\n DataTablePaginationDecalageProps | DataTablePaginationTableProps<TData>\n\n/**\n * Pagination par décalage (offset/limit, total connu) sur la Pagination de\n * shadcn : précédente, fenêtre de pages, suivante, et le nombre de lignes par\n * page (Select). Rien ne s'affiche quand tout tient sur une page de la plus\n * petite taille. Avec `table`, celle d'une pagination côté client, comme la\n * pagination du guide Data Table de shadcn.\n */\nexport function DataTablePagination<TData extends RowData>(\n props: DataTablePaginationProps<TData>\n) {\n if (!props.table) return <PaginationParDecalage {...props} />\n const { table, ...reste } = props\n const pagination = paginationDuTableau(table)\n if (pagination.manuelle) {\n // Sans `paginationClient`, la table ne découpe rien : des numéros de\n // page qui ne changeraient pas les lignes seraient trompeurs.\n avertirPaginationManuelle()\n return null\n }\n const { decalage, limite, total } = pagination\n return (\n <PaginationParDecalage\n {...reste}\n total={total}\n decalage={decalage}\n limite={limite}\n onDecalageChange={(suivant) =>\n table.setPageIndex(Math.floor(suivant / limite))\n }\n onLimiteChange={(suivante) => table.setPageSize(suivante)}\n // Une seule mise à jour : taille et retour en première page ensemble.\n // Deux appels successifs (`setPageSize` puis `setPageIndex`) se\n // résoudraient, avec une pagination contrôlée, contre la même valeur\n // rendue, et le second effacerait la nouvelle taille.\n changerTaille={(suivante) =>\n table.setPagination({ pageIndex: 0, pageSize: suivante })\n }\n // `useDataTable` ramène déjà une page passée au-delà de la fin.\n ramenerAuDela={false}\n />\n )\n}\n\nlet averti = false\nfunction avertirPaginationManuelle() {\n if (averti) return\n averti = true\n console.warn(\n \"DataTablePagination : `table` sans `paginationClient` ne pagine rien. \" +\n \"Passez `paginationClient: true` à useDataTable, ou les nombres \" +\n \"(`total`, `decalage`, `limite`) d'une pagination côté serveur.\"\n )\n}\n\nfunction PaginationParDecalage({\n total,\n decalage,\n limite,\n onDecalageChange,\n onLimiteChange,\n limites = [10, 25, 50, 100],\n className,\n ramenerAuDela = true,\n changerTaille,\n}: Omit<DataTablePaginationDecalageProps, \"table\"> & {\n ramenerAuDela?: boolean\n /** Change la taille et revient à la première page en une fois (à la\n * place de `onLimiteChange` puis `onDecalageChange(0)`). */\n changerTaille?: (limite: number) => void\n}) {\n const idTaille = useId()\n const nombrePages = Math.max(1, Math.ceil(total / limite))\n const page = Math.min(Math.floor(decalage / limite) + 1, nombrePages)\n const tailles = [...new Set([...limites, limite])].sort((a, b) => a - b)\n const choixTaille = onLimiteChange !== undefined && total > tailles[0]\n\n // Décalage au-delà de la fin (dernière ligne de la dernière page\n // supprimée) : on ramène l'application sur la dernière page, sans quoi\n // elle afficherait une page vide sous un numéro de page surligné. Pas\n // tant que `total` vaut 0 : c'est souvent un total pas encore connu\n // (requête de la page suivante en cours, décalage lu dans l'URL), et le\n // ramener renverrait à la première page.\n const decalageMax = (nombrePages - 1) * limite\n const ramener = useEffectEvent(() => onDecalageChange(decalageMax))\n useEffect(() => {\n if (ramenerAuDela && total > 0 && decalage >= total) ramener()\n }, [ramenerAuDela, decalage, total])\n\n if (nombrePages <= 1 && !choixTaille) return null\n\n const allerA = (cible: number) =>\n onDecalageChange((Math.min(Math.max(1, cible), nombrePages) - 1) * limite)\n\n return (\n <div\n data-slot=\"data-table-pagination\"\n className={cn(\n \"flex flex-wrap items-center justify-between gap-x-6 gap-y-2\",\n className\n )}\n >\n {choixTaille ? (\n <div className=\"flex items-center gap-2\">\n <span id={idTaille} className=\"text-sm font-medium\">\n Lignes par page\n </span>\n <Select\n value={String(limite)}\n onValueChange={(valeur) => {\n if (valeur === null) return\n if (changerTaille) return changerTaille(Number(valeur))\n onLimiteChange(Number(valeur))\n onDecalageChange(0)\n }}\n >\n <SelectTrigger className=\"w-[4.5rem]\" aria-labelledby={idTaille}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent side=\"top\">\n {tailles.map((taille) => (\n <SelectItem key={taille} value={String(taille)}>\n {taille}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n ) : null}\n {nombrePages > 1 ? (\n <Pagination className=\"mx-0 ml-auto w-auto\">\n <PaginationContent>\n <PaginationItem>\n {/* Focalisable désactivé : arrivé en bout de liste au clavier,\n le focus reste sur le bouton au lieu de partir sur <body>. */}\n <Button\n variant=\"ghost\"\n className=\"pl-1.5!\"\n aria-label=\"Page précédente\"\n disabled={page === 1}\n focusableWhenDisabled\n onClick={() => allerA(page - 1)}\n >\n <ChevronLeftIcon data-icon=\"inline-start\" />\n <span className=\"hidden sm:block\">Précédente</span>\n </Button>\n </PaginationItem>\n {fenetre(page, nombrePages).map((p, i) => (\n <PaginationItem key={p === \"…\" ? `…${i}` : p}>\n {p === \"…\" ? (\n <PaginationEllipsis />\n ) : (\n <Button\n variant={p === page ? \"outline\" : \"ghost\"}\n size=\"icon\"\n aria-current={p === page ? \"page\" : undefined}\n aria-label={`Page ${p}`}\n onClick={() => allerA(p)}\n >\n {p}\n </Button>\n )}\n </PaginationItem>\n ))}\n <PaginationItem>\n <Button\n variant=\"ghost\"\n className=\"pr-1.5!\"\n aria-label=\"Page suivante\"\n disabled={page === nombrePages}\n focusableWhenDisabled\n onClick={() => allerA(page + 1)}\n >\n <span className=\"hidden sm:block\">Suivante</span>\n <ChevronRightIcon data-icon=\"inline-end\" />\n </Button>\n </PaginationItem>\n </PaginationContent>\n {/* Le focus reste sur la pagination, sous le tableau : la page\n atteinte est annoncée. */}\n <p className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {`Page ${page} sur ${nombrePages}`}\n </p>\n </Pagination>\n ) : null}\n </div>\n )\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
import { RowData } from '@tanstack/react-table';
|
|
3
|
+
import { DataTableUnite } from './data-table-format';
|
|
4
|
+
import { DataTableInstance } from './data-table';
|
|
5
|
+
interface DataTableCountCommun {
|
|
6
|
+
/** Nom des éléments. « élément », « éléments » par défaut. */
|
|
7
|
+
unite?: DataTableUnite;
|
|
8
|
+
/** Accorde « affichées » au féminin. */
|
|
9
|
+
feminin?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Compteur aux nombres donnés par l'application (pagination côté serveur). */
|
|
13
|
+
export interface DataTableCountNombresProps extends DataTableCountCommun {
|
|
14
|
+
table?: never;
|
|
15
|
+
/** Nombre total d'éléments, toutes pages comprises. */
|
|
16
|
+
total: number;
|
|
17
|
+
/** Rang (à partir de 0) du premier élément affiché. 0 par défaut. */
|
|
18
|
+
decalage?: number;
|
|
19
|
+
/** Nombre d'éléments affichés. */
|
|
20
|
+
nombre: number;
|
|
21
|
+
}
|
|
22
|
+
/** Compteur lu dans le tableau (pagination côté client de `useDataTable`) :
|
|
23
|
+
* lignes filtrées, page courante. */
|
|
24
|
+
export interface DataTableCountTableProps<TData extends RowData = RowData> extends DataTableCountCommun {
|
|
25
|
+
table: DataTableInstance<TData>;
|
|
26
|
+
}
|
|
27
|
+
export type DataTableCountProps<TData extends RowData = RowData> = DataTableCountNombresProps | DataTableCountTableProps<TData>;
|
|
28
|
+
/**
|
|
29
|
+
* Compteur d'une liste : « 128 éléments · 26–50 affichés ». C'est une zone
|
|
30
|
+
* de statut : après une recherche, un filtre ou un changement de page, le
|
|
31
|
+
* nouveau compte est annoncé sans déplacer le focus. Avec `table`, il lit
|
|
32
|
+
* les nombres de la pagination côté client.
|
|
33
|
+
*/
|
|
34
|
+
export declare function DataTableCount<TData extends RowData>(props: DataTableCountProps<TData>): import("react").JSX.Element;
|
|
35
|
+
export interface DataTableSelectFilterOption {
|
|
36
|
+
valeur: string;
|
|
37
|
+
libelle: string;
|
|
38
|
+
}
|
|
39
|
+
export interface DataTableSelectFilterProps {
|
|
40
|
+
/** Nom du filtre pour les lecteurs d'écran : « Filtrer par statut ». */
|
|
41
|
+
libelle: string;
|
|
42
|
+
/** Valeur choisie ; `null` = pas de filtre. */
|
|
43
|
+
valeur: string | null;
|
|
44
|
+
onValeurChange: (valeur: string | null) => void;
|
|
45
|
+
options: DataTableSelectFilterOption[];
|
|
46
|
+
/** Entrée sans filtre : « Tous les statuts ». */
|
|
47
|
+
libelleTous: string;
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
/** Filtre d'une liste : un Select de shadcn dont la première entrée retire
|
|
51
|
+
* le filtre. */
|
|
52
|
+
export declare function DataTableSelectFilter({ libelle, valeur, onValeurChange, options, libelleTous, className, }: DataTableSelectFilterProps): import("react").JSX.Element;
|
|
53
|
+
/** Attributs du champ de recherche que l'application peut ajouter. */
|
|
54
|
+
export type DataTableRechercheAttributs = Omit<ComponentProps<"input">, "value" | "defaultValue" | "onChange" | "type" | "ref">;
|
|
55
|
+
export interface DataTableToolbarProps<TData extends RowData = RowData> {
|
|
56
|
+
/** Champ de recherche, contrôlé (l'application temporise sa requête). */
|
|
57
|
+
recherche?: {
|
|
58
|
+
valeur: string;
|
|
59
|
+
onValeurChange: (valeur: string) => void;
|
|
60
|
+
placeholder?: string;
|
|
61
|
+
/** Nom du champ. « Rechercher » par défaut. */
|
|
62
|
+
libelle?: string;
|
|
63
|
+
/** Attributs ajoutés au champ (`name`, `data-*`…). Le champ porte déjà
|
|
64
|
+
* `autoComplete="off"` et les attributs qui écartent les gestionnaires
|
|
65
|
+
* de mots de passe ; ils peuvent être remplacés ici. */
|
|
66
|
+
attributs?: DataTableRechercheAttributs;
|
|
67
|
+
};
|
|
68
|
+
/** Filtres : `DataTableSelectFilter`… */
|
|
69
|
+
filtres?: ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* Nombre de filtres actifs. Fourni, il replie les filtres derrière un
|
|
72
|
+
* bouton « Filtres (n) » sur mobile, où ils s'empileraient sinon au-dessus
|
|
73
|
+
* des résultats, et affiche « Réinitialiser » s'il y en a.
|
|
74
|
+
*/
|
|
75
|
+
filtresActifs?: number;
|
|
76
|
+
/** Retire tous les filtres (bouton « Réinitialiser »). */
|
|
77
|
+
onReinitialiser?: () => void;
|
|
78
|
+
/** Compteur « N éléments · a–b affichés » : ses nombres, ou `{ table }`
|
|
79
|
+
* pour une pagination côté client. */
|
|
80
|
+
compteur?: DataTableCountProps<TData>;
|
|
81
|
+
/** À droite : `DataTableViewOptions`, bouton d'ajout… */
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
className?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Barre d'outils au-dessus d'un tableau, sur le modèle de celle de shadcn :
|
|
87
|
+
* recherche et filtres à gauche, compteur et commandes (colonnes…) à droite.
|
|
88
|
+
*/
|
|
89
|
+
export declare function DataTableToolbar<TData extends RowData = RowData>({ recherche, filtres, filtresActifs, onReinitialiser, compteur, children, className, }: DataTableToolbarProps<TData>): import("react").JSX.Element;
|
|
90
|
+
export {};
|