next-recomponents 1.1.9 → 1.2.0
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 +12 -7
- package/dist/index.mjs +13 -8
- package/package.json +1 -1
- package/src/modal/index.tsx +21 -16
package/dist/index.js
CHANGED
|
@@ -32702,25 +32702,30 @@ function Modal({ button, children }) {
|
|
|
32702
32702
|
var _a;
|
|
32703
32703
|
(_a = modalRef.current) == null ? void 0 : _a.close();
|
|
32704
32704
|
}
|
|
32705
|
-
|
|
32706
|
-
import_react31.default.cloneElement(
|
|
32705
|
+
const newChildren = (0, import_react31.useMemo)(() => {
|
|
32706
|
+
return children && import_react31.default.cloneElement(children, { hide });
|
|
32707
|
+
}, [children]);
|
|
32708
|
+
const newButton = (0, import_react31.useMemo)(() => {
|
|
32709
|
+
return button && import_react31.default.cloneElement(button, {
|
|
32707
32710
|
onClick: (e) => {
|
|
32708
32711
|
var _a, _b;
|
|
32709
32712
|
show();
|
|
32710
32713
|
(_b = (_a = button.props).onClick) == null ? void 0 : _b.call(_a, e);
|
|
32711
32714
|
}
|
|
32712
|
-
})
|
|
32715
|
+
});
|
|
32716
|
+
}, [button]);
|
|
32717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
32718
|
+
newButton,
|
|
32713
32719
|
/* @__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
32720
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
32715
|
-
|
|
32721
|
+
"button",
|
|
32716
32722
|
{
|
|
32717
32723
|
onClick: hide,
|
|
32718
|
-
|
|
32719
|
-
className: "absolute top-0 right-0 ",
|
|
32724
|
+
className: "absolute top-0 right-0 text-red-500 ",
|
|
32720
32725
|
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CloseIcon, {})
|
|
32721
32726
|
}
|
|
32722
32727
|
),
|
|
32723
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-col gap-3 pt-6", children:
|
|
32728
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-col gap-3 pt-6", children: newChildren })
|
|
32724
32729
|
] }) })
|
|
32725
32730
|
] });
|
|
32726
32731
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -32687,7 +32687,7 @@ function Select(_a) {
|
|
|
32687
32687
|
}
|
|
32688
32688
|
|
|
32689
32689
|
// src/modal/index.tsx
|
|
32690
|
-
import React6, { useRef as useRef6 } from "react";
|
|
32690
|
+
import React6, { useMemo as useMemo10, useRef as useRef6 } from "react";
|
|
32691
32691
|
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
32692
32692
|
function Modal({ button, children }) {
|
|
32693
32693
|
const modalRef = useRef6(null);
|
|
@@ -32699,25 +32699,30 @@ function Modal({ button, children }) {
|
|
|
32699
32699
|
var _a;
|
|
32700
32700
|
(_a = modalRef.current) == null ? void 0 : _a.close();
|
|
32701
32701
|
}
|
|
32702
|
-
|
|
32703
|
-
React6.cloneElement(
|
|
32702
|
+
const newChildren = useMemo10(() => {
|
|
32703
|
+
return children && React6.cloneElement(children, { hide });
|
|
32704
|
+
}, [children]);
|
|
32705
|
+
const newButton = useMemo10(() => {
|
|
32706
|
+
return button && React6.cloneElement(button, {
|
|
32704
32707
|
onClick: (e) => {
|
|
32705
32708
|
var _a, _b;
|
|
32706
32709
|
show();
|
|
32707
32710
|
(_b = (_a = button.props).onClick) == null ? void 0 : _b.call(_a, e);
|
|
32708
32711
|
}
|
|
32709
|
-
})
|
|
32712
|
+
});
|
|
32713
|
+
}, [button]);
|
|
32714
|
+
return /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
32715
|
+
newButton,
|
|
32710
32716
|
/* @__PURE__ */ jsx17("dialog", { ref: modalRef, className: "p-5 border shadow rounded", children: /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
|
|
32711
32717
|
/* @__PURE__ */ jsx17(
|
|
32712
|
-
|
|
32718
|
+
"button",
|
|
32713
32719
|
{
|
|
32714
32720
|
onClick: hide,
|
|
32715
|
-
|
|
32716
|
-
className: "absolute top-0 right-0 ",
|
|
32721
|
+
className: "absolute top-0 right-0 text-red-500 ",
|
|
32717
32722
|
children: /* @__PURE__ */ jsx17(CloseIcon, {})
|
|
32718
32723
|
}
|
|
32719
32724
|
),
|
|
32720
|
-
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3 pt-6", children:
|
|
32725
|
+
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3 pt-6", children: newChildren })
|
|
32721
32726
|
] }) })
|
|
32722
32727
|
] });
|
|
32723
32728
|
}
|
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>,
|
|
@@ -16,30 +15,36 @@ export default function Modal({ button, children }: Props) {
|
|
|
16
15
|
function hide() {
|
|
17
16
|
modalRef.current?.close();
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const newChildren = useMemo(() => {
|
|
19
|
+
return (
|
|
20
|
+
children && React.cloneElement(children as React.ReactElement, { hide })
|
|
21
|
+
);
|
|
22
|
+
}, [children]);
|
|
23
|
+
const newButton = useMemo(() => {
|
|
24
|
+
return (
|
|
25
|
+
button &&
|
|
26
|
+
React.cloneElement(button, {
|
|
23
27
|
onClick: (e: any) => {
|
|
24
28
|
show();
|
|
25
29
|
button.props.onClick?.(e);
|
|
26
30
|
},
|
|
27
|
-
})
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
}, [button]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
{newButton}
|
|
28
38
|
<dialog ref={modalRef} className="p-5 border shadow rounded">
|
|
29
39
|
<div className="relative">
|
|
30
40
|
{/* Botón de cerrar en la esquina superior derecha */}
|
|
31
|
-
<
|
|
41
|
+
<button
|
|
32
42
|
onClick={hide}
|
|
33
|
-
|
|
34
|
-
className="absolute top-0 right-0 "
|
|
43
|
+
className="absolute top-0 right-0 text-red-500 "
|
|
35
44
|
>
|
|
36
45
|
<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>
|
|
46
|
+
</button>
|
|
47
|
+
<div className="flex flex-col gap-3 pt-6">{newChildren}</div>
|
|
43
48
|
</div>
|
|
44
49
|
</dialog>
|
|
45
50
|
</>
|