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.mjs CHANGED
@@ -38505,10 +38505,10 @@ import { useEffect as useEffect13 } from "react";
38505
38505
 
38506
38506
  // src/table-advanced/h.table.tsx
38507
38507
  import React10, {
38508
- useCallback as useCallback2,
38508
+ useCallback as useCallback3,
38509
38509
  useEffect as useEffect11,
38510
38510
  useRef as useRef7,
38511
- useState as useState15
38511
+ useState as useState16
38512
38512
  } from "react";
38513
38513
 
38514
38514
  // src/table-advanced/header.tsx
@@ -38537,6 +38537,44 @@ function DropIcon() {
38537
38537
  }
38538
38538
  );
38539
38539
  }
38540
+ function PrevIcon() {
38541
+ return /* @__PURE__ */ jsx30(
38542
+ "svg",
38543
+ {
38544
+ stroke: "currentColor",
38545
+ fill: "currentColor",
38546
+ strokeWidth: "0",
38547
+ viewBox: "0 0 24 24",
38548
+ height: "1em",
38549
+ width: "1em",
38550
+ xmlns: "http://www.w3.org/2000/svg",
38551
+ children: /* @__PURE__ */ jsx30(
38552
+ "polyline",
38553
+ {
38554
+ fill: "none",
38555
+ strokeWidth: "2",
38556
+ points: "7 2 17 12 7 22",
38557
+ transform: "matrix(-1 0 0 1 24 0)"
38558
+ }
38559
+ )
38560
+ }
38561
+ );
38562
+ }
38563
+ function NextIcon() {
38564
+ return /* @__PURE__ */ jsx30(
38565
+ "svg",
38566
+ {
38567
+ stroke: "currentColor",
38568
+ fill: "currentColor",
38569
+ strokeWidth: "0",
38570
+ viewBox: "0 0 24 24",
38571
+ height: "1em",
38572
+ width: "1em",
38573
+ xmlns: "http://www.w3.org/2000/svg",
38574
+ children: /* @__PURE__ */ jsx30("polyline", { fill: "none", "stroke-width": "2", points: "7 2 17 12 7 22" })
38575
+ }
38576
+ );
38577
+ }
38540
38578
  function EditIcon3() {
38541
38579
  return /* @__PURE__ */ jsx30(
38542
38580
  "svg",
@@ -38727,6 +38765,7 @@ function Header({
38727
38765
  padding
38728
38766
  }) {
38729
38767
  const [visible, setVisible] = useState14(false);
38768
+ const [hovered, setHovered] = useState14(false);
38730
38769
  const sortIndex = context.sort.findIndex((b) => b.field == header);
38731
38770
  const [text, setText] = useState14("");
38732
38771
  const cellRef = useRef6(null);
@@ -38781,7 +38820,7 @@ function Header({
38781
38820
  return /* @__PURE__ */ jsx31("div", { className: "", children: /* @__PURE__ */ jsx31(
38782
38821
  "div",
38783
38822
  {
38784
- className: "border flex items-center justify-center text-center relative ",
38823
+ className: " flex items-center justify-center text-center relative ",
38785
38824
  style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
38786
38825
  children: /* @__PURE__ */ jsx31(
38787
38826
  "input",
@@ -38803,11 +38842,13 @@ function Header({
38803
38842
  }
38804
38843
  ) });
38805
38844
  } else
38806
- return /* @__PURE__ */ jsx31("div", { className: "", children: /* @__PURE__ */ jsxs23(
38845
+ return /* @__PURE__ */ jsx31("div", { className: " ", children: /* @__PURE__ */ jsxs23(
38807
38846
  "div",
38808
38847
  {
38809
38848
  ref: cellRef,
38810
- className: "shadow ",
38849
+ className: " border-r ",
38850
+ onMouseEnter: (e) => setHovered(true),
38851
+ onMouseLeave: (e) => setHovered(false),
38811
38852
  style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
38812
38853
  children: [
38813
38854
  /* @__PURE__ */ jsxs23("div", { className: "flex justify-between items-center ", children: [
@@ -38854,7 +38895,7 @@ function Header({
38854
38895
  style: { zIndex: 10 },
38855
38896
  className: "icon font-bold p-1 cursor-pointer pr-3 ",
38856
38897
  onClick: (e) => setVisible(true),
38857
- children: /* @__PURE__ */ jsx31(DropIcon, {})
38898
+ children: hovered ? /* @__PURE__ */ jsx31(DropIcon, {}) : ""
38858
38899
  }
38859
38900
  )
38860
38901
  ] }),
@@ -38862,7 +38903,7 @@ function Header({
38862
38903
  "div",
38863
38904
  {
38864
38905
  onMouseDown: (e) => drag.startDrag(e, header),
38865
- className: "absolute top-0 h-full cursor-col-resize hover:bg-blue-300 p-2",
38906
+ className: "absolute top-0 h-full cursor-col-resize hover:bg-blue-300 ",
38866
38907
  style: { right: -2, width: 6, zIndex: 20 }
38867
38908
  }
38868
38909
  ),
@@ -39036,7 +39077,7 @@ import { jsx as jsx32, jsxs as jsxs24 } from "react/jsx-runtime";
39036
39077
  function Searchable({
39037
39078
  context
39038
39079
  }) {
39039
- return /* @__PURE__ */ jsxs24("div", { className: "flex justify-start p-2 relative w-96", children: [
39080
+ return /* @__PURE__ */ jsxs24("div", { className: "flex justify-start p-2 relative w-96 text-xs", children: [
39040
39081
  /* @__PURE__ */ jsx32(
39041
39082
  "input",
39042
39083
  {
@@ -39083,14 +39124,61 @@ function valueFormatter({
39083
39124
  return value;
39084
39125
  }
39085
39126
 
39127
+ // src/table-advanced/use.pagination.tsx
39128
+ import { useState as useState15, useMemo as useMemo8, useCallback as useCallback2 } from "react";
39129
+ function usePaginacion({
39130
+ total,
39131
+ tamanioPagina = 100,
39132
+ paginaInicial = 1
39133
+ }) {
39134
+ const totalPaginas = Math.max(1, Math.ceil(total / tamanioPagina));
39135
+ const [pagina, setPagina] = useState15(
39136
+ Math.min(Math.max(paginaInicial, 1), totalPaginas)
39137
+ );
39138
+ const inicio = total === 0 ? 0 : (pagina - 1) * tamanioPagina + 1;
39139
+ const fin = Math.min(pagina * tamanioPagina, total);
39140
+ const rango = useMemo8(() => {
39141
+ if (total === 0) return "0 a 0";
39142
+ return `${inicio} a ${fin}`;
39143
+ }, [inicio, fin, total]);
39144
+ const hasNext = pagina < totalPaginas;
39145
+ const hasPrev = pagina > 1;
39146
+ const next = useCallback2(() => {
39147
+ setPagina((p) => Math.min(p + 1, totalPaginas));
39148
+ }, [totalPaginas]);
39149
+ const prev = useCallback2(() => {
39150
+ setPagina((p) => Math.max(p - 1, 1));
39151
+ }, []);
39152
+ const irAPagina = useCallback2(
39153
+ (n) => {
39154
+ setPagina(Math.min(Math.max(n, 1), totalPaginas));
39155
+ },
39156
+ [totalPaginas]
39157
+ );
39158
+ return {
39159
+ rango,
39160
+ inicio,
39161
+ fin,
39162
+ total,
39163
+ pagina,
39164
+ totalPaginas,
39165
+ hasNext,
39166
+ hasPrev,
39167
+ next,
39168
+ prev,
39169
+ irAPagina
39170
+ };
39171
+ }
39172
+ var use_pagination_default = usePaginacion;
39173
+
39086
39174
  // src/table-advanced/h.table.tsx
39087
39175
  import { jsx as jsx33, jsxs as jsxs25 } from "react/jsx-runtime";
39088
39176
  function HTable({
39089
39177
  context
39090
39178
  }) {
39091
- const [isLoading, setIsloading] = useState15(false);
39179
+ const [isLoading, setIsloading] = useState16(false);
39092
39180
  const { cols, headers } = context;
39093
- const [currentIndex, setCurrentIndex] = useState15(-1);
39181
+ const [currentIndex, setCurrentIndex] = useState16(-1);
39094
39182
  const tableRef = useRef7(null);
39095
39183
  const modalRef = useRef7(null);
39096
39184
  const catDensities = { confortable: 80, compact: 30, standard: 53 };
@@ -39106,8 +39194,8 @@ function HTable({
39106
39194
  function resize(headers3) {
39107
39195
  return Object.fromEntries(headers3.map((h) => [h, getWidth(h)]));
39108
39196
  }
39109
- const [widths2, setWidths2] = useState15({});
39110
- const startDrag2 = useCallback2(
39197
+ const [widths2, setWidths2] = useState16({});
39198
+ const startDrag2 = useCallback3(
39111
39199
  (e, headerKey) => {
39112
39200
  var _a;
39113
39201
  e.preventDefault();
@@ -39158,15 +39246,6 @@ function HTable({
39158
39246
  const sizeadosLength = sizeados.length;
39159
39247
  const sizeadosWidth = sizeadosLength * 60;
39160
39248
  const w = (ancho - sizeadosWidth - personalizadosSum) / (headers.length - sizeadosLength - personalizados.length - ocultos.length);
39161
- console.log({
39162
- w,
39163
- ancho,
39164
- sizeadosWidth,
39165
- personalizadosSum,
39166
- headers,
39167
- sizeadosLength,
39168
- personalizados
39169
- });
39170
39249
  setWidths(
39171
39250
  Object.fromEntries(
39172
39251
  headers.map((h) => {
@@ -39188,13 +39267,14 @@ function HTable({
39188
39267
  (value) => String(value).toLowerCase().includes(context.searchBy.toLowerCase())
39189
39268
  );
39190
39269
  });
39270
+ const pagination = use_pagination_default({ total: searchedData.length });
39191
39271
  return /* @__PURE__ */ jsxs25(
39192
39272
  "div",
39193
39273
  {
39194
39274
  className: [
39195
39275
  context.className,
39196
39276
  "bg-white relative",
39197
- "p-2 border shadow rounded-2xl"
39277
+ "p-2 border shadow rounded-2xl w-full rounded-lg "
39198
39278
  ].join(" "),
39199
39279
  ref: tableRef,
39200
39280
  children: [
@@ -39214,10 +39294,11 @@ function HTable({
39214
39294
  }
39215
39295
  }
39216
39296
  return obj;
39217
- })
39297
+ }),
39298
+ `${context.exportName}.xlsx`
39218
39299
  );
39219
39300
  },
39220
- className: "flex gap-1 items-center border shadow rounded p-1 text-white bg-green-800 px-2",
39301
+ className: "flex gap-1 items-center border shadow rounded p-1 text-white bg-green-800 p-1 text-xs",
39221
39302
  children: [
39222
39303
  /* @__PURE__ */ jsx33(ExcelIcon2, {}),
39223
39304
  "Exportar"
@@ -39227,7 +39308,7 @@ function HTable({
39227
39308
  context.onSelect && /* @__PURE__ */ jsx33(
39228
39309
  "button",
39229
39310
  {
39230
- className: "border shadow rounded p-1 text-white px-2 " + (context.selected.length > 0 ? "bg-blue-500" : "bg-gray-500"),
39311
+ className: "border shadow rounded p-1 text-white p-1 text-xs bg-blue-500 cursor-pointer ",
39231
39312
  disabled: context.selected.length == 0,
39232
39313
  onClick: async (e) => {
39233
39314
  setIsloading(true);
@@ -39244,7 +39325,7 @@ function HTable({
39244
39325
  context.onSave && /* @__PURE__ */ jsx33(
39245
39326
  "button",
39246
39327
  {
39247
- className: "border shadow rounded p-1 text-white px-2 bg-blue-500",
39328
+ className: "border shadow rounded p-1 text-white p-1 text-xs bg-blue-500 cursor-pointer ",
39248
39329
  onClick: async (e) => {
39249
39330
  setIsloading(true);
39250
39331
  const ex = context.filteredData.map((d) => {
@@ -39258,204 +39339,253 @@ function HTable({
39258
39339
  }
39259
39340
  )
39260
39341
  ] }),
39261
- /* @__PURE__ */ jsxs25("div", { className: "grid ", style: { gridTemplateColumns }, children: [
39262
- headers.map((header, i) => {
39263
- var _a, _b;
39264
- if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
39265
- if (header.startsWith("_") && !header.startsWith("__")) return null;
39266
- return /* @__PURE__ */ jsxs25(
39267
- "div",
39268
- {
39269
- className: "bg-white relative w-full bg-red-100",
39270
- children: [
39271
- /* @__PURE__ */ jsx33(
39272
- Header,
39273
- {
39274
- padding,
39275
- header,
39276
- context,
39277
- drag: { gridTemplateColumns, startDrag, widths }
39278
- }
39279
- ),
39280
- i < headers.length - 1 && /* @__PURE__ */ jsx33(
39281
- "div",
39282
- {
39283
- onMouseDown: (e) => startDrag(e, header),
39284
- style: {
39285
- position: "absolute",
39286
- right: -3,
39287
- top: 0,
39288
- width: 6,
39289
- height: "100%",
39290
- cursor: "col-resize",
39291
- background: "transparent"
39292
- },
39293
- onMouseEnter: (e) => e.currentTarget.style.background = "var(--border-strong, #ccc)",
39294
- onMouseLeave: (e) => e.currentTarget.style.background = "transparent"
39295
- }
39296
- )
39297
- ]
39298
- },
39299
- header
39300
- );
39301
- }),
39302
- searchedData.map((row, rowIndex) => {
39303
- const items = Object.entries(row);
39304
- return items.map(([key, item], i) => {
39305
- var _a, _b, _c, _d, _e;
39306
- if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, key)) return null;
39307
- if (key.startsWith("_") && !key.startsWith("__")) return null;
39308
- if (key == "__modal__") {
39309
- return /* @__PURE__ */ jsx33(
39310
- "div",
39311
- {
39312
- onMouseEnter: (e) => setCurrentIndex(rowIndex),
39313
- style: {
39314
- height: `${padding}px`
39315
- },
39316
- 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" : ""),
39317
- children: (context == null ? void 0 : context.modalButton) || /* @__PURE__ */ jsx33(
39318
- "button",
39319
- {
39320
- className: "border shadow rounded bg-blue-500 text-white p-2 ",
39321
- onClick: (e) => {
39322
- var _a2;
39323
- setCurrentIndex(rowIndex);
39324
- (_a2 = modalRef.current) == null ? void 0 : _a2.click();
39325
- },
39326
- children: /* @__PURE__ */ jsx33(EditIcon3, {})
39327
- }
39328
- )
39342
+ /* @__PURE__ */ jsxs25(
39343
+ "div",
39344
+ {
39345
+ children: [
39346
+ /* @__PURE__ */ jsx33(
39347
+ "div",
39348
+ {
39349
+ style: {
39350
+ gridTemplateColumns,
39351
+ width: Object.values(widths).reduce((acc, i) => acc + i, 0)
39329
39352
  },
39330
- row.id + i
39331
- );
39332
- }
39333
- if (key == "__select__") {
39334
- return /* @__PURE__ */ jsx33(
39335
- "div",
39336
- {
39337
- onMouseEnter: (e) => setCurrentIndex(rowIndex),
39338
- style: {
39339
- height: `${padding}px`
39340
- },
39341
- 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" : ""),
39342
- children: /* @__PURE__ */ jsx33(
39343
- "input",
39353
+ className: ["grid w-full "].join(" "),
39354
+ children: headers.map((header, i) => {
39355
+ var _a, _b;
39356
+ if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
39357
+ if (header.startsWith("_") && !header.startsWith("__")) return null;
39358
+ return /* @__PURE__ */ jsx33(
39359
+ "div",
39344
39360
  {
39345
- type: "checkbox",
39346
- className: "w-5 h-5 accent-blue-600 transition-all duration-300 checked:scale-110 ",
39347
- checked: Boolean(
39348
- context.selected.find((s) => s == (row == null ? void 0 : row.id))
39349
- ),
39350
- onChange: (e) => {
39351
- const newSelected = [...context.selected];
39352
- const index = newSelected.findIndex((s) => s == (row == null ? void 0 : row.id));
39353
- if (index >= 0) {
39354
- newSelected.splice(index, 1);
39355
- } else {
39356
- newSelected.push(row == null ? void 0 : row.id);
39361
+ className: "bg-white relative w-full bg-red-100",
39362
+ children: /* @__PURE__ */ jsx33(
39363
+ Header,
39364
+ {
39365
+ padding,
39366
+ header,
39367
+ context,
39368
+ drag: { gridTemplateColumns, startDrag, widths }
39357
39369
  }
39358
- context.setSelected(newSelected);
39359
- }
39360
- }
39361
- )
39370
+ )
39371
+ },
39372
+ header
39373
+ );
39374
+ })
39375
+ }
39376
+ ),
39377
+ /* @__PURE__ */ jsx33(
39378
+ "div",
39379
+ {
39380
+ style: {
39381
+ gridTemplateColumns,
39382
+ width: Object.values(widths).reduce((acc, i) => acc + i, 0)
39362
39383
  },
39363
- row.id + i
39364
- );
39365
- }
39366
- return /* @__PURE__ */ jsx33(
39384
+ className: [
39385
+ "grid max-h-[500px] overflow-hidden overflow-y-scroll "
39386
+ ].join(" "),
39387
+ children: searchedData.slice(pagination.inicio - 1, pagination.fin).map((row, rowIndex) => {
39388
+ const items = Object.entries(row);
39389
+ return items.map(([key, item], i) => {
39390
+ var _a, _b, _c, _d, _e;
39391
+ if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, key)) return null;
39392
+ if (key.startsWith("_") && !key.startsWith("__")) return null;
39393
+ if (key == "__modal__") {
39394
+ return /* @__PURE__ */ jsx33(
39395
+ "div",
39396
+ {
39397
+ onMouseEnter: (e) => setCurrentIndex(rowIndex),
39398
+ style: {
39399
+ height: `${padding}px`
39400
+ },
39401
+ 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" : ""),
39402
+ children: (context == null ? void 0 : context.modalButton) || /* @__PURE__ */ jsx33(
39403
+ "button",
39404
+ {
39405
+ className: "border shadow rounded bg-blue-500 text-white p-2 ",
39406
+ onClick: (e) => {
39407
+ var _a2;
39408
+ setCurrentIndex(rowIndex);
39409
+ (_a2 = modalRef.current) == null ? void 0 : _a2.click();
39410
+ },
39411
+ children: /* @__PURE__ */ jsx33(EditIcon3, {})
39412
+ }
39413
+ )
39414
+ },
39415
+ row.id + i
39416
+ );
39417
+ }
39418
+ if (key == "__select__") {
39419
+ return /* @__PURE__ */ jsx33(
39420
+ "div",
39421
+ {
39422
+ onMouseEnter: (e) => setCurrentIndex(rowIndex),
39423
+ style: {
39424
+ height: `${padding}px`
39425
+ },
39426
+ 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" : ""),
39427
+ children: /* @__PURE__ */ jsx33(
39428
+ "input",
39429
+ {
39430
+ type: "checkbox",
39431
+ className: "w-5 h-5 accent-blue-600 transition-all duration-300 checked:scale-110 ",
39432
+ checked: Boolean(
39433
+ context.selected.find((s) => s == (row == null ? void 0 : row.id))
39434
+ ),
39435
+ onChange: (e) => {
39436
+ const newSelected = [...context.selected];
39437
+ const index = newSelected.findIndex(
39438
+ (s) => s == (row == null ? void 0 : row.id)
39439
+ );
39440
+ if (index >= 0) {
39441
+ newSelected.splice(index, 1);
39442
+ } else {
39443
+ newSelected.push(row == null ? void 0 : row.id);
39444
+ }
39445
+ context.setSelected(newSelected);
39446
+ }
39447
+ }
39448
+ )
39449
+ },
39450
+ row.id + i
39451
+ );
39452
+ }
39453
+ return /* @__PURE__ */ jsx33(
39454
+ "div",
39455
+ {
39456
+ onMouseEnter: (e) => setCurrentIndex(rowIndex),
39457
+ style: {
39458
+ fontSize: (context == null ? void 0 : context.fontSize) || "12px",
39459
+ ...(context == null ? void 0 : context.wrapText) ? { minHeight: `${padding}px` } : { height: `${padding}px` }
39460
+ },
39461
+ 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 " : ""),
39462
+ children: (context == null ? void 0 : context.editableFields) && context.editableFields.includes(key) ? /* @__PURE__ */ jsx33(
39463
+ "input",
39464
+ {
39465
+ defaultValue: item,
39466
+ className: "w-full " + (context.editions.includes(row == null ? void 0 : row.id) ? "bg-blue-400 text-white" : "bg-blue-100"),
39467
+ onBlur: (e) => {
39468
+ const id = row == null ? void 0 : row.id;
39469
+ const newData = [...context.data];
39470
+ const index = newData.findIndex((d) => +d.id == +id);
39471
+ newData[index][key] = e.target.value;
39472
+ context.setData(newData);
39473
+ const newEditions = [
39474
+ .../* @__PURE__ */ new Set([...context.editions, id])
39475
+ ];
39476
+ context.setEditions(newEditions);
39477
+ }
39478
+ }
39479
+ ) : ((_c = context.buttons) == null ? void 0 : _c[key]) ? React10.cloneElement(context.buttons[key], {
39480
+ // children: context.buttons[key]?.props?.children
39481
+ // ? item
39482
+ // : undefined,
39483
+ value: item,
39484
+ children: ((_e = (_d = context.buttons[key]) == null ? void 0 : _d.props) == null ? void 0 : _e.children) ? item : null,
39485
+ onClick: async (e) => {
39486
+ var _a2, _b2;
39487
+ const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onClick) == null ? void 0 : _b2.call(_a2, {
39488
+ e,
39489
+ row
39490
+ })) || {};
39491
+ const newData = [...context.data];
39492
+ const index = newData.findIndex(
39493
+ (f) => f.id == (row == null ? void 0 : row.id)
39494
+ );
39495
+ newData[index] = { ...newData[index], ...ret };
39496
+ context.setData(newData);
39497
+ },
39498
+ onChange: async (e) => {
39499
+ var _a2, _b2, _c2;
39500
+ const value = e.target.value;
39501
+ const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onChange) == null ? void 0 : _b2.call(_a2, {
39502
+ e,
39503
+ row
39504
+ })) || {};
39505
+ const newData = [...context.data];
39506
+ const index = newData.findIndex(
39507
+ (f) => f.id == (row == null ? void 0 : row.id)
39508
+ );
39509
+ if (index >= 0) {
39510
+ newData[index][key] = value;
39511
+ }
39512
+ for (let i2 in ret) {
39513
+ if ((_c2 = newData[index]) == null ? void 0 : _c2[i2]) {
39514
+ const v = ret[i2];
39515
+ newData[index][i2] = v;
39516
+ }
39517
+ }
39518
+ context.setData(newData);
39519
+ }
39520
+ }) : ["number", "string"].includes(typeof item) ? valueFormatter({
39521
+ value: item,
39522
+ currentCoin: context.currentCoin
39523
+ }) : React10.isValidElement(item) ? item : JSON.stringify(item)
39524
+ },
39525
+ row.id + i
39526
+ );
39527
+ });
39528
+ })
39529
+ }
39530
+ ),
39531
+ /* @__PURE__ */ jsx33(
39367
39532
  "div",
39368
39533
  {
39369
- onMouseEnter: (e) => setCurrentIndex(rowIndex),
39370
39534
  style: {
39371
- fontSize: context.fontSize,
39372
- ...(context == null ? void 0 : context.wrapText) ? { minHeight: `${padding}px` } : { height: `${padding}px` }
39535
+ gridTemplateColumns,
39536
+ width: Object.values(widths).reduce((acc, i) => acc + i, 0)
39373
39537
  },
39374
- className: " flex justify-center items-center " + (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 " : ""),
39375
- children: (context == null ? void 0 : context.editableFields) && context.editableFields.includes(key) ? /* @__PURE__ */ jsx33(
39376
- "input",
39538
+ className: ["grid border-b bg-white"].join(" "),
39539
+ children: Object.keys((context == null ? void 0 : context.footer) || {}).length > 0 && headers.map((header) => {
39540
+ var _a, _b, _c, _d;
39541
+ if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
39542
+ if (header.startsWith("_") && !header.startsWith("__"))
39543
+ return null;
39544
+ return /* @__PURE__ */ jsx33(
39545
+ "div",
39546
+ {
39547
+ style: {
39548
+ // height: `${padding}px`,
39549
+ maxHeight: "100px"
39550
+ },
39551
+ title: ((_c = context.footer) == null ? void 0 : _c[header]) + " de " + header,
39552
+ className: " cursor-default font-bold bg-white flex items-center justify-center border-r text-xs my-5 ",
39553
+ children: valueFormatter({
39554
+ currentCoin: context.currentCoin,
39555
+ 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) : "" : ""
39556
+ })
39557
+ },
39558
+ header
39559
+ );
39560
+ })
39561
+ }
39562
+ ),
39563
+ /* @__PURE__ */ jsxs25("div", { className: "flex justify-end p-2", children: [
39564
+ pagination.rango,
39565
+ " de ",
39566
+ pagination.total,
39567
+ /* @__PURE__ */ jsxs25("div", { className: "flex items-center gap-5 mx-5", children: [
39568
+ /* @__PURE__ */ jsx33(
39569
+ "button",
39377
39570
  {
39378
- defaultValue: item,
39379
- className: "w-full " + (context.editions.includes(row == null ? void 0 : row.id) ? "bg-blue-400 text-white" : "bg-blue-100"),
39380
- onBlur: (e) => {
39381
- const id = row == null ? void 0 : row.id;
39382
- const newData = [...context.data];
39383
- const index = newData.findIndex((d) => +d.id == +id);
39384
- newData[index][key] = e.target.value;
39385
- context.setData(newData);
39386
- const newEditions = [
39387
- .../* @__PURE__ */ new Set([...context.editions, id])
39388
- ];
39389
- context.setEditions(newEditions);
39390
- }
39571
+ onClick: (e) => pagination.hasPrev && pagination.prev(),
39572
+ className: pagination.hasPrev ? "" : "text-gray-300",
39573
+ children: /* @__PURE__ */ jsx33(PrevIcon, {})
39391
39574
  }
39392
- ) : ((_c = context.buttons) == null ? void 0 : _c[key]) ? React10.cloneElement(context.buttons[key], {
39393
- // children: context.buttons[key]?.props?.children
39394
- // ? item
39395
- // : undefined,
39396
- value: item,
39397
- children: ((_e = (_d = context.buttons[key]) == null ? void 0 : _d.props) == null ? void 0 : _e.children) ? item : null,
39398
- onClick: async (e) => {
39399
- var _a2, _b2;
39400
- const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onClick) == null ? void 0 : _b2.call(_a2, {
39401
- e,
39402
- row
39403
- })) || {};
39404
- const newData = [...context.data];
39405
- const index = newData.findIndex((f) => f.id == (row == null ? void 0 : row.id));
39406
- newData[index] = { ...newData[index], ...ret };
39407
- context.setData(newData);
39408
- },
39409
- onChange: async (e) => {
39410
- var _a2, _b2, _c2;
39411
- const value = e.target.value;
39412
- const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onChange) == null ? void 0 : _b2.call(_a2, {
39413
- e,
39414
- row
39415
- })) || {};
39416
- const newData = [...context.data];
39417
- const index = newData.findIndex((f) => f.id == (row == null ? void 0 : row.id));
39418
- if (index >= 0) {
39419
- newData[index][key] = value;
39420
- }
39421
- for (let i2 in ret) {
39422
- if ((_c2 = newData[index]) == null ? void 0 : _c2[i2]) {
39423
- const v = ret[i2];
39424
- newData[index][i2] = v;
39425
- }
39426
- }
39427
- context.setData(newData);
39575
+ ),
39576
+ /* @__PURE__ */ jsx33(
39577
+ "button",
39578
+ {
39579
+ onClick: (e) => pagination.hasNext && pagination.next(),
39580
+ className: pagination.hasNext ? "" : "text-gray-300",
39581
+ children: /* @__PURE__ */ jsx33(NextIcon, {})
39428
39582
  }
39429
- }) : ["number", "string"].includes(typeof item) ? valueFormatter({
39430
- value: item,
39431
- currentCoin: context.currentCoin
39432
- }) : React10.isValidElement(item) ? item : JSON.stringify(item)
39433
- },
39434
- row.id + i
39435
- );
39436
- });
39437
- }),
39438
- Object.keys((context == null ? void 0 : context.footer) || {}).length > 0 && headers.map((header) => {
39439
- var _a, _b, _c;
39440
- if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
39441
- if (header.startsWith("_") && !header.startsWith("__")) return null;
39442
- return /* @__PURE__ */ jsx33(
39443
- "div",
39444
- {
39445
- style: {
39446
- height: `${padding}px`,
39447
- maxHeight: "100px"
39448
- },
39449
- className: "border-b font-bold bg-white flex items-center justify-center",
39450
- children: valueFormatter({
39451
- currentCoin: context.currentCoin,
39452
- 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) : "" : ""
39453
- })
39454
- },
39455
- header
39456
- );
39457
- })
39458
- ] }),
39583
+ )
39584
+ ] })
39585
+ ] })
39586
+ ]
39587
+ }
39588
+ ),
39459
39589
  context.modal && /* @__PURE__ */ jsx33(
39460
39590
  Modal,
39461
39591
  {
@@ -39533,7 +39663,7 @@ function ModalContent({
39533
39663
  }
39534
39664
 
39535
39665
  // src/table-advanced/context.ts
39536
- import { useEffect as useEffect12, useMemo as useMemo9, useReducer as useReducer3, useState as useState16 } from "react";
39666
+ import { useEffect as useEffect12, useMemo as useMemo10, useReducer as useReducer3, useState as useState17 } from "react";
39537
39667
 
39538
39668
  // src/table-advanced/filter.reducer.ts
39539
39669
  var filterReducer = (acc, b) => {
@@ -39561,19 +39691,19 @@ var sortReducer = (acc, b) => {
39561
39691
  // src/table-advanced/context.ts
39562
39692
  function useContext({ onSelect }) {
39563
39693
  const excel = useExcel();
39564
- const [editions, setEditions] = useState16([]);
39565
- const [selected, setSelected] = useState16([]);
39566
- const [data, setData] = useState16([]);
39694
+ const [editions, setEditions] = useState17([]);
39695
+ const [selected, setSelected] = useState17([]);
39696
+ const [data, setData] = useState17([]);
39567
39697
  const headers = [...new Set(data.map((b) => Object.keys(b)).flat())];
39568
- const [currentHeader, setCurrentHeader] = useState16(null);
39698
+ const [currentHeader, setCurrentHeader] = useState17(null);
39569
39699
  const cols = headers.length;
39570
39700
  const [filters, setFilters] = useReducer3(
39571
39701
  filterReducer,
39572
39702
  new Array()
39573
39703
  );
39574
- const [searchBy, setSearchBy] = useState16("");
39704
+ const [searchBy, setSearchBy] = useState17("");
39575
39705
  const [sort, setSort] = useReducer3(sortReducer, new Array());
39576
- const sortedData = useMemo9(() => {
39706
+ const sortedData = useMemo10(() => {
39577
39707
  return [...data].sort((a, b) => {
39578
39708
  for (const { field, type } of sort.reverse()) {
39579
39709
  const av = a[field];
@@ -39666,14 +39796,14 @@ function TableAdvanced(tableProps) {
39666
39796
  }
39667
39797
 
39668
39798
  // src/tabs/index.tsx
39669
- import React11, { useEffect as useEffect14, useState as useState18 } from "react";
39799
+ import React11, { useEffect as useEffect14, useState as useState19 } from "react";
39670
39800
  import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
39671
39801
  function TabContainer({
39672
39802
  children,
39673
39803
  labelMaxWidth = 100,
39674
39804
  currentIndex = 0
39675
39805
  }) {
39676
- const [index, setIndex] = useState18(0);
39806
+ const [index, setIndex] = useState19(0);
39677
39807
  const items = React11.Children.toArray(
39678
39808
  children
39679
39809
  );