next-recomponents 2.0.15 → 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,16 +37123,18 @@ 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]);
37129
- const props = children == null ? void 0 : children.props;
37131
+ const props = button == null ? void 0 : button.props;
37130
37132
  const onClick = props == null ? void 0 : props.onClick;
37131
37133
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
37132
37134
  (0, import_react10.cloneElement)(button, {
37133
37135
  onClick: (e) => {
37134
37136
  onClick == null ? void 0 : onClick(e);
37135
- pop.modal(children, color, false, true);
37137
+ pop.modal(childrenWithHide, color, false, true);
37136
37138
  }
37137
37139
  }),
37138
37140
  pop.PopupComponent
package/dist/index.mjs CHANGED
@@ -37109,16 +37109,18 @@ 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]);
37115
- const props = children == null ? void 0 : children.props;
37117
+ const props = button == null ? void 0 : button.props;
37116
37118
  const onClick = props == null ? void 0 : props.onClick;
37117
37119
  return /* @__PURE__ */ jsxs10(Fragment2, { children: [
37118
37120
  cloneElement2(button, {
37119
37121
  onClick: (e) => {
37120
37122
  onClick == null ? void 0 : onClick(e);
37121
- pop.modal(children, color, false, true);
37123
+ pop.modal(childrenWithHide, color, false, true);
37122
37124
  }
37123
37125
  }),
37124
37126
  pop.PopupComponent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.15",
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,20 +23,24 @@ 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]);
31
- const props = children?.props;
32
+ pop.updateMessage(childrenWithHide);
33
+ }, [children]); // children como dep para detectar cambios del padre
34
+
35
+ const props = button?.props;
32
36
  const onClick = props?.onClick;
37
+
33
38
  return (
34
39
  <>
35
40
  {cloneElement(button, {
36
41
  onClick: (e) => {
37
42
  onClick?.(e as any);
38
- pop.modal(children, color, false, true);
43
+ pop.modal(childrenWithHide, color, false, true);
39
44
  },
40
45
  })}
41
46
  {pop.PopupComponent}