next-recomponents 1.7.63 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2979,13 +2979,12 @@ __export(index_exports, {
2979
2979
  Pre: () => pre_default,
2980
2980
  Select: () => Select,
2981
2981
  Table: () => Table,
2982
- TableDos: () => TableDos,
2982
+ Table3: () => Table3,
2983
2983
  TextArea: () => TextArea,
2984
2984
  regularExpresions: () => regular_expresions_default,
2985
2985
  useDates: () => useDates,
2986
2986
  useExcel: () => useExcel,
2987
2987
  useFormValues: () => useFormValues,
2988
- useModal: () => useModal,
2989
2988
  useResources: () => useResources
2990
2989
  });
2991
2990
  module.exports = __toCommonJS(index_exports);
@@ -10925,7 +10924,7 @@ function Container({
10925
10924
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
10926
10925
  "div",
10927
10926
  {
10928
- className: ` gap-2 bg-blue-400 text-white ${isSidebarOpen ? "px-[270px]" : "px-[60px]"} hidden sm:flex`,
10927
+ className: ` gap-2 bg-gray-800 text-white ${isSidebarOpen ? "px-[270px]" : "px-[60px]"} hidden sm:flex`,
10929
10928
  children: navItems && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: [{ location: "/", name: "Home", icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HomeIcon, {}) }, navItems].flat().map((li, k) => {
10930
10929
  return li && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
10931
10930
  import_link.default,
@@ -10950,7 +10949,7 @@ function Container({
10950
10949
  animate: {
10951
10950
  width: typeof window !== "undefined" && window.innerWidth < 768 ? isSidebarOpen ? "100%" : 0 : isSidebarOpen ? 250 : 60
10952
10951
  },
10953
- className: "bg-blue-400 text-white overflow-y-auto fixed md:static top-0 left-0 h-full z-50 md:z-auto transition-all duration-300 ease-in-out",
10952
+ className: "bg-gray-800 text-white overflow-y-auto fixed md:static top-0 left-0 h-full z-50 md:z-auto transition-all duration-300 ease-in-out",
10954
10953
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "p-4 ", children: menuList && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("ul", { className: "space-y-3", children: [
10955
10954
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
10956
10955
  "li",
@@ -10976,14 +10975,7 @@ function Container({
10976
10975
  icon,
10977
10976
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: " truncate", children: itemMenu == null ? void 0 : itemMenu.name })
10978
10977
  ] }),
10979
- !isSidebarOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
10980
- "div",
10981
- {
10982
- title: `${itemMenu.name}`,
10983
- className: "text-sm hover:bg-gray-200 hover:text-black rounded p-1",
10984
- children: icon
10985
- }
10986
- )
10978
+ !isSidebarOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-sm hover:bg-gray-200 hover:text-black rounded p-1", children: icon })
10987
10979
  ]
10988
10980
  }
10989
10981
  ) }, k);
@@ -11247,30 +11239,20 @@ function TD(_a) {
11247
11239
  },
11248
11240
  __spreadValues({}, (_b2 = symbols[item == null ? void 0 : item.name]) == null ? void 0 : _b2.props)
11249
11241
  ));
11250
- const typeOf = (value) => {
11251
- if (value instanceof Date) return "date";
11252
- if (typeof value === "number") return "number";
11253
- if (typeof value === "string") {
11254
- const d = new Date(value);
11255
- if (!isNaN(d.getTime())) return "date-string";
11256
- return "string";
11257
- }
11258
- return typeof value;
11259
- };
11260
- const result = typeOf(item == null ? void 0 : item.content);
11261
11242
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
11262
11243
  "td",
11263
- __spreadProps(__spreadValues({}, props), {
11244
+ {
11264
11245
  onDoubleClick: (e) => setIsHidded(!isHidded),
11265
11246
  className: [
11266
11247
  isHidded && color2,
11267
- !isHidded && "whitespace-nowrap overflow-hidden text-ellipsis ",
11268
- " px-2 "
11248
+ !isHidded && "whitespace-nowrap overflow-hidden text-ellipsis ",
11249
+ "border-b max-w-[200px] p-2 "
11250
+ // ["number", "money"].includes(item?.cellTypeOf) && "text-right",
11269
11251
  ].join(" "),
11270
11252
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
11271
11253
  "div",
11272
11254
  {
11273
- className: symbols && (symbols == null ? void 0 : symbols[item == null ? void 0 : item.name]) ? symbols[item == null ? void 0 : item.name] : " flex " + (result == "number" ? "justify-end" : "justify-start"),
11255
+ className: symbols && symbols[item == null ? void 0 : item.name] && "flex justify-between ",
11274
11256
  children: symbols ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-1", children: [
11275
11257
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: import_react23.default.Children.map(symbols[item == null ? void 0 : item.name], (child) => {
11276
11258
  if (import_react23.default.isValidElement(child)) {
@@ -11280,10 +11262,10 @@ function TD(_a) {
11280
11262
  return child;
11281
11263
  }) }),
11282
11264
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: !(newProps == null ? void 0 : newProps["row"]) && (item == null ? void 0 : item.content) })
11283
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "", children: item == null ? void 0 : item.content })
11265
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: item == null ? void 0 : item.content })
11284
11266
  }
11285
11267
  )
11286
- })
11268
+ }
11287
11269
  );
11288
11270
  }
11289
11271
 
@@ -11304,6 +11286,21 @@ function FilterOffIcon() {
11304
11286
  }
11305
11287
  );
11306
11288
  }
11289
+ function EditIcon() {
11290
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
11291
+ "svg",
11292
+ {
11293
+ stroke: "currentColor",
11294
+ fill: "currentColor",
11295
+ strokeWidth: "0",
11296
+ viewBox: "0 0 576 512",
11297
+ height: "20px",
11298
+ width: "20px",
11299
+ xmlns: "http://www.w3.org/2000/svg",
11300
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z" })
11301
+ }
11302
+ );
11303
+ }
11307
11304
  function MdLastPage() {
11308
11305
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
11309
11306
  "svg",
@@ -43443,16 +43440,7 @@ function HTable(_a) {
43443
43440
  const regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
43444
43441
  const isDate = !isObject2 && regex.test(`${d[key]}`);
43445
43442
  const cellTypeOf = isDate ? "date" : isObject2 ? "object" : typeOf;
43446
- const mapedIndex = mapedData.find(
43447
- (mpd) => {
43448
- var _a3, _b3;
43449
- return `${d.id}`.includes(
43450
- (_a3 = mpd == null ? void 0 : mpd.id) == null ? void 0 : _a3.content,
43451
- (_b3 = mpd == null ? void 0 : mpd._id) == null ? void 0 : _b3.content
43452
- );
43453
- }
43454
- );
43455
- const mapedContent = (_b2 = mapedIndex == null ? void 0 : mapedIndex[key]) == null ? void 0 : _b2.content;
43443
+ const mapedContent = (_b2 = mapedData[trkey][key]) == null ? void 0 : _b2.content;
43456
43444
  const content = mapedContent || (cellTypeOf == "date" ? d[key].split("T").join(" ").split(".")[0] : cellTypeOf == "object" ? import_react25.default.isValidElement(d[key]) ? ((_c = d[key]) == null ? void 0 : _c.props).value : JSON.stringify(d[key]) : d[key]);
43457
43445
  const handler = import_react25.default.isValidElement(d[key]) ? d[key] : null;
43458
43446
  obj[key] = {
@@ -43515,12 +43503,12 @@ function HTable(_a) {
43515
43503
  ) })
43516
43504
  ] }),
43517
43505
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", __spreadProps(__spreadValues({}, props), { className: "w-full border-collapse table-auto", children: [
43518
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: "bg-blue-400 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { children: head.map((h, key) => {
43506
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { children: head.map((h, key) => {
43519
43507
  var _a2;
43520
- return h != "_id" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
43508
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
43521
43509
  "th",
43522
43510
  {
43523
- className: "whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px] border-b ",
43511
+ className: "whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px] border-b p-2",
43524
43512
  children: [
43525
43513
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
43526
43514
  "div",
@@ -43529,7 +43517,7 @@ function HTable(_a) {
43529
43517
  onClick: (e) => {
43530
43518
  setSelectedFilter(key == selectedFilter ? null : key);
43531
43519
  },
43532
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "text-white w-full rounded flex justify-center", children: [
43520
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "text-white w-full bg-black rounded flex justify-center", children: [
43533
43521
  h,
43534
43522
  " ",
43535
43523
  !((_a2 = mapedData == null ? void 0 : mapedData.map((d) => {
@@ -43556,7 +43544,7 @@ function HTable(_a) {
43556
43544
  );
43557
43545
  }) }) }),
43558
43546
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: "divide-y divide-gray-200", children: mapedData.map((md, trKey) => {
43559
- var _a2, _b2, _c;
43547
+ var _a2, _b2;
43560
43548
  const start = (page - 1) * maxItems;
43561
43549
  const end = page * maxItems;
43562
43550
  if (!hasFilters) {
@@ -43568,7 +43556,7 @@ function HTable(_a) {
43568
43556
  return null;
43569
43557
  }
43570
43558
  }
43571
- const dataKey = ((_b2 = md == null ? void 0 : md._id) == null ? void 0 : _b2.content) || ((_c = md == null ? void 0 : md.id) == null ? void 0 : _c.content) || trKey;
43559
+ const dataKey = ((_b2 = md == null ? void 0 : md.id) == null ? void 0 : _b2.content) || trKey;
43572
43560
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
43573
43561
  "tr",
43574
43562
  {
@@ -43579,18 +43567,17 @@ function HTable(_a) {
43579
43567
  "data-key": dataKey,
43580
43568
  onClick: (e) => setSelected(trKey),
43581
43569
  className: [
43582
- "hover:bg-blue-100 ",
43570
+ "hover:bg-green-100 ",
43583
43571
  color2,
43584
- selected == trKey && " bg-blue-200 hover:bg-blue-300"
43572
+ selected == trKey && "bg-green-200 hover:bg-green-300"
43585
43573
  ].join(" "),
43586
43574
  children: head.map((h, tdKey) => {
43587
- var _a3, _b3;
43575
+ var _a3;
43588
43576
  const item = md[h];
43589
- const id3 = trKey + "-" + (((_a3 = md == null ? void 0 : md["_id"]) == null ? void 0 : _a3.content) || ((_b3 = md == null ? void 0 : md.id) == null ? void 0 : _b3.content) || tdKey) + "-" + h;
43590
- return h != "_id" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
43577
+ const id3 = trKey + "-" + (((_a3 = md == null ? void 0 : md.id) == null ? void 0 : _a3.content) || tdKey) + "-" + h;
43578
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
43591
43579
  TD,
43592
43580
  {
43593
- "data-key": id3,
43594
43581
  index: trKey,
43595
43582
  symbols,
43596
43583
  item,
@@ -43605,11 +43592,18 @@ function HTable(_a) {
43605
43592
  dataKey
43606
43593
  );
43607
43594
  }) }),
43608
- totals && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tfoot", { className: "bg-blue-400 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { children: head.map((h, fkey) => {
43609
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("th", { className: "text-right border-b max-w-[200px] ", children: totals.includes(h) && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex justify-between text-white w-full rounded ", children: [
43610
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "p-1", children: symbols && symbols[h] && symbols[h] }),
43611
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "p-1", children: mapedTotals[h] })
43612
- ] }) }, fkey);
43595
+ totals && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tfoot", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { children: head.map((h, fkey) => {
43596
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
43597
+ "th",
43598
+ {
43599
+ className: "text-right border-b max-w-[200px] p-2 ",
43600
+ children: totals.includes(h) && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex justify-between text-white w-full bg-black rounded ", children: [
43601
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "p-1", children: symbols && symbols[h] && symbols[h] }),
43602
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "p-1", children: mapedTotals[h] })
43603
+ ] })
43604
+ },
43605
+ fkey
43606
+ );
43613
43607
  }) }) })
43614
43608
  ] })),
43615
43609
  isLoading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "fixed top-0 left-0 w-full h-screen flex items-center justify-center bg-white bg-opacity-50", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: loader }) })
@@ -44870,777 +44864,713 @@ function DocumentViewer({ item }) {
44870
44864
  ] });
44871
44865
  }
44872
44866
 
44873
- // src/table2/index.tsx
44874
- var import_react36 = require("react");
44867
+ // src/table3/index.tsx
44868
+ var import_react37 = __toESM(require("react"));
44875
44869
 
44876
- // src/table2/context.tsx
44870
+ // src/table3/filter.tsx
44877
44871
  var import_react33 = require("react");
44878
- function useTableContext({
44879
- data,
44880
- maxItems,
44881
- symbols,
44882
- handlers,
44883
- onSave,
44884
- exportName,
44885
- selectItems,
44872
+ var import_jsx_runtime28 = require("react/jsx-runtime");
44873
+ function Filter({
44874
+ h,
44875
+ objectData,
44876
+ setObjectData,
44877
+ setPage,
44886
44878
  colSizes
44887
44879
  }) {
44888
- function dataReduce(datums) {
44889
- return datums.map((row) => {
44890
- for (let key in row) {
44891
- if (typeof row[key] === "object") {
44892
- row[key] = JSON.stringify(row[key]);
44893
- }
44894
- }
44895
- return row;
44896
- }).reduce((acc, d) => {
44897
- const id3 = (d == null ? void 0 : d._id) || (d == null ? void 0 : d.id);
44898
- if (!id3) throw new Error("Data must have an '_id' or 'id' field");
44899
- acc[id3] = d;
44900
- acc[id3]._checkedItem = false;
44901
- return acc;
44902
- }, {});
44903
- }
44904
- const excel = useExcel();
44905
- const [defaultData, setDefaultData] = (0, import_react33.useState)(dataReduce(data));
44906
- const [page, setPage] = (0, import_react33.useState)(1);
44907
- const headers = (0, import_react33.useMemo)(() => {
44908
- return [...new Set(data.flatMap((d) => Object.keys(d)))];
44909
- }, [data]);
44910
- const list = (0, import_react33.useMemo)(() => {
44911
- return headers.reduce((acc, h) => {
44912
- acc[h] = [
44913
- ...new Set(
44914
- Object.values(defaultData).map((row) => {
44915
- const value = typeof row[h] === "object" ? JSON.stringify(row[h]) : row[h];
44916
- return value;
44917
- })
44918
- )
44919
- ];
44920
- return acc;
44921
- }, {});
44922
- }, [headers, defaultData]);
44923
- const [filters, setFilters] = (0, import_react33.useState)(
44924
- headers.reduce((acc, h) => {
44925
- acc[h] = list[h].reduce((ac, l) => {
44926
- ac[l] = true;
44927
- return ac;
44928
- }, {});
44929
- return acc;
44930
- }, {})
44931
- );
44932
- const bodyKeys = (0, import_react33.useMemo)(() => Object.keys(defaultData), [defaultData]);
44933
- const body = (0, import_react33.useMemo)(() => defaultData, [defaultData]);
44934
- const filteredBody = (0, import_react33.useMemo)(() => {
44935
- return bodyKeys.filter((key) => {
44936
- return headers.every((header) => {
44937
- var _a, _b;
44938
- return ((_b = filters == null ? void 0 : filters[`${header}`]) == null ? void 0 : _b[(_a = body == null ? void 0 : body[`${key}`]) == null ? void 0 : _a[`${header}`]]) !== false;
44939
- });
44940
- });
44941
- }, [filters, headers, defaultData]);
44942
- const paginatedBody = (0, import_react33.useMemo)(() => {
44943
- return filteredBody.filter((k, index) => {
44944
- if (maxItems === Infinity) return true;
44945
- const desde = (page - 1) * maxItems;
44946
- const hasta = desde + maxItems;
44947
- return index >= desde && index < hasta;
44948
- });
44949
- }, [filteredBody, page]);
44950
- const totalPages = (0, import_react33.useMemo)(
44951
- () => maxItems === Infinity ? 1 : Math.ceil(filteredBody.length / maxItems),
44952
- [filteredBody, maxItems]
44953
- );
44954
- (0, import_react33.useEffect)(() => {
44955
- const original = dataReduce(data);
44956
- const originalKeys = Object.keys(original);
44957
- setDefaultData((prevDefaultData) => {
44958
- var _a;
44959
- const newDefault = {};
44960
- for (let key of originalKeys) {
44961
- newDefault[key] = (_a = prevDefaultData == null ? void 0 : prevDefaultData[key]) != null ? _a : original[key];
44962
- }
44963
- return newDefault;
44964
- });
44965
- }, [data]);
44966
- return {
44967
- page,
44968
- setPage,
44969
- defaultData,
44970
- setDefaultData,
44971
- totalPages,
44972
- headers,
44973
- filters,
44974
- setFilters,
44975
- list,
44976
- filteredBody,
44977
- maxItems,
44978
- paginatedBody,
44979
- handlers,
44980
- symbols,
44981
- onSave,
44982
- exportName,
44983
- excel,
44984
- selectItems,
44985
- colSizes
44986
- };
44987
- }
44988
-
44989
- // src/table2/icons.tsx
44990
- var import_jsx_runtime28 = require("react/jsx-runtime");
44991
- function FilterIcon() {
44992
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
44993
- "svg",
44994
- {
44995
- stroke: "currentColor",
44996
- fill: "currentColor",
44997
- strokeWidth: "0",
44998
- viewBox: "0 0 576 512",
44999
- height: "1rem",
45000
- width: "1rem",
45001
- xmlns: "http://www.w3.org/2000/svg",
45002
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "M3.9 22.9C10.5 8.9 24.5 0 40 0L472 0c15.5 0 29.5 8.9 36.1 22.9s4.6 30.5-5.2 42.5L396.4 195.6C316.2 212.1 256 283 256 368c0 27.4 6.3 53.4 17.5 76.5c-1.6-.8-3.2-1.8-4.7-2.9l-64-48c-8.1-6-12.8-15.5-12.8-25.6l0-79.1L9 65.3C-.7 53.4-2.8 36.8 3.9 22.9zM432 224a144 144 0 1 1 0 288 144 144 0 1 1 0-288zm59.3 107.3c6.2-6.2 6.2-16.4 0-22.6s-16.4-6.2-22.6 0L432 345.4l-36.7-36.7c-6.2-6.2-16.4-6.2-22.6 0s-6.2 16.4 0 22.6L409.4 368l-36.7 36.7c-6.2 6.2-6.2 16.4 0 22.6s16.4 6.2 22.6 0L432 390.6l36.7 36.7c6.2 6.2 16.4 6.2 22.6 0s6.2-16.4 0-22.6L454.6 368l36.7-36.7z" })
45003
- }
45004
- );
45005
- }
45006
- function MdOutlineFirstPage() {
45007
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
45008
- "svg",
45009
- {
45010
- stroke: "currentColor",
45011
- fill: "currentColor",
45012
- strokeWidth: "0",
45013
- viewBox: "0 0 24 24",
45014
- height: "1rem",
45015
- width: "1rem",
45016
- xmlns: "http://www.w3.org/2000/svg",
45017
- children: [
45018
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { fill: "none", d: "M24 0v24H0V0h24z", opacity: ".87" }),
45019
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "M18.41 16.59 13.82 12l4.59-4.59L17 6l-6 6 6 6 1.41-1.41zM6 6h2v12H6V6z" })
45020
- ]
45021
- }
45022
- );
45023
- }
45024
- function MdOutlineLastPage() {
45025
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
45026
- "svg",
45027
- {
45028
- stroke: "currentColor",
45029
- fill: "currentColor",
45030
- strokeWidth: "0",
45031
- viewBox: "0 0 24 24",
45032
- height: "1rem",
45033
- width: "1rem",
45034
- xmlns: "http://www.w3.org/2000/svg",
45035
- children: [
45036
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { fill: "none", d: "M0 0h24v24H0V0z", opacity: ".87" }),
45037
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "M5.59 7.41 10.18 12l-4.59 4.59L7 18l6-6-6-6-1.41 1.41zM16 6h2v12h-2V6z" })
45038
- ]
45039
- }
44880
+ const [visible, setVisible] = (0, import_react33.useState)(false);
44881
+ const [text, setText] = (0, import_react33.useState)("");
44882
+ const items = (0, import_react33.useMemo)(
44883
+ () => [...new Set(Object.values(objectData).map((o) => o[h]))],
44884
+ [objectData]
45040
44885
  );
45041
- }
45042
- function GrFormNext() {
45043
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45044
- "svg",
45045
- {
45046
- stroke: "currentColor",
45047
- fill: "currentColor",
45048
- strokeWidth: "0",
45049
- viewBox: "0 0 24 24",
45050
- height: "1rem",
45051
- width: "1rem",
45052
- xmlns: "http://www.w3.org/2000/svg",
45053
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("polyline", { fill: "none", strokeWidth: "2", points: "9 6 15 12 9 18" })
45054
- }
45055
- );
45056
- }
45057
- function GrFormPrevious() {
45058
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45059
- "svg",
45060
- {
45061
- stroke: "currentColor",
45062
- fill: "currentColor",
45063
- strokeWidth: "0",
45064
- viewBox: "0 0 24 24",
45065
- height: "1rem",
45066
- width: "1rem",
45067
- xmlns: "http://www.w3.org/2000/svg",
45068
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45069
- "polyline",
45070
- {
45071
- fill: "none",
45072
- strokeWidth: "2",
45073
- points: "9 6 15 12 9 18",
45074
- transform: "matrix(-1 0 0 1 24 0)"
45075
- }
45076
- )
45077
- }
45078
- );
45079
- }
45080
- function RiFileExcel2Fill() {
45081
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45082
- "svg",
45083
- {
45084
- stroke: "currentColor",
45085
- fill: "currentColor",
45086
- strokeWidth: "0",
45087
- viewBox: "0 0 24 24",
45088
- height: "1rem",
45089
- width: "1rem",
45090
- xmlns: "http://www.w3.org/2000/svg",
45091
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "M2.85858 2.87732L15.4293 1.0815C15.7027 1.04245 15.9559 1.2324 15.995 1.50577C15.9983 1.52919 16 1.55282 16 1.57648V22.4235C16 22.6996 15.7761 22.9235 15.5 22.9235C15.4763 22.9235 15.4527 22.9218 15.4293 22.9184L2.85858 21.1226C2.36593 21.0522 2 20.6303 2 20.1327V3.86727C2 3.36962 2.36593 2.9477 2.85858 2.87732ZM17 2.99997H21C21.5523 2.99997 22 3.44769 22 3.99997V20C22 20.5523 21.5523 21 21 21H17V2.99997ZM10.2 12L13 7.99997H10.6L9 10.2857L7.39999 7.99997H5L7.8 12L5 16H7.39999L9 13.7143L10.6 16H13L10.2 12Z" })
45092
- }
44886
+ const [selected, setSelected] = (0, import_react33.useState)(items);
44887
+ const itemsFiltered = (0, import_react33.useMemo)(
44888
+ () => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
44889
+ if (!text) return true;
44890
+ return `${item}`.toLowerCase().includes(text.toLowerCase());
44891
+ }),
44892
+ [items, text]
45093
44893
  );
45094
- }
45095
- function IoIosSave() {
45096
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
45097
- "svg",
45098
- {
45099
- stroke: "currentColor",
45100
- fill: "currentColor",
45101
- strokeWidth: "0",
45102
- viewBox: "0 0 512 512",
45103
- height: "1rem",
45104
- width: "1rem",
45105
- xmlns: "http://www.w3.org/2000/svg",
45106
- children: [
45107
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "M272 64h-16c-4.4 0-8 3.6-8 8v72c0 4.4 7.6 8 12 8h12c4.4 0 8-3.6 8-8V72c0-4.4-3.6-8-8-8z" }),
45108
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "M433.9 130.1L382 78.2c-9-9-21.3-14.2-34.1-14.2h-28c-8.8 0-16 7.3-16 16.2v80c0 8.8-7.2 16-16 16H160c-8.8 0-16-7.2-16-16v-80c0-8.8-7.2-16.2-16-16.2H96c-17.6 0-32 14.4-32 32v320c0 17.6 14.4 32 32 32h320c17.6 0 32-14.4 32-32V164c0-12.7-5.1-24.9-14.1-33.9zM322 400.1c0 8.8-8 16-17.8 16H143.8c-9.8 0-17.8-7.2-17.8-16v-96c0-8.8 8-16 17.8-16h160.4c9.8 0 17.8 7.2 17.8 16v96z" })
45109
- ]
44894
+ function filtrar(itemsInterno = []) {
44895
+ const array = Object.values(objectData);
44896
+ let obj;
44897
+ if (itemsInterno.length > 0) {
44898
+ setSelected(items);
44899
+ obj = array.map((row) => {
44900
+ return (row == null ? void 0 : row._id) ? {
44901
+ _id: row._id,
44902
+ _visible: itemsInterno.includes(row[h])
44903
+ } : { id: row.id, _visible: itemsInterno.includes(row[h]) };
44904
+ });
44905
+ } else {
44906
+ obj = array.map((row) => {
44907
+ return (row == null ? void 0 : row._id) ? {
44908
+ _id: row._id,
44909
+ _visible: itemsFiltered.length < items.length ? itemsFiltered.includes(row[h]) : selected.includes(row[h])
44910
+ } : {
44911
+ id: row.id,
44912
+ _visible: itemsFiltered.length < items.length ? itemsFiltered.includes(row[h]) : selected.includes(row[h])
44913
+ };
44914
+ });
45110
44915
  }
45111
- );
45112
- }
45113
-
45114
- // src/table2/v.table.body.tsx
45115
- var import_react34 = __toESM(require("react"));
45116
- var import_jsx_runtime29 = require("react/jsx-runtime");
45117
- var Row = import_react34.default.memo(
45118
- ({ rowKey, context, handleCheck }) => {
45119
- const rowData = context.defaultData[rowKey];
45120
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("tr", { className: "hover:bg-gray-200", children: [
45121
- context.selectItems && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("th", { className: "border-b", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
45122
- "input",
45123
- {
45124
- type: "checkbox",
45125
- className: "w-5 h-5 accent-green-500",
45126
- checked: !!(rowData == null ? void 0 : rowData._checkedItem),
45127
- onChange: (e) => handleCheck(rowKey, e.target.checked)
45128
- }
45129
- ) }),
45130
- context.headers.map((header, index) => {
45131
- var _a, _b, _c, _d;
45132
- if (header.startsWith("_")) return null;
45133
- const value = rowData[header];
45134
- if ((_a = context.handlers) == null ? void 0 : _a[header]) {
45135
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("td", { className: "p-1 w-[100px]", children: import_react34.default.isValidElement(context.handlers[header]) && import_react34.default.cloneElement(context.handlers[header], {
45136
- value,
45137
- onChange: (e) => {
45138
- var _a2, _b2, _c2;
45139
- const result = (_c2 = (_b2 = (_a2 = context.handlers[header]) == null ? void 0 : _a2.props) == null ? void 0 : _b2.onChange) == null ? void 0 : _c2.call(_b2, e);
45140
- const newData = __spreadValues({}, context.defaultData);
45141
- for (let item in result) {
45142
- newData[rowKey][item] = result[item];
45143
- }
45144
- newData[rowKey][header] = e.target.value;
45145
- context.setDefaultData(newData);
45146
- }
45147
- }) }, index);
45148
- } else {
45149
- const updateRow = (data) => {
45150
- const newData = __spreadValues({}, context.defaultData);
45151
- for (let item in data) {
45152
- newData[rowKey][item] = data[item];
45153
- }
45154
- context.setDefaultData(newData);
45155
- };
45156
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("td", { className: "p-1 w-[100px] border-b", children: ((_b = context.symbols) == null ? void 0 : _b[header]) ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex justify-between w-full", children: [
45157
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: import_react34.default.isValidElement((_c = context.symbols) == null ? void 0 : _c[header]) && import_react34.default.cloneElement((_d = context.symbols) == null ? void 0 : _d[header], {
45158
- row: rowData,
45159
- updateRow,
45160
- onClick: (e) => {
45161
- var _a2, _b2, _c2, _d2;
45162
- e.row = rowData;
45163
- e.updateRow = updateRow;
45164
- (_d2 = (_c2 = (_b2 = (_a2 = context.symbols) == null ? void 0 : _a2[header]) == null ? void 0 : _b2.props) == null ? void 0 : _c2.onClick) == null ? void 0 : _d2.call(_c2, e);
45165
- }
45166
- }) }),
45167
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-full px-2 py-[3px] truncate", children: value })
45168
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-full px-2 py-[3px]", children: value }) }, index);
45169
- }
45170
- })
45171
- ] });
45172
- },
45173
- (prev, next) => {
45174
- return prev.context.defaultData[prev.rowKey] === next.context.defaultData[next.rowKey];
44916
+ setObjectData(obj);
44917
+ setPage(1);
44918
+ setVisible(false);
44919
+ setText("");
45175
44920
  }
45176
- );
45177
- function VTableBody({ context }) {
45178
- const handleCheck = (0, import_react34.useCallback)((key, checked) => {
45179
- context.setDefaultData((prev) => __spreadProps(__spreadValues({}, prev), {
45180
- [key]: __spreadProps(__spreadValues({}, prev[key]), { _checkedItem: checked })
45181
- }));
45182
- }, []);
45183
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("tbody", { className: "bg-white", children: context.paginatedBody.map((key) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
45184
- Row,
45185
- {
45186
- rowKey: key,
45187
- context,
45188
- handleCheck
45189
- },
45190
- key
45191
- )) });
45192
- }
45193
-
45194
- // src/table2/v.table.head.filter.tsx
45195
- var import_react35 = require("react");
45196
- var import_jsx_runtime30 = require("react/jsx-runtime");
45197
- function TH({
45198
- context,
45199
- h
45200
- }) {
45201
- var _a;
45202
- if (!context) return null;
45203
- if (`${h}`.startsWith("_")) return;
45204
- const [search, setSearch] = (0, import_react35.useState)("");
45205
- const [visible, setVisible] = (0, import_react35.useState)(false);
45206
- const list = context.list[h];
45207
- const [prev, setPrev] = (0, import_react35.useState)(context.filters[h]);
45208
- const filteredList = (0, import_react35.useMemo)(() => {
45209
- return list.filter((item) => {
45210
- if (!search) return true;
45211
- return item == null ? void 0 : item.toString().toLowerCase().includes(search.toLowerCase());
45212
- });
45213
- }, [list, search]);
45214
- const colSize = ((_a = context == null ? void 0 : context.colSizes) == null ? void 0 : _a[h]) || 100;
45215
- const hasFilter = (0, import_react35.useMemo)(
45216
- () => !Object.values(context.filters[h]).every((p) => p === true),
45217
- [context.filters[h]]
45218
- );
45219
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("th", { className: "p-1 relative", style: { zIndex: 9 }, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: " min-w-[" + colSize + "px] resize-x overflow-auto", children: [
45220
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "flex justify-between gap-2 text-white p-1 shadow rounded text-center w-full font-bold text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
44921
+ const hidden = Object.values(objectData).filter((d) => d._visible === false).map((d) => d[h]);
44922
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("th", { className: "cursor-pointer", children: [
44923
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "relative", children: visible && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45221
44924
  "div",
45222
44925
  {
45223
- onClick: (e) => setVisible(!visible),
45224
- className: "w-full text-center flex gap-2 justify-center cursor-pointer",
45225
- children: [
45226
- h,
45227
- " ",
45228
- hasFilter && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "text-red-500 ", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FilterIcon, {}) })
45229
- ]
44926
+ className: " w-full h-screen top-0 left-0 fixed",
44927
+ style: { zIndex: 9998 },
44928
+ onClick: (e) => setVisible(!visible)
45230
44929
  }
45231
44930
  ) }),
45232
- visible && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
45233
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
44931
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "relative w-full justify-center flex", children: [
44932
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
45234
44933
  "div",
45235
44934
  {
45236
- className: "fixed top-0 left-0 w-screen h-screen ",
45237
- style: { zIndex: 10 },
45238
- onClick: (e) => setVisible(!visible)
44935
+ style: {
44936
+ minWidth: "100px",
44937
+ maxWidth: `${((colSizes == null ? void 0 : colSizes[h]) || 0) + 100}px`,
44938
+ width: `${colSizes == null ? void 0 : colSizes[h]}px`
44939
+ },
44940
+ className: `resize-x overflow-auto text-center flex justify-evenly p-1 items-center`,
44941
+ onClick: (e) => setVisible(!visible),
44942
+ children: [
44943
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: h }),
44944
+ selected.length < items.length && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "text-red-500 ", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FilterOffIcon, {}) })
44945
+ ]
45239
44946
  }
45240
44947
  ),
45241
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
44948
+ visible && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45242
44949
  "div",
45243
44950
  {
45244
- className: "absolute border shadow rounded w-[300px] flex flex-col gap-2 bg-white p-2 text-sm resize-x overflow-auto",
45245
- style: { zIndex: 11 },
45246
- children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
45247
- "form",
45248
- {
45249
- onSubmit: (e) => {
45250
- e.preventDefault();
45251
- setSearch("");
45252
- setVisible(false);
45253
- context.setPage(1);
45254
- const p = __spreadValues({}, Object.keys(prev).reduce((acc, i) => {
45255
- if (search != "") {
45256
- acc[i] = i.toString().toLowerCase().includes(search.toLowerCase()) ? prev[i] : false;
45257
- } else {
45258
- acc[i] = prev[i];
44951
+ className: "border shadow rounded bg-white p-1 absolute fixed text-black",
44952
+ style: { zIndex: 9999 },
44953
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col gap-1 w-[300px] min-w-[300px] resize-x overflow-auto", children: [
44954
+ selected.length < items.length && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
44955
+ "div",
44956
+ {
44957
+ className: "p-1 flex items-center justify-between px-2 bg-red-200 border shadow rounded",
44958
+ onClick: (e) => {
44959
+ filtrar(items);
44960
+ },
44961
+ children: [
44962
+ "Borrar Filtro",
44963
+ " ",
44964
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "text-white ", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FilterOffIcon, {}) })
44965
+ ]
44966
+ }
44967
+ ),
44968
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
44969
+ "input",
44970
+ {
44971
+ className: "border shadow rounded p-2 w-full",
44972
+ type: "search",
44973
+ onChange: (e) => setText(`${e.target.value}`),
44974
+ value: text,
44975
+ onKeyDown: (e) => {
44976
+ if (e.key === "Enter") {
44977
+ setSelected(
44978
+ items.filter(
44979
+ (i) => `${i}`.toLowerCase().includes(`${text}`.toLowerCase())
44980
+ )
44981
+ );
44982
+ filtrar();
45259
44983
  }
45260
- return acc;
45261
- }, {}));
45262
- setPrev(p);
45263
- context.setFilters((nf) => {
45264
- return __spreadProps(__spreadValues({}, nf), { [h]: p });
45265
- });
45266
- },
45267
- children: [
45268
- hasFilter && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
45269
- "button",
45270
- {
45271
- type: "button",
45272
- className: "border p-2 flex justify-center gap-2 w-full items-center text-red-500",
45273
- onClick: (e) => {
45274
- const p = __spreadValues({}, Object.keys(context.filters[h]).reduce((acc, i) => {
45275
- acc[i] = true;
45276
- return acc;
45277
- }, {}));
45278
- setPrev(p);
45279
- context.setFilters((nf) => {
45280
- return __spreadProps(__spreadValues({}, nf), { [h]: p });
45281
- });
45282
- setVisible(false);
45283
- },
45284
- children: [
45285
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FilterIcon, {}),
45286
- " Quitar Filtro"
45287
- ]
44984
+ }
44985
+ }
44986
+ ) }),
44987
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex gap-1 cursor-pointer px-1", children: [
44988
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
44989
+ "input",
44990
+ {
44991
+ type: "checkbox",
44992
+ checked: !Boolean(selected.length < items.length),
44993
+ onChange: (e) => {
44994
+ if (selected.length < items.length) {
44995
+ setSelected(items);
44996
+ } else {
44997
+ setSelected([]);
44998
+ }
45288
44999
  }
45289
- ),
45290
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
45000
+ }
45001
+ ),
45002
+ "(Seleccionar Todo)"
45003
+ ] }) }),
45004
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "overflow-auto flex gap-1 flex-col p-1 border shadow rounded h-[300px]", children: itemsFiltered.map((item) => {
45005
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "hover:bg-gray-100 ", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex gap-1 cursor-pointer truncate", children: [
45006
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45291
45007
  "input",
45292
45008
  {
45293
- className: "border p-1 w-full p-2",
45294
- placeholder: "Buscar...",
45295
- type: "search",
45296
- onChange: (e) => setSearch(e.target.value),
45297
- value: search
45298
- }
45299
- ),
45300
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
45301
- "div",
45302
- {
45303
- className: "w-full h-[300px] p-2 ",
45304
- style: { overflowY: "auto" },
45305
- children: [
45306
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { className: "flex gap-2 truncate", children: [
45307
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
45308
- "input",
45309
- {
45310
- type: "checkbox",
45311
- checked: Object.keys(prev).filter((v) => {
45312
- return v.toString().toLowerCase().includes(search.toLowerCase());
45313
- }).every((v) => prev[v] === true),
45314
- onChange: (e) => {
45315
- setPrev((preveN) => {
45316
- return __spreadValues({}, Object.keys(preveN).reduce((acc, i) => {
45317
- if (search != "") {
45318
- acc[i] = i.toString().toLowerCase().includes(search.toLowerCase()) ? !preveN[i] : false;
45319
- } else {
45320
- acc[i] = e.target.checked;
45321
- }
45322
- return acc;
45323
- }, {}));
45324
- });
45325
- }
45326
- }
45327
- ),
45328
- "(Seleccionar Todo)"
45329
- ] }),
45330
- filteredList.map((item, i) => {
45331
- const checked = prev[item];
45332
- const visibles = Array.from(context.filters[h]);
45333
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { className: "flex gap-2 truncate", children: [
45334
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
45335
- "input",
45336
- {
45337
- type: "checkbox",
45338
- checked,
45339
- onChange: (e) => {
45340
- setPrev((preveN) => {
45341
- return __spreadProps(__spreadValues({}, preveN), { [item]: !checked });
45342
- });
45343
- }
45344
- }
45345
- ),
45346
- item != null ? item : "(Vacio)"
45347
- ] }, item + i);
45348
- })
45349
- ]
45009
+ type: "checkbox",
45010
+ disabled: hidden.includes(item) && items.includes(item),
45011
+ checked: selected.includes(item),
45012
+ onChange: (e) => {
45013
+ const newSelected = [...selected];
45014
+ const index = newSelected.indexOf(item);
45015
+ if (index >= 0) {
45016
+ newSelected.splice(index, 1);
45017
+ } else {
45018
+ newSelected.push(item);
45019
+ }
45020
+ setSelected(newSelected);
45021
+ }
45350
45022
  }
45351
45023
  ),
45352
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex justify-between py-2", children: [
45353
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
45354
- "button",
45355
- {
45356
- type: "button",
45357
- className: "p-1 bg-red-500 text-white border shadow rounded",
45358
- onClick: (e) => setVisible(!visible),
45359
- children: "Cancelar"
45360
- }
45361
- ),
45362
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
45363
- "button",
45364
- {
45365
- type: "submit",
45366
- className: "p-1 bg-blue-500 text-white border shadow rounded",
45367
- children: "Aceptar"
45368
- }
45369
- )
45370
- ] })
45371
- ]
45372
- }
45373
- )
45024
+ item || "(Vacias)"
45025
+ ] }) }, item);
45026
+ }) }),
45027
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex justify-between px-1", children: [
45028
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45029
+ "button",
45030
+ {
45031
+ className: "p-1 shadow rounded border bg-red-500 text-white",
45032
+ onClick: (e) => {
45033
+ setText("");
45034
+ setVisible(false);
45035
+ },
45036
+ children: "Cancelar"
45037
+ }
45038
+ ),
45039
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
45040
+ "button",
45041
+ {
45042
+ className: "p-1 shadow rounded border bg-blue-500 text-white",
45043
+ onClick: (e) => {
45044
+ filtrar();
45045
+ },
45046
+ children: "Aceptar"
45047
+ }
45048
+ )
45049
+ ] })
45050
+ ] })
45374
45051
  }
45375
45052
  )
45376
45053
  ] })
45377
- ] }) });
45054
+ ] });
45378
45055
  }
45379
45056
 
45380
- // src/table2/v.table.head.tsx
45381
- var import_jsx_runtime31 = require("react/jsx-runtime");
45382
- function THead({ context }) {
45383
- return context && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("thead", { className: "bg-blue-400", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("tr", { className: "", children: [
45384
- context.selectItems && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("th", { className: "border-b", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "flex justify-between gap-2 text-white p-1 shadow rounded text-center w-full font-bold text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("label", { className: "w-full text-center flex items-center justify-center gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
45057
+ // src/table3/head.tsx
45058
+ var import_jsx_runtime29 = require("react/jsx-runtime");
45059
+ function TableHead({
45060
+ headers,
45061
+ selectItems,
45062
+ setObjectData,
45063
+ objectData,
45064
+ page,
45065
+ setPage,
45066
+ maxItems,
45067
+ colSizes,
45068
+ modal
45069
+ }) {
45070
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("tr", { className: "bg-blue-500 text-white font-bold", children: [
45071
+ modal && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("th", { children: "-" }),
45072
+ selectItems && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("th", { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
45385
45073
  "input",
45386
45074
  {
45075
+ className: "m-2",
45387
45076
  type: "checkbox",
45388
- className: "w-5 h-5 accent-green-500",
45389
- defaultChecked: false,
45077
+ checked: Object.values(objectData).every(
45078
+ (d) => d._selected === true
45079
+ ),
45390
45080
  onChange: (e) => {
45391
- const newData = Object.keys(context.defaultData).map(
45392
- (key) => {
45393
- const row = context.defaultData[key];
45394
- return __spreadProps(__spreadValues({}, row), {
45395
- _checkedItem: e.target.checked
45396
- });
45081
+ const newVal = Object.values(objectData).map((d) => {
45082
+ if (d == null ? void 0 : d._id) {
45083
+ return {
45084
+ _id: d._id,
45085
+ _selected: e.target.checked
45086
+ };
45087
+ } else {
45088
+ return {
45089
+ id: d.id,
45090
+ _selected: e.target.checked
45091
+ };
45397
45092
  }
45398
- );
45399
- context.setDefaultData(newData);
45093
+ });
45094
+ setObjectData(newVal);
45400
45095
  }
45401
45096
  }
45402
- ) }) }) }) }),
45403
- context.headers.map((h) => {
45404
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(TH, { h, context }, h);
45097
+ ) }),
45098
+ Object.values(headers).map((h) => {
45099
+ if (h.startsWith("_")) return null;
45100
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
45101
+ Filter,
45102
+ {
45103
+ objectData,
45104
+ h,
45105
+ setObjectData,
45106
+ setPage,
45107
+ colSizes
45108
+ },
45109
+ h
45110
+ );
45405
45111
  })
45406
45112
  ] }) });
45407
45113
  }
45408
45114
 
45409
- // src/table2/v.table.pagination.tsx
45115
+ // src/table3/body.tsx
45116
+ var import_react35 = require("react");
45117
+
45118
+ // src/table3/tr.tsx
45119
+ var import_react34 = __toESM(require("react"));
45120
+ var import_jsx_runtime30 = require("react/jsx-runtime");
45121
+ function TR({
45122
+ handlers,
45123
+ setObjectData,
45124
+ id: id3,
45125
+ row,
45126
+ headers,
45127
+ selectItems,
45128
+ colSizes,
45129
+ modal,
45130
+ modalRef,
45131
+ dialogRow,
45132
+ setDialogRow,
45133
+ index,
45134
+ selected,
45135
+ setSelected,
45136
+ onChange
45137
+ }) {
45138
+ const color2 = selected == index ? "bg-blue-600 text-white hover:bg-blue-800" : index % 2 == 0 ? "bg-white" : "bg-blue-50";
45139
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
45140
+ "tr",
45141
+ {
45142
+ className: ` hover:bg-blue-100 ${color2} cursor-pointer`,
45143
+ onClick: (e) => {
45144
+ setSelected(selected == index ? -1 : index);
45145
+ },
45146
+ children: [
45147
+ modal && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("th", { className: "border", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
45148
+ "button",
45149
+ {
45150
+ className: "p-1 border shadow-rounded bg-blue-500 rounded text-white",
45151
+ onClick: (e) => {
45152
+ var _a;
45153
+ (_a = modalRef.current) == null ? void 0 : _a.showModal();
45154
+ setDialogRow(row);
45155
+ },
45156
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EditIcon, {})
45157
+ }
45158
+ ) }),
45159
+ selectItems && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("th", { className: "border", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
45160
+ "input",
45161
+ {
45162
+ type: "checkbox",
45163
+ checked: Boolean(row == null ? void 0 : row._selected),
45164
+ onChange: (e) => {
45165
+ if (row == null ? void 0 : row._id) {
45166
+ setObjectData({ _id: +id3, _selected: e.target.checked });
45167
+ } else {
45168
+ setObjectData({ id: +id3, _selected: e.target.checked });
45169
+ }
45170
+ }
45171
+ }
45172
+ ) }),
45173
+ headers.map((h) => {
45174
+ var _a, _b, _c, _d;
45175
+ const colSize = colSizes == null ? void 0 : colSizes[h];
45176
+ if (h.startsWith("_")) {
45177
+ return null;
45178
+ } else if (handlers == null ? void 0 : handlers[h]) {
45179
+ const original = handlers[h];
45180
+ const cloned = import_react34.default.cloneElement(original, __spreadValues({
45181
+ // si es controlado por value → actualiza con row[h]
45182
+ value: ((_a = original.props) == null ? void 0 : _a.value) !== void 0 ? row[h] : void 0,
45183
+ // si usa children → actualiza con row[h] también
45184
+ children: ((_b = original.props) == null ? void 0 : _b.children) ? typeof original.props.children == "object" ? (_c = original.props) == null ? void 0 : _c.children : row == null ? void 0 : row[h] : null
45185
+ }, Object.keys(__spreadProps(__spreadValues({}, original.props), {
45186
+ onChange: (_d = original.props) == null ? void 0 : _d.onChange
45187
+ })).filter((action) => action.startsWith("on")).reduce((acc, action) => {
45188
+ acc[action] = (e) => {
45189
+ var _a2, _b2;
45190
+ e.row = row;
45191
+ const userResponse = ((_b2 = (_a2 = original.props) == null ? void 0 : _a2[action]) == null ? void 0 : _b2.call(_a2, e)) || {};
45192
+ const newObject = (row == null ? void 0 : row._id) ? __spreadValues({
45193
+ _id: row == null ? void 0 : row._id,
45194
+ [h]: e.target.value,
45195
+ _updated: true,
45196
+ _visible: true
45197
+ }, userResponse) : __spreadValues({
45198
+ id: (row == null ? void 0 : row.id) || null,
45199
+ [h]: e.target.value,
45200
+ _updated: true,
45201
+ _visible: true
45202
+ }, userResponse);
45203
+ const finalResponse = action == "onChange" && onChange ? onChange(__spreadProps(__spreadValues({}, e), { row: __spreadValues(__spreadValues({}, e.row), newObject) })) : {};
45204
+ setObjectData(__spreadValues(__spreadValues({}, newObject), finalResponse));
45205
+ };
45206
+ return acc;
45207
+ }, {})));
45208
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("td", { className: `text-black `, children: cloned }, h);
45209
+ }
45210
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("td", { className: `text-center border max-w-[${colSize}px]`, children: row[h] }, h);
45211
+ })
45212
+ ]
45213
+ },
45214
+ id3
45215
+ );
45216
+ }
45217
+
45218
+ // src/table3/body.tsx
45219
+ var import_jsx_runtime31 = require("react/jsx-runtime");
45220
+ function TableBody({
45221
+ objectData,
45222
+ setObjectData,
45223
+ headers,
45224
+ handlers,
45225
+ selectItems,
45226
+ page,
45227
+ maxItems,
45228
+ colSizes,
45229
+ modal,
45230
+ modalRef,
45231
+ dialogRow,
45232
+ setDialogRow,
45233
+ onChange
45234
+ }) {
45235
+ const [selected, setSelected] = (0, import_react35.useState)(-1);
45236
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("tbody", { children: Object.keys(objectData).reverse().filter((id3) => {
45237
+ var _a;
45238
+ return ((_a = objectData[id3]) == null ? void 0 : _a._visible) === true;
45239
+ }).filter((_id, key) => {
45240
+ if (!maxItems) return true;
45241
+ const start = (page - 1) * maxItems;
45242
+ const end = page * maxItems;
45243
+ return key >= start && key < end;
45244
+ }).map((id3, index) => {
45245
+ const row = objectData[id3];
45246
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
45247
+ TR,
45248
+ __spreadValues({}, {
45249
+ headers,
45250
+ index,
45251
+ setObjectData,
45252
+ id: id3,
45253
+ row,
45254
+ handlers,
45255
+ selectItems,
45256
+ colSizes,
45257
+ modal,
45258
+ modalRef,
45259
+ dialogRow,
45260
+ setDialogRow,
45261
+ setSelected,
45262
+ selected,
45263
+ onChange
45264
+ }),
45265
+ id3
45266
+ );
45267
+ }) });
45268
+ }
45269
+
45270
+ // src/table3/panel.tsx
45410
45271
  var import_jsx_runtime32 = require("react/jsx-runtime");
45411
- function VtablePagination({
45412
- context
45272
+ function Panel({
45273
+ page,
45274
+ setPage,
45275
+ onSave,
45276
+ objectData,
45277
+ exportName,
45278
+ totalPages
45413
45279
  }) {
45414
- return context && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex justify-center p-2 bg-gray-100 ", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex gap-2", children: [
45415
- context.maxItems != Infinity && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
45416
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
45280
+ const excel = useExcel();
45281
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex gap-2 bg-gray-100 items-center", children: [
45282
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex gap-1 ", children: [
45283
+ onSave && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
45417
45284
  "button",
45418
45285
  {
45419
- onClick: () => context.setPage(1),
45420
- className: "border shadow rounded p-1 bg-gray-200 hover:bg-gray-300",
45421
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(MdOutlineFirstPage, {})
45286
+ className: "p-2 border shadow rounded bg-blue-500 text-white flex items-center gap-1 text-md",
45287
+ onClick: (e) => {
45288
+ onSave == null ? void 0 : onSave(Object.values(objectData).reverse());
45289
+ },
45290
+ children: [
45291
+ " ",
45292
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(SaveIcon, {}),
45293
+ "Guardar"
45294
+ ]
45422
45295
  }
45423
45296
  ),
45424
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
45297
+ exportName && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
45425
45298
  "button",
45426
45299
  {
45427
- className: "border shadow rounded p-1 bg-gray-200 hover:bg-gray-300",
45428
- onClick: () => context.setPage((page) => page > 1 ? page - 1 : page),
45429
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(GrFormPrevious, {})
45300
+ className: "p-2 border shadow rounded bg-green-800 text-white flex items-center gap-1 text-md",
45301
+ onClick: (e) => {
45302
+ excel.export(
45303
+ Object.values(objectData).reverse().map((d) => {
45304
+ const _a = d, { _visible, _id, _selected } = _a, data = __objRest(_a, ["_visible", "_id", "_selected"]);
45305
+ return data;
45306
+ }),
45307
+ exportName + ".xlsx"
45308
+ );
45309
+ },
45310
+ children: [
45311
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ExcelIcon, {}),
45312
+ "Exportar"
45313
+ ]
45430
45314
  }
45431
45315
  )
45432
45316
  ] }),
45433
- /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1 items-center justify-center text-xs font-bold bg-white border rounded py-1 px-10", children: [
45434
- /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { children: [
45317
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex gap-2 items-center text-2xl", children: [
45318
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { onClick: () => setPage(1), disabled: page === 1, children: "\u23EE" }),
45319
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { onClick: () => setPage(page - 1), disabled: page === 1, children: "\u25C0" }),
45320
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { className: "text-sm", children: [
45435
45321
  "P\xE1gina ",
45436
- context.page,
45437
- " de ",
45438
- context.totalPages
45322
+ page,
45323
+ " / ",
45324
+ totalPages
45439
45325
  ] }),
45440
- /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { children: [
45441
- "Mostrando ",
45442
- context.filteredBody.length,
45443
- " de",
45444
- " ",
45445
- Object.values(context.defaultData).length,
45446
- " Elementos"
45447
- ] })
45448
- ] }),
45449
- context.maxItems != Infinity && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
45450
45326
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
45451
45327
  "button",
45452
45328
  {
45453
- className: "border shadow rounded p-1 bg-gray-200 hover:bg-gray-300",
45454
- onClick: () => context.setPage(
45455
- (page) => page < context.totalPages ? page + 1 : page
45456
- ),
45457
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(GrFormNext, {})
45329
+ onClick: () => setPage(page + 1),
45330
+ disabled: page === totalPages,
45331
+ children: "\u25B6"
45458
45332
  }
45459
45333
  ),
45460
45334
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
45461
45335
  "button",
45462
45336
  {
45463
- className: "border shadow rounded p-1 bg-gray-200 hover:bg-gray-300",
45464
- onClick: () => context.setPage(context.totalPages),
45465
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(MdOutlineLastPage, {})
45337
+ onClick: () => setPage(totalPages),
45338
+ disabled: page === totalPages,
45339
+ children: "\u23ED"
45466
45340
  }
45467
45341
  )
45468
45342
  ] })
45469
- ] }) });
45343
+ ] });
45470
45344
  }
45471
45345
 
45472
- // src/table2/v.table.tsx
45346
+ // src/table3/footer.tsx
45473
45347
  var import_jsx_runtime33 = require("react/jsx-runtime");
45474
- function VTable2(_a) {
45475
- var _b = _a, {
45476
- context
45477
- } = _b, props = __objRest(_b, [
45478
- "context"
45479
- ]);
45480
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "border shadow rounded m-1 flex flex-col ", children: [
45481
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex gap-2 ", children: [
45482
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex justify-start gap-2 p-2 bg-gray-100 ", children: [
45483
- (context == null ? void 0 : context.onSave) && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
45484
- "button",
45485
- {
45486
- className: "p-1 bg-blue-700 text-white border shadow rounded flex gap-1 items-center",
45487
- onClick: (e) => {
45488
- var _a2;
45489
- return (_a2 = context == null ? void 0 : context.onSave) == null ? void 0 : _a2.call(context, Object.values(context.defaultData));
45490
- },
45491
- children: [
45492
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(IoIosSave, {}),
45493
- "Guardar"
45494
- ]
45495
- }
45496
- ),
45497
- context.exportName && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
45498
- "button",
45499
- {
45500
- className: "p-1 bg-green-700 text-white border shadow rounded flex gap-1 items-center",
45501
- onClick: () => {
45502
- const cleanedData = Object.values(context.defaultData).map(
45503
- (row) => {
45504
- const newRow = {};
45505
- for (const key in row) {
45506
- if (!key.startsWith("_")) {
45507
- newRow[key] = row[key];
45508
- }
45509
- }
45510
- return newRow;
45511
- }
45512
- );
45513
- context.excel.export(cleanedData, context.exportName + ".xlsx");
45514
- },
45515
- children: [
45516
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RiFileExcel2Fill, {}),
45517
- "Exportar"
45518
- ]
45519
- }
45520
- )
45521
- ] }),
45522
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(VtablePagination, { context })
45523
- ] }),
45524
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("table", __spreadProps(__spreadValues({}, props), { children: [
45525
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(THead, { context }),
45526
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(VTableBody, { context })
45527
- ] }))
45528
- ] });
45348
+ function TableFooter({
45349
+ objectData,
45350
+ headers,
45351
+ footer,
45352
+ selectItems,
45353
+ modal
45354
+ }) {
45355
+ function operacion(tipo, header) {
45356
+ switch (tipo) {
45357
+ case "count":
45358
+ return Object.values(objectData).filter(
45359
+ (data) => data._visible === true
45360
+ ).length;
45361
+ case "sum":
45362
+ return Object.values(objectData).filter((data) => data._visible === true).reduce((acc, data) => acc + (data == null ? void 0 : data[header]), 0);
45363
+ case "avg":
45364
+ return Object.values(objectData).filter((data) => data._visible === true).reduce((acc, data) => acc + (data == null ? void 0 : data[header]), 0) / Object.values(objectData).filter(
45365
+ (data) => data._visible === true
45366
+ ).length;
45367
+ default:
45368
+ return null;
45369
+ }
45370
+ }
45371
+ return footer && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("tfoot", { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("tr", { className: "bg-blue-500 text-white", children: [
45372
+ selectItems && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("th", {}),
45373
+ modal && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("th", {}),
45374
+ headers.map((header) => {
45375
+ if (header.startsWith("_")) {
45376
+ return null;
45377
+ } else if (footer == null ? void 0 : footer[header]) {
45378
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("th", { children: operacion(footer[header], header) }, header);
45379
+ }
45380
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("th", {}, header);
45381
+ })
45382
+ ] }) });
45529
45383
  }
45530
45384
 
45531
- // src/table2/h.table.tsx
45385
+ // src/table3/dialog.tsx
45386
+ var import_react36 = __toESM(require("react"));
45532
45387
  var import_jsx_runtime34 = require("react/jsx-runtime");
45533
- function HTable2({ context }) {
45534
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, {});
45388
+ function Dialog({
45389
+ modalRef,
45390
+ children,
45391
+ dialogRow,
45392
+ setDialogRow,
45393
+ setObjectData
45394
+ }) {
45395
+ const show = () => {
45396
+ var _a;
45397
+ return (_a = modalRef.current) == null ? void 0 : _a.showModal();
45398
+ };
45399
+ const hide = () => {
45400
+ var _a;
45401
+ return (_a = modalRef.current) == null ? void 0 : _a.close();
45402
+ };
45403
+ const clonedModal = (0, import_react36.useMemo)(() => {
45404
+ if (dialogRow && import_react36.default.isValidElement(children)) {
45405
+ return import_react36.default.cloneElement(children, {
45406
+ key: JSON.stringify(dialogRow),
45407
+ row: dialogRow,
45408
+ show,
45409
+ hide,
45410
+ update: setObjectData
45411
+ });
45412
+ }
45413
+ return null;
45414
+ }, [dialogRow, children]);
45415
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
45416
+ "dialog",
45417
+ {
45418
+ ref: modalRef,
45419
+ className: "p-6 rounded-xl shadow-2xl backdrop:bg-black/50 w-[100%] h-screen",
45420
+ children: [
45421
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex justify-between items-center mb-4", children: [
45422
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {}),
45423
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
45424
+ "button",
45425
+ {
45426
+ onClick: () => {
45427
+ var _a;
45428
+ return (_a = modalRef.current) == null ? void 0 : _a.close();
45429
+ },
45430
+ className: "text-white hover:text-gray-100 text-xl border shadow rounded p-1 bg-red-500",
45431
+ children: "\u2715"
45432
+ }
45433
+ )
45434
+ ] }),
45435
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "text-gray-700", children: clonedModal })
45436
+ ]
45437
+ }
45438
+ );
45535
45439
  }
45440
+ var dialog_default = Dialog;
45536
45441
 
45537
- // src/table2/index.tsx
45442
+ // src/table3/index.tsx
45538
45443
  var import_jsx_runtime35 = require("react/jsx-runtime");
45539
- function TableDos(_a) {
45444
+ function Table3(_a) {
45540
45445
  var _b = _a, {
45541
45446
  data,
45542
- maxItems = Infinity,
45543
- symbols = {},
45544
- handlers = {},
45447
+ selectItems,
45448
+ maxItems,
45545
45449
  onSave,
45546
45450
  exportName,
45547
- selectItems,
45548
- colSizes
45451
+ colSizes,
45452
+ modal,
45453
+ header,
45454
+ footer,
45455
+ onChange
45549
45456
  } = _b, props = __objRest(_b, [
45550
45457
  "data",
45458
+ "selectItems",
45551
45459
  "maxItems",
45552
- "symbols",
45553
- "handlers",
45554
45460
  "onSave",
45555
45461
  "exportName",
45556
- "selectItems",
45557
- "colSizes"
45462
+ "colSizes",
45463
+ "modal",
45464
+ "header",
45465
+ "footer",
45466
+ "onChange"
45558
45467
  ]);
45559
- if (data.length == 0) return null;
45560
- const [myData, setMyData] = (0, import_react36.useState)(data);
45561
- const isArray = Array.isArray(data);
45562
- const context = useTableContext({
45563
- data: myData,
45564
- maxItems,
45565
- symbols,
45468
+ const [handlers, setHandlers] = (0, import_react37.useState)({});
45469
+ const [page, setPage] = (0, import_react37.useState)(1);
45470
+ function dataReducer(a, b) {
45471
+ if (b == null) return {};
45472
+ if (Array.isArray(b)) {
45473
+ const obj = b.reduce((acc, bb) => {
45474
+ var _a2, _b2, _c, _d, _e, _f, _g;
45475
+ const id3 = (bb == null ? void 0 : bb.id) || (bb == null ? void 0 : bb._id);
45476
+ if (!id3) throw new Error("Se necesita el id o _id");
45477
+ const cc = ((_a2 = a == null ? void 0 : a[id3]) == null ? void 0 : _a2._updated) ? __spreadProps(__spreadValues(__spreadValues({}, bb), a == null ? void 0 : a[id3]), {
45478
+ _selected: bb == null ? void 0 : bb._selected,
45479
+ _visible: (bb == null ? void 0 : bb._visible) == false ? false : true
45480
+ }) : __spreadProps(__spreadValues({}, bb), {
45481
+ _selected: bb == null ? void 0 : bb._selected,
45482
+ _visible: (bb == null ? void 0 : bb._visible) == false ? false : true
45483
+ });
45484
+ const newHandlers = __spreadValues({}, handlers);
45485
+ for (let item in cc) {
45486
+ const isReactComponent = import_react37.default.isValidElement(cc[item]);
45487
+ if (isReactComponent) {
45488
+ newHandlers[item] = cc[item];
45489
+ const value = ((_c = (_b2 = cc[item]) == null ? void 0 : _b2.props) == null ? void 0 : _c.value) || (typeof ((_e = (_d = cc[item]) == null ? void 0 : _d.props) == null ? void 0 : _e.children) !== "object" ? (_g = (_f = cc[item]) == null ? void 0 : _f.props) == null ? void 0 : _g.children : "");
45490
+ cc[item] = value || "";
45491
+ }
45492
+ }
45493
+ setHandlers(newHandlers);
45494
+ acc[id3] = __spreadValues(__spreadValues({}, bb), cc);
45495
+ return acc;
45496
+ }, {});
45497
+ return obj;
45498
+ } else {
45499
+ const newA = __spreadValues({}, a);
45500
+ const id3 = (b == null ? void 0 : b.id) || (b == null ? void 0 : b._id);
45501
+ if (!id3) throw new Error("Se necesita el id o _id para actualizar");
45502
+ newA[id3] = __spreadValues(__spreadValues({}, newA[id3]), b);
45503
+ return newA;
45504
+ }
45505
+ }
45506
+ const [objectData, setObjectData] = (0, import_react37.useReducer)(dataReducer, null);
45507
+ (0, import_react37.useEffect)(() => {
45508
+ setObjectData(data);
45509
+ setPage(1);
45510
+ }, [data]);
45511
+ const headers = (0, import_react37.useMemo)(() => {
45512
+ if (!objectData) return [];
45513
+ return [
45514
+ ...new Set(
45515
+ Object.values(objectData).map((o) => Object.keys(o)).flat()
45516
+ )
45517
+ ];
45518
+ }, [objectData]);
45519
+ const totalPages = (0, import_react37.useMemo)(() => {
45520
+ if (!objectData) return 0;
45521
+ return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
45522
+ }, [objectData, maxItems]);
45523
+ const modalRef = (0, import_react37.useRef)(null);
45524
+ const [dialogRow, setDialogRow] = (0, import_react37.useState)({});
45525
+ const context = __spreadValues({
45526
+ objectData,
45527
+ headers,
45566
45528
  handlers,
45567
- onSave,
45529
+ setObjectData,
45530
+ page,
45531
+ setPage,
45532
+ totalPages,
45568
45533
  exportName,
45534
+ onSave,
45535
+ modalRef,
45536
+ modal,
45537
+ dialogRow,
45538
+ setDialogRow,
45569
45539
  selectItems,
45570
- colSizes
45571
- });
45572
- (0, import_react36.useEffect)(() => {
45573
- setMyData(data);
45574
- }, [data]);
45575
- if (!context) return null;
45576
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: isArray ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(VTable2, __spreadValues({ context }, props)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(HTable2, { context }) });
45577
- }
45578
-
45579
- // src/use-modal/index.tsx
45580
- var import_react37 = require("react");
45581
- var import_react_dom = require("react-dom");
45582
- var import_jsx_runtime36 = require("react/jsx-runtime");
45583
- function useModal() {
45584
- const modalRef = (0, import_react37.useRef)(null);
45585
- const [mounted, setMounted] = (0, import_react37.useState)(false);
45586
- (0, import_react37.useEffect)(() => setMounted(true), []);
45587
- const show = () => {
45588
- requestAnimationFrame(() => {
45589
- const dlg = modalRef.current;
45590
- if (!dlg) return;
45591
- if (typeof dlg.showModal === "function") {
45592
- try {
45593
- if (!dlg.open) dlg.showModal();
45594
- } catch (e) {
45595
- dlg.setAttribute("open", "");
45596
- }
45597
- } else {
45598
- dlg.setAttribute("open", "");
45540
+ maxItems,
45541
+ colSizes,
45542
+ header,
45543
+ footer,
45544
+ onChange
45545
+ }, props);
45546
+ (0, import_react37.useEffect)(() => {
45547
+ if ((dialogRow == null ? void 0 : dialogRow.id) || (dialogRow == null ? void 0 : dialogRow._id)) {
45548
+ const newDialogRow = objectData[dialogRow == null ? void 0 : dialogRow.id] || objectData[dialogRow == null ? void 0 : dialogRow._id];
45549
+ setDialogRow(newDialogRow);
45550
+ }
45551
+ }, [objectData]);
45552
+ const style = (props == null ? void 0 : props.style) ? __spreadProps(__spreadValues({}, props.style), { tableLayout: "fixed" }) : { tableLayout: "fixed" };
45553
+ if (!objectData) return null;
45554
+ console.log({ objectData });
45555
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "border shadow rounded m-1 p-1 bg-white", children: [
45556
+ modal && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
45557
+ dialog_default,
45558
+ {
45559
+ modalRef,
45560
+ dialogRow,
45561
+ setDialogRow,
45562
+ setObjectData,
45563
+ children: modal
45599
45564
  }
45600
- });
45601
- };
45602
- const hide = () => {
45603
- const dlg = modalRef.current;
45604
- if (!dlg) return;
45605
- if (typeof dlg.close === "function") dlg.close();
45606
- else dlg.removeAttribute("open");
45607
- };
45608
- const Modal2 = (_a) => {
45609
- var _b = _a, {
45610
- className,
45611
- children,
45612
- title
45613
- } = _b, props = __objRest(_b, [
45614
- "className",
45615
- "children",
45616
- "title"
45617
- ]);
45618
- if (!mounted) return null;
45619
- const dialog = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
45620
- "dialog",
45621
- __spreadProps(__spreadValues({
45622
- ref: modalRef,
45623
- className: (className != null ? className : "") + " p-6 rounded-2xl shadow-2xl bg-white max-w-lg w-[90%]"
45624
- }, props), {
45625
- children: [
45626
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex justify-between items-center border-b pb-2 mb-4", children: [
45627
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h2", { className: "text-lg font-semibold text-gray-800", children: title }),
45628
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
45629
- "button",
45630
- {
45631
- onClick: hide,
45632
- className: "text-gray-500 hover:text-gray-800 text-2xl font-bold",
45633
- children: "\xD7"
45634
- }
45635
- )
45636
- ] }),
45637
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "mt-2 text-gray-800", children })
45638
- ]
45639
- })
45640
- );
45641
- return (0, import_react_dom.createPortal)(dialog, document.body);
45642
- };
45643
- return { show, hide, Modal: Modal2 };
45565
+ ),
45566
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "font-bold text-2xl py-5 px-2 bg-blue-50", children: header }),
45567
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Panel, __spreadValues({}, context)),
45568
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("table", __spreadProps(__spreadValues({}, props), { style, children: [
45569
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TableHead, __spreadValues({}, context)),
45570
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TableBody, __spreadValues({}, context)),
45571
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TableFooter, __spreadValues({}, context))
45572
+ ] }))
45573
+ ] });
45644
45574
  }
45645
45575
  // Annotate the CommonJS export names for ESM import in node:
45646
45576
  0 && (module.exports = {
@@ -45655,13 +45585,12 @@ function useModal() {
45655
45585
  Pre,
45656
45586
  Select,
45657
45587
  Table,
45658
- TableDos,
45588
+ Table3,
45659
45589
  TextArea,
45660
45590
  regularExpresions,
45661
45591
  useDates,
45662
45592
  useExcel,
45663
45593
  useFormValues,
45664
- useModal,
45665
45594
  useResources
45666
45595
  });
45667
45596
  /*! Bundled license information: