@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/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/api.mjs +2 -2
- package/dist/{chunk-NIGHV7RT.mjs → chunk-KDVKIXOS.mjs} +89 -83
- package/dist/chunk-KDVKIXOS.mjs.map +1 -0
- package/dist/{chunk-SPVA3A6Z.mjs → chunk-M5LCJX2T.mjs} +2 -2
- package/dist/components.js +1 -1
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +1 -1
- package/dist/hooks.js +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +1 -1
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/ui.js +1 -1
- package/dist/ui.js.map +1 -1
- package/dist/ui.mjs +1 -1
- package/example/src/pages/UI/components/Modal.tsx +38 -0
- package/example/src/pages/UI/index.tsx +2 -0
- package/package.json +1 -1
- package/dist/chunk-NIGHV7RT.mjs.map +0 -1
- /package/dist/{chunk-SPVA3A6Z.mjs.map → chunk-M5LCJX2T.mjs.map} +0 -0
package/dist/hooks.mjs
CHANGED
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 =
|
|
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
|
-
|
|
5988
|
-
|
|
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
|
|
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
|
|
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.
|
|
6033
|
+
const modalElements = modalState.modals.map(
|
|
6028
6034
|
(modal) => modal.visible ? (0, import_react_dom.createPortal)(
|
|
6029
|
-
|
|
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
|
);
|