next-recomponents 2.0.57 → 2.0.59
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/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +49 -34
- package/dist/index.mjs +63 -47
- package/package.json +1 -1
- package/src/table-advanced/h.table.tsx +41 -28
- package/src/table-advanced/header.tsx +67 -44
- package/src/table-advanced/types.ts +1 -0
- package/src/table-advanced/use.pagination.tsx +8 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -38766,7 +38766,9 @@ function Header({
|
|
|
38766
38766
|
header,
|
|
38767
38767
|
context,
|
|
38768
38768
|
drag,
|
|
38769
|
-
padding
|
|
38769
|
+
padding,
|
|
38770
|
+
index,
|
|
38771
|
+
length
|
|
38770
38772
|
}) {
|
|
38771
38773
|
const [visible, setVisible] = (0, import_react18.useState)(false);
|
|
38772
38774
|
const [hovered, setHovered] = (0, import_react18.useState)(false);
|
|
@@ -38776,14 +38778,17 @@ function Header({
|
|
|
38776
38778
|
const [coords, setCoords] = (0, import_react18.useState)(
|
|
38777
38779
|
null
|
|
38778
38780
|
);
|
|
38779
|
-
const filteredValues =
|
|
38780
|
-
...new Set(context.data.map((d) => d[header]))
|
|
38781
|
-
|
|
38782
|
-
|
|
38783
|
-
|
|
38784
|
-
});
|
|
38785
|
-
const [selected, setSelected] = (0, import_react18.useState)([
|
|
38781
|
+
const filteredValues = (0, import_react18.useMemo)(() => {
|
|
38782
|
+
return [...new Set(context.data.map((d) => d[header]))].filter((d) => {
|
|
38783
|
+
if (text == "") return true;
|
|
38784
|
+
return `${d}`.toLowerCase().includes(text.toLowerCase());
|
|
38785
|
+
});
|
|
38786
|
+
}, [context.data, header, text]);
|
|
38787
|
+
const [selected, setSelected] = (0, import_react18.useState)([]);
|
|
38786
38788
|
const hasFilter = context.filters.find((b) => b.field == header);
|
|
38789
|
+
(0, import_react18.useEffect)(() => {
|
|
38790
|
+
setSelected(filteredValues);
|
|
38791
|
+
}, [filteredValues]);
|
|
38787
38792
|
(0, import_react18.useEffect)(() => {
|
|
38788
38793
|
if (visible) {
|
|
38789
38794
|
context.setCurrentHeader(header);
|
|
@@ -38850,13 +38855,13 @@ function Header({
|
|
|
38850
38855
|
"div",
|
|
38851
38856
|
{
|
|
38852
38857
|
ref: cellRef,
|
|
38853
|
-
className: "
|
|
38858
|
+
className: index < length - 1 ? "border-r" : "",
|
|
38854
38859
|
onMouseEnter: (e) => setHovered(true),
|
|
38855
38860
|
onMouseLeave: (e) => setHovered(false),
|
|
38856
38861
|
style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
|
|
38857
38862
|
children: [
|
|
38858
38863
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex justify-between items-center ", children: [
|
|
38859
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex gap-2", children: [
|
|
38864
|
+
!context.disabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex gap-2", children: [
|
|
38860
38865
|
hasFilter ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38861
38866
|
"div",
|
|
38862
38867
|
{
|
|
@@ -38879,7 +38884,7 @@ function Header({
|
|
|
38879
38884
|
children: sortIndex >= 0 ? context.sort[sortIndex].type === "ASC" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ArrowUPIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ArrowDownIcon2, {}) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {})
|
|
38880
38885
|
}
|
|
38881
38886
|
)
|
|
38882
|
-
] }),
|
|
38887
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {}),
|
|
38883
38888
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38884
38889
|
"div",
|
|
38885
38890
|
{
|
|
@@ -38893,7 +38898,7 @@ function Header({
|
|
|
38893
38898
|
children: header
|
|
38894
38899
|
}
|
|
38895
38900
|
),
|
|
38896
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38901
|
+
!context.disabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38897
38902
|
"div",
|
|
38898
38903
|
{
|
|
38899
38904
|
style: { zIndex: 10 },
|
|
@@ -38901,9 +38906,9 @@ function Header({
|
|
|
38901
38906
|
onClick: (e) => setVisible(true),
|
|
38902
38907
|
children: hovered ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropIcon, {}) : ""
|
|
38903
38908
|
}
|
|
38904
|
-
)
|
|
38909
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {})
|
|
38905
38910
|
] }),
|
|
38906
|
-
context.currentHeader != header && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38911
|
+
!context.disabled && context.currentHeader != header && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38907
38912
|
"div",
|
|
38908
38913
|
{
|
|
38909
38914
|
onMouseDown: (e) => drag.startDrag(e, header),
|
|
@@ -39029,9 +39034,9 @@ function Header({
|
|
|
39029
39034
|
type: "checkbox",
|
|
39030
39035
|
onChange: (e) => {
|
|
39031
39036
|
const ns = [...selected];
|
|
39032
|
-
const
|
|
39033
|
-
if (
|
|
39034
|
-
ns.splice(
|
|
39037
|
+
const index2 = ns.findIndex((n) => n == d);
|
|
39038
|
+
if (index2 >= 0) {
|
|
39039
|
+
ns.splice(index2, 1);
|
|
39035
39040
|
} else {
|
|
39036
39041
|
ns.push(d);
|
|
39037
39042
|
}
|
|
@@ -39040,7 +39045,7 @@ function Header({
|
|
|
39040
39045
|
checked: text != "" || selected.includes(d)
|
|
39041
39046
|
}
|
|
39042
39047
|
),
|
|
39043
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "truncate", children: d })
|
|
39048
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "truncate", children: d == "" ? "Vacias" : !Boolean(d) ? "null" : d })
|
|
39044
39049
|
] }, d);
|
|
39045
39050
|
})
|
|
39046
39051
|
]
|
|
@@ -39135,7 +39140,9 @@ function usePaginacion({
|
|
|
39135
39140
|
tamanioPagina = 100,
|
|
39136
39141
|
paginaInicial = 1
|
|
39137
39142
|
}) {
|
|
39138
|
-
const totalPaginas =
|
|
39143
|
+
const [totalPaginas, setTotalPaginas] = (0, import_react19.useState)(
|
|
39144
|
+
Math.max(1, Math.ceil(total / tamanioPagina))
|
|
39145
|
+
);
|
|
39139
39146
|
const [pagina, setPagina] = (0, import_react19.useState)(
|
|
39140
39147
|
Math.min(Math.max(paginaInicial, 1), totalPaginas)
|
|
39141
39148
|
);
|
|
@@ -39159,6 +39166,10 @@ function usePaginacion({
|
|
|
39159
39166
|
},
|
|
39160
39167
|
[totalPaginas]
|
|
39161
39168
|
);
|
|
39169
|
+
(0, import_react19.useEffect)(() => {
|
|
39170
|
+
setTotalPaginas(Math.max(1, Math.ceil(total / tamanioPagina)));
|
|
39171
|
+
setPagina(1);
|
|
39172
|
+
}, [total]);
|
|
39162
39173
|
return {
|
|
39163
39174
|
rango,
|
|
39164
39175
|
inicio,
|
|
@@ -39190,9 +39201,8 @@ function HTable({
|
|
|
39190
39201
|
function useResizableColumns(headers2, defaultWidth = 160, minWidth = 60) {
|
|
39191
39202
|
function getWidth(h) {
|
|
39192
39203
|
return [
|
|
39193
|
-
|
|
39194
|
-
"
|
|
39195
|
-
...(context == null ? void 0 : context.hideColumns) || []
|
|
39204
|
+
...(context == null ? void 0 : context.hideColumns) || [],
|
|
39205
|
+
...headers2.filter((h2) => h2.startsWith("_"))
|
|
39196
39206
|
].includes(h) ? minWidth : defaultWidth;
|
|
39197
39207
|
}
|
|
39198
39208
|
function resize(headers3) {
|
|
@@ -39256,7 +39266,7 @@ function HTable({
|
|
|
39256
39266
|
var _a, _b;
|
|
39257
39267
|
return [
|
|
39258
39268
|
h,
|
|
39259
|
-
((_a = context == null ? void 0 : context.colSize) == null ? void 0 : _a[h]) ? (_b = context == null ? void 0 : context.colSize) == null ? void 0 : _b[h] : ["__select__", "__modal__"].includes(h) ? 60 : w
|
|
39269
|
+
((_a = context == null ? void 0 : context.colSize) == null ? void 0 : _a[h]) ? (_b = context == null ? void 0 : context.colSize) == null ? void 0 : _b[h] : ["__select__", "__modal__"].includes(h) ? 60 : h.startsWith("_") ? 0 : w
|
|
39260
39270
|
];
|
|
39261
39271
|
})
|
|
39262
39272
|
)
|
|
@@ -39265,12 +39275,14 @@ function HTable({
|
|
|
39265
39275
|
observer.observe(tableRef.current);
|
|
39266
39276
|
return () => observer.disconnect();
|
|
39267
39277
|
}, [headers.length]);
|
|
39268
|
-
const searchedData =
|
|
39269
|
-
|
|
39270
|
-
|
|
39271
|
-
|
|
39272
|
-
|
|
39273
|
-
|
|
39278
|
+
const searchedData = (0, import_react20.useMemo)(() => {
|
|
39279
|
+
return context.filteredData.filter((row) => {
|
|
39280
|
+
if (context.searchBy === "") return true;
|
|
39281
|
+
return Object.values(row).some(
|
|
39282
|
+
(value) => String(value).toLowerCase().includes(context.searchBy.toLowerCase())
|
|
39283
|
+
);
|
|
39284
|
+
});
|
|
39285
|
+
}, [context.filteredData]);
|
|
39274
39286
|
const pagination = use_pagination_default({ total: searchedData.length });
|
|
39275
39287
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
39276
39288
|
"div",
|
|
@@ -39366,6 +39378,8 @@ function HTable({
|
|
|
39366
39378
|
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39367
39379
|
Header,
|
|
39368
39380
|
{
|
|
39381
|
+
length: headers.length,
|
|
39382
|
+
index: i,
|
|
39369
39383
|
padding,
|
|
39370
39384
|
header,
|
|
39371
39385
|
context,
|
|
@@ -39386,7 +39400,8 @@ function HTable({
|
|
|
39386
39400
|
width: Object.values(widths).reduce((acc, i) => acc + i, 0)
|
|
39387
39401
|
},
|
|
39388
39402
|
className: [
|
|
39389
|
-
"grid max-h-[500px]
|
|
39403
|
+
"grid max-h-[500px] ",
|
|
39404
|
+
context.filteredData.length >= 5 ? "overflow-hidden overflow-y-scroll " : ""
|
|
39390
39405
|
].join(" "),
|
|
39391
39406
|
children: searchedData.slice(pagination.inicio - 1, pagination.fin).map((row, rowIndex) => {
|
|
39392
39407
|
const items = Object.entries(row);
|
|
@@ -39541,7 +39556,7 @@ function HTable({
|
|
|
39541
39556
|
},
|
|
39542
39557
|
className: ["grid border-b bg-white"].join(" "),
|
|
39543
39558
|
children: Object.keys((context == null ? void 0 : context.footer) || {}).length > 0 && headers.map((header) => {
|
|
39544
|
-
var _a, _b, _c, _d;
|
|
39559
|
+
var _a, _b, _c, _d, _e;
|
|
39545
39560
|
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
|
|
39546
39561
|
if (header.startsWith("_") && !header.startsWith("__"))
|
|
39547
39562
|
return null;
|
|
@@ -39553,10 +39568,10 @@ function HTable({
|
|
|
39553
39568
|
maxHeight: "100px"
|
|
39554
39569
|
},
|
|
39555
39570
|
title: ((_c = context.footer) == null ? void 0 : _c[header]) + " de " + header,
|
|
39556
|
-
className: " cursor-default font-bold bg-white flex items-center justify-center
|
|
39571
|
+
className: " cursor-default font-bold bg-white flex items-center justify-center text-xs my-5 " + (((_d = context.footer) == null ? void 0 : _d[header]) ? " border-r border-l " : ""),
|
|
39557
39572
|
children: valueFormatter({
|
|
39558
39573
|
currentCoin: context.currentCoin,
|
|
39559
|
-
value: ((
|
|
39574
|
+
value: ((_e = context.footer) == null ? void 0 : _e[header]) ? context.footer[header] == "sum" ? context.filteredData.map((d) => +d[header]).reduce((acc, h) => h + acc, 0) : context.footer[header] == "count" ? context.filteredData.map((d) => d[header] != "" ? 1 : 0).reduce((acc, h) => acc + h, 0) : context.footer[header] == "avg" ? context.filteredData.map((d) => +d[header]).reduce((acc, h) => h + acc, 0) / context.filteredData.map((d) => d[header] != "" ? 1 : 0).reduce((acc, h) => acc + h, 0) : "" : ""
|
|
39560
39575
|
})
|
|
39561
39576
|
},
|
|
39562
39577
|
header
|
|
@@ -39564,7 +39579,7 @@ function HTable({
|
|
|
39564
39579
|
})
|
|
39565
39580
|
}
|
|
39566
39581
|
),
|
|
39567
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex justify-end p-2", children: [
|
|
39582
|
+
searchedData.length > 100 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex justify-end p-2", children: [
|
|
39568
39583
|
pagination.rango,
|
|
39569
39584
|
" de ",
|
|
39570
39585
|
pagination.total,
|
package/dist/index.mjs
CHANGED
|
@@ -38501,18 +38501,19 @@ function Table3({
|
|
|
38501
38501
|
}
|
|
38502
38502
|
|
|
38503
38503
|
// src/table-advanced/index.tsx
|
|
38504
|
-
import { useEffect as
|
|
38504
|
+
import { useEffect as useEffect14 } from "react";
|
|
38505
38505
|
|
|
38506
38506
|
// src/table-advanced/h.table.tsx
|
|
38507
38507
|
import React10, {
|
|
38508
38508
|
useCallback as useCallback3,
|
|
38509
|
-
useEffect as
|
|
38509
|
+
useEffect as useEffect12,
|
|
38510
|
+
useMemo as useMemo10,
|
|
38510
38511
|
useRef as useRef7,
|
|
38511
38512
|
useState as useState16
|
|
38512
38513
|
} from "react";
|
|
38513
38514
|
|
|
38514
38515
|
// src/table-advanced/header.tsx
|
|
38515
|
-
import { useEffect as useEffect10, useRef as useRef6, useState as useState14 } from "react";
|
|
38516
|
+
import { useEffect as useEffect10, useMemo as useMemo8, useRef as useRef6, useState as useState14 } from "react";
|
|
38516
38517
|
import { createPortal } from "react-dom";
|
|
38517
38518
|
|
|
38518
38519
|
// src/table-advanced/icons.tsx
|
|
@@ -38762,7 +38763,9 @@ function Header({
|
|
|
38762
38763
|
header,
|
|
38763
38764
|
context,
|
|
38764
38765
|
drag,
|
|
38765
|
-
padding
|
|
38766
|
+
padding,
|
|
38767
|
+
index,
|
|
38768
|
+
length
|
|
38766
38769
|
}) {
|
|
38767
38770
|
const [visible, setVisible] = useState14(false);
|
|
38768
38771
|
const [hovered, setHovered] = useState14(false);
|
|
@@ -38772,14 +38775,17 @@ function Header({
|
|
|
38772
38775
|
const [coords, setCoords] = useState14(
|
|
38773
38776
|
null
|
|
38774
38777
|
);
|
|
38775
|
-
const filteredValues =
|
|
38776
|
-
...new Set(context.data.map((d) => d[header]))
|
|
38777
|
-
|
|
38778
|
-
|
|
38779
|
-
|
|
38780
|
-
});
|
|
38781
|
-
const [selected, setSelected] = useState14([
|
|
38778
|
+
const filteredValues = useMemo8(() => {
|
|
38779
|
+
return [...new Set(context.data.map((d) => d[header]))].filter((d) => {
|
|
38780
|
+
if (text == "") return true;
|
|
38781
|
+
return `${d}`.toLowerCase().includes(text.toLowerCase());
|
|
38782
|
+
});
|
|
38783
|
+
}, [context.data, header, text]);
|
|
38784
|
+
const [selected, setSelected] = useState14([]);
|
|
38782
38785
|
const hasFilter = context.filters.find((b) => b.field == header);
|
|
38786
|
+
useEffect10(() => {
|
|
38787
|
+
setSelected(filteredValues);
|
|
38788
|
+
}, [filteredValues]);
|
|
38783
38789
|
useEffect10(() => {
|
|
38784
38790
|
if (visible) {
|
|
38785
38791
|
context.setCurrentHeader(header);
|
|
@@ -38846,13 +38852,13 @@ function Header({
|
|
|
38846
38852
|
"div",
|
|
38847
38853
|
{
|
|
38848
38854
|
ref: cellRef,
|
|
38849
|
-
className: "
|
|
38855
|
+
className: index < length - 1 ? "border-r" : "",
|
|
38850
38856
|
onMouseEnter: (e) => setHovered(true),
|
|
38851
38857
|
onMouseLeave: (e) => setHovered(false),
|
|
38852
38858
|
style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
|
|
38853
38859
|
children: [
|
|
38854
38860
|
/* @__PURE__ */ jsxs23("div", { className: "flex justify-between items-center ", children: [
|
|
38855
|
-
/* @__PURE__ */ jsxs23("div", { className: "flex gap-2", children: [
|
|
38861
|
+
!context.disabled ? /* @__PURE__ */ jsxs23("div", { className: "flex gap-2", children: [
|
|
38856
38862
|
hasFilter ? /* @__PURE__ */ jsx31(
|
|
38857
38863
|
"div",
|
|
38858
38864
|
{
|
|
@@ -38875,7 +38881,7 @@ function Header({
|
|
|
38875
38881
|
children: sortIndex >= 0 ? context.sort[sortIndex].type === "ASC" ? /* @__PURE__ */ jsx31(ArrowUPIcon, {}) : /* @__PURE__ */ jsx31(ArrowDownIcon2, {}) : /* @__PURE__ */ jsx31("div", {})
|
|
38876
38882
|
}
|
|
38877
38883
|
)
|
|
38878
|
-
] }),
|
|
38884
|
+
] }) : /* @__PURE__ */ jsx31("div", {}),
|
|
38879
38885
|
/* @__PURE__ */ jsx31(
|
|
38880
38886
|
"div",
|
|
38881
38887
|
{
|
|
@@ -38889,7 +38895,7 @@ function Header({
|
|
|
38889
38895
|
children: header
|
|
38890
38896
|
}
|
|
38891
38897
|
),
|
|
38892
|
-
/* @__PURE__ */ jsx31(
|
|
38898
|
+
!context.disabled ? /* @__PURE__ */ jsx31(
|
|
38893
38899
|
"div",
|
|
38894
38900
|
{
|
|
38895
38901
|
style: { zIndex: 10 },
|
|
@@ -38897,9 +38903,9 @@ function Header({
|
|
|
38897
38903
|
onClick: (e) => setVisible(true),
|
|
38898
38904
|
children: hovered ? /* @__PURE__ */ jsx31(DropIcon, {}) : ""
|
|
38899
38905
|
}
|
|
38900
|
-
)
|
|
38906
|
+
) : /* @__PURE__ */ jsx31("div", {})
|
|
38901
38907
|
] }),
|
|
38902
|
-
context.currentHeader != header && /* @__PURE__ */ jsx31(
|
|
38908
|
+
!context.disabled && context.currentHeader != header && /* @__PURE__ */ jsx31(
|
|
38903
38909
|
"div",
|
|
38904
38910
|
{
|
|
38905
38911
|
onMouseDown: (e) => drag.startDrag(e, header),
|
|
@@ -39025,9 +39031,9 @@ function Header({
|
|
|
39025
39031
|
type: "checkbox",
|
|
39026
39032
|
onChange: (e) => {
|
|
39027
39033
|
const ns = [...selected];
|
|
39028
|
-
const
|
|
39029
|
-
if (
|
|
39030
|
-
ns.splice(
|
|
39034
|
+
const index2 = ns.findIndex((n) => n == d);
|
|
39035
|
+
if (index2 >= 0) {
|
|
39036
|
+
ns.splice(index2, 1);
|
|
39031
39037
|
} else {
|
|
39032
39038
|
ns.push(d);
|
|
39033
39039
|
}
|
|
@@ -39036,7 +39042,7 @@ function Header({
|
|
|
39036
39042
|
checked: text != "" || selected.includes(d)
|
|
39037
39043
|
}
|
|
39038
39044
|
),
|
|
39039
|
-
/* @__PURE__ */ jsx31("div", { className: "truncate", children: d })
|
|
39045
|
+
/* @__PURE__ */ jsx31("div", { className: "truncate", children: d == "" ? "Vacias" : !Boolean(d) ? "null" : d })
|
|
39040
39046
|
] }, d);
|
|
39041
39047
|
})
|
|
39042
39048
|
]
|
|
@@ -39125,19 +39131,21 @@ function valueFormatter({
|
|
|
39125
39131
|
}
|
|
39126
39132
|
|
|
39127
39133
|
// src/table-advanced/use.pagination.tsx
|
|
39128
|
-
import { useState as useState15, useMemo as
|
|
39134
|
+
import { useState as useState15, useMemo as useMemo9, useCallback as useCallback2, useEffect as useEffect11 } from "react";
|
|
39129
39135
|
function usePaginacion({
|
|
39130
39136
|
total,
|
|
39131
39137
|
tamanioPagina = 100,
|
|
39132
39138
|
paginaInicial = 1
|
|
39133
39139
|
}) {
|
|
39134
|
-
const totalPaginas =
|
|
39140
|
+
const [totalPaginas, setTotalPaginas] = useState15(
|
|
39141
|
+
Math.max(1, Math.ceil(total / tamanioPagina))
|
|
39142
|
+
);
|
|
39135
39143
|
const [pagina, setPagina] = useState15(
|
|
39136
39144
|
Math.min(Math.max(paginaInicial, 1), totalPaginas)
|
|
39137
39145
|
);
|
|
39138
39146
|
const inicio = total === 0 ? 0 : (pagina - 1) * tamanioPagina + 1;
|
|
39139
39147
|
const fin = Math.min(pagina * tamanioPagina, total);
|
|
39140
|
-
const rango =
|
|
39148
|
+
const rango = useMemo9(() => {
|
|
39141
39149
|
if (total === 0) return "0 a 0";
|
|
39142
39150
|
return `${inicio} a ${fin}`;
|
|
39143
39151
|
}, [inicio, fin, total]);
|
|
@@ -39155,6 +39163,10 @@ function usePaginacion({
|
|
|
39155
39163
|
},
|
|
39156
39164
|
[totalPaginas]
|
|
39157
39165
|
);
|
|
39166
|
+
useEffect11(() => {
|
|
39167
|
+
setTotalPaginas(Math.max(1, Math.ceil(total / tamanioPagina)));
|
|
39168
|
+
setPagina(1);
|
|
39169
|
+
}, [total]);
|
|
39158
39170
|
return {
|
|
39159
39171
|
rango,
|
|
39160
39172
|
inicio,
|
|
@@ -39186,9 +39198,8 @@ function HTable({
|
|
|
39186
39198
|
function useResizableColumns(headers2, defaultWidth = 160, minWidth = 60) {
|
|
39187
39199
|
function getWidth(h) {
|
|
39188
39200
|
return [
|
|
39189
|
-
|
|
39190
|
-
"
|
|
39191
|
-
...(context == null ? void 0 : context.hideColumns) || []
|
|
39201
|
+
...(context == null ? void 0 : context.hideColumns) || [],
|
|
39202
|
+
...headers2.filter((h2) => h2.startsWith("_"))
|
|
39192
39203
|
].includes(h) ? minWidth : defaultWidth;
|
|
39193
39204
|
}
|
|
39194
39205
|
function resize(headers3) {
|
|
@@ -39230,7 +39241,7 @@ function HTable({
|
|
|
39230
39241
|
return { widths: widths2, gridTemplateColumns: gridTemplateColumns2, startDrag: startDrag2, setWidths: setWidths2 };
|
|
39231
39242
|
}
|
|
39232
39243
|
const { gridTemplateColumns, startDrag, widths, setWidths } = useResizableColumns(headers);
|
|
39233
|
-
|
|
39244
|
+
useEffect12(() => {
|
|
39234
39245
|
if (!tableRef.current) return;
|
|
39235
39246
|
const observer = new ResizeObserver(([entry]) => {
|
|
39236
39247
|
const ocultos = headers.filter(
|
|
@@ -39252,7 +39263,7 @@ function HTable({
|
|
|
39252
39263
|
var _a, _b;
|
|
39253
39264
|
return [
|
|
39254
39265
|
h,
|
|
39255
|
-
((_a = context == null ? void 0 : context.colSize) == null ? void 0 : _a[h]) ? (_b = context == null ? void 0 : context.colSize) == null ? void 0 : _b[h] : ["__select__", "__modal__"].includes(h) ? 60 : w
|
|
39266
|
+
((_a = context == null ? void 0 : context.colSize) == null ? void 0 : _a[h]) ? (_b = context == null ? void 0 : context.colSize) == null ? void 0 : _b[h] : ["__select__", "__modal__"].includes(h) ? 60 : h.startsWith("_") ? 0 : w
|
|
39256
39267
|
];
|
|
39257
39268
|
})
|
|
39258
39269
|
)
|
|
@@ -39261,12 +39272,14 @@ function HTable({
|
|
|
39261
39272
|
observer.observe(tableRef.current);
|
|
39262
39273
|
return () => observer.disconnect();
|
|
39263
39274
|
}, [headers.length]);
|
|
39264
|
-
const searchedData =
|
|
39265
|
-
|
|
39266
|
-
|
|
39267
|
-
|
|
39268
|
-
|
|
39269
|
-
|
|
39275
|
+
const searchedData = useMemo10(() => {
|
|
39276
|
+
return context.filteredData.filter((row) => {
|
|
39277
|
+
if (context.searchBy === "") return true;
|
|
39278
|
+
return Object.values(row).some(
|
|
39279
|
+
(value) => String(value).toLowerCase().includes(context.searchBy.toLowerCase())
|
|
39280
|
+
);
|
|
39281
|
+
});
|
|
39282
|
+
}, [context.filteredData]);
|
|
39270
39283
|
const pagination = use_pagination_default({ total: searchedData.length });
|
|
39271
39284
|
return /* @__PURE__ */ jsxs25(
|
|
39272
39285
|
"div",
|
|
@@ -39362,6 +39375,8 @@ function HTable({
|
|
|
39362
39375
|
children: /* @__PURE__ */ jsx33(
|
|
39363
39376
|
Header,
|
|
39364
39377
|
{
|
|
39378
|
+
length: headers.length,
|
|
39379
|
+
index: i,
|
|
39365
39380
|
padding,
|
|
39366
39381
|
header,
|
|
39367
39382
|
context,
|
|
@@ -39382,7 +39397,8 @@ function HTable({
|
|
|
39382
39397
|
width: Object.values(widths).reduce((acc, i) => acc + i, 0)
|
|
39383
39398
|
},
|
|
39384
39399
|
className: [
|
|
39385
|
-
"grid max-h-[500px]
|
|
39400
|
+
"grid max-h-[500px] ",
|
|
39401
|
+
context.filteredData.length >= 5 ? "overflow-hidden overflow-y-scroll " : ""
|
|
39386
39402
|
].join(" "),
|
|
39387
39403
|
children: searchedData.slice(pagination.inicio - 1, pagination.fin).map((row, rowIndex) => {
|
|
39388
39404
|
const items = Object.entries(row);
|
|
@@ -39537,7 +39553,7 @@ function HTable({
|
|
|
39537
39553
|
},
|
|
39538
39554
|
className: ["grid border-b bg-white"].join(" "),
|
|
39539
39555
|
children: Object.keys((context == null ? void 0 : context.footer) || {}).length > 0 && headers.map((header) => {
|
|
39540
|
-
var _a, _b, _c, _d;
|
|
39556
|
+
var _a, _b, _c, _d, _e;
|
|
39541
39557
|
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
|
|
39542
39558
|
if (header.startsWith("_") && !header.startsWith("__"))
|
|
39543
39559
|
return null;
|
|
@@ -39549,10 +39565,10 @@ function HTable({
|
|
|
39549
39565
|
maxHeight: "100px"
|
|
39550
39566
|
},
|
|
39551
39567
|
title: ((_c = context.footer) == null ? void 0 : _c[header]) + " de " + header,
|
|
39552
|
-
className: " cursor-default font-bold bg-white flex items-center justify-center
|
|
39568
|
+
className: " cursor-default font-bold bg-white flex items-center justify-center text-xs my-5 " + (((_d = context.footer) == null ? void 0 : _d[header]) ? " border-r border-l " : ""),
|
|
39553
39569
|
children: valueFormatter({
|
|
39554
39570
|
currentCoin: context.currentCoin,
|
|
39555
|
-
value: ((
|
|
39571
|
+
value: ((_e = context.footer) == null ? void 0 : _e[header]) ? context.footer[header] == "sum" ? context.filteredData.map((d) => +d[header]).reduce((acc, h) => h + acc, 0) : context.footer[header] == "count" ? context.filteredData.map((d) => d[header] != "" ? 1 : 0).reduce((acc, h) => acc + h, 0) : context.footer[header] == "avg" ? context.filteredData.map((d) => +d[header]).reduce((acc, h) => h + acc, 0) / context.filteredData.map((d) => d[header] != "" ? 1 : 0).reduce((acc, h) => acc + h, 0) : "" : ""
|
|
39556
39572
|
})
|
|
39557
39573
|
},
|
|
39558
39574
|
header
|
|
@@ -39560,7 +39576,7 @@ function HTable({
|
|
|
39560
39576
|
})
|
|
39561
39577
|
}
|
|
39562
39578
|
),
|
|
39563
|
-
/* @__PURE__ */ jsxs25("div", { className: "flex justify-end p-2", children: [
|
|
39579
|
+
searchedData.length > 100 && /* @__PURE__ */ jsxs25("div", { className: "flex justify-end p-2", children: [
|
|
39564
39580
|
pagination.rango,
|
|
39565
39581
|
" de ",
|
|
39566
39582
|
pagination.total,
|
|
@@ -39663,7 +39679,7 @@ function ModalContent({
|
|
|
39663
39679
|
}
|
|
39664
39680
|
|
|
39665
39681
|
// src/table-advanced/context.ts
|
|
39666
|
-
import { useEffect as
|
|
39682
|
+
import { useEffect as useEffect13, useMemo as useMemo11, useReducer as useReducer3, useState as useState17 } from "react";
|
|
39667
39683
|
|
|
39668
39684
|
// src/table-advanced/filter.reducer.ts
|
|
39669
39685
|
var filterReducer = (acc, b) => {
|
|
@@ -39703,7 +39719,7 @@ function useContext({ onSelect }) {
|
|
|
39703
39719
|
);
|
|
39704
39720
|
const [searchBy, setSearchBy] = useState17("");
|
|
39705
39721
|
const [sort, setSort] = useReducer3(sortReducer, new Array());
|
|
39706
|
-
const sortedData =
|
|
39722
|
+
const sortedData = useMemo11(() => {
|
|
39707
39723
|
return [...data].sort((a, b) => {
|
|
39708
39724
|
for (const { field, type } of sort.reverse()) {
|
|
39709
39725
|
const av = a[field];
|
|
@@ -39733,7 +39749,7 @@ function useContext({ onSelect }) {
|
|
|
39733
39749
|
}
|
|
39734
39750
|
return true;
|
|
39735
39751
|
});
|
|
39736
|
-
|
|
39752
|
+
useEffect13(() => {
|
|
39737
39753
|
if (filters.length == 0) {
|
|
39738
39754
|
setEditions([]);
|
|
39739
39755
|
}
|
|
@@ -39766,7 +39782,7 @@ import { jsx as jsx34 } from "react/jsx-runtime";
|
|
|
39766
39782
|
function TableAdvanced(tableProps) {
|
|
39767
39783
|
const { data, ...props } = tableProps;
|
|
39768
39784
|
const context = useContext({ onSelect: Boolean(tableProps.onSelect) });
|
|
39769
|
-
|
|
39785
|
+
useEffect14(() => {
|
|
39770
39786
|
context.setData(
|
|
39771
39787
|
Array.isArray(data) ? data.map((d) => {
|
|
39772
39788
|
return {
|
|
@@ -39777,7 +39793,7 @@ function TableAdvanced(tableProps) {
|
|
|
39777
39793
|
}) : data
|
|
39778
39794
|
);
|
|
39779
39795
|
}, [data]);
|
|
39780
|
-
|
|
39796
|
+
useEffect14(() => {
|
|
39781
39797
|
if (tableProps == null ? void 0 : tableProps.sortBy) {
|
|
39782
39798
|
const [k, v] = Object.entries(tableProps.sortBy)[0];
|
|
39783
39799
|
context.setSort({ [k]: v });
|
|
@@ -39796,7 +39812,7 @@ function TableAdvanced(tableProps) {
|
|
|
39796
39812
|
}
|
|
39797
39813
|
|
|
39798
39814
|
// src/tabs/index.tsx
|
|
39799
|
-
import React11, { useEffect as
|
|
39815
|
+
import React11, { useEffect as useEffect15, useState as useState19 } from "react";
|
|
39800
39816
|
import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
39801
39817
|
function TabContainer({
|
|
39802
39818
|
children,
|
|
@@ -39813,7 +39829,7 @@ function TabContainer({
|
|
|
39813
39829
|
if (e.key === "ArrowLeft")
|
|
39814
39830
|
setIndex((k - 1 + labels.length) % labels.length);
|
|
39815
39831
|
};
|
|
39816
|
-
|
|
39832
|
+
useEffect15(() => {
|
|
39817
39833
|
setIndex(currentIndex);
|
|
39818
39834
|
}, [currentIndex]);
|
|
39819
39835
|
return /* @__PURE__ */ jsxs26("div", { className: "w-full bg-white", children: [
|
package/package.json
CHANGED
|
@@ -41,9 +41,8 @@ export default function HTable({
|
|
|
41
41
|
) {
|
|
42
42
|
function getWidth(h: string) {
|
|
43
43
|
return [
|
|
44
|
-
"__select__",
|
|
45
|
-
"__modal__",
|
|
46
44
|
...(context?.hideColumns || []),
|
|
45
|
+
...headers.filter((h) => h.startsWith("_")),
|
|
47
46
|
].includes(h)
|
|
48
47
|
? minWidth
|
|
49
48
|
: defaultWidth;
|
|
@@ -65,6 +64,7 @@ export default function HTable({
|
|
|
65
64
|
minWidth,
|
|
66
65
|
startWidth + (ev.clientX - startX),
|
|
67
66
|
);
|
|
67
|
+
|
|
68
68
|
setWidths((prev) => ({ ...prev, [headerKey]: newWidth }));
|
|
69
69
|
};
|
|
70
70
|
const onUp = () => {
|
|
@@ -87,7 +87,6 @@ export default function HTable({
|
|
|
87
87
|
})
|
|
88
88
|
.map((h) => `${widths[h] ?? defaultWidth}px`)
|
|
89
89
|
.join(" ");
|
|
90
|
-
|
|
91
90
|
return { widths, gridTemplateColumns, startDrag, setWidths };
|
|
92
91
|
}
|
|
93
92
|
const { gridTemplateColumns, startDrag, widths, setWidths } =
|
|
@@ -130,7 +129,9 @@ export default function HTable({
|
|
|
130
129
|
? context?.colSize?.[h]
|
|
131
130
|
: ["__select__", "__modal__"].includes(h)
|
|
132
131
|
? 60
|
|
133
|
-
:
|
|
132
|
+
: h.startsWith("_")
|
|
133
|
+
? 0
|
|
134
|
+
: w,
|
|
134
135
|
]),
|
|
135
136
|
),
|
|
136
137
|
);
|
|
@@ -138,13 +139,17 @@ export default function HTable({
|
|
|
138
139
|
observer.observe(tableRef.current);
|
|
139
140
|
return () => observer.disconnect();
|
|
140
141
|
}, [headers.length]);
|
|
141
|
-
const searchedData = context.filteredData.filter((row) => {
|
|
142
|
-
if (context.searchBy === "") return true;
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
const searchedData = useMemo(() => {
|
|
144
|
+
return context.filteredData.filter((row) => {
|
|
145
|
+
if (context.searchBy === "") return true;
|
|
146
|
+
|
|
147
|
+
return Object.values(row).some((value) =>
|
|
148
|
+
String(value).toLowerCase().includes(context.searchBy.toLowerCase()),
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
}, [context.filteredData]);
|
|
152
|
+
|
|
148
153
|
const pagination = usePaginacion({ total: searchedData.length });
|
|
149
154
|
return (
|
|
150
155
|
<div
|
|
@@ -247,6 +252,8 @@ export default function HTable({
|
|
|
247
252
|
// style={{ position: "relative" }}
|
|
248
253
|
>
|
|
249
254
|
<Header
|
|
255
|
+
length={headers.length}
|
|
256
|
+
index={i}
|
|
250
257
|
padding={padding}
|
|
251
258
|
header={header}
|
|
252
259
|
context={context}
|
|
@@ -284,7 +291,10 @@ export default function HTable({
|
|
|
284
291
|
width: Object.values(widths).reduce((acc, i) => acc + i, 0),
|
|
285
292
|
}}
|
|
286
293
|
className={[
|
|
287
|
-
"grid max-h-[500px]
|
|
294
|
+
"grid max-h-[500px] ",
|
|
295
|
+
context.filteredData.length >= 5
|
|
296
|
+
? "overflow-hidden overflow-y-scroll "
|
|
297
|
+
: "",
|
|
288
298
|
].join(" ")}
|
|
289
299
|
>
|
|
290
300
|
{searchedData
|
|
@@ -515,7 +525,8 @@ export default function HTable({
|
|
|
515
525
|
className={
|
|
516
526
|
" cursor-default font-bold " +
|
|
517
527
|
" bg-white flex items-center justify-center" +
|
|
518
|
-
"
|
|
528
|
+
" text-xs my-5 " +
|
|
529
|
+
(context.footer?.[header] ? " border-r border-l " : "")
|
|
519
530
|
}
|
|
520
531
|
>
|
|
521
532
|
{valueFormatter({
|
|
@@ -543,23 +554,25 @@ export default function HTable({
|
|
|
543
554
|
);
|
|
544
555
|
})}
|
|
545
556
|
</div>
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
<
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
557
|
+
{searchedData.length > 100 && (
|
|
558
|
+
<div className="flex justify-end p-2">
|
|
559
|
+
{pagination.rango} de {pagination.total}
|
|
560
|
+
<div className="flex items-center gap-5 mx-5">
|
|
561
|
+
<button
|
|
562
|
+
onClick={(e) => pagination.hasPrev && pagination.prev()}
|
|
563
|
+
className={pagination.hasPrev ? "" : "text-gray-300"}
|
|
564
|
+
>
|
|
565
|
+
<PrevIcon />
|
|
566
|
+
</button>
|
|
567
|
+
<button
|
|
568
|
+
onClick={(e) => pagination.hasNext && pagination.next()}
|
|
569
|
+
className={pagination.hasNext ? "" : "text-gray-300"}
|
|
570
|
+
>
|
|
571
|
+
<NextIcon />
|
|
572
|
+
</button>
|
|
573
|
+
</div>
|
|
561
574
|
</div>
|
|
562
|
-
|
|
575
|
+
)}
|
|
563
576
|
</div>
|
|
564
577
|
|
|
565
578
|
{context.modal && (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { createPortal } from "react-dom";
|
|
3
3
|
import DropIcon, {
|
|
4
4
|
ArrowDownIcon,
|
|
@@ -17,14 +17,18 @@ export function Header({
|
|
|
17
17
|
context,
|
|
18
18
|
drag,
|
|
19
19
|
padding,
|
|
20
|
+
index,
|
|
21
|
+
length,
|
|
20
22
|
}: {
|
|
21
23
|
header: string;
|
|
22
24
|
context: ContextType & Omit<TableProps, "data">;
|
|
25
|
+
index: number;
|
|
23
26
|
drag: {
|
|
24
27
|
widths: Record<string, number>;
|
|
25
28
|
gridTemplateColumns: string;
|
|
26
29
|
startDrag: (e: React.MouseEvent, headerKey: string) => void;
|
|
27
30
|
};
|
|
31
|
+
length: number;
|
|
28
32
|
padding: string;
|
|
29
33
|
}) {
|
|
30
34
|
const [visible, setVisible] = useState(false);
|
|
@@ -36,17 +40,21 @@ export function Header({
|
|
|
36
40
|
null,
|
|
37
41
|
);
|
|
38
42
|
|
|
39
|
-
const filteredValues =
|
|
40
|
-
...new Set(context.data.map((d) => d[header]))
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
43
|
+
const filteredValues = useMemo(() => {
|
|
44
|
+
return [...new Set(context.data.map((d) => d[header]))].filter((d) => {
|
|
45
|
+
if (text == "") return true;
|
|
46
|
+
return `${d}`.toLowerCase().includes(text.toLowerCase());
|
|
47
|
+
});
|
|
48
|
+
}, [context.data, header, text]);
|
|
45
49
|
|
|
46
|
-
const [selected, setSelected] = useState([
|
|
50
|
+
const [selected, setSelected] = useState<any[]>([]);
|
|
47
51
|
|
|
48
52
|
const hasFilter = context.filters.find((b) => b.field == header);
|
|
49
53
|
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setSelected(filteredValues);
|
|
56
|
+
}, [filteredValues]);
|
|
57
|
+
|
|
50
58
|
useEffect(() => {
|
|
51
59
|
if (visible) {
|
|
52
60
|
context.setCurrentHeader(header);
|
|
@@ -121,44 +129,49 @@ export function Header({
|
|
|
121
129
|
<div className=" ">
|
|
122
130
|
<div
|
|
123
131
|
ref={cellRef}
|
|
124
|
-
className={"
|
|
132
|
+
className={index < length - 1 ? "border-r" : ""}
|
|
125
133
|
onMouseEnter={(e) => setHovered(true)}
|
|
126
134
|
onMouseLeave={(e) => setHovered(false)}
|
|
127
135
|
style={{ zIndex: 10, height: `${padding}px`, maxHeight: "100px" }}
|
|
128
136
|
>
|
|
129
137
|
<div className="flex justify-between items-center ">
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
{!context.disabled ? (
|
|
139
|
+
<div className="flex gap-2">
|
|
140
|
+
{hasFilter ? (
|
|
141
|
+
<div
|
|
142
|
+
className="cursor-pointer"
|
|
143
|
+
onClick={(e) => {
|
|
144
|
+
context.setFilters(null);
|
|
145
|
+
setSelected(filteredValues);
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<FilterIcon />
|
|
149
|
+
</div>
|
|
150
|
+
) : (
|
|
151
|
+
<div></div>
|
|
152
|
+
)}
|
|
153
|
+
|
|
132
154
|
<div
|
|
133
|
-
className="cursor-pointer"
|
|
134
155
|
onClick={(e) => {
|
|
135
|
-
context.
|
|
136
|
-
|
|
156
|
+
context.setSort({
|
|
157
|
+
[header]: "TOGGLE",
|
|
158
|
+
});
|
|
137
159
|
}}
|
|
138
160
|
>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
onClick={(e) => {
|
|
146
|
-
context.setSort({
|
|
147
|
-
[header]: "TOGGLE",
|
|
148
|
-
});
|
|
149
|
-
}}
|
|
150
|
-
>
|
|
151
|
-
{sortIndex >= 0 ? (
|
|
152
|
-
context.sort[sortIndex].type === "ASC" ? (
|
|
153
|
-
<ArrowUPIcon />
|
|
161
|
+
{sortIndex >= 0 ? (
|
|
162
|
+
context.sort[sortIndex].type === "ASC" ? (
|
|
163
|
+
<ArrowUPIcon />
|
|
164
|
+
) : (
|
|
165
|
+
<ArrowDownIcon />
|
|
166
|
+
)
|
|
154
167
|
) : (
|
|
155
|
-
<
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
<div></div>
|
|
159
|
-
)}
|
|
168
|
+
<div></div>
|
|
169
|
+
)}
|
|
170
|
+
</div>
|
|
160
171
|
</div>
|
|
161
|
-
|
|
172
|
+
) : (
|
|
173
|
+
<div></div>
|
|
174
|
+
)}
|
|
162
175
|
<div
|
|
163
176
|
className="font-bold flex truncate text-xs items-center "
|
|
164
177
|
style={{ height: `${padding}px` }}
|
|
@@ -170,16 +183,20 @@ export function Header({
|
|
|
170
183
|
>
|
|
171
184
|
{header}
|
|
172
185
|
</div>
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
186
|
+
{!context.disabled ? (
|
|
187
|
+
<div
|
|
188
|
+
style={{ zIndex: 10 }}
|
|
189
|
+
className="icon font-bold p-1 cursor-pointer pr-3 "
|
|
190
|
+
onClick={(e) => setVisible(true)}
|
|
191
|
+
>
|
|
192
|
+
{hovered ? <DropIcon /> : ""}
|
|
193
|
+
</div>
|
|
194
|
+
) : (
|
|
195
|
+
<div></div>
|
|
196
|
+
)}
|
|
180
197
|
</div>
|
|
181
198
|
|
|
182
|
-
{context.currentHeader != header && (
|
|
199
|
+
{!context.disabled && context.currentHeader != header && (
|
|
183
200
|
<div
|
|
184
201
|
onMouseDown={(e) => drag.startDrag(e, header)}
|
|
185
202
|
className="absolute top-0 h-full cursor-col-resize hover:bg-blue-300 "
|
|
@@ -304,7 +321,13 @@ export function Header({
|
|
|
304
321
|
}}
|
|
305
322
|
checked={text != "" || selected.includes(d)}
|
|
306
323
|
/>
|
|
307
|
-
<div className="truncate">
|
|
324
|
+
<div className="truncate">
|
|
325
|
+
{d == ""
|
|
326
|
+
? "Vacias"
|
|
327
|
+
: !Boolean(d)
|
|
328
|
+
? "null"
|
|
329
|
+
: d}
|
|
330
|
+
</div>
|
|
308
331
|
</div>
|
|
309
332
|
);
|
|
310
333
|
})}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useMemo, useCallback } from "react";
|
|
1
|
+
import { useState, useMemo, useCallback, useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
function usePaginacion({
|
|
4
4
|
total,
|
|
@@ -9,7 +9,9 @@ function usePaginacion({
|
|
|
9
9
|
tamanioPagina?: number;
|
|
10
10
|
paginaInicial?: number;
|
|
11
11
|
}) {
|
|
12
|
-
const totalPaginas =
|
|
12
|
+
const [totalPaginas, setTotalPaginas] = useState(
|
|
13
|
+
Math.max(1, Math.ceil(total / tamanioPagina)),
|
|
14
|
+
);
|
|
13
15
|
|
|
14
16
|
const [pagina, setPagina] = useState(
|
|
15
17
|
Math.min(Math.max(paginaInicial, 1), totalPaginas),
|
|
@@ -41,6 +43,10 @@ function usePaginacion({
|
|
|
41
43
|
[totalPaginas],
|
|
42
44
|
);
|
|
43
45
|
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setTotalPaginas(Math.max(1, Math.ceil(total / tamanioPagina)));
|
|
48
|
+
setPagina(1);
|
|
49
|
+
}, [total]);
|
|
44
50
|
return {
|
|
45
51
|
rango,
|
|
46
52
|
inicio,
|