next-recomponents 2.0.2 → 2.0.4

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.d.mts CHANGED
@@ -215,4 +215,11 @@ interface Table3Props<T extends Record<string, any>> extends DetailedHTMLProps<T
215
215
  }
216
216
  declare function Table3<T extends Record<string, any>>({ data, selectItems, maxItems, onSave, exportName, colSizes, modal, header, footer, onChange, symbols, sortBy, ...props }: Table3Props<T>): react_jsx_runtime.JSX.Element | null;
217
217
 
218
- export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, Table, Table3, type TableButtonProps, type TableButtonProps as TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, useResources };
218
+ declare function usePopup(): {
219
+ alert: (message: string) => Promise<void>;
220
+ confirm: (message: string) => Promise<boolean>;
221
+ prompt: (message: string) => Promise<string | null>;
222
+ PopupComponent: react_jsx_runtime.JSX.Element | null;
223
+ };
224
+
225
+ export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, Table, Table3, type TableButtonProps, type TableButtonProps as TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, usePopup, useResources };
package/dist/index.d.ts CHANGED
@@ -215,4 +215,11 @@ interface Table3Props<T extends Record<string, any>> extends DetailedHTMLProps<T
215
215
  }
216
216
  declare function Table3<T extends Record<string, any>>({ data, selectItems, maxItems, onSave, exportName, colSizes, modal, header, footer, onChange, symbols, sortBy, ...props }: Table3Props<T>): react_jsx_runtime.JSX.Element | null;
217
217
 
218
- export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, Table, Table3, type TableButtonProps, type TableButtonProps as TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, useResources };
218
+ declare function usePopup(): {
219
+ alert: (message: string) => Promise<void>;
220
+ confirm: (message: string) => Promise<boolean>;
221
+ prompt: (message: string) => Promise<string | null>;
222
+ PopupComponent: react_jsx_runtime.JSX.Element | null;
223
+ };
224
+
225
+ export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, Table, Table3, type TableButtonProps, type TableButtonProps as TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, usePopup, useResources };
package/dist/index.js CHANGED
@@ -3505,6 +3505,7 @@ __export(index_exports, {
3505
3505
  useDates: () => useDates,
3506
3506
  useExcel: () => useExcel,
3507
3507
  useFormValues: () => useFormValues,
3508
+ usePopup: () => usePopup,
3508
3509
  useResources: () => useResources
3509
3510
  });
3510
3511
  module.exports = __toCommonJS(index_exports);
@@ -37957,6 +37958,143 @@ function Table3({
37957
37958
  ] })
37958
37959
  ] });
37959
37960
  }
37961
+
37962
+ // src/pop/index.tsx
37963
+ var import_react16 = require("react");
37964
+ var import_jsx_runtime28 = require("react/jsx-runtime");
37965
+ function usePopup() {
37966
+ const [popup, setPopup] = (0, import_react16.useState)({ type: "alert", message: "", visible: false, inputValue: "" });
37967
+ function alert2(message) {
37968
+ return new Promise((resolve) => {
37969
+ setPopup({
37970
+ type: "alert",
37971
+ message,
37972
+ visible: true,
37973
+ inputValue: "",
37974
+ onConfirm: () => resolve()
37975
+ });
37976
+ });
37977
+ }
37978
+ function confirm(message) {
37979
+ return new Promise((resolve) => {
37980
+ setPopup({
37981
+ type: "confirm",
37982
+ message,
37983
+ visible: true,
37984
+ inputValue: "",
37985
+ onConfirm: () => resolve(true),
37986
+ onCancel: () => resolve(false)
37987
+ });
37988
+ });
37989
+ }
37990
+ function prompt(message) {
37991
+ return new Promise((resolve) => {
37992
+ setPopup({
37993
+ type: "prompt",
37994
+ message,
37995
+ visible: true,
37996
+ inputValue: "",
37997
+ onConfirm: (value) => resolve(value != null ? value : ""),
37998
+ onCancel: () => resolve(null)
37999
+ });
38000
+ });
38001
+ }
38002
+ function close(confirmed, value) {
38003
+ setPopup((prev) => {
38004
+ var _a, _b;
38005
+ if (confirmed) (_a = prev.onConfirm) == null ? void 0 : _a.call(prev, value);
38006
+ else (_b = prev.onCancel) == null ? void 0 : _b.call(prev);
38007
+ return { ...prev, visible: false, inputValue: "" };
38008
+ });
38009
+ }
38010
+ const PopupComponent = popup.visible ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
38011
+ "div",
38012
+ {
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
+ },
38025
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
38026
+ "div",
38027
+ {
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
+ },
38036
+ 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)(
38039
+ "input",
38040
+ {
38041
+ autoFocus: true,
38042
+ type: "text",
38043
+ value: popup.inputValue,
38044
+ onChange: (e) => setPopup((prev) => ({ ...prev, inputValue: e.target.value })),
38045
+ 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
+ }
38055
+ }
38056
+ ),
38057
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { style: { display: "flex", gap: "8px", justifyContent: "center" }, children: [
38058
+ (popup.type === "confirm" || popup.type === "prompt") && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
38059
+ "button",
38060
+ {
38061
+ 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
+ },
38071
+ children: "Cancelar"
38072
+ }
38073
+ ),
38074
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
38075
+ "button",
38076
+ {
38077
+ 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"
38088
+ }
38089
+ )
38090
+ ] })
38091
+ ]
38092
+ }
38093
+ )
38094
+ }
38095
+ ) : null;
38096
+ return { alert: alert2, confirm, prompt, PopupComponent };
38097
+ }
37960
38098
  // Annotate the CommonJS export names for ESM import in node:
37961
38099
  0 && (module.exports = {
37962
38100
  Alert,
@@ -37976,6 +38114,7 @@ function Table3({
37976
38114
  useDates,
37977
38115
  useExcel,
37978
38116
  useFormValues,
38117
+ usePopup,
37979
38118
  useResources
37980
38119
  });
37981
38120
  /*! Bundled license information:
package/dist/index.mjs CHANGED
@@ -37952,6 +37952,143 @@ function Table3({
37952
37952
  ] })
37953
37953
  ] });
37954
37954
  }
37955
+
37956
+ // src/pop/index.tsx
37957
+ import { useState as useState13 } from "react";
37958
+ import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
37959
+ function usePopup() {
37960
+ const [popup, setPopup] = useState13({ type: "alert", message: "", visible: false, inputValue: "" });
37961
+ function alert2(message) {
37962
+ return new Promise((resolve) => {
37963
+ setPopup({
37964
+ type: "alert",
37965
+ message,
37966
+ visible: true,
37967
+ inputValue: "",
37968
+ onConfirm: () => resolve()
37969
+ });
37970
+ });
37971
+ }
37972
+ function confirm(message) {
37973
+ return new Promise((resolve) => {
37974
+ setPopup({
37975
+ type: "confirm",
37976
+ message,
37977
+ visible: true,
37978
+ inputValue: "",
37979
+ onConfirm: () => resolve(true),
37980
+ onCancel: () => resolve(false)
37981
+ });
37982
+ });
37983
+ }
37984
+ function prompt(message) {
37985
+ return new Promise((resolve) => {
37986
+ setPopup({
37987
+ type: "prompt",
37988
+ message,
37989
+ visible: true,
37990
+ inputValue: "",
37991
+ onConfirm: (value) => resolve(value != null ? value : ""),
37992
+ onCancel: () => resolve(null)
37993
+ });
37994
+ });
37995
+ }
37996
+ function close(confirmed, value) {
37997
+ setPopup((prev) => {
37998
+ var _a, _b;
37999
+ if (confirmed) (_a = prev.onConfirm) == null ? void 0 : _a.call(prev, value);
38000
+ else (_b = prev.onCancel) == null ? void 0 : _b.call(prev);
38001
+ return { ...prev, visible: false, inputValue: "" };
38002
+ });
38003
+ }
38004
+ const PopupComponent = popup.visible ? /* @__PURE__ */ jsx27(
38005
+ "div",
38006
+ {
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
+ },
38019
+ children: /* @__PURE__ */ jsxs19(
38020
+ "div",
38021
+ {
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
+ },
38030
+ children: [
38031
+ /* @__PURE__ */ jsx27("p", { style: { margin: "0 0 16px", fontSize: "16px" }, children: popup.message }),
38032
+ popup.type === "prompt" && /* @__PURE__ */ jsx27(
38033
+ "input",
38034
+ {
38035
+ autoFocus: true,
38036
+ type: "text",
38037
+ value: popup.inputValue,
38038
+ onChange: (e) => setPopup((prev) => ({ ...prev, inputValue: e.target.value })),
38039
+ 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
+ }
38049
+ }
38050
+ ),
38051
+ /* @__PURE__ */ jsxs19("div", { style: { display: "flex", gap: "8px", justifyContent: "center" }, children: [
38052
+ (popup.type === "confirm" || popup.type === "prompt") && /* @__PURE__ */ jsx27(
38053
+ "button",
38054
+ {
38055
+ 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
+ },
38065
+ children: "Cancelar"
38066
+ }
38067
+ ),
38068
+ /* @__PURE__ */ jsx27(
38069
+ "button",
38070
+ {
38071
+ 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"
38082
+ }
38083
+ )
38084
+ ] })
38085
+ ]
38086
+ }
38087
+ )
38088
+ }
38089
+ ) : null;
38090
+ return { alert: alert2, confirm, prompt, PopupComponent };
38091
+ }
37955
38092
  export {
37956
38093
  Alert,
37957
38094
  Button,
@@ -37970,6 +38107,7 @@ export {
37970
38107
  useDates,
37971
38108
  useExcel,
37972
38109
  useFormValues,
38110
+ usePopup,
37973
38111
  useResources
37974
38112
  };
37975
38113
  /*! Bundled license information:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "description nueva",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.tsx CHANGED
@@ -18,3 +18,4 @@ export { default as MyCalendar } from "./calendar";
18
18
  export { useFormValues } from "./form";
19
19
  export { default as DocumentViewer } from "./doc-viewer";
20
20
  export { default as Table3 } from "./table3";
21
+ export { default as usePopup } from "./pop";
@@ -0,0 +1,147 @@
1
+ "use client";
2
+ import { useState } from "react";
3
+
4
+ export default function usePopup() {
5
+ const [popup, setPopup] = useState<{
6
+ type: "alert" | "confirm" | "prompt";
7
+ message: string;
8
+ visible: boolean;
9
+ inputValue: string;
10
+ onConfirm?: (value?: string) => void;
11
+ onCancel?: () => void;
12
+ }>({ type: "alert", message: "", visible: false, inputValue: "" });
13
+
14
+ function alert(message: string): Promise<void> {
15
+ return new Promise((resolve) => {
16
+ setPopup({
17
+ type: "alert",
18
+ message,
19
+ visible: true,
20
+ inputValue: "",
21
+ onConfirm: () => resolve(),
22
+ });
23
+ });
24
+ }
25
+
26
+ function confirm(message: string): Promise<boolean> {
27
+ return new Promise((resolve) => {
28
+ setPopup({
29
+ type: "confirm",
30
+ message,
31
+ visible: true,
32
+ inputValue: "",
33
+ onConfirm: () => resolve(true),
34
+ onCancel: () => resolve(false),
35
+ });
36
+ });
37
+ }
38
+
39
+ function prompt(message: string): Promise<string | null> {
40
+ return new Promise((resolve) => {
41
+ setPopup({
42
+ type: "prompt",
43
+ message,
44
+ visible: true,
45
+ inputValue: "",
46
+ onConfirm: (value) => resolve(value ?? ""),
47
+ onCancel: () => resolve(null),
48
+ });
49
+ });
50
+ }
51
+
52
+ function close(confirmed: boolean, value?: string) {
53
+ setPopup((prev) => {
54
+ if (confirmed) prev.onConfirm?.(value);
55
+ else prev.onCancel?.();
56
+ return { ...prev, visible: false, inputValue: "" };
57
+ });
58
+ }
59
+
60
+ const PopupComponent = popup.visible ? (
61
+ <div
62
+ style={{
63
+ position: "fixed",
64
+ top: 0,
65
+ left: 0,
66
+ width: "100%",
67
+ height: "100%",
68
+ background: "rgba(0,0,0,0.5)",
69
+ display: "flex",
70
+ alignItems: "center",
71
+ justifyContent: "center",
72
+ zIndex: 1000,
73
+ }}
74
+ >
75
+ <div
76
+ style={{
77
+ background: "#fff",
78
+ padding: "24px 32px",
79
+ borderRadius: "8px",
80
+ minWidth: "300px",
81
+ textAlign: "center",
82
+ boxShadow: "0 4px 20px rgba(0,0,0,0.2)",
83
+ }}
84
+ >
85
+ <p style={{ margin: "0 0 16px", fontSize: "16px" }}>{popup.message}</p>
86
+
87
+ {popup.type === "prompt" && (
88
+ <input
89
+ autoFocus
90
+ type="text"
91
+ value={popup.inputValue}
92
+ onChange={(e) =>
93
+ setPopup((prev) => ({ ...prev, inputValue: e.target.value }))
94
+ }
95
+ onKeyDown={(e) =>
96
+ e.key === "Enter" && close(true, popup.inputValue)
97
+ }
98
+ style={{
99
+ width: "100%",
100
+ padding: "8px 12px",
101
+ marginBottom: "16px",
102
+ border: "1px solid #d1d5db",
103
+ borderRadius: "6px",
104
+ fontSize: "14px",
105
+ boxSizing: "border-box",
106
+ }}
107
+ />
108
+ )}
109
+
110
+ <div style={{ display: "flex", gap: "8px", justifyContent: "center" }}>
111
+ {(popup.type === "confirm" || popup.type === "prompt") && (
112
+ <button
113
+ onClick={() => close(false)}
114
+ style={{
115
+ padding: "8px 24px",
116
+ background: "#e5e7eb",
117
+ color: "#374151",
118
+ border: "none",
119
+ borderRadius: "6px",
120
+ cursor: "pointer",
121
+ fontSize: "14px",
122
+ }}
123
+ >
124
+ Cancelar
125
+ </button>
126
+ )}
127
+ <button
128
+ onClick={() => close(true, popup.inputValue)}
129
+ style={{
130
+ padding: "8px 24px",
131
+ background: "#3b82f6",
132
+ color: "#fff",
133
+ border: "none",
134
+ borderRadius: "6px",
135
+ cursor: "pointer",
136
+ fontSize: "14px",
137
+ }}
138
+ >
139
+ OK
140
+ </button>
141
+ </div>
142
+ </div>
143
+ </div>
144
+ ) : null;
145
+
146
+ return { alert, confirm, prompt, PopupComponent };
147
+ }