next-recomponents 2.0.56 → 2.0.58

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
@@ -38501,18 +38501,19 @@ function Table3({
38501
38501
  }
38502
38502
 
38503
38503
  // src/table-advanced/index.tsx
38504
- import { useEffect as useEffect13 } from "react";
38504
+ import { useEffect as useEffect14 } from "react";
38505
38505
 
38506
38506
  // src/table-advanced/h.table.tsx
38507
38507
  import React10, {
38508
- useCallback as useCallback2,
38509
- useEffect as useEffect11,
38508
+ useCallback as useCallback3,
38509
+ useEffect as useEffect12,
38510
+ useMemo as useMemo10,
38510
38511
  useRef as useRef7,
38511
- useState as useState15
38512
+ useState as useState16
38512
38513
  } from "react";
38513
38514
 
38514
38515
  // src/table-advanced/header.tsx
38515
- import { useEffect as useEffect10, useRef as useRef6, useState as useState14 } from "react";
38516
+ import { useEffect as useEffect10, useMemo as useMemo8, useRef as useRef6, useState as useState14 } from "react";
38516
38517
  import { createPortal } from "react-dom";
38517
38518
 
38518
38519
  // src/table-advanced/icons.tsx
@@ -38537,6 +38538,44 @@ function DropIcon() {
38537
38538
  }
38538
38539
  );
38539
38540
  }
38541
+ function PrevIcon() {
38542
+ return /* @__PURE__ */ jsx30(
38543
+ "svg",
38544
+ {
38545
+ stroke: "currentColor",
38546
+ fill: "currentColor",
38547
+ strokeWidth: "0",
38548
+ viewBox: "0 0 24 24",
38549
+ height: "1em",
38550
+ width: "1em",
38551
+ xmlns: "http://www.w3.org/2000/svg",
38552
+ children: /* @__PURE__ */ jsx30(
38553
+ "polyline",
38554
+ {
38555
+ fill: "none",
38556
+ strokeWidth: "2",
38557
+ points: "7 2 17 12 7 22",
38558
+ transform: "matrix(-1 0 0 1 24 0)"
38559
+ }
38560
+ )
38561
+ }
38562
+ );
38563
+ }
38564
+ function NextIcon() {
38565
+ return /* @__PURE__ */ jsx30(
38566
+ "svg",
38567
+ {
38568
+ stroke: "currentColor",
38569
+ fill: "currentColor",
38570
+ strokeWidth: "0",
38571
+ viewBox: "0 0 24 24",
38572
+ height: "1em",
38573
+ width: "1em",
38574
+ xmlns: "http://www.w3.org/2000/svg",
38575
+ children: /* @__PURE__ */ jsx30("polyline", { fill: "none", "stroke-width": "2", points: "7 2 17 12 7 22" })
38576
+ }
38577
+ );
38578
+ }
38540
38579
  function EditIcon3() {
38541
38580
  return /* @__PURE__ */ jsx30(
38542
38581
  "svg",
@@ -38724,23 +38763,29 @@ function Header({
38724
38763
  header,
38725
38764
  context,
38726
38765
  drag,
38727
- padding
38766
+ padding,
38767
+ index,
38768
+ length
38728
38769
  }) {
38729
38770
  const [visible, setVisible] = useState14(false);
38771
+ const [hovered, setHovered] = useState14(false);
38730
38772
  const sortIndex = context.sort.findIndex((b) => b.field == header);
38731
38773
  const [text, setText] = useState14("");
38732
38774
  const cellRef = useRef6(null);
38733
38775
  const [coords, setCoords] = useState14(
38734
38776
  null
38735
38777
  );
38736
- const filteredValues = [
38737
- ...new Set(context.data.map((d) => d[header]))
38738
- ].filter((d) => {
38739
- if (text == "") return true;
38740
- return `${d}`.toLowerCase().includes(text.toLowerCase());
38741
- });
38742
- const [selected, setSelected] = useState14([...filteredValues]);
38778
+ const filteredValues = useMemo8(() => {
38779
+ return [...new Set(context.data.map((d) => d[header]))].filter((d) => {
38780
+ if (text == "") return true;
38781
+ return `${d}`.toLowerCase().includes(text.toLowerCase());
38782
+ });
38783
+ }, [context.data, header, text]);
38784
+ const [selected, setSelected] = useState14([]);
38743
38785
  const hasFilter = context.filters.find((b) => b.field == header);
38786
+ useEffect10(() => {
38787
+ setSelected(filteredValues);
38788
+ }, [filteredValues]);
38744
38789
  useEffect10(() => {
38745
38790
  if (visible) {
38746
38791
  context.setCurrentHeader(header);
@@ -38781,7 +38826,7 @@ function Header({
38781
38826
  return /* @__PURE__ */ jsx31("div", { className: "", children: /* @__PURE__ */ jsx31(
38782
38827
  "div",
38783
38828
  {
38784
- className: "border flex items-center justify-center text-center relative ",
38829
+ className: " flex items-center justify-center text-center relative ",
38785
38830
  style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
38786
38831
  children: /* @__PURE__ */ jsx31(
38787
38832
  "input",
@@ -38803,15 +38848,17 @@ function Header({
38803
38848
  }
38804
38849
  ) });
38805
38850
  } else
38806
- return /* @__PURE__ */ jsx31("div", { className: "", children: /* @__PURE__ */ jsxs23(
38851
+ return /* @__PURE__ */ jsx31("div", { className: " ", children: /* @__PURE__ */ jsxs23(
38807
38852
  "div",
38808
38853
  {
38809
38854
  ref: cellRef,
38810
- className: "shadow ",
38855
+ className: index < length - 1 ? "border-r" : "",
38856
+ onMouseEnter: (e) => setHovered(true),
38857
+ onMouseLeave: (e) => setHovered(false),
38811
38858
  style: { zIndex: 10, height: `${padding}px`, maxHeight: "100px" },
38812
38859
  children: [
38813
38860
  /* @__PURE__ */ jsxs23("div", { className: "flex justify-between items-center ", children: [
38814
- /* @__PURE__ */ jsxs23("div", { className: "flex gap-2", children: [
38861
+ !context.disabled ? /* @__PURE__ */ jsxs23("div", { className: "flex gap-2", children: [
38815
38862
  hasFilter ? /* @__PURE__ */ jsx31(
38816
38863
  "div",
38817
38864
  {
@@ -38834,7 +38881,7 @@ function Header({
38834
38881
  children: sortIndex >= 0 ? context.sort[sortIndex].type === "ASC" ? /* @__PURE__ */ jsx31(ArrowUPIcon, {}) : /* @__PURE__ */ jsx31(ArrowDownIcon2, {}) : /* @__PURE__ */ jsx31("div", {})
38835
38882
  }
38836
38883
  )
38837
- ] }),
38884
+ ] }) : /* @__PURE__ */ jsx31("div", {}),
38838
38885
  /* @__PURE__ */ jsx31(
38839
38886
  "div",
38840
38887
  {
@@ -38848,21 +38895,21 @@ function Header({
38848
38895
  children: header
38849
38896
  }
38850
38897
  ),
38851
- /* @__PURE__ */ jsx31(
38898
+ !context.disabled ? /* @__PURE__ */ jsx31(
38852
38899
  "div",
38853
38900
  {
38854
38901
  style: { zIndex: 10 },
38855
38902
  className: "icon font-bold p-1 cursor-pointer pr-3 ",
38856
38903
  onClick: (e) => setVisible(true),
38857
- children: /* @__PURE__ */ jsx31(DropIcon, {})
38904
+ children: hovered ? /* @__PURE__ */ jsx31(DropIcon, {}) : ""
38858
38905
  }
38859
- )
38906
+ ) : /* @__PURE__ */ jsx31("div", {})
38860
38907
  ] }),
38861
- context.currentHeader != header && /* @__PURE__ */ jsx31(
38908
+ !context.disabled && context.currentHeader != header && /* @__PURE__ */ jsx31(
38862
38909
  "div",
38863
38910
  {
38864
38911
  onMouseDown: (e) => drag.startDrag(e, header),
38865
- className: "absolute top-0 h-full cursor-col-resize hover:bg-blue-300 p-2",
38912
+ className: "absolute top-0 h-full cursor-col-resize hover:bg-blue-300 ",
38866
38913
  style: { right: -2, width: 6, zIndex: 20 }
38867
38914
  }
38868
38915
  ),
@@ -38984,9 +39031,9 @@ function Header({
38984
39031
  type: "checkbox",
38985
39032
  onChange: (e) => {
38986
39033
  const ns = [...selected];
38987
- const index = ns.findIndex((n) => n == d);
38988
- if (index >= 0) {
38989
- ns.splice(index, 1);
39034
+ const index2 = ns.findIndex((n) => n == d);
39035
+ if (index2 >= 0) {
39036
+ ns.splice(index2, 1);
38990
39037
  } else {
38991
39038
  ns.push(d);
38992
39039
  }
@@ -38995,7 +39042,7 @@ function Header({
38995
39042
  checked: text != "" || selected.includes(d)
38996
39043
  }
38997
39044
  ),
38998
- /* @__PURE__ */ jsx31("div", { className: "truncate", children: d })
39045
+ /* @__PURE__ */ jsx31("div", { className: "truncate", children: d == "" ? "Vacias" : !Boolean(d) ? "null" : d })
38999
39046
  ] }, d);
39000
39047
  })
39001
39048
  ]
@@ -39036,7 +39083,7 @@ import { jsx as jsx32, jsxs as jsxs24 } from "react/jsx-runtime";
39036
39083
  function Searchable({
39037
39084
  context
39038
39085
  }) {
39039
- return /* @__PURE__ */ jsxs24("div", { className: "flex justify-start p-2 relative w-96", children: [
39086
+ return /* @__PURE__ */ jsxs24("div", { className: "flex justify-start p-2 relative w-96 text-xs", children: [
39040
39087
  /* @__PURE__ */ jsx32(
39041
39088
  "input",
39042
39089
  {
@@ -39083,14 +39130,67 @@ function valueFormatter({
39083
39130
  return value;
39084
39131
  }
39085
39132
 
39133
+ // src/table-advanced/use.pagination.tsx
39134
+ import { useState as useState15, useMemo as useMemo9, useCallback as useCallback2, useEffect as useEffect11 } from "react";
39135
+ function usePaginacion({
39136
+ total,
39137
+ tamanioPagina = 100,
39138
+ paginaInicial = 1
39139
+ }) {
39140
+ const [totalPaginas, setTotalPaginas] = useState15(
39141
+ Math.max(1, Math.ceil(total / tamanioPagina))
39142
+ );
39143
+ const [pagina, setPagina] = useState15(
39144
+ Math.min(Math.max(paginaInicial, 1), totalPaginas)
39145
+ );
39146
+ const inicio = total === 0 ? 0 : (pagina - 1) * tamanioPagina + 1;
39147
+ const fin = Math.min(pagina * tamanioPagina, total);
39148
+ const rango = useMemo9(() => {
39149
+ if (total === 0) return "0 a 0";
39150
+ return `${inicio} a ${fin}`;
39151
+ }, [inicio, fin, total]);
39152
+ const hasNext = pagina < totalPaginas;
39153
+ const hasPrev = pagina > 1;
39154
+ const next = useCallback2(() => {
39155
+ setPagina((p) => Math.min(p + 1, totalPaginas));
39156
+ }, [totalPaginas]);
39157
+ const prev = useCallback2(() => {
39158
+ setPagina((p) => Math.max(p - 1, 1));
39159
+ }, []);
39160
+ const irAPagina = useCallback2(
39161
+ (n) => {
39162
+ setPagina(Math.min(Math.max(n, 1), totalPaginas));
39163
+ },
39164
+ [totalPaginas]
39165
+ );
39166
+ useEffect11(() => {
39167
+ setTotalPaginas(Math.max(1, Math.ceil(total / tamanioPagina)));
39168
+ setPagina(1);
39169
+ }, [total]);
39170
+ return {
39171
+ rango,
39172
+ inicio,
39173
+ fin,
39174
+ total,
39175
+ pagina,
39176
+ totalPaginas,
39177
+ hasNext,
39178
+ hasPrev,
39179
+ next,
39180
+ prev,
39181
+ irAPagina
39182
+ };
39183
+ }
39184
+ var use_pagination_default = usePaginacion;
39185
+
39086
39186
  // src/table-advanced/h.table.tsx
39087
39187
  import { jsx as jsx33, jsxs as jsxs25 } from "react/jsx-runtime";
39088
39188
  function HTable({
39089
39189
  context
39090
39190
  }) {
39091
- const [isLoading, setIsloading] = useState15(false);
39191
+ const [isLoading, setIsloading] = useState16(false);
39092
39192
  const { cols, headers } = context;
39093
- const [currentIndex, setCurrentIndex] = useState15(-1);
39193
+ const [currentIndex, setCurrentIndex] = useState16(-1);
39094
39194
  const tableRef = useRef7(null);
39095
39195
  const modalRef = useRef7(null);
39096
39196
  const catDensities = { confortable: 80, compact: 30, standard: 53 };
@@ -39106,8 +39206,8 @@ function HTable({
39106
39206
  function resize(headers3) {
39107
39207
  return Object.fromEntries(headers3.map((h) => [h, getWidth(h)]));
39108
39208
  }
39109
- const [widths2, setWidths2] = useState15({});
39110
- const startDrag2 = useCallback2(
39209
+ const [widths2, setWidths2] = useState16({});
39210
+ const startDrag2 = useCallback3(
39111
39211
  (e, headerKey) => {
39112
39212
  var _a;
39113
39213
  e.preventDefault();
@@ -39142,7 +39242,7 @@ function HTable({
39142
39242
  return { widths: widths2, gridTemplateColumns: gridTemplateColumns2, startDrag: startDrag2, setWidths: setWidths2 };
39143
39243
  }
39144
39244
  const { gridTemplateColumns, startDrag, widths, setWidths } = useResizableColumns(headers);
39145
- useEffect11(() => {
39245
+ useEffect12(() => {
39146
39246
  if (!tableRef.current) return;
39147
39247
  const observer = new ResizeObserver(([entry]) => {
39148
39248
  const ocultos = headers.filter(
@@ -39158,15 +39258,6 @@ function HTable({
39158
39258
  const sizeadosLength = sizeados.length;
39159
39259
  const sizeadosWidth = sizeadosLength * 60;
39160
39260
  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
39261
  setWidths(
39171
39262
  Object.fromEntries(
39172
39263
  headers.map((h) => {
@@ -39182,19 +39273,22 @@ function HTable({
39182
39273
  observer.observe(tableRef.current);
39183
39274
  return () => observer.disconnect();
39184
39275
  }, [headers.length]);
39185
- const searchedData = context.filteredData.filter((row) => {
39186
- if (context.searchBy === "") return true;
39187
- return Object.values(row).some(
39188
- (value) => String(value).toLowerCase().includes(context.searchBy.toLowerCase())
39189
- );
39190
- });
39276
+ const searchedData = useMemo10(() => {
39277
+ return context.filteredData.filter((row) => {
39278
+ if (context.searchBy === "") return true;
39279
+ return Object.values(row).some(
39280
+ (value) => String(value).toLowerCase().includes(context.searchBy.toLowerCase())
39281
+ );
39282
+ });
39283
+ }, [context.filteredData]);
39284
+ const pagination = use_pagination_default({ total: searchedData.length });
39191
39285
  return /* @__PURE__ */ jsxs25(
39192
39286
  "div",
39193
39287
  {
39194
39288
  className: [
39195
39289
  context.className,
39196
39290
  "bg-white relative",
39197
- "p-2 border shadow rounded-2xl"
39291
+ "p-2 border shadow rounded-2xl w-full rounded-lg "
39198
39292
  ].join(" "),
39199
39293
  ref: tableRef,
39200
39294
  children: [
@@ -39214,10 +39308,11 @@ function HTable({
39214
39308
  }
39215
39309
  }
39216
39310
  return obj;
39217
- })
39311
+ }),
39312
+ `${context.exportName}.xlsx`
39218
39313
  );
39219
39314
  },
39220
- className: "flex gap-1 items-center border shadow rounded p-1 text-white bg-green-800 px-2",
39315
+ className: "flex gap-1 items-center border shadow rounded p-1 text-white bg-green-800 p-1 text-xs",
39221
39316
  children: [
39222
39317
  /* @__PURE__ */ jsx33(ExcelIcon2, {}),
39223
39318
  "Exportar"
@@ -39227,7 +39322,7 @@ function HTable({
39227
39322
  context.onSelect && /* @__PURE__ */ jsx33(
39228
39323
  "button",
39229
39324
  {
39230
- className: "border shadow rounded p-1 text-white px-2 " + (context.selected.length > 0 ? "bg-blue-500" : "bg-gray-500"),
39325
+ className: "border shadow rounded p-1 text-white p-1 text-xs bg-blue-500 cursor-pointer ",
39231
39326
  disabled: context.selected.length == 0,
39232
39327
  onClick: async (e) => {
39233
39328
  setIsloading(true);
@@ -39244,7 +39339,7 @@ function HTable({
39244
39339
  context.onSave && /* @__PURE__ */ jsx33(
39245
39340
  "button",
39246
39341
  {
39247
- className: "border shadow rounded p-1 text-white px-2 bg-blue-500",
39342
+ className: "border shadow rounded p-1 text-white p-1 text-xs bg-blue-500 cursor-pointer ",
39248
39343
  onClick: async (e) => {
39249
39344
  setIsloading(true);
39250
39345
  const ex = context.filteredData.map((d) => {
@@ -39258,204 +39353,256 @@ function HTable({
39258
39353
  }
39259
39354
  )
39260
39355
  ] }),
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
- )
39356
+ /* @__PURE__ */ jsxs25(
39357
+ "div",
39358
+ {
39359
+ children: [
39360
+ /* @__PURE__ */ jsx33(
39361
+ "div",
39362
+ {
39363
+ style: {
39364
+ gridTemplateColumns,
39365
+ width: Object.values(widths).reduce((acc, i) => acc + i, 0)
39329
39366
  },
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",
39367
+ className: ["grid w-full "].join(" "),
39368
+ children: headers.map((header, i) => {
39369
+ var _a, _b;
39370
+ if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
39371
+ if (header.startsWith("_") && !header.startsWith("__")) return null;
39372
+ return /* @__PURE__ */ jsx33(
39373
+ "div",
39344
39374
  {
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);
39375
+ className: "bg-white relative w-full bg-red-100",
39376
+ children: /* @__PURE__ */ jsx33(
39377
+ Header,
39378
+ {
39379
+ length: headers.length,
39380
+ index: i,
39381
+ padding,
39382
+ header,
39383
+ context,
39384
+ drag: { gridTemplateColumns, startDrag, widths }
39357
39385
  }
39358
- context.setSelected(newSelected);
39359
- }
39360
- }
39361
- )
39386
+ )
39387
+ },
39388
+ header
39389
+ );
39390
+ })
39391
+ }
39392
+ ),
39393
+ /* @__PURE__ */ jsx33(
39394
+ "div",
39395
+ {
39396
+ style: {
39397
+ gridTemplateColumns,
39398
+ width: Object.values(widths).reduce((acc, i) => acc + i, 0)
39362
39399
  },
39363
- row.id + i
39364
- );
39365
- }
39366
- return /* @__PURE__ */ jsx33(
39400
+ className: [
39401
+ "grid max-h-[500px] ",
39402
+ context.filteredData.length >= 5 ? "overflow-hidden overflow-y-scroll " : ""
39403
+ ].join(" "),
39404
+ children: searchedData.slice(pagination.inicio - 1, pagination.fin).map((row, rowIndex) => {
39405
+ const items = Object.entries(row);
39406
+ return items.map(([key, item], i) => {
39407
+ var _a, _b, _c, _d, _e;
39408
+ if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, key)) return null;
39409
+ if (key.startsWith("_") && !key.startsWith("__")) return null;
39410
+ if (key == "__modal__") {
39411
+ return /* @__PURE__ */ jsx33(
39412
+ "div",
39413
+ {
39414
+ onMouseEnter: (e) => setCurrentIndex(rowIndex),
39415
+ style: {
39416
+ height: `${padding}px`
39417
+ },
39418
+ 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" : ""),
39419
+ children: (context == null ? void 0 : context.modalButton) || /* @__PURE__ */ jsx33(
39420
+ "button",
39421
+ {
39422
+ className: "border shadow rounded bg-blue-500 text-white p-2 ",
39423
+ onClick: (e) => {
39424
+ var _a2;
39425
+ setCurrentIndex(rowIndex);
39426
+ (_a2 = modalRef.current) == null ? void 0 : _a2.click();
39427
+ },
39428
+ children: /* @__PURE__ */ jsx33(EditIcon3, {})
39429
+ }
39430
+ )
39431
+ },
39432
+ row.id + i
39433
+ );
39434
+ }
39435
+ if (key == "__select__") {
39436
+ return /* @__PURE__ */ jsx33(
39437
+ "div",
39438
+ {
39439
+ onMouseEnter: (e) => setCurrentIndex(rowIndex),
39440
+ style: {
39441
+ height: `${padding}px`
39442
+ },
39443
+ 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" : ""),
39444
+ children: /* @__PURE__ */ jsx33(
39445
+ "input",
39446
+ {
39447
+ type: "checkbox",
39448
+ className: "w-5 h-5 accent-blue-600 transition-all duration-300 checked:scale-110 ",
39449
+ checked: Boolean(
39450
+ context.selected.find((s) => s == (row == null ? void 0 : row.id))
39451
+ ),
39452
+ onChange: (e) => {
39453
+ const newSelected = [...context.selected];
39454
+ const index = newSelected.findIndex(
39455
+ (s) => s == (row == null ? void 0 : row.id)
39456
+ );
39457
+ if (index >= 0) {
39458
+ newSelected.splice(index, 1);
39459
+ } else {
39460
+ newSelected.push(row == null ? void 0 : row.id);
39461
+ }
39462
+ context.setSelected(newSelected);
39463
+ }
39464
+ }
39465
+ )
39466
+ },
39467
+ row.id + i
39468
+ );
39469
+ }
39470
+ return /* @__PURE__ */ jsx33(
39471
+ "div",
39472
+ {
39473
+ onMouseEnter: (e) => setCurrentIndex(rowIndex),
39474
+ style: {
39475
+ fontSize: (context == null ? void 0 : context.fontSize) || "12px",
39476
+ ...(context == null ? void 0 : context.wrapText) ? { minHeight: `${padding}px` } : { height: `${padding}px` }
39477
+ },
39478
+ 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 " : ""),
39479
+ children: (context == null ? void 0 : context.editableFields) && context.editableFields.includes(key) ? /* @__PURE__ */ jsx33(
39480
+ "input",
39481
+ {
39482
+ defaultValue: item,
39483
+ className: "w-full " + (context.editions.includes(row == null ? void 0 : row.id) ? "bg-blue-400 text-white" : "bg-blue-100"),
39484
+ onBlur: (e) => {
39485
+ const id = row == null ? void 0 : row.id;
39486
+ const newData = [...context.data];
39487
+ const index = newData.findIndex((d) => +d.id == +id);
39488
+ newData[index][key] = e.target.value;
39489
+ context.setData(newData);
39490
+ const newEditions = [
39491
+ .../* @__PURE__ */ new Set([...context.editions, id])
39492
+ ];
39493
+ context.setEditions(newEditions);
39494
+ }
39495
+ }
39496
+ ) : ((_c = context.buttons) == null ? void 0 : _c[key]) ? React10.cloneElement(context.buttons[key], {
39497
+ // children: context.buttons[key]?.props?.children
39498
+ // ? item
39499
+ // : undefined,
39500
+ value: item,
39501
+ children: ((_e = (_d = context.buttons[key]) == null ? void 0 : _d.props) == null ? void 0 : _e.children) ? item : null,
39502
+ onClick: async (e) => {
39503
+ var _a2, _b2;
39504
+ const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onClick) == null ? void 0 : _b2.call(_a2, {
39505
+ e,
39506
+ row
39507
+ })) || {};
39508
+ const newData = [...context.data];
39509
+ const index = newData.findIndex(
39510
+ (f) => f.id == (row == null ? void 0 : row.id)
39511
+ );
39512
+ newData[index] = { ...newData[index], ...ret };
39513
+ context.setData(newData);
39514
+ },
39515
+ onChange: async (e) => {
39516
+ var _a2, _b2, _c2;
39517
+ const value = e.target.value;
39518
+ const ret = await ((_b2 = (_a2 = context.buttons[key].props) == null ? void 0 : _a2.onChange) == null ? void 0 : _b2.call(_a2, {
39519
+ e,
39520
+ row
39521
+ })) || {};
39522
+ const newData = [...context.data];
39523
+ const index = newData.findIndex(
39524
+ (f) => f.id == (row == null ? void 0 : row.id)
39525
+ );
39526
+ if (index >= 0) {
39527
+ newData[index][key] = value;
39528
+ }
39529
+ for (let i2 in ret) {
39530
+ if ((_c2 = newData[index]) == null ? void 0 : _c2[i2]) {
39531
+ const v = ret[i2];
39532
+ newData[index][i2] = v;
39533
+ }
39534
+ }
39535
+ context.setData(newData);
39536
+ }
39537
+ }) : ["number", "string"].includes(typeof item) ? valueFormatter({
39538
+ value: item,
39539
+ currentCoin: context.currentCoin
39540
+ }) : React10.isValidElement(item) ? item : JSON.stringify(item)
39541
+ },
39542
+ row.id + i
39543
+ );
39544
+ });
39545
+ })
39546
+ }
39547
+ ),
39548
+ /* @__PURE__ */ jsx33(
39367
39549
  "div",
39368
39550
  {
39369
- onMouseEnter: (e) => setCurrentIndex(rowIndex),
39370
39551
  style: {
39371
- fontSize: context.fontSize,
39372
- ...(context == null ? void 0 : context.wrapText) ? { minHeight: `${padding}px` } : { height: `${padding}px` }
39552
+ gridTemplateColumns,
39553
+ width: Object.values(widths).reduce((acc, i) => acc + i, 0)
39373
39554
  },
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",
39555
+ className: ["grid border-b bg-white"].join(" "),
39556
+ children: Object.keys((context == null ? void 0 : context.footer) || {}).length > 0 && headers.map((header) => {
39557
+ var _a, _b, _c, _d, _e;
39558
+ if ((_b = (_a = context == null ? void 0 : context.hideColumns) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, header)) return null;
39559
+ if (header.startsWith("_") && !header.startsWith("__"))
39560
+ return null;
39561
+ return /* @__PURE__ */ jsx33(
39562
+ "div",
39563
+ {
39564
+ style: {
39565
+ // height: `${padding}px`,
39566
+ maxHeight: "100px"
39567
+ },
39568
+ title: ((_c = context.footer) == null ? void 0 : _c[header]) + " de " + header,
39569
+ className: " cursor-default font-bold bg-white flex items-center justify-center text-xs my-5 " + (((_d = context.footer) == null ? void 0 : _d[header]) ? " border-r border-l " : ""),
39570
+ children: valueFormatter({
39571
+ currentCoin: context.currentCoin,
39572
+ value: ((_e = context.footer) == null ? void 0 : _e[header]) ? context.footer[header] == "sum" ? context.filteredData.map((d) => +d[header]).reduce((acc, h) => h + acc, 0) : context.footer[header] == "count" ? context.filteredData.map((d) => d[header] != "" ? 1 : 0).reduce((acc, h) => acc + h, 0) : context.footer[header] == "avg" ? context.filteredData.map((d) => +d[header]).reduce((acc, h) => h + acc, 0) / context.filteredData.map((d) => d[header] != "" ? 1 : 0).reduce((acc, h) => acc + h, 0) : "" : ""
39573
+ })
39574
+ },
39575
+ header
39576
+ );
39577
+ })
39578
+ }
39579
+ ),
39580
+ searchedData.length > 100 && /* @__PURE__ */ jsxs25("div", { className: "flex justify-end p-2", children: [
39581
+ pagination.rango,
39582
+ " de ",
39583
+ pagination.total,
39584
+ /* @__PURE__ */ jsxs25("div", { className: "flex items-center gap-5 mx-5", children: [
39585
+ /* @__PURE__ */ jsx33(
39586
+ "button",
39377
39587
  {
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
- }
39588
+ onClick: (e) => pagination.hasPrev && pagination.prev(),
39589
+ className: pagination.hasPrev ? "" : "text-gray-300",
39590
+ children: /* @__PURE__ */ jsx33(PrevIcon, {})
39391
39591
  }
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);
39592
+ ),
39593
+ /* @__PURE__ */ jsx33(
39594
+ "button",
39595
+ {
39596
+ onClick: (e) => pagination.hasNext && pagination.next(),
39597
+ className: pagination.hasNext ? "" : "text-gray-300",
39598
+ children: /* @__PURE__ */ jsx33(NextIcon, {})
39428
39599
  }
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
- ] }),
39600
+ )
39601
+ ] })
39602
+ ] })
39603
+ ]
39604
+ }
39605
+ ),
39459
39606
  context.modal && /* @__PURE__ */ jsx33(
39460
39607
  Modal,
39461
39608
  {
@@ -39533,7 +39680,7 @@ function ModalContent({
39533
39680
  }
39534
39681
 
39535
39682
  // src/table-advanced/context.ts
39536
- import { useEffect as useEffect12, useMemo as useMemo9, useReducer as useReducer3, useState as useState16 } from "react";
39683
+ import { useEffect as useEffect13, useMemo as useMemo11, useReducer as useReducer3, useState as useState17 } from "react";
39537
39684
 
39538
39685
  // src/table-advanced/filter.reducer.ts
39539
39686
  var filterReducer = (acc, b) => {
@@ -39561,19 +39708,19 @@ var sortReducer = (acc, b) => {
39561
39708
  // src/table-advanced/context.ts
39562
39709
  function useContext({ onSelect }) {
39563
39710
  const excel = useExcel();
39564
- const [editions, setEditions] = useState16([]);
39565
- const [selected, setSelected] = useState16([]);
39566
- const [data, setData] = useState16([]);
39711
+ const [editions, setEditions] = useState17([]);
39712
+ const [selected, setSelected] = useState17([]);
39713
+ const [data, setData] = useState17([]);
39567
39714
  const headers = [...new Set(data.map((b) => Object.keys(b)).flat())];
39568
- const [currentHeader, setCurrentHeader] = useState16(null);
39715
+ const [currentHeader, setCurrentHeader] = useState17(null);
39569
39716
  const cols = headers.length;
39570
39717
  const [filters, setFilters] = useReducer3(
39571
39718
  filterReducer,
39572
39719
  new Array()
39573
39720
  );
39574
- const [searchBy, setSearchBy] = useState16("");
39721
+ const [searchBy, setSearchBy] = useState17("");
39575
39722
  const [sort, setSort] = useReducer3(sortReducer, new Array());
39576
- const sortedData = useMemo9(() => {
39723
+ const sortedData = useMemo11(() => {
39577
39724
  return [...data].sort((a, b) => {
39578
39725
  for (const { field, type } of sort.reverse()) {
39579
39726
  const av = a[field];
@@ -39603,7 +39750,7 @@ function useContext({ onSelect }) {
39603
39750
  }
39604
39751
  return true;
39605
39752
  });
39606
- useEffect12(() => {
39753
+ useEffect13(() => {
39607
39754
  if (filters.length == 0) {
39608
39755
  setEditions([]);
39609
39756
  }
@@ -39636,7 +39783,7 @@ import { jsx as jsx34 } from "react/jsx-runtime";
39636
39783
  function TableAdvanced(tableProps) {
39637
39784
  const { data, ...props } = tableProps;
39638
39785
  const context = useContext({ onSelect: Boolean(tableProps.onSelect) });
39639
- useEffect13(() => {
39786
+ useEffect14(() => {
39640
39787
  context.setData(
39641
39788
  Array.isArray(data) ? data.map((d) => {
39642
39789
  return {
@@ -39647,7 +39794,7 @@ function TableAdvanced(tableProps) {
39647
39794
  }) : data
39648
39795
  );
39649
39796
  }, [data]);
39650
- useEffect13(() => {
39797
+ useEffect14(() => {
39651
39798
  if (tableProps == null ? void 0 : tableProps.sortBy) {
39652
39799
  const [k, v] = Object.entries(tableProps.sortBy)[0];
39653
39800
  context.setSort({ [k]: v });
@@ -39666,14 +39813,14 @@ function TableAdvanced(tableProps) {
39666
39813
  }
39667
39814
 
39668
39815
  // src/tabs/index.tsx
39669
- import React11, { useEffect as useEffect14, useState as useState18 } from "react";
39816
+ import React11, { useEffect as useEffect15, useState as useState19 } from "react";
39670
39817
  import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
39671
39818
  function TabContainer({
39672
39819
  children,
39673
39820
  labelMaxWidth = 100,
39674
39821
  currentIndex = 0
39675
39822
  }) {
39676
- const [index, setIndex] = useState18(0);
39823
+ const [index, setIndex] = useState19(0);
39677
39824
  const items = React11.Children.toArray(
39678
39825
  children
39679
39826
  );
@@ -39683,7 +39830,7 @@ function TabContainer({
39683
39830
  if (e.key === "ArrowLeft")
39684
39831
  setIndex((k - 1 + labels.length) % labels.length);
39685
39832
  };
39686
- useEffect14(() => {
39833
+ useEffect15(() => {
39687
39834
  setIndex(currentIndex);
39688
39835
  }, [currentIndex]);
39689
39836
  return /* @__PURE__ */ jsxs26("div", { className: "w-full bg-white", children: [