@whitesev/pops 3.2.1 → 3.3.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/README.md +249 -249
- package/dist/index.amd.js +736 -948
- 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 +736 -948
- 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 +736 -948
- 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 +736 -948
- 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 +736 -948
- 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 +736 -948
- 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/src/PopsCore.d.ts +15 -7
- package/dist/types/src/components/folder/types/index.d.ts +43 -13
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +313 -313
- package/dist/types/src/types/animation.d.ts +19 -19
- package/dist/types/src/types/button.d.ts +94 -94
- package/dist/types/src/types/components.d.ts +211 -211
- package/dist/types/src/types/event.d.ts +43 -43
- package/dist/types/src/types/global.d.ts +31 -31
- package/dist/types/src/types/icon.d.ts +32 -32
- package/dist/types/src/types/inst.d.ts +28 -28
- package/dist/types/src/types/main.d.ts +66 -66
- package/dist/types/src/types/mask.d.ts +52 -52
- package/dist/types/src/types/position.d.ts +60 -60
- package/package.json +28 -27
- package/src/Pops.ts +206 -206
- package/src/PopsAnimation.ts +32 -32
- package/src/PopsCSS.ts +54 -54
- package/src/PopsCore.ts +53 -37
- package/src/PopsIcon.ts +95 -95
- package/src/PopsInst.ts +21 -21
- package/src/components/alert/defaultConfig.ts +62 -62
- package/src/components/alert/index.ts +163 -163
- package/src/components/alert/types/index.ts +23 -23
- package/src/components/confirm/defaultConfig.ts +90 -90
- package/src/components/confirm/index.ts +165 -165
- package/src/components/confirm/types/index.ts +13 -17
- package/src/components/drawer/defaultConfig.ts +89 -89
- package/src/components/drawer/index.css +37 -37
- package/src/components/drawer/index.ts +245 -245
- package/src/components/drawer/types/index.ts +62 -61
- package/src/components/folder/defaultConfig.ts +151 -151
- package/src/components/folder/folderIcon.ts +28 -28
- package/src/components/folder/index.css +303 -303
- package/src/components/folder/index.ts +953 -932
- package/src/components/folder/types/index.ts +143 -110
- package/src/components/iframe/defaultConfig.ts +60 -60
- package/src/components/iframe/index.css +76 -76
- package/src/components/iframe/index.ts +331 -331
- package/src/components/iframe/types/index.ts +96 -96
- package/src/components/loading/defaultConfig.ts +29 -29
- package/src/components/loading/index.css +66 -66
- package/src/components/loading/index.ts +101 -101
- package/src/components/loading/types/index.ts +36 -34
- package/src/components/panel/css/components-select.css +84 -84
- package/src/components/panel/defaultConfig.ts +868 -868
- package/src/components/panel/handlerComponents.ts +3993 -3993
- package/src/components/panel/index.css +1403 -1403
- package/src/components/panel/index.ts +221 -221
- package/src/components/panel/types/components-button.ts +56 -56
- package/src/components/panel/types/components-common.ts +73 -73
- package/src/components/panel/types/components-container.ts +25 -25
- package/src/components/panel/types/components-deepMenu.ts +64 -64
- package/src/components/panel/types/components-input.ts +90 -90
- package/src/components/panel/types/components-own.ts +16 -16
- package/src/components/panel/types/components-select.ts +169 -169
- package/src/components/panel/types/components-selectMultiple.ts +105 -104
- package/src/components/panel/types/components-slider.ts +55 -55
- package/src/components/panel/types/components-switch.ts +33 -33
- package/src/components/panel/types/components-textarea.ts +45 -45
- package/src/components/panel/types/index.ts +244 -244
- package/src/components/prompt/defaultConfig.ts +94 -94
- package/src/components/prompt/index.css +34 -34
- package/src/components/prompt/index.ts +187 -215
- package/src/components/prompt/types/index.ts +57 -56
- package/src/components/rightClickMenu/defaultConfig.ts +103 -103
- package/src/components/rightClickMenu/index.css +115 -115
- package/src/components/rightClickMenu/index.ts +662 -662
- package/src/components/rightClickMenu/types/index.ts +145 -143
- package/src/components/searchSuggestion/defaultConfig.ts +63 -63
- package/src/components/searchSuggestion/index.ts +813 -813
- package/src/components/searchSuggestion/types/index.ts +244 -242
- package/src/components/tooltip/defaultConfig.ts +33 -33
- package/src/components/tooltip/index.css +199 -199
- package/src/components/tooltip/index.ts +617 -617
- package/src/components/tooltip/types/index.ts +123 -121
- package/src/config/CommonCSSClassName.ts +17 -17
- package/src/config/GlobalConfig.ts +63 -63
- package/src/css/animation.css +987 -987
- package/src/css/button.css +551 -551
- package/src/css/common.css +54 -54
- package/src/css/index.css +253 -253
- package/src/css/ninePalaceGridPosition.css +50 -50
- package/src/css/scrollbar.css +22 -22
- package/src/handler/PopsElementHandler.ts +303 -303
- package/src/handler/PopsHandler.ts +611 -611
- package/src/types/PopsDOMUtilsEventType.d.ts +313 -313
- package/src/types/animation.d.ts +19 -19
- package/src/types/button.d.ts +94 -94
- package/src/types/components.d.ts +211 -211
- package/src/types/event.d.ts +43 -43
- package/src/types/global.d.ts +31 -31
- package/src/types/icon.d.ts +32 -32
- package/src/types/inst.d.ts +28 -28
- package/src/types/main.d.ts +66 -66
- package/src/types/mask.d.ts +52 -52
- package/src/types/position.d.ts +60 -60
- package/src/utils/PopsDOMUtils.ts +2483 -2483
- package/src/utils/PopsDOMUtilsEventsConfig.ts +4 -4
- package/src/utils/PopsInstanceUtils.ts +714 -714
- package/src/utils/PopsMathUtils.ts +71 -71
- package/src/utils/PopsSafeUtils.ts +22 -22
- package/src/utils/PopsUtils.ts +391 -421
|
@@ -1,245 +1,245 @@
|
|
|
1
|
-
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
2
|
-
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
3
|
-
import { PopsHandler } from "../../handler/PopsHandler";
|
|
4
|
-
import { PopsCSS } from "../../PopsCSS";
|
|
5
|
-
import type { PopsHandlerEventConfig } from "../../types/event";
|
|
6
|
-
import type { PopsType } from "../../types/main";
|
|
7
|
-
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
8
|
-
import { popsUtils } from "../../utils/PopsUtils";
|
|
9
|
-
import { PopsDrawerDefaultConfig } from "./defaultConfig";
|
|
10
|
-
import type { PopsDrawerConfig } from "./types";
|
|
11
|
-
|
|
12
|
-
export const PopsDrawer = {
|
|
13
|
-
init(__config__: PopsDrawerConfig) {
|
|
14
|
-
const guid = popsUtils.getRandomGUID();
|
|
15
|
-
// 设置当前类型
|
|
16
|
-
const popsType: PopsType = "drawer";
|
|
17
|
-
|
|
18
|
-
let config = PopsDrawerDefaultConfig();
|
|
19
|
-
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
20
|
-
config = popsUtils.assign(config, __config__);
|
|
21
|
-
config = PopsHandler.handleOnly(popsType, config);
|
|
22
|
-
|
|
23
|
-
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
24
|
-
PopsHandler.handleInit($shadowRoot, [
|
|
25
|
-
{
|
|
26
|
-
name: "index",
|
|
27
|
-
css: PopsCSS.index,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: "ninePalaceGridPosition",
|
|
31
|
-
css: PopsCSS.ninePalaceGridPosition,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "scrollbar",
|
|
35
|
-
css: PopsCSS.scrollbar,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: "button",
|
|
39
|
-
css: PopsCSS.button,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "anim",
|
|
43
|
-
css: PopsCSS.anim,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: "common",
|
|
47
|
-
css: PopsCSS.common,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "drawerCSS",
|
|
51
|
-
css: PopsCSS.drawerCSS,
|
|
52
|
-
},
|
|
53
|
-
]);
|
|
54
|
-
|
|
55
|
-
// 先把z-index提取出来
|
|
56
|
-
const zIndex = PopsHandler.handleZIndex(config.zIndex);
|
|
57
|
-
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
58
|
-
|
|
59
|
-
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
60
|
-
const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
|
|
61
|
-
const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
|
|
62
|
-
const { contentStyle, contentPStyle } = PopsElementHandler.createContentStyle(popsType, config);
|
|
63
|
-
const animHTML = PopsElementHandler.createAnim(
|
|
64
|
-
guid,
|
|
65
|
-
popsType,
|
|
66
|
-
config,
|
|
67
|
-
/*html*/ `
|
|
68
|
-
${
|
|
69
|
-
config.title.enable
|
|
70
|
-
? /*html*/ `<div class="pops-title pops-${popsType}-title" style="${headerStyle}">${
|
|
71
|
-
config.title.html
|
|
72
|
-
? config.title.text
|
|
73
|
-
: /*html*/ `<p pops class="pops-${popsType}-title-text" style="width: 100%;text-align: ${config.title.position};${headerPStyle}">${config.title.text}</p>`
|
|
74
|
-
}${headerBtnHTML}</div>`
|
|
75
|
-
: ""
|
|
76
|
-
}
|
|
77
|
-
<div class="pops-content pops-${popsType}-content" style="${contentStyle}">${
|
|
78
|
-
config.content.html
|
|
79
|
-
? config.content.text
|
|
80
|
-
: `<p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>`
|
|
81
|
-
}</div>${bottomBtnHTML}`,
|
|
82
|
-
bottomBtnHTML,
|
|
83
|
-
zIndex
|
|
84
|
-
);
|
|
85
|
-
/**
|
|
86
|
-
* 弹窗的主元素,包括动画层
|
|
87
|
-
*/
|
|
88
|
-
const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
|
|
89
|
-
const {
|
|
90
|
-
$pops: popsElement,
|
|
91
|
-
$headerBtnClose: headerCloseBtnElement,
|
|
92
|
-
$btnCancel: btnCancelElement,
|
|
93
|
-
$btnOk: btnOkElement,
|
|
94
|
-
$btnOther: btnOtherElement,
|
|
95
|
-
} = PopsHandler.handleQueryElement($anim, popsType);
|
|
96
|
-
const $pops = popsElement!;
|
|
97
|
-
const $headerCloseBtn = headerCloseBtnElement!;
|
|
98
|
-
const $btnCancel = btnCancelElement!;
|
|
99
|
-
const $btnOk = btnOkElement!;
|
|
100
|
-
const $btnOther = btnOtherElement!;
|
|
101
|
-
/**
|
|
102
|
-
* 遮罩层元素
|
|
103
|
-
*/
|
|
104
|
-
let $mask: HTMLDivElement | undefined = void 0;
|
|
105
|
-
/**
|
|
106
|
-
* 已创建的元素列表
|
|
107
|
-
*/
|
|
108
|
-
const $elList: HTMLElement[] = [$anim];
|
|
109
|
-
|
|
110
|
-
if (config.mask.enable) {
|
|
111
|
-
const handleMask = PopsHandler.handleMask({
|
|
112
|
-
type: popsType,
|
|
113
|
-
guid: guid,
|
|
114
|
-
config: config,
|
|
115
|
-
animElement: $anim,
|
|
116
|
-
maskHTML: maskHTML,
|
|
117
|
-
});
|
|
118
|
-
$mask = handleMask.maskElement;
|
|
119
|
-
$elList.push($mask);
|
|
120
|
-
}
|
|
121
|
-
const evtConfig = PopsHandler.handleEventConfig(
|
|
122
|
-
config,
|
|
123
|
-
guid,
|
|
124
|
-
$shadowContainer,
|
|
125
|
-
$shadowRoot,
|
|
126
|
-
popsType,
|
|
127
|
-
$anim,
|
|
128
|
-
$pops,
|
|
129
|
-
$mask
|
|
130
|
-
);
|
|
131
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
132
|
-
// 处理方向
|
|
133
|
-
|
|
134
|
-
$pops.setAttribute("direction", config.direction);
|
|
135
|
-
|
|
136
|
-
// 处理border-radius
|
|
137
|
-
// 处理动画前的宽高
|
|
138
|
-
if (config.direction === "top") {
|
|
139
|
-
$pops.style.setProperty("height", "0");
|
|
140
|
-
|
|
141
|
-
$pops.style.setProperty("border-radius", `0px 0px ${config.borderRadius}px ${config.borderRadius}px`);
|
|
142
|
-
} else if (config.direction === "bottom") {
|
|
143
|
-
$pops.style.setProperty("height", "0");
|
|
144
|
-
|
|
145
|
-
$pops.style.setProperty("border-radius", `${config.borderRadius}px ${config.borderRadius}px 0px 0px`);
|
|
146
|
-
} else if (config.direction === "left") {
|
|
147
|
-
$pops.style.setProperty("width", "0");
|
|
148
|
-
|
|
149
|
-
$pops.style.setProperty("border-radius", `0px ${config.borderRadius}px 0px ${config.borderRadius}px`);
|
|
150
|
-
} else if (config.direction === "right") {
|
|
151
|
-
$pops.style.setProperty("width", "0");
|
|
152
|
-
|
|
153
|
-
$pops.style.setProperty("border-radius", `${config.borderRadius}px 0px ${config.borderRadius}px 0px`);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// 按下Esc键触发关闭
|
|
157
|
-
if (config.closeOnPressEscape) {
|
|
158
|
-
PopsHandler.handleKeyboardEvent("Escape", [], function () {
|
|
159
|
-
evtConfig.close();
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
// 待处理的点击事件列表
|
|
163
|
-
const needHandleClickEventList: {
|
|
164
|
-
type: PopsHandlerEventConfig["type"];
|
|
165
|
-
ele: HTMLElement;
|
|
166
|
-
}[] = [
|
|
167
|
-
{
|
|
168
|
-
type: "close",
|
|
169
|
-
ele: $headerCloseBtn,
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
type: "cancel",
|
|
173
|
-
ele: $btnCancel,
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
type: "ok",
|
|
177
|
-
ele: $btnOk,
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
type: "other",
|
|
181
|
-
ele: $btnOther,
|
|
182
|
-
},
|
|
183
|
-
];
|
|
184
|
-
needHandleClickEventList.forEach((item) => {
|
|
185
|
-
PopsHandler.handleClickEvent(item.type, item.ele, evtConfig, (evtConfig, event) => {
|
|
186
|
-
const callback = config.btn[item.type].callback;
|
|
187
|
-
if (typeof callback === "function") {
|
|
188
|
-
callback(evtConfig, event);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
// 先隐藏,然后根据config.openDelay来显示
|
|
194
|
-
$elList.forEach((element) => {
|
|
195
|
-
element.style.setProperty("display", "none");
|
|
196
|
-
if (["top"].includes(config.direction)) {
|
|
197
|
-
$pops.style.setProperty("height", config.size.toString());
|
|
198
|
-
|
|
199
|
-
$pops.style.setProperty("transform", "translateY(-100%)");
|
|
200
|
-
} else if (["bottom"].includes(config.direction)) {
|
|
201
|
-
$pops.style.setProperty("height", config.size.toString());
|
|
202
|
-
|
|
203
|
-
$pops.style.setProperty("transform", "translateY(100%)");
|
|
204
|
-
} else if (["left"].includes(config.direction)) {
|
|
205
|
-
$pops.style.setProperty("width", config.size.toString());
|
|
206
|
-
|
|
207
|
-
$pops.style.setProperty("transform", "translateX(-100%)");
|
|
208
|
-
} else if (["right"].includes(config.direction)) {
|
|
209
|
-
$pops.style.setProperty("width", config.size.toString());
|
|
210
|
-
|
|
211
|
-
$pops.style.setProperty("transform", "translateX(100%)");
|
|
212
|
-
}
|
|
213
|
-
element.style.setProperty("display", "");
|
|
214
|
-
});
|
|
215
|
-
// 创建到页面中
|
|
216
|
-
|
|
217
|
-
popsDOMUtils.append($shadowRoot, $elList);
|
|
218
|
-
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
219
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
popsDOMUtils.appendBody($shadowContainer);
|
|
223
|
-
popsUtils.setTimeout(() => {
|
|
224
|
-
popsUtils.setTimeout(() => {
|
|
225
|
-
$pops.style.setProperty("transform", "");
|
|
226
|
-
}, config.openDelay);
|
|
227
|
-
}, 50);
|
|
228
|
-
|
|
229
|
-
if ($mask != null) {
|
|
230
|
-
$anim.after($mask);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
PopsHandler.handlePush(popsType, {
|
|
234
|
-
guid: guid,
|
|
235
|
-
$anim: $anim,
|
|
236
|
-
$pops: $pops,
|
|
237
|
-
$mask: $mask!,
|
|
238
|
-
$shadowContainer: $shadowContainer,
|
|
239
|
-
$shadowRoot: $shadowRoot,
|
|
240
|
-
config: config,
|
|
241
|
-
destory: result.close,
|
|
242
|
-
});
|
|
243
|
-
return result;
|
|
244
|
-
},
|
|
245
|
-
};
|
|
1
|
+
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
2
|
+
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
3
|
+
import { PopsHandler } from "../../handler/PopsHandler";
|
|
4
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
5
|
+
import type { PopsHandlerEventConfig } from "../../types/event";
|
|
6
|
+
import type { PopsType } from "../../types/main";
|
|
7
|
+
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
8
|
+
import { popsUtils } from "../../utils/PopsUtils";
|
|
9
|
+
import { PopsDrawerDefaultConfig } from "./defaultConfig";
|
|
10
|
+
import type { PopsDrawerConfig } from "./types";
|
|
11
|
+
|
|
12
|
+
export const PopsDrawer = {
|
|
13
|
+
init(__config__: PopsDrawerConfig) {
|
|
14
|
+
const guid = popsUtils.getRandomGUID();
|
|
15
|
+
// 设置当前类型
|
|
16
|
+
const popsType: PopsType = "drawer";
|
|
17
|
+
|
|
18
|
+
let config = PopsDrawerDefaultConfig();
|
|
19
|
+
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
20
|
+
config = popsUtils.assign(config, __config__);
|
|
21
|
+
config = PopsHandler.handleOnly(popsType, config);
|
|
22
|
+
|
|
23
|
+
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
24
|
+
PopsHandler.handleInit($shadowRoot, [
|
|
25
|
+
{
|
|
26
|
+
name: "index",
|
|
27
|
+
css: PopsCSS.index,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "ninePalaceGridPosition",
|
|
31
|
+
css: PopsCSS.ninePalaceGridPosition,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "scrollbar",
|
|
35
|
+
css: PopsCSS.scrollbar,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "button",
|
|
39
|
+
css: PopsCSS.button,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "anim",
|
|
43
|
+
css: PopsCSS.anim,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "common",
|
|
47
|
+
css: PopsCSS.common,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "drawerCSS",
|
|
51
|
+
css: PopsCSS.drawerCSS,
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
// 先把z-index提取出来
|
|
56
|
+
const zIndex = PopsHandler.handleZIndex(config.zIndex);
|
|
57
|
+
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
58
|
+
|
|
59
|
+
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
60
|
+
const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
|
|
61
|
+
const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
|
|
62
|
+
const { contentStyle, contentPStyle } = PopsElementHandler.createContentStyle(popsType, config);
|
|
63
|
+
const animHTML = PopsElementHandler.createAnim(
|
|
64
|
+
guid,
|
|
65
|
+
popsType,
|
|
66
|
+
config,
|
|
67
|
+
/*html*/ `
|
|
68
|
+
${
|
|
69
|
+
config.title.enable
|
|
70
|
+
? /*html*/ `<div class="pops-title pops-${popsType}-title" style="${headerStyle}">${
|
|
71
|
+
config.title.html
|
|
72
|
+
? config.title.text
|
|
73
|
+
: /*html*/ `<p pops class="pops-${popsType}-title-text" style="width: 100%;text-align: ${config.title.position};${headerPStyle}">${config.title.text}</p>`
|
|
74
|
+
}${headerBtnHTML}</div>`
|
|
75
|
+
: ""
|
|
76
|
+
}
|
|
77
|
+
<div class="pops-content pops-${popsType}-content" style="${contentStyle}">${
|
|
78
|
+
config.content.html
|
|
79
|
+
? config.content.text
|
|
80
|
+
: `<p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>`
|
|
81
|
+
}</div>${bottomBtnHTML}`,
|
|
82
|
+
bottomBtnHTML,
|
|
83
|
+
zIndex
|
|
84
|
+
);
|
|
85
|
+
/**
|
|
86
|
+
* 弹窗的主元素,包括动画层
|
|
87
|
+
*/
|
|
88
|
+
const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
|
|
89
|
+
const {
|
|
90
|
+
$pops: popsElement,
|
|
91
|
+
$headerBtnClose: headerCloseBtnElement,
|
|
92
|
+
$btnCancel: btnCancelElement,
|
|
93
|
+
$btnOk: btnOkElement,
|
|
94
|
+
$btnOther: btnOtherElement,
|
|
95
|
+
} = PopsHandler.handleQueryElement($anim, popsType);
|
|
96
|
+
const $pops = popsElement!;
|
|
97
|
+
const $headerCloseBtn = headerCloseBtnElement!;
|
|
98
|
+
const $btnCancel = btnCancelElement!;
|
|
99
|
+
const $btnOk = btnOkElement!;
|
|
100
|
+
const $btnOther = btnOtherElement!;
|
|
101
|
+
/**
|
|
102
|
+
* 遮罩层元素
|
|
103
|
+
*/
|
|
104
|
+
let $mask: HTMLDivElement | undefined = void 0;
|
|
105
|
+
/**
|
|
106
|
+
* 已创建的元素列表
|
|
107
|
+
*/
|
|
108
|
+
const $elList: HTMLElement[] = [$anim];
|
|
109
|
+
|
|
110
|
+
if (config.mask.enable) {
|
|
111
|
+
const handleMask = PopsHandler.handleMask({
|
|
112
|
+
type: popsType,
|
|
113
|
+
guid: guid,
|
|
114
|
+
config: config,
|
|
115
|
+
animElement: $anim,
|
|
116
|
+
maskHTML: maskHTML,
|
|
117
|
+
});
|
|
118
|
+
$mask = handleMask.maskElement;
|
|
119
|
+
$elList.push($mask);
|
|
120
|
+
}
|
|
121
|
+
const evtConfig = PopsHandler.handleEventConfig(
|
|
122
|
+
config,
|
|
123
|
+
guid,
|
|
124
|
+
$shadowContainer,
|
|
125
|
+
$shadowRoot,
|
|
126
|
+
popsType,
|
|
127
|
+
$anim,
|
|
128
|
+
$pops,
|
|
129
|
+
$mask
|
|
130
|
+
);
|
|
131
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
132
|
+
// 处理方向
|
|
133
|
+
|
|
134
|
+
$pops.setAttribute("direction", config.direction);
|
|
135
|
+
|
|
136
|
+
// 处理border-radius
|
|
137
|
+
// 处理动画前的宽高
|
|
138
|
+
if (config.direction === "top") {
|
|
139
|
+
$pops.style.setProperty("height", "0");
|
|
140
|
+
|
|
141
|
+
$pops.style.setProperty("border-radius", `0px 0px ${config.borderRadius}px ${config.borderRadius}px`);
|
|
142
|
+
} else if (config.direction === "bottom") {
|
|
143
|
+
$pops.style.setProperty("height", "0");
|
|
144
|
+
|
|
145
|
+
$pops.style.setProperty("border-radius", `${config.borderRadius}px ${config.borderRadius}px 0px 0px`);
|
|
146
|
+
} else if (config.direction === "left") {
|
|
147
|
+
$pops.style.setProperty("width", "0");
|
|
148
|
+
|
|
149
|
+
$pops.style.setProperty("border-radius", `0px ${config.borderRadius}px 0px ${config.borderRadius}px`);
|
|
150
|
+
} else if (config.direction === "right") {
|
|
151
|
+
$pops.style.setProperty("width", "0");
|
|
152
|
+
|
|
153
|
+
$pops.style.setProperty("border-radius", `${config.borderRadius}px 0px ${config.borderRadius}px 0px`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 按下Esc键触发关闭
|
|
157
|
+
if (config.closeOnPressEscape) {
|
|
158
|
+
PopsHandler.handleKeyboardEvent("Escape", [], function () {
|
|
159
|
+
evtConfig.close();
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// 待处理的点击事件列表
|
|
163
|
+
const needHandleClickEventList: {
|
|
164
|
+
type: PopsHandlerEventConfig["type"];
|
|
165
|
+
ele: HTMLElement;
|
|
166
|
+
}[] = [
|
|
167
|
+
{
|
|
168
|
+
type: "close",
|
|
169
|
+
ele: $headerCloseBtn,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
type: "cancel",
|
|
173
|
+
ele: $btnCancel,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "ok",
|
|
177
|
+
ele: $btnOk,
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
type: "other",
|
|
181
|
+
ele: $btnOther,
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
needHandleClickEventList.forEach((item) => {
|
|
185
|
+
PopsHandler.handleClickEvent(item.type, item.ele, evtConfig, (evtConfig, event) => {
|
|
186
|
+
const callback = config.btn[item.type].callback;
|
|
187
|
+
if (typeof callback === "function") {
|
|
188
|
+
callback(evtConfig, event);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// 先隐藏,然后根据config.openDelay来显示
|
|
194
|
+
$elList.forEach((element) => {
|
|
195
|
+
element.style.setProperty("display", "none");
|
|
196
|
+
if (["top"].includes(config.direction)) {
|
|
197
|
+
$pops.style.setProperty("height", config.size.toString());
|
|
198
|
+
|
|
199
|
+
$pops.style.setProperty("transform", "translateY(-100%)");
|
|
200
|
+
} else if (["bottom"].includes(config.direction)) {
|
|
201
|
+
$pops.style.setProperty("height", config.size.toString());
|
|
202
|
+
|
|
203
|
+
$pops.style.setProperty("transform", "translateY(100%)");
|
|
204
|
+
} else if (["left"].includes(config.direction)) {
|
|
205
|
+
$pops.style.setProperty("width", config.size.toString());
|
|
206
|
+
|
|
207
|
+
$pops.style.setProperty("transform", "translateX(-100%)");
|
|
208
|
+
} else if (["right"].includes(config.direction)) {
|
|
209
|
+
$pops.style.setProperty("width", config.size.toString());
|
|
210
|
+
|
|
211
|
+
$pops.style.setProperty("transform", "translateX(100%)");
|
|
212
|
+
}
|
|
213
|
+
element.style.setProperty("display", "");
|
|
214
|
+
});
|
|
215
|
+
// 创建到页面中
|
|
216
|
+
|
|
217
|
+
popsDOMUtils.append($shadowRoot, $elList);
|
|
218
|
+
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
219
|
+
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
popsDOMUtils.appendBody($shadowContainer);
|
|
223
|
+
popsUtils.setTimeout(() => {
|
|
224
|
+
popsUtils.setTimeout(() => {
|
|
225
|
+
$pops.style.setProperty("transform", "");
|
|
226
|
+
}, config.openDelay);
|
|
227
|
+
}, 50);
|
|
228
|
+
|
|
229
|
+
if ($mask != null) {
|
|
230
|
+
$anim.after($mask);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
PopsHandler.handlePush(popsType, {
|
|
234
|
+
guid: guid,
|
|
235
|
+
$anim: $anim,
|
|
236
|
+
$pops: $pops,
|
|
237
|
+
$mask: $mask!,
|
|
238
|
+
$shadowContainer: $shadowContainer,
|
|
239
|
+
$shadowRoot: $shadowRoot,
|
|
240
|
+
config: config,
|
|
241
|
+
destory: result.close,
|
|
242
|
+
});
|
|
243
|
+
return result;
|
|
244
|
+
},
|
|
245
|
+
};
|
|
@@ -1,61 +1,62 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
PopsTitleConfig,
|
|
3
|
-
PopsContentConfig,
|
|
4
|
-
// PopsDragConfig,
|
|
5
|
-
PopsGeneralConfig,
|
|
6
|
-
PopsMoreButtonConfig,
|
|
7
|
-
} from "../../../types/components";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* pops.drawer
|
|
11
|
-
*/
|
|
12
|
-
export interface PopsDrawerConfig
|
|
13
|
-
extends
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
1
|
+
import type {
|
|
2
|
+
PopsTitleConfig,
|
|
3
|
+
PopsContentConfig,
|
|
4
|
+
// PopsDragConfig,
|
|
5
|
+
PopsGeneralConfig,
|
|
6
|
+
PopsMoreButtonConfig,
|
|
7
|
+
} from "../../../types/components";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* pops.drawer
|
|
11
|
+
*/
|
|
12
|
+
export interface PopsDrawerConfig
|
|
13
|
+
extends
|
|
14
|
+
PopsContentConfig,
|
|
15
|
+
PopsMoreButtonConfig,
|
|
16
|
+
Omit<PopsGeneralConfig, "width" | "height" | "position" | "animation"> {
|
|
17
|
+
/**
|
|
18
|
+
* 标题
|
|
19
|
+
*/
|
|
20
|
+
title?: Partial<PopsTitleConfig["title"]> & {
|
|
21
|
+
/**
|
|
22
|
+
* 是否启用
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
enable: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 打开的方向
|
|
29
|
+
* @default "right"
|
|
30
|
+
*/
|
|
31
|
+
direction?: "top" | "bottom" | "left" | "right";
|
|
32
|
+
/**
|
|
33
|
+
* 窗体的大小; 当使用 number 类型时; 以像素为单位,默认为30%
|
|
34
|
+
* @default "30%"
|
|
35
|
+
*/
|
|
36
|
+
size?: string | number;
|
|
37
|
+
/**
|
|
38
|
+
* 是否在 Drawer 出现时将 body 滚动锁定,默认为false
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
lockScroll?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* 是否可以通过按下 ESC 关闭 Drawer,默认为true
|
|
44
|
+
* @default true'
|
|
45
|
+
*/
|
|
46
|
+
closeOnPressEscape?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 打开的延时时间,单位毫秒,默认为0
|
|
49
|
+
* @default 0
|
|
50
|
+
*/
|
|
51
|
+
openDelay?: number;
|
|
52
|
+
/**
|
|
53
|
+
* 关闭的延时时间,单位毫秒,默认为0
|
|
54
|
+
* @default 0
|
|
55
|
+
*/
|
|
56
|
+
closeDelay?: number;
|
|
57
|
+
/**
|
|
58
|
+
* border-radius,根据direction自动适应,默认为5
|
|
59
|
+
* @default 5
|
|
60
|
+
*/
|
|
61
|
+
borderRadius?: number;
|
|
62
|
+
}
|