next-recomponents 1.2.0 → 1.2.2
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 +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +23 -19
- package/dist/index.mjs +24 -20
- package/package.json +1 -1
- package/src/modal/index.tsx +28 -26
package/dist/index.d.mts
CHANGED
|
@@ -125,8 +125,13 @@ interface CustomSelectProps extends React$1.DetailedHTMLProps<React$1.InputHTMLA
|
|
|
125
125
|
declare function Select({ label, placeholder, children, strictMode, ...props }: CustomSelectProps): react_jsx_runtime.JSX.Element;
|
|
126
126
|
|
|
127
127
|
interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
128
|
-
button: React$1.ReactElement
|
|
128
|
+
button: React$1.ReactElement<{
|
|
129
|
+
onClick: (e: React$1.MouseEvent) => void;
|
|
130
|
+
}>;
|
|
131
|
+
children: React$1.ReactElement<{
|
|
132
|
+
hide: () => void;
|
|
133
|
+
}>;
|
|
129
134
|
}
|
|
130
|
-
declare function Modal({ button, children }: Props): react_jsx_runtime.JSX.Element;
|
|
135
|
+
declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
|
|
131
136
|
|
|
132
137
|
export { Alert, Button, Container, Form, Input, Modal, Select, Table, TextArea, regularExpresions, useResources };
|
package/dist/index.d.ts
CHANGED
|
@@ -125,8 +125,13 @@ interface CustomSelectProps extends React$1.DetailedHTMLProps<React$1.InputHTMLA
|
|
|
125
125
|
declare function Select({ label, placeholder, children, strictMode, ...props }: CustomSelectProps): react_jsx_runtime.JSX.Element;
|
|
126
126
|
|
|
127
127
|
interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
128
|
-
button: React$1.ReactElement
|
|
128
|
+
button: React$1.ReactElement<{
|
|
129
|
+
onClick: (e: React$1.MouseEvent) => void;
|
|
130
|
+
}>;
|
|
131
|
+
children: React$1.ReactElement<{
|
|
132
|
+
hide: () => void;
|
|
133
|
+
}>;
|
|
129
134
|
}
|
|
130
|
-
declare function Modal({ button, children }: Props): react_jsx_runtime.JSX.Element;
|
|
135
|
+
declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
|
|
131
136
|
|
|
132
137
|
export { Alert, Button, Container, Form, Input, Modal, Select, Table, TextArea, regularExpresions, useResources };
|
package/dist/index.js
CHANGED
|
@@ -32692,40 +32692,44 @@ function Select(_a) {
|
|
|
32692
32692
|
// src/modal/index.tsx
|
|
32693
32693
|
var import_react31 = __toESM(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
|
-
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, {
|
|
32710
|
-
onClick: (e) => {
|
|
32711
|
-
var _a, _b;
|
|
32712
|
-
show();
|
|
32713
|
-
(_b = (_a = button.props).onClick) == null ? void 0 : _b.call(_a, e);
|
|
32714
|
-
}
|
|
32715
|
-
});
|
|
32716
|
-
}, [button]);
|
|
32717
32705
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
32718
|
-
|
|
32706
|
+
import_react31.default.Children.map(button, (child) => {
|
|
32707
|
+
if (import_react31.default.isValidElement(child)) {
|
|
32708
|
+
return import_react31.default.cloneElement(child, {
|
|
32709
|
+
onClick: (e) => {
|
|
32710
|
+
var _a, _b;
|
|
32711
|
+
show();
|
|
32712
|
+
(_b = (_a = child.props) == null ? void 0 : _a.onClick) == null ? void 0 : _b.call(_a, e);
|
|
32713
|
+
}
|
|
32714
|
+
});
|
|
32715
|
+
}
|
|
32716
|
+
return child;
|
|
32717
|
+
}),
|
|
32719
32718
|
/* @__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: [
|
|
32720
32719
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
32721
32720
|
"button",
|
|
32722
32721
|
{
|
|
32723
32722
|
onClick: hide,
|
|
32724
32723
|
className: "absolute top-0 right-0 text-red-500 ",
|
|
32725
|
-
children:
|
|
32724
|
+
children: "X"
|
|
32726
32725
|
}
|
|
32727
32726
|
),
|
|
32728
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-col gap-3 pt-6", children:
|
|
32727
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-col gap-3 pt-6", children: import_react31.default.Children.map(children, (child) => {
|
|
32728
|
+
if (import_react31.default.isValidElement(child)) {
|
|
32729
|
+
return import_react31.default.cloneElement(child, { hide });
|
|
32730
|
+
}
|
|
32731
|
+
return child;
|
|
32732
|
+
}) })
|
|
32729
32733
|
] }) })
|
|
32730
32734
|
] });
|
|
32731
32735
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -32687,42 +32687,46 @@ function Select(_a) {
|
|
|
32687
32687
|
}
|
|
32688
32688
|
|
|
32689
32689
|
// src/modal/index.tsx
|
|
32690
|
-
import React6, {
|
|
32690
|
+
import React6, { 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
|
-
const newChildren = useMemo10(() => {
|
|
32703
|
-
return children && React6.cloneElement(children, { hide });
|
|
32704
|
-
}, [children]);
|
|
32705
|
-
const newButton = useMemo10(() => {
|
|
32706
|
-
return button && React6.cloneElement(button, {
|
|
32707
|
-
onClick: (e) => {
|
|
32708
|
-
var _a, _b;
|
|
32709
|
-
show();
|
|
32710
|
-
(_b = (_a = button.props).onClick) == null ? void 0 : _b.call(_a, e);
|
|
32711
|
-
}
|
|
32712
|
-
});
|
|
32713
|
-
}, [button]);
|
|
32714
32702
|
return /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
32715
|
-
|
|
32703
|
+
React6.Children.map(button, (child) => {
|
|
32704
|
+
if (React6.isValidElement(child)) {
|
|
32705
|
+
return React6.cloneElement(child, {
|
|
32706
|
+
onClick: (e) => {
|
|
32707
|
+
var _a, _b;
|
|
32708
|
+
show();
|
|
32709
|
+
(_b = (_a = child.props) == null ? void 0 : _a.onClick) == null ? void 0 : _b.call(_a, e);
|
|
32710
|
+
}
|
|
32711
|
+
});
|
|
32712
|
+
}
|
|
32713
|
+
return child;
|
|
32714
|
+
}),
|
|
32716
32715
|
/* @__PURE__ */ jsx17("dialog", { ref: modalRef, className: "p-5 border shadow rounded", children: /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
|
|
32717
32716
|
/* @__PURE__ */ jsx17(
|
|
32718
32717
|
"button",
|
|
32719
32718
|
{
|
|
32720
32719
|
onClick: hide,
|
|
32721
32720
|
className: "absolute top-0 right-0 text-red-500 ",
|
|
32722
|
-
children:
|
|
32721
|
+
children: "X"
|
|
32723
32722
|
}
|
|
32724
32723
|
),
|
|
32725
|
-
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3 pt-6", children:
|
|
32724
|
+
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3 pt-6", children: React6.Children.map(children, (child) => {
|
|
32725
|
+
if (React6.isValidElement(child)) {
|
|
32726
|
+
return React6.cloneElement(child, { hide });
|
|
32727
|
+
}
|
|
32728
|
+
return child;
|
|
32729
|
+
}) })
|
|
32726
32730
|
] }) })
|
|
32727
32731
|
] });
|
|
32728
32732
|
}
|
package/package.json
CHANGED
package/src/modal/index.tsx
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
|
|
3
3
|
interface Props
|
|
4
4
|
extends React.DetailedHTMLProps<
|
|
5
5
|
React.DialogHTMLAttributes<HTMLDialogElement>,
|
|
6
6
|
HTMLDialogElement
|
|
7
7
|
> {
|
|
8
|
-
button: React.ReactElement
|
|
8
|
+
button: React.ReactElement<{ onClick: (e: React.MouseEvent) => void }>;
|
|
9
|
+
children: React.ReactElement<{ hide: () => void }>;
|
|
9
10
|
}
|
|
10
|
-
export default function Modal({ button, children }: Props) {
|
|
11
|
-
const modalRef = useRef<HTMLDialogElement>(null);
|
|
11
|
+
export default function Modal({ button, children, ref }: Props) {
|
|
12
|
+
const modalRef = ref || useRef<HTMLDialogElement>(null);
|
|
12
13
|
function show() {
|
|
13
|
-
modalRef.current?.showModal();
|
|
14
|
+
typeof modalRef == "object" && modalRef.current?.showModal();
|
|
14
15
|
}
|
|
15
16
|
function hide() {
|
|
16
|
-
modalRef.current?.close();
|
|
17
|
+
typeof modalRef == "object" && modalRef.current?.close();
|
|
17
18
|
}
|
|
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, {
|
|
27
|
-
onClick: (e: any) => {
|
|
28
|
-
show();
|
|
29
|
-
button.props.onClick?.(e);
|
|
30
|
-
},
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
}, [button]);
|
|
34
19
|
|
|
35
20
|
return (
|
|
36
21
|
<>
|
|
37
|
-
{
|
|
22
|
+
{React.Children.map(button, (child) => {
|
|
23
|
+
if (React.isValidElement(child)) {
|
|
24
|
+
return React.cloneElement(child, {
|
|
25
|
+
onClick: (e) => {
|
|
26
|
+
show();
|
|
27
|
+
child.props?.onClick?.(e);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return child;
|
|
32
|
+
})}
|
|
38
33
|
<dialog ref={modalRef} className="p-5 border shadow rounded">
|
|
39
34
|
<div className="relative">
|
|
40
35
|
{/* Botón de cerrar en la esquina superior derecha */}
|
|
@@ -42,9 +37,16 @@ export default function Modal({ button, children }: Props) {
|
|
|
42
37
|
onClick={hide}
|
|
43
38
|
className="absolute top-0 right-0 text-red-500 "
|
|
44
39
|
>
|
|
45
|
-
|
|
40
|
+
X
|
|
46
41
|
</button>
|
|
47
|
-
<div className="flex flex-col gap-3 pt-6">
|
|
42
|
+
<div className="flex flex-col gap-3 pt-6">
|
|
43
|
+
{React.Children.map(children, (child) => {
|
|
44
|
+
if (React.isValidElement(child)) {
|
|
45
|
+
return React.cloneElement(child, { hide });
|
|
46
|
+
}
|
|
47
|
+
return child;
|
|
48
|
+
})}
|
|
49
|
+
</div>
|
|
48
50
|
</div>
|
|
49
51
|
</dialog>
|
|
50
52
|
</>
|