next-recomponents 1.1.9 → 1.2.1
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -16
- package/dist/index.mjs +9 -16
- package/package.json +1 -1
- package/src/modal/index.tsx +10 -21
package/dist/index.d.mts
CHANGED
|
@@ -127,6 +127,6 @@ declare function Select({ label, placeholder, children, strictMode, ...props }:
|
|
|
127
127
|
interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
128
128
|
button: React$1.ReactElement;
|
|
129
129
|
}
|
|
130
|
-
declare function Modal({ button, children }: Props): react_jsx_runtime.JSX.Element;
|
|
130
|
+
declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
|
|
131
131
|
|
|
132
132
|
export { Alert, Button, Container, Form, Input, Modal, Select, Table, TextArea, regularExpresions, useResources };
|
package/dist/index.d.ts
CHANGED
|
@@ -127,6 +127,6 @@ declare function Select({ label, placeholder, children, strictMode, ...props }:
|
|
|
127
127
|
interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
128
128
|
button: React$1.ReactElement;
|
|
129
129
|
}
|
|
130
|
-
declare function Modal({ button, children }: Props): react_jsx_runtime.JSX.Element;
|
|
130
|
+
declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
|
|
131
131
|
|
|
132
132
|
export { Alert, Button, Container, Form, Input, Modal, Select, Table, TextArea, regularExpresions, useResources };
|
package/dist/index.js
CHANGED
|
@@ -32690,37 +32690,30 @@ function Select(_a) {
|
|
|
32690
32690
|
}
|
|
32691
32691
|
|
|
32692
32692
|
// src/modal/index.tsx
|
|
32693
|
-
var import_react31 =
|
|
32693
|
+
var import_react31 = require("react");
|
|
32694
32694
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
32695
|
-
function Modal({ button, children }) {
|
|
32696
|
-
const modalRef = (0, import_react31.useRef)(null);
|
|
32695
|
+
function Modal({ button, children, ref }) {
|
|
32696
|
+
const modalRef = ref || (0, import_react31.useRef)(null);
|
|
32697
32697
|
function show() {
|
|
32698
32698
|
var _a;
|
|
32699
|
-
(_a = modalRef.current) == null ? void 0 : _a.showModal();
|
|
32699
|
+
typeof modalRef == "object" && ((_a = modalRef.current) == null ? void 0 : _a.showModal());
|
|
32700
32700
|
}
|
|
32701
32701
|
function hide() {
|
|
32702
32702
|
var _a;
|
|
32703
|
-
(_a = modalRef.current) == null ? void 0 : _a.close();
|
|
32703
|
+
typeof modalRef == "object" && ((_a = modalRef.current) == null ? void 0 : _a.close());
|
|
32704
32704
|
}
|
|
32705
32705
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
32706
|
-
|
|
32707
|
-
onClick: (e) => {
|
|
32708
|
-
var _a, _b;
|
|
32709
|
-
show();
|
|
32710
|
-
(_b = (_a = button.props).onClick) == null ? void 0 : _b.call(_a, e);
|
|
32711
|
-
}
|
|
32712
|
-
}),
|
|
32706
|
+
button,
|
|
32713
32707
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("dialog", { ref: modalRef, className: "p-5 border shadow rounded", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative", children: [
|
|
32714
32708
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
32715
|
-
|
|
32709
|
+
"button",
|
|
32716
32710
|
{
|
|
32717
32711
|
onClick: hide,
|
|
32718
|
-
|
|
32719
|
-
className: "absolute top-0 right-0 ",
|
|
32712
|
+
className: "absolute top-0 right-0 text-red-500 ",
|
|
32720
32713
|
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CloseIcon, {})
|
|
32721
32714
|
}
|
|
32722
32715
|
),
|
|
32723
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-col gap-3 pt-6", children
|
|
32716
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-col gap-3 pt-6", children })
|
|
32724
32717
|
] }) })
|
|
32725
32718
|
] });
|
|
32726
32719
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -32687,37 +32687,30 @@ function Select(_a) {
|
|
|
32687
32687
|
}
|
|
32688
32688
|
|
|
32689
32689
|
// src/modal/index.tsx
|
|
32690
|
-
import
|
|
32690
|
+
import { useRef as useRef6 } from "react";
|
|
32691
32691
|
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
32692
|
-
function Modal({ button, children }) {
|
|
32693
|
-
const modalRef = useRef6(null);
|
|
32692
|
+
function Modal({ button, children, ref }) {
|
|
32693
|
+
const modalRef = ref || useRef6(null);
|
|
32694
32694
|
function show() {
|
|
32695
32695
|
var _a;
|
|
32696
|
-
(_a = modalRef.current) == null ? void 0 : _a.showModal();
|
|
32696
|
+
typeof modalRef == "object" && ((_a = modalRef.current) == null ? void 0 : _a.showModal());
|
|
32697
32697
|
}
|
|
32698
32698
|
function hide() {
|
|
32699
32699
|
var _a;
|
|
32700
|
-
(_a = modalRef.current) == null ? void 0 : _a.close();
|
|
32700
|
+
typeof modalRef == "object" && ((_a = modalRef.current) == null ? void 0 : _a.close());
|
|
32701
32701
|
}
|
|
32702
32702
|
return /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
32703
|
-
|
|
32704
|
-
onClick: (e) => {
|
|
32705
|
-
var _a, _b;
|
|
32706
|
-
show();
|
|
32707
|
-
(_b = (_a = button.props).onClick) == null ? void 0 : _b.call(_a, e);
|
|
32708
|
-
}
|
|
32709
|
-
}),
|
|
32703
|
+
button,
|
|
32710
32704
|
/* @__PURE__ */ jsx17("dialog", { ref: modalRef, className: "p-5 border shadow rounded", children: /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
|
|
32711
32705
|
/* @__PURE__ */ jsx17(
|
|
32712
|
-
|
|
32706
|
+
"button",
|
|
32713
32707
|
{
|
|
32714
32708
|
onClick: hide,
|
|
32715
|
-
|
|
32716
|
-
className: "absolute top-0 right-0 ",
|
|
32709
|
+
className: "absolute top-0 right-0 text-red-500 ",
|
|
32717
32710
|
children: /* @__PURE__ */ jsx17(CloseIcon, {})
|
|
32718
32711
|
}
|
|
32719
32712
|
),
|
|
32720
|
-
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3 pt-6", children
|
|
32713
|
+
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3 pt-6", children })
|
|
32721
32714
|
] }) })
|
|
32722
32715
|
] });
|
|
32723
32716
|
}
|
package/package.json
CHANGED
package/src/modal/index.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { useRef } from "react";
|
|
1
|
+
import React, { useMemo, useRef } from "react";
|
|
2
2
|
import CloseIcon from "../select/close";
|
|
3
|
-
import { Button } from "..";
|
|
4
3
|
interface Props
|
|
5
4
|
extends React.DetailedHTMLProps<
|
|
6
5
|
React.DialogHTMLAttributes<HTMLDialogElement>,
|
|
@@ -8,38 +7,28 @@ interface Props
|
|
|
8
7
|
> {
|
|
9
8
|
button: React.ReactElement;
|
|
10
9
|
}
|
|
11
|
-
export default function Modal({ button, children }: Props) {
|
|
12
|
-
const modalRef = useRef<HTMLDialogElement>(null);
|
|
10
|
+
export default function Modal({ button, children, ref }: Props) {
|
|
11
|
+
const modalRef = ref || useRef<HTMLDialogElement>(null);
|
|
13
12
|
function show() {
|
|
14
|
-
modalRef.current?.showModal();
|
|
13
|
+
typeof modalRef == "object" && modalRef.current?.showModal();
|
|
15
14
|
}
|
|
16
15
|
function hide() {
|
|
17
|
-
modalRef.current?.close();
|
|
16
|
+
typeof modalRef == "object" && modalRef.current?.close();
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
return (
|
|
21
20
|
<>
|
|
22
|
-
{
|
|
23
|
-
onClick: (e: any) => {
|
|
24
|
-
show();
|
|
25
|
-
button.props.onClick?.(e);
|
|
26
|
-
},
|
|
27
|
-
})}
|
|
21
|
+
{button}
|
|
28
22
|
<dialog ref={modalRef} className="p-5 border shadow rounded">
|
|
29
23
|
<div className="relative">
|
|
30
24
|
{/* Botón de cerrar en la esquina superior derecha */}
|
|
31
|
-
<
|
|
25
|
+
<button
|
|
32
26
|
onClick={hide}
|
|
33
|
-
|
|
34
|
-
className="absolute top-0 right-0 "
|
|
27
|
+
className="absolute top-0 right-0 text-red-500 "
|
|
35
28
|
>
|
|
36
29
|
<CloseIcon />
|
|
37
|
-
</
|
|
38
|
-
|
|
39
|
-
<div className="flex flex-col gap-3 pt-6">
|
|
40
|
-
{children &&
|
|
41
|
-
React.cloneElement(children as React.ReactElement, { hide })}
|
|
42
|
-
</div>
|
|
30
|
+
</button>
|
|
31
|
+
<div className="flex flex-col gap-3 pt-6">{children}</div>
|
|
43
32
|
</div>
|
|
44
33
|
</dialog>
|
|
45
34
|
</>
|