next-recomponents 2.0.4 → 2.0.5

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
@@ -35694,24 +35694,17 @@ function useExcel() {
35694
35694
  }
35695
35695
 
35696
35696
  // src/table/index.tsx
35697
- var import_material2 = require("@mui/material");
35698
35697
  var import_jsx_runtime7 = require("react/jsx-runtime");
35699
- function Table(props) {
35700
- if (Array.isArray(props.data)) {
35701
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IHTable, { ...props });
35702
- } else {
35703
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: " bg-white border shadow rounded p-1", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("table", { className: "rounded", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tbody", { children: Object.keys(props.data).map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("tr", { className: "border-b ", children: [
35704
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("th", { className: "font-bold p-3 text-right", children: k }),
35705
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35706
- "td",
35707
- {
35708
- className: typeof props.data[k] === "number" ? "text-right" : "text-center",
35709
- children: props.data[k]
35710
- }
35711
- )
35712
- ] }, k)) }) }) });
35713
- }
35714
- }
35698
+ var HEIGHT_MAP = {
35699
+ 1: 150,
35700
+ 2: 200,
35701
+ 3: 250,
35702
+ 4: 310,
35703
+ 5: 360,
35704
+ 6: 410,
35705
+ 7: 460,
35706
+ 8: 510
35707
+ };
35715
35708
  function EditIcon() {
35716
35709
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35717
35710
  "svg",
@@ -35727,65 +35720,142 @@ function EditIcon() {
35727
35720
  }
35728
35721
  );
35729
35722
  }
35730
- function IHTable({
35731
- data,
35732
- flex = 1,
35733
- editableFields,
35723
+ function KeyValueTable({ data }) {
35724
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "bg-white border shadow rounded p-1", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("table", { className: "rounded", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tbody", { children: Object.keys(data).map((key) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("tr", { className: "border-b", children: [
35725
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("th", { className: "font-bold p-3 text-right", children: key }),
35726
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35727
+ "td",
35728
+ {
35729
+ className: typeof data[key] === "number" ? "text-right" : "text-center",
35730
+ children: data[key]
35731
+ }
35732
+ )
35733
+ ] }, key)) }) }) });
35734
+ }
35735
+ var FOOTER_LABELS = {
35736
+ sum: "Suma",
35737
+ avg: "Promedio",
35738
+ count: "Conteo"
35739
+ };
35740
+ function computeAggregation(rows, key, type) {
35741
+ const values = rows.map((r) => {
35742
+ var _a;
35743
+ return Number((_a = r[key]) != null ? _a : 0);
35744
+ }).filter((v) => !isNaN(v));
35745
+ if (type === "sum") return values.reduce((acc, v) => acc + v, 0);
35746
+ if (type === "count") return values.length;
35747
+ if (type === "avg")
35748
+ return values.length ? values.reduce((acc, v) => acc + v, 0) / values.length : 0;
35749
+ return 0;
35750
+ }
35751
+ function CustomFooter({
35752
+ rows,
35753
+ footer
35754
+ }) {
35755
+ const entries = Object.entries(footer);
35756
+ if (!entries.length) return null;
35757
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-end gap-6 px-4 py-2 bg-gray-100 border-t border-gray-300 text-sm font-semibold text-gray-700", children: entries.map(([key, type]) => {
35758
+ const value = computeAggregation(rows, key, type);
35759
+ const formatted = type === "avg" ? value.toLocaleString(void 0, { maximumFractionDigits: 2 }) : value.toLocaleString();
35760
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
35761
+ FOOTER_LABELS[type],
35762
+ " de",
35763
+ " ",
35764
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-gray-900", children: key }),
35765
+ ":",
35766
+ " ",
35767
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-blue-700", children: formatted })
35768
+ ] }, key);
35769
+ }) });
35770
+ }
35771
+ function ModalDialog({ open, onClose, modal, selectedRow }) {
35772
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_material.Dialog, { open, onClose, maxWidth: "xl", fullWidth: true, children: [
35773
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35774
+ "button",
35775
+ {
35776
+ onClick: onClose,
35777
+ className: "text-gray-500 hover:text-gray-800 text-xl font-bold p-5",
35778
+ children: "\xD7"
35779
+ }
35780
+ ) }),
35781
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-4 m-auto p-5", children: selectedRow && import_react4.default.cloneElement(
35782
+ modal,
35783
+ { row: selectedRow }
35784
+ ) })
35785
+ ] });
35786
+ }
35787
+ function Toolbar({
35788
+ exportName,
35734
35789
  onSave,
35735
35790
  onSelect,
35736
- buttons,
35737
- exportName,
35738
- modal,
35739
- height = 600,
35740
- width = "100%",
35741
- header,
35742
- hideColumns = [],
35743
- footer
35791
+ rows,
35792
+ filteredRows
35744
35793
  }) {
35745
- const [open, setOpen] = (0, import_react4.useState)(false);
35746
- if (modal) {
35747
- buttons = { ...buttons, Modal: "" };
35748
- }
35749
- const handleOpen = () => setOpen(true);
35750
- const handleClose = () => {
35751
- setOpen(false);
35752
- setSelectedRows({
35753
- type: "include",
35754
- ids: /* @__PURE__ */ new Set()
35755
- });
35756
- };
35757
35794
  const excel = useExcel();
35758
- const [rows, setRows] = (0, import_react4.useState)(data);
35759
- const [selectedRows, setSelectedRows] = (0, import_react4.useState)();
35760
- (0, import_react4.useEffect)(() => {
35761
- setRows(data);
35762
- }, [data]);
35763
- const columns = (0, import_react4.useMemo)(() => {
35795
+ const stripMeta = (r) => {
35796
+ const { _edited, ...rest } = r;
35797
+ return rest;
35798
+ };
35799
+ if (!exportName && !onSave && !onSelect) return null;
35800
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex gap-2 bg-gray-200 border shadow rounded p-2", children: [
35801
+ exportName && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35802
+ Button,
35803
+ {
35804
+ className: "bg-green-800 text-white",
35805
+ onClick: () => excel.export(rows.map(stripMeta), `${exportName}.xlsx`),
35806
+ children: "Exportar"
35807
+ }
35808
+ ),
35809
+ onSelect ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35810
+ Button,
35811
+ {
35812
+ disabled: filteredRows.length === 0,
35813
+ color: filteredRows.length === 0 ? "white" : "primary",
35814
+ onClick: () => onSelect(filteredRows.map(stripMeta)),
35815
+ children: "Guardar Selecci\xF3n"
35816
+ }
35817
+ ) : onSave && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { onClick: () => onSave(rows.map(stripMeta)), children: "Guardar" })
35818
+ ] });
35819
+ }
35820
+ function useColumns(rows, options) {
35821
+ const {
35822
+ flex,
35823
+ editableFields,
35824
+ buttons,
35825
+ hideColumns,
35826
+ modal,
35827
+ handleRowUpdate,
35828
+ onModalOpen
35829
+ } = options;
35830
+ return (0, import_react4.useMemo)(() => {
35764
35831
  if (!rows.length) return [];
35765
- const arr = Object.keys(rows[0]).filter((key) => !key.startsWith("_") && !hideColumns.includes(key)).map((key, i) => ({
35766
- field: key,
35767
- headerName: key,
35768
- flex,
35769
- editable: editableFields == null ? void 0 : editableFields.includes(key),
35770
- type: typeof rows[0][key] === "number" ? "number" : "string",
35771
- renderCell: (buttons == null ? void 0 : buttons[key]) ? (params) => {
35772
- var _a, _b;
35773
- return import_react4.default.cloneElement(buttons[key], {
35774
- className: ((_a = params == null ? void 0 : params.className) != null ? _a : "") + " m-auto text-xs ",
35775
- children: (_b = params == null ? void 0 : params.row) == null ? void 0 : _b[key],
35776
- onClick: (e) => {
35777
- var _a2, _b2;
35778
- e.row = params == null ? void 0 : params.row;
35779
- if ((_b2 = (_a2 = buttons[key]) == null ? void 0 : _a2.props) == null ? void 0 : _b2.onClick) {
35780
- const newVal = buttons[key].props.onClick(e);
35781
- newVal && handleRowUpdate(newVal);
35832
+ const cols = Object.keys(rows[0]).filter((key) => !key.startsWith("_") && !hideColumns.includes(key)).map((key) => {
35833
+ var _a;
35834
+ return {
35835
+ field: key,
35836
+ headerName: key,
35837
+ flex,
35838
+ editable: (_a = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _a : false,
35839
+ type: typeof rows[0][key] === "number" ? "number" : "string",
35840
+ renderCell: (buttons == null ? void 0 : buttons[key]) ? (params) => {
35841
+ var _a2, _b;
35842
+ return import_react4.default.cloneElement(buttons[key], {
35843
+ className: `${(_a2 = params == null ? void 0 : params.className) != null ? _a2 : ""} m-auto text-xs`,
35844
+ children: (_b = params == null ? void 0 : params.row) == null ? void 0 : _b[key],
35845
+ onClick: (e) => {
35846
+ var _a3, _b2;
35847
+ e.row = params == null ? void 0 : params.row;
35848
+ if ((_b2 = (_a3 = buttons[key]) == null ? void 0 : _a3.props) == null ? void 0 : _b2.onClick) {
35849
+ const newVal = buttons[key].props.onClick(e);
35850
+ if (newVal) handleRowUpdate(newVal);
35851
+ }
35782
35852
  }
35783
- }
35784
- });
35785
- } : null
35786
- }));
35853
+ });
35854
+ } : null
35855
+ };
35856
+ });
35787
35857
  if (modal) {
35788
- arr.unshift({
35858
+ cols.unshift({
35789
35859
  field: "Modal",
35790
35860
  headerName: "Modal",
35791
35861
  flex,
@@ -35797,9 +35867,7 @@ function IHTable({
35797
35867
  Button,
35798
35868
  {
35799
35869
  className: "text-xs",
35800
- onClick: () => {
35801
- handleOpen();
35802
- },
35870
+ onClick: () => onModalOpen(params.row),
35803
35871
  icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditIcon, {}),
35804
35872
  children: (_a = params == null ? void 0 : params.row) == null ? void 0 : _a["Modal"]
35805
35873
  }
@@ -35807,98 +35875,104 @@ function IHTable({
35807
35875
  }
35808
35876
  });
35809
35877
  }
35810
- return arr;
35878
+ return cols;
35811
35879
  }, [rows]);
35880
+ }
35881
+ function IHTable({
35882
+ data,
35883
+ flex = 1,
35884
+ editableFields,
35885
+ onSave,
35886
+ onSelect,
35887
+ buttons,
35888
+ exportName,
35889
+ modal,
35890
+ height = 510,
35891
+ width = "100%",
35892
+ header,
35893
+ hideColumns = [],
35894
+ footer = {}
35895
+ }) {
35896
+ var _a;
35897
+ if (modal && onSelect)
35898
+ throw new Error("Solo se puede usar modal o onSelect por separado");
35899
+ const [open, setOpen] = (0, import_react4.useState)(false);
35900
+ const [rows, setRows] = (0, import_react4.useState)(data);
35901
+ const [selectedRows, setSelectedRows] = (0, import_react4.useState)({
35902
+ type: "include",
35903
+ ids: /* @__PURE__ */ new Set()
35904
+ });
35905
+ const [modalRow, setModalRow] = (0, import_react4.useState)();
35906
+ const resolvedButtons = modal ? { ...buttons, Modal: "" } : buttons;
35907
+ (0, import_react4.useEffect)(() => {
35908
+ setRows(data);
35909
+ }, [data]);
35910
+ const handleModalOpen = (row) => {
35911
+ setModalRow(row);
35912
+ setOpen(true);
35913
+ };
35914
+ const handleClose = () => {
35915
+ setOpen(false);
35916
+ setModalRow(void 0);
35917
+ };
35812
35918
  const handleRowUpdate = (newRow) => {
35813
35919
  if (!newRow.id) throw new Error("Fila sin id");
35814
- newRow._edited = true;
35815
- setRows((prev) => prev.map((row) => row.id === newRow.id ? newRow : row));
35816
- return newRow;
35817
- };
35818
- const ref = (0, import_react4.useRef)(null);
35819
- const cat1 = {
35820
- 1: 110,
35821
- 2: 160,
35822
- 3: 215,
35823
- 4: 266,
35824
- 5: 316
35920
+ const updated = { ...newRow, _edited: true };
35921
+ setRows(
35922
+ (prev) => prev.map((row) => row.id === updated.id ? updated : row)
35923
+ );
35924
+ return updated;
35825
35925
  };
35826
- const filtered = (0, import_react4.useMemo)(() => {
35827
- let filtered2 = [];
35828
- if ((selectedRows == null ? void 0 : selectedRows.type) == "exclude") {
35829
- filtered2 = rows.filter(
35830
- (r) => !Array.from(selectedRows.ids).includes(r.id)
35831
- );
35832
- } else if ((selectedRows == null ? void 0 : selectedRows.type) == "include") {
35833
- filtered2 = rows.filter(
35834
- (r) => Array.from(selectedRows.ids).includes(r.id)
35835
- );
35836
- }
35837
- return filtered2;
35838
- }, [selectedRows]);
35839
- return rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
35926
+ const filteredRows = (0, import_react4.useMemo)(() => {
35927
+ if ((selectedRows == null ? void 0 : selectedRows.type) === "exclude") {
35928
+ return rows.filter((r) => !Array.from(selectedRows.ids).includes(r.id));
35929
+ }
35930
+ if ((selectedRows == null ? void 0 : selectedRows.type) === "include") {
35931
+ return rows.filter((r) => Array.from(selectedRows.ids).includes(r.id));
35932
+ }
35933
+ return [];
35934
+ }, [selectedRows, rows]);
35935
+ const columns = useColumns(rows, {
35936
+ flex,
35937
+ editableFields,
35938
+ buttons: resolvedButtons,
35939
+ hideColumns,
35940
+ modal,
35941
+ handleRowUpdate,
35942
+ onModalOpen: handleModalOpen
35943
+ });
35944
+ if (!rows.length) return null;
35945
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
35840
35946
  import_material.Box,
35841
35947
  {
35842
35948
  sx: {
35843
35949
  display: "flex",
35844
35950
  flexDirection: "column",
35845
- height: (cat1 == null ? void 0 : cat1[height]) || height,
35951
+ height: (_a = HEIGHT_MAP[rows.length]) != null ? _a : height,
35846
35952
  width,
35847
35953
  zIndex: 999999999
35848
35954
  },
35849
35955
  children: [
35850
- modal && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_material2.Dialog, { open, onClose: handleClose, maxWidth: "xl", fullWidth: true, children: [
35851
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35852
- "button",
35853
- {
35854
- onClick: () => {
35855
- handleClose();
35856
- },
35857
- className: "text-gray-500 hover:text-gray-800 text-xl font-bold p-5",
35858
- children: "\xD7"
35859
- }
35860
- ) }),
35861
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-4 m-auto p-5", children: selectedRows && Array.from(selectedRows == null ? void 0 : selectedRows.ids).length > 0 && import_react4.default.cloneElement(modal, {
35862
- row: rows.find(
35863
- (r) => Array.from(selectedRows == null ? void 0 : selectedRows.ids).includes(r.id)
35864
- )
35865
- }) })
35866
- ] }),
35956
+ modal && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35957
+ ModalDialog,
35958
+ {
35959
+ open,
35960
+ onClose: handleClose,
35961
+ modal,
35962
+ selectedRow: modalRow
35963
+ }
35964
+ ),
35867
35965
  header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-bold text-xl p-2 bg-blue-500 text-white border shadow rounded", children: header }),
35868
- (exportName || onSave || onSelect) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex gap-2 bg-gray-200 border shadow rounded p-2", children: [
35869
- exportName && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35870
- Button,
35871
- {
35872
- className: "bg-green-800 text-white",
35873
- onClick: (e) => {
35874
- excel.export(
35875
- rows.map(({ _edited, ...r }) => r),
35876
- `${exportName}.xlsx`
35877
- );
35878
- },
35879
- children: "Exportar"
35880
- }
35881
- ),
35882
- onSelect ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35883
- Button,
35884
- {
35885
- disabled: filtered.length == 0,
35886
- color: filtered.length == 0 ? "white" : "primary",
35887
- onClick: (e) => {
35888
- onSelect == null ? void 0 : onSelect(filtered.map(({ _edited, ...r }) => r));
35889
- },
35890
- children: "Guardar Selecci\xF3n"
35891
- }
35892
- ) : onSave && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35893
- Button,
35894
- {
35895
- onClick: (e) => {
35896
- onSave == null ? void 0 : onSave(rows.map(({ _edited, ...r }) => r));
35897
- },
35898
- children: "Guardar"
35899
- }
35900
- )
35901
- ] }),
35966
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35967
+ Toolbar,
35968
+ {
35969
+ exportName,
35970
+ onSave,
35971
+ onSelect,
35972
+ rows,
35973
+ filteredRows
35974
+ }
35975
+ ),
35902
35976
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35903
35977
  import_x_data_grid.DataGrid,
35904
35978
  {
@@ -35906,59 +35980,34 @@ function IHTable({
35906
35980
  columns,
35907
35981
  checkboxSelection: Boolean(onSelect),
35908
35982
  rowSelectionModel: selectedRows,
35909
- onRowSelectionModelChange: (newSelection) => {
35910
- setSelectedRows(newSelection);
35911
- },
35983
+ onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
35912
35984
  sx: {
35913
35985
  "& .MuiDataGrid-cell--editable": {
35914
35986
  backgroundColor: "#c6d8f0",
35915
35987
  fontWeight: 500
35988
+ },
35989
+ ...rows.length <= Object.keys(HEIGHT_MAP).length && {
35990
+ "& .MuiDataGrid-filler": {
35991
+ display: "none"
35992
+ }
35916
35993
  }
35917
35994
  },
35918
35995
  editMode: "row",
35919
35996
  processRowUpdate: handleRowUpdate,
35920
- pageSizeOptions: [5, 10]
35997
+ pageSizeOptions: [5, 10],
35998
+ hideFooter: rows.length <= Object.keys(HEIGHT_MAP).length
35921
35999
  }
35922
36000
  ),
35923
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CustomFooter, { footer: footer || {}, rows })
36001
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CustomFooter, { footer, rows })
35924
36002
  ]
35925
36003
  }
35926
36004
  );
35927
36005
  }
35928
- function CustomFooter({
35929
- rows,
35930
- footer
35931
- }) {
35932
- const entries = Object.entries(footer);
35933
- if (!entries.length) return null;
35934
- const compute = (key, type) => {
35935
- const values = rows.map((r) => {
35936
- var _a;
35937
- return Number((_a = r[key]) != null ? _a : 0);
35938
- }).filter((v) => !isNaN(v));
35939
- if (type === "sum") return values.reduce((acc, v) => acc + v, 0);
35940
- if (type === "avg")
35941
- return values.length ? values.reduce((acc, v) => acc + v, 0) / values.length : 0;
35942
- if (type === "count") return values.length;
35943
- return 0;
35944
- };
35945
- const label = {
35946
- sum: "Suma",
35947
- avg: "Promedio",
35948
- count: "Conteo"
35949
- };
35950
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-end gap-6 px-4 py-2 bg-gray-100 border-t border-gray-300 text-sm font-semibold text-gray-700", children: entries.map(([key, type]) => {
35951
- const value = compute(key, type);
35952
- const formatted = type === "avg" ? value.toLocaleString(void 0, { maximumFractionDigits: 2 }) : value.toLocaleString();
35953
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
35954
- label[type],
35955
- " de ",
35956
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-gray-900", children: key }),
35957
- ":",
35958
- " ",
35959
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-blue-700", children: formatted })
35960
- ] }, key);
35961
- }) });
36006
+ function Table(props) {
36007
+ if (Array.isArray(props.data)) {
36008
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IHTable, { ...props });
36009
+ }
36010
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(KeyValueTable, { data: props.data });
35962
36011
  }
35963
36012
 
35964
36013
  // src/text-area/index.tsx
@@ -36755,7 +36804,7 @@ function CloseIcon2() {
36755
36804
  }
36756
36805
 
36757
36806
  // src/modal/index.tsx
36758
- var import_material3 = require("@mui/material");
36807
+ var import_material2 = require("@mui/material");
36759
36808
  var import_jsx_runtime13 = require("react/jsx-runtime");
36760
36809
  function Modal({ button, children, ref, title = "" }) {
36761
36810
  const [open, setOpen] = (0, import_react9.useState)(false);
@@ -36780,7 +36829,7 @@ function Modal({ button, children, ref, title = "" }) {
36780
36829
  }
36781
36830
  return child;
36782
36831
  }),
36783
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material3.Dialog, { open, onClose: hide, fullWidth: true, maxWidth: "xl", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "m-auto p-5", children: [
36832
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material2.Dialog, { open, onClose: hide, fullWidth: true, maxWidth: "xl", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "m-auto p-5", children: [
36784
36833
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
36785
36834
  "button",
36786
36835
  {
@@ -36872,7 +36921,7 @@ function CalendarIcon() {
36872
36921
  }
36873
36922
 
36874
36923
  // src/calendar/index.tsx
36875
- var import_material4 = require("@mui/material");
36924
+ var import_material3 = require("@mui/material");
36876
36925
  var import_jsx_runtime16 = require("react/jsx-runtime");
36877
36926
  function MyCalendar({
36878
36927
  enabledDates,
@@ -36937,7 +36986,7 @@ function MyCalendar({
36937
36986
  }
36938
36987
  ) })
36939
36988
  ] }),
36940
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material4.Dialog, { open, children: [
36989
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_material3.Dialog, { open, children: [
36941
36990
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex justify-end p-5 font-bold", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
36942
36991
  "button",
36943
36992
  {
@@ -37962,20 +38011,85 @@ function Table3({
37962
38011
  // src/pop/index.tsx
37963
38012
  var import_react16 = require("react");
37964
38013
  var import_jsx_runtime28 = require("react/jsx-runtime");
38014
+ var COLOR_CONFIG = {
38015
+ primary: {
38016
+ bg: "from-blue-50 to-indigo-50",
38017
+ iconBg: "bg-blue-100",
38018
+ iconText: "text-blue-600",
38019
+ border: "border-blue-200",
38020
+ confirm: "bg-blue-600 hover:bg-blue-700 focus:ring-blue-300",
38021
+ label: "\u2139"
38022
+ },
38023
+ info: {
38024
+ bg: "from-sky-50 to-cyan-50",
38025
+ iconBg: "bg-sky-100",
38026
+ iconText: "text-sky-600",
38027
+ border: "border-sky-200",
38028
+ confirm: "bg-sky-600 hover:bg-sky-700 focus:ring-sky-300",
38029
+ label: "\u2139"
38030
+ },
38031
+ success: {
38032
+ bg: "from-emerald-50 to-green-50",
38033
+ iconBg: "bg-emerald-100",
38034
+ iconText: "text-emerald-600",
38035
+ border: "border-emerald-200",
38036
+ confirm: "bg-emerald-600 hover:bg-emerald-700 focus:ring-emerald-300",
38037
+ label: "\u2713"
38038
+ },
38039
+ warning: {
38040
+ bg: "from-amber-50 to-yellow-50",
38041
+ iconBg: "bg-amber-100",
38042
+ iconText: "text-amber-600",
38043
+ border: "border-amber-200",
38044
+ confirm: "bg-amber-500 hover:bg-amber-600 focus:ring-amber-300",
38045
+ label: "\u26A0"
38046
+ },
38047
+ danger: {
38048
+ bg: "from-red-50 to-rose-50",
38049
+ iconBg: "bg-red-100",
38050
+ iconText: "text-red-600",
38051
+ border: "border-red-200",
38052
+ confirm: "bg-red-600 hover:bg-red-700 focus:ring-red-300",
38053
+ label: "\u2715"
38054
+ },
38055
+ secondary: {
38056
+ bg: "from-slate-50 to-gray-50",
38057
+ iconBg: "bg-slate-100",
38058
+ iconText: "text-slate-600",
38059
+ border: "border-slate-200",
38060
+ confirm: "bg-slate-700 hover:bg-slate-800 focus:ring-slate-300",
38061
+ label: "\u25CE"
38062
+ },
38063
+ white: {
38064
+ bg: "from-gray-50 to-white",
38065
+ iconBg: "bg-gray-100",
38066
+ iconText: "text-gray-500",
38067
+ border: "border-gray-200",
38068
+ confirm: "bg-gray-700 hover:bg-gray-800 focus:ring-gray-300",
38069
+ label: "\u25CE"
38070
+ }
38071
+ };
37965
38072
  function usePopup() {
37966
- const [popup, setPopup] = (0, import_react16.useState)({ type: "alert", message: "", visible: false, inputValue: "" });
37967
- function alert2(message) {
38073
+ const [popup, setPopup] = (0, import_react16.useState)({
38074
+ type: "alert",
38075
+ message: "",
38076
+ visible: false,
38077
+ inputValue: "",
38078
+ color: "primary"
38079
+ });
38080
+ function alert2(message, color = "primary") {
37968
38081
  return new Promise((resolve) => {
37969
38082
  setPopup({
37970
38083
  type: "alert",
37971
38084
  message,
37972
38085
  visible: true,
37973
38086
  inputValue: "",
37974
- onConfirm: () => resolve()
38087
+ onConfirm: () => resolve(),
38088
+ color
37975
38089
  });
37976
38090
  });
37977
38091
  }
37978
- function confirm(message) {
38092
+ function confirm(message, color = "primary") {
37979
38093
  return new Promise((resolve) => {
37980
38094
  setPopup({
37981
38095
  type: "confirm",
@@ -37983,11 +38097,12 @@ function usePopup() {
37983
38097
  visible: true,
37984
38098
  inputValue: "",
37985
38099
  onConfirm: () => resolve(true),
37986
- onCancel: () => resolve(false)
38100
+ onCancel: () => resolve(false),
38101
+ color
37987
38102
  });
37988
38103
  });
37989
38104
  }
37990
- function prompt(message) {
38105
+ function prompt(message, color = "primary") {
37991
38106
  return new Promise((resolve) => {
37992
38107
  setPopup({
37993
38108
  type: "prompt",
@@ -37995,7 +38110,8 @@ function usePopup() {
37995
38110
  visible: true,
37996
38111
  inputValue: "",
37997
38112
  onConfirm: (value) => resolve(value != null ? value : ""),
37998
- onCancel: () => resolve(null)
38113
+ onCancel: () => resolve(null),
38114
+ color
37999
38115
  });
38000
38116
  });
38001
38117
  }
@@ -38007,35 +38123,40 @@ function usePopup() {
38007
38123
  return { ...prev, visible: false, inputValue: "" };
38008
38124
  });
38009
38125
  }
38126
+ const c = COLOR_CONFIG[popup.color];
38010
38127
  const PopupComponent = popup.visible ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
38011
38128
  "div",
38012
38129
  {
38013
- style: {
38014
- position: "fixed",
38015
- top: 0,
38016
- left: 0,
38017
- width: "100%",
38018
- height: "100%",
38019
- background: "rgba(0,0,0,0.5)",
38020
- display: "flex",
38021
- alignItems: "center",
38022
- justifyContent: "center",
38023
- zIndex: 1e3
38024
- },
38130
+ className: "fixed inset-0 flex items-center justify-center z-[1000]",
38131
+ style: { background: "rgba(15,23,42,0.45)", backdropFilter: "blur(2px)" },
38132
+ onClick: (e) => e.target === e.currentTarget && close(false),
38025
38133
  children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
38026
38134
  "div",
38027
38135
  {
38028
- style: {
38029
- background: "#fff",
38030
- padding: "24px 32px",
38031
- borderRadius: "8px",
38032
- minWidth: "300px",
38033
- textAlign: "center",
38034
- boxShadow: "0 4px 20px rgba(0,0,0,0.2)"
38035
- },
38136
+ className: `
38137
+ bg-gradient-to-br ${c.bg} border ${c.border}
38138
+ rounded-2xl shadow-2xl w-full max-w-sm mx-4
38139
+ animate-[fadeInScale_0.18s_ease-out]
38140
+ `,
38141
+ style: { animation: "fadeInScale 0.18s ease-out" },
38036
38142
  children: [
38037
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { style: { margin: "0 0 16px", fontSize: "16px" }, children: popup.message }),
38038
- popup.type === "prompt" && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
38143
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("style", { children: `
38144
+ @keyframes fadeInScale {
38145
+ from { opacity: 0; transform: scale(0.93) translateY(8px); }
38146
+ to { opacity: 1; transform: scale(1) translateY(0); }
38147
+ }
38148
+ ` }),
38149
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col items-center gap-3 px-8 pt-8 pb-5 text-center", children: [
38150
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
38151
+ "div",
38152
+ {
38153
+ className: `w-12 h-12 rounded-full ${c.iconBg} flex items-center justify-center`,
38154
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: `text-xl font-bold ${c.iconText}`, children: c.label })
38155
+ }
38156
+ ),
38157
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-gray-800 text-[15px] font-medium leading-snug", children: popup.message })
38158
+ ] }),
38159
+ popup.type === "prompt" && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "px-8 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
38039
38160
  "input",
38040
38161
  {
38041
38162
  autoFocus: true,
@@ -38043,31 +38164,22 @@ function usePopup() {
38043
38164
  value: popup.inputValue,
38044
38165
  onChange: (e) => setPopup((prev) => ({ ...prev, inputValue: e.target.value })),
38045
38166
  onKeyDown: (e) => e.key === "Enter" && close(true, popup.inputValue),
38046
- style: {
38047
- width: "100%",
38048
- padding: "8px 12px",
38049
- marginBottom: "16px",
38050
- border: "1px solid #d1d5db",
38051
- borderRadius: "6px",
38052
- fontSize: "14px",
38053
- boxSizing: "border-box"
38054
- }
38167
+ className: `
38168
+ w-full px-3 py-2 rounded-lg border ${c.border} bg-white
38169
+ text-sm text-gray-800 outline-none
38170
+ focus:ring-2 ${c.confirm.includes("blue") ? "focus:ring-blue-200" : "focus:ring-gray-200"}
38171
+ transition
38172
+ `,
38173
+ placeholder: "Escribe aqu\xED..."
38055
38174
  }
38056
- ),
38057
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { style: { display: "flex", gap: "8px", justifyContent: "center" }, children: [
38175
+ ) }),
38176
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: `border-t ${c.border} mx-0 mt-4` }),
38177
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex gap-2 px-6 py-4 justify-end", children: [
38058
38178
  (popup.type === "confirm" || popup.type === "prompt") && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
38059
38179
  "button",
38060
38180
  {
38061
38181
  onClick: () => close(false),
38062
- style: {
38063
- padding: "8px 24px",
38064
- background: "#e5e7eb",
38065
- color: "#374151",
38066
- border: "none",
38067
- borderRadius: "6px",
38068
- cursor: "pointer",
38069
- fontSize: "14px"
38070
- },
38182
+ className: "\r\n px-4 py-2 rounded-lg text-sm font-medium\r\n bg-white border border-gray-200 text-gray-600\r\n hover:bg-gray-50 transition\r\n ",
38071
38183
  children: "Cancelar"
38072
38184
  }
38073
38185
  ),
@@ -38075,16 +38187,11 @@ function usePopup() {
38075
38187
  "button",
38076
38188
  {
38077
38189
  onClick: () => close(true, popup.inputValue),
38078
- style: {
38079
- padding: "8px 24px",
38080
- background: "#3b82f6",
38081
- color: "#fff",
38082
- border: "none",
38083
- borderRadius: "6px",
38084
- cursor: "pointer",
38085
- fontSize: "14px"
38086
- },
38087
- children: "OK"
38190
+ className: `
38191
+ px-5 py-2 rounded-lg text-sm font-semibold text-white
38192
+ ${c.confirm} transition focus:outline-none focus:ring-2
38193
+ `,
38194
+ children: "Aceptar"
38088
38195
  }
38089
38196
  )
38090
38197
  ] })