@whitesev/pops 2.0.3 → 2.0.4
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.amd.js +138 -112
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +138 -112
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +138 -112
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +138 -112
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +138 -112
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +138 -112
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +3 -3
- package/dist/types/src/components/searchSuggestion/indexType.d.ts +1 -1
- package/dist/types/src/types/event.d.ts +3 -3
- package/dist/types/src/types/mask.d.ts +1 -1
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +3 -3
- package/package.json +1 -1
- package/src/Pops.ts +1 -1
- package/src/components/loading/index.ts +3 -0
- package/src/components/searchSuggestion/indexType.ts +1 -1
- package/src/handler/PopsHandler.ts +9 -11
- package/src/types/event.d.ts +3 -3
- package/src/types/mask.d.ts +1 -1
- package/src/utils/PopsDOMUtils.ts +21 -19
- package/src/utils/PopsInstanceUtils.ts +120 -96
package/dist/index.esm.js
CHANGED
|
@@ -1219,30 +1219,32 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
1219
1219
|
if (element == null) {
|
|
1220
1220
|
return;
|
|
1221
1221
|
}
|
|
1222
|
+
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1223
|
+
if (typeof propertyValue === "string" &&
|
|
1224
|
+
propertyValue.trim().endsWith("!important")) {
|
|
1225
|
+
propertyValue = propertyValue
|
|
1226
|
+
.trim()
|
|
1227
|
+
.replace(/!important$/gi, "")
|
|
1228
|
+
.trim();
|
|
1229
|
+
element.style.setProperty(propertyName, propertyValue, "important");
|
|
1230
|
+
}
|
|
1231
|
+
else {
|
|
1232
|
+
propertyValue = handlePixe(propertyName, propertyValue);
|
|
1233
|
+
element.style.setProperty(propertyName, propertyValue);
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1222
1236
|
if (typeof property === "string") {
|
|
1223
1237
|
if (value == null) {
|
|
1224
1238
|
return getComputedStyle(element).getPropertyValue(property);
|
|
1225
1239
|
}
|
|
1226
1240
|
else {
|
|
1227
|
-
|
|
1228
|
-
element.style.setProperty(property, value, "important");
|
|
1229
|
-
}
|
|
1230
|
-
else {
|
|
1231
|
-
value = handlePixe(property, value);
|
|
1232
|
-
element.style.setProperty(property, value);
|
|
1233
|
-
}
|
|
1241
|
+
setStyleProperty(property, value);
|
|
1234
1242
|
}
|
|
1235
1243
|
}
|
|
1236
1244
|
else if (typeof property === "object") {
|
|
1237
1245
|
for (let prop in property) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
element.style.setProperty(prop, property[prop], "important");
|
|
1241
|
-
}
|
|
1242
|
-
else {
|
|
1243
|
-
property[prop] = handlePixe(prop, property[prop]);
|
|
1244
|
-
element.style.setProperty(prop, property[prop]);
|
|
1245
|
-
}
|
|
1246
|
+
let value = property[prop];
|
|
1247
|
+
setStyleProperty(prop, value);
|
|
1246
1248
|
}
|
|
1247
1249
|
}
|
|
1248
1250
|
}
|
|
@@ -1901,31 +1903,37 @@ const PopsInstanceUtils = {
|
|
|
1901
1903
|
* @param maskElement
|
|
1902
1904
|
*/
|
|
1903
1905
|
hide(popsType, layerConfigList, guid, config, animElement, maskElement) {
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1906
|
+
return new Promise((resolve) => {
|
|
1907
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
1908
|
+
if (popsType === "drawer") {
|
|
1909
|
+
let drawerConfig = config;
|
|
1910
|
+
setTimeout(() => {
|
|
1911
|
+
maskElement.style.setProperty("display", "none");
|
|
1912
|
+
if (["top", "bottom"].includes(drawerConfig.direction)) {
|
|
1913
|
+
popsElement.style.setProperty("height", "0");
|
|
1914
|
+
}
|
|
1915
|
+
else if (["left", "right"].includes(drawerConfig.direction)) {
|
|
1916
|
+
popsElement.style.setProperty("width", "0");
|
|
1917
|
+
}
|
|
1918
|
+
else {
|
|
1919
|
+
console.error("未知direction:", drawerConfig.direction);
|
|
1920
|
+
}
|
|
1921
|
+
resolve();
|
|
1922
|
+
}, drawerConfig.closeDelay);
|
|
1923
|
+
}
|
|
1924
|
+
else {
|
|
1925
|
+
let findLayerIns = layerConfigList.find((layerConfigItem) => layerConfigItem.guid === guid);
|
|
1926
|
+
if (findLayerIns) {
|
|
1923
1927
|
/* 存在动画 */
|
|
1928
|
+
let layerConfigItem = findLayerIns;
|
|
1924
1929
|
layerConfigItem.animElement.style.width = "100%";
|
|
1925
1930
|
layerConfigItem.animElement.style.height = "100%";
|
|
1926
1931
|
layerConfigItem.animElement.style["animation-name"] =
|
|
1927
1932
|
layerConfigItem.animElement.getAttribute("anim") + "-reverse";
|
|
1928
1933
|
if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.style["animation-name"])) {
|
|
1934
|
+
/**
|
|
1935
|
+
* 动画结束的回调
|
|
1936
|
+
*/
|
|
1929
1937
|
function animationendCallBack() {
|
|
1930
1938
|
layerConfigItem.animElement.style.display = "none";
|
|
1931
1939
|
if (layerConfigItem.maskElement) {
|
|
@@ -1934,6 +1942,7 @@ const PopsInstanceUtils = {
|
|
|
1934
1942
|
popsDOMUtils.off(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
1935
1943
|
capture: true,
|
|
1936
1944
|
});
|
|
1945
|
+
resolve();
|
|
1937
1946
|
}
|
|
1938
1947
|
popsDOMUtils.on(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
1939
1948
|
capture: true,
|
|
@@ -1944,11 +1953,11 @@ const PopsInstanceUtils = {
|
|
|
1944
1953
|
if (layerConfigItem.maskElement) {
|
|
1945
1954
|
layerConfigItem.maskElement.style.display = "none";
|
|
1946
1955
|
}
|
|
1956
|
+
resolve();
|
|
1947
1957
|
}
|
|
1948
|
-
return;
|
|
1949
1958
|
}
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1959
|
+
}
|
|
1960
|
+
});
|
|
1952
1961
|
},
|
|
1953
1962
|
/**
|
|
1954
1963
|
* 显示
|
|
@@ -1960,27 +1969,30 @@ const PopsInstanceUtils = {
|
|
|
1960
1969
|
* @param maskElement
|
|
1961
1970
|
*/
|
|
1962
1971
|
show(popsType, layerConfigList, guid, config, animElement, maskElement) {
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1972
|
+
return new Promise((resolve) => {
|
|
1973
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
1974
|
+
if (popsType === "drawer") {
|
|
1975
|
+
let drawerConfig = config;
|
|
1976
|
+
setTimeout(() => {
|
|
1977
|
+
popsDOMUtils.css(maskElement, "display", "");
|
|
1978
|
+
let direction = drawerConfig.direction;
|
|
1979
|
+
let size = drawerConfig.size.toString();
|
|
1980
|
+
if (["top", "bottom"].includes(direction)) {
|
|
1981
|
+
popsElement.style.setProperty("height", size);
|
|
1982
|
+
}
|
|
1983
|
+
else if (["left", "right"].includes(direction)) {
|
|
1984
|
+
popsElement.style.setProperty("width", size);
|
|
1985
|
+
}
|
|
1986
|
+
else {
|
|
1987
|
+
console.error("未知direction:", direction);
|
|
1988
|
+
}
|
|
1989
|
+
resolve();
|
|
1990
|
+
}, drawerConfig.openDelay);
|
|
1991
|
+
}
|
|
1992
|
+
else {
|
|
1993
|
+
let findLayerIns = layerConfigList.find((layerConfigItem) => layerConfigItem.guid === guid);
|
|
1994
|
+
if (findLayerIns) {
|
|
1995
|
+
let layerConfigItem = findLayerIns;
|
|
1984
1996
|
layerConfigItem.animElement.style.width = "";
|
|
1985
1997
|
layerConfigItem.animElement.style.height = "";
|
|
1986
1998
|
layerConfigItem.animElement.style["animation-name"] =
|
|
@@ -1988,14 +2000,18 @@ const PopsInstanceUtils = {
|
|
|
1988
2000
|
.animElement.getAttribute("anim")
|
|
1989
2001
|
.replace("-reverse", "");
|
|
1990
2002
|
if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.style["animation-name"])) {
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
}
|
|
2003
|
+
/**
|
|
2004
|
+
* 动画结束的回调
|
|
2005
|
+
*/
|
|
1995
2006
|
function animationendCallBack() {
|
|
1996
2007
|
popsDOMUtils.off(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
1997
2008
|
capture: true,
|
|
1998
2009
|
});
|
|
2010
|
+
resolve();
|
|
2011
|
+
}
|
|
2012
|
+
layerConfigItem.animElement.style.display = "";
|
|
2013
|
+
if (layerConfigItem.maskElement) {
|
|
2014
|
+
layerConfigItem.maskElement.style.display = "";
|
|
1999
2015
|
}
|
|
2000
2016
|
popsDOMUtils.on(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
2001
2017
|
capture: true,
|
|
@@ -2006,11 +2022,11 @@ const PopsInstanceUtils = {
|
|
|
2006
2022
|
if (layerConfigItem.maskElement) {
|
|
2007
2023
|
layerConfigItem.maskElement.style.display = "";
|
|
2008
2024
|
}
|
|
2025
|
+
resolve();
|
|
2009
2026
|
}
|
|
2010
2027
|
}
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
}
|
|
2028
|
+
}
|
|
2029
|
+
});
|
|
2014
2030
|
},
|
|
2015
2031
|
/**
|
|
2016
2032
|
* 关闭
|
|
@@ -2021,50 +2037,57 @@ const PopsInstanceUtils = {
|
|
|
2021
2037
|
* @param animElement
|
|
2022
2038
|
*/
|
|
2023
2039
|
close(popsType, layerConfigList, guid, config, animElement) {
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
function
|
|
2031
|
-
|
|
2040
|
+
return new Promise((resolve) => {
|
|
2041
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
2042
|
+
let drawerConfig = config;
|
|
2043
|
+
/**
|
|
2044
|
+
* 动画结束事件
|
|
2045
|
+
*/
|
|
2046
|
+
function transitionendEvent() {
|
|
2047
|
+
/**
|
|
2048
|
+
* 弹窗已关闭的回调
|
|
2049
|
+
*/
|
|
2050
|
+
function closeCallBack(event) {
|
|
2051
|
+
if (event.propertyName !== "transform") {
|
|
2052
|
+
return;
|
|
2053
|
+
}
|
|
2054
|
+
popsDOMUtils.off(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, closeCallBack);
|
|
2055
|
+
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2056
|
+
resolve();
|
|
2057
|
+
}
|
|
2058
|
+
/* 监听过渡结束 */
|
|
2059
|
+
popsDOMUtils.on(popsElement, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
|
|
2060
|
+
let popsTransForm = getComputedStyle(popsElement).transform;
|
|
2061
|
+
if (popsTransForm !== "none") {
|
|
2062
|
+
popsDOMUtils.trigger(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, true);
|
|
2032
2063
|
return;
|
|
2033
2064
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
}
|
|
2050
|
-
else if (["left"].includes(drawerConfig.direction)) {
|
|
2051
|
-
popsElement.style.setProperty("transform", "translateX(-100%)");
|
|
2065
|
+
if (["top"].includes(drawerConfig.direction)) {
|
|
2066
|
+
popsElement.style.setProperty("transform", "translateY(-100%)");
|
|
2067
|
+
}
|
|
2068
|
+
else if (["bottom"].includes(drawerConfig.direction)) {
|
|
2069
|
+
popsElement.style.setProperty("transform", "translateY(100%)");
|
|
2070
|
+
}
|
|
2071
|
+
else if (["left"].includes(drawerConfig.direction)) {
|
|
2072
|
+
popsElement.style.setProperty("transform", "translateX(-100%)");
|
|
2073
|
+
}
|
|
2074
|
+
else if (["right"].includes(drawerConfig.direction)) {
|
|
2075
|
+
popsElement.style.setProperty("transform", "translateX(100%)");
|
|
2076
|
+
}
|
|
2077
|
+
else {
|
|
2078
|
+
console.error("未知direction:", drawerConfig.direction);
|
|
2079
|
+
}
|
|
2052
2080
|
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2081
|
+
if (popsType === "drawer") {
|
|
2082
|
+
setTimeout(() => {
|
|
2083
|
+
transitionendEvent();
|
|
2084
|
+
}, drawerConfig.closeDelay);
|
|
2055
2085
|
}
|
|
2056
2086
|
else {
|
|
2057
|
-
|
|
2087
|
+
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2088
|
+
resolve();
|
|
2058
2089
|
}
|
|
2059
|
-
}
|
|
2060
|
-
if (popsType === "drawer") {
|
|
2061
|
-
setTimeout(() => {
|
|
2062
|
-
transitionendEvent();
|
|
2063
|
-
}, drawerConfig.closeDelay);
|
|
2064
|
-
}
|
|
2065
|
-
else {
|
|
2066
|
-
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2067
|
-
}
|
|
2090
|
+
});
|
|
2068
2091
|
},
|
|
2069
2092
|
/**
|
|
2070
2093
|
* 拖拽元素
|
|
@@ -2793,11 +2816,11 @@ const PopsHandler = {
|
|
|
2793
2816
|
function originalRun() {
|
|
2794
2817
|
if (details.config.mask.clickEvent.toClose) {
|
|
2795
2818
|
/* 关闭 */
|
|
2796
|
-
PopsInstanceUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
|
|
2819
|
+
return PopsInstanceUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
|
|
2797
2820
|
}
|
|
2798
2821
|
else if (details.config.mask.clickEvent.toHide) {
|
|
2799
2822
|
/* 隐藏 */
|
|
2800
|
-
PopsInstanceUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
|
|
2823
|
+
return PopsInstanceUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
|
|
2801
2824
|
}
|
|
2802
2825
|
}
|
|
2803
2826
|
if (typeof details.config.mask.clickCallBack === "function") {
|
|
@@ -2976,13 +2999,13 @@ const PopsHandler = {
|
|
|
2976
2999
|
mode: mode,
|
|
2977
3000
|
guid: guid,
|
|
2978
3001
|
close() {
|
|
2979
|
-
PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3002
|
+
return PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
2980
3003
|
},
|
|
2981
3004
|
hide() {
|
|
2982
|
-
PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3005
|
+
return PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
2983
3006
|
},
|
|
2984
3007
|
show() {
|
|
2985
|
-
PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3008
|
+
return PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
2986
3009
|
},
|
|
2987
3010
|
};
|
|
2988
3011
|
},
|
|
@@ -3004,13 +3027,13 @@ const PopsHandler = {
|
|
|
3004
3027
|
mode: mode,
|
|
3005
3028
|
guid: guid,
|
|
3006
3029
|
close() {
|
|
3007
|
-
PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3030
|
+
return PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3008
3031
|
},
|
|
3009
3032
|
hide() {
|
|
3010
|
-
PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3033
|
+
return PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3011
3034
|
},
|
|
3012
3035
|
show() {
|
|
3013
|
-
PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3036
|
+
return PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3014
3037
|
},
|
|
3015
3038
|
};
|
|
3016
3039
|
},
|
|
@@ -3778,6 +3801,9 @@ class PopsLoading {
|
|
|
3778
3801
|
maskHTML: maskHTML,
|
|
3779
3802
|
});
|
|
3780
3803
|
$mask = _handleMask_.maskElement;
|
|
3804
|
+
// 遮罩层必须是跟随主内容
|
|
3805
|
+
// 即设置主内容position: relative,mask:position: absolute
|
|
3806
|
+
popsDOMUtils.css($mask, "position", "absolute !important");
|
|
3781
3807
|
elementList.push($mask);
|
|
3782
3808
|
}
|
|
3783
3809
|
let eventDetails = PopsHandler.handleLoadingEventDetails(guid, PopsType, $anim, $pops, $mask, config);
|
|
@@ -10052,7 +10078,7 @@ class Pops {
|
|
|
10052
10078
|
/** 配置 */
|
|
10053
10079
|
config = {
|
|
10054
10080
|
/** 版本号 */
|
|
10055
|
-
version: "2025.5.
|
|
10081
|
+
version: "2025.5.12",
|
|
10056
10082
|
cssText: {
|
|
10057
10083
|
/** 主CSS */
|
|
10058
10084
|
index: indexCSS,
|