@whitesev/pops 3.2.1 → 3.2.2
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 +702 -667
- 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 +702 -667
- 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 +702 -667
- 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 +702 -667
- 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 +702 -667
- 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 +702 -667
- 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/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 +27 -25
- package/src/Pops.ts +206 -206
- package/src/PopsAnimation.ts +32 -32
- package/src/PopsCSS.ts +54 -54
- package/src/PopsCore.ts +37 -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 +421 -421
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
2
|
-
import { PopsHandler } from "../../handler/PopsHandler";
|
|
3
|
-
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
4
|
-
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
5
|
-
import { popsUtils } from "../../utils/PopsUtils";
|
|
6
|
-
import type { PopsPanelConfig, PopsPanelEventType } from "./types";
|
|
7
|
-
import { PopsPanelDefaultConfig } from "./defaultConfig";
|
|
8
|
-
import { PanelHandlerComponents } from "./handlerComponents";
|
|
9
|
-
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
10
|
-
import { PopsCSS } from "../../PopsCSS";
|
|
11
|
-
import type { PopsType } from "../../types/main";
|
|
12
|
-
|
|
13
|
-
export const PopsPanel = {
|
|
14
|
-
init(__config__: PopsPanelConfig) {
|
|
15
|
-
const guid = popsUtils.getRandomGUID();
|
|
16
|
-
// 设置当前类型
|
|
17
|
-
const popsType: PopsType = "panel";
|
|
18
|
-
|
|
19
|
-
let config: Required<PopsPanelConfig> = PopsPanelDefaultConfig();
|
|
20
|
-
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
21
|
-
config = popsUtils.assign(config, __config__);
|
|
22
|
-
config = PopsHandler.handleOnly(popsType, config);
|
|
23
|
-
|
|
24
|
-
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
25
|
-
PopsHandler.handleInit($shadowRoot, [
|
|
26
|
-
{
|
|
27
|
-
name: "index",
|
|
28
|
-
css: PopsCSS.index,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: "ninePalaceGridPosition",
|
|
32
|
-
css: PopsCSS.ninePalaceGridPosition,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "scrollbar",
|
|
36
|
-
css: PopsCSS.scrollbar,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "button",
|
|
40
|
-
css: PopsCSS.button,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "anim",
|
|
44
|
-
css: PopsCSS.anim,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "common",
|
|
48
|
-
css: PopsCSS.common,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "panelCSS",
|
|
52
|
-
css: PopsCSS.panelCSS,
|
|
53
|
-
},
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
// 先把z-index提取出来
|
|
57
|
-
const zIndex = PopsHandler.handleZIndex(config.zIndex);
|
|
58
|
-
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
59
|
-
|
|
60
|
-
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
61
|
-
const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
|
|
62
|
-
|
|
63
|
-
const animHTML = PopsElementHandler.createAnim(
|
|
64
|
-
guid,
|
|
65
|
-
popsType,
|
|
66
|
-
config,
|
|
67
|
-
/*html*/ `
|
|
68
|
-
<div class="pops-title pops-${popsType}-title" style="text-align: ${config.title.position};${headerStyle}">${
|
|
69
|
-
config.title.html
|
|
70
|
-
? config.title.text
|
|
71
|
-
: `<p pops class="pops-${popsType}-title-text" class="pops-${popsType}-title-text" style="${headerPStyle}">${config.title.text}</p>`
|
|
72
|
-
}${headerBtnHTML}</div>
|
|
73
|
-
<div class="pops-content pops-${popsType}-content">
|
|
74
|
-
<aside class="pops-${popsType}-aside pops-user-select-none">
|
|
75
|
-
<ul class="pops-${popsType}-aside-top-container"></ul>
|
|
76
|
-
<ul class="pops-${popsType}-aside-bottom-container"></ul>
|
|
77
|
-
</aside>
|
|
78
|
-
<div class="pops-${popsType}-section-wrapper">
|
|
79
|
-
<section class="pops-${popsType}-container">
|
|
80
|
-
<ul class="pops-${popsType}-container-header-ul"></ul>
|
|
81
|
-
<ul class="pops-${popsType}-container-main-ul"></ul>
|
|
82
|
-
</section>
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
<div class="pops-${popsType}-bottom-wrapper">
|
|
86
|
-
<section class="pops-${popsType}-bottom-container">
|
|
87
|
-
<ul class="pops-${popsType}-bottom-left-container"></ul>
|
|
88
|
-
<ul class="pops-${popsType}-bottom-right-container"></ul>
|
|
89
|
-
</section>
|
|
90
|
-
</div>
|
|
91
|
-
`,
|
|
92
|
-
"",
|
|
93
|
-
zIndex
|
|
94
|
-
);
|
|
95
|
-
/**
|
|
96
|
-
* 弹窗的主元素,包括动画层
|
|
97
|
-
*/
|
|
98
|
-
const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
|
|
99
|
-
// 结构元素
|
|
100
|
-
const {
|
|
101
|
-
$pops,
|
|
102
|
-
$headerBtnClose,
|
|
103
|
-
$title,
|
|
104
|
-
$content,
|
|
105
|
-
$panelRightSectionWrapper,
|
|
106
|
-
$panelLeftAside,
|
|
107
|
-
$panelContentSectionContainer,
|
|
108
|
-
$panelBottomWrapper,
|
|
109
|
-
$panelBottomContainer,
|
|
110
|
-
$panelBottomLeftContainer,
|
|
111
|
-
$panelBottomRightContainer,
|
|
112
|
-
} = PopsHandler.handleQueryElement($anim, popsType);
|
|
113
|
-
if (config.isMobile || popsUtils.isPhone()) {
|
|
114
|
-
popsDOMUtils.addClassName($pops, config.mobileClassName);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* 遮罩层元素
|
|
118
|
-
*/
|
|
119
|
-
let $mask: HTMLDivElement | undefined = void 0;
|
|
120
|
-
/**
|
|
121
|
-
* 已创建的元素列表
|
|
122
|
-
*/
|
|
123
|
-
const $elList: HTMLElement[] = [$anim];
|
|
124
|
-
|
|
125
|
-
// 遮罩层元素
|
|
126
|
-
if (config.mask.enable) {
|
|
127
|
-
const handleMask = PopsHandler.handleMask({
|
|
128
|
-
type: popsType,
|
|
129
|
-
guid: guid,
|
|
130
|
-
config: config,
|
|
131
|
-
animElement: $anim,
|
|
132
|
-
maskHTML: maskHTML,
|
|
133
|
-
});
|
|
134
|
-
$mask = handleMask.maskElement;
|
|
135
|
-
$elList.push($mask);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// 处理返回的配置
|
|
139
|
-
const evtConfig = PopsHandler.handleEventConfig(
|
|
140
|
-
config,
|
|
141
|
-
guid,
|
|
142
|
-
$shadowContainer,
|
|
143
|
-
$shadowRoot,
|
|
144
|
-
popsType,
|
|
145
|
-
$anim,
|
|
146
|
-
$pops,
|
|
147
|
-
$mask
|
|
148
|
-
);
|
|
149
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
150
|
-
// 为顶部右边的关闭按钮添加点击事件
|
|
151
|
-
PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
|
|
152
|
-
|
|
153
|
-
// 创建到页面中
|
|
154
|
-
popsDOMUtils.append($shadowRoot, $elList);
|
|
155
|
-
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
156
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
157
|
-
}
|
|
158
|
-
popsDOMUtils.appendBody($shadowContainer);
|
|
159
|
-
// 追加遮罩层元素
|
|
160
|
-
if ($mask != null) {
|
|
161
|
-
$anim.after($mask);
|
|
162
|
-
}
|
|
163
|
-
const panelHandlerComponents = PanelHandlerComponents();
|
|
164
|
-
/**
|
|
165
|
-
* 处理内部配置
|
|
166
|
-
*/
|
|
167
|
-
panelHandlerComponents.init({
|
|
168
|
-
config: config,
|
|
169
|
-
$el: {
|
|
170
|
-
$pops,
|
|
171
|
-
$content,
|
|
172
|
-
$panelRightSectionWrapper,
|
|
173
|
-
$panelLeftAside,
|
|
174
|
-
$panelContentSectionContainer,
|
|
175
|
-
$panelBottomWrapper,
|
|
176
|
-
$panelBottomContainer,
|
|
177
|
-
$panelBottomLeftContainer,
|
|
178
|
-
$panelBottomRightContainer,
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
PopsHandler.handlePush(popsType, {
|
|
183
|
-
guid: guid,
|
|
184
|
-
$anim: $anim,
|
|
185
|
-
$pops: $pops,
|
|
186
|
-
$mask: $mask!,
|
|
187
|
-
$shadowContainer: $shadowContainer,
|
|
188
|
-
$shadowRoot: $shadowRoot,
|
|
189
|
-
config: config,
|
|
190
|
-
destory: result.close,
|
|
191
|
-
});
|
|
192
|
-
// 拖拽
|
|
193
|
-
if (config.drag) {
|
|
194
|
-
PopsInstanceUtils.drag($pops, {
|
|
195
|
-
dragElement: $title,
|
|
196
|
-
limit: config.dragLimit,
|
|
197
|
-
extraDistance: config.dragExtraDistance,
|
|
198
|
-
moveCallBack: config.dragMoveCallBack,
|
|
199
|
-
endCallBack: config.dragEndCallBack,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
...result,
|
|
205
|
-
addEventListener: <K extends keyof PopsPanelEventType>(
|
|
206
|
-
event: K,
|
|
207
|
-
listener: (evt: CustomEvent<PopsPanelEventType[K]>) => void,
|
|
208
|
-
options?: boolean | EventListenerOptions
|
|
209
|
-
) => {
|
|
210
|
-
$pops.addEventListener(event, listener as any, options);
|
|
211
|
-
},
|
|
212
|
-
removeEventListener: <K extends keyof PopsPanelEventType>(
|
|
213
|
-
event: K,
|
|
214
|
-
listener: (evt: CustomEvent<PopsPanelEventType[K]>) => void,
|
|
215
|
-
options?: boolean | EventListenerOptions
|
|
216
|
-
) => {
|
|
217
|
-
$pops.removeEventListener(event, listener as any, options);
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
},
|
|
221
|
-
};
|
|
1
|
+
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
2
|
+
import { PopsHandler } from "../../handler/PopsHandler";
|
|
3
|
+
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
4
|
+
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
5
|
+
import { popsUtils } from "../../utils/PopsUtils";
|
|
6
|
+
import type { PopsPanelConfig, PopsPanelEventType } from "./types";
|
|
7
|
+
import { PopsPanelDefaultConfig } from "./defaultConfig";
|
|
8
|
+
import { PanelHandlerComponents } from "./handlerComponents";
|
|
9
|
+
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
10
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
11
|
+
import type { PopsType } from "../../types/main";
|
|
12
|
+
|
|
13
|
+
export const PopsPanel = {
|
|
14
|
+
init(__config__: PopsPanelConfig) {
|
|
15
|
+
const guid = popsUtils.getRandomGUID();
|
|
16
|
+
// 设置当前类型
|
|
17
|
+
const popsType: PopsType = "panel";
|
|
18
|
+
|
|
19
|
+
let config: Required<PopsPanelConfig> = PopsPanelDefaultConfig();
|
|
20
|
+
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
21
|
+
config = popsUtils.assign(config, __config__);
|
|
22
|
+
config = PopsHandler.handleOnly(popsType, config);
|
|
23
|
+
|
|
24
|
+
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
25
|
+
PopsHandler.handleInit($shadowRoot, [
|
|
26
|
+
{
|
|
27
|
+
name: "index",
|
|
28
|
+
css: PopsCSS.index,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "ninePalaceGridPosition",
|
|
32
|
+
css: PopsCSS.ninePalaceGridPosition,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "scrollbar",
|
|
36
|
+
css: PopsCSS.scrollbar,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "button",
|
|
40
|
+
css: PopsCSS.button,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "anim",
|
|
44
|
+
css: PopsCSS.anim,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "common",
|
|
48
|
+
css: PopsCSS.common,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "panelCSS",
|
|
52
|
+
css: PopsCSS.panelCSS,
|
|
53
|
+
},
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
// 先把z-index提取出来
|
|
57
|
+
const zIndex = PopsHandler.handleZIndex(config.zIndex);
|
|
58
|
+
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
59
|
+
|
|
60
|
+
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
61
|
+
const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
|
|
62
|
+
|
|
63
|
+
const animHTML = PopsElementHandler.createAnim(
|
|
64
|
+
guid,
|
|
65
|
+
popsType,
|
|
66
|
+
config,
|
|
67
|
+
/*html*/ `
|
|
68
|
+
<div class="pops-title pops-${popsType}-title" style="text-align: ${config.title.position};${headerStyle}">${
|
|
69
|
+
config.title.html
|
|
70
|
+
? config.title.text
|
|
71
|
+
: `<p pops class="pops-${popsType}-title-text" class="pops-${popsType}-title-text" style="${headerPStyle}">${config.title.text}</p>`
|
|
72
|
+
}${headerBtnHTML}</div>
|
|
73
|
+
<div class="pops-content pops-${popsType}-content">
|
|
74
|
+
<aside class="pops-${popsType}-aside pops-user-select-none">
|
|
75
|
+
<ul class="pops-${popsType}-aside-top-container"></ul>
|
|
76
|
+
<ul class="pops-${popsType}-aside-bottom-container"></ul>
|
|
77
|
+
</aside>
|
|
78
|
+
<div class="pops-${popsType}-section-wrapper">
|
|
79
|
+
<section class="pops-${popsType}-container">
|
|
80
|
+
<ul class="pops-${popsType}-container-header-ul"></ul>
|
|
81
|
+
<ul class="pops-${popsType}-container-main-ul"></ul>
|
|
82
|
+
</section>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="pops-${popsType}-bottom-wrapper">
|
|
86
|
+
<section class="pops-${popsType}-bottom-container">
|
|
87
|
+
<ul class="pops-${popsType}-bottom-left-container"></ul>
|
|
88
|
+
<ul class="pops-${popsType}-bottom-right-container"></ul>
|
|
89
|
+
</section>
|
|
90
|
+
</div>
|
|
91
|
+
`,
|
|
92
|
+
"",
|
|
93
|
+
zIndex
|
|
94
|
+
);
|
|
95
|
+
/**
|
|
96
|
+
* 弹窗的主元素,包括动画层
|
|
97
|
+
*/
|
|
98
|
+
const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
|
|
99
|
+
// 结构元素
|
|
100
|
+
const {
|
|
101
|
+
$pops,
|
|
102
|
+
$headerBtnClose,
|
|
103
|
+
$title,
|
|
104
|
+
$content,
|
|
105
|
+
$panelRightSectionWrapper,
|
|
106
|
+
$panelLeftAside,
|
|
107
|
+
$panelContentSectionContainer,
|
|
108
|
+
$panelBottomWrapper,
|
|
109
|
+
$panelBottomContainer,
|
|
110
|
+
$panelBottomLeftContainer,
|
|
111
|
+
$panelBottomRightContainer,
|
|
112
|
+
} = PopsHandler.handleQueryElement($anim, popsType);
|
|
113
|
+
if (config.isMobile || popsUtils.isPhone()) {
|
|
114
|
+
popsDOMUtils.addClassName($pops, config.mobileClassName);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 遮罩层元素
|
|
118
|
+
*/
|
|
119
|
+
let $mask: HTMLDivElement | undefined = void 0;
|
|
120
|
+
/**
|
|
121
|
+
* 已创建的元素列表
|
|
122
|
+
*/
|
|
123
|
+
const $elList: HTMLElement[] = [$anim];
|
|
124
|
+
|
|
125
|
+
// 遮罩层元素
|
|
126
|
+
if (config.mask.enable) {
|
|
127
|
+
const handleMask = PopsHandler.handleMask({
|
|
128
|
+
type: popsType,
|
|
129
|
+
guid: guid,
|
|
130
|
+
config: config,
|
|
131
|
+
animElement: $anim,
|
|
132
|
+
maskHTML: maskHTML,
|
|
133
|
+
});
|
|
134
|
+
$mask = handleMask.maskElement;
|
|
135
|
+
$elList.push($mask);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 处理返回的配置
|
|
139
|
+
const evtConfig = PopsHandler.handleEventConfig(
|
|
140
|
+
config,
|
|
141
|
+
guid,
|
|
142
|
+
$shadowContainer,
|
|
143
|
+
$shadowRoot,
|
|
144
|
+
popsType,
|
|
145
|
+
$anim,
|
|
146
|
+
$pops,
|
|
147
|
+
$mask
|
|
148
|
+
);
|
|
149
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
150
|
+
// 为顶部右边的关闭按钮添加点击事件
|
|
151
|
+
PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
|
|
152
|
+
|
|
153
|
+
// 创建到页面中
|
|
154
|
+
popsDOMUtils.append($shadowRoot, $elList);
|
|
155
|
+
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
156
|
+
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
157
|
+
}
|
|
158
|
+
popsDOMUtils.appendBody($shadowContainer);
|
|
159
|
+
// 追加遮罩层元素
|
|
160
|
+
if ($mask != null) {
|
|
161
|
+
$anim.after($mask);
|
|
162
|
+
}
|
|
163
|
+
const panelHandlerComponents = PanelHandlerComponents();
|
|
164
|
+
/**
|
|
165
|
+
* 处理内部配置
|
|
166
|
+
*/
|
|
167
|
+
panelHandlerComponents.init({
|
|
168
|
+
config: config,
|
|
169
|
+
$el: {
|
|
170
|
+
$pops,
|
|
171
|
+
$content,
|
|
172
|
+
$panelRightSectionWrapper,
|
|
173
|
+
$panelLeftAside,
|
|
174
|
+
$panelContentSectionContainer,
|
|
175
|
+
$panelBottomWrapper,
|
|
176
|
+
$panelBottomContainer,
|
|
177
|
+
$panelBottomLeftContainer,
|
|
178
|
+
$panelBottomRightContainer,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
PopsHandler.handlePush(popsType, {
|
|
183
|
+
guid: guid,
|
|
184
|
+
$anim: $anim,
|
|
185
|
+
$pops: $pops,
|
|
186
|
+
$mask: $mask!,
|
|
187
|
+
$shadowContainer: $shadowContainer,
|
|
188
|
+
$shadowRoot: $shadowRoot,
|
|
189
|
+
config: config,
|
|
190
|
+
destory: result.close,
|
|
191
|
+
});
|
|
192
|
+
// 拖拽
|
|
193
|
+
if (config.drag) {
|
|
194
|
+
PopsInstanceUtils.drag($pops, {
|
|
195
|
+
dragElement: $title,
|
|
196
|
+
limit: config.dragLimit,
|
|
197
|
+
extraDistance: config.dragExtraDistance,
|
|
198
|
+
moveCallBack: config.dragMoveCallBack,
|
|
199
|
+
endCallBack: config.dragEndCallBack,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
...result,
|
|
205
|
+
addEventListener: <K extends keyof PopsPanelEventType>(
|
|
206
|
+
event: K,
|
|
207
|
+
listener: (evt: CustomEvent<PopsPanelEventType[K]>) => void,
|
|
208
|
+
options?: boolean | EventListenerOptions
|
|
209
|
+
) => {
|
|
210
|
+
$pops.addEventListener(event, listener as any, options);
|
|
211
|
+
},
|
|
212
|
+
removeEventListener: <K extends keyof PopsPanelEventType>(
|
|
213
|
+
event: K,
|
|
214
|
+
listener: (evt: CustomEvent<PopsPanelEventType[K]>) => void,
|
|
215
|
+
options?: boolean | EventListenerOptions
|
|
216
|
+
) => {
|
|
217
|
+
$pops.removeEventListener(event, listener as any, options);
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
};
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import type { PopsPanelGeneralConfig } from "./components-common";
|
|
2
|
-
import type { PopsButtonStyleType } from "../../../types/button";
|
|
3
|
-
import type { PopsIconType } from "../../../types/icon";
|
|
4
|
-
/**
|
|
5
|
-
* pops.panel的 button
|
|
6
|
-
*/
|
|
7
|
-
export interface PopsPanelButtonConfig extends PopsPanelGeneralConfig<PopsPanelButtonConfig> {
|
|
8
|
-
/**
|
|
9
|
-
* 组件类型
|
|
10
|
-
*/
|
|
11
|
-
type: "button";
|
|
12
|
-
/**
|
|
13
|
-
* 显示在左边的文字
|
|
14
|
-
*/
|
|
15
|
-
text: string;
|
|
16
|
-
/**
|
|
17
|
-
* (可选)左边的文字下面的描述
|
|
18
|
-
*/
|
|
19
|
-
description?: string;
|
|
20
|
-
/**
|
|
21
|
-
* (可选)是否禁用
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
disable?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* 按钮的类型
|
|
27
|
-
*/
|
|
28
|
-
buttonType: PopsButtonStyleType;
|
|
29
|
-
/**
|
|
30
|
-
* 按钮的文字
|
|
31
|
-
*/
|
|
32
|
-
buttonText: string | (() => string);
|
|
33
|
-
/**
|
|
34
|
-
* 按钮的图标,已配置的svg请看pops.config.iconSVG,或者自定义的图标svg代码,留空则是没有图标
|
|
35
|
-
* @default ""
|
|
36
|
-
*/
|
|
37
|
-
buttonIcon?: PopsIconType;
|
|
38
|
-
/**
|
|
39
|
-
* 按钮的图标在右边
|
|
40
|
-
* + true 右边
|
|
41
|
-
* + false 左边
|
|
42
|
-
* @default false
|
|
43
|
-
*/
|
|
44
|
-
buttonIsRightIcon?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* 按钮的图标旋转
|
|
47
|
-
* + true 旋转
|
|
48
|
-
* + false 不旋转
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
51
|
-
buttonIconIsLoading?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* 点击button触发的事件
|
|
54
|
-
*/
|
|
55
|
-
callback: (event: MouseEvent | PointerEvent) => void;
|
|
56
|
-
}
|
|
1
|
+
import type { PopsPanelGeneralConfig } from "./components-common";
|
|
2
|
+
import type { PopsButtonStyleType } from "../../../types/button";
|
|
3
|
+
import type { PopsIconType } from "../../../types/icon";
|
|
4
|
+
/**
|
|
5
|
+
* pops.panel的 button
|
|
6
|
+
*/
|
|
7
|
+
export interface PopsPanelButtonConfig extends PopsPanelGeneralConfig<PopsPanelButtonConfig> {
|
|
8
|
+
/**
|
|
9
|
+
* 组件类型
|
|
10
|
+
*/
|
|
11
|
+
type: "button";
|
|
12
|
+
/**
|
|
13
|
+
* 显示在左边的文字
|
|
14
|
+
*/
|
|
15
|
+
text: string;
|
|
16
|
+
/**
|
|
17
|
+
* (可选)左边的文字下面的描述
|
|
18
|
+
*/
|
|
19
|
+
description?: string;
|
|
20
|
+
/**
|
|
21
|
+
* (可选)是否禁用
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
disable?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 按钮的类型
|
|
27
|
+
*/
|
|
28
|
+
buttonType: PopsButtonStyleType;
|
|
29
|
+
/**
|
|
30
|
+
* 按钮的文字
|
|
31
|
+
*/
|
|
32
|
+
buttonText: string | (() => string);
|
|
33
|
+
/**
|
|
34
|
+
* 按钮的图标,已配置的svg请看pops.config.iconSVG,或者自定义的图标svg代码,留空则是没有图标
|
|
35
|
+
* @default ""
|
|
36
|
+
*/
|
|
37
|
+
buttonIcon?: PopsIconType;
|
|
38
|
+
/**
|
|
39
|
+
* 按钮的图标在右边
|
|
40
|
+
* + true 右边
|
|
41
|
+
* + false 左边
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
buttonIsRightIcon?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 按钮的图标旋转
|
|
47
|
+
* + true 旋转
|
|
48
|
+
* + false 不旋转
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
buttonIconIsLoading?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* 点击button触发的事件
|
|
54
|
+
*/
|
|
55
|
+
callback: (event: MouseEvent | PointerEvent) => void;
|
|
56
|
+
}
|