@shoplflow/base 0.45.15 → 0.45.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.cjs +50 -22
- package/dist/index.js +50 -22
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -905,22 +905,33 @@ var useViewportSizeObserver = () => {
|
|
|
905
905
|
return size2;
|
|
906
906
|
};
|
|
907
907
|
var ModalOptionContext = React3.createContext({
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
908
|
+
topHeight: 0,
|
|
909
|
+
bottomHeight: 0,
|
|
910
|
+
setTopHeight: utils.noop,
|
|
911
|
+
setBottomHeight: utils.noop,
|
|
912
|
+
clearTopHeight: utils.noop,
|
|
913
|
+
clearBottomHeight: utils.noop
|
|
911
914
|
});
|
|
912
915
|
var ModalOptionContextProvider = ({ children }) => {
|
|
913
|
-
const [
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
+
const [topHeight, setTopHeight] = React3.useState(0);
|
|
917
|
+
const [bottomHeight, setBottomHeight] = React3.useState(0);
|
|
918
|
+
const clearTopHeight = React3.useCallback(() => {
|
|
919
|
+
setTopHeight(0);
|
|
916
920
|
}, []);
|
|
917
|
-
const
|
|
918
|
-
|
|
921
|
+
const clearBottomHeight = React3.useCallback(() => {
|
|
922
|
+
setBottomHeight(0);
|
|
919
923
|
}, []);
|
|
920
924
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
921
925
|
ModalOptionContext.Provider,
|
|
922
926
|
{
|
|
923
|
-
value: {
|
|
927
|
+
value: {
|
|
928
|
+
topHeight,
|
|
929
|
+
bottomHeight,
|
|
930
|
+
setTopHeight,
|
|
931
|
+
setBottomHeight,
|
|
932
|
+
clearTopHeight,
|
|
933
|
+
clearBottomHeight
|
|
934
|
+
},
|
|
924
935
|
children
|
|
925
936
|
}
|
|
926
937
|
);
|
|
@@ -1012,7 +1023,8 @@ var ModalBody = ({
|
|
|
1012
1023
|
padding
|
|
1013
1024
|
}) => {
|
|
1014
1025
|
const { height: windowHeight } = useViewportSizeObserver();
|
|
1015
|
-
const {
|
|
1026
|
+
const { topHeight, bottomHeight } = useModalOption();
|
|
1027
|
+
const heightToDeduct = topHeight + bottomHeight;
|
|
1016
1028
|
const headerHeight = 64;
|
|
1017
1029
|
const footerHeight = 72;
|
|
1018
1030
|
const topBottomMargin = 64;
|
|
@@ -1110,29 +1122,45 @@ ModalHeader[exports.MODAL_HEADER_KEY] = true;
|
|
|
1110
1122
|
var ModalHeader_default = ModalHeader;
|
|
1111
1123
|
var ModalTop = ({ children }) => {
|
|
1112
1124
|
const [topRef, setTopRef] = React3.useState(null);
|
|
1113
|
-
const {
|
|
1125
|
+
const { setTopHeight, clearTopHeight } = useModalOption();
|
|
1114
1126
|
React3.useEffect(() => {
|
|
1115
|
-
if (!topRef) {
|
|
1127
|
+
if (!topRef || !setTopHeight) {
|
|
1116
1128
|
return;
|
|
1117
1129
|
}
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1130
|
+
const updateHeight = () => {
|
|
1131
|
+
const { height } = topRef.getBoundingClientRect();
|
|
1132
|
+
setTopHeight(height);
|
|
1133
|
+
};
|
|
1134
|
+
updateHeight();
|
|
1135
|
+
const resizeObserver = new ResizeObserver(updateHeight);
|
|
1136
|
+
resizeObserver.observe(topRef);
|
|
1137
|
+
return () => {
|
|
1138
|
+
resizeObserver.disconnect();
|
|
1139
|
+
clearTopHeight();
|
|
1140
|
+
};
|
|
1141
|
+
}, [topRef, setTopHeight, clearTopHeight]);
|
|
1122
1142
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setTopRef, children });
|
|
1123
1143
|
};
|
|
1124
1144
|
var ModalTop_default = ModalTop;
|
|
1125
1145
|
var ModalBottom = ({ children }) => {
|
|
1126
1146
|
const [bottomRef, setBottomRef] = React3.useState(null);
|
|
1127
|
-
const {
|
|
1147
|
+
const { setBottomHeight, clearBottomHeight } = useModalOption();
|
|
1128
1148
|
React3.useEffect(() => {
|
|
1129
|
-
if (!bottomRef) {
|
|
1149
|
+
if (!bottomRef || !setBottomHeight) {
|
|
1130
1150
|
return;
|
|
1131
1151
|
}
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1152
|
+
const updateHeight = () => {
|
|
1153
|
+
const { height } = bottomRef.getBoundingClientRect();
|
|
1154
|
+
setBottomHeight(height);
|
|
1155
|
+
};
|
|
1156
|
+
updateHeight();
|
|
1157
|
+
const resizeObserver = new ResizeObserver(updateHeight);
|
|
1158
|
+
resizeObserver.observe(bottomRef);
|
|
1159
|
+
return () => {
|
|
1160
|
+
resizeObserver.disconnect();
|
|
1161
|
+
clearBottomHeight();
|
|
1162
|
+
};
|
|
1163
|
+
}, [bottomRef, setBottomHeight, clearBottomHeight]);
|
|
1136
1164
|
return /* @__PURE__ */ jsxRuntime.jsx(BottomContainer, { ref: setBottomRef, children });
|
|
1137
1165
|
};
|
|
1138
1166
|
exports.ModalHandlerContext = React3.createContext({
|
package/dist/index.js
CHANGED
|
@@ -878,22 +878,33 @@ var useViewportSizeObserver = () => {
|
|
|
878
878
|
return size2;
|
|
879
879
|
};
|
|
880
880
|
var ModalOptionContext = createContext({
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
881
|
+
topHeight: 0,
|
|
882
|
+
bottomHeight: 0,
|
|
883
|
+
setTopHeight: noop,
|
|
884
|
+
setBottomHeight: noop,
|
|
885
|
+
clearTopHeight: noop,
|
|
886
|
+
clearBottomHeight: noop
|
|
884
887
|
});
|
|
885
888
|
var ModalOptionContextProvider = ({ children }) => {
|
|
886
|
-
const [
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
+
const [topHeight, setTopHeight] = useState(0);
|
|
890
|
+
const [bottomHeight, setBottomHeight] = useState(0);
|
|
891
|
+
const clearTopHeight = useCallback(() => {
|
|
892
|
+
setTopHeight(0);
|
|
889
893
|
}, []);
|
|
890
|
-
const
|
|
891
|
-
|
|
894
|
+
const clearBottomHeight = useCallback(() => {
|
|
895
|
+
setBottomHeight(0);
|
|
892
896
|
}, []);
|
|
893
897
|
return /* @__PURE__ */ jsx(
|
|
894
898
|
ModalOptionContext.Provider,
|
|
895
899
|
{
|
|
896
|
-
value: {
|
|
900
|
+
value: {
|
|
901
|
+
topHeight,
|
|
902
|
+
bottomHeight,
|
|
903
|
+
setTopHeight,
|
|
904
|
+
setBottomHeight,
|
|
905
|
+
clearTopHeight,
|
|
906
|
+
clearBottomHeight
|
|
907
|
+
},
|
|
897
908
|
children
|
|
898
909
|
}
|
|
899
910
|
);
|
|
@@ -985,7 +996,8 @@ var ModalBody = ({
|
|
|
985
996
|
padding
|
|
986
997
|
}) => {
|
|
987
998
|
const { height: windowHeight } = useViewportSizeObserver();
|
|
988
|
-
const {
|
|
999
|
+
const { topHeight, bottomHeight } = useModalOption();
|
|
1000
|
+
const heightToDeduct = topHeight + bottomHeight;
|
|
989
1001
|
const headerHeight = 64;
|
|
990
1002
|
const footerHeight = 72;
|
|
991
1003
|
const topBottomMargin = 64;
|
|
@@ -1083,29 +1095,45 @@ ModalHeader[MODAL_HEADER_KEY] = true;
|
|
|
1083
1095
|
var ModalHeader_default = ModalHeader;
|
|
1084
1096
|
var ModalTop = ({ children }) => {
|
|
1085
1097
|
const [topRef, setTopRef] = useState(null);
|
|
1086
|
-
const {
|
|
1098
|
+
const { setTopHeight, clearTopHeight } = useModalOption();
|
|
1087
1099
|
useEffect(() => {
|
|
1088
|
-
if (!topRef) {
|
|
1100
|
+
if (!topRef || !setTopHeight) {
|
|
1089
1101
|
return;
|
|
1090
1102
|
}
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1103
|
+
const updateHeight = () => {
|
|
1104
|
+
const { height } = topRef.getBoundingClientRect();
|
|
1105
|
+
setTopHeight(height);
|
|
1106
|
+
};
|
|
1107
|
+
updateHeight();
|
|
1108
|
+
const resizeObserver = new ResizeObserver(updateHeight);
|
|
1109
|
+
resizeObserver.observe(topRef);
|
|
1110
|
+
return () => {
|
|
1111
|
+
resizeObserver.disconnect();
|
|
1112
|
+
clearTopHeight();
|
|
1113
|
+
};
|
|
1114
|
+
}, [topRef, setTopHeight, clearTopHeight]);
|
|
1095
1115
|
return /* @__PURE__ */ jsx("div", { ref: setTopRef, children });
|
|
1096
1116
|
};
|
|
1097
1117
|
var ModalTop_default = ModalTop;
|
|
1098
1118
|
var ModalBottom = ({ children }) => {
|
|
1099
1119
|
const [bottomRef, setBottomRef] = useState(null);
|
|
1100
|
-
const {
|
|
1120
|
+
const { setBottomHeight, clearBottomHeight } = useModalOption();
|
|
1101
1121
|
useEffect(() => {
|
|
1102
|
-
if (!bottomRef) {
|
|
1122
|
+
if (!bottomRef || !setBottomHeight) {
|
|
1103
1123
|
return;
|
|
1104
1124
|
}
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1125
|
+
const updateHeight = () => {
|
|
1126
|
+
const { height } = bottomRef.getBoundingClientRect();
|
|
1127
|
+
setBottomHeight(height);
|
|
1128
|
+
};
|
|
1129
|
+
updateHeight();
|
|
1130
|
+
const resizeObserver = new ResizeObserver(updateHeight);
|
|
1131
|
+
resizeObserver.observe(bottomRef);
|
|
1132
|
+
return () => {
|
|
1133
|
+
resizeObserver.disconnect();
|
|
1134
|
+
clearBottomHeight();
|
|
1135
|
+
};
|
|
1136
|
+
}, [bottomRef, setBottomHeight, clearBottomHeight]);
|
|
1109
1137
|
return /* @__PURE__ */ jsx(BottomContainer, { ref: setBottomRef, children });
|
|
1110
1138
|
};
|
|
1111
1139
|
var ModalHandlerContext = createContext({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shoplflow/base",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"react-dom": "^18.2.0",
|
|
100
100
|
"simplebar-react": "^3.2.6",
|
|
101
101
|
"@shoplflow/hada-assets": "^0.1.10",
|
|
102
|
-
"@shoplflow/shopl-assets": "^0.12.
|
|
102
|
+
"@shoplflow/shopl-assets": "^0.12.35",
|
|
103
103
|
"@shoplflow/utils": "^0.7.2"
|
|
104
104
|
},
|
|
105
105
|
"homepage": "https://github.com/shopl/shoplflow#readme",
|