@whitesev/pops 2.6.1 → 3.0.0
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 +1208 -1067
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +1208 -1067
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +1208 -1067
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +1208 -1067
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +1208 -1067
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +1208 -1067
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/eslint.config.d.mts +2 -0
- package/dist/types/src/Pops.d.ts +98 -103
- package/dist/types/src/PopsInst.d.ts +2 -2
- package/dist/types/src/components/alert/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/alert/index.d.ts +2 -2
- package/dist/types/src/components/alert/types/index.d.ts +4 -4
- package/dist/types/src/components/confirm/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/confirm/index.d.ts +2 -2
- package/dist/types/src/components/confirm/types/index.d.ts +2 -2
- package/dist/types/src/components/drawer/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/drawer/index.d.ts +2 -2
- package/dist/types/src/components/drawer/types/index.d.ts +2 -2
- package/dist/types/src/components/folder/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/folder/index.d.ts +2 -2
- package/dist/types/src/components/folder/types/index.d.ts +31 -7
- package/dist/types/src/components/iframe/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/iframe/index.d.ts +2 -5
- package/dist/types/src/components/iframe/types/index.d.ts +13 -42
- package/dist/types/src/components/loading/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/loading/index.d.ts +2 -2
- package/dist/types/src/components/loading/types/index.d.ts +4 -4
- package/dist/types/src/components/panel/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/panel/handlerComponents.d.ts +47 -43
- package/dist/types/src/components/panel/index.d.ts +3 -3
- package/dist/types/src/components/panel/types/components-button.d.ts +7 -6
- package/dist/types/src/components/panel/types/components-common.d.ts +7 -7
- package/dist/types/src/components/panel/types/components-container.d.ts +24 -0
- package/dist/types/src/components/panel/types/components-deepMenu.d.ts +13 -13
- package/dist/types/src/components/panel/types/components-input.d.ts +6 -6
- package/dist/types/src/components/panel/types/components-own.d.ts +2 -2
- package/dist/types/src/components/panel/types/components-select.d.ts +9 -9
- package/dist/types/src/components/panel/types/components-selectMultiple.d.ts +8 -8
- package/dist/types/src/components/panel/types/components-slider.d.ts +7 -7
- package/dist/types/src/components/panel/types/components-switch.d.ts +6 -6
- package/dist/types/src/components/panel/types/components-textarea.d.ts +6 -6
- package/dist/types/src/components/panel/types/index.d.ts +36 -28
- package/dist/types/src/components/prompt/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/prompt/index.d.ts +2 -2
- package/dist/types/src/components/prompt/types/index.d.ts +4 -3
- package/dist/types/src/components/rightClickMenu/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/rightClickMenu/index.d.ts +29 -27
- package/dist/types/src/components/rightClickMenu/types/index.d.ts +32 -11
- package/dist/types/src/components/searchSuggestion/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/searchSuggestion/index.d.ts +21 -6
- package/dist/types/src/components/searchSuggestion/types/index.d.ts +15 -13
- package/dist/types/src/components/tooltip/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/tooltip/index.d.ts +6 -21
- package/dist/types/src/components/tooltip/types/index.d.ts +8 -6
- package/dist/types/src/config/GlobalConfig.d.ts +3 -3
- package/dist/types/src/handler/PopsElementHandler.d.ts +6 -6
- package/dist/types/src/handler/PopsHandler.d.ts +18 -18
- package/dist/types/src/types/button.d.ts +4 -97
- package/dist/types/src/types/components.d.ts +8 -8
- package/dist/types/src/types/event.d.ts +0 -30
- package/dist/types/src/types/global.d.ts +2 -0
- package/dist/types/src/types/inst.d.ts +5 -5
- package/dist/types/src/types/main.d.ts +35 -80
- package/dist/types/src/types/mask.d.ts +18 -15
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +15 -15
- package/dist/types/src/utils/PopsUtils.d.ts +4 -0
- package/package.json +10 -10
- package/src/Pops.ts +44 -44
- package/src/PopsAnimation.ts +1 -1
- package/src/PopsInst.ts +2 -2
- package/src/components/alert/{config.ts → defaultConfig.ts} +7 -7
- package/src/components/alert/index.ts +16 -18
- package/src/components/alert/types/index.ts +4 -4
- package/src/components/confirm/{config.ts → defaultConfig.ts} +11 -11
- package/src/components/confirm/index.ts +11 -13
- package/src/components/confirm/types/index.ts +3 -3
- package/src/components/drawer/{config.ts → defaultConfig.ts} +10 -10
- package/src/components/drawer/index.ts +18 -17
- package/src/components/drawer/types/index.ts +3 -3
- package/src/components/folder/{config.ts → defaultConfig.ts} +22 -18
- package/src/components/folder/index.ts +61 -60
- package/src/components/folder/types/index.ts +31 -18
- package/src/components/iframe/{config.ts → defaultConfig.ts} +2 -2
- package/src/components/iframe/index.ts +24 -29
- package/src/components/iframe/types/index.ts +13 -56
- package/src/components/loading/{config.ts → defaultConfig.ts} +3 -3
- package/src/components/loading/index.ts +13 -11
- package/src/components/loading/types/index.ts +5 -5
- package/src/components/panel/{config.ts → defaultConfig.ts} +115 -37
- package/src/components/panel/handlerComponents.ts +445 -427
- package/src/components/panel/index.css +5 -1
- package/src/components/panel/index.ts +15 -28
- package/src/components/panel/types/components-button.ts +7 -6
- package/src/components/panel/types/components-common.ts +7 -7
- package/src/components/panel/types/components-container.ts +25 -0
- package/src/components/panel/types/components-deepMenu.ts +13 -13
- package/src/components/panel/types/components-input.ts +6 -6
- package/src/components/panel/types/components-own.ts +2 -2
- package/src/components/panel/types/components-select.ts +11 -11
- package/src/components/panel/types/components-selectMultiple.ts +8 -9
- package/src/components/panel/types/components-slider.ts +7 -7
- package/src/components/panel/types/components-switch.ts +6 -6
- package/src/components/panel/types/components-textarea.ts +6 -6
- package/src/components/panel/types/index.ts +45 -38
- package/src/components/prompt/{config.ts → defaultConfig.ts} +10 -10
- package/src/components/prompt/index.ts +13 -15
- package/src/components/prompt/types/index.ts +4 -3
- package/src/components/rightClickMenu/{config.ts → defaultConfig.ts} +20 -19
- package/src/components/rightClickMenu/index.ts +125 -108
- package/src/components/rightClickMenu/types/index.ts +36 -14
- package/src/components/searchSuggestion/{config.ts → defaultConfig.ts} +18 -11
- package/src/components/searchSuggestion/index.ts +116 -96
- package/src/components/searchSuggestion/types/index.ts +17 -15
- package/src/components/tooltip/{config.ts → defaultConfig.ts} +5 -6
- package/src/components/tooltip/index.ts +21 -21
- package/src/components/tooltip/types/index.ts +9 -7
- package/src/config/GlobalConfig.ts +2 -2
- package/src/handler/PopsElementHandler.ts +29 -30
- package/src/handler/PopsHandler.ts +43 -43
- package/src/types/button.d.ts +4 -97
- package/src/types/components.d.ts +8 -8
- package/src/types/event.d.ts +0 -30
- package/src/types/global.d.ts +2 -0
- package/src/types/inst.d.ts +5 -5
- package/src/types/main.d.ts +35 -80
- package/src/types/mask.d.ts +18 -15
- package/src/utils/PopsDOMUtils.ts +34 -34
- package/src/utils/PopsInstanceUtils.ts +129 -139
- package/src/utils/PopsUtils.ts +60 -45
- package/dist/types/src/components/alert/config.d.ts +0 -2
- package/dist/types/src/components/confirm/config.d.ts +0 -2
- package/dist/types/src/components/drawer/config.d.ts +0 -2
- package/dist/types/src/components/folder/config.d.ts +0 -2
- package/dist/types/src/components/iframe/config.d.ts +0 -2
- package/dist/types/src/components/loading/config.d.ts +0 -2
- package/dist/types/src/components/panel/config.d.ts +0 -2
- package/dist/types/src/components/panel/types/components-forms.d.ts +0 -23
- package/dist/types/src/components/prompt/config.d.ts +0 -2
- package/dist/types/src/components/rightClickMenu/config.d.ts +0 -2
- package/dist/types/src/components/searchSuggestion/config.d.ts +0 -2
- package/dist/types/src/components/tooltip/config.d.ts +0 -2
- package/src/components/panel/types/components-forms.ts +0 -24
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
1
|
+
import type { PopsAlertConfig } from "../components/alert/types";
|
|
2
|
+
import type { PopsConfirmConfig } from "../components/confirm/types";
|
|
3
|
+
import type { PopsDrawerConfig } from "../components/drawer/types";
|
|
4
|
+
import type { PopsFolderConfig } from "../components/folder/types";
|
|
5
|
+
import type { PopsIframeConfig } from "../components/iframe/types";
|
|
6
|
+
import type { PopsLoadingConfig } from "../components/loading/types";
|
|
7
|
+
import type { PopsPanelConfig } from "../components/panel/types";
|
|
8
|
+
import type { PopsPromptConfig } from "../components/prompt/types/index";
|
|
9
|
+
import type { PopsInstGeneralConfig } from "../types/inst";
|
|
10
10
|
import type { PopsInstStoreType } from "../types/main";
|
|
11
11
|
import { popsDOMUtils } from "./PopsDOMUtils";
|
|
12
12
|
import { popsUtils } from "./PopsUtils";
|
|
@@ -65,7 +65,7 @@ export const PopsInstanceUtils = {
|
|
|
65
65
|
}
|
|
66
66
|
/** 元素的样式 */
|
|
67
67
|
const nodeStyle = PopsCore.window.getComputedStyle($ele);
|
|
68
|
-
|
|
68
|
+
// 不对position为static和display为none的元素进行获取它们的z-index
|
|
69
69
|
if (isVisibleNode(nodeStyle)) {
|
|
70
70
|
const nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
71
71
|
if (!isNaN(nodeZIndex)) {
|
|
@@ -122,14 +122,14 @@ export const PopsInstanceUtils = {
|
|
|
122
122
|
const instData = PopsInstData[instKeyName as PopsInstStoreType];
|
|
123
123
|
for (let index = 0; index < instData.length; index++) {
|
|
124
124
|
const inst = instData[index];
|
|
125
|
-
const nodeStyle = window.getComputedStyle(inst
|
|
126
|
-
|
|
125
|
+
const nodeStyle = window.getComputedStyle(inst.$anim);
|
|
126
|
+
// 不对position为static和display为none的元素进行获取它们的z-index
|
|
127
127
|
if (isVisibleNode(nodeStyle)) {
|
|
128
128
|
const nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
129
129
|
if (!isNaN(nodeZIndex)) {
|
|
130
130
|
if (nodeZIndex > zIndex) {
|
|
131
131
|
zIndex = nodeZIndex;
|
|
132
|
-
maxZIndexNode = inst
|
|
132
|
+
maxZIndexNode = inst.$anim;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -159,19 +159,19 @@ export const PopsInstanceUtils = {
|
|
|
159
159
|
* @param guid 唯一标识
|
|
160
160
|
* @param isAll 是否全部删除
|
|
161
161
|
*/
|
|
162
|
-
removeInstance(instConfigList:
|
|
162
|
+
removeInstance(instConfigList: PopsInstGeneralConfig[][], guid: string, isAll = false) {
|
|
163
163
|
/**
|
|
164
164
|
* 移除元素实例
|
|
165
165
|
* @param instCommonConfig
|
|
166
166
|
*/
|
|
167
|
-
function removeItem(instCommonConfig:
|
|
167
|
+
function removeItem(instCommonConfig: PopsInstGeneralConfig) {
|
|
168
168
|
if (typeof instCommonConfig.beforeRemoveCallBack === "function") {
|
|
169
169
|
// 调用移除签的回调
|
|
170
170
|
instCommonConfig.beforeRemoveCallBack(instCommonConfig);
|
|
171
171
|
}
|
|
172
|
-
instCommonConfig?.
|
|
173
|
-
instCommonConfig?.
|
|
174
|
-
instCommonConfig?.
|
|
172
|
+
instCommonConfig?.$anim?.remove();
|
|
173
|
+
instCommonConfig?.$pops?.remove();
|
|
174
|
+
instCommonConfig?.$mask?.remove();
|
|
175
175
|
instCommonConfig?.$shadowContainer?.remove();
|
|
176
176
|
}
|
|
177
177
|
// [ inst[], inst[],...]
|
|
@@ -181,15 +181,15 @@ export const PopsInstanceUtils = {
|
|
|
181
181
|
// 移除全部或者guid相同
|
|
182
182
|
if (isAll || instConfigItem["guid"] === guid) {
|
|
183
183
|
// 判断是否有动画
|
|
184
|
-
const animName = instConfigItem.
|
|
184
|
+
const animName = instConfigItem.$anim.getAttribute("anim")!;
|
|
185
185
|
if (PopsAnimation.hasAnim(animName)) {
|
|
186
186
|
const reverseAnimName = animName + "-reverse";
|
|
187
|
-
instConfigItem.
|
|
188
|
-
instConfigItem.
|
|
189
|
-
(instConfigItem.
|
|
190
|
-
if (PopsAnimation.hasAnim((instConfigItem.
|
|
187
|
+
instConfigItem.$anim.style.width = "100%";
|
|
188
|
+
instConfigItem.$anim.style.height = "100%";
|
|
189
|
+
(instConfigItem.$anim.style as any)["animation-name"] = reverseAnimName;
|
|
190
|
+
if (PopsAnimation.hasAnim((instConfigItem.$anim.style as any)["animation-name"])) {
|
|
191
191
|
popsDOMUtils.on(
|
|
192
|
-
instConfigItem
|
|
192
|
+
instConfigItem.$anim,
|
|
193
193
|
popsDOMUtils.getAnimationEndNameList(),
|
|
194
194
|
function () {
|
|
195
195
|
removeItem(instConfigItem);
|
|
@@ -222,32 +222,32 @@ export const PopsInstanceUtils = {
|
|
|
222
222
|
*/
|
|
223
223
|
hide(
|
|
224
224
|
config:
|
|
225
|
-
|
|
|
226
|
-
|
|
|
227
|
-
|
|
|
228
|
-
|
|
|
229
|
-
|
|
|
230
|
-
|
|
|
231
|
-
|
|
|
232
|
-
|
|
|
225
|
+
| PopsAlertConfig
|
|
226
|
+
| PopsDrawerConfig
|
|
227
|
+
| PopsPromptConfig
|
|
228
|
+
| PopsConfirmConfig
|
|
229
|
+
| PopsIframeConfig
|
|
230
|
+
| PopsLoadingConfig
|
|
231
|
+
| PopsPanelConfig
|
|
232
|
+
| PopsFolderConfig,
|
|
233
233
|
popsType: PopsInstStoreType,
|
|
234
|
-
instConfigList:
|
|
234
|
+
instConfigList: PopsInstGeneralConfig[],
|
|
235
235
|
guid: string,
|
|
236
236
|
$anim: HTMLElement,
|
|
237
237
|
$mask?: HTMLElement
|
|
238
238
|
) {
|
|
239
239
|
return new Promise<void>((resolve) => {
|
|
240
|
-
const
|
|
240
|
+
const $pops = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
|
|
241
241
|
if (popsType === "drawer") {
|
|
242
|
-
const drawerConfig = config as Required<
|
|
242
|
+
const drawerConfig = config as Required<PopsDrawerConfig>;
|
|
243
243
|
popsUtils.setTimeout(() => {
|
|
244
244
|
if ($mask) {
|
|
245
245
|
popsDOMUtils.css($mask, "display", "none");
|
|
246
246
|
}
|
|
247
247
|
if (["top", "bottom"].includes(drawerConfig.direction)) {
|
|
248
|
-
|
|
248
|
+
$pops.style.setProperty("height", "0");
|
|
249
249
|
} else if (["left", "right"].includes(drawerConfig.direction)) {
|
|
250
|
-
|
|
250
|
+
$pops.style.setProperty("width", "0");
|
|
251
251
|
} else {
|
|
252
252
|
console.error("未知direction:", drawerConfig.direction);
|
|
253
253
|
}
|
|
@@ -256,41 +256,36 @@ export const PopsInstanceUtils = {
|
|
|
256
256
|
} else {
|
|
257
257
|
const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
|
|
258
258
|
if (fintInst) {
|
|
259
|
-
|
|
259
|
+
// 存在动画
|
|
260
260
|
const instConfigItem = fintInst;
|
|
261
|
-
instConfigItem.
|
|
262
|
-
instConfigItem.
|
|
261
|
+
instConfigItem.$anim.style.width = "100%";
|
|
262
|
+
instConfigItem.$anim.style.height = "100%";
|
|
263
263
|
Reflect.set(
|
|
264
|
-
instConfigItem.
|
|
264
|
+
instConfigItem.$anim.style,
|
|
265
265
|
"animation-name",
|
|
266
|
-
instConfigItem.
|
|
266
|
+
instConfigItem.$anim.getAttribute("anim") + "-reverse"
|
|
267
267
|
);
|
|
268
|
-
if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.
|
|
268
|
+
if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
|
|
269
269
|
/**
|
|
270
270
|
* 动画结束的回调
|
|
271
271
|
*/
|
|
272
272
|
function animationendCallBack() {
|
|
273
|
-
instConfigItem.
|
|
274
|
-
if (instConfigItem
|
|
275
|
-
instConfigItem.
|
|
273
|
+
instConfigItem.$anim.style.display = "none";
|
|
274
|
+
if (instConfigItem.$mask) {
|
|
275
|
+
instConfigItem.$mask.style.display = "none";
|
|
276
276
|
}
|
|
277
|
-
popsDOMUtils.off(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
animationendCallBack,
|
|
281
|
-
{
|
|
282
|
-
capture: true,
|
|
283
|
-
}
|
|
284
|
-
);
|
|
277
|
+
popsDOMUtils.off(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
278
|
+
capture: true,
|
|
279
|
+
});
|
|
285
280
|
resolve();
|
|
286
281
|
}
|
|
287
|
-
popsDOMUtils.on(instConfigItem
|
|
282
|
+
popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
288
283
|
capture: true,
|
|
289
284
|
});
|
|
290
285
|
} else {
|
|
291
|
-
instConfigItem.
|
|
292
|
-
if (instConfigItem
|
|
293
|
-
instConfigItem.
|
|
286
|
+
instConfigItem.$anim.style.display = "none";
|
|
287
|
+
if (instConfigItem.$mask) {
|
|
288
|
+
instConfigItem.$mask.style.display = "none";
|
|
294
289
|
}
|
|
295
290
|
|
|
296
291
|
resolve();
|
|
@@ -310,24 +305,24 @@ export const PopsInstanceUtils = {
|
|
|
310
305
|
*/
|
|
311
306
|
show(
|
|
312
307
|
config:
|
|
313
|
-
|
|
|
314
|
-
|
|
|
315
|
-
|
|
|
316
|
-
|
|
|
317
|
-
|
|
|
318
|
-
|
|
|
319
|
-
|
|
|
320
|
-
|
|
|
308
|
+
| PopsAlertConfig
|
|
309
|
+
| PopsDrawerConfig
|
|
310
|
+
| PopsPromptConfig
|
|
311
|
+
| PopsConfirmConfig
|
|
312
|
+
| PopsIframeConfig
|
|
313
|
+
| PopsLoadingConfig
|
|
314
|
+
| PopsPanelConfig
|
|
315
|
+
| PopsFolderConfig,
|
|
321
316
|
popsType: PopsInstStoreType,
|
|
322
|
-
instConfigList:
|
|
317
|
+
instConfigList: PopsInstGeneralConfig[],
|
|
323
318
|
guid: string,
|
|
324
319
|
$anim: HTMLElement,
|
|
325
320
|
$mask?: HTMLElement
|
|
326
321
|
) {
|
|
327
322
|
return new Promise<void>((resolve) => {
|
|
328
|
-
const
|
|
323
|
+
const $pops = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
|
|
329
324
|
if (popsType === "drawer") {
|
|
330
|
-
const drawerConfig = config as
|
|
325
|
+
const drawerConfig = config as PopsDrawerConfig;
|
|
331
326
|
popsUtils.setTimeout(() => {
|
|
332
327
|
if ($mask) {
|
|
333
328
|
popsDOMUtils.css($mask, "display", "");
|
|
@@ -335,9 +330,9 @@ export const PopsInstanceUtils = {
|
|
|
335
330
|
const direction = drawerConfig.direction!;
|
|
336
331
|
const size = drawerConfig.size!.toString();
|
|
337
332
|
if (["top", "bottom"].includes(direction)) {
|
|
338
|
-
|
|
333
|
+
$pops.style.setProperty("height", size);
|
|
339
334
|
} else if (["left", "right"].includes(direction)) {
|
|
340
|
-
|
|
335
|
+
$pops.style.setProperty("width", size);
|
|
341
336
|
} else {
|
|
342
337
|
console.error("未知direction:", direction);
|
|
343
338
|
}
|
|
@@ -347,39 +342,34 @@ export const PopsInstanceUtils = {
|
|
|
347
342
|
const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
|
|
348
343
|
if (fintInst) {
|
|
349
344
|
const instConfigItem = fintInst;
|
|
350
|
-
instConfigItem.
|
|
351
|
-
instConfigItem.
|
|
345
|
+
instConfigItem.$anim.style.width = "";
|
|
346
|
+
instConfigItem.$anim.style.height = "";
|
|
352
347
|
Reflect.set(
|
|
353
|
-
instConfigItem.
|
|
348
|
+
instConfigItem.$anim.style,
|
|
354
349
|
"animation-name",
|
|
355
|
-
instConfigItem
|
|
350
|
+
instConfigItem.$anim!.getAttribute("anim")!.replace("-reverse", "")
|
|
356
351
|
);
|
|
357
|
-
if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.
|
|
352
|
+
if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
|
|
358
353
|
/**
|
|
359
354
|
* 动画结束的回调
|
|
360
355
|
*/
|
|
361
356
|
function animationendCallBack() {
|
|
362
|
-
popsDOMUtils.off(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
animationendCallBack,
|
|
366
|
-
{
|
|
367
|
-
capture: true,
|
|
368
|
-
}
|
|
369
|
-
);
|
|
357
|
+
popsDOMUtils.off(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
358
|
+
capture: true,
|
|
359
|
+
});
|
|
370
360
|
resolve();
|
|
371
361
|
}
|
|
372
|
-
instConfigItem.
|
|
373
|
-
if (instConfigItem
|
|
374
|
-
instConfigItem.
|
|
362
|
+
instConfigItem.$anim.style.display = "";
|
|
363
|
+
if (instConfigItem.$mask) {
|
|
364
|
+
instConfigItem.$mask.style.display = "";
|
|
375
365
|
}
|
|
376
|
-
popsDOMUtils.on(instConfigItem
|
|
366
|
+
popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
377
367
|
capture: true,
|
|
378
368
|
});
|
|
379
369
|
} else {
|
|
380
|
-
instConfigItem.
|
|
381
|
-
if (instConfigItem
|
|
382
|
-
instConfigItem.
|
|
370
|
+
instConfigItem.$anim.style.display = "";
|
|
371
|
+
if (instConfigItem.$mask) {
|
|
372
|
+
instConfigItem.$mask.style.display = "";
|
|
383
373
|
}
|
|
384
374
|
resolve();
|
|
385
375
|
}
|
|
@@ -397,22 +387,22 @@ export const PopsInstanceUtils = {
|
|
|
397
387
|
*/
|
|
398
388
|
close(
|
|
399
389
|
config:
|
|
400
|
-
|
|
|
401
|
-
|
|
|
402
|
-
|
|
|
403
|
-
|
|
|
404
|
-
|
|
|
405
|
-
|
|
|
406
|
-
|
|
|
407
|
-
|
|
|
390
|
+
| PopsAlertConfig
|
|
391
|
+
| PopsDrawerConfig
|
|
392
|
+
| PopsPromptConfig
|
|
393
|
+
| PopsConfirmConfig
|
|
394
|
+
| PopsIframeConfig
|
|
395
|
+
| PopsLoadingConfig
|
|
396
|
+
| PopsPanelConfig
|
|
397
|
+
| PopsFolderConfig,
|
|
408
398
|
popsType: string,
|
|
409
|
-
instConfigList:
|
|
399
|
+
instConfigList: PopsInstGeneralConfig[],
|
|
410
400
|
guid: string,
|
|
411
401
|
$anim: HTMLElement
|
|
412
402
|
) {
|
|
413
403
|
return new Promise<void>((resolve) => {
|
|
414
|
-
const
|
|
415
|
-
const drawerConfig = config as Required<
|
|
404
|
+
const $pops = $anim.querySelector<HTMLDivElement>(".pops[type-value]")!;
|
|
405
|
+
const drawerConfig = config as Required<PopsDrawerConfig>;
|
|
416
406
|
/**
|
|
417
407
|
* 动画结束事件
|
|
418
408
|
*/
|
|
@@ -424,25 +414,25 @@ export const PopsInstanceUtils = {
|
|
|
424
414
|
if ((event as TransitionEvent).propertyName !== "transform") {
|
|
425
415
|
return;
|
|
426
416
|
}
|
|
427
|
-
popsDOMUtils.off(
|
|
417
|
+
popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(), void 0, closeCallBack);
|
|
428
418
|
PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
429
419
|
resolve();
|
|
430
420
|
}
|
|
431
|
-
|
|
432
|
-
popsDOMUtils.on(
|
|
433
|
-
const popsTransForm = getComputedStyle(
|
|
421
|
+
// 监听过渡结束
|
|
422
|
+
popsDOMUtils.on($pops, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
|
|
423
|
+
const popsTransForm = getComputedStyle($pops).transform;
|
|
434
424
|
if (popsTransForm !== "none") {
|
|
435
|
-
popsDOMUtils.trigger(
|
|
425
|
+
popsDOMUtils.trigger($pops, popsDOMUtils.getTransitionEndNameList(), void 0, true);
|
|
436
426
|
return;
|
|
437
427
|
}
|
|
438
428
|
if (["top"].includes(drawerConfig.direction)) {
|
|
439
|
-
|
|
429
|
+
$pops.style.setProperty("transform", "translateY(-100%)");
|
|
440
430
|
} else if (["bottom"].includes(drawerConfig.direction)) {
|
|
441
|
-
|
|
431
|
+
$pops.style.setProperty("transform", "translateY(100%)");
|
|
442
432
|
} else if (["left"].includes(drawerConfig.direction)) {
|
|
443
|
-
|
|
433
|
+
$pops.style.setProperty("transform", "translateX(-100%)");
|
|
444
434
|
} else if (["right"].includes(drawerConfig.direction)) {
|
|
445
|
-
|
|
435
|
+
$pops.style.setProperty("transform", "translateX(100%)");
|
|
446
436
|
} else {
|
|
447
437
|
console.error("未知direction:", drawerConfig.direction);
|
|
448
438
|
}
|
|
@@ -463,11 +453,11 @@ export const PopsInstanceUtils = {
|
|
|
463
453
|
* 说明:
|
|
464
454
|
* + 元素的position为absolute或者fixed
|
|
465
455
|
* + 会为元素的
|
|
466
|
-
* @param
|
|
456
|
+
* @param $move 需要拖拽的元素
|
|
467
457
|
* @param options 配置
|
|
468
458
|
*/
|
|
469
459
|
drag(
|
|
470
|
-
|
|
460
|
+
$move: HTMLElement,
|
|
471
461
|
options: {
|
|
472
462
|
dragElement: HTMLElement;
|
|
473
463
|
limit: boolean;
|
|
@@ -489,9 +479,9 @@ export const PopsInstanceUtils = {
|
|
|
489
479
|
options
|
|
490
480
|
);
|
|
491
481
|
let isMove = false;
|
|
492
|
-
|
|
482
|
+
// 点击元素,left偏移
|
|
493
483
|
let clickElementLeftOffset = 0;
|
|
494
|
-
|
|
484
|
+
// 点击元素,top偏移
|
|
495
485
|
let clickElementTopOffset = 0;
|
|
496
486
|
const AnyTouch = popsUtils.AnyTouch();
|
|
497
487
|
const anyTouchElement = new AnyTouch(options.dragElement, {
|
|
@@ -549,7 +539,7 @@ export const PopsInstanceUtils = {
|
|
|
549
539
|
}
|
|
550
540
|
}
|
|
551
541
|
// 获取transform偏移
|
|
552
|
-
let transformInfo = popsDOMUtils.getTransform(
|
|
542
|
+
let transformInfo = popsDOMUtils.getTransform($move);
|
|
553
543
|
|
|
554
544
|
let resumeMoveElementStyle: ((...args: any[]) => any) | null = null;
|
|
555
545
|
|
|
@@ -559,7 +549,7 @@ export const PopsInstanceUtils = {
|
|
|
559
549
|
const rect = options.dragElement.getBoundingClientRect();
|
|
560
550
|
clickElementLeftOffset = event.x - rect.left;
|
|
561
551
|
clickElementTopOffset = event.y - rect.top;
|
|
562
|
-
transformInfo = popsDOMUtils.getTransform(
|
|
552
|
+
transformInfo = popsDOMUtils.getTransform($move);
|
|
563
553
|
//if (event.nativeEvent.offsetX) {
|
|
564
554
|
// clickElementLeftOffset = parseInt(event.nativeEvent.offsetX);
|
|
565
555
|
//} else {
|
|
@@ -570,66 +560,66 @@ export const PopsInstanceUtils = {
|
|
|
570
560
|
//} else {
|
|
571
561
|
// clickElementTopOffset = parseInt(event.getOffset().y);
|
|
572
562
|
//}
|
|
573
|
-
resumeMoveElementStyle = changeMoveElementStyle(
|
|
563
|
+
resumeMoveElementStyle = changeMoveElementStyle($move);
|
|
574
564
|
}
|
|
575
565
|
|
|
576
566
|
/** 当前移动的left偏移 */
|
|
577
567
|
let currentMoveLeftOffset = event.x - clickElementLeftOffset + transformInfo.transformLeft;
|
|
578
568
|
/** 当前移动的top偏移 */
|
|
579
569
|
let currentMoveTopOffset = event.y - clickElementTopOffset + transformInfo.transformTop;
|
|
580
|
-
|
|
570
|
+
// 拖拽移动
|
|
581
571
|
if (event.phase === "move") {
|
|
582
572
|
if (options.limit) {
|
|
583
|
-
|
|
584
|
-
|
|
573
|
+
// 限制在容器内移动
|
|
574
|
+
// left偏移最大值
|
|
585
575
|
const maxLeftOffset =
|
|
586
576
|
getContainerWidthOrHeight(options.container!).width -
|
|
587
|
-
popsDOMUtils.width(
|
|
577
|
+
popsDOMUtils.width($move) +
|
|
588
578
|
transformInfo.transformLeft;
|
|
589
579
|
const { left: minLeftOffset, top: minTopOffset } = getContainerTopOrLeft(options.container!);
|
|
590
|
-
|
|
580
|
+
// top偏移的最大值
|
|
591
581
|
const maxTopOffset =
|
|
592
582
|
getContainerWidthOrHeight(options.container!).height -
|
|
593
|
-
popsDOMUtils.height(
|
|
583
|
+
popsDOMUtils.height($move) +
|
|
594
584
|
transformInfo.transformTop;
|
|
595
585
|
if (currentMoveLeftOffset > maxLeftOffset) {
|
|
596
|
-
|
|
586
|
+
// 不允许超过容器的最大宽度
|
|
597
587
|
currentMoveLeftOffset = maxLeftOffset;
|
|
598
588
|
}
|
|
599
589
|
if (currentMoveTopOffset > maxTopOffset) {
|
|
600
|
-
|
|
590
|
+
// 不允许超过容器的最大高度
|
|
601
591
|
currentMoveTopOffset = maxTopOffset;
|
|
602
592
|
}
|
|
603
593
|
if (currentMoveLeftOffset - options.extraDistance * 2 < minLeftOffset + transformInfo.transformLeft) {
|
|
604
|
-
|
|
594
|
+
// 不允许left偏移小于容器最小值
|
|
605
595
|
currentMoveLeftOffset = minLeftOffset + transformInfo.transformLeft;
|
|
606
|
-
|
|
596
|
+
// 最左边 +额外距离
|
|
607
597
|
currentMoveLeftOffset += options.extraDistance;
|
|
608
598
|
} else {
|
|
609
|
-
|
|
599
|
+
// 最右边 -额外距离
|
|
610
600
|
currentMoveLeftOffset -= options.extraDistance;
|
|
611
601
|
}
|
|
612
602
|
if (currentMoveTopOffset - options.extraDistance * 2 < minTopOffset + transformInfo.transformTop) {
|
|
613
|
-
|
|
603
|
+
// 不允许top偏移小于容器最小值
|
|
614
604
|
currentMoveTopOffset = minTopOffset + transformInfo.transformTop;
|
|
615
|
-
|
|
605
|
+
// 最上面 +额外距离
|
|
616
606
|
currentMoveTopOffset += options.extraDistance;
|
|
617
607
|
} else {
|
|
618
|
-
|
|
608
|
+
// 最下面 -额外距离
|
|
619
609
|
currentMoveTopOffset -= options.extraDistance;
|
|
620
610
|
}
|
|
621
611
|
}
|
|
622
612
|
if (typeof options.moveCallBack === "function") {
|
|
623
|
-
options.moveCallBack(
|
|
613
|
+
options.moveCallBack($move, currentMoveLeftOffset, currentMoveTopOffset);
|
|
624
614
|
}
|
|
625
615
|
|
|
626
|
-
popsDOMUtils.css(
|
|
616
|
+
popsDOMUtils.css($move, {
|
|
627
617
|
left: currentMoveLeftOffset + "px",
|
|
628
618
|
top: currentMoveTopOffset + "px",
|
|
629
619
|
});
|
|
630
620
|
}
|
|
631
621
|
|
|
632
|
-
|
|
622
|
+
// 停止拖拽
|
|
633
623
|
if (event.phase === "end") {
|
|
634
624
|
isMove = false;
|
|
635
625
|
if (typeof resumeMoveElementStyle === "function") {
|
|
@@ -637,12 +627,12 @@ export const PopsInstanceUtils = {
|
|
|
637
627
|
resumeMoveElementStyle = null;
|
|
638
628
|
}
|
|
639
629
|
if (typeof options.endCallBack === "function") {
|
|
640
|
-
options.endCallBack(
|
|
630
|
+
options.endCallBack($move, currentMoveLeftOffset, currentMoveTopOffset);
|
|
641
631
|
}
|
|
642
632
|
}
|
|
643
633
|
});
|
|
644
634
|
if (options.triggerClick) {
|
|
645
|
-
|
|
635
|
+
// 因为会覆盖上面的点击事件,主动触发一下
|
|
646
636
|
anyTouchElement.on(["tap"], function (event) {
|
|
647
637
|
event.changedPoints.forEach((item) => {
|
|
648
638
|
popsDOMUtils.trigger(item.target! as HTMLElement, "click", void 0, true);
|
|
@@ -668,8 +658,8 @@ export const PopsInstanceUtils = {
|
|
|
668
658
|
throw new Error("获取前面的值或后面的值的方法不能为空");
|
|
669
659
|
}
|
|
670
660
|
return function (after_obj: T, before_obj: T) {
|
|
671
|
-
const beforeValue = getBeforeValueFun(before_obj);
|
|
672
|
-
const afterValue = getAfterValueFun(after_obj);
|
|
661
|
+
const beforeValue = getBeforeValueFun(before_obj); // 前
|
|
662
|
+
const afterValue = getAfterValueFun(after_obj); // 后
|
|
673
663
|
if (sortByDesc) {
|
|
674
664
|
if (afterValue > beforeValue) {
|
|
675
665
|
return -1;
|
package/src/utils/PopsUtils.ts
CHANGED
|
@@ -90,12 +90,6 @@ class PopsUtils {
|
|
|
90
90
|
assign<T1, T2 extends object, T3 extends boolean>(target: T1, source: T2, isAdd?: T3): T3 extends true ? T1 & T2 : T1;
|
|
91
91
|
assign(target = {}, source = {}, isAdd = false) {
|
|
92
92
|
const UtilsContext = this;
|
|
93
|
-
if (source == null) {
|
|
94
|
-
return target;
|
|
95
|
-
}
|
|
96
|
-
if (target == null) {
|
|
97
|
-
target = {};
|
|
98
|
-
}
|
|
99
93
|
if (Array.isArray(source)) {
|
|
100
94
|
const canTraverse = source.filter((item) => {
|
|
101
95
|
return typeof item === "object";
|
|
@@ -104,42 +98,49 @@ class PopsUtils {
|
|
|
104
98
|
return source;
|
|
105
99
|
}
|
|
106
100
|
}
|
|
101
|
+
if (source == null) {
|
|
102
|
+
return target;
|
|
103
|
+
}
|
|
104
|
+
if (target == null) {
|
|
105
|
+
target = {};
|
|
106
|
+
}
|
|
107
|
+
// 当前遍历的目标对象
|
|
108
|
+
let iteratorTarget;
|
|
107
109
|
if (isAdd) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const targetValue = (target as any)[targetKeyName];
|
|
111
|
-
const sourceValue = (source as any)[sourceKeyName];
|
|
112
|
-
if (
|
|
113
|
-
typeof sourceValue === "object" &&
|
|
114
|
-
sourceValue != null &&
|
|
115
|
-
sourceKeyName in target &&
|
|
116
|
-
!UtilsContext.isDOM(sourceValue)
|
|
117
|
-
) {
|
|
118
|
-
/* 源端的值是object类型,且不是元素节点 */
|
|
119
|
-
(target as any)[sourceKeyName] = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
(target as any)[sourceKeyName] = sourceValue;
|
|
123
|
-
}
|
|
110
|
+
// 追加并覆盖是以source为准
|
|
111
|
+
iteratorTarget = source;
|
|
124
112
|
} else {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
113
|
+
// 覆盖以target为准
|
|
114
|
+
iteratorTarget = target;
|
|
115
|
+
}
|
|
116
|
+
for (const keyName in iteratorTarget) {
|
|
117
|
+
if (!isAdd && !(keyName in source)) {
|
|
118
|
+
// 仅替换 但是源端没有此键
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const targetValue = Reflect.get(target, keyName);
|
|
122
|
+
const sourceValue = Reflect.get(source, keyName);
|
|
123
|
+
if (
|
|
124
|
+
typeof sourceValue === "object" &&
|
|
125
|
+
sourceValue != null &&
|
|
126
|
+
keyName in target &&
|
|
127
|
+
!UtilsContext.isDOM(sourceValue)
|
|
128
|
+
) {
|
|
129
|
+
// 源端的值是object类型,且不是元素节点
|
|
130
|
+
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
131
|
+
let childObjectValue;
|
|
132
|
+
if (Array.isArray(sourceValue)) {
|
|
133
|
+
if (Array.isArray(targetValue)) {
|
|
134
|
+
targetValue.length = 0;
|
|
139
135
|
}
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
childObjectValue = sourceValue;
|
|
137
|
+
} else {
|
|
138
|
+
childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
142
139
|
}
|
|
140
|
+
Reflect.set(target, keyName, childObjectValue);
|
|
141
|
+
} else {
|
|
142
|
+
/* 直接赋值 */
|
|
143
|
+
Reflect.set(target, keyName, sourceValue);
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
|
|
@@ -272,19 +273,19 @@ class PopsUtils {
|
|
|
272
273
|
|
|
273
274
|
const timeRegexp = {
|
|
274
275
|
yyyy: time.getFullYear(),
|
|
275
|
-
|
|
276
|
+
// 年
|
|
276
277
|
MM: checkTime(time.getMonth() + 1),
|
|
277
|
-
|
|
278
|
+
// 月
|
|
278
279
|
dd: checkTime(time.getDate()),
|
|
279
|
-
|
|
280
|
+
// 日
|
|
280
281
|
HH: checkTime(time.getHours()),
|
|
281
|
-
|
|
282
|
+
// 时 (24小时制)
|
|
282
283
|
hh: checkTime(timeSystemChange(time.getHours())),
|
|
283
|
-
|
|
284
|
+
// 时 (12小时制)
|
|
284
285
|
mm: checkTime(time.getMinutes()),
|
|
285
|
-
|
|
286
|
+
// 分
|
|
286
287
|
ss: checkTime(time.getSeconds()),
|
|
287
|
-
|
|
288
|
+
// 秒
|
|
288
289
|
};
|
|
289
290
|
Object.keys(timeRegexp).forEach(function (key) {
|
|
290
291
|
const replaecRegexp = new RegExp(key, "g");
|
|
@@ -399,6 +400,20 @@ class PopsUtils {
|
|
|
399
400
|
PopsCore.clearInterval(timeId);
|
|
400
401
|
}
|
|
401
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* 覆盖对象中的数组新值
|
|
405
|
+
*/
|
|
406
|
+
setArray<T>(target: T, key: keyof T, newArr: any[]) {
|
|
407
|
+
if (target == null) return;
|
|
408
|
+
if (!Array.isArray(newArr)) return;
|
|
409
|
+
const arr: any = target[key];
|
|
410
|
+
if (Array.isArray(target[key])) {
|
|
411
|
+
arr.length = 0;
|
|
412
|
+
} else {
|
|
413
|
+
(<any>target)[key] = [];
|
|
414
|
+
}
|
|
415
|
+
(<any>target)[key] = newArr;
|
|
416
|
+
}
|
|
402
417
|
}
|
|
403
418
|
|
|
404
419
|
const popsUtils = new PopsUtils();
|