next-recomponents 2.0.55 → 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.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +421 -229
- package/dist/index.mjs +410 -220
- package/package.json +1 -1
- package/src/index.tsx +2 -0
- 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/src/tabs/index.tsx +83 -0
package/dist/index.js
CHANGED
|
@@ -3498,6 +3498,8 @@ __export(index_exports, {
|
|
|
3498
3498
|
MyCalendar: () => MyCalendar,
|
|
3499
3499
|
Pre: () => pre_default,
|
|
3500
3500
|
Select: () => Select,
|
|
3501
|
+
TabContainer: () => TabContainer,
|
|
3502
|
+
TabItem: () => TabItem,
|
|
3501
3503
|
Table: () => Table,
|
|
3502
3504
|
Table3: () => Table3,
|
|
3503
3505
|
TableAdvanced: () => TableAdvanced,
|
|
@@ -38508,10 +38510,10 @@ function Table3({
|
|
|
38508
38510
|
}
|
|
38509
38511
|
|
|
38510
38512
|
// src/table-advanced/index.tsx
|
|
38511
|
-
var
|
|
38513
|
+
var import_react22 = require("react");
|
|
38512
38514
|
|
|
38513
38515
|
// src/table-advanced/h.table.tsx
|
|
38514
|
-
var
|
|
38516
|
+
var import_react20 = __toESM(require("react"));
|
|
38515
38517
|
|
|
38516
38518
|
// src/table-advanced/header.tsx
|
|
38517
38519
|
var import_react18 = require("react");
|
|
@@ -38539,6 +38541,44 @@ function DropIcon() {
|
|
|
38539
38541
|
}
|
|
38540
38542
|
);
|
|
38541
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
|
+
}
|
|
38542
38582
|
function EditIcon3() {
|
|
38543
38583
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
38544
38584
|
"svg",
|
|
@@ -38729,6 +38769,7 @@ function Header({
|
|
|
38729
38769
|
padding
|
|
38730
38770
|
}) {
|
|
38731
38771
|
const [visible, setVisible] = (0, import_react18.useState)(false);
|
|
38772
|
+
const [hovered, setHovered] = (0, import_react18.useState)(false);
|
|
38732
38773
|
const sortIndex = context.sort.findIndex((b) => b.field == header);
|
|
38733
38774
|
const [text, setText] = (0, import_react18.useState)("");
|
|
38734
38775
|
const cellRef = (0, import_react18.useRef)(null);
|
|
@@ -38783,7 +38824,7 @@ function Header({
|
|
|
38783
38824
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38784
38825
|
"div",
|
|
38785
38826
|
{
|
|
38786
|
-
className: "
|
|
38827
|
+
className: " flex items-center justify-center text-center relative ",
|
|
38787
38828
|
style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
|
|
38788
38829
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
38789
38830
|
"input",
|
|
@@ -38805,11 +38846,13 @@ function Header({
|
|
|
38805
38846
|
}
|
|
38806
38847
|
) });
|
|
38807
38848
|
} else
|
|
38808
|
-
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)(
|
|
38809
38850
|
"div",
|
|
38810
38851
|
{
|
|
38811
38852
|
ref: cellRef,
|
|
38812
|
-
className: "
|
|
38853
|
+
className: " border-r ",
|
|
38854
|
+
onMouseEnter: (e) => setHovered(true),
|
|
38855
|
+
onMouseLeave: (e) => setHovered(false),
|
|
38813
38856
|
style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
|
|
38814
38857
|
children: [
|
|
38815
38858
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex justify-between items-center ", children: [
|
|
@@ -38856,7 +38899,7 @@ function Header({
|
|
|
38856
38899
|
style: { zIndex: 10 },
|
|
38857
38900
|
className: "icon font-bold p-1 cursor-pointer pr-3 ",
|
|
38858
38901
|
onClick: (e) => setVisible(true),
|
|
38859
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropIcon, {})
|
|
38902
|
+
children: hovered ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropIcon, {}) : ""
|
|
38860
38903
|
}
|
|
38861
38904
|
)
|
|
38862
38905
|
] }),
|
|
@@ -38864,7 +38907,7 @@ function Header({
|
|
|
38864
38907
|
"div",
|
|
38865
38908
|
{
|
|
38866
38909
|
onMouseDown: (e) => drag.startDrag(e, header),
|
|
38867
|
-
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 ",
|
|
38868
38911
|
style: { right: -2, width: 6, zIndex: 20 }
|
|
38869
38912
|
}
|
|
38870
38913
|
),
|
|
@@ -39038,7 +39081,7 @@ var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
|
39038
39081
|
function Searchable({
|
|
39039
39082
|
context
|
|
39040
39083
|
}) {
|
|
39041
|
-
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: [
|
|
39042
39085
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
39043
39086
|
"input",
|
|
39044
39087
|
{
|
|
@@ -39085,16 +39128,63 @@ function valueFormatter({
|
|
|
39085
39128
|
return value;
|
|
39086
39129
|
}
|
|
39087
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
|
+
|
|
39088
39178
|
// src/table-advanced/h.table.tsx
|
|
39089
39179
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
39090
39180
|
function HTable({
|
|
39091
39181
|
context
|
|
39092
39182
|
}) {
|
|
39093
|
-
const [isLoading, setIsloading] = (0,
|
|
39183
|
+
const [isLoading, setIsloading] = (0, import_react20.useState)(false);
|
|
39094
39184
|
const { cols, headers } = context;
|
|
39095
|
-
const [currentIndex, setCurrentIndex] = (0,
|
|
39096
|
-
const tableRef = (0,
|
|
39097
|
-
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);
|
|
39098
39188
|
const catDensities = { confortable: 80, compact: 30, standard: 53 };
|
|
39099
39189
|
const padding = (context == null ? void 0 : context.rowHeight) || (context == null ? void 0 : context.density) ? catDensities[context == null ? void 0 : context.density] : 53;
|
|
39100
39190
|
function useResizableColumns(headers2, defaultWidth = 160, minWidth = 60) {
|
|
@@ -39108,8 +39198,8 @@ function HTable({
|
|
|
39108
39198
|
function resize(headers3) {
|
|
39109
39199
|
return Object.fromEntries(headers3.map((h) => [h, getWidth(h)]));
|
|
39110
39200
|
}
|
|
39111
|
-
const [widths2, setWidths2] = (0,
|
|
39112
|
-
const startDrag2 = (0,
|
|
39201
|
+
const [widths2, setWidths2] = (0, import_react20.useState)({});
|
|
39202
|
+
const startDrag2 = (0, import_react20.useCallback)(
|
|
39113
39203
|
(e, headerKey) => {
|
|
39114
39204
|
var _a;
|
|
39115
39205
|
e.preventDefault();
|
|
@@ -39144,7 +39234,7 @@ function HTable({
|
|
|
39144
39234
|
return { widths: widths2, gridTemplateColumns: gridTemplateColumns2, startDrag: startDrag2, setWidths: setWidths2 };
|
|
39145
39235
|
}
|
|
39146
39236
|
const { gridTemplateColumns, startDrag, widths, setWidths } = useResizableColumns(headers);
|
|
39147
|
-
(0,
|
|
39237
|
+
(0, import_react20.useEffect)(() => {
|
|
39148
39238
|
if (!tableRef.current) return;
|
|
39149
39239
|
const observer = new ResizeObserver(([entry]) => {
|
|
39150
39240
|
const ocultos = headers.filter(
|
|
@@ -39160,15 +39250,6 @@ function HTable({
|
|
|
39160
39250
|
const sizeadosLength = sizeados.length;
|
|
39161
39251
|
const sizeadosWidth = sizeadosLength * 60;
|
|
39162
39252
|
const w = (ancho - sizeadosWidth - personalizadosSum) / (headers.length - sizeadosLength - personalizados.length - ocultos.length);
|
|
39163
|
-
console.log({
|
|
39164
|
-
w,
|
|
39165
|
-
ancho,
|
|
39166
|
-
sizeadosWidth,
|
|
39167
|
-
personalizadosSum,
|
|
39168
|
-
headers,
|
|
39169
|
-
sizeadosLength,
|
|
39170
|
-
personalizados
|
|
39171
|
-
});
|
|
39172
39253
|
setWidths(
|
|
39173
39254
|
Object.fromEntries(
|
|
39174
39255
|
headers.map((h) => {
|
|
@@ -39190,13 +39271,14 @@ function HTable({
|
|
|
39190
39271
|
(value) => String(value).toLowerCase().includes(context.searchBy.toLowerCase())
|
|
39191
39272
|
);
|
|
39192
39273
|
});
|
|
39274
|
+
const pagination = use_pagination_default({ total: searchedData.length });
|
|
39193
39275
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
39194
39276
|
"div",
|
|
39195
39277
|
{
|
|
39196
39278
|
className: [
|
|
39197
39279
|
context.className,
|
|
39198
39280
|
"bg-white relative",
|
|
39199
|
-
"p-2 border shadow rounded-2xl"
|
|
39281
|
+
"p-2 border shadow rounded-2xl w-full rounded-lg "
|
|
39200
39282
|
].join(" "),
|
|
39201
39283
|
ref: tableRef,
|
|
39202
39284
|
children: [
|
|
@@ -39216,10 +39298,11 @@ function HTable({
|
|
|
39216
39298
|
}
|
|
39217
39299
|
}
|
|
39218
39300
|
return obj;
|
|
39219
|
-
})
|
|
39301
|
+
}),
|
|
39302
|
+
`${context.exportName}.xlsx`
|
|
39220
39303
|
);
|
|
39221
39304
|
},
|
|
39222
|
-
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",
|
|
39223
39306
|
children: [
|
|
39224
39307
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ExcelIcon2, {}),
|
|
39225
39308
|
"Exportar"
|
|
@@ -39229,7 +39312,7 @@ function HTable({
|
|
|
39229
39312
|
context.onSelect && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39230
39313
|
"button",
|
|
39231
39314
|
{
|
|
39232
|
-
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 ",
|
|
39233
39316
|
disabled: context.selected.length == 0,
|
|
39234
39317
|
onClick: async (e) => {
|
|
39235
39318
|
setIsloading(true);
|
|
@@ -39246,7 +39329,7 @@ function HTable({
|
|
|
39246
39329
|
context.onSave && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39247
39330
|
"button",
|
|
39248
39331
|
{
|
|
39249
|
-
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 ",
|
|
39250
39333
|
onClick: async (e) => {
|
|
39251
39334
|
setIsloading(true);
|
|
39252
39335
|
const ex = context.filteredData.map((d) => {
|
|
@@ -39260,204 +39343,253 @@ function HTable({
|
|
|
39260
39343
|
}
|
|
39261
39344
|
)
|
|
39262
39345
|
] }),
|
|
39263
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
39264
|
-
|
|
39265
|
-
|
|
39266
|
-
|
|
39267
|
-
|
|
39268
|
-
|
|
39269
|
-
|
|
39270
|
-
|
|
39271
|
-
|
|
39272
|
-
|
|
39273
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39274
|
-
Header,
|
|
39275
|
-
{
|
|
39276
|
-
padding,
|
|
39277
|
-
header,
|
|
39278
|
-
context,
|
|
39279
|
-
drag: { gridTemplateColumns, startDrag, widths }
|
|
39280
|
-
}
|
|
39281
|
-
),
|
|
39282
|
-
i < headers.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39283
|
-
"div",
|
|
39284
|
-
{
|
|
39285
|
-
onMouseDown: (e) => startDrag(e, header),
|
|
39286
|
-
style: {
|
|
39287
|
-
position: "absolute",
|
|
39288
|
-
right: -3,
|
|
39289
|
-
top: 0,
|
|
39290
|
-
width: 6,
|
|
39291
|
-
height: "100%",
|
|
39292
|
-
cursor: "col-resize",
|
|
39293
|
-
background: "transparent"
|
|
39294
|
-
},
|
|
39295
|
-
onMouseEnter: (e) => e.currentTarget.style.background = "var(--border-strong, #ccc)",
|
|
39296
|
-
onMouseLeave: (e) => e.currentTarget.style.background = "transparent"
|
|
39297
|
-
}
|
|
39298
|
-
)
|
|
39299
|
-
]
|
|
39300
|
-
},
|
|
39301
|
-
header
|
|
39302
|
-
);
|
|
39303
|
-
}),
|
|
39304
|
-
searchedData.map((row, rowIndex) => {
|
|
39305
|
-
const items = Object.entries(row);
|
|
39306
|
-
return items.map(([key, item], i) => {
|
|
39307
|
-
var _a, _b, _c, _d, _e;
|
|
39308
|
-
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, key)) return null;
|
|
39309
|
-
if (key.startsWith("_") && !key.startsWith("__")) return null;
|
|
39310
|
-
if (key == "__modal__") {
|
|
39311
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39312
|
-
"div",
|
|
39313
|
-
{
|
|
39314
|
-
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39315
|
-
style: {
|
|
39316
|
-
height: `${padding}px`
|
|
39317
|
-
},
|
|
39318
|
-
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" : ""),
|
|
39319
|
-
children: (context == null ? void 0 : context.modalButton) || /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39320
|
-
"button",
|
|
39321
|
-
{
|
|
39322
|
-
className: "border shadow rounded bg-blue-500 text-white p-2 ",
|
|
39323
|
-
onClick: (e) => {
|
|
39324
|
-
var _a2;
|
|
39325
|
-
setCurrentIndex(rowIndex);
|
|
39326
|
-
(_a2 = modalRef.current) == null ? void 0 : _a2.click();
|
|
39327
|
-
},
|
|
39328
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EditIcon3, {})
|
|
39329
|
-
}
|
|
39330
|
-
)
|
|
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)
|
|
39331
39356
|
},
|
|
39332
|
-
|
|
39333
|
-
|
|
39334
|
-
|
|
39335
|
-
|
|
39336
|
-
|
|
39337
|
-
|
|
39338
|
-
|
|
39339
|
-
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39340
|
-
style: {
|
|
39341
|
-
height: `${padding}px`
|
|
39342
|
-
},
|
|
39343
|
-
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" : ""),
|
|
39344
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39345
|
-
"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",
|
|
39346
39364
|
{
|
|
39347
|
-
|
|
39348
|
-
|
|
39349
|
-
|
|
39350
|
-
|
|
39351
|
-
|
|
39352
|
-
|
|
39353
|
-
|
|
39354
|
-
|
|
39355
|
-
if (index >= 0) {
|
|
39356
|
-
newSelected.splice(index, 1);
|
|
39357
|
-
} else {
|
|
39358
|
-
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 }
|
|
39359
39373
|
}
|
|
39360
|
-
|
|
39361
|
-
|
|
39362
|
-
|
|
39363
|
-
)
|
|
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)
|
|
39364
39387
|
},
|
|
39365
|
-
|
|
39366
|
-
|
|
39367
|
-
|
|
39368
|
-
|
|
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)(
|
|
39369
39536
|
"div",
|
|
39370
39537
|
{
|
|
39371
|
-
onMouseEnter: (e) => setCurrentIndex(rowIndex),
|
|
39372
39538
|
style: {
|
|
39373
|
-
|
|
39374
|
-
|
|
39539
|
+
gridTemplateColumns,
|
|
39540
|
+
width: Object.values(widths).reduce((acc, i) => acc + i, 0)
|
|
39375
39541
|
},
|
|
39376
|
-
className: "
|
|
39377
|
-
children: (context == null ? void 0 : context.
|
|
39378
|
-
|
|
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",
|
|
39379
39574
|
{
|
|
39380
|
-
|
|
39381
|
-
className:
|
|
39382
|
-
|
|
39383
|
-
const id = row == null ? void 0 : row.id;
|
|
39384
|
-
const newData = [...context.data];
|
|
39385
|
-
const index = newData.findIndex((d) => +d.id == +id);
|
|
39386
|
-
newData[index][key] = e.target.value;
|
|
39387
|
-
context.setData(newData);
|
|
39388
|
-
const newEditions = [
|
|
39389
|
-
.../* @__PURE__ */ new Set([...context.editions, id])
|
|
39390
|
-
];
|
|
39391
|
-
context.setEditions(newEditions);
|
|
39392
|
-
}
|
|
39575
|
+
onClick: (e) => pagination.hasPrev && pagination.prev(),
|
|
39576
|
+
className: pagination.hasPrev ? "" : "text-gray-300",
|
|
39577
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PrevIcon, {})
|
|
39393
39578
|
}
|
|
39394
|
-
)
|
|
39395
|
-
|
|
39396
|
-
|
|
39397
|
-
|
|
39398
|
-
|
|
39399
|
-
|
|
39400
|
-
|
|
39401
|
-
var _a2, _b2;
|
|
39402
|
-
const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onClick) == null ? void 0 : _b2.call(_a2, {
|
|
39403
|
-
e,
|
|
39404
|
-
row
|
|
39405
|
-
})) || {};
|
|
39406
|
-
const newData = [...context.data];
|
|
39407
|
-
const index = newData.findIndex((f) => f.id == (row == null ? void 0 : row.id));
|
|
39408
|
-
newData[index] = { ...newData[index], ...ret };
|
|
39409
|
-
context.setData(newData);
|
|
39410
|
-
},
|
|
39411
|
-
onChange: async (e) => {
|
|
39412
|
-
var _a2, _b2, _c2;
|
|
39413
|
-
const value = e.target.value;
|
|
39414
|
-
const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onChange) == null ? void 0 : _b2.call(_a2, {
|
|
39415
|
-
e,
|
|
39416
|
-
row
|
|
39417
|
-
})) || {};
|
|
39418
|
-
const newData = [...context.data];
|
|
39419
|
-
const index = newData.findIndex((f) => f.id == (row == null ? void 0 : row.id));
|
|
39420
|
-
if (index >= 0) {
|
|
39421
|
-
newData[index][key] = value;
|
|
39422
|
-
}
|
|
39423
|
-
for (let i2 in ret) {
|
|
39424
|
-
if ((_c2 = newData[index]) == null ? void 0 : _c2[i2]) {
|
|
39425
|
-
const v = ret[i2];
|
|
39426
|
-
newData[index][i2] = v;
|
|
39427
|
-
}
|
|
39428
|
-
}
|
|
39429
|
-
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, {})
|
|
39430
39586
|
}
|
|
39431
|
-
|
|
39432
|
-
|
|
39433
|
-
|
|
39434
|
-
|
|
39435
|
-
|
|
39436
|
-
|
|
39437
|
-
);
|
|
39438
|
-
});
|
|
39439
|
-
}),
|
|
39440
|
-
Object.keys((context == null ? void 0 : context.footer) || {}).length > 0 && headers.map((header) => {
|
|
39441
|
-
var _a, _b, _c;
|
|
39442
|
-
if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
|
|
39443
|
-
if (header.startsWith("_") && !header.startsWith("__")) return null;
|
|
39444
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39445
|
-
"div",
|
|
39446
|
-
{
|
|
39447
|
-
style: {
|
|
39448
|
-
height: `${padding}px`,
|
|
39449
|
-
maxHeight: "100px"
|
|
39450
|
-
},
|
|
39451
|
-
className: "border-b font-bold bg-white flex items-center justify-center",
|
|
39452
|
-
children: valueFormatter({
|
|
39453
|
-
currentCoin: context.currentCoin,
|
|
39454
|
-
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) : "" : ""
|
|
39455
|
-
})
|
|
39456
|
-
},
|
|
39457
|
-
header
|
|
39458
|
-
);
|
|
39459
|
-
})
|
|
39460
|
-
] }),
|
|
39587
|
+
)
|
|
39588
|
+
] })
|
|
39589
|
+
] })
|
|
39590
|
+
]
|
|
39591
|
+
}
|
|
39592
|
+
),
|
|
39461
39593
|
context.modal && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
39462
39594
|
Modal,
|
|
39463
39595
|
{
|
|
@@ -39527,7 +39659,7 @@ function ModalContent({
|
|
|
39527
39659
|
}
|
|
39528
39660
|
)
|
|
39529
39661
|
] }),
|
|
39530
|
-
|
|
39662
|
+
import_react20.default.cloneElement(context.modal, {
|
|
39531
39663
|
row: searchedData[currentIndex],
|
|
39532
39664
|
hide
|
|
39533
39665
|
})
|
|
@@ -39535,7 +39667,7 @@ function ModalContent({
|
|
|
39535
39667
|
}
|
|
39536
39668
|
|
|
39537
39669
|
// src/table-advanced/context.ts
|
|
39538
|
-
var
|
|
39670
|
+
var import_react21 = require("react");
|
|
39539
39671
|
|
|
39540
39672
|
// src/table-advanced/filter.reducer.ts
|
|
39541
39673
|
var filterReducer = (acc, b) => {
|
|
@@ -39563,19 +39695,19 @@ var sortReducer = (acc, b) => {
|
|
|
39563
39695
|
// src/table-advanced/context.ts
|
|
39564
39696
|
function useContext({ onSelect }) {
|
|
39565
39697
|
const excel = useExcel();
|
|
39566
|
-
const [editions, setEditions] = (0,
|
|
39567
|
-
const [selected, setSelected] = (0,
|
|
39568
|
-
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)([]);
|
|
39569
39701
|
const headers = [...new Set(data.map((b) => Object.keys(b)).flat())];
|
|
39570
|
-
const [currentHeader, setCurrentHeader] = (0,
|
|
39702
|
+
const [currentHeader, setCurrentHeader] = (0, import_react21.useState)(null);
|
|
39571
39703
|
const cols = headers.length;
|
|
39572
|
-
const [filters, setFilters] = (0,
|
|
39704
|
+
const [filters, setFilters] = (0, import_react21.useReducer)(
|
|
39573
39705
|
filterReducer,
|
|
39574
39706
|
new Array()
|
|
39575
39707
|
);
|
|
39576
|
-
const [searchBy, setSearchBy] = (0,
|
|
39577
|
-
const [sort, setSort] = (0,
|
|
39578
|
-
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)(() => {
|
|
39579
39711
|
return [...data].sort((a, b) => {
|
|
39580
39712
|
for (const { field, type } of sort.reverse()) {
|
|
39581
39713
|
const av = a[field];
|
|
@@ -39605,7 +39737,7 @@ function useContext({ onSelect }) {
|
|
|
39605
39737
|
}
|
|
39606
39738
|
return true;
|
|
39607
39739
|
});
|
|
39608
|
-
(0,
|
|
39740
|
+
(0, import_react21.useEffect)(() => {
|
|
39609
39741
|
if (filters.length == 0) {
|
|
39610
39742
|
setEditions([]);
|
|
39611
39743
|
}
|
|
@@ -39638,7 +39770,7 @@ var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
|
39638
39770
|
function TableAdvanced(tableProps) {
|
|
39639
39771
|
const { data, ...props } = tableProps;
|
|
39640
39772
|
const context = useContext({ onSelect: Boolean(tableProps.onSelect) });
|
|
39641
|
-
(0,
|
|
39773
|
+
(0, import_react22.useEffect)(() => {
|
|
39642
39774
|
context.setData(
|
|
39643
39775
|
Array.isArray(data) ? data.map((d) => {
|
|
39644
39776
|
return {
|
|
@@ -39649,7 +39781,7 @@ function TableAdvanced(tableProps) {
|
|
|
39649
39781
|
}) : data
|
|
39650
39782
|
);
|
|
39651
39783
|
}, [data]);
|
|
39652
|
-
(0,
|
|
39784
|
+
(0, import_react22.useEffect)(() => {
|
|
39653
39785
|
if (tableProps == null ? void 0 : tableProps.sortBy) {
|
|
39654
39786
|
const [k, v] = Object.entries(tableProps.sortBy)[0];
|
|
39655
39787
|
context.setSort({ [k]: v });
|
|
@@ -39666,6 +39798,64 @@ function TableAdvanced(tableProps) {
|
|
|
39666
39798
|
}
|
|
39667
39799
|
return null;
|
|
39668
39800
|
}
|
|
39801
|
+
|
|
39802
|
+
// src/tabs/index.tsx
|
|
39803
|
+
var import_react23 = __toESM(require("react"));
|
|
39804
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
39805
|
+
function TabContainer({
|
|
39806
|
+
children,
|
|
39807
|
+
labelMaxWidth = 100,
|
|
39808
|
+
currentIndex = 0
|
|
39809
|
+
}) {
|
|
39810
|
+
const [index, setIndex] = (0, import_react23.useState)(0);
|
|
39811
|
+
const items = import_react23.default.Children.toArray(
|
|
39812
|
+
children
|
|
39813
|
+
);
|
|
39814
|
+
const labels = items.map((c) => c.props.label);
|
|
39815
|
+
const handleKeyDown = (e, k) => {
|
|
39816
|
+
if (e.key === "ArrowRight") setIndex((k + 1) % labels.length);
|
|
39817
|
+
if (e.key === "ArrowLeft")
|
|
39818
|
+
setIndex((k - 1 + labels.length) % labels.length);
|
|
39819
|
+
};
|
|
39820
|
+
(0, import_react23.useEffect)(() => {
|
|
39821
|
+
setIndex(currentIndex);
|
|
39822
|
+
}, [currentIndex]);
|
|
39823
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "w-full bg-white", children: [
|
|
39824
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { role: "tablist", className: "flex gap-1 border-b border-slate-200", children: labels.map((label, k) => {
|
|
39825
|
+
var _a, _b;
|
|
39826
|
+
const active = k === index;
|
|
39827
|
+
const isDisabled = (_b = (_a = items.find((i) => i.props.label == label)) == null ? void 0 : _a.props) == null ? void 0 : _b.disabled;
|
|
39828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
39829
|
+
"button",
|
|
39830
|
+
{
|
|
39831
|
+
style: { maxWidth: labelMaxWidth },
|
|
39832
|
+
title: label,
|
|
39833
|
+
role: "tab",
|
|
39834
|
+
type: "button",
|
|
39835
|
+
"aria-selected": active,
|
|
39836
|
+
tabIndex: active ? 0 : -1,
|
|
39837
|
+
onClick: () => !isDisabled && setIndex(k),
|
|
39838
|
+
onKeyDown: (e) => !isDisabled && handleKeyDown(e, k),
|
|
39839
|
+
className: [
|
|
39840
|
+
"truncate relative px-4 py-2 text-sm font-medium transition-colors duration-150",
|
|
39841
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-offset-1 rounded-t-md",
|
|
39842
|
+
active ? "text-indigo-600" : "text-slate-500 hover:text-slate-700 hover:bg-gray-200",
|
|
39843
|
+
isDisabled ? " text-gray-300 cursor-not-allowed hover:text-gray-300 hover:bg-white" : ""
|
|
39844
|
+
].join(" "),
|
|
39845
|
+
children: [
|
|
39846
|
+
label,
|
|
39847
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "absolute left-0 right-0 -bottom-px h-0.5 bg-indigo-600 rounded-full" })
|
|
39848
|
+
]
|
|
39849
|
+
},
|
|
39850
|
+
label + k
|
|
39851
|
+
);
|
|
39852
|
+
}) }),
|
|
39853
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { role: "tabpanel", className: "p-4 text-sm text-slate-700", children: items[index] })
|
|
39854
|
+
] });
|
|
39855
|
+
}
|
|
39856
|
+
function TabItem({ children }) {
|
|
39857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
|
39858
|
+
}
|
|
39669
39859
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39670
39860
|
0 && (module.exports = {
|
|
39671
39861
|
Alert,
|
|
@@ -39678,6 +39868,8 @@ function TableAdvanced(tableProps) {
|
|
|
39678
39868
|
MyCalendar,
|
|
39679
39869
|
Pre,
|
|
39680
39870
|
Select,
|
|
39871
|
+
TabContainer,
|
|
39872
|
+
TabItem,
|
|
39681
39873
|
Table,
|
|
39682
39874
|
Table3,
|
|
39683
39875
|
TableAdvanced,
|