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.mjs CHANGED
@@ -10900,7 +10900,7 @@ function Container({
10900
10900
  /* @__PURE__ */ jsx5(
10901
10901
  "div",
10902
10902
  {
10903
- className: ` gap-2 bg-blue-400 text-white ${isSidebarOpen ? "px-[270px]" : "px-[60px]"} hidden sm:flex`,
10903
+ className: ` gap-2 bg-gray-800 text-white ${isSidebarOpen ? "px-[270px]" : "px-[60px]"} hidden sm:flex`,
10904
10904
  children: navItems && /* @__PURE__ */ jsx5(Fragment3, { children: [{ location: "/", name: "Home", icon: /* @__PURE__ */ jsx5(HomeIcon, {}) }, navItems].flat().map((li, k) => {
10905
10905
  return li && /* @__PURE__ */ jsxs3(
10906
10906
  import_link.default,
@@ -10925,7 +10925,7 @@ function Container({
10925
10925
  animate: {
10926
10926
  width: typeof window !== "undefined" && window.innerWidth < 768 ? isSidebarOpen ? "100%" : 0 : isSidebarOpen ? 250 : 60
10927
10927
  },
10928
- 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",
10928
+ 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",
10929
10929
  children: /* @__PURE__ */ jsx5("div", { className: "p-4 ", children: menuList && /* @__PURE__ */ jsxs3("ul", { className: "space-y-3", children: [
10930
10930
  /* @__PURE__ */ jsx5(
10931
10931
  "li",
@@ -10951,14 +10951,7 @@ function Container({
10951
10951
  icon,
10952
10952
  /* @__PURE__ */ jsx5("div", { className: " truncate", children: itemMenu == null ? void 0 : itemMenu.name })
10953
10953
  ] }),
10954
- !isSidebarOpen && /* @__PURE__ */ jsx5(
10955
- "div",
10956
- {
10957
- title: `${itemMenu.name}`,
10958
- className: "text-sm hover:bg-gray-200 hover:text-black rounded p-1",
10959
- children: icon
10960
- }
10961
- )
10954
+ !isSidebarOpen && /* @__PURE__ */ jsx5("div", { className: "text-sm hover:bg-gray-200 hover:text-black rounded p-1", children: icon })
10962
10955
  ]
10963
10956
  }
10964
10957
  ) }, k);
@@ -11227,30 +11220,20 @@ function TD(_a) {
11227
11220
  },
11228
11221
  __spreadValues({}, (_b2 = symbols[item == null ? void 0 : item.name]) == null ? void 0 : _b2.props)
11229
11222
  ));
11230
- const typeOf = (value) => {
11231
- if (value instanceof Date) return "date";
11232
- if (typeof value === "number") return "number";
11233
- if (typeof value === "string") {
11234
- const d = new Date(value);
11235
- if (!isNaN(d.getTime())) return "date-string";
11236
- return "string";
11237
- }
11238
- return typeof value;
11239
- };
11240
- const result = typeOf(item == null ? void 0 : item.content);
11241
11223
  return /* @__PURE__ */ jsx8(
11242
11224
  "td",
11243
- __spreadProps(__spreadValues({}, props), {
11225
+ {
11244
11226
  onDoubleClick: (e) => setIsHidded(!isHidded),
11245
11227
  className: [
11246
11228
  isHidded && color2,
11247
- !isHidded && "whitespace-nowrap overflow-hidden text-ellipsis ",
11248
- " px-2 "
11229
+ !isHidded && "whitespace-nowrap overflow-hidden text-ellipsis ",
11230
+ "border-b max-w-[200px] p-2 "
11231
+ // ["number", "money"].includes(item?.cellTypeOf) && "text-right",
11249
11232
  ].join(" "),
11250
11233
  children: /* @__PURE__ */ jsx8(
11251
11234
  "div",
11252
11235
  {
11253
- 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"),
11236
+ className: symbols && symbols[item == null ? void 0 : item.name] && "flex justify-between ",
11254
11237
  children: symbols ? /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-1", children: [
11255
11238
  /* @__PURE__ */ jsx8("div", { children: React3.Children.map(symbols[item == null ? void 0 : item.name], (child) => {
11256
11239
  if (React3.isValidElement(child)) {
@@ -11260,10 +11243,10 @@ function TD(_a) {
11260
11243
  return child;
11261
11244
  }) }),
11262
11245
  /* @__PURE__ */ jsx8("div", { children: !(newProps == null ? void 0 : newProps["row"]) && (item == null ? void 0 : item.content) })
11263
- ] }) : /* @__PURE__ */ jsx8("div", { className: "", children: item == null ? void 0 : item.content })
11246
+ ] }) : /* @__PURE__ */ jsx8("div", { children: item == null ? void 0 : item.content })
11264
11247
  }
11265
11248
  )
11266
- })
11249
+ }
11267
11250
  );
11268
11251
  }
11269
11252
 
@@ -11284,6 +11267,21 @@ function FilterOffIcon() {
11284
11267
  }
11285
11268
  );
11286
11269
  }
11270
+ function EditIcon() {
11271
+ return /* @__PURE__ */ jsx9(
11272
+ "svg",
11273
+ {
11274
+ stroke: "currentColor",
11275
+ fill: "currentColor",
11276
+ strokeWidth: "0",
11277
+ viewBox: "0 0 576 512",
11278
+ height: "20px",
11279
+ width: "20px",
11280
+ xmlns: "http://www.w3.org/2000/svg",
11281
+ children: /* @__PURE__ */ jsx9("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" })
11282
+ }
11283
+ );
11284
+ }
11287
11285
  function MdLastPage() {
11288
11286
  return /* @__PURE__ */ jsxs7(
11289
11287
  "svg",
@@ -43423,16 +43421,7 @@ function HTable(_a) {
43423
43421
  const regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
43424
43422
  const isDate = !isObject2 && regex.test(`${d[key]}`);
43425
43423
  const cellTypeOf = isDate ? "date" : isObject2 ? "object" : typeOf;
43426
- const mapedIndex = mapedData.find(
43427
- (mpd) => {
43428
- var _a3, _b3;
43429
- return `${d.id}`.includes(
43430
- (_a3 = mpd == null ? void 0 : mpd.id) == null ? void 0 : _a3.content,
43431
- (_b3 = mpd == null ? void 0 : mpd._id) == null ? void 0 : _b3.content
43432
- );
43433
- }
43434
- );
43435
- const mapedContent = (_b2 = mapedIndex == null ? void 0 : mapedIndex[key]) == null ? void 0 : _b2.content;
43424
+ const mapedContent = (_b2 = mapedData[trkey][key]) == null ? void 0 : _b2.content;
43436
43425
  const content = mapedContent || (cellTypeOf == "date" ? d[key].split("T").join(" ").split(".")[0] : cellTypeOf == "object" ? React4.isValidElement(d[key]) ? ((_c = d[key]) == null ? void 0 : _c.props).value : JSON.stringify(d[key]) : d[key]);
43437
43426
  const handler = React4.isValidElement(d[key]) ? d[key] : null;
43438
43427
  obj[key] = {
@@ -43495,12 +43484,12 @@ function HTable(_a) {
43495
43484
  ) })
43496
43485
  ] }),
43497
43486
  /* @__PURE__ */ jsxs10("table", __spreadProps(__spreadValues({}, props), { className: "w-full border-collapse table-auto", children: [
43498
- /* @__PURE__ */ jsx12("thead", { className: "bg-blue-400 text-white", children: /* @__PURE__ */ jsx12("tr", { children: head.map((h, key) => {
43487
+ /* @__PURE__ */ jsx12("thead", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ jsx12("tr", { children: head.map((h, key) => {
43499
43488
  var _a2;
43500
- return h != "_id" && /* @__PURE__ */ jsxs10(
43489
+ return /* @__PURE__ */ jsxs10(
43501
43490
  "th",
43502
43491
  {
43503
- className: "whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px] border-b ",
43492
+ className: "whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px] border-b p-2",
43504
43493
  children: [
43505
43494
  /* @__PURE__ */ jsx12(
43506
43495
  "div",
@@ -43509,7 +43498,7 @@ function HTable(_a) {
43509
43498
  onClick: (e) => {
43510
43499
  setSelectedFilter(key == selectedFilter ? null : key);
43511
43500
  },
43512
- children: /* @__PURE__ */ jsxs10("div", { className: "text-white w-full rounded flex justify-center", children: [
43501
+ children: /* @__PURE__ */ jsxs10("div", { className: "text-white w-full bg-black rounded flex justify-center", children: [
43513
43502
  h,
43514
43503
  " ",
43515
43504
  !((_a2 = mapedData == null ? void 0 : mapedData.map((d) => {
@@ -43536,7 +43525,7 @@ function HTable(_a) {
43536
43525
  );
43537
43526
  }) }) }),
43538
43527
  /* @__PURE__ */ jsx12("tbody", { className: "divide-y divide-gray-200", children: mapedData.map((md, trKey) => {
43539
- var _a2, _b2, _c;
43528
+ var _a2, _b2;
43540
43529
  const start = (page - 1) * maxItems;
43541
43530
  const end = page * maxItems;
43542
43531
  if (!hasFilters) {
@@ -43548,7 +43537,7 @@ function HTable(_a) {
43548
43537
  return null;
43549
43538
  }
43550
43539
  }
43551
- 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;
43540
+ const dataKey = ((_b2 = md == null ? void 0 : md.id) == null ? void 0 : _b2.content) || trKey;
43552
43541
  return /* @__PURE__ */ jsx12(
43553
43542
  "tr",
43554
43543
  {
@@ -43559,18 +43548,17 @@ function HTable(_a) {
43559
43548
  "data-key": dataKey,
43560
43549
  onClick: (e) => setSelected(trKey),
43561
43550
  className: [
43562
- "hover:bg-blue-100 ",
43551
+ "hover:bg-green-100 ",
43563
43552
  color2,
43564
- selected == trKey && " bg-blue-200 hover:bg-blue-300"
43553
+ selected == trKey && "bg-green-200 hover:bg-green-300"
43565
43554
  ].join(" "),
43566
43555
  children: head.map((h, tdKey) => {
43567
- var _a3, _b3;
43556
+ var _a3;
43568
43557
  const item = md[h];
43569
- 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;
43570
- return h != "_id" && /* @__PURE__ */ jsx12(
43558
+ const id3 = trKey + "-" + (((_a3 = md == null ? void 0 : md.id) == null ? void 0 : _a3.content) || tdKey) + "-" + h;
43559
+ return /* @__PURE__ */ jsx12(
43571
43560
  TD,
43572
43561
  {
43573
- "data-key": id3,
43574
43562
  index: trKey,
43575
43563
  symbols,
43576
43564
  item,
@@ -43585,11 +43573,18 @@ function HTable(_a) {
43585
43573
  dataKey
43586
43574
  );
43587
43575
  }) }),
43588
- totals && /* @__PURE__ */ jsx12("tfoot", { className: "bg-blue-400 text-white", children: /* @__PURE__ */ jsx12("tr", { children: head.map((h, fkey) => {
43589
- return /* @__PURE__ */ jsx12("th", { className: "text-right border-b max-w-[200px] ", children: totals.includes(h) && /* @__PURE__ */ jsxs10("div", { className: "flex justify-between text-white w-full rounded ", children: [
43590
- /* @__PURE__ */ jsx12("div", { className: "p-1", children: symbols && symbols[h] && symbols[h] }),
43591
- /* @__PURE__ */ jsx12("div", { className: "p-1", children: mapedTotals[h] })
43592
- ] }) }, fkey);
43576
+ totals && /* @__PURE__ */ jsx12("tfoot", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ jsx12("tr", { children: head.map((h, fkey) => {
43577
+ return /* @__PURE__ */ jsx12(
43578
+ "th",
43579
+ {
43580
+ className: "text-right border-b max-w-[200px] p-2 ",
43581
+ children: totals.includes(h) && /* @__PURE__ */ jsxs10("div", { className: "flex justify-between text-white w-full bg-black rounded ", children: [
43582
+ /* @__PURE__ */ jsx12("div", { className: "p-1", children: symbols && symbols[h] && symbols[h] }),
43583
+ /* @__PURE__ */ jsx12("div", { className: "p-1", children: mapedTotals[h] })
43584
+ ] })
43585
+ },
43586
+ fkey
43587
+ );
43593
43588
  }) }) })
43594
43589
  ] })),
43595
43590
  isLoading && /* @__PURE__ */ jsx12("div", { className: "fixed top-0 left-0 w-full h-screen flex items-center justify-center bg-white bg-opacity-50", children: /* @__PURE__ */ jsx12("div", { children: loader }) })
@@ -44860,784 +44855,719 @@ function DocumentViewer({ item }) {
44860
44855
  ] });
44861
44856
  }
44862
44857
 
44863
- // src/table2/index.tsx
44864
- import {
44858
+ // src/table3/index.tsx
44859
+ import React11, {
44865
44860
  useEffect as useEffect11,
44861
+ useMemo as useMemo12,
44862
+ useReducer as useReducer2,
44863
+ useRef as useRef8,
44866
44864
  useState as useState14
44867
44865
  } from "react";
44868
44866
 
44869
- // src/table2/context.tsx
44870
- import { useEffect as useEffect10, useMemo as useMemo10, useState as useState12 } from "react";
44871
- function useTableContext({
44872
- data,
44873
- maxItems,
44874
- symbols,
44875
- handlers,
44876
- onSave,
44877
- exportName,
44878
- selectItems,
44867
+ // src/table3/filter.tsx
44868
+ import { useMemo as useMemo10, useState as useState12 } from "react";
44869
+ import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
44870
+ function Filter({
44871
+ h,
44872
+ objectData,
44873
+ setObjectData,
44874
+ setPage,
44879
44875
  colSizes
44880
44876
  }) {
44881
- function dataReduce(datums) {
44882
- return datums.map((row) => {
44883
- for (let key in row) {
44884
- if (typeof row[key] === "object") {
44885
- row[key] = JSON.stringify(row[key]);
44886
- }
44887
- }
44888
- return row;
44889
- }).reduce((acc, d) => {
44890
- const id3 = (d == null ? void 0 : d._id) || (d == null ? void 0 : d.id);
44891
- if (!id3) throw new Error("Data must have an '_id' or 'id' field");
44892
- acc[id3] = d;
44893
- acc[id3]._checkedItem = false;
44894
- return acc;
44895
- }, {});
44896
- }
44897
- const excel = useExcel();
44898
- const [defaultData, setDefaultData] = useState12(dataReduce(data));
44899
- const [page, setPage] = useState12(1);
44900
- const headers = useMemo10(() => {
44901
- return [...new Set(data.flatMap((d) => Object.keys(d)))];
44902
- }, [data]);
44903
- const list = useMemo10(() => {
44904
- return headers.reduce((acc, h) => {
44905
- acc[h] = [
44906
- ...new Set(
44907
- Object.values(defaultData).map((row) => {
44908
- const value = typeof row[h] === "object" ? JSON.stringify(row[h]) : row[h];
44909
- return value;
44910
- })
44911
- )
44912
- ];
44913
- return acc;
44914
- }, {});
44915
- }, [headers, defaultData]);
44916
- const [filters, setFilters] = useState12(
44917
- headers.reduce((acc, h) => {
44918
- acc[h] = list[h].reduce((ac, l) => {
44919
- ac[l] = true;
44920
- return ac;
44921
- }, {});
44922
- return acc;
44923
- }, {})
44924
- );
44925
- const bodyKeys = useMemo10(() => Object.keys(defaultData), [defaultData]);
44926
- const body = useMemo10(() => defaultData, [defaultData]);
44927
- const filteredBody = useMemo10(() => {
44928
- return bodyKeys.filter((key) => {
44929
- return headers.every((header) => {
44930
- var _a, _b;
44931
- 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;
44932
- });
44933
- });
44934
- }, [filters, headers, defaultData]);
44935
- const paginatedBody = useMemo10(() => {
44936
- return filteredBody.filter((k, index) => {
44937
- if (maxItems === Infinity) return true;
44938
- const desde = (page - 1) * maxItems;
44939
- const hasta = desde + maxItems;
44940
- return index >= desde && index < hasta;
44941
- });
44942
- }, [filteredBody, page]);
44943
- const totalPages = useMemo10(
44944
- () => maxItems === Infinity ? 1 : Math.ceil(filteredBody.length / maxItems),
44945
- [filteredBody, maxItems]
44946
- );
44947
- useEffect10(() => {
44948
- const original = dataReduce(data);
44949
- const originalKeys = Object.keys(original);
44950
- setDefaultData((prevDefaultData) => {
44951
- var _a;
44952
- const newDefault = {};
44953
- for (let key of originalKeys) {
44954
- newDefault[key] = (_a = prevDefaultData == null ? void 0 : prevDefaultData[key]) != null ? _a : original[key];
44955
- }
44956
- return newDefault;
44957
- });
44958
- }, [data]);
44959
- return {
44960
- page,
44961
- setPage,
44962
- defaultData,
44963
- setDefaultData,
44964
- totalPages,
44965
- headers,
44966
- filters,
44967
- setFilters,
44968
- list,
44969
- filteredBody,
44970
- maxItems,
44971
- paginatedBody,
44972
- handlers,
44973
- symbols,
44974
- onSave,
44975
- exportName,
44976
- excel,
44977
- selectItems,
44978
- colSizes
44979
- };
44980
- }
44981
-
44982
- // src/table2/icons.tsx
44983
- import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
44984
- function FilterIcon() {
44985
- return /* @__PURE__ */ jsx27(
44986
- "svg",
44987
- {
44988
- stroke: "currentColor",
44989
- fill: "currentColor",
44990
- strokeWidth: "0",
44991
- viewBox: "0 0 576 512",
44992
- height: "1rem",
44993
- width: "1rem",
44994
- xmlns: "http://www.w3.org/2000/svg",
44995
- children: /* @__PURE__ */ jsx27("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" })
44996
- }
44997
- );
44998
- }
44999
- function MdOutlineFirstPage() {
45000
- return /* @__PURE__ */ jsxs18(
45001
- "svg",
45002
- {
45003
- stroke: "currentColor",
45004
- fill: "currentColor",
45005
- strokeWidth: "0",
45006
- viewBox: "0 0 24 24",
45007
- height: "1rem",
45008
- width: "1rem",
45009
- xmlns: "http://www.w3.org/2000/svg",
45010
- children: [
45011
- /* @__PURE__ */ jsx27("path", { fill: "none", d: "M24 0v24H0V0h24z", opacity: ".87" }),
45012
- /* @__PURE__ */ jsx27("path", { d: "M18.41 16.59 13.82 12l4.59-4.59L17 6l-6 6 6 6 1.41-1.41zM6 6h2v12H6V6z" })
45013
- ]
45014
- }
45015
- );
45016
- }
45017
- function MdOutlineLastPage() {
45018
- return /* @__PURE__ */ jsxs18(
45019
- "svg",
45020
- {
45021
- stroke: "currentColor",
45022
- fill: "currentColor",
45023
- strokeWidth: "0",
45024
- viewBox: "0 0 24 24",
45025
- height: "1rem",
45026
- width: "1rem",
45027
- xmlns: "http://www.w3.org/2000/svg",
45028
- children: [
45029
- /* @__PURE__ */ jsx27("path", { fill: "none", d: "M0 0h24v24H0V0z", opacity: ".87" }),
45030
- /* @__PURE__ */ jsx27("path", { d: "M5.59 7.41 10.18 12l-4.59 4.59L7 18l6-6-6-6-1.41 1.41zM16 6h2v12h-2V6z" })
45031
- ]
45032
- }
45033
- );
45034
- }
45035
- function GrFormNext() {
45036
- return /* @__PURE__ */ jsx27(
45037
- "svg",
45038
- {
45039
- stroke: "currentColor",
45040
- fill: "currentColor",
45041
- strokeWidth: "0",
45042
- viewBox: "0 0 24 24",
45043
- height: "1rem",
45044
- width: "1rem",
45045
- xmlns: "http://www.w3.org/2000/svg",
45046
- children: /* @__PURE__ */ jsx27("polyline", { fill: "none", strokeWidth: "2", points: "9 6 15 12 9 18" })
45047
- }
45048
- );
45049
- }
45050
- function GrFormPrevious() {
45051
- return /* @__PURE__ */ jsx27(
45052
- "svg",
45053
- {
45054
- stroke: "currentColor",
45055
- fill: "currentColor",
45056
- strokeWidth: "0",
45057
- viewBox: "0 0 24 24",
45058
- height: "1rem",
45059
- width: "1rem",
45060
- xmlns: "http://www.w3.org/2000/svg",
45061
- children: /* @__PURE__ */ jsx27(
45062
- "polyline",
45063
- {
45064
- fill: "none",
45065
- strokeWidth: "2",
45066
- points: "9 6 15 12 9 18",
45067
- transform: "matrix(-1 0 0 1 24 0)"
45068
- }
45069
- )
45070
- }
44877
+ const [visible, setVisible] = useState12(false);
44878
+ const [text, setText] = useState12("");
44879
+ const items = useMemo10(
44880
+ () => [...new Set(Object.values(objectData).map((o) => o[h]))],
44881
+ [objectData]
45071
44882
  );
45072
- }
45073
- function RiFileExcel2Fill() {
45074
- return /* @__PURE__ */ jsx27(
45075
- "svg",
45076
- {
45077
- stroke: "currentColor",
45078
- fill: "currentColor",
45079
- strokeWidth: "0",
45080
- viewBox: "0 0 24 24",
45081
- height: "1rem",
45082
- width: "1rem",
45083
- xmlns: "http://www.w3.org/2000/svg",
45084
- children: /* @__PURE__ */ jsx27("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" })
45085
- }
44883
+ const [selected, setSelected] = useState12(items);
44884
+ const itemsFiltered = useMemo10(
44885
+ () => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
44886
+ if (!text) return true;
44887
+ return `${item}`.toLowerCase().includes(text.toLowerCase());
44888
+ }),
44889
+ [items, text]
45086
44890
  );
45087
- }
45088
- function IoIosSave() {
45089
- return /* @__PURE__ */ jsxs18(
45090
- "svg",
45091
- {
45092
- stroke: "currentColor",
45093
- fill: "currentColor",
45094
- strokeWidth: "0",
45095
- viewBox: "0 0 512 512",
45096
- height: "1rem",
45097
- width: "1rem",
45098
- xmlns: "http://www.w3.org/2000/svg",
45099
- children: [
45100
- /* @__PURE__ */ jsx27("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" }),
45101
- /* @__PURE__ */ jsx27("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" })
45102
- ]
44891
+ function filtrar(itemsInterno = []) {
44892
+ const array = Object.values(objectData);
44893
+ let obj;
44894
+ if (itemsInterno.length > 0) {
44895
+ setSelected(items);
44896
+ obj = array.map((row) => {
44897
+ return (row == null ? void 0 : row._id) ? {
44898
+ _id: row._id,
44899
+ _visible: itemsInterno.includes(row[h])
44900
+ } : { id: row.id, _visible: itemsInterno.includes(row[h]) };
44901
+ });
44902
+ } else {
44903
+ obj = array.map((row) => {
44904
+ return (row == null ? void 0 : row._id) ? {
44905
+ _id: row._id,
44906
+ _visible: itemsFiltered.length < items.length ? itemsFiltered.includes(row[h]) : selected.includes(row[h])
44907
+ } : {
44908
+ id: row.id,
44909
+ _visible: itemsFiltered.length < items.length ? itemsFiltered.includes(row[h]) : selected.includes(row[h])
44910
+ };
44911
+ });
45103
44912
  }
45104
- );
45105
- }
45106
-
45107
- // src/table2/v.table.body.tsx
45108
- import React9, { useCallback as useCallback3 } from "react";
45109
- import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
45110
- var Row = React9.memo(
45111
- ({ rowKey, context, handleCheck }) => {
45112
- const rowData = context.defaultData[rowKey];
45113
- return /* @__PURE__ */ jsxs19("tr", { className: "hover:bg-gray-200", children: [
45114
- context.selectItems && /* @__PURE__ */ jsx28("th", { className: "border-b", children: /* @__PURE__ */ jsx28(
45115
- "input",
45116
- {
45117
- type: "checkbox",
45118
- className: "w-5 h-5 accent-green-500",
45119
- checked: !!(rowData == null ? void 0 : rowData._checkedItem),
45120
- onChange: (e) => handleCheck(rowKey, e.target.checked)
45121
- }
45122
- ) }),
45123
- context.headers.map((header, index) => {
45124
- var _a, _b, _c, _d;
45125
- if (header.startsWith("_")) return null;
45126
- const value = rowData[header];
45127
- if ((_a = context.handlers) == null ? void 0 : _a[header]) {
45128
- return /* @__PURE__ */ jsx28("td", { className: "p-1 w-[100px]", children: React9.isValidElement(context.handlers[header]) && React9.cloneElement(context.handlers[header], {
45129
- value,
45130
- onChange: (e) => {
45131
- var _a2, _b2, _c2;
45132
- 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);
45133
- const newData = __spreadValues({}, context.defaultData);
45134
- for (let item in result) {
45135
- newData[rowKey][item] = result[item];
45136
- }
45137
- newData[rowKey][header] = e.target.value;
45138
- context.setDefaultData(newData);
45139
- }
45140
- }) }, index);
45141
- } else {
45142
- const updateRow = (data) => {
45143
- const newData = __spreadValues({}, context.defaultData);
45144
- for (let item in data) {
45145
- newData[rowKey][item] = data[item];
45146
- }
45147
- context.setDefaultData(newData);
45148
- };
45149
- return /* @__PURE__ */ jsx28("td", { className: "p-1 w-[100px] border-b", children: ((_b = context.symbols) == null ? void 0 : _b[header]) ? /* @__PURE__ */ jsxs19("div", { className: "flex justify-between w-full", children: [
45150
- /* @__PURE__ */ jsx28("div", { children: React9.isValidElement((_c = context.symbols) == null ? void 0 : _c[header]) && React9.cloneElement((_d = context.symbols) == null ? void 0 : _d[header], {
45151
- row: rowData,
45152
- updateRow,
45153
- onClick: (e) => {
45154
- var _a2, _b2, _c2, _d2;
45155
- e.row = rowData;
45156
- e.updateRow = updateRow;
45157
- (_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);
45158
- }
45159
- }) }),
45160
- /* @__PURE__ */ jsx28("div", { className: "w-full px-2 py-[3px] truncate", children: value })
45161
- ] }) : /* @__PURE__ */ jsx28("div", { className: "w-full px-2 py-[3px]", children: value }) }, index);
45162
- }
45163
- })
45164
- ] });
45165
- },
45166
- (prev, next) => {
45167
- return prev.context.defaultData[prev.rowKey] === next.context.defaultData[next.rowKey];
44913
+ setObjectData(obj);
44914
+ setPage(1);
44915
+ setVisible(false);
44916
+ setText("");
45168
44917
  }
45169
- );
45170
- function VTableBody({ context }) {
45171
- const handleCheck = useCallback3((key, checked) => {
45172
- context.setDefaultData((prev) => __spreadProps(__spreadValues({}, prev), {
45173
- [key]: __spreadProps(__spreadValues({}, prev[key]), { _checkedItem: checked })
45174
- }));
45175
- }, []);
45176
- return /* @__PURE__ */ jsx28("tbody", { className: "bg-white", children: context.paginatedBody.map((key) => /* @__PURE__ */ jsx28(
45177
- Row,
45178
- {
45179
- rowKey: key,
45180
- context,
45181
- handleCheck
45182
- },
45183
- key
45184
- )) });
45185
- }
45186
-
45187
- // src/table2/v.table.head.filter.tsx
45188
- import { useMemo as useMemo12, useState as useState13 } from "react";
45189
- import { Fragment as Fragment7, jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
45190
- function TH({
45191
- context,
45192
- h
45193
- }) {
45194
- var _a;
45195
- if (!context) return null;
45196
- if (`${h}`.startsWith("_")) return;
45197
- const [search, setSearch] = useState13("");
45198
- const [visible, setVisible] = useState13(false);
45199
- const list = context.list[h];
45200
- const [prev, setPrev] = useState13(context.filters[h]);
45201
- const filteredList = useMemo12(() => {
45202
- return list.filter((item) => {
45203
- if (!search) return true;
45204
- return item == null ? void 0 : item.toString().toLowerCase().includes(search.toLowerCase());
45205
- });
45206
- }, [list, search]);
45207
- const colSize = ((_a = context == null ? void 0 : context.colSizes) == null ? void 0 : _a[h]) || 100;
45208
- const hasFilter = useMemo12(
45209
- () => !Object.values(context.filters[h]).every((p) => p === true),
45210
- [context.filters[h]]
45211
- );
45212
- return /* @__PURE__ */ jsx29("th", { className: "p-1 relative", style: { zIndex: 9 }, children: /* @__PURE__ */ jsxs20("div", { className: " min-w-[" + colSize + "px] resize-x overflow-auto", children: [
45213
- /* @__PURE__ */ jsx29("div", { className: "flex justify-between gap-2 text-white p-1 shadow rounded text-center w-full font-bold text-xs", children: /* @__PURE__ */ jsxs20(
44918
+ const hidden = Object.values(objectData).filter((d) => d._visible === false).map((d) => d[h]);
44919
+ return /* @__PURE__ */ jsxs18("th", { className: "cursor-pointer", children: [
44920
+ /* @__PURE__ */ jsx27("div", { className: "relative", children: visible && /* @__PURE__ */ jsx27(
45214
44921
  "div",
45215
44922
  {
45216
- onClick: (e) => setVisible(!visible),
45217
- className: "w-full text-center flex gap-2 justify-center cursor-pointer",
45218
- children: [
45219
- h,
45220
- " ",
45221
- hasFilter && /* @__PURE__ */ jsx29("div", { className: "text-red-500 ", children: /* @__PURE__ */ jsx29(FilterIcon, {}) })
45222
- ]
44923
+ className: " w-full h-screen top-0 left-0 fixed",
44924
+ style: { zIndex: 9998 },
44925
+ onClick: (e) => setVisible(!visible)
45223
44926
  }
45224
44927
  ) }),
45225
- visible && /* @__PURE__ */ jsxs20(Fragment7, { children: [
45226
- /* @__PURE__ */ jsx29(
44928
+ /* @__PURE__ */ jsxs18("div", { className: "relative w-full justify-center flex", children: [
44929
+ /* @__PURE__ */ jsxs18(
45227
44930
  "div",
45228
44931
  {
45229
- className: "fixed top-0 left-0 w-screen h-screen ",
45230
- style: { zIndex: 10 },
45231
- onClick: (e) => setVisible(!visible)
44932
+ style: {
44933
+ minWidth: "100px",
44934
+ maxWidth: `${((colSizes == null ? void 0 : colSizes[h]) || 0) + 100}px`,
44935
+ width: `${colSizes == null ? void 0 : colSizes[h]}px`
44936
+ },
44937
+ className: `resize-x overflow-auto text-center flex justify-evenly p-1 items-center`,
44938
+ onClick: (e) => setVisible(!visible),
44939
+ children: [
44940
+ /* @__PURE__ */ jsx27("div", { children: h }),
44941
+ selected.length < items.length && /* @__PURE__ */ jsx27("div", { className: "text-red-500 ", children: /* @__PURE__ */ jsx27(FilterOffIcon, {}) })
44942
+ ]
45232
44943
  }
45233
44944
  ),
45234
- /* @__PURE__ */ jsx29(
44945
+ visible && /* @__PURE__ */ jsx27(
45235
44946
  "div",
45236
44947
  {
45237
- className: "absolute border shadow rounded w-[300px] flex flex-col gap-2 bg-white p-2 text-sm resize-x overflow-auto",
45238
- style: { zIndex: 11 },
45239
- children: /* @__PURE__ */ jsxs20(
45240
- "form",
45241
- {
45242
- onSubmit: (e) => {
45243
- e.preventDefault();
45244
- setSearch("");
45245
- setVisible(false);
45246
- context.setPage(1);
45247
- const p = __spreadValues({}, Object.keys(prev).reduce((acc, i) => {
45248
- if (search != "") {
45249
- acc[i] = i.toString().toLowerCase().includes(search.toLowerCase()) ? prev[i] : false;
45250
- } else {
45251
- acc[i] = prev[i];
44948
+ className: "border shadow rounded bg-white p-1 absolute fixed text-black",
44949
+ style: { zIndex: 9999 },
44950
+ children: /* @__PURE__ */ jsxs18("div", { className: "flex flex-col gap-1 w-[300px] min-w-[300px] resize-x overflow-auto", children: [
44951
+ selected.length < items.length && /* @__PURE__ */ jsxs18(
44952
+ "div",
44953
+ {
44954
+ className: "p-1 flex items-center justify-between px-2 bg-red-200 border shadow rounded",
44955
+ onClick: (e) => {
44956
+ filtrar(items);
44957
+ },
44958
+ children: [
44959
+ "Borrar Filtro",
44960
+ " ",
44961
+ /* @__PURE__ */ jsx27("div", { className: "text-white ", children: /* @__PURE__ */ jsx27(FilterOffIcon, {}) })
44962
+ ]
44963
+ }
44964
+ ),
44965
+ /* @__PURE__ */ jsx27("div", { className: "", children: /* @__PURE__ */ jsx27(
44966
+ "input",
44967
+ {
44968
+ className: "border shadow rounded p-2 w-full",
44969
+ type: "search",
44970
+ onChange: (e) => setText(`${e.target.value}`),
44971
+ value: text,
44972
+ onKeyDown: (e) => {
44973
+ if (e.key === "Enter") {
44974
+ setSelected(
44975
+ items.filter(
44976
+ (i) => `${i}`.toLowerCase().includes(`${text}`.toLowerCase())
44977
+ )
44978
+ );
44979
+ filtrar();
45252
44980
  }
45253
- return acc;
45254
- }, {}));
45255
- setPrev(p);
45256
- context.setFilters((nf) => {
45257
- return __spreadProps(__spreadValues({}, nf), { [h]: p });
45258
- });
45259
- },
45260
- children: [
45261
- hasFilter && /* @__PURE__ */ jsxs20(
45262
- "button",
45263
- {
45264
- type: "button",
45265
- className: "border p-2 flex justify-center gap-2 w-full items-center text-red-500",
45266
- onClick: (e) => {
45267
- const p = __spreadValues({}, Object.keys(context.filters[h]).reduce((acc, i) => {
45268
- acc[i] = true;
45269
- return acc;
45270
- }, {}));
45271
- setPrev(p);
45272
- context.setFilters((nf) => {
45273
- return __spreadProps(__spreadValues({}, nf), { [h]: p });
45274
- });
45275
- setVisible(false);
45276
- },
45277
- children: [
45278
- /* @__PURE__ */ jsx29(FilterIcon, {}),
45279
- " Quitar Filtro"
45280
- ]
44981
+ }
44982
+ }
44983
+ ) }),
44984
+ /* @__PURE__ */ jsx27("div", { children: /* @__PURE__ */ jsxs18("label", { className: "flex gap-1 cursor-pointer px-1", children: [
44985
+ /* @__PURE__ */ jsx27(
44986
+ "input",
44987
+ {
44988
+ type: "checkbox",
44989
+ checked: !Boolean(selected.length < items.length),
44990
+ onChange: (e) => {
44991
+ if (selected.length < items.length) {
44992
+ setSelected(items);
44993
+ } else {
44994
+ setSelected([]);
44995
+ }
45281
44996
  }
45282
- ),
45283
- /* @__PURE__ */ jsx29(
44997
+ }
44998
+ ),
44999
+ "(Seleccionar Todo)"
45000
+ ] }) }),
45001
+ /* @__PURE__ */ jsx27("div", { className: "overflow-auto flex gap-1 flex-col p-1 border shadow rounded h-[300px]", children: itemsFiltered.map((item) => {
45002
+ return /* @__PURE__ */ jsx27("div", { className: "hover:bg-gray-100 ", children: /* @__PURE__ */ jsxs18("label", { className: "flex gap-1 cursor-pointer truncate", children: [
45003
+ /* @__PURE__ */ jsx27(
45284
45004
  "input",
45285
45005
  {
45286
- className: "border p-1 w-full p-2",
45287
- placeholder: "Buscar...",
45288
- type: "search",
45289
- onChange: (e) => setSearch(e.target.value),
45290
- value: search
45291
- }
45292
- ),
45293
- /* @__PURE__ */ jsxs20(
45294
- "div",
45295
- {
45296
- className: "w-full h-[300px] p-2 ",
45297
- style: { overflowY: "auto" },
45298
- children: [
45299
- /* @__PURE__ */ jsxs20("label", { className: "flex gap-2 truncate", children: [
45300
- /* @__PURE__ */ jsx29(
45301
- "input",
45302
- {
45303
- type: "checkbox",
45304
- checked: Object.keys(prev).filter((v) => {
45305
- return v.toString().toLowerCase().includes(search.toLowerCase());
45306
- }).every((v) => prev[v] === true),
45307
- onChange: (e) => {
45308
- setPrev((preveN) => {
45309
- return __spreadValues({}, Object.keys(preveN).reduce((acc, i) => {
45310
- if (search != "") {
45311
- acc[i] = i.toString().toLowerCase().includes(search.toLowerCase()) ? !preveN[i] : false;
45312
- } else {
45313
- acc[i] = e.target.checked;
45314
- }
45315
- return acc;
45316
- }, {}));
45317
- });
45318
- }
45319
- }
45320
- ),
45321
- "(Seleccionar Todo)"
45322
- ] }),
45323
- filteredList.map((item, i) => {
45324
- const checked = prev[item];
45325
- const visibles = Array.from(context.filters[h]);
45326
- return /* @__PURE__ */ jsxs20("label", { className: "flex gap-2 truncate", children: [
45327
- /* @__PURE__ */ jsx29(
45328
- "input",
45329
- {
45330
- type: "checkbox",
45331
- checked,
45332
- onChange: (e) => {
45333
- setPrev((preveN) => {
45334
- return __spreadProps(__spreadValues({}, preveN), { [item]: !checked });
45335
- });
45336
- }
45337
- }
45338
- ),
45339
- item != null ? item : "(Vacio)"
45340
- ] }, item + i);
45341
- })
45342
- ]
45006
+ type: "checkbox",
45007
+ disabled: hidden.includes(item) && items.includes(item),
45008
+ checked: selected.includes(item),
45009
+ onChange: (e) => {
45010
+ const newSelected = [...selected];
45011
+ const index = newSelected.indexOf(item);
45012
+ if (index >= 0) {
45013
+ newSelected.splice(index, 1);
45014
+ } else {
45015
+ newSelected.push(item);
45016
+ }
45017
+ setSelected(newSelected);
45018
+ }
45343
45019
  }
45344
45020
  ),
45345
- /* @__PURE__ */ jsxs20("div", { className: "flex justify-between py-2", children: [
45346
- /* @__PURE__ */ jsx29(
45347
- "button",
45348
- {
45349
- type: "button",
45350
- className: "p-1 bg-red-500 text-white border shadow rounded",
45351
- onClick: (e) => setVisible(!visible),
45352
- children: "Cancelar"
45353
- }
45354
- ),
45355
- /* @__PURE__ */ jsx29(
45356
- "button",
45357
- {
45358
- type: "submit",
45359
- className: "p-1 bg-blue-500 text-white border shadow rounded",
45360
- children: "Aceptar"
45361
- }
45362
- )
45363
- ] })
45364
- ]
45365
- }
45366
- )
45021
+ item || "(Vacias)"
45022
+ ] }) }, item);
45023
+ }) }),
45024
+ /* @__PURE__ */ jsxs18("div", { className: "flex justify-between px-1", children: [
45025
+ /* @__PURE__ */ jsx27(
45026
+ "button",
45027
+ {
45028
+ className: "p-1 shadow rounded border bg-red-500 text-white",
45029
+ onClick: (e) => {
45030
+ setText("");
45031
+ setVisible(false);
45032
+ },
45033
+ children: "Cancelar"
45034
+ }
45035
+ ),
45036
+ /* @__PURE__ */ jsx27(
45037
+ "button",
45038
+ {
45039
+ className: "p-1 shadow rounded border bg-blue-500 text-white",
45040
+ onClick: (e) => {
45041
+ filtrar();
45042
+ },
45043
+ children: "Aceptar"
45044
+ }
45045
+ )
45046
+ ] })
45047
+ ] })
45367
45048
  }
45368
45049
  )
45369
45050
  ] })
45370
- ] }) });
45051
+ ] });
45371
45052
  }
45372
45053
 
45373
- // src/table2/v.table.head.tsx
45374
- import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
45375
- function THead({ context }) {
45376
- return context && /* @__PURE__ */ jsx30("thead", { className: "bg-blue-400", children: /* @__PURE__ */ jsxs21("tr", { className: "", children: [
45377
- context.selectItems && /* @__PURE__ */ jsx30("th", { className: "border-b", children: /* @__PURE__ */ jsx30("div", { className: "", children: /* @__PURE__ */ jsx30("div", { className: "flex justify-between gap-2 text-white p-1 shadow rounded text-center w-full font-bold text-xs", children: /* @__PURE__ */ jsx30("label", { className: "w-full text-center flex items-center justify-center gap-1", children: /* @__PURE__ */ jsx30(
45054
+ // src/table3/head.tsx
45055
+ import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
45056
+ function TableHead({
45057
+ headers,
45058
+ selectItems,
45059
+ setObjectData,
45060
+ objectData,
45061
+ page,
45062
+ setPage,
45063
+ maxItems,
45064
+ colSizes,
45065
+ modal
45066
+ }) {
45067
+ return /* @__PURE__ */ jsx28("thead", { children: /* @__PURE__ */ jsxs19("tr", { className: "bg-blue-500 text-white font-bold", children: [
45068
+ modal && /* @__PURE__ */ jsx28("th", { children: "-" }),
45069
+ selectItems && /* @__PURE__ */ jsx28("th", { children: /* @__PURE__ */ jsx28(
45378
45070
  "input",
45379
45071
  {
45072
+ className: "m-2",
45380
45073
  type: "checkbox",
45381
- className: "w-5 h-5 accent-green-500",
45382
- defaultChecked: false,
45074
+ checked: Object.values(objectData).every(
45075
+ (d) => d._selected === true
45076
+ ),
45383
45077
  onChange: (e) => {
45384
- const newData = Object.keys(context.defaultData).map(
45385
- (key) => {
45386
- const row = context.defaultData[key];
45387
- return __spreadProps(__spreadValues({}, row), {
45388
- _checkedItem: e.target.checked
45389
- });
45078
+ const newVal = Object.values(objectData).map((d) => {
45079
+ if (d == null ? void 0 : d._id) {
45080
+ return {
45081
+ _id: d._id,
45082
+ _selected: e.target.checked
45083
+ };
45084
+ } else {
45085
+ return {
45086
+ id: d.id,
45087
+ _selected: e.target.checked
45088
+ };
45390
45089
  }
45391
- );
45392
- context.setDefaultData(newData);
45090
+ });
45091
+ setObjectData(newVal);
45393
45092
  }
45394
45093
  }
45395
- ) }) }) }) }),
45396
- context.headers.map((h) => {
45397
- return /* @__PURE__ */ jsx30(TH, { h, context }, h);
45094
+ ) }),
45095
+ Object.values(headers).map((h) => {
45096
+ if (h.startsWith("_")) return null;
45097
+ return /* @__PURE__ */ jsx28(
45098
+ Filter,
45099
+ {
45100
+ objectData,
45101
+ h,
45102
+ setObjectData,
45103
+ setPage,
45104
+ colSizes
45105
+ },
45106
+ h
45107
+ );
45398
45108
  })
45399
45109
  ] }) });
45400
45110
  }
45401
45111
 
45402
- // src/table2/v.table.pagination.tsx
45403
- import { Fragment as Fragment8, jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
45404
- function VtablePagination({
45405
- context
45112
+ // src/table3/body.tsx
45113
+ import { useState as useState13 } from "react";
45114
+
45115
+ // src/table3/tr.tsx
45116
+ import React9 from "react";
45117
+ import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
45118
+ function TR({
45119
+ handlers,
45120
+ setObjectData,
45121
+ id: id3,
45122
+ row,
45123
+ headers,
45124
+ selectItems,
45125
+ colSizes,
45126
+ modal,
45127
+ modalRef,
45128
+ dialogRow,
45129
+ setDialogRow,
45130
+ index,
45131
+ selected,
45132
+ setSelected,
45133
+ onChange
45406
45134
  }) {
45407
- return context && /* @__PURE__ */ jsx31("div", { className: "flex justify-center p-2 bg-gray-100 ", children: /* @__PURE__ */ jsxs22("div", { className: "flex gap-2", children: [
45408
- context.maxItems != Infinity && /* @__PURE__ */ jsxs22(Fragment8, { children: [
45409
- /* @__PURE__ */ jsx31(
45135
+ const color2 = selected == index ? "bg-blue-600 text-white hover:bg-blue-800" : index % 2 == 0 ? "bg-white" : "bg-blue-50";
45136
+ return /* @__PURE__ */ jsxs20(
45137
+ "tr",
45138
+ {
45139
+ className: ` hover:bg-blue-100 ${color2} cursor-pointer`,
45140
+ onClick: (e) => {
45141
+ setSelected(selected == index ? -1 : index);
45142
+ },
45143
+ children: [
45144
+ modal && /* @__PURE__ */ jsx29("th", { className: "border", children: /* @__PURE__ */ jsx29(
45145
+ "button",
45146
+ {
45147
+ className: "p-1 border shadow-rounded bg-blue-500 rounded text-white",
45148
+ onClick: (e) => {
45149
+ var _a;
45150
+ (_a = modalRef.current) == null ? void 0 : _a.showModal();
45151
+ setDialogRow(row);
45152
+ },
45153
+ children: /* @__PURE__ */ jsx29(EditIcon, {})
45154
+ }
45155
+ ) }),
45156
+ selectItems && /* @__PURE__ */ jsx29("th", { className: "border", children: /* @__PURE__ */ jsx29(
45157
+ "input",
45158
+ {
45159
+ type: "checkbox",
45160
+ checked: Boolean(row == null ? void 0 : row._selected),
45161
+ onChange: (e) => {
45162
+ if (row == null ? void 0 : row._id) {
45163
+ setObjectData({ _id: +id3, _selected: e.target.checked });
45164
+ } else {
45165
+ setObjectData({ id: +id3, _selected: e.target.checked });
45166
+ }
45167
+ }
45168
+ }
45169
+ ) }),
45170
+ headers.map((h) => {
45171
+ var _a, _b, _c, _d;
45172
+ const colSize = colSizes == null ? void 0 : colSizes[h];
45173
+ if (h.startsWith("_")) {
45174
+ return null;
45175
+ } else if (handlers == null ? void 0 : handlers[h]) {
45176
+ const original = handlers[h];
45177
+ const cloned = React9.cloneElement(original, __spreadValues({
45178
+ // si es controlado por value → actualiza con row[h]
45179
+ value: ((_a = original.props) == null ? void 0 : _a.value) !== void 0 ? row[h] : void 0,
45180
+ // si usa children → actualiza con row[h] también
45181
+ 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
45182
+ }, Object.keys(__spreadProps(__spreadValues({}, original.props), {
45183
+ onChange: (_d = original.props) == null ? void 0 : _d.onChange
45184
+ })).filter((action) => action.startsWith("on")).reduce((acc, action) => {
45185
+ acc[action] = (e) => {
45186
+ var _a2, _b2;
45187
+ e.row = row;
45188
+ const userResponse = ((_b2 = (_a2 = original.props) == null ? void 0 : _a2[action]) == null ? void 0 : _b2.call(_a2, e)) || {};
45189
+ const newObject = (row == null ? void 0 : row._id) ? __spreadValues({
45190
+ _id: row == null ? void 0 : row._id,
45191
+ [h]: e.target.value,
45192
+ _updated: true,
45193
+ _visible: true
45194
+ }, userResponse) : __spreadValues({
45195
+ id: (row == null ? void 0 : row.id) || null,
45196
+ [h]: e.target.value,
45197
+ _updated: true,
45198
+ _visible: true
45199
+ }, userResponse);
45200
+ const finalResponse = action == "onChange" && onChange ? onChange(__spreadProps(__spreadValues({}, e), { row: __spreadValues(__spreadValues({}, e.row), newObject) })) : {};
45201
+ setObjectData(__spreadValues(__spreadValues({}, newObject), finalResponse));
45202
+ };
45203
+ return acc;
45204
+ }, {})));
45205
+ return /* @__PURE__ */ jsx29("td", { className: `text-black `, children: cloned }, h);
45206
+ }
45207
+ return /* @__PURE__ */ jsx29("td", { className: `text-center border max-w-[${colSize}px]`, children: row[h] }, h);
45208
+ })
45209
+ ]
45210
+ },
45211
+ id3
45212
+ );
45213
+ }
45214
+
45215
+ // src/table3/body.tsx
45216
+ import { jsx as jsx30 } from "react/jsx-runtime";
45217
+ function TableBody({
45218
+ objectData,
45219
+ setObjectData,
45220
+ headers,
45221
+ handlers,
45222
+ selectItems,
45223
+ page,
45224
+ maxItems,
45225
+ colSizes,
45226
+ modal,
45227
+ modalRef,
45228
+ dialogRow,
45229
+ setDialogRow,
45230
+ onChange
45231
+ }) {
45232
+ const [selected, setSelected] = useState13(-1);
45233
+ return /* @__PURE__ */ jsx30("tbody", { children: Object.keys(objectData).reverse().filter((id3) => {
45234
+ var _a;
45235
+ return ((_a = objectData[id3]) == null ? void 0 : _a._visible) === true;
45236
+ }).filter((_id, key) => {
45237
+ if (!maxItems) return true;
45238
+ const start = (page - 1) * maxItems;
45239
+ const end = page * maxItems;
45240
+ return key >= start && key < end;
45241
+ }).map((id3, index) => {
45242
+ const row = objectData[id3];
45243
+ return /* @__PURE__ */ jsx30(
45244
+ TR,
45245
+ __spreadValues({}, {
45246
+ headers,
45247
+ index,
45248
+ setObjectData,
45249
+ id: id3,
45250
+ row,
45251
+ handlers,
45252
+ selectItems,
45253
+ colSizes,
45254
+ modal,
45255
+ modalRef,
45256
+ dialogRow,
45257
+ setDialogRow,
45258
+ setSelected,
45259
+ selected,
45260
+ onChange
45261
+ }),
45262
+ id3
45263
+ );
45264
+ }) });
45265
+ }
45266
+
45267
+ // src/table3/panel.tsx
45268
+ import { jsx as jsx31, jsxs as jsxs21 } from "react/jsx-runtime";
45269
+ function Panel({
45270
+ page,
45271
+ setPage,
45272
+ onSave,
45273
+ objectData,
45274
+ exportName,
45275
+ totalPages
45276
+ }) {
45277
+ const excel = useExcel();
45278
+ return /* @__PURE__ */ jsxs21("div", { className: "flex gap-2 bg-gray-100 items-center", children: [
45279
+ /* @__PURE__ */ jsxs21("div", { className: "flex gap-1 ", children: [
45280
+ onSave && /* @__PURE__ */ jsxs21(
45410
45281
  "button",
45411
45282
  {
45412
- onClick: () => context.setPage(1),
45413
- className: "border shadow rounded p-1 bg-gray-200 hover:bg-gray-300",
45414
- children: /* @__PURE__ */ jsx31(MdOutlineFirstPage, {})
45283
+ className: "p-2 border shadow rounded bg-blue-500 text-white flex items-center gap-1 text-md",
45284
+ onClick: (e) => {
45285
+ onSave == null ? void 0 : onSave(Object.values(objectData).reverse());
45286
+ },
45287
+ children: [
45288
+ " ",
45289
+ /* @__PURE__ */ jsx31(SaveIcon, {}),
45290
+ "Guardar"
45291
+ ]
45415
45292
  }
45416
45293
  ),
45417
- /* @__PURE__ */ jsx31(
45294
+ exportName && /* @__PURE__ */ jsxs21(
45418
45295
  "button",
45419
45296
  {
45420
- className: "border shadow rounded p-1 bg-gray-200 hover:bg-gray-300",
45421
- onClick: () => context.setPage((page) => page > 1 ? page - 1 : page),
45422
- children: /* @__PURE__ */ jsx31(GrFormPrevious, {})
45297
+ className: "p-2 border shadow rounded bg-green-800 text-white flex items-center gap-1 text-md",
45298
+ onClick: (e) => {
45299
+ excel.export(
45300
+ Object.values(objectData).reverse().map((d) => {
45301
+ const _a = d, { _visible, _id, _selected } = _a, data = __objRest(_a, ["_visible", "_id", "_selected"]);
45302
+ return data;
45303
+ }),
45304
+ exportName + ".xlsx"
45305
+ );
45306
+ },
45307
+ children: [
45308
+ /* @__PURE__ */ jsx31(ExcelIcon, {}),
45309
+ "Exportar"
45310
+ ]
45423
45311
  }
45424
45312
  )
45425
45313
  ] }),
45426
- /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-1 items-center justify-center text-xs font-bold bg-white border rounded py-1 px-10", children: [
45427
- /* @__PURE__ */ jsxs22("span", { children: [
45314
+ /* @__PURE__ */ jsxs21("div", { className: "flex gap-2 items-center text-2xl", children: [
45315
+ /* @__PURE__ */ jsx31("button", { onClick: () => setPage(1), disabled: page === 1, children: "\u23EE" }),
45316
+ /* @__PURE__ */ jsx31("button", { onClick: () => setPage(page - 1), disabled: page === 1, children: "\u25C0" }),
45317
+ /* @__PURE__ */ jsxs21("span", { className: "text-sm", children: [
45428
45318
  "P\xE1gina ",
45429
- context.page,
45430
- " de ",
45431
- context.totalPages
45319
+ page,
45320
+ " / ",
45321
+ totalPages
45432
45322
  ] }),
45433
- /* @__PURE__ */ jsxs22("span", { children: [
45434
- "Mostrando ",
45435
- context.filteredBody.length,
45436
- " de",
45437
- " ",
45438
- Object.values(context.defaultData).length,
45439
- " Elementos"
45440
- ] })
45441
- ] }),
45442
- context.maxItems != Infinity && /* @__PURE__ */ jsxs22(Fragment8, { children: [
45443
45323
  /* @__PURE__ */ jsx31(
45444
45324
  "button",
45445
45325
  {
45446
- className: "border shadow rounded p-1 bg-gray-200 hover:bg-gray-300",
45447
- onClick: () => context.setPage(
45448
- (page) => page < context.totalPages ? page + 1 : page
45449
- ),
45450
- children: /* @__PURE__ */ jsx31(GrFormNext, {})
45326
+ onClick: () => setPage(page + 1),
45327
+ disabled: page === totalPages,
45328
+ children: "\u25B6"
45451
45329
  }
45452
45330
  ),
45453
45331
  /* @__PURE__ */ jsx31(
45454
45332
  "button",
45455
45333
  {
45456
- className: "border shadow rounded p-1 bg-gray-200 hover:bg-gray-300",
45457
- onClick: () => context.setPage(context.totalPages),
45458
- children: /* @__PURE__ */ jsx31(MdOutlineLastPage, {})
45334
+ onClick: () => setPage(totalPages),
45335
+ disabled: page === totalPages,
45336
+ children: "\u23ED"
45459
45337
  }
45460
45338
  )
45461
45339
  ] })
45462
- ] }) });
45340
+ ] });
45463
45341
  }
45464
45342
 
45465
- // src/table2/v.table.tsx
45466
- import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
45467
- function VTable2(_a) {
45468
- var _b = _a, {
45469
- context
45470
- } = _b, props = __objRest(_b, [
45471
- "context"
45472
- ]);
45473
- return /* @__PURE__ */ jsxs23("div", { className: "border shadow rounded m-1 flex flex-col ", children: [
45474
- /* @__PURE__ */ jsxs23("div", { className: "flex gap-2 ", children: [
45475
- /* @__PURE__ */ jsxs23("div", { className: "flex justify-start gap-2 p-2 bg-gray-100 ", children: [
45476
- (context == null ? void 0 : context.onSave) && /* @__PURE__ */ jsxs23(
45477
- "button",
45478
- {
45479
- className: "p-1 bg-blue-700 text-white border shadow rounded flex gap-1 items-center",
45480
- onClick: (e) => {
45481
- var _a2;
45482
- return (_a2 = context == null ? void 0 : context.onSave) == null ? void 0 : _a2.call(context, Object.values(context.defaultData));
45483
- },
45484
- children: [
45485
- /* @__PURE__ */ jsx32(IoIosSave, {}),
45486
- "Guardar"
45487
- ]
45488
- }
45489
- ),
45490
- context.exportName && /* @__PURE__ */ jsxs23(
45491
- "button",
45492
- {
45493
- className: "p-1 bg-green-700 text-white border shadow rounded flex gap-1 items-center",
45494
- onClick: () => {
45495
- const cleanedData = Object.values(context.defaultData).map(
45496
- (row) => {
45497
- const newRow = {};
45498
- for (const key in row) {
45499
- if (!key.startsWith("_")) {
45500
- newRow[key] = row[key];
45501
- }
45502
- }
45503
- return newRow;
45504
- }
45505
- );
45506
- context.excel.export(cleanedData, context.exportName + ".xlsx");
45507
- },
45508
- children: [
45509
- /* @__PURE__ */ jsx32(RiFileExcel2Fill, {}),
45510
- "Exportar"
45511
- ]
45512
- }
45513
- )
45514
- ] }),
45515
- /* @__PURE__ */ jsx32(VtablePagination, { context })
45516
- ] }),
45517
- /* @__PURE__ */ jsxs23("table", __spreadProps(__spreadValues({}, props), { children: [
45518
- /* @__PURE__ */ jsx32(THead, { context }),
45519
- /* @__PURE__ */ jsx32(VTableBody, { context })
45520
- ] }))
45521
- ] });
45343
+ // src/table3/footer.tsx
45344
+ import { jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
45345
+ function TableFooter({
45346
+ objectData,
45347
+ headers,
45348
+ footer,
45349
+ selectItems,
45350
+ modal
45351
+ }) {
45352
+ function operacion(tipo, header) {
45353
+ switch (tipo) {
45354
+ case "count":
45355
+ return Object.values(objectData).filter(
45356
+ (data) => data._visible === true
45357
+ ).length;
45358
+ case "sum":
45359
+ return Object.values(objectData).filter((data) => data._visible === true).reduce((acc, data) => acc + (data == null ? void 0 : data[header]), 0);
45360
+ case "avg":
45361
+ return Object.values(objectData).filter((data) => data._visible === true).reduce((acc, data) => acc + (data == null ? void 0 : data[header]), 0) / Object.values(objectData).filter(
45362
+ (data) => data._visible === true
45363
+ ).length;
45364
+ default:
45365
+ return null;
45366
+ }
45367
+ }
45368
+ return footer && /* @__PURE__ */ jsx32("tfoot", { children: /* @__PURE__ */ jsxs22("tr", { className: "bg-blue-500 text-white", children: [
45369
+ selectItems && /* @__PURE__ */ jsx32("th", {}),
45370
+ modal && /* @__PURE__ */ jsx32("th", {}),
45371
+ headers.map((header) => {
45372
+ if (header.startsWith("_")) {
45373
+ return null;
45374
+ } else if (footer == null ? void 0 : footer[header]) {
45375
+ return /* @__PURE__ */ jsx32("th", { children: operacion(footer[header], header) }, header);
45376
+ }
45377
+ return /* @__PURE__ */ jsx32("th", {}, header);
45378
+ })
45379
+ ] }) });
45522
45380
  }
45523
45381
 
45524
- // src/table2/h.table.tsx
45525
- import { Fragment as Fragment9, jsx as jsx33 } from "react/jsx-runtime";
45526
- function HTable2({ context }) {
45527
- return /* @__PURE__ */ jsx33(Fragment9, {});
45382
+ // src/table3/dialog.tsx
45383
+ import React10, { useMemo as useMemo11 } from "react";
45384
+ import { jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
45385
+ function Dialog({
45386
+ modalRef,
45387
+ children,
45388
+ dialogRow,
45389
+ setDialogRow,
45390
+ setObjectData
45391
+ }) {
45392
+ const show = () => {
45393
+ var _a;
45394
+ return (_a = modalRef.current) == null ? void 0 : _a.showModal();
45395
+ };
45396
+ const hide = () => {
45397
+ var _a;
45398
+ return (_a = modalRef.current) == null ? void 0 : _a.close();
45399
+ };
45400
+ const clonedModal = useMemo11(() => {
45401
+ if (dialogRow && React10.isValidElement(children)) {
45402
+ return React10.cloneElement(children, {
45403
+ key: JSON.stringify(dialogRow),
45404
+ row: dialogRow,
45405
+ show,
45406
+ hide,
45407
+ update: setObjectData
45408
+ });
45409
+ }
45410
+ return null;
45411
+ }, [dialogRow, children]);
45412
+ return /* @__PURE__ */ jsxs23(
45413
+ "dialog",
45414
+ {
45415
+ ref: modalRef,
45416
+ className: "p-6 rounded-xl shadow-2xl backdrop:bg-black/50 w-[100%] h-screen",
45417
+ children: [
45418
+ /* @__PURE__ */ jsxs23("div", { className: "flex justify-between items-center mb-4", children: [
45419
+ /* @__PURE__ */ jsx33("div", {}),
45420
+ /* @__PURE__ */ jsx33(
45421
+ "button",
45422
+ {
45423
+ onClick: () => {
45424
+ var _a;
45425
+ return (_a = modalRef.current) == null ? void 0 : _a.close();
45426
+ },
45427
+ className: "text-white hover:text-gray-100 text-xl border shadow rounded p-1 bg-red-500",
45428
+ children: "\u2715"
45429
+ }
45430
+ )
45431
+ ] }),
45432
+ /* @__PURE__ */ jsx33("div", { className: "text-gray-700", children: clonedModal })
45433
+ ]
45434
+ }
45435
+ );
45528
45436
  }
45437
+ var dialog_default = Dialog;
45529
45438
 
45530
- // src/table2/index.tsx
45531
- import { Fragment as Fragment10, jsx as jsx34 } from "react/jsx-runtime";
45532
- function TableDos(_a) {
45439
+ // src/table3/index.tsx
45440
+ import { jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
45441
+ function Table3(_a) {
45533
45442
  var _b = _a, {
45534
45443
  data,
45535
- maxItems = Infinity,
45536
- symbols = {},
45537
- handlers = {},
45444
+ selectItems,
45445
+ maxItems,
45538
45446
  onSave,
45539
45447
  exportName,
45540
- selectItems,
45541
- colSizes
45448
+ colSizes,
45449
+ modal,
45450
+ header,
45451
+ footer,
45452
+ onChange
45542
45453
  } = _b, props = __objRest(_b, [
45543
45454
  "data",
45455
+ "selectItems",
45544
45456
  "maxItems",
45545
- "symbols",
45546
- "handlers",
45547
45457
  "onSave",
45548
45458
  "exportName",
45549
- "selectItems",
45550
- "colSizes"
45459
+ "colSizes",
45460
+ "modal",
45461
+ "header",
45462
+ "footer",
45463
+ "onChange"
45551
45464
  ]);
45552
- if (data.length == 0) return null;
45553
- const [myData, setMyData] = useState14(data);
45554
- const isArray = Array.isArray(data);
45555
- const context = useTableContext({
45556
- data: myData,
45557
- maxItems,
45558
- symbols,
45465
+ const [handlers, setHandlers] = useState14({});
45466
+ const [page, setPage] = useState14(1);
45467
+ function dataReducer(a, b) {
45468
+ if (b == null) return {};
45469
+ if (Array.isArray(b)) {
45470
+ const obj = b.reduce((acc, bb) => {
45471
+ var _a2, _b2, _c, _d, _e, _f, _g;
45472
+ const id3 = (bb == null ? void 0 : bb.id) || (bb == null ? void 0 : bb._id);
45473
+ if (!id3) throw new Error("Se necesita el id o _id");
45474
+ const cc = ((_a2 = a == null ? void 0 : a[id3]) == null ? void 0 : _a2._updated) ? __spreadProps(__spreadValues(__spreadValues({}, bb), a == null ? void 0 : a[id3]), {
45475
+ _selected: bb == null ? void 0 : bb._selected,
45476
+ _visible: (bb == null ? void 0 : bb._visible) == false ? false : true
45477
+ }) : __spreadProps(__spreadValues({}, bb), {
45478
+ _selected: bb == null ? void 0 : bb._selected,
45479
+ _visible: (bb == null ? void 0 : bb._visible) == false ? false : true
45480
+ });
45481
+ const newHandlers = __spreadValues({}, handlers);
45482
+ for (let item in cc) {
45483
+ const isReactComponent = React11.isValidElement(cc[item]);
45484
+ if (isReactComponent) {
45485
+ newHandlers[item] = cc[item];
45486
+ 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 : "");
45487
+ cc[item] = value || "";
45488
+ }
45489
+ }
45490
+ setHandlers(newHandlers);
45491
+ acc[id3] = __spreadValues(__spreadValues({}, bb), cc);
45492
+ return acc;
45493
+ }, {});
45494
+ return obj;
45495
+ } else {
45496
+ const newA = __spreadValues({}, a);
45497
+ const id3 = (b == null ? void 0 : b.id) || (b == null ? void 0 : b._id);
45498
+ if (!id3) throw new Error("Se necesita el id o _id para actualizar");
45499
+ newA[id3] = __spreadValues(__spreadValues({}, newA[id3]), b);
45500
+ return newA;
45501
+ }
45502
+ }
45503
+ const [objectData, setObjectData] = useReducer2(dataReducer, null);
45504
+ useEffect11(() => {
45505
+ setObjectData(data);
45506
+ setPage(1);
45507
+ }, [data]);
45508
+ const headers = useMemo12(() => {
45509
+ if (!objectData) return [];
45510
+ return [
45511
+ ...new Set(
45512
+ Object.values(objectData).map((o) => Object.keys(o)).flat()
45513
+ )
45514
+ ];
45515
+ }, [objectData]);
45516
+ const totalPages = useMemo12(() => {
45517
+ if (!objectData) return 0;
45518
+ return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
45519
+ }, [objectData, maxItems]);
45520
+ const modalRef = useRef8(null);
45521
+ const [dialogRow, setDialogRow] = useState14({});
45522
+ const context = __spreadValues({
45523
+ objectData,
45524
+ headers,
45559
45525
  handlers,
45560
- onSave,
45526
+ setObjectData,
45527
+ page,
45528
+ setPage,
45529
+ totalPages,
45561
45530
  exportName,
45531
+ onSave,
45532
+ modalRef,
45533
+ modal,
45534
+ dialogRow,
45535
+ setDialogRow,
45562
45536
  selectItems,
45563
- colSizes
45564
- });
45537
+ maxItems,
45538
+ colSizes,
45539
+ header,
45540
+ footer,
45541
+ onChange
45542
+ }, props);
45565
45543
  useEffect11(() => {
45566
- setMyData(data);
45567
- }, [data]);
45568
- if (!context) return null;
45569
- return /* @__PURE__ */ jsx34(Fragment10, { children: isArray ? /* @__PURE__ */ jsx34(VTable2, __spreadValues({ context }, props)) : /* @__PURE__ */ jsx34(HTable2, { context }) });
45570
- }
45571
-
45572
- // src/use-modal/index.tsx
45573
- import {
45574
- useEffect as useEffect12,
45575
- useRef as useRef8,
45576
- useState as useState15
45577
- } from "react";
45578
- import { createPortal } from "react-dom";
45579
- import { jsx as jsx35, jsxs as jsxs24 } from "react/jsx-runtime";
45580
- function useModal() {
45581
- const modalRef = useRef8(null);
45582
- const [mounted, setMounted] = useState15(false);
45583
- useEffect12(() => setMounted(true), []);
45584
- const show = () => {
45585
- requestAnimationFrame(() => {
45586
- const dlg = modalRef.current;
45587
- if (!dlg) return;
45588
- if (typeof dlg.showModal === "function") {
45589
- try {
45590
- if (!dlg.open) dlg.showModal();
45591
- } catch (e) {
45592
- dlg.setAttribute("open", "");
45593
- }
45594
- } else {
45595
- dlg.setAttribute("open", "");
45544
+ if ((dialogRow == null ? void 0 : dialogRow.id) || (dialogRow == null ? void 0 : dialogRow._id)) {
45545
+ const newDialogRow = objectData[dialogRow == null ? void 0 : dialogRow.id] || objectData[dialogRow == null ? void 0 : dialogRow._id];
45546
+ setDialogRow(newDialogRow);
45547
+ }
45548
+ }, [objectData]);
45549
+ const style = (props == null ? void 0 : props.style) ? __spreadProps(__spreadValues({}, props.style), { tableLayout: "fixed" }) : { tableLayout: "fixed" };
45550
+ if (!objectData) return null;
45551
+ console.log({ objectData });
45552
+ return /* @__PURE__ */ jsxs24("div", { className: "border shadow rounded m-1 p-1 bg-white", children: [
45553
+ modal && /* @__PURE__ */ jsx34(
45554
+ dialog_default,
45555
+ {
45556
+ modalRef,
45557
+ dialogRow,
45558
+ setDialogRow,
45559
+ setObjectData,
45560
+ children: modal
45596
45561
  }
45597
- });
45598
- };
45599
- const hide = () => {
45600
- const dlg = modalRef.current;
45601
- if (!dlg) return;
45602
- if (typeof dlg.close === "function") dlg.close();
45603
- else dlg.removeAttribute("open");
45604
- };
45605
- const Modal2 = (_a) => {
45606
- var _b = _a, {
45607
- className,
45608
- children,
45609
- title
45610
- } = _b, props = __objRest(_b, [
45611
- "className",
45612
- "children",
45613
- "title"
45614
- ]);
45615
- if (!mounted) return null;
45616
- const dialog = /* @__PURE__ */ jsxs24(
45617
- "dialog",
45618
- __spreadProps(__spreadValues({
45619
- ref: modalRef,
45620
- className: (className != null ? className : "") + " p-6 rounded-2xl shadow-2xl bg-white max-w-lg w-[90%]"
45621
- }, props), {
45622
- children: [
45623
- /* @__PURE__ */ jsxs24("div", { className: "flex justify-between items-center border-b pb-2 mb-4", children: [
45624
- /* @__PURE__ */ jsx35("h2", { className: "text-lg font-semibold text-gray-800", children: title }),
45625
- /* @__PURE__ */ jsx35(
45626
- "button",
45627
- {
45628
- onClick: hide,
45629
- className: "text-gray-500 hover:text-gray-800 text-2xl font-bold",
45630
- children: "\xD7"
45631
- }
45632
- )
45633
- ] }),
45634
- /* @__PURE__ */ jsx35("div", { className: "mt-2 text-gray-800", children })
45635
- ]
45636
- })
45637
- );
45638
- return createPortal(dialog, document.body);
45639
- };
45640
- return { show, hide, Modal: Modal2 };
45562
+ ),
45563
+ /* @__PURE__ */ jsx34("div", { className: "font-bold text-2xl py-5 px-2 bg-blue-50", children: header }),
45564
+ /* @__PURE__ */ jsx34(Panel, __spreadValues({}, context)),
45565
+ /* @__PURE__ */ jsxs24("table", __spreadProps(__spreadValues({}, props), { style, children: [
45566
+ /* @__PURE__ */ jsx34(TableHead, __spreadValues({}, context)),
45567
+ /* @__PURE__ */ jsx34(TableBody, __spreadValues({}, context)),
45568
+ /* @__PURE__ */ jsx34(TableFooter, __spreadValues({}, context))
45569
+ ] }))
45570
+ ] });
45641
45571
  }
45642
45572
  export {
45643
45573
  Alert,
@@ -45651,13 +45581,12 @@ export {
45651
45581
  pre_default as Pre,
45652
45582
  Select,
45653
45583
  Table,
45654
- TableDos,
45584
+ Table3,
45655
45585
  TextArea,
45656
45586
  regular_expresions_default as regularExpresions,
45657
45587
  useDates,
45658
45588
  useExcel,
45659
45589
  useFormValues,
45660
- useModal,
45661
45590
  useResources
45662
45591
  };
45663
45592
  /*! Bundled license information: