@whitesev/pops 2.6.0 → 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 +1233 -1092
- 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 +1233 -1092
- 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 +1233 -1092
- 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 +1233 -1092
- 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 +1233 -1092
- 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 +1233 -1092
- 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 +446 -428
- package/src/components/panel/index.css +11 -3
- 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/css/common.css +6 -0
- package/src/handler/PopsElementHandler.ts +29 -30
- package/src/handler/PopsHandler.ts +43 -43
- package/src/svg/cpu.svg +7 -7
- package/src/svg/delete.svg +4 -4
- package/src/svg/documentCopy.svg +4 -4
- package/src/svg/edit.svg +7 -7
- package/src/svg/eleme.svg +4 -4
- package/src/svg/elemePlus.svg +4 -4
- package/src/svg/headset.svg +4 -4
- package/src/svg/hide.svg +7 -7
- package/src/svg/keyboard.svg +7 -7
- package/src/svg/loading.svg +4 -4
- package/src/svg/max.svg +4 -4
- package/src/svg/min.svg +2 -4
- package/src/svg/mise.svg +4 -4
- package/src/svg/monitor.svg +4 -4
- package/src/svg/next.svg +4 -4
- package/src/svg/picture.svg +7 -7
- package/src/svg/prev.svg +4 -4
- package/src/svg/search.svg +4 -4
- package/src/svg/share.svg +4 -4
- package/src/svg/upload.svg +4 -4
- package/src/svg/videoPause.svg +4 -4
- package/src/svg/videoPlay.svg +4 -4
- package/src/svg/view.svg +4 -4
- 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
|
@@ -6,17 +6,18 @@ import type { PopsHandlerEventConfig } from "../../types/event";
|
|
|
6
6
|
import type { PopsType } from "../../types/main";
|
|
7
7
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
8
8
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
9
|
-
import {
|
|
10
|
-
import type {
|
|
9
|
+
import { PopsDrawerDefaultConfig } from "./defaultConfig";
|
|
10
|
+
import type { PopsDrawerConfig } from "./types";
|
|
11
11
|
|
|
12
12
|
export const PopsDrawer = {
|
|
13
|
-
init(
|
|
13
|
+
init(__config__: PopsDrawerConfig) {
|
|
14
14
|
const guid = popsUtils.getRandomGUID();
|
|
15
15
|
// 设置当前类型
|
|
16
16
|
const popsType: PopsType = "drawer";
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
let config = PopsDrawerDefaultConfig();
|
|
18
19
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
19
|
-
config = popsUtils.assign(config,
|
|
20
|
+
config = popsUtils.assign(config, __config__);
|
|
20
21
|
config = PopsHandler.handleOnly(popsType, config);
|
|
21
22
|
|
|
22
23
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
@@ -127,12 +128,12 @@ export const PopsDrawer = {
|
|
|
127
128
|
$pops,
|
|
128
129
|
$mask
|
|
129
130
|
);
|
|
130
|
-
|
|
131
|
+
// 处理方向
|
|
131
132
|
|
|
132
133
|
$pops.setAttribute("direction", config.direction);
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
// 处理border-radius
|
|
136
|
+
// 处理动画前的宽高
|
|
136
137
|
if (config.direction === "top") {
|
|
137
138
|
$pops.style.setProperty("height", "0");
|
|
138
139
|
|
|
@@ -151,13 +152,13 @@ export const PopsDrawer = {
|
|
|
151
152
|
$pops.style.setProperty("border-radius", `${config.borderRadius}px 0px ${config.borderRadius}px 0px`);
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
// 按下Esc键触发关闭
|
|
155
156
|
if (config.closeOnPressEscape) {
|
|
156
157
|
PopsHandler.handleKeyboardEvent("Escape", [], function () {
|
|
157
158
|
evtConfig.close();
|
|
158
159
|
});
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
+
// 待处理的点击事件列表
|
|
161
162
|
const needHandleClickEventList: {
|
|
162
163
|
type: PopsHandlerEventConfig["type"];
|
|
163
164
|
ele: HTMLElement;
|
|
@@ -180,15 +181,15 @@ export const PopsDrawer = {
|
|
|
180
181
|
},
|
|
181
182
|
];
|
|
182
183
|
needHandleClickEventList.forEach((item) => {
|
|
183
|
-
PopsHandler.handleClickEvent(item.type, item.ele, evtConfig, (
|
|
184
|
+
PopsHandler.handleClickEvent(item.type, item.ele, evtConfig, (evtConfig, event) => {
|
|
184
185
|
const callback = config.btn[item.type].callback;
|
|
185
186
|
if (typeof callback === "function") {
|
|
186
|
-
callback(
|
|
187
|
+
callback(evtConfig, event);
|
|
187
188
|
}
|
|
188
189
|
});
|
|
189
190
|
});
|
|
190
191
|
|
|
191
|
-
|
|
192
|
+
// 先隐藏,然后根据config.openDelay来显示
|
|
192
193
|
$elList.forEach((element) => {
|
|
193
194
|
element.style.setProperty("display", "none");
|
|
194
195
|
if (["top"].includes(config.direction)) {
|
|
@@ -210,7 +211,7 @@ export const PopsDrawer = {
|
|
|
210
211
|
}
|
|
211
212
|
element.style.setProperty("display", "");
|
|
212
213
|
});
|
|
213
|
-
|
|
214
|
+
// 创建到页面中
|
|
214
215
|
|
|
215
216
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
216
217
|
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
@@ -230,9 +231,9 @@ export const PopsDrawer = {
|
|
|
230
231
|
|
|
231
232
|
PopsHandler.handlePush(popsType, {
|
|
232
233
|
guid: guid,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
$anim: $anim,
|
|
235
|
+
$pops: $pops,
|
|
236
|
+
$mask: $mask!,
|
|
236
237
|
$shadowContainer: $shadowContainer,
|
|
237
238
|
$shadowRoot: $shadowRoot,
|
|
238
239
|
});
|
|
@@ -2,17 +2,17 @@ import type {
|
|
|
2
2
|
PopsTitleConfig,
|
|
3
3
|
PopsContentConfig,
|
|
4
4
|
// PopsDragConfig,
|
|
5
|
-
|
|
5
|
+
PopsGeneralConfig,
|
|
6
6
|
PopsMoreButtonConfig,
|
|
7
7
|
} from "../../../types/components";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* pops.drawer
|
|
11
11
|
*/
|
|
12
|
-
export interface
|
|
12
|
+
export interface PopsDrawerConfig
|
|
13
13
|
extends PopsContentConfig,
|
|
14
14
|
PopsMoreButtonConfig,
|
|
15
|
-
Omit<
|
|
15
|
+
Omit<PopsGeneralConfig, "width" | "height" | "position" | "animation"> {
|
|
16
16
|
/**
|
|
17
17
|
* 标题
|
|
18
18
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PopsFolderConfig } from "./types";
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const PopsFolderDefaultConfig = (): DeepRequired<PopsFolderConfig> => {
|
|
4
4
|
return {
|
|
5
5
|
title: {
|
|
6
6
|
text: "pops.Folder",
|
|
@@ -11,7 +11,6 @@ export const PopsFolderConfig = (): DeepRequired<PopsFolderDetails> => {
|
|
|
11
11
|
sort: {
|
|
12
12
|
name: "latestTime",
|
|
13
13
|
isDesc: false,
|
|
14
|
-
// @ts-ignore
|
|
15
14
|
callback() {},
|
|
16
15
|
},
|
|
17
16
|
folder: [
|
|
@@ -23,7 +22,6 @@ export const PopsFolderConfig = (): DeepRequired<PopsFolderDetails> => {
|
|
|
23
22
|
latestTime: 0,
|
|
24
23
|
isFolder: true,
|
|
25
24
|
index: 0,
|
|
26
|
-
// @ts-ignore
|
|
27
25
|
clickEvent() {
|
|
28
26
|
return [
|
|
29
27
|
{
|
|
@@ -34,7 +32,6 @@ export const PopsFolderConfig = (): DeepRequired<PopsFolderDetails> => {
|
|
|
34
32
|
latestTime: 0,
|
|
35
33
|
isFolder: true,
|
|
36
34
|
index: 0,
|
|
37
|
-
// @ts-ignore
|
|
38
35
|
clickEvent() {
|
|
39
36
|
return [
|
|
40
37
|
{
|
|
@@ -45,9 +42,13 @@ export const PopsFolderConfig = (): DeepRequired<PopsFolderDetails> => {
|
|
|
45
42
|
latestTime: 1702039602126,
|
|
46
43
|
isFolder: false,
|
|
47
44
|
index: 1,
|
|
48
|
-
clickEvent() {
|
|
49
|
-
console.log("下载文件:",
|
|
50
|
-
return
|
|
45
|
+
clickEvent(event, config) {
|
|
46
|
+
console.log("下载文件:", config);
|
|
47
|
+
return {
|
|
48
|
+
autoDownload: true,
|
|
49
|
+
url: "https://update.greasyfork.org/scripts/456485/pops.js",
|
|
50
|
+
mode: "aBlank",
|
|
51
|
+
};
|
|
51
52
|
},
|
|
52
53
|
},
|
|
53
54
|
];
|
|
@@ -64,10 +65,13 @@ export const PopsFolderConfig = (): DeepRequired<PopsFolderDetails> => {
|
|
|
64
65
|
latestTime: 1702039410440,
|
|
65
66
|
isFolder: false,
|
|
66
67
|
index: 1,
|
|
67
|
-
// @ts-ignore
|
|
68
68
|
clickEvent() {
|
|
69
69
|
console.log("下载文件:", this.fileName);
|
|
70
|
-
return
|
|
70
|
+
return {
|
|
71
|
+
autoDownload: true,
|
|
72
|
+
url: "https://update.greasyfork.org/scripts/456485/pops.js",
|
|
73
|
+
mode: "openBlank",
|
|
74
|
+
};
|
|
71
75
|
},
|
|
72
76
|
},
|
|
73
77
|
],
|
|
@@ -84,8 +88,8 @@ export const PopsFolderConfig = (): DeepRequired<PopsFolderDetails> => {
|
|
|
84
88
|
iconIsLoading: false,
|
|
85
89
|
text: "确定",
|
|
86
90
|
type: "primary",
|
|
87
|
-
callback(
|
|
88
|
-
|
|
91
|
+
callback(evtConfig) {
|
|
92
|
+
evtConfig.close();
|
|
89
93
|
},
|
|
90
94
|
},
|
|
91
95
|
cancel: {
|
|
@@ -96,8 +100,8 @@ export const PopsFolderConfig = (): DeepRequired<PopsFolderDetails> => {
|
|
|
96
100
|
iconIsLoading: false,
|
|
97
101
|
text: "关闭",
|
|
98
102
|
type: "default",
|
|
99
|
-
callback(
|
|
100
|
-
|
|
103
|
+
callback(evtConfig) {
|
|
104
|
+
evtConfig.close();
|
|
101
105
|
},
|
|
102
106
|
},
|
|
103
107
|
other: {
|
|
@@ -108,14 +112,14 @@ export const PopsFolderConfig = (): DeepRequired<PopsFolderDetails> => {
|
|
|
108
112
|
iconIsLoading: false,
|
|
109
113
|
text: "其它按钮",
|
|
110
114
|
type: "default",
|
|
111
|
-
callback(
|
|
112
|
-
|
|
115
|
+
callback(evtConfig) {
|
|
116
|
+
evtConfig.close();
|
|
113
117
|
},
|
|
114
118
|
},
|
|
115
119
|
close: {
|
|
116
120
|
enable: true,
|
|
117
|
-
callback(
|
|
118
|
-
|
|
121
|
+
callback(evtConfig) {
|
|
122
|
+
evtConfig.close();
|
|
119
123
|
},
|
|
120
124
|
},
|
|
121
125
|
},
|
|
@@ -8,19 +8,19 @@ import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
|
8
8
|
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
9
9
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
10
10
|
import { PopsLoading } from "../loading";
|
|
11
|
-
import {
|
|
11
|
+
import { PopsFolderDefaultConfig } from "./defaultConfig";
|
|
12
12
|
import { Folder_ICON } from "./folderIcon";
|
|
13
|
-
import type { PopsFolderDataConfig,
|
|
13
|
+
import type { PopsFolderDataConfig, PopsFolderConfig, PopsFolderDownloadOption } from "./types";
|
|
14
14
|
|
|
15
15
|
export const PopsFolder = {
|
|
16
|
-
init(
|
|
16
|
+
init(__config__: PopsFolderConfig) {
|
|
17
17
|
const guid = popsUtils.getRandomGUID();
|
|
18
18
|
// 设置当前类型
|
|
19
19
|
const popsType: PopsType = "folder";
|
|
20
20
|
|
|
21
|
-
let config =
|
|
21
|
+
let config = PopsFolderDefaultConfig();
|
|
22
22
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
23
|
-
config = popsUtils.assign(config,
|
|
23
|
+
config = popsUtils.assign(config, __config__);
|
|
24
24
|
config = PopsHandler.handleOnly(popsType, config);
|
|
25
25
|
|
|
26
26
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
@@ -55,7 +55,7 @@ export const PopsFolder = {
|
|
|
55
55
|
},
|
|
56
56
|
]);
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
// 办公几件套
|
|
59
59
|
Reflect.set(Folder_ICON, "docx", Folder_ICON.doc);
|
|
60
60
|
Reflect.set(Folder_ICON, "rtf", Folder_ICON.doc);
|
|
61
61
|
Reflect.set(Folder_ICON, "xlsx", Folder_ICON.xls);
|
|
@@ -63,7 +63,7 @@ export const PopsFolder = {
|
|
|
63
63
|
Reflect.set(Folder_ICON, "dmg", Folder_ICON.ipa);
|
|
64
64
|
Reflect.set(Folder_ICON, "json", Folder_ICON.js);
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
// 压缩包
|
|
67
67
|
const zipIconList = [
|
|
68
68
|
"rar",
|
|
69
69
|
"7z",
|
|
@@ -83,13 +83,13 @@ export const PopsFolder = {
|
|
|
83
83
|
"001",
|
|
84
84
|
];
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
// 图片
|
|
87
87
|
const imageIconList = ["jpg", "jpeg", "ico", "webp"];
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
// 代码语言
|
|
90
90
|
const codeLanguageIconList = ["htm", "py", "vue", "bat", "sh", "vbs", "java", "kt"];
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
// Android安装包
|
|
93
93
|
const androidIconList = ["apk", "apkm", "xapk"];
|
|
94
94
|
|
|
95
95
|
zipIconList.forEach((keyName) => {
|
|
@@ -105,8 +105,8 @@ export const PopsFolder = {
|
|
|
105
105
|
Folder_ICON[keyName as keyof typeof Folder_ICON] = Folder_ICON.apk;
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
if (
|
|
109
|
-
Reflect.set(config, "folder",
|
|
108
|
+
if (config?.folder) {
|
|
109
|
+
Reflect.set(config, "folder", config.folder);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// 先把z-index提取出来
|
|
@@ -269,7 +269,7 @@ export const PopsFolder = {
|
|
|
269
269
|
$mask = handleMask.maskElement;
|
|
270
270
|
$elList.push($mask);
|
|
271
271
|
}
|
|
272
|
-
|
|
272
|
+
// 事件
|
|
273
273
|
const evtConfig = PopsHandler.handleEventConfig(
|
|
274
274
|
config,
|
|
275
275
|
guid,
|
|
@@ -284,7 +284,7 @@ export const PopsFolder = {
|
|
|
284
284
|
PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
|
|
285
285
|
PopsHandler.handleClickEvent("cancel", btnCancelElement, evtConfig, config.btn.cancel.callback);
|
|
286
286
|
PopsHandler.handleClickEvent("other", btnOtherElement, evtConfig, config.btn.other.callback);
|
|
287
|
-
|
|
287
|
+
// 创建到页面中
|
|
288
288
|
|
|
289
289
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
290
290
|
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
@@ -299,15 +299,15 @@ export const PopsFolder = {
|
|
|
299
299
|
init() {
|
|
300
300
|
config.folder.sort();
|
|
301
301
|
this.initFolderView(config.folder);
|
|
302
|
-
|
|
302
|
+
// 将数据存到全部文件的属性_config_中
|
|
303
303
|
|
|
304
|
-
const
|
|
304
|
+
const $allFiles = folderFileListBreadcrumbPrimaryElement.querySelector<HTMLDivElement>(
|
|
305
305
|
".pops-folder-list .pops-folder-file-list-breadcrumb-allFiles:first-child"
|
|
306
306
|
)!;
|
|
307
307
|
|
|
308
|
-
Reflect.set(
|
|
309
|
-
|
|
310
|
-
popsDOMUtils.on<MouseEvent | PointerEvent>(
|
|
308
|
+
Reflect.set($allFiles, "data-config", config.folder);
|
|
309
|
+
// 设置点击顶部的全部文件事件
|
|
310
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>($allFiles, "click", (event) => {
|
|
311
311
|
this.setBreadcrumbClickEvent(event, true, config.folder);
|
|
312
312
|
});
|
|
313
313
|
// 文件名的点击排序
|
|
@@ -343,7 +343,7 @@ export const PopsFolder = {
|
|
|
343
343
|
capture: true,
|
|
344
344
|
}
|
|
345
345
|
);
|
|
346
|
-
|
|
346
|
+
// 设置默认触发的arrow
|
|
347
347
|
if (config.sort.name === "fileName") {
|
|
348
348
|
popsDOMUtils.trigger(folderListSortFileNameElement, "click", {
|
|
349
349
|
notChangeSortRule: true,
|
|
@@ -385,11 +385,11 @@ export const PopsFolder = {
|
|
|
385
385
|
let fileType = "";
|
|
386
386
|
let fileIcon = Folder_ICON.folder;
|
|
387
387
|
if (isFolder) {
|
|
388
|
-
|
|
388
|
+
// 文件夹
|
|
389
389
|
latestTime = "";
|
|
390
390
|
fileSize = "";
|
|
391
391
|
} else {
|
|
392
|
-
|
|
392
|
+
// 文件
|
|
393
393
|
fileIcon = "";
|
|
394
394
|
if (typeof latestTime === "number") {
|
|
395
395
|
latestTime = popsUtils.formatTime(latestTime);
|
|
@@ -400,8 +400,7 @@ export const PopsFolder = {
|
|
|
400
400
|
for (const keyName in Folder_ICON) {
|
|
401
401
|
if (fileName.toLowerCase().endsWith("." + keyName)) {
|
|
402
402
|
fileType = keyName;
|
|
403
|
-
|
|
404
|
-
fileIcon = (Folder_ICON as any)[keyName];
|
|
403
|
+
fileIcon = Reflect.get(Folder_ICON, keyName);
|
|
405
404
|
break;
|
|
406
405
|
}
|
|
407
406
|
}
|
|
@@ -444,7 +443,7 @@ export const PopsFolder = {
|
|
|
444
443
|
`
|
|
445
444
|
);
|
|
446
445
|
|
|
447
|
-
|
|
446
|
+
// 存储原来的值
|
|
448
447
|
const __value__ = {
|
|
449
448
|
fileName: origin_fileName,
|
|
450
449
|
latestTime: origin_latestTime,
|
|
@@ -490,11 +489,11 @@ export const PopsFolder = {
|
|
|
490
489
|
let fileType = "";
|
|
491
490
|
let fileIcon = Folder_ICON.folder;
|
|
492
491
|
if (isFolder) {
|
|
493
|
-
|
|
492
|
+
// 文件夹
|
|
494
493
|
latestTime = "";
|
|
495
494
|
fileSize = "";
|
|
496
495
|
} else {
|
|
497
|
-
|
|
496
|
+
// 文件
|
|
498
497
|
fileIcon = "";
|
|
499
498
|
if (typeof latestTime === "number") {
|
|
500
499
|
latestTime = popsUtils.formatTime(latestTime);
|
|
@@ -505,8 +504,7 @@ export const PopsFolder = {
|
|
|
505
504
|
for (const keyName in Folder_ICON) {
|
|
506
505
|
if (fileName.toLowerCase().endsWith("." + keyName)) {
|
|
507
506
|
fileType = keyName;
|
|
508
|
-
|
|
509
|
-
fileIcon = (Folder_ICON as any)[keyName];
|
|
507
|
+
fileIcon = Reflect.get(Folder_ICON, keyName);
|
|
510
508
|
break;
|
|
511
509
|
}
|
|
512
510
|
}
|
|
@@ -529,7 +527,7 @@ export const PopsFolder = {
|
|
|
529
527
|
</div>
|
|
530
528
|
`
|
|
531
529
|
);
|
|
532
|
-
|
|
530
|
+
// 存储原来的值
|
|
533
531
|
const __value__ = {
|
|
534
532
|
fileName: origin_fileName,
|
|
535
533
|
latestTime: origin_latestTime,
|
|
@@ -564,13 +562,16 @@ export const PopsFolder = {
|
|
|
564
562
|
* @param folderName 文件夹名
|
|
565
563
|
* @param folderDataConfig 文件夹配置
|
|
566
564
|
*/
|
|
567
|
-
createBreadcrumb(
|
|
565
|
+
createBreadcrumb(
|
|
566
|
+
folderName: string,
|
|
567
|
+
folderDataConfig: PopsFolderDownloadOption | PopsFolderDataConfig[] | null | undefined | void
|
|
568
|
+
) {
|
|
568
569
|
const $breadcrumb = popsDOMUtils.createElement(
|
|
569
570
|
"span",
|
|
570
571
|
{
|
|
571
572
|
className: "pops-folder-file-list-breadcrumb-allFiles cursor-p",
|
|
572
573
|
innerHTML: `<a>${folderName}</a>`,
|
|
573
|
-
|
|
574
|
+
"data-config": folderDataConfig,
|
|
574
575
|
},
|
|
575
576
|
{
|
|
576
577
|
title: folderName,
|
|
@@ -590,7 +591,7 @@ export const PopsFolder = {
|
|
|
590
591
|
dataConfigList: PopsFolderDataConfig[]
|
|
591
592
|
) {
|
|
592
593
|
this.clearFolderInfoView();
|
|
593
|
-
|
|
594
|
+
// 获取当前的导航元素
|
|
594
595
|
const $click = clickEvent.target as HTMLElement;
|
|
595
596
|
const currentBreadcrumb = $click.closest<HTMLSpanElement>("span.pops-folder-file-list-breadcrumb-allFiles");
|
|
596
597
|
if (currentBreadcrumb) {
|
|
@@ -601,7 +602,7 @@ export const PopsFolder = {
|
|
|
601
602
|
console.error("获取导航按钮失败");
|
|
602
603
|
}
|
|
603
604
|
const loadingMask = PopsLoading.init({
|
|
604
|
-
parent: $content,
|
|
605
|
+
$parent: $content,
|
|
605
606
|
content: {
|
|
606
607
|
text: "获取文件列表中...",
|
|
607
608
|
},
|
|
@@ -627,7 +628,7 @@ export const PopsFolder = {
|
|
|
627
628
|
async enterFolder(clickEvent: MouseEvent | PointerEvent, dataConfig: PopsFolderDataConfig) {
|
|
628
629
|
this.clearFolderInfoView();
|
|
629
630
|
const loadingMask = PopsLoading.init({
|
|
630
|
-
parent: $content,
|
|
631
|
+
$parent: $content,
|
|
631
632
|
content: {
|
|
632
633
|
text: "获取文件列表中...",
|
|
633
634
|
},
|
|
@@ -638,15 +639,15 @@ export const PopsFolder = {
|
|
|
638
639
|
});
|
|
639
640
|
if (typeof dataConfig.clickEvent === "function") {
|
|
640
641
|
const childConfig = await dataConfig.clickEvent(clickEvent, dataConfig);
|
|
641
|
-
|
|
642
|
+
// 添加顶部导航的箭头
|
|
642
643
|
folderFileListBreadcrumbPrimaryElement.appendChild(this.createHeaderArrowIcon());
|
|
643
|
-
|
|
644
|
-
const
|
|
644
|
+
// 添加顶部导航的链接文字
|
|
645
|
+
const $breadcrumbAllFiles = this.createBreadcrumb(dataConfig.fileName, childConfig);
|
|
645
646
|
|
|
646
|
-
folderFileListBreadcrumbPrimaryElement.appendChild(
|
|
647
|
-
|
|
647
|
+
folderFileListBreadcrumbPrimaryElement.appendChild($breadcrumbAllFiles);
|
|
648
|
+
// 设置顶部导航点击事件
|
|
648
649
|
|
|
649
|
-
popsDOMUtils.on<MouseEvent | PointerEvent>(
|
|
650
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>($breadcrumbAllFiles, "click", (event) => {
|
|
650
651
|
this.setBreadcrumbClickEvent(event, false, childConfig as PopsFolderDataConfig[]);
|
|
651
652
|
});
|
|
652
653
|
|
|
@@ -675,12 +676,12 @@ export const PopsFolder = {
|
|
|
675
676
|
$link.setAttribute("href", downloadInfo.url);
|
|
676
677
|
$link.setAttribute("target", "_blank");
|
|
677
678
|
if (downloadInfo.autoDownload) {
|
|
678
|
-
if (downloadInfo.mode == null || (downloadInfo
|
|
679
|
-
|
|
679
|
+
if (downloadInfo.mode == null || String(downloadInfo.mode) === "") {
|
|
680
|
+
// 未设置mode的话默认为aBlank
|
|
680
681
|
downloadInfo.mode = "aBlank";
|
|
681
682
|
}
|
|
682
683
|
if (downloadInfo.mode === "a" || downloadInfo.mode === "aBlank") {
|
|
683
|
-
|
|
684
|
+
// a标签下载
|
|
684
685
|
const $anchor = popsDOMUtils.createElement("a");
|
|
685
686
|
|
|
686
687
|
if (downloadInfo.mode === "aBlank") {
|
|
@@ -690,7 +691,7 @@ export const PopsFolder = {
|
|
|
690
691
|
$anchor.href = downloadInfo.url;
|
|
691
692
|
$anchor.click();
|
|
692
693
|
} else if (downloadInfo.mode === "open" || downloadInfo.mode === "openBlank") {
|
|
693
|
-
|
|
694
|
+
// window.open下载
|
|
694
695
|
|
|
695
696
|
if (downloadInfo.mode === "openBlank") {
|
|
696
697
|
globalThis.open(downloadInfo.url, "_blank");
|
|
@@ -698,7 +699,7 @@ export const PopsFolder = {
|
|
|
698
699
|
globalThis.open(downloadInfo.url);
|
|
699
700
|
}
|
|
700
701
|
} else if (downloadInfo.mode === "iframe") {
|
|
701
|
-
|
|
702
|
+
// iframe下载
|
|
702
703
|
const $downloadIframe = popsDOMUtils.createElement("iframe");
|
|
703
704
|
|
|
704
705
|
$downloadIframe.src = downloadInfo.url;
|
|
@@ -746,7 +747,7 @@ export const PopsFolder = {
|
|
|
746
747
|
const afterVal = rightConfig[sortName].toString();
|
|
747
748
|
let compareVal = beforeVal.localeCompare(afterVal);
|
|
748
749
|
if (isDesc) {
|
|
749
|
-
|
|
750
|
+
// 降序
|
|
750
751
|
if (compareVal > 0) {
|
|
751
752
|
compareVal = -1;
|
|
752
753
|
} else if (compareVal < 0) {
|
|
@@ -761,7 +762,7 @@ export const PopsFolder = {
|
|
|
761
762
|
const afterVal = rightConfig[sortName].toString();
|
|
762
763
|
let compareVal = beforeVal.localeCompare(afterVal);
|
|
763
764
|
if (isDesc) {
|
|
764
|
-
|
|
765
|
+
// 降序
|
|
765
766
|
if (compareVal > 0) {
|
|
766
767
|
compareVal = -1;
|
|
767
768
|
} else if (compareVal < 0) {
|
|
@@ -782,24 +783,24 @@ export const PopsFolder = {
|
|
|
782
783
|
let beforeVal = beforeConfig[sortName];
|
|
783
784
|
let afterVal = afterConfig[sortName];
|
|
784
785
|
if (sortName === "fileSize") {
|
|
785
|
-
|
|
786
|
+
// 文件大小,进行Float转换
|
|
786
787
|
beforeVal = parseFloat(beforeVal.toString());
|
|
787
788
|
afterVal = parseFloat(afterVal.toString());
|
|
788
789
|
} else if (sortName === "latestTime") {
|
|
789
|
-
|
|
790
|
+
// 文件时间
|
|
790
791
|
beforeVal = new Date(beforeVal).getTime();
|
|
791
792
|
afterVal = new Date(afterVal).getTime();
|
|
792
793
|
}
|
|
793
794
|
if (beforeVal > afterVal) {
|
|
794
795
|
if (isDesc) {
|
|
795
|
-
|
|
796
|
+
// 降序
|
|
796
797
|
return -1;
|
|
797
798
|
} else {
|
|
798
799
|
return 1;
|
|
799
800
|
}
|
|
800
801
|
} else if (beforeVal < afterVal) {
|
|
801
802
|
if (isDesc) {
|
|
802
|
-
|
|
803
|
+
// 降序
|
|
803
804
|
return 1;
|
|
804
805
|
} else {
|
|
805
806
|
return -1;
|
|
@@ -874,13 +875,13 @@ export const PopsFolder = {
|
|
|
874
875
|
arrowToSortFolderInfoView(target: HTMLDivElement, event: MouseEvent | PointerEvent, sortName: string) {
|
|
875
876
|
const notChangeSortRule = Reflect.get(event, "notChangeSortRule");
|
|
876
877
|
if (!notChangeSortRule) {
|
|
877
|
-
|
|
878
|
+
config.sort.name = sortName as PopsFolderConfig["sort"]["name"];
|
|
878
879
|
config.sort.isDesc = !config.sort.isDesc;
|
|
879
880
|
}
|
|
880
881
|
|
|
881
|
-
const arrowUp = target.querySelector<HTMLDivElement>(".pops-folder-icon-arrow-up")!;
|
|
882
|
-
const arrowDown = target.querySelector<HTMLDivElement>(".pops-folder-icon-arrow-down")!;
|
|
883
|
-
this.changeArrowActive(arrowUp, arrowDown, config.sort.isDesc);
|
|
882
|
+
const $arrowUp = target.querySelector<HTMLDivElement>(".pops-folder-icon-arrow-up")!;
|
|
883
|
+
const $arrowDown = target.querySelector<HTMLDivElement>(".pops-folder-icon-arrow-down")!;
|
|
884
|
+
this.changeArrowActive($arrowUp, $arrowDown, config.sort.isDesc);
|
|
884
885
|
if (
|
|
885
886
|
typeof config.sort.callback === "function" &&
|
|
886
887
|
config.sort.callback(target, event, config.sort.name, config.sort.isDesc)
|
|
@@ -905,7 +906,7 @@ export const PopsFolder = {
|
|
|
905
906
|
const popsFolder = new PopsFolder();
|
|
906
907
|
popsFolder.init();
|
|
907
908
|
Reflect.set($pops, "data-pops-folder", popsFolder);
|
|
908
|
-
|
|
909
|
+
// 拖拽
|
|
909
910
|
if (config.drag) {
|
|
910
911
|
PopsInstanceUtils.drag($pops, {
|
|
911
912
|
dragElement: $title,
|
|
@@ -917,9 +918,9 @@ export const PopsFolder = {
|
|
|
917
918
|
}
|
|
918
919
|
PopsHandler.handlePush(popsType, {
|
|
919
920
|
guid: guid,
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
921
|
+
$anim: $anim,
|
|
922
|
+
$pops: $pops,
|
|
923
|
+
$mask: $mask!,
|
|
923
924
|
$shadowContainer: $shadowContainer,
|
|
924
925
|
$shadowRoot: $shadowRoot,
|
|
925
926
|
});
|
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
PopsTitleConfig,
|
|
3
3
|
PopsDragConfig,
|
|
4
|
-
|
|
4
|
+
PopsGeneralConfig,
|
|
5
5
|
PopsMoreButtonConfig,
|
|
6
6
|
} from "../../../types/components";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* pops.folder的下载配置选项
|
|
10
|
+
*/
|
|
11
|
+
export type PopsFolderDownloadOption = {
|
|
12
|
+
/**
|
|
13
|
+
* 是否点击触发下载
|
|
14
|
+
*
|
|
15
|
+
* + true:根据设置的`mode`值来选择下载方式
|
|
16
|
+
* + false:不触发下载
|
|
17
|
+
*/
|
|
18
|
+
autoDownload: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 触发下载后会根据提供的url链接进行下载
|
|
21
|
+
*/
|
|
22
|
+
url: string;
|
|
23
|
+
/**
|
|
24
|
+
* 下载方式
|
|
25
|
+
*
|
|
26
|
+
* + a:使用a标签进行下载
|
|
27
|
+
* + aBlank:使用a标签进行下载(添加属性`target="_blank"`)
|
|
28
|
+
* + iframe:使用iframe进行下载
|
|
29
|
+
* + open:使用window.open进行下载
|
|
30
|
+
* + openBlank:使用window.open进行下载(添加参数`_blank`)
|
|
31
|
+
*
|
|
32
|
+
* @default "aBlank"
|
|
33
|
+
*/
|
|
34
|
+
mode?: "a" | "aBlank" | "iframe" | "open" | "openBlank";
|
|
35
|
+
};
|
|
8
36
|
/**
|
|
9
37
|
* pops.folder的folder配置信息
|
|
10
38
|
*/
|
|
@@ -43,28 +71,13 @@ export interface PopsFolderDataConfig {
|
|
|
43
71
|
clickEvent?: (
|
|
44
72
|
event: MouseEvent | PointerEvent,
|
|
45
73
|
config: PopsFolderDataConfig
|
|
46
|
-
) =>
|
|
47
|
-
| Promise<
|
|
48
|
-
| {
|
|
49
|
-
autoDownload: boolean;
|
|
50
|
-
url: string;
|
|
51
|
-
mode: "a" | "aBlank" | "iframe" | "open" | "openBlank";
|
|
52
|
-
}
|
|
53
|
-
| null
|
|
54
|
-
| undefined
|
|
55
|
-
| void
|
|
56
|
-
| PopsFolderDataConfig[]
|
|
57
|
-
>
|
|
58
|
-
| null
|
|
59
|
-
| undefined
|
|
60
|
-
| void
|
|
61
|
-
| PopsFolderDataConfig[];
|
|
74
|
+
) => IPromise<PopsFolderDownloadOption | PopsFolderDataConfig[] | null | undefined | void>;
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
/**
|
|
65
78
|
* pops.folder
|
|
66
79
|
*/
|
|
67
|
-
export interface
|
|
80
|
+
export interface PopsFolderConfig extends PopsTitleConfig, PopsDragConfig, PopsMoreButtonConfig, PopsGeneralConfig {
|
|
68
81
|
/**
|
|
69
82
|
* 排序
|
|
70
83
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PopsIframeConfig } from "./types";
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const PopsIframeDefaultConfig = (): DeepRequired<PopsIframeConfig> => {
|
|
4
4
|
return {
|
|
5
5
|
title: {
|
|
6
6
|
position: "center",
|