next-recomponents 2.0.14 → 2.0.16

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 CHANGED
@@ -37123,12 +37123,19 @@ function Modal({
37123
37123
  color = "primary"
37124
37124
  }) {
37125
37125
  const pop = usePopup();
37126
+ const hide = () => pop.close(false);
37127
+ const childrenWithHide = (0, import_react10.cloneElement)(children, { hide });
37126
37128
  (0, import_react10.useEffect)(() => {
37127
- pop.updateMessage(children);
37129
+ pop.updateMessage(childrenWithHide);
37128
37130
  }, [children]);
37131
+ const props = button == null ? void 0 : button.props;
37132
+ const onClick = props == null ? void 0 : props.onClick;
37129
37133
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
37130
37134
  (0, import_react10.cloneElement)(button, {
37131
- onClick: () => pop.modal(children, color, false, true)
37135
+ onClick: (e) => {
37136
+ onClick == null ? void 0 : onClick(e);
37137
+ pop.modal(childrenWithHide, color, false, true);
37138
+ }
37132
37139
  }),
37133
37140
  pop.PopupComponent
37134
37141
  ] });
package/dist/index.mjs CHANGED
@@ -37109,12 +37109,19 @@ function Modal({
37109
37109
  color = "primary"
37110
37110
  }) {
37111
37111
  const pop = usePopup();
37112
+ const hide = () => pop.close(false);
37113
+ const childrenWithHide = cloneElement2(children, { hide });
37112
37114
  useEffect6(() => {
37113
- pop.updateMessage(children);
37115
+ pop.updateMessage(childrenWithHide);
37114
37116
  }, [children]);
37117
+ const props = button == null ? void 0 : button.props;
37118
+ const onClick = props == null ? void 0 : props.onClick;
37115
37119
  return /* @__PURE__ */ jsxs10(Fragment2, { children: [
37116
37120
  cloneElement2(button, {
37117
- onClick: () => pop.modal(children, color, false, true)
37121
+ onClick: (e) => {
37122
+ onClick == null ? void 0 : onClick(e);
37123
+ pop.modal(childrenWithHide, color, false, true);
37124
+ }
37118
37125
  }),
37119
37126
  pop.PopupComponent
37120
37127
  ] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
4
4
  "description": "description nueva",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +1,7 @@
1
1
  // Modal.tsx
2
2
  import React, { ReactElement, cloneElement, useEffect } from "react";
3
3
  import usePopup from "../pop";
4
+
4
5
  export type PopupColor =
5
6
  | "white"
6
7
  | "primary"
@@ -22,17 +23,25 @@ export default function Modal({
22
23
  color?: PopupColor;
23
24
  }) {
24
25
  const pop = usePopup();
26
+ const hide = () => pop.close(false);
27
+
28
+ // Inyectamos hide en children
29
+ const childrenWithHide = cloneElement(children, { hide });
25
30
 
26
- // ✅ Cada vez que children cambia (estado del padre actualizado),
27
- // propagamos el nuevo ReactNode al modal si está abierto
28
31
  useEffect(() => {
29
- pop.updateMessage(children);
30
- }, [children]);
32
+ pop.updateMessage(childrenWithHide);
33
+ }, [children]); // children como dep para detectar cambios del padre
34
+
35
+ const props = button?.props;
36
+ const onClick = props?.onClick;
31
37
 
32
38
  return (
33
39
  <>
34
40
  {cloneElement(button, {
35
- onClick: () => pop.modal(children, color, false, true),
41
+ onClick: (e) => {
42
+ onClick?.(e as any);
43
+ pop.modal(childrenWithHide, color, false, true);
44
+ },
36
45
  })}
37
46
  {pop.PopupComponent}
38
47
  </>