@whitesev/pops 2.0.3 → 2.0.5
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 +141 -112
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +141 -112
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +141 -112
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +141 -112
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +141 -112
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +141 -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 +6 -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.umd.js
CHANGED
|
@@ -1225,30 +1225,32 @@
|
|
|
1225
1225
|
if (element == null) {
|
|
1226
1226
|
return;
|
|
1227
1227
|
}
|
|
1228
|
+
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1229
|
+
if (typeof propertyValue === "string" &&
|
|
1230
|
+
propertyValue.trim().endsWith("!important")) {
|
|
1231
|
+
propertyValue = propertyValue
|
|
1232
|
+
.trim()
|
|
1233
|
+
.replace(/!important$/gi, "")
|
|
1234
|
+
.trim();
|
|
1235
|
+
element.style.setProperty(propertyName, propertyValue, "important");
|
|
1236
|
+
}
|
|
1237
|
+
else {
|
|
1238
|
+
propertyValue = handlePixe(propertyName, propertyValue);
|
|
1239
|
+
element.style.setProperty(propertyName, propertyValue);
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1228
1242
|
if (typeof property === "string") {
|
|
1229
1243
|
if (value == null) {
|
|
1230
1244
|
return getComputedStyle(element).getPropertyValue(property);
|
|
1231
1245
|
}
|
|
1232
1246
|
else {
|
|
1233
|
-
|
|
1234
|
-
element.style.setProperty(property, value, "important");
|
|
1235
|
-
}
|
|
1236
|
-
else {
|
|
1237
|
-
value = handlePixe(property, value);
|
|
1238
|
-
element.style.setProperty(property, value);
|
|
1239
|
-
}
|
|
1247
|
+
setStyleProperty(property, value);
|
|
1240
1248
|
}
|
|
1241
1249
|
}
|
|
1242
1250
|
else if (typeof property === "object") {
|
|
1243
1251
|
for (let prop in property) {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
element.style.setProperty(prop, property[prop], "important");
|
|
1247
|
-
}
|
|
1248
|
-
else {
|
|
1249
|
-
property[prop] = handlePixe(prop, property[prop]);
|
|
1250
|
-
element.style.setProperty(prop, property[prop]);
|
|
1251
|
-
}
|
|
1252
|
+
let value = property[prop];
|
|
1253
|
+
setStyleProperty(prop, value);
|
|
1252
1254
|
}
|
|
1253
1255
|
}
|
|
1254
1256
|
}
|
|
@@ -1907,31 +1909,37 @@
|
|
|
1907
1909
|
* @param maskElement
|
|
1908
1910
|
*/
|
|
1909
1911
|
hide(popsType, layerConfigList, guid, config, animElement, maskElement) {
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1912
|
+
return new Promise((resolve) => {
|
|
1913
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
1914
|
+
if (popsType === "drawer") {
|
|
1915
|
+
let drawerConfig = config;
|
|
1916
|
+
setTimeout(() => {
|
|
1917
|
+
maskElement.style.setProperty("display", "none");
|
|
1918
|
+
if (["top", "bottom"].includes(drawerConfig.direction)) {
|
|
1919
|
+
popsElement.style.setProperty("height", "0");
|
|
1920
|
+
}
|
|
1921
|
+
else if (["left", "right"].includes(drawerConfig.direction)) {
|
|
1922
|
+
popsElement.style.setProperty("width", "0");
|
|
1923
|
+
}
|
|
1924
|
+
else {
|
|
1925
|
+
console.error("未知direction:", drawerConfig.direction);
|
|
1926
|
+
}
|
|
1927
|
+
resolve();
|
|
1928
|
+
}, drawerConfig.closeDelay);
|
|
1929
|
+
}
|
|
1930
|
+
else {
|
|
1931
|
+
let findLayerIns = layerConfigList.find((layerConfigItem) => layerConfigItem.guid === guid);
|
|
1932
|
+
if (findLayerIns) {
|
|
1929
1933
|
/* 存在动画 */
|
|
1934
|
+
let layerConfigItem = findLayerIns;
|
|
1930
1935
|
layerConfigItem.animElement.style.width = "100%";
|
|
1931
1936
|
layerConfigItem.animElement.style.height = "100%";
|
|
1932
1937
|
layerConfigItem.animElement.style["animation-name"] =
|
|
1933
1938
|
layerConfigItem.animElement.getAttribute("anim") + "-reverse";
|
|
1934
1939
|
if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.style["animation-name"])) {
|
|
1940
|
+
/**
|
|
1941
|
+
* 动画结束的回调
|
|
1942
|
+
*/
|
|
1935
1943
|
function animationendCallBack() {
|
|
1936
1944
|
layerConfigItem.animElement.style.display = "none";
|
|
1937
1945
|
if (layerConfigItem.maskElement) {
|
|
@@ -1940,6 +1948,7 @@
|
|
|
1940
1948
|
popsDOMUtils.off(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
1941
1949
|
capture: true,
|
|
1942
1950
|
});
|
|
1951
|
+
resolve();
|
|
1943
1952
|
}
|
|
1944
1953
|
popsDOMUtils.on(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
1945
1954
|
capture: true,
|
|
@@ -1950,11 +1959,11 @@
|
|
|
1950
1959
|
if (layerConfigItem.maskElement) {
|
|
1951
1960
|
layerConfigItem.maskElement.style.display = "none";
|
|
1952
1961
|
}
|
|
1962
|
+
resolve();
|
|
1953
1963
|
}
|
|
1954
|
-
return;
|
|
1955
1964
|
}
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1965
|
+
}
|
|
1966
|
+
});
|
|
1958
1967
|
},
|
|
1959
1968
|
/**
|
|
1960
1969
|
* 显示
|
|
@@ -1966,27 +1975,30 @@
|
|
|
1966
1975
|
* @param maskElement
|
|
1967
1976
|
*/
|
|
1968
1977
|
show(popsType, layerConfigList, guid, config, animElement, maskElement) {
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1978
|
+
return new Promise((resolve) => {
|
|
1979
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
1980
|
+
if (popsType === "drawer") {
|
|
1981
|
+
let drawerConfig = config;
|
|
1982
|
+
setTimeout(() => {
|
|
1983
|
+
popsDOMUtils.css(maskElement, "display", "");
|
|
1984
|
+
let direction = drawerConfig.direction;
|
|
1985
|
+
let size = drawerConfig.size.toString();
|
|
1986
|
+
if (["top", "bottom"].includes(direction)) {
|
|
1987
|
+
popsElement.style.setProperty("height", size);
|
|
1988
|
+
}
|
|
1989
|
+
else if (["left", "right"].includes(direction)) {
|
|
1990
|
+
popsElement.style.setProperty("width", size);
|
|
1991
|
+
}
|
|
1992
|
+
else {
|
|
1993
|
+
console.error("未知direction:", direction);
|
|
1994
|
+
}
|
|
1995
|
+
resolve();
|
|
1996
|
+
}, drawerConfig.openDelay);
|
|
1997
|
+
}
|
|
1998
|
+
else {
|
|
1999
|
+
let findLayerIns = layerConfigList.find((layerConfigItem) => layerConfigItem.guid === guid);
|
|
2000
|
+
if (findLayerIns) {
|
|
2001
|
+
let layerConfigItem = findLayerIns;
|
|
1990
2002
|
layerConfigItem.animElement.style.width = "";
|
|
1991
2003
|
layerConfigItem.animElement.style.height = "";
|
|
1992
2004
|
layerConfigItem.animElement.style["animation-name"] =
|
|
@@ -1994,14 +2006,18 @@
|
|
|
1994
2006
|
.animElement.getAttribute("anim")
|
|
1995
2007
|
.replace("-reverse", "");
|
|
1996
2008
|
if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.style["animation-name"])) {
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
}
|
|
2009
|
+
/**
|
|
2010
|
+
* 动画结束的回调
|
|
2011
|
+
*/
|
|
2001
2012
|
function animationendCallBack() {
|
|
2002
2013
|
popsDOMUtils.off(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
2003
2014
|
capture: true,
|
|
2004
2015
|
});
|
|
2016
|
+
resolve();
|
|
2017
|
+
}
|
|
2018
|
+
layerConfigItem.animElement.style.display = "";
|
|
2019
|
+
if (layerConfigItem.maskElement) {
|
|
2020
|
+
layerConfigItem.maskElement.style.display = "";
|
|
2005
2021
|
}
|
|
2006
2022
|
popsDOMUtils.on(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
2007
2023
|
capture: true,
|
|
@@ -2012,11 +2028,11 @@
|
|
|
2012
2028
|
if (layerConfigItem.maskElement) {
|
|
2013
2029
|
layerConfigItem.maskElement.style.display = "";
|
|
2014
2030
|
}
|
|
2031
|
+
resolve();
|
|
2015
2032
|
}
|
|
2016
2033
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
}
|
|
2034
|
+
}
|
|
2035
|
+
});
|
|
2020
2036
|
},
|
|
2021
2037
|
/**
|
|
2022
2038
|
* 关闭
|
|
@@ -2027,50 +2043,57 @@
|
|
|
2027
2043
|
* @param animElement
|
|
2028
2044
|
*/
|
|
2029
2045
|
close(popsType, layerConfigList, guid, config, animElement) {
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
function
|
|
2037
|
-
|
|
2046
|
+
return new Promise((resolve) => {
|
|
2047
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
2048
|
+
let drawerConfig = config;
|
|
2049
|
+
/**
|
|
2050
|
+
* 动画结束事件
|
|
2051
|
+
*/
|
|
2052
|
+
function transitionendEvent() {
|
|
2053
|
+
/**
|
|
2054
|
+
* 弹窗已关闭的回调
|
|
2055
|
+
*/
|
|
2056
|
+
function closeCallBack(event) {
|
|
2057
|
+
if (event.propertyName !== "transform") {
|
|
2058
|
+
return;
|
|
2059
|
+
}
|
|
2060
|
+
popsDOMUtils.off(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, closeCallBack);
|
|
2061
|
+
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2062
|
+
resolve();
|
|
2063
|
+
}
|
|
2064
|
+
/* 监听过渡结束 */
|
|
2065
|
+
popsDOMUtils.on(popsElement, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
|
|
2066
|
+
let popsTransForm = getComputedStyle(popsElement).transform;
|
|
2067
|
+
if (popsTransForm !== "none") {
|
|
2068
|
+
popsDOMUtils.trigger(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, true);
|
|
2038
2069
|
return;
|
|
2039
2070
|
}
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
}
|
|
2056
|
-
else if (["left"].includes(drawerConfig.direction)) {
|
|
2057
|
-
popsElement.style.setProperty("transform", "translateX(-100%)");
|
|
2071
|
+
if (["top"].includes(drawerConfig.direction)) {
|
|
2072
|
+
popsElement.style.setProperty("transform", "translateY(-100%)");
|
|
2073
|
+
}
|
|
2074
|
+
else if (["bottom"].includes(drawerConfig.direction)) {
|
|
2075
|
+
popsElement.style.setProperty("transform", "translateY(100%)");
|
|
2076
|
+
}
|
|
2077
|
+
else if (["left"].includes(drawerConfig.direction)) {
|
|
2078
|
+
popsElement.style.setProperty("transform", "translateX(-100%)");
|
|
2079
|
+
}
|
|
2080
|
+
else if (["right"].includes(drawerConfig.direction)) {
|
|
2081
|
+
popsElement.style.setProperty("transform", "translateX(100%)");
|
|
2082
|
+
}
|
|
2083
|
+
else {
|
|
2084
|
+
console.error("未知direction:", drawerConfig.direction);
|
|
2085
|
+
}
|
|
2058
2086
|
}
|
|
2059
|
-
|
|
2060
|
-
|
|
2087
|
+
if (popsType === "drawer") {
|
|
2088
|
+
setTimeout(() => {
|
|
2089
|
+
transitionendEvent();
|
|
2090
|
+
}, drawerConfig.closeDelay);
|
|
2061
2091
|
}
|
|
2062
2092
|
else {
|
|
2063
|
-
|
|
2093
|
+
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2094
|
+
resolve();
|
|
2064
2095
|
}
|
|
2065
|
-
}
|
|
2066
|
-
if (popsType === "drawer") {
|
|
2067
|
-
setTimeout(() => {
|
|
2068
|
-
transitionendEvent();
|
|
2069
|
-
}, drawerConfig.closeDelay);
|
|
2070
|
-
}
|
|
2071
|
-
else {
|
|
2072
|
-
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2073
|
-
}
|
|
2096
|
+
});
|
|
2074
2097
|
},
|
|
2075
2098
|
/**
|
|
2076
2099
|
* 拖拽元素
|
|
@@ -2799,11 +2822,11 @@
|
|
|
2799
2822
|
function originalRun() {
|
|
2800
2823
|
if (details.config.mask.clickEvent.toClose) {
|
|
2801
2824
|
/* 关闭 */
|
|
2802
|
-
PopsInstanceUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
|
|
2825
|
+
return PopsInstanceUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
|
|
2803
2826
|
}
|
|
2804
2827
|
else if (details.config.mask.clickEvent.toHide) {
|
|
2805
2828
|
/* 隐藏 */
|
|
2806
|
-
PopsInstanceUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
|
|
2829
|
+
return PopsInstanceUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
|
|
2807
2830
|
}
|
|
2808
2831
|
}
|
|
2809
2832
|
if (typeof details.config.mask.clickCallBack === "function") {
|
|
@@ -2982,13 +3005,13 @@
|
|
|
2982
3005
|
mode: mode,
|
|
2983
3006
|
guid: guid,
|
|
2984
3007
|
close() {
|
|
2985
|
-
PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3008
|
+
return PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
2986
3009
|
},
|
|
2987
3010
|
hide() {
|
|
2988
|
-
PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3011
|
+
return PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
2989
3012
|
},
|
|
2990
3013
|
show() {
|
|
2991
|
-
PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3014
|
+
return PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
2992
3015
|
},
|
|
2993
3016
|
};
|
|
2994
3017
|
},
|
|
@@ -3010,13 +3033,13 @@
|
|
|
3010
3033
|
mode: mode,
|
|
3011
3034
|
guid: guid,
|
|
3012
3035
|
close() {
|
|
3013
|
-
PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3036
|
+
return PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3014
3037
|
},
|
|
3015
3038
|
hide() {
|
|
3016
|
-
PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3039
|
+
return PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3017
3040
|
},
|
|
3018
3041
|
show() {
|
|
3019
|
-
PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3042
|
+
return PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3020
3043
|
},
|
|
3021
3044
|
};
|
|
3022
3045
|
},
|
|
@@ -3765,6 +3788,9 @@
|
|
|
3765
3788
|
* 弹窗的主元素,包括动画层
|
|
3766
3789
|
*/
|
|
3767
3790
|
let $anim = PopsElementHandler.parseElement(animHTML);
|
|
3791
|
+
// 遮罩层必须是跟随主内容
|
|
3792
|
+
// 即设置主内容position: relative,mask:position: absolute
|
|
3793
|
+
popsDOMUtils.css($anim, "position", "absolute !important");
|
|
3768
3794
|
let { popsElement: $pops } = PopsHandler.handleQueryElement($anim, PopsType);
|
|
3769
3795
|
/**
|
|
3770
3796
|
* 遮罩层元素
|
|
@@ -3784,6 +3810,9 @@
|
|
|
3784
3810
|
maskHTML: maskHTML,
|
|
3785
3811
|
});
|
|
3786
3812
|
$mask = _handleMask_.maskElement;
|
|
3813
|
+
// 遮罩层必须是跟随主内容
|
|
3814
|
+
// 即设置主内容position: relative,mask:position: absolute
|
|
3815
|
+
popsDOMUtils.css($mask, "position", "absolute !important");
|
|
3787
3816
|
elementList.push($mask);
|
|
3788
3817
|
}
|
|
3789
3818
|
let eventDetails = PopsHandler.handleLoadingEventDetails(guid, PopsType, $anim, $pops, $mask, config);
|
|
@@ -10058,7 +10087,7 @@
|
|
|
10058
10087
|
/** 配置 */
|
|
10059
10088
|
config = {
|
|
10060
10089
|
/** 版本号 */
|
|
10061
|
-
version: "2025.5.
|
|
10090
|
+
version: "2025.5.12",
|
|
10062
10091
|
cssText: {
|
|
10063
10092
|
/** 主CSS */
|
|
10064
10093
|
index: indexCSS,
|