next-recomponents 1.2.1 → 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 +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +20 -4
- package/dist/index.mjs +20 -4
- package/package.json +1 -1
- package/src/modal/index.tsx +24 -6
package/dist/index.d.mts
CHANGED
|
@@ -125,7 +125,12 @@ 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
135
|
declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
|
|
131
136
|
|
package/dist/index.d.ts
CHANGED
|
@@ -125,7 +125,12 @@ 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
135
|
declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
|
|
131
136
|
|
package/dist/index.js
CHANGED
|
@@ -32690,7 +32690,7 @@ function Select(_a) {
|
|
|
32690
32690
|
}
|
|
32691
32691
|
|
|
32692
32692
|
// src/modal/index.tsx
|
|
32693
|
-
var import_react31 = require("react");
|
|
32693
|
+
var import_react31 = __toESM(require("react"));
|
|
32694
32694
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
32695
32695
|
function Modal({ button, children, ref }) {
|
|
32696
32696
|
const modalRef = ref || (0, import_react31.useRef)(null);
|
|
@@ -32703,17 +32703,33 @@ function Modal({ button, children, ref }) {
|
|
|
32703
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
|
-
button,
|
|
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
|
+
}),
|
|
32707
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: [
|
|
32708
32719
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
32709
32720
|
"button",
|
|
32710
32721
|
{
|
|
32711
32722
|
onClick: hide,
|
|
32712
32723
|
className: "absolute top-0 right-0 text-red-500 ",
|
|
32713
|
-
children:
|
|
32724
|
+
children: "X"
|
|
32714
32725
|
}
|
|
32715
32726
|
),
|
|
32716
|
-
/* @__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
|
+
}) })
|
|
32717
32733
|
] }) })
|
|
32718
32734
|
] });
|
|
32719
32735
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -32687,7 +32687,7 @@ function Select(_a) {
|
|
|
32687
32687
|
}
|
|
32688
32688
|
|
|
32689
32689
|
// src/modal/index.tsx
|
|
32690
|
-
import { useRef as useRef6 } from "react";
|
|
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
32692
|
function Modal({ button, children, ref }) {
|
|
32693
32693
|
const modalRef = ref || useRef6(null);
|
|
@@ -32700,17 +32700,33 @@ function Modal({ button, children, ref }) {
|
|
|
32700
32700
|
typeof modalRef == "object" && ((_a = modalRef.current) == null ? void 0 : _a.close());
|
|
32701
32701
|
}
|
|
32702
32702
|
return /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
32703
|
-
button,
|
|
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
|
+
}),
|
|
32704
32715
|
/* @__PURE__ */ jsx17("dialog", { ref: modalRef, className: "p-5 border shadow rounded", children: /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
|
|
32705
32716
|
/* @__PURE__ */ jsx17(
|
|
32706
32717
|
"button",
|
|
32707
32718
|
{
|
|
32708
32719
|
onClick: hide,
|
|
32709
32720
|
className: "absolute top-0 right-0 text-red-500 ",
|
|
32710
|
-
children:
|
|
32721
|
+
children: "X"
|
|
32711
32722
|
}
|
|
32712
32723
|
),
|
|
32713
|
-
/* @__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
|
+
}) })
|
|
32714
32730
|
] }) })
|
|
32715
32731
|
] });
|
|
32716
32732
|
}
|
package/package.json
CHANGED
package/src/modal/index.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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
11
|
export default function Modal({ button, children, ref }: Props) {
|
|
11
12
|
const modalRef = ref || useRef<HTMLDialogElement>(null);
|
|
@@ -18,7 +19,17 @@ export default function Modal({ button, children, ref }: Props) {
|
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
21
|
<>
|
|
21
|
-
{button
|
|
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
|
+
})}
|
|
22
33
|
<dialog ref={modalRef} className="p-5 border shadow rounded">
|
|
23
34
|
<div className="relative">
|
|
24
35
|
{/* Botón de cerrar en la esquina superior derecha */}
|
|
@@ -26,9 +37,16 @@ export default function Modal({ button, children, ref }: Props) {
|
|
|
26
37
|
onClick={hide}
|
|
27
38
|
className="absolute top-0 right-0 text-red-500 "
|
|
28
39
|
>
|
|
29
|
-
|
|
40
|
+
X
|
|
30
41
|
</button>
|
|
31
|
-
<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>
|
|
32
50
|
</div>
|
|
33
51
|
</dialog>
|
|
34
52
|
</>
|