@whitesev/pops 1.4.0 → 1.5.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.map +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +50 -48
- package/src/Config.ts +3 -0
- package/src/Core.ts +45 -0
- package/src/Pops.ts +340 -0
- package/src/components/alert/index.css +45 -0
- package/src/components/alert/index.ts +216 -0
- package/src/components/alert/indexType.ts +30 -0
- package/src/components/confirm/index.css +45 -0
- package/src/components/confirm/index.ts +264 -0
- package/src/components/confirm/indexType.ts +17 -0
- package/src/components/drawer/index.css +47 -0
- package/src/components/drawer/index.ts +338 -0
- package/src/components/drawer/indexType.ts +53 -0
- package/src/components/folder/folderIcon.ts +28 -0
- package/src/components/folder/index.css +291 -0
- package/src/components/folder/index.ts +1111 -0
- package/src/components/folder/indexType.ts +87 -0
- package/src/components/iframe/index.css +90 -0
- package/src/components/iframe/index.ts +415 -0
- package/src/components/iframe/indexType.ts +144 -0
- package/src/components/loading/index.css +60 -0
- package/src/components/loading/index.ts +123 -0
- package/src/components/loading/indexType.ts +31 -0
- package/src/components/panel/buttonType.ts +60 -0
- package/src/components/panel/commonType.ts +50 -0
- package/src/components/panel/deepMenuType.ts +59 -0
- package/src/components/panel/formsType.ts +32 -0
- package/src/components/panel/index.css +754 -0
- package/src/components/panel/index.ts +2435 -0
- package/src/components/panel/indexType.ts +107 -0
- package/src/components/panel/inputType.ts +65 -0
- package/src/components/panel/ownType.ts +28 -0
- package/src/components/panel/selectType.ts +80 -0
- package/src/components/panel/sliderType.ts +59 -0
- package/src/components/panel/switchType.ts +43 -0
- package/src/components/panel/textareaType.ts +54 -0
- package/src/components/prompt/index.css +60 -0
- package/src/components/prompt/index.ts +293 -0
- package/src/components/prompt/indexType.ts +47 -0
- package/src/components/rightClickMenu/index.ts +729 -0
- package/src/components/rightClickMenu/indexType.ts +89 -0
- package/src/components/searchSuggestion/index.css +0 -0
- package/src/components/searchSuggestion/index.ts +656 -0
- package/src/components/searchSuggestion/indexType.ts +238 -0
- package/src/components/tooltip/index.css +171 -0
- package/src/components/tooltip/index.ts +358 -0
- package/src/components/tooltip/indexType.ts +95 -0
- package/src/css/animation.css +2240 -0
- package/src/css/button.css +290 -0
- package/src/css/common.css +24 -0
- package/src/css/index.css +135 -0
- package/src/css/ninePalaceGridPosition.css +50 -0
- package/src/css/scrollbar.css +18 -0
- package/src/handler/PopsElementHandler.ts +353 -0
- package/src/handler/PopsHandler.ts +659 -0
- package/src/svg/arrowLeft.svg +4 -0
- package/src/svg/arrowRight.svg +4 -0
- package/src/svg/chromeFilled.svg +14 -0
- package/src/svg/circleClose.svg +8 -0
- package/src/svg/close.svg +5 -0
- package/src/svg/cpu.svg +8 -0
- package/src/svg/delete.svg +5 -0
- package/src/svg/documentCopy.svg +5 -0
- package/src/svg/edit.svg +8 -0
- package/src/svg/eleme.svg +5 -0
- package/src/svg/elemePlus.svg +5 -0
- package/src/svg/headset.svg +5 -0
- package/src/svg/hide.svg +8 -0
- package/src/svg/keyboard.svg +8 -0
- package/src/svg/loading.svg +5 -0
- package/src/svg/max.svg +5 -0
- package/src/svg/min.svg +5 -0
- package/src/svg/mise.svg +5 -0
- package/src/svg/monitor.svg +5 -0
- package/src/svg/next.svg +5 -0
- package/src/svg/picture.svg +8 -0
- package/src/svg/prev.svg +5 -0
- package/src/svg/search.svg +5 -0
- package/src/svg/share.svg +5 -0
- package/src/svg/upload.svg +5 -0
- package/src/svg/videoPause.svg +5 -0
- package/src/svg/videoPlay.svg +5 -0
- package/src/svg/view.svg +5 -0
- package/src/types/PopsDOMUtilsEventType.d.ts +246 -0
- package/src/types/animation.d.ts +19 -0
- package/src/types/button.d.ts +226 -0
- package/src/types/components.d.ts +197 -0
- package/src/types/event.d.ts +62 -0
- package/src/types/global.d.ts +11 -0
- package/src/types/icon.d.ts +32 -0
- package/src/types/layer.d.ts +20 -0
- package/src/types/main.d.ts +136 -0
- package/src/types/mask.d.ts +35 -0
- package/src/types/position.d.ts +60 -0
- package/src/utils/AnyTouch.js +1394 -0
- package/src/utils/PopsDOMUtils.ts +2013 -0
- package/src/utils/PopsInstanceUtils.ts +685 -0
- package/src/utils/PopsMathUtils.ts +77 -0
- package/src/utils/PopsUtils.ts +380 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
2
|
+
import { PopsHandler } from "../../handler/PopsHandler";
|
|
3
|
+
import { pops } from "../../Pops";
|
|
4
|
+
import type { PopsMode } from "../../types/main";
|
|
5
|
+
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
6
|
+
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
7
|
+
import { popsUtils } from "../../utils/PopsUtils";
|
|
8
|
+
import type { PopsAlertDetails } from "./indexType";
|
|
9
|
+
|
|
10
|
+
export class PopsAlert {
|
|
11
|
+
constructor(details: PopsAlertDetails) {
|
|
12
|
+
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow();
|
|
13
|
+
PopsHandler.handleInit($shadowRoot, [
|
|
14
|
+
pops.config.cssText.index,
|
|
15
|
+
pops.config.cssText.ninePalaceGridPosition,
|
|
16
|
+
pops.config.cssText.scrollbar,
|
|
17
|
+
pops.config.cssText.button,
|
|
18
|
+
pops.config.cssText.anim,
|
|
19
|
+
pops.config.cssText.common,
|
|
20
|
+
pops.config.cssText.alertCSS,
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
let config: Required<PopsAlertDetails> = {
|
|
24
|
+
title: {
|
|
25
|
+
text: "默认标题",
|
|
26
|
+
position: "left",
|
|
27
|
+
html: false,
|
|
28
|
+
style: "",
|
|
29
|
+
},
|
|
30
|
+
content: {
|
|
31
|
+
text: "默认内容",
|
|
32
|
+
html: false,
|
|
33
|
+
style: "",
|
|
34
|
+
},
|
|
35
|
+
btn: {
|
|
36
|
+
position: "flex-end",
|
|
37
|
+
ok: {
|
|
38
|
+
size: void 0,
|
|
39
|
+
enable: true,
|
|
40
|
+
icon: void 0,
|
|
41
|
+
rightIcon: false,
|
|
42
|
+
iconIsLoading: false,
|
|
43
|
+
text: "确定",
|
|
44
|
+
type: "primary",
|
|
45
|
+
callback: function (event) {
|
|
46
|
+
event.close();
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
close: {
|
|
50
|
+
enable: true,
|
|
51
|
+
callback: function (event) {
|
|
52
|
+
event.close();
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
class: "",
|
|
57
|
+
only: false,
|
|
58
|
+
width: "350px",
|
|
59
|
+
height: "200px",
|
|
60
|
+
position: "center",
|
|
61
|
+
animation: "pops-anim-fadein-zoom",
|
|
62
|
+
zIndex: 10000,
|
|
63
|
+
mask: {
|
|
64
|
+
enable: false,
|
|
65
|
+
clickEvent: {
|
|
66
|
+
toClose: false,
|
|
67
|
+
toHide: false,
|
|
68
|
+
},
|
|
69
|
+
clickCallBack: void 0,
|
|
70
|
+
},
|
|
71
|
+
drag: false,
|
|
72
|
+
dragLimit: true,
|
|
73
|
+
dragExtraDistance: 3,
|
|
74
|
+
dragMoveCallBack() {},
|
|
75
|
+
dragEndCallBack() {},
|
|
76
|
+
forbiddenScroll: false,
|
|
77
|
+
style: null,
|
|
78
|
+
beforeAppendToPageCallBack() {},
|
|
79
|
+
};
|
|
80
|
+
config = popsUtils.assign(config, details);
|
|
81
|
+
let guid = popsUtils.getRandomGUID();
|
|
82
|
+
// 设置当前类型
|
|
83
|
+
const PopsType: PopsMode = "alert";
|
|
84
|
+
config = PopsHandler.handleOnly(PopsType, config);
|
|
85
|
+
|
|
86
|
+
let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
|
|
87
|
+
let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
|
|
88
|
+
let bottomBtnHTML = PopsElementHandler.getBottomBtnHTML(PopsType, config);
|
|
89
|
+
let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(
|
|
90
|
+
PopsType,
|
|
91
|
+
config
|
|
92
|
+
);
|
|
93
|
+
let { contentStyle, contentPStyle } = PopsElementHandler.getContentStyle(
|
|
94
|
+
PopsType,
|
|
95
|
+
config
|
|
96
|
+
);
|
|
97
|
+
let animHTML = PopsElementHandler.getAnimHTML(
|
|
98
|
+
guid,
|
|
99
|
+
PopsType,
|
|
100
|
+
config,
|
|
101
|
+
`
|
|
102
|
+
<div
|
|
103
|
+
class="pops-alert-title"
|
|
104
|
+
style="text-align: ${config.title.position};
|
|
105
|
+
${headerStyle}">
|
|
106
|
+
${
|
|
107
|
+
config.title.html
|
|
108
|
+
? config.title.text
|
|
109
|
+
: `<p pops style="${headerPStyle}">${config.title.text}</p>`
|
|
110
|
+
}
|
|
111
|
+
${headerBtnHTML}
|
|
112
|
+
</div>
|
|
113
|
+
<div class="pops-alert-content" style="${contentStyle}">
|
|
114
|
+
${
|
|
115
|
+
config.content.html
|
|
116
|
+
? config.content.text
|
|
117
|
+
: `<p pops style="${contentPStyle}">${config.content.text}</p>`
|
|
118
|
+
}
|
|
119
|
+
</div>
|
|
120
|
+
${bottomBtnHTML}`,
|
|
121
|
+
bottomBtnHTML
|
|
122
|
+
);
|
|
123
|
+
/**
|
|
124
|
+
* 弹窗的主元素,包括动画层
|
|
125
|
+
*/
|
|
126
|
+
let $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
|
|
127
|
+
|
|
128
|
+
let {
|
|
129
|
+
popsElement: $pops,
|
|
130
|
+
headerCloseBtnElement: $headerCloseBtn,
|
|
131
|
+
btnOkElement,
|
|
132
|
+
titleElement: $title,
|
|
133
|
+
} = PopsHandler.handleQueryElement($anim, PopsType);
|
|
134
|
+
|
|
135
|
+
/** 遮罩层元素 */
|
|
136
|
+
let $mask: HTMLDivElement | null = null;
|
|
137
|
+
/** 已创建的元素列表 */
|
|
138
|
+
let elementList: HTMLElement[] = [$anim];
|
|
139
|
+
|
|
140
|
+
/* 遮罩层元素 */
|
|
141
|
+
|
|
142
|
+
if (config.mask.enable) {
|
|
143
|
+
let _handleMask_ = PopsHandler.handleMask({
|
|
144
|
+
type: PopsType,
|
|
145
|
+
guid: guid,
|
|
146
|
+
config: config,
|
|
147
|
+
animElement: $anim,
|
|
148
|
+
maskHTML: maskHTML,
|
|
149
|
+
});
|
|
150
|
+
$mask = _handleMask_.maskElement;
|
|
151
|
+
elementList.push($mask);
|
|
152
|
+
}
|
|
153
|
+
/* 处理返回的配置 */
|
|
154
|
+
let eventDetails = PopsHandler.handleEventDetails(
|
|
155
|
+
guid,
|
|
156
|
+
$shadowContainer,
|
|
157
|
+
$shadowRoot,
|
|
158
|
+
PopsType,
|
|
159
|
+
$anim,
|
|
160
|
+
$pops!,
|
|
161
|
+
$mask!,
|
|
162
|
+
config
|
|
163
|
+
);
|
|
164
|
+
/* 为顶部右边的关闭按钮添加点击事件 */
|
|
165
|
+
PopsHandler.handleClickEvent(
|
|
166
|
+
"close",
|
|
167
|
+
$headerCloseBtn!,
|
|
168
|
+
eventDetails,
|
|
169
|
+
config.btn.close!.callback!
|
|
170
|
+
);
|
|
171
|
+
/* 为底部ok按钮添加点击事件 */
|
|
172
|
+
PopsHandler.handleClickEvent(
|
|
173
|
+
"ok",
|
|
174
|
+
btnOkElement!,
|
|
175
|
+
eventDetails!,
|
|
176
|
+
config.btn.ok!.callback!
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
/* 创建到页面中 */
|
|
180
|
+
|
|
181
|
+
popsDOMUtils.append($shadowRoot, elementList);
|
|
182
|
+
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
183
|
+
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
popsDOMUtils.appendBody($shadowContainer);
|
|
187
|
+
if ($mask != null) {
|
|
188
|
+
// 添加遮罩层
|
|
189
|
+
$anim.after($mask);
|
|
190
|
+
}
|
|
191
|
+
/* 保存 */
|
|
192
|
+
PopsHandler.handlePush(PopsType, {
|
|
193
|
+
guid: guid,
|
|
194
|
+
|
|
195
|
+
animElement: $anim,
|
|
196
|
+
|
|
197
|
+
popsElement: $pops!,
|
|
198
|
+
|
|
199
|
+
maskElement: $mask!,
|
|
200
|
+
$shadowContainer: $shadowContainer,
|
|
201
|
+
$shadowRoot: $shadowRoot,
|
|
202
|
+
});
|
|
203
|
+
/* 拖拽 */
|
|
204
|
+
if (config.drag) {
|
|
205
|
+
PopsInstanceUtils.drag($pops!, {
|
|
206
|
+
dragElement: $title!,
|
|
207
|
+
limit: config.dragLimit,
|
|
208
|
+
extraDistance: config.dragExtraDistance!,
|
|
209
|
+
moveCallBack: config.dragMoveCallBack!,
|
|
210
|
+
endCallBack: config.dragEndCallBack!,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return PopsHandler.handleResultDetails(eventDetails);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PopsTitleConfig,
|
|
3
|
+
PopsContentConfig,
|
|
4
|
+
PopsDragConfig,
|
|
5
|
+
PopsCommonConfig,
|
|
6
|
+
PopsButtonConfig,
|
|
7
|
+
} from "../../types/components";
|
|
8
|
+
import type {
|
|
9
|
+
PopsButtonDetails,
|
|
10
|
+
PopsButtonDetailsAnyType,
|
|
11
|
+
} from "../../types/button";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* pops.alert
|
|
15
|
+
*/
|
|
16
|
+
export interface PopsAlertDetails
|
|
17
|
+
extends PopsTitleConfig,
|
|
18
|
+
PopsContentConfig,
|
|
19
|
+
PopsDragConfig,
|
|
20
|
+
PopsCommonConfig {
|
|
21
|
+
/**
|
|
22
|
+
* 按钮配置
|
|
23
|
+
*/
|
|
24
|
+
btn?: Partial<PopsButtonConfig["btn"]> & {
|
|
25
|
+
/**
|
|
26
|
+
* 确定按钮
|
|
27
|
+
*/
|
|
28
|
+
ok?: Partial<PopsButtonDetails | PopsButtonDetailsAnyType>;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.pops[type-value] .pops-confirm-title {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
}
|
|
6
|
+
.pops[type-value="confirm"] .pops-confirm-title {
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: var(--container-title-height);
|
|
9
|
+
border-bottom: 1px solid rgb(229, 229, 229, var(--pops-bd-opacity));
|
|
10
|
+
}
|
|
11
|
+
.pops[type-value="confirm"] .pops-confirm-title p[pops] {
|
|
12
|
+
width: 100%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
color: rgb(51, 51, 51);
|
|
15
|
+
text-indent: 15px;
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
line-height: var(--container-title-height);
|
|
20
|
+
}
|
|
21
|
+
.pops[type-value="confirm"] .pops-confirm-content p[pops] {
|
|
22
|
+
padding: 5px 10px;
|
|
23
|
+
color: rgb(51, 51, 51);
|
|
24
|
+
text-indent: 15px;
|
|
25
|
+
}
|
|
26
|
+
.pops[type-value="confirm"] .pops-confirm-content {
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: calc(
|
|
29
|
+
100% - var(--container-title-height) - var(--container-bottom-btn-height)
|
|
30
|
+
);
|
|
31
|
+
overflow: auto;
|
|
32
|
+
word-break: break-word;
|
|
33
|
+
}
|
|
34
|
+
.pops[type-value="confirm"] .pops-confirm-btn {
|
|
35
|
+
position: absolute;
|
|
36
|
+
bottom: 0;
|
|
37
|
+
display: flex;
|
|
38
|
+
padding: 10px 10px 10px 10px;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: var(--container-bottom-btn-height);
|
|
41
|
+
border-top: 1px solid rgb(229, 229, 229, var(--pops-bd-opacity));
|
|
42
|
+
text-align: right;
|
|
43
|
+
line-height: var(--container-bottom-btn-height);
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
2
|
+
import { PopsHandler } from "../../handler/PopsHandler";
|
|
3
|
+
import { pops } from "../../Pops";
|
|
4
|
+
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
5
|
+
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
6
|
+
import { popsUtils } from "../../utils/PopsUtils";
|
|
7
|
+
import type { PopsConfirmDetails } from "./indexType";
|
|
8
|
+
|
|
9
|
+
export class PopsConfirm {
|
|
10
|
+
constructor(details: PopsConfirmDetails) {
|
|
11
|
+
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow();
|
|
12
|
+
PopsHandler.handleInit($shadowRoot, [
|
|
13
|
+
pops.config.cssText.index,
|
|
14
|
+
pops.config.cssText.ninePalaceGridPosition,
|
|
15
|
+
pops.config.cssText.scrollbar,
|
|
16
|
+
pops.config.cssText.button,
|
|
17
|
+
pops.config.cssText.anim,
|
|
18
|
+
pops.config.cssText.common,
|
|
19
|
+
pops.config.cssText.confirmCSS,
|
|
20
|
+
]);
|
|
21
|
+
let config: Required<PopsConfirmDetails> = {
|
|
22
|
+
title: {
|
|
23
|
+
text: "默认标题",
|
|
24
|
+
position: "left",
|
|
25
|
+
html: false,
|
|
26
|
+
style: "",
|
|
27
|
+
},
|
|
28
|
+
content: {
|
|
29
|
+
text: "默认内容",
|
|
30
|
+
html: false,
|
|
31
|
+
style: "",
|
|
32
|
+
},
|
|
33
|
+
btn: {
|
|
34
|
+
merge: false,
|
|
35
|
+
mergeReverse: false,
|
|
36
|
+
reverse: false,
|
|
37
|
+
position: "flex-end",
|
|
38
|
+
ok: {
|
|
39
|
+
enable: true,
|
|
40
|
+
|
|
41
|
+
size: void 0,
|
|
42
|
+
|
|
43
|
+
icon: void 0,
|
|
44
|
+
rightIcon: false,
|
|
45
|
+
iconIsLoading: false,
|
|
46
|
+
text: "确定",
|
|
47
|
+
type: "primary",
|
|
48
|
+
callback(event) {
|
|
49
|
+
event.close();
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
cancel: {
|
|
53
|
+
enable: true,
|
|
54
|
+
|
|
55
|
+
size: void 0,
|
|
56
|
+
|
|
57
|
+
icon: void 0,
|
|
58
|
+
rightIcon: false,
|
|
59
|
+
iconIsLoading: false,
|
|
60
|
+
text: "关闭",
|
|
61
|
+
type: "default",
|
|
62
|
+
callback(event) {
|
|
63
|
+
event.close();
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
other: {
|
|
67
|
+
enable: false,
|
|
68
|
+
|
|
69
|
+
size: void 0,
|
|
70
|
+
|
|
71
|
+
icon: void 0,
|
|
72
|
+
rightIcon: false,
|
|
73
|
+
iconIsLoading: false,
|
|
74
|
+
text: "其它按钮",
|
|
75
|
+
type: "default",
|
|
76
|
+
callback(event) {
|
|
77
|
+
event.close();
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
close: {
|
|
81
|
+
enable: true,
|
|
82
|
+
callback(event) {
|
|
83
|
+
event.close();
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
class: "",
|
|
88
|
+
only: false,
|
|
89
|
+
width: "350px",
|
|
90
|
+
height: "200px",
|
|
91
|
+
position: "center",
|
|
92
|
+
animation: "pops-anim-fadein-zoom",
|
|
93
|
+
zIndex: 10000,
|
|
94
|
+
mask: {
|
|
95
|
+
enable: false,
|
|
96
|
+
clickEvent: {
|
|
97
|
+
toClose: false,
|
|
98
|
+
toHide: false,
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
clickCallBack: void 0,
|
|
102
|
+
},
|
|
103
|
+
drag: false,
|
|
104
|
+
dragLimit: true,
|
|
105
|
+
dragExtraDistance: 3,
|
|
106
|
+
dragMoveCallBack() {},
|
|
107
|
+
dragEndCallBack() {},
|
|
108
|
+
forbiddenScroll: false,
|
|
109
|
+
|
|
110
|
+
style: null,
|
|
111
|
+
beforeAppendToPageCallBack() {},
|
|
112
|
+
};
|
|
113
|
+
config = popsUtils.assign(config, details);
|
|
114
|
+
let guid = popsUtils.getRandomGUID();
|
|
115
|
+
// 设置当前类型
|
|
116
|
+
const PopsType = "confirm";
|
|
117
|
+
|
|
118
|
+
config = PopsHandler.handleOnly(PopsType, config);
|
|
119
|
+
|
|
120
|
+
let maskHTML = PopsElementHandler.getMaskHTML(guid, config.zIndex);
|
|
121
|
+
|
|
122
|
+
let headerBtnHTML = PopsElementHandler.getHeaderBtnHTML(PopsType, config);
|
|
123
|
+
let bottomBtnHTML = PopsElementHandler.getBottomBtnHTML(PopsType, config);
|
|
124
|
+
let { headerStyle, headerPStyle } = PopsElementHandler.getHeaderStyle(
|
|
125
|
+
PopsType,
|
|
126
|
+
config
|
|
127
|
+
);
|
|
128
|
+
let { contentStyle, contentPStyle } = PopsElementHandler.getContentStyle(
|
|
129
|
+
PopsType,
|
|
130
|
+
config
|
|
131
|
+
);
|
|
132
|
+
let animHTML = PopsElementHandler.getAnimHTML(
|
|
133
|
+
guid,
|
|
134
|
+
PopsType,
|
|
135
|
+
config,
|
|
136
|
+
`
|
|
137
|
+
<div class="pops-confirm-title" style="text-align: ${
|
|
138
|
+
config.title.position
|
|
139
|
+
};${headerStyle}">
|
|
140
|
+
${
|
|
141
|
+
config.title.html
|
|
142
|
+
? config.title.text
|
|
143
|
+
: `<p pops style="${headerPStyle}">${config.title.text}</p>`
|
|
144
|
+
}
|
|
145
|
+
${headerBtnHTML}
|
|
146
|
+
</div>
|
|
147
|
+
<div class="pops-confirm-content" style="${contentStyle}">
|
|
148
|
+
${
|
|
149
|
+
config.content.html
|
|
150
|
+
? config.content.text
|
|
151
|
+
: `<p pops style="${contentPStyle}">${config.content.text}</p>`
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
</div>
|
|
155
|
+
${bottomBtnHTML}
|
|
156
|
+
`,
|
|
157
|
+
bottomBtnHTML
|
|
158
|
+
);
|
|
159
|
+
/**
|
|
160
|
+
* 弹窗的主元素,包括动画层
|
|
161
|
+
*/
|
|
162
|
+
let $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
|
|
163
|
+
let {
|
|
164
|
+
popsElement: $pops,
|
|
165
|
+
titleElement: $title,
|
|
166
|
+
headerCloseBtnElement: $btnClose,
|
|
167
|
+
btnOkElement: $btnOk,
|
|
168
|
+
btnCancelElement: $btnCancel,
|
|
169
|
+
btnOtherElement: $btnOther,
|
|
170
|
+
} = PopsHandler.handleQueryElement($anim, PopsType);
|
|
171
|
+
/**
|
|
172
|
+
* 遮罩层元素
|
|
173
|
+
*/
|
|
174
|
+
let $mask: HTMLDivElement | null = null;
|
|
175
|
+
/**
|
|
176
|
+
* 已创建的元素列表
|
|
177
|
+
*/
|
|
178
|
+
let elementList: HTMLElement[] = [$anim];
|
|
179
|
+
|
|
180
|
+
if (config.mask.enable) {
|
|
181
|
+
// 启用遮罩层
|
|
182
|
+
let _handleMask_ = PopsHandler.handleMask({
|
|
183
|
+
type: PopsType,
|
|
184
|
+
guid: guid,
|
|
185
|
+
config: config,
|
|
186
|
+
animElement: $anim,
|
|
187
|
+
maskHTML: maskHTML,
|
|
188
|
+
});
|
|
189
|
+
$mask = _handleMask_.maskElement;
|
|
190
|
+
elementList.push($mask);
|
|
191
|
+
}
|
|
192
|
+
let eventDetails = PopsHandler.handleEventDetails(
|
|
193
|
+
guid,
|
|
194
|
+
$shadowContainer,
|
|
195
|
+
$shadowRoot,
|
|
196
|
+
PopsType,
|
|
197
|
+
|
|
198
|
+
$anim,
|
|
199
|
+
$pops!,
|
|
200
|
+
$mask!,
|
|
201
|
+
config
|
|
202
|
+
);
|
|
203
|
+
PopsHandler.handleClickEvent(
|
|
204
|
+
"close",
|
|
205
|
+
$btnClose!,
|
|
206
|
+
eventDetails,
|
|
207
|
+
config.btn.close!.callback!
|
|
208
|
+
);
|
|
209
|
+
PopsHandler.handleClickEvent(
|
|
210
|
+
"ok",
|
|
211
|
+
$btnOk!,
|
|
212
|
+
eventDetails!,
|
|
213
|
+
config.btn.ok!.callback!
|
|
214
|
+
);
|
|
215
|
+
PopsHandler.handleClickEvent(
|
|
216
|
+
"cancel",
|
|
217
|
+
$btnCancel!,
|
|
218
|
+
eventDetails,
|
|
219
|
+
config.btn.cancel!.callback!
|
|
220
|
+
);
|
|
221
|
+
PopsHandler.handleClickEvent(
|
|
222
|
+
"other",
|
|
223
|
+
$btnOther!,
|
|
224
|
+
eventDetails,
|
|
225
|
+
config.btn.other!.callback!
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
/* 创建到页面中 */
|
|
229
|
+
|
|
230
|
+
popsDOMUtils.append($shadowRoot, elementList);
|
|
231
|
+
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
232
|
+
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
popsDOMUtils.appendBody($shadowContainer);
|
|
236
|
+
if ($mask != null) {
|
|
237
|
+
$anim.after($mask);
|
|
238
|
+
}
|
|
239
|
+
PopsHandler.handlePush(PopsType, {
|
|
240
|
+
guid: guid,
|
|
241
|
+
|
|
242
|
+
animElement: $anim,
|
|
243
|
+
|
|
244
|
+
popsElement: $pops!,
|
|
245
|
+
|
|
246
|
+
maskElement: $mask!,
|
|
247
|
+
$shadowContainer: $shadowContainer,
|
|
248
|
+
$shadowRoot: $shadowRoot,
|
|
249
|
+
});
|
|
250
|
+
/* 拖拽 */
|
|
251
|
+
if (config.drag) {
|
|
252
|
+
0;
|
|
253
|
+
|
|
254
|
+
PopsInstanceUtils.drag($pops!, {
|
|
255
|
+
dragElement: $title!,
|
|
256
|
+
limit: config.dragLimit,
|
|
257
|
+
extraDistance: config.dragExtraDistance,
|
|
258
|
+
moveCallBack: config.dragMoveCallBack,
|
|
259
|
+
endCallBack: config.dragEndCallBack,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return PopsHandler.handleResultDetails(eventDetails);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PopsTitleConfig,
|
|
3
|
+
PopsContentConfig,
|
|
4
|
+
PopsDragConfig,
|
|
5
|
+
PopsCommonConfig,
|
|
6
|
+
PopsMoreButtonConfig,
|
|
7
|
+
} from "../../types/components";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* pops.confirm
|
|
11
|
+
*/
|
|
12
|
+
export interface PopsConfirmDetails
|
|
13
|
+
extends PopsTitleConfig,
|
|
14
|
+
PopsContentConfig,
|
|
15
|
+
PopsMoreButtonConfig,
|
|
16
|
+
PopsDragConfig,
|
|
17
|
+
PopsCommonConfig {}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.pops[type-value="drawer"] {
|
|
2
|
+
position: fixed;
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
box-shadow: 0px 16px 48px 16px rgba(0, 0, 0, 0.08),
|
|
7
|
+
0px 12px 32px rgba(0, 0, 0, 0.12), 0px 8px 16px -8px rgba(0, 0, 0, 0.16);
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
transition: all 0.3s;
|
|
10
|
+
}
|
|
11
|
+
.pops[type-value] .pops-drawer-title {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.pops[type-value="drawer"][direction="top"] {
|
|
18
|
+
width: 100%;
|
|
19
|
+
left: 0;
|
|
20
|
+
right: 0;
|
|
21
|
+
top: 0;
|
|
22
|
+
}
|
|
23
|
+
.pops[type-value="drawer"][direction="bottom"] {
|
|
24
|
+
width: 100%;
|
|
25
|
+
left: 0;
|
|
26
|
+
right: 0;
|
|
27
|
+
bottom: 0;
|
|
28
|
+
}
|
|
29
|
+
.pops[type-value="drawer"][direction="left"] {
|
|
30
|
+
height: 100%;
|
|
31
|
+
top: 0;
|
|
32
|
+
bottom: 0;
|
|
33
|
+
left: 0;
|
|
34
|
+
}
|
|
35
|
+
.pops[type-value="drawer"][direction="right"] {
|
|
36
|
+
height: 100%;
|
|
37
|
+
top: 0;
|
|
38
|
+
bottom: 0;
|
|
39
|
+
right: 0;
|
|
40
|
+
}
|
|
41
|
+
.pops-drawer-content {
|
|
42
|
+
height: 100%;
|
|
43
|
+
}
|
|
44
|
+
.pops[type-value="drawer"] .pops-drawer-btn {
|
|
45
|
+
padding-top: 10px;
|
|
46
|
+
padding-bottom: 10px;
|
|
47
|
+
}
|