@whitesev/pops 2.0.10 → 2.0.12
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 +4695 -4403
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +4695 -4403
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +4695 -4403
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +4695 -4403
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +4695 -4403
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +4695 -4403
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +66 -42
- package/dist/types/src/PopsAnimation.d.ts +14 -0
- package/dist/types/src/PopsCSS.d.ts +34 -0
- package/dist/types/src/PopsIcon.d.ts +25 -0
- package/dist/types/src/PopsLayer.d.ts +3 -0
- package/dist/types/src/components/panel/buttonType.d.ts +2 -2
- package/dist/types/src/components/rightClickMenu/index.d.ts +2 -3
- package/dist/types/src/components/rightClickMenu/indexType.d.ts +4 -3
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +19 -6
- package/dist/types/src/types/button.d.ts +3 -3
- package/dist/types/src/types/icon.d.ts +1 -1
- package/dist/types/src/utils/PopsDOMUtils.d.ts +120 -26
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -6
- package/dist/types/src/utils/PopsUtils.d.ts +5 -6
- package/package.json +1 -1
- package/src/Pops.ts +12 -152
- package/src/PopsAnimation.ts +32 -0
- package/src/PopsCSS.ts +51 -0
- package/src/PopsIcon.ts +93 -0
- package/src/PopsLayer.ts +17 -0
- package/src/components/alert/index.ts +8 -8
- package/src/components/confirm/index.ts +8 -8
- package/src/components/drawer/index.ts +8 -8
- package/src/components/folder/index.ts +15 -15
- package/src/components/iframe/index.ts +9 -12
- package/src/components/loading/index.ts +5 -5
- package/src/components/panel/PanelHandleContentDetails.ts +28 -25
- package/src/components/panel/buttonType.ts +2 -2
- package/src/components/panel/config.ts +4 -0
- package/src/components/panel/index.css +33 -0
- package/src/components/panel/index.ts +9 -9
- package/src/components/prompt/index.ts +8 -8
- package/src/components/rightClickMenu/config.ts +7 -7
- package/src/components/rightClickMenu/index.ts +41 -29
- package/src/components/rightClickMenu/indexType.ts +5 -3
- package/src/components/searchSuggestion/index.ts +5 -5
- package/src/components/tooltip/index.ts +5 -5
- package/src/handler/PopsElementHandler.ts +17 -17
- package/src/handler/PopsHandler.ts +22 -19
- package/src/types/PopsDOMUtilsEventType.d.ts +19 -6
- package/src/types/button.d.ts +3 -3
- package/src/types/icon.d.ts +1 -1
- package/src/utils/PopsDOMUtils.ts +568 -170
- package/src/utils/PopsInstanceUtils.ts +13 -31
- package/src/utils/PopsUtils.ts +7 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GlobalConfig } from "../../GlobalConfig";
|
|
2
2
|
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
3
3
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
4
|
-
import {
|
|
4
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
5
5
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
6
6
|
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
7
7
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
@@ -21,13 +21,13 @@ export const PopsPrompt = {
|
|
|
21
21
|
|
|
22
22
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
23
23
|
PopsHandler.handleInit($shadowRoot, [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
PopsCSS.index,
|
|
25
|
+
PopsCSS.ninePalaceGridPosition,
|
|
26
|
+
PopsCSS.scrollbar,
|
|
27
|
+
PopsCSS.button,
|
|
28
|
+
PopsCSS.anim,
|
|
29
|
+
PopsCSS.common,
|
|
30
|
+
PopsCSS.promptCSS,
|
|
31
31
|
]);
|
|
32
32
|
|
|
33
33
|
// 先把z-index提取出来
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PopsIcon } from "../../PopsIcon";
|
|
2
2
|
import type { PopsRightClickMenuDetails } from "./indexType";
|
|
3
3
|
|
|
4
4
|
export const rightClickMenuConfig =
|
|
@@ -8,7 +8,7 @@ export const rightClickMenuConfig =
|
|
|
8
8
|
targetSelector: null,
|
|
9
9
|
data: [
|
|
10
10
|
{
|
|
11
|
-
icon:
|
|
11
|
+
icon: PopsIcon.getIcon("search")!,
|
|
12
12
|
iconIsLoading: false,
|
|
13
13
|
text: "搜索",
|
|
14
14
|
item: [],
|
|
@@ -21,7 +21,7 @@ export const rightClickMenuConfig =
|
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
icon:
|
|
24
|
+
icon: PopsIcon.getIcon("documentCopy")!,
|
|
25
25
|
iconIsLoading: false,
|
|
26
26
|
text: "复制",
|
|
27
27
|
item: [],
|
|
@@ -34,7 +34,7 @@ export const rightClickMenuConfig =
|
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
icon:
|
|
37
|
+
icon: PopsIcon.getIcon("delete")!,
|
|
38
38
|
text: "删除",
|
|
39
39
|
iconIsLoading: false,
|
|
40
40
|
item: [],
|
|
@@ -47,7 +47,7 @@ export const rightClickMenuConfig =
|
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
icon:
|
|
50
|
+
icon: PopsIcon.getIcon("loading")!,
|
|
51
51
|
iconIsLoading: true,
|
|
52
52
|
text: "加载",
|
|
53
53
|
item: [],
|
|
@@ -61,7 +61,7 @@ export const rightClickMenuConfig =
|
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
|
-
icon:
|
|
64
|
+
icon: PopsIcon.getIcon("elemePlus")!,
|
|
65
65
|
iconIsLoading: true,
|
|
66
66
|
text: "饿了么",
|
|
67
67
|
callback(clickEvent, contextMenuEvent, liElement) {
|
|
@@ -99,7 +99,7 @@ export const rightClickMenuConfig =
|
|
|
99
99
|
},
|
|
100
100
|
item: [
|
|
101
101
|
{
|
|
102
|
-
icon:
|
|
102
|
+
icon: PopsIcon.getIcon("view")!,
|
|
103
103
|
iconIsLoading: false,
|
|
104
104
|
text: "查看",
|
|
105
105
|
item: [],
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { OriginPrototype } from "../../Core";
|
|
2
2
|
import { GlobalConfig } from "../../GlobalConfig";
|
|
3
3
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
4
|
-
import { pops } from "../../Pops";
|
|
5
4
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
6
5
|
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
7
6
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
8
7
|
import { rightClickMenuConfig as PopsRightClickMenuConfig } from "./config";
|
|
9
|
-
import type { PopsIcon } from "../../types/icon";
|
|
10
8
|
import type {
|
|
11
9
|
PopsRightClickMenuDataDetails,
|
|
12
10
|
PopsRightClickMenuDetails,
|
|
13
11
|
} from "./indexType";
|
|
12
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
13
|
+
import { PopsIcon } from "../../PopsIcon";
|
|
14
14
|
|
|
15
15
|
export const PopsRightClickMenu = {
|
|
16
16
|
init(details: PopsRightClickMenuDetails) {
|
|
@@ -31,10 +31,10 @@ export const PopsRightClickMenu = {
|
|
|
31
31
|
}
|
|
32
32
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
33
33
|
PopsHandler.handleInit($shadowRoot, [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
PopsCSS.index,
|
|
35
|
+
PopsCSS.anim,
|
|
36
|
+
PopsCSS.common,
|
|
37
|
+
PopsCSS.rightClickMenu,
|
|
38
38
|
]);
|
|
39
39
|
|
|
40
40
|
if (config.style != null) {
|
|
@@ -149,8 +149,9 @@ export const PopsRightClickMenu = {
|
|
|
149
149
|
/**
|
|
150
150
|
* contextmenu事件
|
|
151
151
|
* @param event
|
|
152
|
+
* @param selectorTarget
|
|
152
153
|
*/
|
|
153
|
-
contextMenuEvent(event: PointerEvent) {
|
|
154
|
+
contextMenuEvent(event: PointerEvent, selectorTarget: HTMLElement) {
|
|
154
155
|
if (config.preventDefault) {
|
|
155
156
|
popsDOMUtils.preventEvent(event);
|
|
156
157
|
}
|
|
@@ -158,15 +159,19 @@ export const PopsRightClickMenu = {
|
|
|
158
159
|
if (PopsContextMenu.rootElement) {
|
|
159
160
|
PopsContextMenu.closeAllMenu(PopsContextMenu.rootElement);
|
|
160
161
|
}
|
|
161
|
-
let rootElement = PopsContextMenu.showMenu(
|
|
162
|
+
let rootElement = PopsContextMenu.showMenu(
|
|
163
|
+
event,
|
|
164
|
+
config.data,
|
|
165
|
+
selectorTarget
|
|
166
|
+
);
|
|
162
167
|
PopsContextMenu.rootElement = rootElement;
|
|
163
168
|
if (config.only) {
|
|
164
169
|
PopsHandler.handlePush(PopsType, {
|
|
165
170
|
$shadowRoot: $shadowRoot,
|
|
166
171
|
$shadowContainer: $shadowContainer,
|
|
167
172
|
guid: guid,
|
|
168
|
-
animElement: rootElement
|
|
169
|
-
popsElement: rootElement
|
|
173
|
+
animElement: rootElement,
|
|
174
|
+
popsElement: rootElement,
|
|
170
175
|
beforeRemoveCallBack(layerCommonConfig) {
|
|
171
176
|
PopsContextMenu.closeAllMenu(layerCommonConfig.popsElement);
|
|
172
177
|
},
|
|
@@ -217,7 +222,6 @@ export const PopsRightClickMenu = {
|
|
|
217
222
|
popsDOMUtils.off(
|
|
218
223
|
element,
|
|
219
224
|
popsDOMUtils.getTransitionEndNameList(),
|
|
220
|
-
void 0,
|
|
221
225
|
transitionEndEvent,
|
|
222
226
|
{
|
|
223
227
|
capture: true,
|
|
@@ -230,7 +234,6 @@ export const PopsRightClickMenu = {
|
|
|
230
234
|
popsDOMUtils.on(
|
|
231
235
|
element,
|
|
232
236
|
popsDOMUtils.getTransitionEndNameList(),
|
|
233
|
-
void 0,
|
|
234
237
|
transitionEndEvent,
|
|
235
238
|
{
|
|
236
239
|
capture: true,
|
|
@@ -327,10 +330,12 @@ export const PopsRightClickMenu = {
|
|
|
327
330
|
* 显示菜单
|
|
328
331
|
* @param menuEvent 触发的事件
|
|
329
332
|
* @param _config_
|
|
333
|
+
* @param menuListenerRootNode 右键菜单监听的元素
|
|
330
334
|
*/
|
|
331
335
|
showMenu(
|
|
332
336
|
menuEvent: PointerEvent,
|
|
333
|
-
_config_: PopsRightClickMenuDataDetails[]
|
|
337
|
+
_config_: PopsRightClickMenuDataDetails[],
|
|
338
|
+
menuListenerRootNode: HTMLElement
|
|
334
339
|
) {
|
|
335
340
|
let menuElement = this.getMenuContainerElement(false);
|
|
336
341
|
Reflect.set(menuElement, "__menuData__", {
|
|
@@ -338,9 +343,10 @@ export const PopsRightClickMenu = {
|
|
|
338
343
|
});
|
|
339
344
|
PopsContextMenu.addMenuLiELement(
|
|
340
345
|
menuEvent,
|
|
341
|
-
menuElement
|
|
342
|
-
menuElement
|
|
343
|
-
_config_
|
|
346
|
+
menuElement,
|
|
347
|
+
menuElement,
|
|
348
|
+
_config_,
|
|
349
|
+
menuListenerRootNode
|
|
344
350
|
);
|
|
345
351
|
/* 先隐藏 */
|
|
346
352
|
popsDOMUtils.css(menuElement, {
|
|
@@ -377,6 +383,7 @@ export const PopsRightClickMenu = {
|
|
|
377
383
|
* @param _config_
|
|
378
384
|
* @param rootElement 根菜单元素
|
|
379
385
|
* @param targetLiElement 父li项元素
|
|
386
|
+
* @param menuListenerRootNode 右键菜单监听的元素
|
|
380
387
|
*/
|
|
381
388
|
showClildMenu(
|
|
382
389
|
menuEvent: PointerEvent,
|
|
@@ -386,7 +393,8 @@ export const PopsRightClickMenu = {
|
|
|
386
393
|
},
|
|
387
394
|
_config_: PopsRightClickMenuDataDetails[],
|
|
388
395
|
rootElement: HTMLDivElement,
|
|
389
|
-
targetLiElement: HTMLLIElement
|
|
396
|
+
targetLiElement: HTMLLIElement,
|
|
397
|
+
menuListenerRootNode: HTMLElement
|
|
390
398
|
) {
|
|
391
399
|
let menuElement = this.getMenuContainerElement(true);
|
|
392
400
|
Reflect.set(menuElement, "__menuData__", {
|
|
@@ -397,10 +405,11 @@ export const PopsRightClickMenu = {
|
|
|
397
405
|
let rootElementMenuData = Reflect.get(rootElement, "__menuData__");
|
|
398
406
|
rootElementMenuData.child.push(menuElement);
|
|
399
407
|
PopsContextMenu.addMenuLiELement(
|
|
400
|
-
menuEvent
|
|
401
|
-
rootElement
|
|
402
|
-
menuElement
|
|
403
|
-
_config_
|
|
408
|
+
menuEvent,
|
|
409
|
+
rootElement,
|
|
410
|
+
menuElement,
|
|
411
|
+
_config_,
|
|
412
|
+
menuListenerRootNode
|
|
404
413
|
);
|
|
405
414
|
/* 先隐藏 */
|
|
406
415
|
popsDOMUtils.css(menuElement, {
|
|
@@ -430,23 +439,24 @@ export const PopsRightClickMenu = {
|
|
|
430
439
|
* @param rootElement 根元素
|
|
431
440
|
* @param menuElement 菜单元素
|
|
432
441
|
* @param _config_ 配置
|
|
442
|
+
* @param menuListenerRootNode 右键菜单监听的元素
|
|
433
443
|
*/
|
|
434
444
|
addMenuLiELement(
|
|
435
445
|
menuEvent: PointerEvent,
|
|
436
446
|
rootElement: HTMLDivElement,
|
|
437
447
|
menuElement: HTMLDivElement,
|
|
438
|
-
_config_: PopsRightClickMenuDataDetails[]
|
|
448
|
+
_config_: PopsRightClickMenuDataDetails[],
|
|
449
|
+
menuListenerRootNode: HTMLElement
|
|
439
450
|
) {
|
|
440
451
|
let menuEventTarget = menuEvent.target;
|
|
441
452
|
let menuULElement = menuElement.querySelector<HTMLUListElement>("ul")!;
|
|
442
453
|
_config_.forEach((item) => {
|
|
443
454
|
let menuLiElement =
|
|
444
|
-
|
|
455
|
+
popsDOMUtils.parseTextToDOM<HTMLLIElement>(`<li></li>`);
|
|
445
456
|
/* 判断有无图标,有就添加进去 */
|
|
446
457
|
if (typeof item.icon === "string" && item.icon.trim() !== "") {
|
|
447
|
-
let iconSVGHTML =
|
|
448
|
-
|
|
449
|
-
let iconElement = popsUtils.parseTextToDOM(
|
|
458
|
+
let iconSVGHTML = PopsIcon.getIcon(item.icon) ?? item.icon;
|
|
459
|
+
let iconElement = popsDOMUtils.parseTextToDOM(
|
|
450
460
|
/*html*/ `<i class="pops-${PopsType}-icon" is-loading="${item.iconIsLoading}">${iconSVGHTML}</i>`
|
|
451
461
|
);
|
|
452
462
|
menuLiElement.appendChild(iconElement);
|
|
@@ -512,8 +522,9 @@ export const PopsRightClickMenu = {
|
|
|
512
522
|
clientY: rect.top,
|
|
513
523
|
},
|
|
514
524
|
item.item,
|
|
515
|
-
rootElement
|
|
516
|
-
menuLiElement
|
|
525
|
+
rootElement,
|
|
526
|
+
menuLiElement,
|
|
527
|
+
menuListenerRootNode
|
|
517
528
|
);
|
|
518
529
|
(menuLiElement as any).__menuData__ = {
|
|
519
530
|
child: childMenu,
|
|
@@ -536,7 +547,8 @@ export const PopsRightClickMenu = {
|
|
|
536
547
|
let callbackResult = await item.callback(
|
|
537
548
|
clickEvent as PointerEvent,
|
|
538
549
|
menuEvent,
|
|
539
|
-
menuLiElement
|
|
550
|
+
menuLiElement,
|
|
551
|
+
menuListenerRootNode
|
|
540
552
|
);
|
|
541
553
|
if (
|
|
542
554
|
typeof callbackResult === "boolean" &&
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PopsCommonConfig } from "../../types/components";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PopsIconType } from "../../types/icon";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* pops.rightClickMenu的右键菜单配置
|
|
@@ -8,7 +8,7 @@ export interface PopsRightClickMenuDataDetails {
|
|
|
8
8
|
/**
|
|
9
9
|
* svg图标
|
|
10
10
|
*/
|
|
11
|
-
icon:
|
|
11
|
+
icon: PopsIconType | string;
|
|
12
12
|
/**
|
|
13
13
|
* 图标是否旋转
|
|
14
14
|
*/
|
|
@@ -22,6 +22,7 @@ export interface PopsRightClickMenuDataDetails {
|
|
|
22
22
|
* @param clickEvent 点击菜单的click事件
|
|
23
23
|
* @param contextMenuEvent 触发的contextmenu事件
|
|
24
24
|
* @param liElement <li>元素
|
|
25
|
+
* @param menuListenerRootNode 右键菜单监听的元素
|
|
25
26
|
* @returns
|
|
26
27
|
* + true(默认) 关闭菜单
|
|
27
28
|
* + false 不关闭菜单
|
|
@@ -30,7 +31,8 @@ export interface PopsRightClickMenuDataDetails {
|
|
|
30
31
|
callback?: (
|
|
31
32
|
clickEvent: PointerEvent,
|
|
32
33
|
contextMenuEvent: PointerEvent,
|
|
33
|
-
liElement: HTMLLIElement
|
|
34
|
+
liElement: HTMLLIElement,
|
|
35
|
+
menuListenerRootNode: HTMLElement
|
|
34
36
|
) => boolean | void | Promise<boolean | void>;
|
|
35
37
|
/**
|
|
36
38
|
* 子项配置
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
2
|
-
import { pops } from "../../Pops";
|
|
3
2
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
4
3
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
5
4
|
import { searchSuggestionConfig as PopsSearchSuggestionConfig } from "./config";
|
|
6
5
|
import { GlobalConfig } from "../../GlobalConfig";
|
|
7
6
|
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
8
7
|
import type { PopsSearchSuggestionDetails } from "./indexType";
|
|
8
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
9
9
|
|
|
10
10
|
export const PopsSearchSuggestion = {
|
|
11
11
|
init(details: PopsSearchSuggestionDetails) {
|
|
@@ -29,9 +29,9 @@ export const PopsSearchSuggestion = {
|
|
|
29
29
|
|
|
30
30
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
31
31
|
PopsHandler.handleInit($shadowRoot, [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
PopsCSS.index,
|
|
33
|
+
PopsCSS.anim,
|
|
34
|
+
PopsCSS.common,
|
|
35
35
|
]);
|
|
36
36
|
|
|
37
37
|
if (config.style != null) {
|
|
@@ -655,7 +655,7 @@ export const PopsSearchSuggestion = {
|
|
|
655
655
|
this.$data.isEmpty = true;
|
|
656
656
|
this.clearAllSearchItemLi();
|
|
657
657
|
this.$el.$hintULContainer.appendChild(
|
|
658
|
-
|
|
658
|
+
popsDOMUtils.parseTextToDOM(config.toSearhNotResultHTML)
|
|
659
659
|
);
|
|
660
660
|
if (config.toHideWithNotResult) {
|
|
661
661
|
this.hide();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GlobalConfig } from "../../GlobalConfig";
|
|
2
2
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
3
|
-
import {
|
|
3
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
4
4
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
5
5
|
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
6
6
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
@@ -613,10 +613,10 @@ export const PopsTooltip = {
|
|
|
613
613
|
|
|
614
614
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
615
615
|
PopsHandler.handleInit($shadowRoot, [
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
616
|
+
PopsCSS.index,
|
|
617
|
+
PopsCSS.anim,
|
|
618
|
+
PopsCSS.common,
|
|
619
|
+
PopsCSS.tooltipCSS,
|
|
620
620
|
]);
|
|
621
621
|
|
|
622
622
|
let toolTip = new ToolTip(config, guid, {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { PopsAlertDetails } from "../components/alert/indexType";
|
|
2
2
|
import type { PopsConfirmDetails } from "../components/confirm/indexType";
|
|
3
3
|
import type { PopsIframeDetails } from "../components/iframe/indexType";
|
|
4
|
-
import {
|
|
5
|
-
import type { PopsIcon } from "../types/icon";
|
|
4
|
+
import type { PopsIconType } from "../types/icon";
|
|
6
5
|
import type {
|
|
7
6
|
PopsSupportAnim,
|
|
8
7
|
PopsSupportBottomBtn,
|
|
@@ -13,7 +12,8 @@ import type {
|
|
|
13
12
|
PopsTypeSupportContent,
|
|
14
13
|
PopsTypeSupportHeaderTitle,
|
|
15
14
|
} from "../types/main";
|
|
16
|
-
import {
|
|
15
|
+
import { PopsIcon } from "../PopsIcon";
|
|
16
|
+
import { popsDOMUtils } from "../utils/PopsDOMUtils";
|
|
17
17
|
|
|
18
18
|
export const PopsElementHandler = {
|
|
19
19
|
/**
|
|
@@ -101,9 +101,7 @@ export const PopsElementHandler = {
|
|
|
101
101
|
item = item.toLowerCase();
|
|
102
102
|
topRightButtonHTML += /*html*/ `
|
|
103
103
|
<button class="pops-header-control" type="${item}">
|
|
104
|
-
<i class="pops-icon">${
|
|
105
|
-
(pops.config.iconSVG as any)[item]
|
|
106
|
-
}</i>
|
|
104
|
+
<i class="pops-icon">${PopsIcon.getIcon(item)}</i>
|
|
107
105
|
</button>`;
|
|
108
106
|
});
|
|
109
107
|
resultHTML = /*html*/ `
|
|
@@ -113,7 +111,7 @@ export const PopsElementHandler = {
|
|
|
113
111
|
closeHTML = /*html*/ `
|
|
114
112
|
<div class="pops-header-controls">
|
|
115
113
|
<button class="pops-header-control" type="close" data-header>
|
|
116
|
-
<i class="pops-icon">${
|
|
114
|
+
<i class="pops-icon">${PopsIcon.getIcon("close")}</i>
|
|
117
115
|
</button>
|
|
118
116
|
</div>`;
|
|
119
117
|
}
|
|
@@ -168,12 +166,12 @@ export const PopsElementHandler = {
|
|
|
168
166
|
okButtonSizeClassName = "pops-button-" + config.btn.ok.size;
|
|
169
167
|
}
|
|
170
168
|
let okIconHTML = "";
|
|
171
|
-
let okIcon = __config_confirm.btn.ok!.icon! as
|
|
169
|
+
let okIcon = __config_confirm.btn.ok!.icon! as PopsIconType | string;
|
|
172
170
|
if (okIcon !== "") {
|
|
173
171
|
// 判断图标是否是svg库内的
|
|
174
172
|
let iconHTML = "";
|
|
175
|
-
if (okIcon
|
|
176
|
-
iconHTML =
|
|
173
|
+
if (PopsIcon.hasIcon(okIcon)) {
|
|
174
|
+
iconHTML = PopsIcon.getIcon(okIcon)!;
|
|
177
175
|
} else {
|
|
178
176
|
iconHTML = okIcon;
|
|
179
177
|
}
|
|
@@ -202,12 +200,14 @@ export const PopsElementHandler = {
|
|
|
202
200
|
"pops-button-" + __config_confirm.btn.cancel.size;
|
|
203
201
|
}
|
|
204
202
|
let cancelIconHTML = "";
|
|
205
|
-
let cancelIcon = __config_confirm.btn.cancel!.icon as
|
|
203
|
+
let cancelIcon = __config_confirm.btn.cancel!.icon as
|
|
204
|
+
| PopsIconType
|
|
205
|
+
| string;
|
|
206
206
|
if (cancelIcon !== "") {
|
|
207
207
|
let iconHTML = "";
|
|
208
208
|
// 判断图标是否是svg库内的
|
|
209
|
-
if (cancelIcon
|
|
210
|
-
iconHTML =
|
|
209
|
+
if (PopsIcon.hasIcon(cancelIcon)) {
|
|
210
|
+
iconHTML = PopsIcon.getIcon(cancelIcon)!;
|
|
211
211
|
} else {
|
|
212
212
|
iconHTML = cancelIcon;
|
|
213
213
|
}
|
|
@@ -236,12 +236,12 @@ export const PopsElementHandler = {
|
|
|
236
236
|
"pops-button-" + __config_confirm.btn.other.size;
|
|
237
237
|
}
|
|
238
238
|
let otherIconHTML = "";
|
|
239
|
-
let otherIcon = __config_confirm.btn.other!.icon as
|
|
239
|
+
let otherIcon = __config_confirm.btn.other!.icon as PopsIconType | string;
|
|
240
240
|
if (otherIcon !== "") {
|
|
241
241
|
let iconHTML = "";
|
|
242
242
|
// 判断图标是否是svg库内的
|
|
243
|
-
if (otherIcon
|
|
244
|
-
iconHTML =
|
|
243
|
+
if (PopsIcon.hasIcon(otherIcon)) {
|
|
244
|
+
iconHTML = PopsIcon.getIcon(otherIcon)!;
|
|
245
245
|
} else {
|
|
246
246
|
otherIcon;
|
|
247
247
|
}
|
|
@@ -315,6 +315,6 @@ export const PopsElementHandler = {
|
|
|
315
315
|
* @param html
|
|
316
316
|
*/
|
|
317
317
|
parseElement<T extends HTMLElement>(html: string): T {
|
|
318
|
-
return
|
|
318
|
+
return popsDOMUtils.parseTextToDOM(html);
|
|
319
319
|
},
|
|
320
320
|
};
|
|
@@ -7,7 +7,8 @@ import type { PopsLoadingDetails } from "../components/loading/indexType";
|
|
|
7
7
|
import type { PopsPanelDetails } from "../components/panel/indexType";
|
|
8
8
|
import type { PopsPromptDetails } from "../components/prompt/indexType";
|
|
9
9
|
import { PopsCore } from "../Core";
|
|
10
|
-
import {
|
|
10
|
+
import { PopsAnimation } from "../PopsAnimation";
|
|
11
|
+
import { PopsLayer } from "../PopsLayer";
|
|
11
12
|
import type { PopsCommonConfig } from "../types/components";
|
|
12
13
|
import { PopsEventDetails, PopsHandlerEventDetails } from "../types/event";
|
|
13
14
|
import { PopsLayerCommonConfig } from "../types/layer";
|
|
@@ -50,7 +51,7 @@ export const PopsHandler = {
|
|
|
50
51
|
$shadowRoot?: ShadowRoot | HTMLElement,
|
|
51
52
|
cssText?: string | string[]
|
|
52
53
|
) {
|
|
53
|
-
|
|
54
|
+
PopsAnimation.init();
|
|
54
55
|
if (!arguments.length) {
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
@@ -101,7 +102,9 @@ export const PopsHandler = {
|
|
|
101
102
|
}
|
|
102
103
|
) {
|
|
103
104
|
let result = {
|
|
104
|
-
maskElement:
|
|
105
|
+
maskElement: popsDOMUtils.parseTextToDOM<HTMLDivElement>(
|
|
106
|
+
details.maskHTML
|
|
107
|
+
),
|
|
105
108
|
};
|
|
106
109
|
let isMaskClick = false;
|
|
107
110
|
/**
|
|
@@ -111,7 +114,7 @@ export const PopsHandler = {
|
|
|
111
114
|
function clickEvent(event: MouseEvent | PointerEvent) {
|
|
112
115
|
popsDOMUtils.preventEvent(event);
|
|
113
116
|
// 获取该类型实例存储列表
|
|
114
|
-
let targetLayer =
|
|
117
|
+
let targetLayer = PopsLayer[details.type];
|
|
115
118
|
function originalRun() {
|
|
116
119
|
if (details.config.mask!.clickEvent!.toClose) {
|
|
117
120
|
/* 关闭 */
|
|
@@ -400,7 +403,7 @@ export const PopsHandler = {
|
|
|
400
403
|
close() {
|
|
401
404
|
return PopsInstanceUtils.close(
|
|
402
405
|
mode,
|
|
403
|
-
|
|
406
|
+
PopsLayer[mode],
|
|
404
407
|
guid,
|
|
405
408
|
config,
|
|
406
409
|
animElement
|
|
@@ -409,7 +412,7 @@ export const PopsHandler = {
|
|
|
409
412
|
hide() {
|
|
410
413
|
return PopsInstanceUtils.hide(
|
|
411
414
|
mode,
|
|
412
|
-
|
|
415
|
+
PopsLayer[mode],
|
|
413
416
|
guid,
|
|
414
417
|
config,
|
|
415
418
|
animElement,
|
|
@@ -419,7 +422,7 @@ export const PopsHandler = {
|
|
|
419
422
|
show() {
|
|
420
423
|
return PopsInstanceUtils.show(
|
|
421
424
|
mode,
|
|
422
|
-
|
|
425
|
+
PopsLayer[mode],
|
|
423
426
|
guid,
|
|
424
427
|
config,
|
|
425
428
|
animElement,
|
|
@@ -463,7 +466,7 @@ export const PopsHandler = {
|
|
|
463
466
|
close() {
|
|
464
467
|
return PopsInstanceUtils.close(
|
|
465
468
|
mode,
|
|
466
|
-
|
|
469
|
+
PopsLayer[mode],
|
|
467
470
|
guid,
|
|
468
471
|
config,
|
|
469
472
|
animElement
|
|
@@ -472,7 +475,7 @@ export const PopsHandler = {
|
|
|
472
475
|
hide() {
|
|
473
476
|
return PopsInstanceUtils.hide(
|
|
474
477
|
mode,
|
|
475
|
-
|
|
478
|
+
PopsLayer[mode],
|
|
476
479
|
guid,
|
|
477
480
|
config,
|
|
478
481
|
animElement,
|
|
@@ -482,7 +485,7 @@ export const PopsHandler = {
|
|
|
482
485
|
show() {
|
|
483
486
|
return PopsInstanceUtils.show(
|
|
484
487
|
mode,
|
|
485
|
-
|
|
488
|
+
PopsLayer[mode],
|
|
486
489
|
guid,
|
|
487
490
|
config,
|
|
488
491
|
animElement,
|
|
@@ -636,20 +639,20 @@ export const PopsHandler = {
|
|
|
636
639
|
type === "tooltip" ||
|
|
637
640
|
type === "rightClickMenu"
|
|
638
641
|
) {
|
|
639
|
-
let layer =
|
|
642
|
+
let layer = PopsLayer[type as keyof typeof PopsLayer];
|
|
640
643
|
if (layer) {
|
|
641
644
|
PopsInstanceUtils.removeInstance([layer], "", true);
|
|
642
645
|
}
|
|
643
646
|
} else {
|
|
644
647
|
PopsInstanceUtils.removeInstance(
|
|
645
648
|
[
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
649
|
+
PopsLayer.alert,
|
|
650
|
+
PopsLayer.confirm,
|
|
651
|
+
PopsLayer.prompt,
|
|
652
|
+
PopsLayer.iframe,
|
|
653
|
+
PopsLayer.drawer,
|
|
654
|
+
PopsLayer.folder,
|
|
655
|
+
PopsLayer.panel,
|
|
653
656
|
],
|
|
654
657
|
"",
|
|
655
658
|
true
|
|
@@ -674,6 +677,6 @@ export const PopsHandler = {
|
|
|
674
677
|
* @param value
|
|
675
678
|
*/
|
|
676
679
|
handlePush(type: PopsLayerMode, value: PopsLayerCommonConfig) {
|
|
677
|
-
|
|
680
|
+
PopsLayer[type].push(value);
|
|
678
681
|
},
|
|
679
682
|
};
|
|
@@ -205,23 +205,23 @@ export type PopsDOMUtils_EventType = keyof PopsDOMUtils_Event;
|
|
|
205
205
|
/**
|
|
206
206
|
* 元素上的events属性
|
|
207
207
|
*/
|
|
208
|
-
export interface PopsDOMUtilsEventListenerOptionsAttribute {
|
|
208
|
+
export declare interface PopsDOMUtilsEventListenerOptionsAttribute {
|
|
209
209
|
/**
|
|
210
|
-
*
|
|
210
|
+
* DOMUtils的ownCallBack,元素上的监听事件就是它,移除事件时也需要传入这个函数
|
|
211
211
|
*/
|
|
212
|
-
callback: () => void;
|
|
212
|
+
callback: (event: Event) => void;
|
|
213
213
|
/**
|
|
214
214
|
* 属性配置
|
|
215
215
|
*/
|
|
216
|
-
option:
|
|
216
|
+
option: DOMUtilsEventListenerOption;
|
|
217
217
|
/**
|
|
218
218
|
* 用户添加的事件
|
|
219
219
|
*/
|
|
220
|
-
originCallBack: () => void;
|
|
220
|
+
originCallBack: (event: Event, selectorTarget?: HTMLElement) => void;
|
|
221
221
|
/**
|
|
222
222
|
* 子元素选择器
|
|
223
223
|
*/
|
|
224
|
-
selector?: string;
|
|
224
|
+
selector?: string[];
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
export type PopsDOMUtilsElementEventType =
|
|
@@ -244,3 +244,16 @@ export type ParseHTMLReturnType<T1, T2> = T1 extends true
|
|
|
244
244
|
? Document
|
|
245
245
|
: HTMLElement
|
|
246
246
|
: HTMLElement;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 事件的额外配置
|
|
250
|
+
*/
|
|
251
|
+
export declare type PopsDOMUtilsEventListenerOption =
|
|
252
|
+
AddEventListenerOptions & {
|
|
253
|
+
/**
|
|
254
|
+
* 是否使用 event.composedPath() 来代替 event.target
|
|
255
|
+
*
|
|
256
|
+
* 一般用于设置了selector参数
|
|
257
|
+
*/
|
|
258
|
+
isComposedPath?: boolean;
|
|
259
|
+
};
|
package/src/types/button.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PopsEventDetails, PopsHandlerEventDetails } from "./event";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PopsIconType } from "./icon";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 按钮类型
|
|
@@ -79,7 +79,7 @@ export interface PopsButtonDetails<T = {}> {
|
|
|
79
79
|
/**
|
|
80
80
|
* 图标按钮,如果名字为内置的,则使用内置的,否则为自定义的svg
|
|
81
81
|
*/
|
|
82
|
-
icon:
|
|
82
|
+
icon: PopsIconType;
|
|
83
83
|
/**
|
|
84
84
|
* 图标按钮是否放在右边
|
|
85
85
|
*/
|
|
@@ -125,7 +125,7 @@ export interface PopsButtonDetailsAnyType<T = {}> {
|
|
|
125
125
|
/**
|
|
126
126
|
* 图标按钮,如果名字为内置的,则使用内置的,否则为自定义的svg
|
|
127
127
|
*/
|
|
128
|
-
icon:
|
|
128
|
+
icon: PopsIconType;
|
|
129
129
|
/**
|
|
130
130
|
* 图标按钮是否放在右边
|
|
131
131
|
*/
|