@proef/common-ui 2.3.0 → 2.6.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/dist/esm/legacy/components/molecules/DataTable/DataTable.js +195 -103
- package/dist/esm/legacy/components/molecules/DataTable/DataTable.js.map +1 -1
- package/dist/esm/v1/capabilities/overlay/useFloatingPanel.js +5 -2
- package/dist/esm/v1/capabilities/overlay/useFloatingPanel.js.map +1 -1
- package/dist/esm/v1/components/data/Pagination/Pagination.js +30 -26
- package/dist/esm/v1/components/data/Pagination/Pagination.js.map +1 -1
- package/dist/esm/v1/components/forms/FormField/FormField.js +3 -2
- package/dist/esm/v1/components/forms/FormField/FormField.js.map +1 -1
- package/dist/esm/v1/components/layout/AppShell/AppShell.js +8 -3
- package/dist/esm/v1/components/layout/AppShell/AppShell.js.map +1 -1
- package/dist/esm/v1/components/layout/Page/Page.js +1 -1
- package/dist/esm/v1/components/layout/Page/Page.js.map +1 -1
- package/dist/esm/v1/components/layout/PageHeader/PageHeader.js +21 -18
- package/dist/esm/v1/components/layout/PageHeader/PageHeader.js.map +1 -1
- package/dist/esm/v1/components/lists/ListFinder/ListFinder.js +16 -16
- package/dist/esm/v1/components/lists/ListFinder/ListFinder.js.map +1 -1
- package/dist/esm/v1/components/overlays/Dialog/Dialog.js +2 -2
- package/dist/esm/v1/components/overlays/Dialog/Dialog.js.map +1 -1
- package/dist/esm/v1/primitives/buttons/SegmentedControl/SegmentedControl.js +3 -3
- package/dist/esm/v1/primitives/buttons/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/esm/v1/primitives/display/Kpi/Kpi.js +6 -3
- package/dist/esm/v1/primitives/display/Kpi/Kpi.js.map +1 -1
- package/dist/esm/v1/primitives/forms/SelectInput/SelectInput.js +28 -8
- package/dist/esm/v1/primitives/forms/SelectInput/SelectInput.js.map +1 -1
- package/dist/esm/v1/primitives/lists/ListItem/ListItem.js +5 -5
- package/dist/esm/v1/primitives/lists/ListItem/ListItem.js.map +1 -1
- package/dist/esm/v1/primitives/navigation/Tabs/Tabs.js +97 -36
- package/dist/esm/v1/primitives/navigation/Tabs/Tabs.js.map +1 -1
- package/dist/style.components.css +1 -1
- package/dist/style.css +1 -1
- package/dist/style.layered.css +1 -1
- package/dist/types/legacy/components/molecules/DataTable/DataTable.d.ts +15 -1
- package/dist/types/v1/primitives/forms/SelectInput/SelectInput.d.ts +12 -0
- package/dist/types/v1/primitives/lists/ListItem/ListItem.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect, useMemo, useRef, useLayoutEffect, Fragment } from "react";
|
|
3
3
|
import { FilterChips } from "../../../../v1/primitives/display/FilterChips/FilterChips.js";
|
|
4
4
|
import { Pagination } from "../../../../v1/components/data/Pagination/Pagination.js";
|
|
@@ -48,6 +48,20 @@ const Layers = ({ size = 11, className }) => /* @__PURE__ */ jsxs("svg", { xmlns
|
|
|
48
48
|
] });
|
|
49
49
|
const Caret = ({ size = 11, className }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", className, children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) });
|
|
50
50
|
const Spinner = ({ size = 16, className }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", className: `animate-spin ${className ?? ""}`, "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) });
|
|
51
|
+
const MOBILE_QUERY = "(max-width: 639px)";
|
|
52
|
+
function useEcraEstreito() {
|
|
53
|
+
const ler = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(MOBILE_QUERY).matches;
|
|
54
|
+
const [estreito, setEstreito] = useState(ler);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (typeof window.matchMedia !== "function") return;
|
|
57
|
+
const mq = window.matchMedia(MOBILE_QUERY);
|
|
58
|
+
const mudar = () => setEstreito(mq.matches);
|
|
59
|
+
mudar();
|
|
60
|
+
mq.addEventListener?.("change", mudar);
|
|
61
|
+
return () => mq.removeEventListener?.("change", mudar);
|
|
62
|
+
}, []);
|
|
63
|
+
return estreito;
|
|
64
|
+
}
|
|
51
65
|
const EMPTY = "—";
|
|
52
66
|
const MAX_OPCOES_FILTRO = 50;
|
|
53
67
|
const DEFAULT_STICKY_WIDTH = 160;
|
|
@@ -210,6 +224,7 @@ function DataTable({
|
|
|
210
224
|
resizableColumns = true,
|
|
211
225
|
sortFromFilter = true,
|
|
212
226
|
filterMode = "excel",
|
|
227
|
+
filterStartsEmpty = false,
|
|
213
228
|
defaultSortKey,
|
|
214
229
|
defaultSortDir,
|
|
215
230
|
viewRef,
|
|
@@ -225,9 +240,11 @@ function DataTable({
|
|
|
225
240
|
onGroupByChange,
|
|
226
241
|
onSortChange,
|
|
227
242
|
onColumnFiltersChange,
|
|
228
|
-
scrollAffordance = false
|
|
243
|
+
scrollAffordance = false,
|
|
244
|
+
mobileCards = true
|
|
229
245
|
}) {
|
|
230
246
|
const L = { ...DEFAULT_LABELS, ...labels };
|
|
247
|
+
const estreito = useEcraEstreito();
|
|
231
248
|
const [larguras, setLarguras] = useState(() => {
|
|
232
249
|
if (!storageKey) return {};
|
|
233
250
|
try {
|
|
@@ -334,19 +351,27 @@ function DataTable({
|
|
|
334
351
|
} catch {
|
|
335
352
|
}
|
|
336
353
|
}, [columnFilters, rangeFilters, sort, groupByKeys, grupoControlado, storageKey]);
|
|
354
|
+
const posicionarPopup = () => {
|
|
355
|
+
if (!funilAberto) return;
|
|
356
|
+
const el = filterRefs.current.get(funilAberto);
|
|
357
|
+
if (!el) return;
|
|
358
|
+
const r = el.getBoundingClientRect();
|
|
359
|
+
const largura = Math.min(288, window.innerWidth * 0.8);
|
|
360
|
+
const left = Math.max(8, Math.min(r.left, window.innerWidth - largura - 8));
|
|
361
|
+
let top = r.bottom + 6;
|
|
362
|
+
const altura = popupRef.current?.offsetHeight ?? 0;
|
|
363
|
+
if (altura && top + altura > window.innerHeight - 8) {
|
|
364
|
+
const acima = r.top - 6 - altura;
|
|
365
|
+
top = acima >= 8 ? acima : Math.max(8, window.innerHeight - altura - 8);
|
|
366
|
+
}
|
|
367
|
+
setPopupPos((p) => p && p.top === top && p.left === left ? p : { top, left });
|
|
368
|
+
};
|
|
337
369
|
useLayoutEffect(() => {
|
|
338
370
|
if (!funilAberto) {
|
|
339
371
|
setPopupPos(null);
|
|
340
372
|
return;
|
|
341
373
|
}
|
|
342
|
-
const recalcular =
|
|
343
|
-
const el = filterRefs.current.get(funilAberto);
|
|
344
|
-
if (!el) return;
|
|
345
|
-
const r = el.getBoundingClientRect();
|
|
346
|
-
const largura = Math.min(288, window.innerWidth * 0.8);
|
|
347
|
-
const left = Math.max(8, Math.min(r.left, window.innerWidth - largura - 8));
|
|
348
|
-
setPopupPos({ top: r.bottom + 6, left });
|
|
349
|
-
};
|
|
374
|
+
const recalcular = posicionarPopup;
|
|
350
375
|
recalcular();
|
|
351
376
|
window.addEventListener("scroll", recalcular, true);
|
|
352
377
|
window.addEventListener("resize", recalcular);
|
|
@@ -510,6 +535,9 @@ function DataTable({
|
|
|
510
535
|
}
|
|
511
536
|
return { opts, total: correspondentes.length, correspondentes };
|
|
512
537
|
}, [openFilterOptions, openFilterOptionsLower, filterSearch, modoExcel]);
|
|
538
|
+
useLayoutEffect(() => {
|
|
539
|
+
if (popupPos) posicionarPopup();
|
|
540
|
+
});
|
|
513
541
|
const filtrar = (rows) => {
|
|
514
542
|
if (activeFilters.length === 0 && activeRanges.length === 0) return rows;
|
|
515
543
|
const predicados = activeFilters.flatMap(([key, sel]) => passaFiltro(key, sel) ?? []);
|
|
@@ -676,7 +704,7 @@ function DataTable({
|
|
|
676
704
|
if (!allData) onDataNeeded?.();
|
|
677
705
|
setSort((s) => s?.key === key ? s.dir === 1 ? { key, dir: -1 } : null : { key, dir: 1 });
|
|
678
706
|
};
|
|
679
|
-
const selecaoDaColuna = (key) => new Set(rascunho?.key === key ? rascunho.sel : columnFilters[key] ?? (modoExcel ? openFilterOptions : []));
|
|
707
|
+
const selecaoDaColuna = (key) => new Set(rascunho?.key === key ? rascunho.sel : columnFilters[key] ?? (modoExcel && !filterStartsEmpty ? openFilterOptions : []));
|
|
680
708
|
const aplicarSelecao = (key, sel) => setRascunho({ key, sel });
|
|
681
709
|
const confirmarSelecao = (key) => {
|
|
682
710
|
if (rascunho?.key === key) {
|
|
@@ -688,7 +716,7 @@ function DataTable({
|
|
|
688
716
|
};
|
|
689
717
|
const gravarSelecao = (key, sel) => mudarFiltrosCol((prev) => {
|
|
690
718
|
const proximo = { ...prev };
|
|
691
|
-
if (modoExcel && sel.size === openFilterOptions.length) delete proximo[key];
|
|
719
|
+
if (modoExcel && (sel.size === openFilterOptions.length || filterStartsEmpty && sel.size === 0)) delete proximo[key];
|
|
692
720
|
else proximo[key] = sel;
|
|
693
721
|
return proximo;
|
|
694
722
|
});
|
|
@@ -931,7 +959,7 @@ function DataTable({
|
|
|
931
959
|
),
|
|
932
960
|
/* @__PURE__ */ jsxs("div", { className: "max-h-64 overflow-y-auto overflow-x-hidden space-y-0.5", children: [
|
|
933
961
|
modoExcel && opts.length > 0 && (() => {
|
|
934
|
-
const marcados = opcoesVisiveis.correspondentes.filter((v) => sel ? sel.has(v) :
|
|
962
|
+
const marcados = opcoesVisiveis.correspondentes.filter((v) => sel ? sel.has(v) : !filterStartsEmpty).length;
|
|
935
963
|
const todos = marcados === opcoesVisiveis.correspondentes.length;
|
|
936
964
|
const alguns = marcados > 0 && !todos;
|
|
937
965
|
return /* @__PURE__ */ jsxs(
|
|
@@ -956,7 +984,7 @@ function DataTable({
|
|
|
956
984
|
);
|
|
957
985
|
})(),
|
|
958
986
|
opts.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-[11px] text-slate-400 text-center py-3", children: L.noOptions }) : opts.map((v) => {
|
|
959
|
-
const checked = sel ? sel.has(v) : modoExcel;
|
|
987
|
+
const checked = sel ? sel.has(v) : modoExcel && !filterStartsEmpty;
|
|
960
988
|
return /* @__PURE__ */ jsxs(
|
|
961
989
|
"button",
|
|
962
990
|
{
|
|
@@ -1131,10 +1159,71 @@ function DataTable({
|
|
|
1131
1159
|
!recolhido && (no.filhos.length > 0 ? renderGrupos(no.filhos, nivel + 1) : no.items.map((row) => renderLinha(row, indicePorLinha.get(row) ?? 0)))
|
|
1132
1160
|
] }, no.path);
|
|
1133
1161
|
});
|
|
1162
|
+
const renderCartoes = () => {
|
|
1163
|
+
const vazio = /* @__PURE__ */ jsx("span", { className: "text-slate-400", children: EMPTY });
|
|
1164
|
+
const conteudo = (row, c) => c.render ? c.render(row) : rawValue(row, c) ?? vazio;
|
|
1165
|
+
const [principal, ...resto] = columns;
|
|
1166
|
+
const campos = resto.filter((c) => c.label);
|
|
1167
|
+
const semValor = (row, c) => {
|
|
1168
|
+
if (!c.value && !(c.key in row)) return false;
|
|
1169
|
+
const v = rawValue(row, c);
|
|
1170
|
+
return v === null || v === "";
|
|
1171
|
+
};
|
|
1172
|
+
const acoes = resto.filter((c) => !c.label);
|
|
1173
|
+
const aviso = (texto) => /* @__PURE__ */ jsx("div", { className: "py-12 text-center text-sm text-slate-400", children: texto });
|
|
1174
|
+
return /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 text-[13px] dark:text-slate-200", children: isLoading || aEsperarDataset ? aviso(
|
|
1175
|
+
/* @__PURE__ */ jsxs("span", { role: "status", "aria-live": "polite", className: "inline-flex items-center gap-2", children: [
|
|
1176
|
+
/* @__PURE__ */ jsx(Spinner, { size: 16, className: "text-proef-blue dark:text-proef-turquoise" }),
|
|
1177
|
+
L.loading
|
|
1178
|
+
] })
|
|
1179
|
+
) : sorted.length === 0 ? aviso(
|
|
1180
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1181
|
+
emptyIcon && /* @__PURE__ */ jsx("div", { className: "flex justify-center mb-2", children: emptyIcon }),
|
|
1182
|
+
/* @__PURE__ */ jsx("p", { className: "m-0", children: L.empty }),
|
|
1183
|
+
emptySubLabel && /* @__PURE__ */ jsx("p", { className: "m-0 text-xs mt-1", children: emptySubLabel })
|
|
1184
|
+
] })
|
|
1185
|
+
) : /* @__PURE__ */ jsx("ul", { className: "m-0 list-none p-0 divide-y divide-slate-100 dark:divide-slate-800", children: pageData.map((row, i) => {
|
|
1186
|
+
const k = chaveDe(row, i);
|
|
1187
|
+
const marcada = selectable && selectedKeys.has(k);
|
|
1188
|
+
const selecionavel = !!selectable && podeSelecionar(row);
|
|
1189
|
+
return /* @__PURE__ */ jsxs(
|
|
1190
|
+
"li",
|
|
1191
|
+
{
|
|
1192
|
+
onClick: () => onRowClick?.(row),
|
|
1193
|
+
className: `px-3 py-3 space-y-1.5 ${onRowClick ? "cursor-pointer active:bg-slate-100 dark:active:bg-slate-800" : ""} ${marcada ? "bg-proef-turquoise/5" : ""} ${rowClassName?.(row) ?? ""}`,
|
|
1194
|
+
children: [
|
|
1195
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
1196
|
+
selectable && /* @__PURE__ */ jsx(
|
|
1197
|
+
"span",
|
|
1198
|
+
{
|
|
1199
|
+
role: "checkbox",
|
|
1200
|
+
"aria-checked": !!marcada,
|
|
1201
|
+
"aria-disabled": !selecionavel || void 0,
|
|
1202
|
+
onClick: (e) => {
|
|
1203
|
+
e.stopPropagation();
|
|
1204
|
+
if (selecionavel) alternarLinha(k);
|
|
1205
|
+
},
|
|
1206
|
+
className: `mt-0.5 w-4 h-4 shrink-0 flex items-center justify-center border rounded ${marcada ? "bg-proef-navy dark:bg-proef-turquoise border-proef-navy dark:border-proef-turquoise text-white dark:text-proef-navy" : "border-slate-300 dark:border-slate-600"} ${selecionavel ? "" : "opacity-40"}`,
|
|
1207
|
+
children: marcada && /* @__PURE__ */ jsx("span", { className: "text-[9px] leading-none", children: "✓" })
|
|
1208
|
+
}
|
|
1209
|
+
),
|
|
1210
|
+
principal && /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1 font-semibold break-words", children: conteudo(row, principal) }),
|
|
1211
|
+
acoes.length > 0 && /* @__PURE__ */ jsx("div", { className: "-my-1 flex shrink-0 items-center gap-1", onClick: (e) => e.stopPropagation(), children: acoes.map((c) => /* @__PURE__ */ jsx(Fragment, { children: conteudo(row, c) }, c.key)) })
|
|
1212
|
+
] }),
|
|
1213
|
+
campos.filter((c) => !semValor(row, c)).map((c) => /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
1214
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] uppercase tracking-wide text-slate-500 dark:text-slate-400 pt-px", children: c.label }),
|
|
1215
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 text-right break-words", children: conteudo(row, c) })
|
|
1216
|
+
] }, c.key))
|
|
1217
|
+
]
|
|
1218
|
+
},
|
|
1219
|
+
k
|
|
1220
|
+
);
|
|
1221
|
+
}) }) });
|
|
1222
|
+
};
|
|
1134
1223
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1135
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 mb-2.5", children: [
|
|
1136
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs text-slate-500 dark:text-slate-400", children: isLoading ? "" : L.results.replace("{count}", String(totalResultados)) }),
|
|
1137
|
-
/* @__PURE__ */ jsxs("div", { className: "ml-auto flex flex-wrap items-center justify-end gap-2", children: [
|
|
1224
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 mb-2.5 max-sm:[&>div>:has(input[type=search])]:order-first max-sm:[&>div>:has(input[type=search])]:w-full", children: [
|
|
1225
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-slate-500 dark:text-slate-400 max-sm:mr-auto", children: isLoading ? "" : L.results.replace("{count}", String(totalResultados)) }),
|
|
1226
|
+
/* @__PURE__ */ jsxs("div", { className: "ml-auto flex flex-wrap items-center justify-end gap-2 max-sm:contents", children: [
|
|
1138
1227
|
extraToolbar,
|
|
1139
1228
|
exportFileName && sorted.length > 0 && // Mesmo aspeto do botão Colunas ao lado (o navy cheio competia com as ações da página).
|
|
1140
1229
|
/* @__PURE__ */ jsxs(
|
|
@@ -1149,7 +1238,7 @@ function DataTable({
|
|
|
1149
1238
|
/* @__PURE__ */ jsx("polyline", { points: "7 10 12 15 17 10" }),
|
|
1150
1239
|
/* @__PURE__ */ jsx("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
|
|
1151
1240
|
] }),
|
|
1152
|
-
L.export
|
|
1241
|
+
/* @__PURE__ */ jsx("span", { className: "max-sm:sr-only", children: L.export })
|
|
1153
1242
|
]
|
|
1154
1243
|
}
|
|
1155
1244
|
)
|
|
@@ -1203,95 +1292,98 @@ function DataTable({
|
|
|
1203
1292
|
clearAllLabel: L.clearAll
|
|
1204
1293
|
}
|
|
1205
1294
|
),
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
{
|
|
1217
|
-
|
|
1218
|
-
className: `appearance-none cursor-pointer w-4 h-4 flex items-center justify-center border transition-colors rounded ${todasVisiveisMarcadas ? "bg-proef-navy dark:bg-proef-turquoise border-proef-navy dark:border-proef-turquoise text-white dark:text-proef-navy" : algumaVisivelMarcada ? "bg-slate-300 dark:bg-slate-600 border-slate-300 dark:border-slate-600 text-white" : "bg-white dark:bg-slate-900 border-slate-300 dark:border-slate-600 hover:border-slate-400 dark:hover:border-slate-500"}`,
|
|
1219
|
-
children: (todasVisiveisMarcadas || algumaVisivelMarcada) && /* @__PURE__ */ jsx("span", { className: "text-[9px] leading-none", children: "✓" })
|
|
1220
|
-
}
|
|
1221
|
-
) }),
|
|
1222
|
-
columns.map((c) => {
|
|
1223
|
-
const podeOrdenar = c.sortable !== false;
|
|
1224
|
-
const podeAgrupar = agrupavel(c);
|
|
1225
|
-
const agrupada = groupByKeys.includes(c.key);
|
|
1226
|
-
return /* @__PURE__ */ jsxs(
|
|
1227
|
-
"th",
|
|
1295
|
+
mobileCards && estreito && !isGrouped ? renderCartoes() : (
|
|
1296
|
+
/* rounded-xl: os mesmos cantos dos cartões da biblioteca (Ui.tsx) e das tabelas dos portais. */
|
|
1297
|
+
/* @__PURE__ */ jsx(
|
|
1298
|
+
"div",
|
|
1299
|
+
{
|
|
1300
|
+
className: `overflow-auto rounded-xl border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 ${scrollAffordance ? "outline-none focus-visible:ring-2 focus-visible:ring-proef-blue dark:focus-visible:ring-proef-turquoise" : ""}`,
|
|
1301
|
+
style: { maxHeight },
|
|
1302
|
+
...scrollAffordance ? { tabIndex: 0, role: "region", "aria-label": L.scrollRegion ?? DEFAULT_LABELS.scrollRegion, onKeyDown: rolarComTeclado } : {},
|
|
1303
|
+
children: /* @__PURE__ */ jsxs("table", { className: "w-full text-[13px] border-collapse dark:text-slate-200", children: [
|
|
1304
|
+
/* @__PURE__ */ jsx("thead", { className: "sticky top-0 z-[2]", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1305
|
+
selectable && /* @__PURE__ */ jsx("th", { className: "bg-slate-50 dark:bg-slate-800 px-3 py-2.5 border-b border-slate-200 dark:border-slate-700 w-10 sticky left-0 z-[3]", children: /* @__PURE__ */ jsx(
|
|
1306
|
+
"button",
|
|
1228
1307
|
{
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
"button",
|
|
1254
|
-
{
|
|
1255
|
-
onClick: () => toggleSort(c.key),
|
|
1256
|
-
className: "appearance-none bg-transparent border-0 cursor-pointer p-0 uppercase tracking-wide text-slate-500 dark:text-slate-400 hover:text-proef-blue dark:hover:text-proef-turquoise font-semibold",
|
|
1257
|
-
children: [
|
|
1258
|
-
c.label,
|
|
1259
|
-
sort?.key === c.key && /* @__PURE__ */ jsx("span", { className: "ml-1", children: sort.dir === 1 ? "▲" : "▼" })
|
|
1260
|
-
]
|
|
1261
|
-
}
|
|
1262
|
-
) : /* @__PURE__ */ jsx("span", { children: c.label }),
|
|
1263
|
-
podeAgrupar && /* @__PURE__ */ jsx(
|
|
1264
|
-
"button",
|
|
1308
|
+
onClick: alternarTodas,
|
|
1309
|
+
className: `appearance-none cursor-pointer w-4 h-4 flex items-center justify-center border transition-colors rounded ${todasVisiveisMarcadas ? "bg-proef-navy dark:bg-proef-turquoise border-proef-navy dark:border-proef-turquoise text-white dark:text-proef-navy" : algumaVisivelMarcada ? "bg-slate-300 dark:bg-slate-600 border-slate-300 dark:border-slate-600 text-white" : "bg-white dark:bg-slate-900 border-slate-300 dark:border-slate-600 hover:border-slate-400 dark:hover:border-slate-500"}`,
|
|
1310
|
+
children: (todasVisiveisMarcadas || algumaVisivelMarcada) && /* @__PURE__ */ jsx("span", { className: "text-[9px] leading-none", children: "✓" })
|
|
1311
|
+
}
|
|
1312
|
+
) }),
|
|
1313
|
+
columns.map((c) => {
|
|
1314
|
+
const podeOrdenar = c.sortable !== false;
|
|
1315
|
+
const podeAgrupar = agrupavel(c);
|
|
1316
|
+
const agrupada = groupByKeys.includes(c.key);
|
|
1317
|
+
return /* @__PURE__ */ jsxs(
|
|
1318
|
+
"th",
|
|
1319
|
+
{
|
|
1320
|
+
style: {
|
|
1321
|
+
...c.width ? { minWidth: c.width } : {},
|
|
1322
|
+
...larguras[c.key] ? { width: larguras[c.key], minWidth: larguras[c.key], maxWidth: larguras[c.key] } : {},
|
|
1323
|
+
...estiloPreso(c) ?? {}
|
|
1324
|
+
},
|
|
1325
|
+
className: `group/th relative bg-slate-50 dark:bg-slate-800 text-[11.5px] uppercase tracking-wide text-slate-500 dark:text-slate-400 font-semibold px-3 py-2.5 border-b border-slate-200 dark:border-slate-700 whitespace-nowrap select-none ${alignClass(
|
|
1326
|
+
c.align
|
|
1327
|
+
)} ${c.sticky ? `sticky z-[3] bg-slate-50 dark:bg-slate-800 ${c.sticky === "right" ? "border-l border-slate-200 dark:border-slate-700" : ""}` : ""} ${c.headerClassName ?? ""}`,
|
|
1328
|
+
children: [
|
|
1329
|
+
resizableColumns && // Pega no limite direito: arrastar redimensiona; duplo clique repõe a largura automática
|
|
1330
|
+
/* @__PURE__ */ jsx(
|
|
1331
|
+
"span",
|
|
1265
1332
|
{
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1333
|
+
role: "separator",
|
|
1334
|
+
"aria-orientation": "vertical",
|
|
1335
|
+
title: L.resizeColumn,
|
|
1336
|
+
onMouseDown: (e) => iniciarResize(e, c.key),
|
|
1337
|
+
onDoubleClick: () => reporLargura(c.key),
|
|
1338
|
+
onClick: (e) => e.stopPropagation(),
|
|
1339
|
+
className: "absolute right-0 top-0 z-[4] h-full w-1.5 cursor-col-resize bg-transparent hover:bg-proef-blue/40 group-hover/th:bg-slate-300/60 dark:group-hover/th:bg-slate-600/60"
|
|
1270
1340
|
}
|
|
1271
1341
|
),
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1342
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1343
|
+
podeOrdenar ? /* @__PURE__ */ jsxs(
|
|
1344
|
+
"button",
|
|
1345
|
+
{
|
|
1346
|
+
onClick: () => toggleSort(c.key),
|
|
1347
|
+
className: "appearance-none bg-transparent border-0 cursor-pointer p-0 uppercase tracking-wide text-slate-500 dark:text-slate-400 hover:text-proef-blue dark:hover:text-proef-turquoise font-semibold",
|
|
1348
|
+
children: [
|
|
1349
|
+
c.label,
|
|
1350
|
+
sort?.key === c.key && /* @__PURE__ */ jsx("span", { className: "ml-1", children: sort.dir === 1 ? "▲" : "▼" })
|
|
1351
|
+
]
|
|
1352
|
+
}
|
|
1353
|
+
) : /* @__PURE__ */ jsx("span", { children: c.label }),
|
|
1354
|
+
podeAgrupar && /* @__PURE__ */ jsx(
|
|
1355
|
+
"button",
|
|
1356
|
+
{
|
|
1357
|
+
onClick: () => alternarGrupo(c.key),
|
|
1358
|
+
title: (agrupada ? L.ungroup : L.groupBy).replace("{label}", c.label),
|
|
1359
|
+
className: `appearance-none bg-transparent border-0 cursor-pointer p-0.5 transition-colors ${agrupada ? "text-violet-600 dark:text-violet-300" : "text-slate-300 dark:text-slate-600 hover:text-slate-500 dark:hover:text-slate-300"}`,
|
|
1360
|
+
children: /* @__PURE__ */ jsx(Layers, { size: 10 })
|
|
1361
|
+
}
|
|
1362
|
+
),
|
|
1363
|
+
botaoFunil(c)
|
|
1364
|
+
] }),
|
|
1365
|
+
c.headerExtra && /* @__PURE__ */ jsx("div", { className: "mt-0.5 normal-case font-normal tracking-normal", children: c.headerExtra(filtered) })
|
|
1366
|
+
]
|
|
1367
|
+
},
|
|
1368
|
+
c.key
|
|
1369
|
+
);
|
|
1370
|
+
})
|
|
1371
|
+
] }) }),
|
|
1372
|
+
/* @__PURE__ */ jsx("tbody", { children: isLoading ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: nColunas, className: "py-16 text-center text-sm font-bold uppercase tracking-widest text-slate-400", children: /* @__PURE__ */ jsxs("div", { role: "status", "aria-live": "polite", className: "inline-flex items-center gap-2", children: [
|
|
1373
|
+
/* @__PURE__ */ jsx(Spinner, { size: 16, className: "text-proef-blue dark:text-proef-turquoise" }),
|
|
1374
|
+
/* @__PURE__ */ jsx("span", { children: L.loading })
|
|
1375
|
+
] }) }) }) : aEsperarDataset ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: nColunas, className: "py-16 text-center text-sm font-bold uppercase tracking-widest text-slate-400", children: L.loading }) }) : isGrouped ? grupos.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: nColunas, className: "py-16 text-center text-sm text-slate-400", children: L.empty }) }) : renderGrupos(grupos, 0) : sorted.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs("td", { colSpan: nColunas, className: "py-16 text-center", children: [
|
|
1376
|
+
emptyIcon && /* @__PURE__ */ jsx("div", { className: "flex justify-center mb-2", children: emptyIcon }),
|
|
1377
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-slate-400", children: L.empty }),
|
|
1378
|
+
emptySubLabel && /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 mt-1", children: emptySubLabel })
|
|
1379
|
+
] }) }) : pageData.map((row, i) => renderLinha(row, i)) }),
|
|
1380
|
+
totalRow && !isLoading && !aEsperarDataset && sorted.length > 0 && /* @__PURE__ */ jsx("tfoot", { className: "sticky bottom-0 z-[2]", children: /* @__PURE__ */ jsxs("tr", { className: "bg-slate-100 dark:bg-slate-800 font-black text-slate-800 dark:text-slate-100", children: [
|
|
1381
|
+
/* @__PURE__ */ jsx("td", { colSpan: colunasRotuloGrupo, className: "px-3 py-2 border-t-2 border-slate-200 dark:border-slate-700 text-[10px] uppercase tracking-widest", children: L.total }),
|
|
1382
|
+
colunasComValor.map((c) => /* @__PURE__ */ jsx("td", { className: `px-3 py-2 border-t-2 border-slate-200 dark:border-slate-700 whitespace-nowrap text-xs ${alignClass(c.align)}`, children: c.groupAggregate?.(sorted) }, c.key))
|
|
1383
|
+
] }) })
|
|
1384
|
+
] })
|
|
1385
|
+
}
|
|
1386
|
+
)
|
|
1295
1387
|
),
|
|
1296
1388
|
!isLoading && paginando && (totalPages > 1 || (pageSizeOptions?.length ?? 0) > 0) && /* @__PURE__ */ jsx(
|
|
1297
1389
|
Pagination,
|