next-recomponents 2.0.56 → 2.0.57
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.js +363 -233
- package/dist/index.mjs +352 -222
- package/package.json +1 -1
- package/src/table-advanced/h.table.tsx +325 -267
- package/src/table-advanced/header.tsx +8 -6
- package/src/table-advanced/icons.tsx +37 -0
- package/src/table-advanced/searchable.tsx +1 -1
- package/src/table-advanced/use.pagination.tsx +59 -0
package/dist/index.js
CHANGED
|
@@ -38510,10 +38510,10 @@ function Table3({
|
|
|
38510
38510
|
}
|
|
38511
38511
|
|
|
38512
38512
|
// src/table-advanced/index.tsx
|
|
38513
|
-
var
|
|
38513
|
+
var import_react22 = require("react");
|
|
38514
38514
|
|
|
38515
38515
|
// src/table-advanced/h.table.tsx
|
|
38516
|
-
var
|
|
38516
|
+
var import_react20 = __toESM(require("react"));
|
|
38517
38517
|
|
|
38518
38518
|
// src/table-advanced/header.tsx
|
|
38519
38519
|
var import_react18 = require("react");
|
|
@@ -38541,6 +38541,44 @@ function DropIcon() {
|
|
|
38541
38541
|
}
|
|
38542
38542
|
);
|
|
38543
38543
|
}
|
|
38544
|
+
function PrevIcon() {
|
|
38545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
38546
|
+
"svg",
|
|
38547
|
+
{
|
|
38548
|
+
stroke: "currentColor",
|
|
38549
|
+
fill: "currentColor",
|
|
38550
|
+
strokeWidth: "0",
|
|
38551
|
+
viewBox: "0 0 24 24",
|
|
38552
|
+
height: "1em",
|
|
38553
|
+
width: "1em",
|
|
38554
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
38555
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
38556
|
+
"polyline",
|
|
38557
|
+
{
|
|
38558
|
+
fill: "none",
|
|
38559
|
+
strokeWidth: "2",
|
|
38560
|
+
points: "7 2 17 12 7 22",
|
|
38561
|
+
transform: "matrix(-1 0 0 1 24 0)"
|
|
38562
|
+
}
|
|
38563
|
+
)
|
|
38564
|
+
}
|
|
38565
|
+
);
|
|
38566
|
+
}
|
|
38567
|
+
function NextIcon() {
|
|
38568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
38569
|
+
"svg",
|
|
38570
|
+
{
|
|
38571
|
+
stroke: "currentColor",
|
|
38572
|
+
fill: "currentColor",
|
|
38573
|
+
strokeWidth: "0",
|
|
38574
|
+
viewBox: "0 0 24 24",
|
|
38575
|
+
height: "1em",
|
|
38576
|
+
width: "1em",
|
|
38577
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
38578
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("polyline", { fill: "none", "stroke-width": "2", points: "7 2 17 12 7 22" })
|
|
38579
|
+
}
|
|
38580
|
+
);
|
|
38581
|
+
}
|
|
38544
38582
|
function EditIcon3() {
|
|
38545
38583
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
38546
38584
|
"svg",
|
|
@@ -38731,6 +38769,7 @@ function Header({
|
|
|
38731
38769
|
padding
|
|
38732
38770
|
}) {
|
|
38733
38771
|
const [visible, setVisible] = (0, import_react18.useState)(false);
|
|
38772
|
+
const [hovered, setHovered] = (0, import_react18.useState)(false);
|
|
38734
38773
|
const sortIndex = context.sort.findIndex((b) => b.field == header);
|
|
38735
38774
|
const [text, setText] = (0, import_react18.useState)("");
|
|
38736
38775
|
const cellRef = (0, import_react18.useRef)(null);
|
|
@@ -38785,7 +38824,7 @@ function Header({
|
|
|
38785
38824
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38786
38825
|
"div",
|
|
38787
38826
|
{
|
|
38788
|
-
className: "
|
|
38827
|
+
className: " flex items-center justify-center text-center relative ",
|
|
38789
38828
|
style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
|
|
38790
38829
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38791
38830
|
"input",
|
|
@@ -38807,11 +38846,13 @@ function Header({
|
|
|
38807
38846
|
}
|
|
38808
38847
|
) });
|
|
38809
38848
|
} else
|
|
38810
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
38849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: " ", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
38811
38850
|
"div",
|
|
38812
38851
|
{
|
|
38813
38852
|
ref: cellRef,
|
|
38814
|
-
className: "
|
|
38853
|
+
className: " border-r ",
|
|
38854
|
+
onMouseEnter: (e) => setHovered(true),
|
|
38855
|
+
onMouseLeave: (e) => setHovered(false),
|
|
38815
38856
|
style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
|
|
38816
38857
|
children: [
|
|
38817
38858
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex justify-between items-center ", children: [
|
|
@@ -38858,7 +38899,7 @@ function Header({
|
|
|
38858
38899
|
style: { zIndex: 10 },
|
|
38859
38900
|
className: "icon font-bold p-1 cursor-pointer pr-3 ",
|
|
38860
38901
|
onClick: (e) => setVisible(true),
|
|
38861
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropIcon, {})
|
|
38902
|
+
children: hovered ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropIcon, {}) : ""
|
|
38862
38903
|
}
|
|
38863
38904
|
)
|
|
38864
38905
|
] }),
|
|
@@ -38866,7 +38907,7 @@ function Header({
|
|
|
38866
38907
|
"div",
|
|
38867
38908
|
{
|
|
38868
38909
|
onMouseDown: (e) => drag.startDrag(e, header),
|
|
38869
|
-
className: "absolute top-0 h-full cursor-col-resize hover:bg-blue-300
|
|
38910
|
+
className: "absolute top-0 h-full cursor-col-resize hover:bg-blue-300 ",
|
|
38870
38911
|
style: { right: -2, width: 6, zIndex: 20 }
|
|
38871
38912
|
}
|
|
38872
38913
|
),
|
|
@@ -39040,7 +39081,7 @@ var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
|
39040
39081
|
function Searchable({
|
|
39041
39082
|
context
|
|
39042
39083
|
}) {
|
|
39043
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex justify-start p-2 relative w-96", children: [
|
|
39084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex justify-start p-2 relative w-96 text-xs", children: [
|
|
39044
39085
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
39045
39086
|
"input",
|
|
39046
39087
|
{
|
|
@@ -39087,16 +39128,63 @@ function valueFormatter({
|
|
|
39087
39128
|
return value;
|
|
39088
39129
|
}
|
|
39089
39130
|
|
|
39131
|
+
// src/table-advanced/use.pagination.tsx
|
|
39132
|
+
var import_react19 = require("react");
|
|
39133
|
+
function usePaginacion({
|
|
39134
|
+
total,
|
|
39135
|
+
tamanioPagina = 100,
|
|
39136
|
+
paginaInicial = 1
|
|
39137
|
+
}) {
|
|
39138
|
+
const totalPaginas = Math.max(1, Math.ceil(total / tamanioPagina));
|
|
39139
|
+
const [pagina, setPagina] = (0, import_react19.useState)(
|
|
39140
|
+
Math.min(Math.max(paginaInicial, 1), totalPaginas)
|
|
39141
|
+
);
|
|
39142
|
+
const inicio = total === 0 ? 0 : (pagina - 1) * tamanioPagina + 1;
|
|
39143
|
+
const fin = Math.min(pagina * tamanioPagina, total);
|
|
39144
|
+
const rango = (0, import_react19.useMemo)(() => {
|
|
39145
|
+
if (total === 0) return "0 a 0";
|
|
39146
|
+
return `${inicio} a ${fin}`;
|
|
39147
|
+
}, [inicio, fin, total]);
|
|
39148
|
+
const hasNext = pagina < totalPaginas;
|
|
39149
|
+
const hasPrev = pagina > 1;
|
|
39150
|
+
const next = (0, import_react19.useCallback)(() => {
|
|
39151
|
+
setPagina((p) => Math.min(p + 1, totalPaginas));
|
|
39152
|
+
}, [totalPaginas]);
|
|
39153
|
+
const prev = (0, import_react19.useCallback)(() => {
|
|
39154
|
+
setPagina((p) => Math.max(p - 1, 1));
|
|
39155
|
+
}, []);
|
|
39156
|
+
const irAPagina = (0, import_react19.useCallback)(
|
|
39157
|
+
(n) => {
|
|
39158
|
+
setPagina(Math.min(Math.max(n, 1), totalPaginas));
|
|
39159
|
+
},
|
|
39160
|
+
[totalPaginas]
|
|
39161
|
+
);
|
|
39162
|
+
return {
|
|
39163
|
+
rango,
|
|
39164
|
+
inicio,
|
|
39165
|
+
fin,
|
|
39166
|
+
total,
|
|
39167
|
+
pagina,
|
|
39168
|
+
totalPaginas,
|
|
39169
|
+
hasNext,
|
|
39170
|
+
hasPrev,
|
|
39171
|
+
next,
|
|
39172
|
+
prev,
|
|
39173
|
+
irAPagina
|
|
39174
|
+
};
|
|
39175
|
+
}
|
|
39176
|
+
var use_pagination_default = usePaginacion;
|
|
39177
|
+
|
|
39090
39178
|
// src/table-advanced/h.table.tsx
|
|
39091
39179
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
39092
39180
|
function HTable({
|
|
39093
39181
|
context
|
|
39094
39182
|
}) {
|
|
39095
|
-
const [isLoading, setIsloading] = (0,
|
|
39183
|
+
const [isLoading, setIsloading] = (0, import_react20.useState)(false);
|
|
39096
39184
|
const { cols, headers } = context;
|
|
39097
|
-
const [currentIndex, setCurrentIndex] = (0,
|
|
39098
|
-
const tableRef = (0,
|
|
39099
|
-
const modalRef = (0,
|
|
39185
|
+
const [currentIndex, setCurrentIndex] = (0, import_react20.useState)(-1);
|
|
39186
|
+
const tableRef = (0, import_react20.useRef)(null);
|
|
39187
|
+
const modalRef = (0, import_react20.useRef)(null);
|
|
39100
39188
|
const catDensities = { confortable: 80, compact: 30, standard: 53 };
|
|
39101
39189
|
const padding = (context == null ? void 0 : context.rowHeight) || (context == null ? void 0 : context.density) ? catDensities[context == null ? void 0 : context.density] : 53;
|
|
39102
39190
|
function useResizableColumns(headers2, defaultWidth = 160, minWidth = 60) {
|
|
@@ -39110,8 +39198,8 @@ function HTable({
|
|
|
39110
39198
|
function resize(headers3) {
|
|
39111
39199
|
return Object.fromEntries(headers3.map((h) => [h, getWidth(h)]));
|
|
39112
39200
|
}
|
|
39113
|
-
const [widths2, setWidths2] = (0,
|
|
39114
|
-
const startDrag2 = (0,
|
|
39201
|
+
const [widths2, setWidths2] = (0, import_react20.useState)({});
|
|
39202
|
+
const startDrag2 = (0, import_react20.useCallback)(
|
|
39115
39203
|
(e, headerKey) => {
|
|
39116
39204
|
var _a;
|
|
39117
39205
|
e.preventDefault();
|
|
@@ -39146,7 +39234,7 @@ function HTable({
|
|
|
39146
39234
|
return { widths: widths2, gridTemplateColumns: gridTemplateColumns2, startDrag: startDrag2, setWidths: setWidths2 };
|
|
39147
39235
|
}
|
|
39148
39236
|
const { gridTemplateColumns, startDrag, widths, setWidths } = useResizableColumns(headers);
|
|
39149
|
-
(0,
|
|
39237
|
+
(0, import_react20.useEffect)(() => {
|
|
39150
39238
|
if (!tableRef.current) return;
|
|
39151
39239
|
const observer = new ResizeObserver(([entry]) => {
|
|
39152
39240
|
const ocultos = headers.filter(
|
|
@@ -39162,15 +39250,6 @@ function HTable({
|
|
|
39162
39250
|
const sizeadosLength = sizeados.length;
|
|
39163
39251
|
const sizeadosWidth = sizeadosLength * 60;
|
|
39164
39252
|
const w = (ancho - sizeadosWidth - personalizadosSum) / (headers.length - sizeadosLength - personalizados.length - ocultos.length);
|
|
39165
|
-
console.log({
|
|
39166
|
-
w,
|
|
39167
|
-
ancho,
|
|
39168
|
-
sizeadosWidth,
|
|
39169
|
-
personalizadosSum,
|
|
39170
|
-
headers,
|
|
39171
|
-
sizeadosLength,
|
|
39172
|
-
personalizados
|
|
39173
|
-
});
|
|
39174
39253
|
setWidths(
|
|
39175
39254
|
Object.fromEntries(
|
|
39176
39255
|
headers.map((h) => {
|
|
@@ -39192,13 +39271,14 @@ function HTable({
|
|
|
39192
39271
|
(value) => String(value).toLowerCase().includes(context.searchBy.toLowerCase())
|
|
39193
39272
|
);
|
|
39194
39273
|
});
|
|
39274
|
+
const pagination = use_pagination_default({ total: searchedData.length });
|
|
39195
39275
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
39196
39276
|
"div",
|
|
39197
39277
|
{
|
|
39198
39278
|
className: [
|
|
39199
39279
|
context.className,
|
|
39200
39280
|
"bg-white relative",
|
|
39201
|
-
"p-2 border shadow rounded-2xl"
|
|
39281
|
+
"p-2 border shadow rounded-2xl w-full rounded-lg "
|
|
39202
39282
|
].join(" "),
|
|
39203
39283
|
ref: tableRef,
|
|
39204
39284
|
children: [
|
|
@@ -39218,10 +39298,11 @@ function HTable({
|
|
|
39218
39298
|
}
|
|
39219
39299
|
}
|
|
39220
39300
|
return obj;
|
|
39221
|
-
})
|
|
39301
|
+
}),
|
|
39302
|
+
`${context.exportName}.xlsx`
|
|
39222
39303
|
);
|
|
39223
39304
|
},
|
|
39224
|
-
className: "flex gap-1 items-center border shadow rounded p-1 text-white bg-green-800
|
|
39305
|
+
className: "flex gap-1 items-center border shadow rounded p-1 text-white bg-green-800 p-1 text-xs",
|
|
39225
39306
|
children: [
|
|
39226
39307
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ExcelIcon2, {}),
|
|
39227
39308
|
"Exportar"
|
|
@@ -39231,7 +39312,7 @@ function HTable({
|
|
|
39231
39312
|
context.onSelect && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39232
39313
|
"button",
|
|
39233
39314
|
{
|
|
39234
|
-
className: "border shadow rounded p-1 text-white
|
|
39315
|
+
className: "border shadow rounded p-1 text-white p-1 text-xs bg-blue-500 cursor-pointer ",
|
|
39235
39316
|
disabled: context.selected.length == 0,
|
|
39236
39317
|
onClick: async (e) => {
|
|
39237
39318
|
setIsloading(true);
|
|
@@ -39248,7 +39329,7 @@ function HTable({
|
|
|
39248
39329
|
context.onSave && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39249
39330
|
"button",
|
|
39250
39331
|
{
|
|
39251
|
-
className: "border shadow rounded p-1 text-white
|
|
39332
|
+
className: "border shadow rounded p-1 text-white p-1 text-xs bg-blue-500 cursor-pointer ",
|
|
39252
39333
|
onClick: async (e) => {
|
|
39253
39334
|
setIsloading(true);
|
|
39254
39335
|
const ex = context.filteredData.map((d) => {
|
|
@@ -39262,204 +39343,253 @@ function HTable({
|
|
|
39262
39343
|
}
|
|
39263
39344
|
)
|
|
39264
39345
|
] }),
|
|
39265
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
39266
|
-
|
|
39267
|
-
|
|
39268
|
-
|
|
39269
|
-
|
|
39270
|
-
|
|
39271
|
-
|
|
39272
|
-
|
|
39273
|
-
|
|
39274
|
-
|
|
39275
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39276
|
-
Header,
|
|
39277
|
-
{
|
|
39278
|
-
padding,
|
|
39279
|
-
header,
|
|
39280
|
-
context,
|
|
39281
|
-
drag: { gridTemplateColumns, startDrag, widths }
|
|
39282
|
-
}
|
|
39283
|
-
),
|
|
39284
|
-
i < headers.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39285
|
-
"div",
|
|
39286
|
-
{
|
|
39287
|
-
onMouseDown: (e) => startDrag(e, header),
|
|
39288
|
-
style: {
|
|
39289
|
-
position: "absolute",
|
|
39290
|
-
right: -3,
|
|
39291
|
-
top: 0,
|
|
39292
|
-
width: 6,
|
|
39293
|
-
height: "100%",
|
|
39294
|
-
cursor: "col-resize",
|
|
39295
|
-
background: "transparent"
|
|
39296
|
-
},
|
|
39297
|
-
onMouseEnter: (e) => e.currentTarget.style.background = "var(--border-strong, #ccc)",
|
|
39298
|
-
onMouseLeave: (e) => e.currentTarget.style.background = "transparent"
|
|
39299
|
-
}
|
|
39300
|
-
)
|
|
39301
|
-
]
|
|
39302
|
-
},
|
|
39303
|
-
header
|
|
39304
|
-
);
|
|
39305
|
-
}),
|
|
39306
|
-
searchedData.map((row, rowIndex) => {
|
|
39307
|
-
const items = Object.entries(row);
|
|
39308
|
-
return items.map(([key, item], i) => {
|
|
39309
|
-
var _a, _b, _c, _d, _e;
|
|
39310
|
-
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, key)) return null;
|
|
39311
|
-
if (key.startsWith("_") && !key.startsWith("__")) return null;
|
|
39312
|
-
if (key == "__modal__") {
|
|
39313
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39314
|
-
"div",
|
|
39315
|
-
{
|
|
39316
|
-
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39317
|
-
style: {
|
|
39318
|
-
height: `${padding}px`
|
|
39319
|
-
},
|
|
39320
|
-
className: (rowIndex == currentIndex ? " bg-blue-100 " : " bg-white ") + " border-b p-2 flex items-center justify-center " + (context.searchBy && String(item).toLowerCase().includes(context.searchBy.toLowerCase()) ? "bg-yellow-100" : ""),
|
|
39321
|
-
children: (context == null ? void 0 : context.modalButton) || /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39322
|
-
"button",
|
|
39323
|
-
{
|
|
39324
|
-
className: "border shadow rounded bg-blue-500 text-white p-2 ",
|
|
39325
|
-
onClick: (e) => {
|
|
39326
|
-
var _a2;
|
|
39327
|
-
setCurrentIndex(rowIndex);
|
|
39328
|
-
(_a2 = modalRef.current) == null ? void 0 : _a2.click();
|
|
39329
|
-
},
|
|
39330
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EditIcon3, {})
|
|
39331
|
-
}
|
|
39332
|
-
)
|
|
39346
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
39347
|
+
"div",
|
|
39348
|
+
{
|
|
39349
|
+
children: [
|
|
39350
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39351
|
+
"div",
|
|
39352
|
+
{
|
|
39353
|
+
style: {
|
|
39354
|
+
gridTemplateColumns,
|
|
39355
|
+
width: Object.values(widths).reduce((acc, i) => acc + i, 0)
|
|
39333
39356
|
},
|
|
39334
|
-
|
|
39335
|
-
|
|
39336
|
-
|
|
39337
|
-
|
|
39338
|
-
|
|
39339
|
-
|
|
39340
|
-
|
|
39341
|
-
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39342
|
-
style: {
|
|
39343
|
-
height: `${padding}px`
|
|
39344
|
-
},
|
|
39345
|
-
className: (rowIndex == currentIndex ? " bg-blue-100 " : " bg-white ") + " border-b p-2 flex items-center justify-center " + (context.searchBy && String(item).toLowerCase().includes(context.searchBy.toLowerCase()) ? "bg-yellow-100" : ""),
|
|
39346
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39347
|
-
"input",
|
|
39357
|
+
className: ["grid w-full "].join(" "),
|
|
39358
|
+
children: headers.map((header, i) => {
|
|
39359
|
+
var _a, _b;
|
|
39360
|
+
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
|
|
39361
|
+
if (header.startsWith("_") && !header.startsWith("__")) return null;
|
|
39362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39363
|
+
"div",
|
|
39348
39364
|
{
|
|
39349
|
-
|
|
39350
|
-
|
|
39351
|
-
|
|
39352
|
-
|
|
39353
|
-
|
|
39354
|
-
|
|
39355
|
-
|
|
39356
|
-
|
|
39357
|
-
if (index >= 0) {
|
|
39358
|
-
newSelected.splice(index, 1);
|
|
39359
|
-
} else {
|
|
39360
|
-
newSelected.push(row == null ? void 0 : row.id);
|
|
39365
|
+
className: "bg-white relative w-full bg-red-100",
|
|
39366
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39367
|
+
Header,
|
|
39368
|
+
{
|
|
39369
|
+
padding,
|
|
39370
|
+
header,
|
|
39371
|
+
context,
|
|
39372
|
+
drag: { gridTemplateColumns, startDrag, widths }
|
|
39361
39373
|
}
|
|
39362
|
-
|
|
39363
|
-
|
|
39364
|
-
|
|
39365
|
-
)
|
|
39374
|
+
)
|
|
39375
|
+
},
|
|
39376
|
+
header
|
|
39377
|
+
);
|
|
39378
|
+
})
|
|
39379
|
+
}
|
|
39380
|
+
),
|
|
39381
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39382
|
+
"div",
|
|
39383
|
+
{
|
|
39384
|
+
style: {
|
|
39385
|
+
gridTemplateColumns,
|
|
39386
|
+
width: Object.values(widths).reduce((acc, i) => acc + i, 0)
|
|
39366
39387
|
},
|
|
39367
|
-
|
|
39368
|
-
|
|
39369
|
-
|
|
39370
|
-
|
|
39388
|
+
className: [
|
|
39389
|
+
"grid max-h-[500px] overflow-hidden overflow-y-scroll "
|
|
39390
|
+
].join(" "),
|
|
39391
|
+
children: searchedData.slice(pagination.inicio - 1, pagination.fin).map((row, rowIndex) => {
|
|
39392
|
+
const items = Object.entries(row);
|
|
39393
|
+
return items.map(([key, item], i) => {
|
|
39394
|
+
var _a, _b, _c, _d, _e;
|
|
39395
|
+
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, key)) return null;
|
|
39396
|
+
if (key.startsWith("_") && !key.startsWith("__")) return null;
|
|
39397
|
+
if (key == "__modal__") {
|
|
39398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39399
|
+
"div",
|
|
39400
|
+
{
|
|
39401
|
+
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39402
|
+
style: {
|
|
39403
|
+
height: `${padding}px`
|
|
39404
|
+
},
|
|
39405
|
+
className: (rowIndex == currentIndex ? " bg-blue-100 " : " bg-white ") + " border-b p-2 flex items-center justify-center " + (context.searchBy && String(item).toLowerCase().includes(context.searchBy.toLowerCase()) ? "bg-yellow-100" : ""),
|
|
39406
|
+
children: (context == null ? void 0 : context.modalButton) || /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39407
|
+
"button",
|
|
39408
|
+
{
|
|
39409
|
+
className: "border shadow rounded bg-blue-500 text-white p-2 ",
|
|
39410
|
+
onClick: (e) => {
|
|
39411
|
+
var _a2;
|
|
39412
|
+
setCurrentIndex(rowIndex);
|
|
39413
|
+
(_a2 = modalRef.current) == null ? void 0 : _a2.click();
|
|
39414
|
+
},
|
|
39415
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EditIcon3, {})
|
|
39416
|
+
}
|
|
39417
|
+
)
|
|
39418
|
+
},
|
|
39419
|
+
row.id + i
|
|
39420
|
+
);
|
|
39421
|
+
}
|
|
39422
|
+
if (key == "__select__") {
|
|
39423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39424
|
+
"div",
|
|
39425
|
+
{
|
|
39426
|
+
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39427
|
+
style: {
|
|
39428
|
+
height: `${padding}px`
|
|
39429
|
+
},
|
|
39430
|
+
className: (rowIndex == currentIndex ? " bg-blue-100 " : " bg-white ") + " border-b flex items-start p-2 justify-center " + (context.searchBy && String(item).toLowerCase().includes(context.searchBy.toLowerCase()) ? "bg-yellow-100" : ""),
|
|
39431
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39432
|
+
"input",
|
|
39433
|
+
{
|
|
39434
|
+
type: "checkbox",
|
|
39435
|
+
className: "w-5 h-5 accent-blue-600 transition-all duration-300 checked:scale-110 ",
|
|
39436
|
+
checked: Boolean(
|
|
39437
|
+
context.selected.find((s) => s == (row == null ? void 0 : row.id))
|
|
39438
|
+
),
|
|
39439
|
+
onChange: (e) => {
|
|
39440
|
+
const newSelected = [...context.selected];
|
|
39441
|
+
const index = newSelected.findIndex(
|
|
39442
|
+
(s) => s == (row == null ? void 0 : row.id)
|
|
39443
|
+
);
|
|
39444
|
+
if (index >= 0) {
|
|
39445
|
+
newSelected.splice(index, 1);
|
|
39446
|
+
} else {
|
|
39447
|
+
newSelected.push(row == null ? void 0 : row.id);
|
|
39448
|
+
}
|
|
39449
|
+
context.setSelected(newSelected);
|
|
39450
|
+
}
|
|
39451
|
+
}
|
|
39452
|
+
)
|
|
39453
|
+
},
|
|
39454
|
+
row.id + i
|
|
39455
|
+
);
|
|
39456
|
+
}
|
|
39457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39458
|
+
"div",
|
|
39459
|
+
{
|
|
39460
|
+
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39461
|
+
style: {
|
|
39462
|
+
fontSize: (context == null ? void 0 : context.fontSize) || "12px",
|
|
39463
|
+
...(context == null ? void 0 : context.wrapText) ? { minHeight: `${padding}px` } : { height: `${padding}px` }
|
|
39464
|
+
},
|
|
39465
|
+
className: " p-1" + (rowIndex == currentIndex ? " bg-blue-100 " : " bg-white ") + (context.wrapText ? " text-wrap truncate " : " truncate ") + " border-b " + (context.searchBy && String(item).toLowerCase().includes(context.searchBy.toLowerCase()) ? rowIndex == currentIndex ? " bg-yellow-200 " : " bg-yellow-100 " : ""),
|
|
39466
|
+
children: (context == null ? void 0 : context.editableFields) && context.editableFields.includes(key) ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39467
|
+
"input",
|
|
39468
|
+
{
|
|
39469
|
+
defaultValue: item,
|
|
39470
|
+
className: "w-full " + (context.editions.includes(row == null ? void 0 : row.id) ? "bg-blue-400 text-white" : "bg-blue-100"),
|
|
39471
|
+
onBlur: (e) => {
|
|
39472
|
+
const id = row == null ? void 0 : row.id;
|
|
39473
|
+
const newData = [...context.data];
|
|
39474
|
+
const index = newData.findIndex((d) => +d.id == +id);
|
|
39475
|
+
newData[index][key] = e.target.value;
|
|
39476
|
+
context.setData(newData);
|
|
39477
|
+
const newEditions = [
|
|
39478
|
+
.../* @__PURE__ */ new Set([...context.editions, id])
|
|
39479
|
+
];
|
|
39480
|
+
context.setEditions(newEditions);
|
|
39481
|
+
}
|
|
39482
|
+
}
|
|
39483
|
+
) : ((_c = context.buttons) == null ? void 0 : _c[key]) ? import_react20.default.cloneElement(context.buttons[key], {
|
|
39484
|
+
// children: context.buttons[key]?.props?.children
|
|
39485
|
+
// ? item
|
|
39486
|
+
// : undefined,
|
|
39487
|
+
value: item,
|
|
39488
|
+
children: ((_e = (_d = context.buttons[key]) == null ? void 0 : _d.props) == null ? void 0 : _e.children) ? item : null,
|
|
39489
|
+
onClick: async (e) => {
|
|
39490
|
+
var _a2, _b2;
|
|
39491
|
+
const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onClick) == null ? void 0 : _b2.call(_a2, {
|
|
39492
|
+
e,
|
|
39493
|
+
row
|
|
39494
|
+
})) || {};
|
|
39495
|
+
const newData = [...context.data];
|
|
39496
|
+
const index = newData.findIndex(
|
|
39497
|
+
(f) => f.id == (row == null ? void 0 : row.id)
|
|
39498
|
+
);
|
|
39499
|
+
newData[index] = { ...newData[index], ...ret };
|
|
39500
|
+
context.setData(newData);
|
|
39501
|
+
},
|
|
39502
|
+
onChange: async (e) => {
|
|
39503
|
+
var _a2, _b2, _c2;
|
|
39504
|
+
const value = e.target.value;
|
|
39505
|
+
const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onChange) == null ? void 0 : _b2.call(_a2, {
|
|
39506
|
+
e,
|
|
39507
|
+
row
|
|
39508
|
+
})) || {};
|
|
39509
|
+
const newData = [...context.data];
|
|
39510
|
+
const index = newData.findIndex(
|
|
39511
|
+
(f) => f.id == (row == null ? void 0 : row.id)
|
|
39512
|
+
);
|
|
39513
|
+
if (index >= 0) {
|
|
39514
|
+
newData[index][key] = value;
|
|
39515
|
+
}
|
|
39516
|
+
for (let i2 in ret) {
|
|
39517
|
+
if ((_c2 = newData[index]) == null ? void 0 : _c2[i2]) {
|
|
39518
|
+
const v = ret[i2];
|
|
39519
|
+
newData[index][i2] = v;
|
|
39520
|
+
}
|
|
39521
|
+
}
|
|
39522
|
+
context.setData(newData);
|
|
39523
|
+
}
|
|
39524
|
+
}) : ["number", "string"].includes(typeof item) ? valueFormatter({
|
|
39525
|
+
value: item,
|
|
39526
|
+
currentCoin: context.currentCoin
|
|
39527
|
+
}) : import_react20.default.isValidElement(item) ? item : JSON.stringify(item)
|
|
39528
|
+
},
|
|
39529
|
+
row.id + i
|
|
39530
|
+
);
|
|
39531
|
+
});
|
|
39532
|
+
})
|
|
39533
|
+
}
|
|
39534
|
+
),
|
|
39535
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39371
39536
|
"div",
|
|
39372
39537
|
{
|
|
39373
|
-
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39374
39538
|
style: {
|
|
39375
|
-
|
|
39376
|
-
|
|
39539
|
+
gridTemplateColumns,
|
|
39540
|
+
width: Object.values(widths).reduce((acc, i) => acc + i, 0)
|
|
39377
39541
|
},
|
|
39378
|
-
className: "
|
|
39379
|
-
children: (context == null ? void 0 : context.
|
|
39380
|
-
|
|
39542
|
+
className: ["grid border-b bg-white"].join(" "),
|
|
39543
|
+
children: Object.keys((context == null ? void 0 : context.footer) || {}).length > 0 && headers.map((header) => {
|
|
39544
|
+
var _a, _b, _c, _d;
|
|
39545
|
+
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
|
|
39546
|
+
if (header.startsWith("_") && !header.startsWith("__"))
|
|
39547
|
+
return null;
|
|
39548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39549
|
+
"div",
|
|
39550
|
+
{
|
|
39551
|
+
style: {
|
|
39552
|
+
// height: `${padding}px`,
|
|
39553
|
+
maxHeight: "100px"
|
|
39554
|
+
},
|
|
39555
|
+
title: ((_c = context.footer) == null ? void 0 : _c[header]) + " de " + header,
|
|
39556
|
+
className: " cursor-default font-bold bg-white flex items-center justify-center border-r text-xs my-5 ",
|
|
39557
|
+
children: valueFormatter({
|
|
39558
|
+
currentCoin: context.currentCoin,
|
|
39559
|
+
value: ((_d = context.footer) == null ? void 0 : _d[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
|
+
})
|
|
39561
|
+
},
|
|
39562
|
+
header
|
|
39563
|
+
);
|
|
39564
|
+
})
|
|
39565
|
+
}
|
|
39566
|
+
),
|
|
39567
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex justify-end p-2", children: [
|
|
39568
|
+
pagination.rango,
|
|
39569
|
+
" de ",
|
|
39570
|
+
pagination.total,
|
|
39571
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center gap-5 mx-5", children: [
|
|
39572
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39573
|
+
"button",
|
|
39381
39574
|
{
|
|
39382
|
-
|
|
39383
|
-
className:
|
|
39384
|
-
|
|
39385
|
-
const id = row == null ? void 0 : row.id;
|
|
39386
|
-
const newData = [...context.data];
|
|
39387
|
-
const index = newData.findIndex((d) => +d.id == +id);
|
|
39388
|
-
newData[index][key] = e.target.value;
|
|
39389
|
-
context.setData(newData);
|
|
39390
|
-
const newEditions = [
|
|
39391
|
-
.../* @__PURE__ */ new Set([...context.editions, id])
|
|
39392
|
-
];
|
|
39393
|
-
context.setEditions(newEditions);
|
|
39394
|
-
}
|
|
39575
|
+
onClick: (e) => pagination.hasPrev && pagination.prev(),
|
|
39576
|
+
className: pagination.hasPrev ? "" : "text-gray-300",
|
|
39577
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PrevIcon, {})
|
|
39395
39578
|
}
|
|
39396
|
-
)
|
|
39397
|
-
|
|
39398
|
-
|
|
39399
|
-
|
|
39400
|
-
|
|
39401
|
-
|
|
39402
|
-
|
|
39403
|
-
var _a2, _b2;
|
|
39404
|
-
const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onClick) == null ? void 0 : _b2.call(_a2, {
|
|
39405
|
-
e,
|
|
39406
|
-
row
|
|
39407
|
-
})) || {};
|
|
39408
|
-
const newData = [...context.data];
|
|
39409
|
-
const index = newData.findIndex((f) => f.id == (row == null ? void 0 : row.id));
|
|
39410
|
-
newData[index] = { ...newData[index], ...ret };
|
|
39411
|
-
context.setData(newData);
|
|
39412
|
-
},
|
|
39413
|
-
onChange: async (e) => {
|
|
39414
|
-
var _a2, _b2, _c2;
|
|
39415
|
-
const value = e.target.value;
|
|
39416
|
-
const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onChange) == null ? void 0 : _b2.call(_a2, {
|
|
39417
|
-
e,
|
|
39418
|
-
row
|
|
39419
|
-
})) || {};
|
|
39420
|
-
const newData = [...context.data];
|
|
39421
|
-
const index = newData.findIndex((f) => f.id == (row == null ? void 0 : row.id));
|
|
39422
|
-
if (index >= 0) {
|
|
39423
|
-
newData[index][key] = value;
|
|
39424
|
-
}
|
|
39425
|
-
for (let i2 in ret) {
|
|
39426
|
-
if ((_c2 = newData[index]) == null ? void 0 : _c2[i2]) {
|
|
39427
|
-
const v = ret[i2];
|
|
39428
|
-
newData[index][i2] = v;
|
|
39429
|
-
}
|
|
39430
|
-
}
|
|
39431
|
-
context.setData(newData);
|
|
39579
|
+
),
|
|
39580
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39581
|
+
"button",
|
|
39582
|
+
{
|
|
39583
|
+
onClick: (e) => pagination.hasNext && pagination.next(),
|
|
39584
|
+
className: pagination.hasNext ? "" : "text-gray-300",
|
|
39585
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(NextIcon, {})
|
|
39432
39586
|
}
|
|
39433
|
-
|
|
39434
|
-
|
|
39435
|
-
|
|
39436
|
-
|
|
39437
|
-
|
|
39438
|
-
|
|
39439
|
-
);
|
|
39440
|
-
});
|
|
39441
|
-
}),
|
|
39442
|
-
Object.keys((context == null ? void 0 : context.footer) || {}).length > 0 && headers.map((header) => {
|
|
39443
|
-
var _a, _b, _c;
|
|
39444
|
-
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
|
|
39445
|
-
if (header.startsWith("_") && !header.startsWith("__")) return null;
|
|
39446
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39447
|
-
"div",
|
|
39448
|
-
{
|
|
39449
|
-
style: {
|
|
39450
|
-
height: `${padding}px`,
|
|
39451
|
-
maxHeight: "100px"
|
|
39452
|
-
},
|
|
39453
|
-
className: "border-b font-bold bg-white flex items-center justify-center",
|
|
39454
|
-
children: valueFormatter({
|
|
39455
|
-
currentCoin: context.currentCoin,
|
|
39456
|
-
value: ((_c = context.footer) == null ? void 0 : _c[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) : "" : ""
|
|
39457
|
-
})
|
|
39458
|
-
},
|
|
39459
|
-
header
|
|
39460
|
-
);
|
|
39461
|
-
})
|
|
39462
|
-
] }),
|
|
39587
|
+
)
|
|
39588
|
+
] })
|
|
39589
|
+
] })
|
|
39590
|
+
]
|
|
39591
|
+
}
|
|
39592
|
+
),
|
|
39463
39593
|
context.modal && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39464
39594
|
Modal,
|
|
39465
39595
|
{
|
|
@@ -39529,7 +39659,7 @@ function ModalContent({
|
|
|
39529
39659
|
}
|
|
39530
39660
|
)
|
|
39531
39661
|
] }),
|
|
39532
|
-
|
|
39662
|
+
import_react20.default.cloneElement(context.modal, {
|
|
39533
39663
|
row: searchedData[currentIndex],
|
|
39534
39664
|
hide
|
|
39535
39665
|
})
|
|
@@ -39537,7 +39667,7 @@ function ModalContent({
|
|
|
39537
39667
|
}
|
|
39538
39668
|
|
|
39539
39669
|
// src/table-advanced/context.ts
|
|
39540
|
-
var
|
|
39670
|
+
var import_react21 = require("react");
|
|
39541
39671
|
|
|
39542
39672
|
// src/table-advanced/filter.reducer.ts
|
|
39543
39673
|
var filterReducer = (acc, b) => {
|
|
@@ -39565,19 +39695,19 @@ var sortReducer = (acc, b) => {
|
|
|
39565
39695
|
// src/table-advanced/context.ts
|
|
39566
39696
|
function useContext({ onSelect }) {
|
|
39567
39697
|
const excel = useExcel();
|
|
39568
|
-
const [editions, setEditions] = (0,
|
|
39569
|
-
const [selected, setSelected] = (0,
|
|
39570
|
-
const [data, setData] = (0,
|
|
39698
|
+
const [editions, setEditions] = (0, import_react21.useState)([]);
|
|
39699
|
+
const [selected, setSelected] = (0, import_react21.useState)([]);
|
|
39700
|
+
const [data, setData] = (0, import_react21.useState)([]);
|
|
39571
39701
|
const headers = [...new Set(data.map((b) => Object.keys(b)).flat())];
|
|
39572
|
-
const [currentHeader, setCurrentHeader] = (0,
|
|
39702
|
+
const [currentHeader, setCurrentHeader] = (0, import_react21.useState)(null);
|
|
39573
39703
|
const cols = headers.length;
|
|
39574
|
-
const [filters, setFilters] = (0,
|
|
39704
|
+
const [filters, setFilters] = (0, import_react21.useReducer)(
|
|
39575
39705
|
filterReducer,
|
|
39576
39706
|
new Array()
|
|
39577
39707
|
);
|
|
39578
|
-
const [searchBy, setSearchBy] = (0,
|
|
39579
|
-
const [sort, setSort] = (0,
|
|
39580
|
-
const sortedData = (0,
|
|
39708
|
+
const [searchBy, setSearchBy] = (0, import_react21.useState)("");
|
|
39709
|
+
const [sort, setSort] = (0, import_react21.useReducer)(sortReducer, new Array());
|
|
39710
|
+
const sortedData = (0, import_react21.useMemo)(() => {
|
|
39581
39711
|
return [...data].sort((a, b) => {
|
|
39582
39712
|
for (const { field, type } of sort.reverse()) {
|
|
39583
39713
|
const av = a[field];
|
|
@@ -39607,7 +39737,7 @@ function useContext({ onSelect }) {
|
|
|
39607
39737
|
}
|
|
39608
39738
|
return true;
|
|
39609
39739
|
});
|
|
39610
|
-
(0,
|
|
39740
|
+
(0, import_react21.useEffect)(() => {
|
|
39611
39741
|
if (filters.length == 0) {
|
|
39612
39742
|
setEditions([]);
|
|
39613
39743
|
}
|
|
@@ -39640,7 +39770,7 @@ var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
|
39640
39770
|
function TableAdvanced(tableProps) {
|
|
39641
39771
|
const { data, ...props } = tableProps;
|
|
39642
39772
|
const context = useContext({ onSelect: Boolean(tableProps.onSelect) });
|
|
39643
|
-
(0,
|
|
39773
|
+
(0, import_react22.useEffect)(() => {
|
|
39644
39774
|
context.setData(
|
|
39645
39775
|
Array.isArray(data) ? data.map((d) => {
|
|
39646
39776
|
return {
|
|
@@ -39651,7 +39781,7 @@ function TableAdvanced(tableProps) {
|
|
|
39651
39781
|
}) : data
|
|
39652
39782
|
);
|
|
39653
39783
|
}, [data]);
|
|
39654
|
-
(0,
|
|
39784
|
+
(0, import_react22.useEffect)(() => {
|
|
39655
39785
|
if (tableProps == null ? void 0 : tableProps.sortBy) {
|
|
39656
39786
|
const [k, v] = Object.entries(tableProps.sortBy)[0];
|
|
39657
39787
|
context.setSort({ [k]: v });
|
|
@@ -39670,15 +39800,15 @@ function TableAdvanced(tableProps) {
|
|
|
39670
39800
|
}
|
|
39671
39801
|
|
|
39672
39802
|
// src/tabs/index.tsx
|
|
39673
|
-
var
|
|
39803
|
+
var import_react23 = __toESM(require("react"));
|
|
39674
39804
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
39675
39805
|
function TabContainer({
|
|
39676
39806
|
children,
|
|
39677
39807
|
labelMaxWidth = 100,
|
|
39678
39808
|
currentIndex = 0
|
|
39679
39809
|
}) {
|
|
39680
|
-
const [index, setIndex] = (0,
|
|
39681
|
-
const items =
|
|
39810
|
+
const [index, setIndex] = (0, import_react23.useState)(0);
|
|
39811
|
+
const items = import_react23.default.Children.toArray(
|
|
39682
39812
|
children
|
|
39683
39813
|
);
|
|
39684
39814
|
const labels = items.map((c) => c.props.label);
|
|
@@ -39687,7 +39817,7 @@ function TabContainer({
|
|
|
39687
39817
|
if (e.key === "ArrowLeft")
|
|
39688
39818
|
setIndex((k - 1 + labels.length) % labels.length);
|
|
39689
39819
|
};
|
|
39690
|
-
(0,
|
|
39820
|
+
(0, import_react23.useEffect)(() => {
|
|
39691
39821
|
setIndex(currentIndex);
|
|
39692
39822
|
}, [currentIndex]);
|
|
39693
39823
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "w-full bg-white", children: [
|