@matchain/matchid-sdk-react 0.1.56-alpha.2 → 0.1.56-alpha.3

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/hooks.mjs CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  useTransaction,
15
15
  useUserInfo,
16
16
  useWallet
17
- } from "./chunk-NIGHV7RT.mjs";
17
+ } from "./chunk-KDVKIXOS.mjs";
18
18
  import "./chunk-JX73EY6V.mjs";
19
19
  import "./chunk-UA6XHZHX.mjs";
20
20
  import "./chunk-IZOOVZAD.mjs";
package/dist/index.js CHANGED
@@ -2434,7 +2434,7 @@ var import_react31 = require("react");
2434
2434
  var import_viem9 = require("viem");
2435
2435
 
2436
2436
  // src/context/ModalContext.tsx
2437
- var import_react30 = __toESM(require("react"));
2437
+ var import_react30 = require("react");
2438
2438
  var import_react_dom = require("react-dom");
2439
2439
 
2440
2440
  // src/ui/index.ts
@@ -5983,18 +5983,24 @@ function ModalProvider({ children }) {
5983
5983
  modals: [],
5984
5984
  highestZIndex: 100
5985
5985
  });
5986
+ const highestIndexRef = (0, import_react30.useRef)(100);
5986
5987
  const getNextIndex = (0, import_react30.useCallback)(() => {
5987
- return Math.max(...modalState.modals.map((modal) => modal.index), 0) + 1 || 100;
5988
- }, [modalState]);
5988
+ highestIndexRef.current += 1;
5989
+ return highestIndexRef.current;
5990
+ }, []);
5989
5991
  const closeModal = (0, import_react30.useCallback)((index) => {
5992
+ console.log("closeModal", index);
5990
5993
  setModalState((prevState) => ({
5991
5994
  modals: prevState.modals.filter((modal) => modal.index !== index),
5992
5995
  highestZIndex: prevState.highestZIndex
5993
5996
  }));
5994
5997
  }, []);
5998
+ (0, import_react30.useEffect)(() => {
5999
+ console.log("modalState", modalState);
6000
+ }, [modalState]);
5995
6001
  const show = (0, import_react30.useCallback)((content, index) => {
5996
6002
  setModalState((prevState) => {
5997
- const modalIndex = index !== void 0 ? index : getNextIndex();
6003
+ const modalIndex = index ?? getNextIndex();
5998
6004
  const newZIndex = prevState.highestZIndex + 1;
5999
6005
  return {
6000
6006
  modals: [...prevState.modals, {
@@ -6010,7 +6016,7 @@ function ModalProvider({ children }) {
6010
6016
  }, [getNextIndex, closeModal]);
6011
6017
  const open = (0, import_react30.useCallback)((props) => {
6012
6018
  setModalState((prevState) => {
6013
- const modalIndex = props.index !== void 0 ? props.index : getNextIndex();
6019
+ const modalIndex = props.index ?? getNextIndex();
6014
6020
  const newZIndex = prevState.highestZIndex + 1;
6015
6021
  return {
6016
6022
  modals: [...prevState.modals, {
@@ -6024,9 +6030,9 @@ function ModalProvider({ children }) {
6024
6030
  };
6025
6031
  });
6026
6032
  }, [getNextIndex, closeModal]);
6027
- const modalElements = modalState.modals.sort((a, b) => b.zIndex - a.zIndex).map(
6033
+ const modalElements = modalState.modals.map(
6028
6034
  (modal) => modal.visible ? (0, import_react_dom.createPortal)(
6029
- import_react30.default.createElement(modal.content, { zIndex: modal.zIndex, close: modal.close }),
6035
+ /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(modal.content, { zIndex: modal.zIndex, close: modal.close }, modal.index),
6030
6036
  document.body
6031
6037
  ) : null
6032
6038
  );