@proef/common-ui 2.2.6 → 2.5.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/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/legacy/components/charts/Charts.js +52 -192
- package/dist/esm/legacy/components/charts/Charts.js.map +1 -1
- package/dist/esm/legacy/components/molecules/DataTable/DataTable.js +252 -115
- package/dist/esm/legacy/components/molecules/DataTable/DataTable.js.map +1 -1
- package/dist/esm/legacy/components/organisms/GanttChart/GanttChart.js +7 -4
- package/dist/esm/legacy/components/organisms/GanttChart/GanttChart.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/Charts/Charts.js +301 -0
- package/dist/esm/v1/components/data/Charts/Charts.js.map +1 -0
- 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 +5 -2
- package/dist/esm/v1/components/overlays/Dialog/Dialog.js.map +1 -1
- package/dist/esm/v1/components/tables/Table/ColumnFilter.js +3 -1
- package/dist/esm/v1/components/tables/Table/ColumnFilter.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 +31 -9
- 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/theme.css +28 -0
- package/dist/types/legacy/components/charts/Charts.d.ts +14 -11
- package/dist/types/legacy/components/molecules/DataTable/DataTable.d.ts +12 -1
- package/dist/types/legacy/components/organisms/GanttChart/GanttChart.d.ts +15 -1
- package/dist/types/legacy/exports/organisms.d.ts +1 -1
- package/dist/types/v1/components/data/Charts/Charts.d.ts +103 -0
- package/dist/types/v1/index.d.ts +2 -0
- 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";
|
|
@@ -37,7 +37,9 @@ const DEFAULT_LABELS = {
|
|
|
37
37
|
clearGroups: "Clear grouping",
|
|
38
38
|
perPage: "Per page",
|
|
39
39
|
selectAll: "(Select all)",
|
|
40
|
-
selectAllResults: "(Select results)"
|
|
40
|
+
selectAllResults: "(Select results)",
|
|
41
|
+
cancel: "Cancel",
|
|
42
|
+
confirm: "Confirm"
|
|
41
43
|
};
|
|
42
44
|
const Funnel = ({ size = 12, 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, children: /* @__PURE__ */ jsx("path", { d: "M22 3H2l8 9.46V19l4 2v-8.54L22 3z" }) });
|
|
43
45
|
const Layers = ({ size = 11, className }) => /* @__PURE__ */ jsxs("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, children: [
|
|
@@ -46,6 +48,20 @@ const Layers = ({ size = 11, className }) => /* @__PURE__ */ jsxs("svg", { xmlns
|
|
|
46
48
|
] });
|
|
47
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" }) });
|
|
48
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
|
+
}
|
|
49
65
|
const EMPTY = "—";
|
|
50
66
|
const MAX_OPCOES_FILTRO = 50;
|
|
51
67
|
const DEFAULT_STICKY_WIDTH = 160;
|
|
@@ -136,14 +152,18 @@ function valorParaIntervalo(row, col) {
|
|
|
136
152
|
const v = rawValue(row, col);
|
|
137
153
|
return col.sortType === "date" ? timestampDeData(v) : Number(v);
|
|
138
154
|
}
|
|
155
|
+
function csvValue(row, col) {
|
|
156
|
+
const v = rawValue(row, col);
|
|
157
|
+
if (v == null) return "";
|
|
158
|
+
if (typeof v === "number") return Number.isInteger(v) ? String(v) : String(v).replace(".", ",");
|
|
159
|
+
return v === "[object Object]" ? "" : v;
|
|
160
|
+
}
|
|
139
161
|
function toCsv(columns, rows) {
|
|
140
|
-
const esc = (
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const body = rows.map((r) => columns.map((c) => esc(rawValue(r, c))).join(",")).join("\n");
|
|
146
|
-
return `${head}
|
|
162
|
+
const esc = (s) => /[";\n\r]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
|
|
163
|
+
const cols = columns.filter((c) => rows.some((r) => csvValue(r, c) !== ""));
|
|
164
|
+
const head = cols.map((c) => esc(c.label)).join(";");
|
|
165
|
+
const body = rows.map((r) => cols.map((c) => esc(csvValue(r, c))).join(";")).join("\r\n");
|
|
166
|
+
return `${head}\r
|
|
147
167
|
${body}`;
|
|
148
168
|
}
|
|
149
169
|
const ordenarRotulos = (a, b) => a === EMPTY ? 1 : b === EMPTY ? -1 : COLLATOR.compare(a, b);
|
|
@@ -219,9 +239,11 @@ function DataTable({
|
|
|
219
239
|
onGroupByChange,
|
|
220
240
|
onSortChange,
|
|
221
241
|
onColumnFiltersChange,
|
|
222
|
-
scrollAffordance = false
|
|
242
|
+
scrollAffordance = false,
|
|
243
|
+
mobileCards = true
|
|
223
244
|
}) {
|
|
224
245
|
const L = { ...DEFAULT_LABELS, ...labels };
|
|
246
|
+
const estreito = useEcraEstreito();
|
|
225
247
|
const [larguras, setLarguras] = useState(() => {
|
|
226
248
|
if (!storageKey) return {};
|
|
227
249
|
try {
|
|
@@ -308,6 +330,10 @@ function DataTable({
|
|
|
308
330
|
const [selectedKeys, setSelectedKeys] = useState(() => new Set(selecaoInicial ?? []));
|
|
309
331
|
const [openFilter, setOpenFilter] = useState(null);
|
|
310
332
|
const [filterSearch, setFilterSearch] = useState("");
|
|
333
|
+
const [rascunho, setRascunho] = useState(null);
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
setRascunho(null);
|
|
336
|
+
}, [openFilter]);
|
|
311
337
|
const filterRefs = useRef(/* @__PURE__ */ new Map());
|
|
312
338
|
const popupRef = useRef(null);
|
|
313
339
|
const [popupPos, setPopupPos] = useState(null);
|
|
@@ -666,8 +692,17 @@ function DataTable({
|
|
|
666
692
|
if (!allData) onDataNeeded?.();
|
|
667
693
|
setSort((s) => s?.key === key ? s.dir === 1 ? { key, dir: -1 } : null : { key, dir: 1 });
|
|
668
694
|
};
|
|
669
|
-
const selecaoDaColuna = (key) => new Set(columnFilters[key] ?? (modoExcel ? openFilterOptions : []));
|
|
670
|
-
const aplicarSelecao = (key, sel) =>
|
|
695
|
+
const selecaoDaColuna = (key) => new Set(rascunho?.key === key ? rascunho.sel : columnFilters[key] ?? (modoExcel ? openFilterOptions : []));
|
|
696
|
+
const aplicarSelecao = (key, sel) => setRascunho({ key, sel });
|
|
697
|
+
const confirmarSelecao = (key) => {
|
|
698
|
+
if (rascunho?.key === key) {
|
|
699
|
+
if (!allData) onDataNeeded?.();
|
|
700
|
+
gravarSelecao(key, rascunho.sel);
|
|
701
|
+
}
|
|
702
|
+
setOpenFilter(null);
|
|
703
|
+
setFilterSearch("");
|
|
704
|
+
};
|
|
705
|
+
const gravarSelecao = (key, sel) => mudarFiltrosCol((prev) => {
|
|
671
706
|
const proximo = { ...prev };
|
|
672
707
|
if (modoExcel && sel.size === openFilterOptions.length) delete proximo[key];
|
|
673
708
|
else proximo[key] = sel;
|
|
@@ -703,6 +738,7 @@ function DataTable({
|
|
|
703
738
|
});
|
|
704
739
|
};
|
|
705
740
|
const clearColumnFilter = (key) => {
|
|
741
|
+
setRascunho(null);
|
|
706
742
|
mudarFiltrosCol((prev) => {
|
|
707
743
|
const n = { ...prev };
|
|
708
744
|
delete n[key];
|
|
@@ -724,8 +760,9 @@ function DataTable({
|
|
|
724
760
|
};
|
|
725
761
|
const temFiltro = (key) => (modoExcel ? columnFilters[key] !== void 0 : (columnFilters[key]?.size ?? 0) > 0) || temIntervalo(key);
|
|
726
762
|
const handleExport = () => {
|
|
727
|
-
|
|
728
|
-
|
|
763
|
+
const linhas = allData && !isClientMode ? ordenar(filtrar(allData)) : sorted;
|
|
764
|
+
if (onExport) return onExport(linhas);
|
|
765
|
+
const csv = toCsv(columns, linhas);
|
|
729
766
|
const blob = new Blob([`\uFEFF${csv}`], { type: "text/csv;charset=utf-8;" });
|
|
730
767
|
const url = URL.createObjectURL(blob);
|
|
731
768
|
const a = document.createElement("a");
|
|
@@ -789,7 +826,7 @@ function DataTable({
|
|
|
789
826
|
const renderPopup = (coluna, key, listas) => {
|
|
790
827
|
const col = key === coluna.key ? coluna : void 0;
|
|
791
828
|
const { opts, total: totalOpcoes } = opcoesVisiveis;
|
|
792
|
-
const sel = columnFilters[key];
|
|
829
|
+
const sel = rascunho?.key === key ? rascunho.sel : columnFilters[key];
|
|
793
830
|
const isFiltered = temFiltro(key);
|
|
794
831
|
const podeOrdenar = !!sortFromFilter && !!col && col.sortable !== false;
|
|
795
832
|
const eData = col?.sortType === "date";
|
|
@@ -898,6 +935,12 @@ function DataTable({
|
|
|
898
935
|
autoFocus: true,
|
|
899
936
|
value: filterSearch,
|
|
900
937
|
onChange: (e) => setFilterSearch(e.target.value),
|
|
938
|
+
onKeyDown: (e) => {
|
|
939
|
+
if (e.key === "Enter") {
|
|
940
|
+
e.preventDefault();
|
|
941
|
+
confirmarSelecao(key);
|
|
942
|
+
}
|
|
943
|
+
},
|
|
901
944
|
placeholder: L.search,
|
|
902
945
|
className: "w-full bg-slate-50 dark:bg-slate-800 dark:text-slate-100 border border-slate-200 dark:border-slate-700 rounded-lg px-2 py-1.5 text-xs outline-none focus:border-proef-blue dark:focus:border-proef-turquoise mb-2"
|
|
903
946
|
}
|
|
@@ -951,14 +994,38 @@ function DataTable({
|
|
|
951
994
|
})
|
|
952
995
|
] }),
|
|
953
996
|
totalOpcoes > opts.length && /* @__PURE__ */ jsx("p", { className: "text-[10.5px] text-slate-400 text-center pt-2", children: L.moreOptions.replace("{shown}", String(opts.length)).replace("{total}", String(totalOpcoes)) }),
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
997
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mt-2 pt-2 border-t border-slate-100 dark:border-slate-800", children: [
|
|
998
|
+
isFiltered && /* @__PURE__ */ jsx(
|
|
999
|
+
"button",
|
|
1000
|
+
{
|
|
1001
|
+
type: "button",
|
|
1002
|
+
onClick: () => clearColumnFilter(key),
|
|
1003
|
+
className: "appearance-none bg-transparent border-0 cursor-pointer text-[10px] font-black uppercase tracking-wider text-red-400 hover:text-red-500",
|
|
1004
|
+
children: L.clear
|
|
1005
|
+
}
|
|
1006
|
+
),
|
|
1007
|
+
/* @__PURE__ */ jsx(
|
|
1008
|
+
"button",
|
|
1009
|
+
{
|
|
1010
|
+
type: "button",
|
|
1011
|
+
onClick: () => {
|
|
1012
|
+
setOpenFilter(null);
|
|
1013
|
+
setFilterSearch("");
|
|
1014
|
+
},
|
|
1015
|
+
className: "appearance-none bg-transparent border-0 cursor-pointer ml-auto text-[10px] font-black uppercase tracking-wider text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",
|
|
1016
|
+
children: L.cancel
|
|
1017
|
+
}
|
|
1018
|
+
),
|
|
1019
|
+
/* @__PURE__ */ jsx(
|
|
1020
|
+
"button",
|
|
1021
|
+
{
|
|
1022
|
+
type: "button",
|
|
1023
|
+
onClick: () => confirmarSelecao(key),
|
|
1024
|
+
className: "appearance-none border-0 cursor-pointer rounded-lg bg-proef-navy dark:bg-proef-turquoise px-3 py-1.5 text-[10px] font-black uppercase tracking-wider text-white dark:text-proef-navy hover:bg-proef-blue dark:hover:opacity-90",
|
|
1025
|
+
children: L.confirm
|
|
1026
|
+
}
|
|
1027
|
+
)
|
|
1028
|
+
] })
|
|
962
1029
|
] })
|
|
963
1030
|
]
|
|
964
1031
|
}
|
|
@@ -1080,19 +1147,86 @@ function DataTable({
|
|
|
1080
1147
|
!recolhido && (no.filhos.length > 0 ? renderGrupos(no.filhos, nivel + 1) : no.items.map((row) => renderLinha(row, indicePorLinha.get(row) ?? 0)))
|
|
1081
1148
|
] }, no.path);
|
|
1082
1149
|
});
|
|
1150
|
+
const renderCartoes = () => {
|
|
1151
|
+
const vazio = /* @__PURE__ */ jsx("span", { className: "text-slate-400", children: EMPTY });
|
|
1152
|
+
const conteudo = (row, c) => c.render ? c.render(row) : rawValue(row, c) ?? vazio;
|
|
1153
|
+
const [principal, ...resto] = columns;
|
|
1154
|
+
const campos = resto.filter((c) => c.label);
|
|
1155
|
+
const semValor = (row, c) => {
|
|
1156
|
+
if (!c.value && !(c.key in row)) return false;
|
|
1157
|
+
const v = rawValue(row, c);
|
|
1158
|
+
return v === null || v === "";
|
|
1159
|
+
};
|
|
1160
|
+
const acoes = resto.filter((c) => !c.label);
|
|
1161
|
+
const aviso = (texto) => /* @__PURE__ */ jsx("div", { className: "py-12 text-center text-sm text-slate-400", children: texto });
|
|
1162
|
+
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(
|
|
1163
|
+
/* @__PURE__ */ jsxs("span", { role: "status", "aria-live": "polite", className: "inline-flex items-center gap-2", children: [
|
|
1164
|
+
/* @__PURE__ */ jsx(Spinner, { size: 16, className: "text-proef-blue dark:text-proef-turquoise" }),
|
|
1165
|
+
L.loading
|
|
1166
|
+
] })
|
|
1167
|
+
) : sorted.length === 0 ? aviso(
|
|
1168
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1169
|
+
emptyIcon && /* @__PURE__ */ jsx("div", { className: "flex justify-center mb-2", children: emptyIcon }),
|
|
1170
|
+
/* @__PURE__ */ jsx("p", { className: "m-0", children: L.empty }),
|
|
1171
|
+
emptySubLabel && /* @__PURE__ */ jsx("p", { className: "m-0 text-xs mt-1", children: emptySubLabel })
|
|
1172
|
+
] })
|
|
1173
|
+
) : /* @__PURE__ */ jsx("ul", { className: "m-0 list-none p-0 divide-y divide-slate-100 dark:divide-slate-800", children: pageData.map((row, i) => {
|
|
1174
|
+
const k = chaveDe(row, i);
|
|
1175
|
+
const marcada = selectable && selectedKeys.has(k);
|
|
1176
|
+
const selecionavel = !!selectable && podeSelecionar(row);
|
|
1177
|
+
return /* @__PURE__ */ jsxs(
|
|
1178
|
+
"li",
|
|
1179
|
+
{
|
|
1180
|
+
onClick: () => onRowClick?.(row),
|
|
1181
|
+
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) ?? ""}`,
|
|
1182
|
+
children: [
|
|
1183
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
1184
|
+
selectable && /* @__PURE__ */ jsx(
|
|
1185
|
+
"span",
|
|
1186
|
+
{
|
|
1187
|
+
role: "checkbox",
|
|
1188
|
+
"aria-checked": !!marcada,
|
|
1189
|
+
"aria-disabled": !selecionavel || void 0,
|
|
1190
|
+
onClick: (e) => {
|
|
1191
|
+
e.stopPropagation();
|
|
1192
|
+
if (selecionavel) alternarLinha(k);
|
|
1193
|
+
},
|
|
1194
|
+
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"}`,
|
|
1195
|
+
children: marcada && /* @__PURE__ */ jsx("span", { className: "text-[9px] leading-none", children: "✓" })
|
|
1196
|
+
}
|
|
1197
|
+
),
|
|
1198
|
+
principal && /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1 font-semibold break-words", children: conteudo(row, principal) }),
|
|
1199
|
+
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)) })
|
|
1200
|
+
] }),
|
|
1201
|
+
campos.filter((c) => !semValor(row, c)).map((c) => /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
1202
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] uppercase tracking-wide text-slate-500 dark:text-slate-400 pt-px", children: c.label }),
|
|
1203
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 text-right break-words", children: conteudo(row, c) })
|
|
1204
|
+
] }, c.key))
|
|
1205
|
+
]
|
|
1206
|
+
},
|
|
1207
|
+
k
|
|
1208
|
+
);
|
|
1209
|
+
}) }) });
|
|
1210
|
+
};
|
|
1083
1211
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1084
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 mb-2.5", children: [
|
|
1085
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs text-slate-500 dark:text-slate-400", children: isLoading ? "" : L.results.replace("{count}", String(totalResultados)) }),
|
|
1086
|
-
/* @__PURE__ */ jsxs("div", { className: "ml-auto flex flex-wrap items-center justify-end gap-2", children: [
|
|
1212
|
+
/* @__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: [
|
|
1213
|
+
/* @__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)) }),
|
|
1214
|
+
/* @__PURE__ */ jsxs("div", { className: "ml-auto flex flex-wrap items-center justify-end gap-2 max-sm:contents", children: [
|
|
1087
1215
|
extraToolbar,
|
|
1088
|
-
exportFileName && sorted.length > 0 &&
|
|
1216
|
+
exportFileName && sorted.length > 0 && // Mesmo aspeto do botão Colunas ao lado (o navy cheio competia com as ações da página).
|
|
1217
|
+
/* @__PURE__ */ jsxs(
|
|
1089
1218
|
"button",
|
|
1090
1219
|
{
|
|
1220
|
+
type: "button",
|
|
1091
1221
|
onClick: handleExport,
|
|
1092
|
-
className: "appearance-none cursor-pointer inline-flex items-center gap-
|
|
1222
|
+
className: "appearance-none cursor-pointer bg-white inline-flex items-center gap-2 h-8 rounded-lg border border-slate-300 px-3 text-xs font-medium text-slate-700 transition hover:bg-slate-50 dark:bg-slate-800 dark:border-slate-600 dark:text-slate-200 dark:hover:bg-slate-700",
|
|
1093
1223
|
children: [
|
|
1094
|
-
"
|
|
1095
|
-
|
|
1224
|
+
/* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", "aria-hidden": true, children: [
|
|
1225
|
+
/* @__PURE__ */ jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1226
|
+
/* @__PURE__ */ jsx("polyline", { points: "7 10 12 15 17 10" }),
|
|
1227
|
+
/* @__PURE__ */ jsx("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
|
|
1228
|
+
] }),
|
|
1229
|
+
/* @__PURE__ */ jsx("span", { className: "max-sm:sr-only", children: L.export })
|
|
1096
1230
|
]
|
|
1097
1231
|
}
|
|
1098
1232
|
)
|
|
@@ -1146,95 +1280,98 @@ function DataTable({
|
|
|
1146
1280
|
clearAllLabel: L.clearAll
|
|
1147
1281
|
}
|
|
1148
1282
|
),
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
{
|
|
1160
|
-
|
|
1161
|
-
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"}`,
|
|
1162
|
-
children: (todasVisiveisMarcadas || algumaVisivelMarcada) && /* @__PURE__ */ jsx("span", { className: "text-[9px] leading-none", children: "✓" })
|
|
1163
|
-
}
|
|
1164
|
-
) }),
|
|
1165
|
-
columns.map((c) => {
|
|
1166
|
-
const podeOrdenar = c.sortable !== false;
|
|
1167
|
-
const podeAgrupar = agrupavel(c);
|
|
1168
|
-
const agrupada = groupByKeys.includes(c.key);
|
|
1169
|
-
return /* @__PURE__ */ jsxs(
|
|
1170
|
-
"th",
|
|
1283
|
+
mobileCards && estreito && !isGrouped ? renderCartoes() : (
|
|
1284
|
+
/* rounded-xl: os mesmos cantos dos cartões da biblioteca (Ui.tsx) e das tabelas dos portais. */
|
|
1285
|
+
/* @__PURE__ */ jsx(
|
|
1286
|
+
"div",
|
|
1287
|
+
{
|
|
1288
|
+
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" : ""}`,
|
|
1289
|
+
style: { maxHeight },
|
|
1290
|
+
...scrollAffordance ? { tabIndex: 0, role: "region", "aria-label": L.scrollRegion ?? DEFAULT_LABELS.scrollRegion, onKeyDown: rolarComTeclado } : {},
|
|
1291
|
+
children: /* @__PURE__ */ jsxs("table", { className: "w-full text-[13px] border-collapse dark:text-slate-200", children: [
|
|
1292
|
+
/* @__PURE__ */ jsx("thead", { className: "sticky top-0 z-[2]", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1293
|
+
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(
|
|
1294
|
+
"button",
|
|
1171
1295
|
{
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
"button",
|
|
1197
|
-
{
|
|
1198
|
-
onClick: () => toggleSort(c.key),
|
|
1199
|
-
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",
|
|
1200
|
-
children: [
|
|
1201
|
-
c.label,
|
|
1202
|
-
sort?.key === c.key && /* @__PURE__ */ jsx("span", { className: "ml-1", children: sort.dir === 1 ? "▲" : "▼" })
|
|
1203
|
-
]
|
|
1204
|
-
}
|
|
1205
|
-
) : /* @__PURE__ */ jsx("span", { children: c.label }),
|
|
1206
|
-
podeAgrupar && /* @__PURE__ */ jsx(
|
|
1207
|
-
"button",
|
|
1296
|
+
onClick: alternarTodas,
|
|
1297
|
+
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"}`,
|
|
1298
|
+
children: (todasVisiveisMarcadas || algumaVisivelMarcada) && /* @__PURE__ */ jsx("span", { className: "text-[9px] leading-none", children: "✓" })
|
|
1299
|
+
}
|
|
1300
|
+
) }),
|
|
1301
|
+
columns.map((c) => {
|
|
1302
|
+
const podeOrdenar = c.sortable !== false;
|
|
1303
|
+
const podeAgrupar = agrupavel(c);
|
|
1304
|
+
const agrupada = groupByKeys.includes(c.key);
|
|
1305
|
+
return /* @__PURE__ */ jsxs(
|
|
1306
|
+
"th",
|
|
1307
|
+
{
|
|
1308
|
+
style: {
|
|
1309
|
+
...c.width ? { minWidth: c.width } : {},
|
|
1310
|
+
...larguras[c.key] ? { width: larguras[c.key], minWidth: larguras[c.key], maxWidth: larguras[c.key] } : {},
|
|
1311
|
+
...estiloPreso(c) ?? {}
|
|
1312
|
+
},
|
|
1313
|
+
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(
|
|
1314
|
+
c.align
|
|
1315
|
+
)} ${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 ?? ""}`,
|
|
1316
|
+
children: [
|
|
1317
|
+
resizableColumns && // Pega no limite direito: arrastar redimensiona; duplo clique repõe a largura automática
|
|
1318
|
+
/* @__PURE__ */ jsx(
|
|
1319
|
+
"span",
|
|
1208
1320
|
{
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1321
|
+
role: "separator",
|
|
1322
|
+
"aria-orientation": "vertical",
|
|
1323
|
+
title: L.resizeColumn,
|
|
1324
|
+
onMouseDown: (e) => iniciarResize(e, c.key),
|
|
1325
|
+
onDoubleClick: () => reporLargura(c.key),
|
|
1326
|
+
onClick: (e) => e.stopPropagation(),
|
|
1327
|
+
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"
|
|
1213
1328
|
}
|
|
1214
1329
|
),
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1330
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1331
|
+
podeOrdenar ? /* @__PURE__ */ jsxs(
|
|
1332
|
+
"button",
|
|
1333
|
+
{
|
|
1334
|
+
onClick: () => toggleSort(c.key),
|
|
1335
|
+
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",
|
|
1336
|
+
children: [
|
|
1337
|
+
c.label,
|
|
1338
|
+
sort?.key === c.key && /* @__PURE__ */ jsx("span", { className: "ml-1", children: sort.dir === 1 ? "▲" : "▼" })
|
|
1339
|
+
]
|
|
1340
|
+
}
|
|
1341
|
+
) : /* @__PURE__ */ jsx("span", { children: c.label }),
|
|
1342
|
+
podeAgrupar && /* @__PURE__ */ jsx(
|
|
1343
|
+
"button",
|
|
1344
|
+
{
|
|
1345
|
+
onClick: () => alternarGrupo(c.key),
|
|
1346
|
+
title: (agrupada ? L.ungroup : L.groupBy).replace("{label}", c.label),
|
|
1347
|
+
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"}`,
|
|
1348
|
+
children: /* @__PURE__ */ jsx(Layers, { size: 10 })
|
|
1349
|
+
}
|
|
1350
|
+
),
|
|
1351
|
+
botaoFunil(c)
|
|
1352
|
+
] }),
|
|
1353
|
+
c.headerExtra && /* @__PURE__ */ jsx("div", { className: "mt-0.5 normal-case font-normal tracking-normal", children: c.headerExtra(filtered) })
|
|
1354
|
+
]
|
|
1355
|
+
},
|
|
1356
|
+
c.key
|
|
1357
|
+
);
|
|
1358
|
+
})
|
|
1359
|
+
] }) }),
|
|
1360
|
+
/* @__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: [
|
|
1361
|
+
/* @__PURE__ */ jsx(Spinner, { size: 16, className: "text-proef-blue dark:text-proef-turquoise" }),
|
|
1362
|
+
/* @__PURE__ */ jsx("span", { children: L.loading })
|
|
1363
|
+
] }) }) }) : 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: [
|
|
1364
|
+
emptyIcon && /* @__PURE__ */ jsx("div", { className: "flex justify-center mb-2", children: emptyIcon }),
|
|
1365
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-slate-400", children: L.empty }),
|
|
1366
|
+
emptySubLabel && /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 mt-1", children: emptySubLabel })
|
|
1367
|
+
] }) }) : pageData.map((row, i) => renderLinha(row, i)) }),
|
|
1368
|
+
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: [
|
|
1369
|
+
/* @__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 }),
|
|
1370
|
+
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))
|
|
1371
|
+
] }) })
|
|
1372
|
+
] })
|
|
1373
|
+
}
|
|
1374
|
+
)
|
|
1238
1375
|
),
|
|
1239
1376
|
!isLoading && paginando && (totalPages > 1 || (pageSizeOptions?.length ?? 0) > 0) && /* @__PURE__ */ jsx(
|
|
1240
1377
|
Pagination,
|