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