@whitesev/pops 3.3.4 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +13118 -12906
- 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 +805 -593
- 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 +805 -593
- 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 +13119 -12907
- 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 +13122 -12910
- 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 +13121 -12909
- 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/Pops.d.ts +61 -46
- package/dist/types/src/PopsAnimation.d.ts +33 -0
- package/dist/types/src/PopsIcon.d.ts +1 -1
- package/dist/types/src/components/alert/index.d.ts +3 -1
- package/dist/types/src/components/confirm/index.d.ts +3 -1
- package/dist/types/src/components/drawer/index.d.ts +3 -1
- package/dist/types/src/components/folder/index.d.ts +3 -1
- package/dist/types/src/components/folder/types/index.d.ts +4 -0
- package/dist/types/src/components/iframe/index.d.ts +6 -1
- package/dist/types/src/components/iframe/types/index.d.ts +4 -2
- package/dist/types/src/components/loading/index.d.ts +3 -1
- package/dist/types/src/components/panel/handlerComponents.d.ts +4 -1
- package/dist/types/src/components/panel/index.d.ts +2 -16
- package/dist/types/src/components/panel/types/index.d.ts +7 -2
- package/dist/types/src/components/prompt/index.d.ts +3 -1
- package/dist/types/src/components/searchSuggestion/index.d.ts +4 -1
- package/dist/types/src/components/tooltip/index.d.ts +6 -2
- package/dist/types/src/config/GlobalConfig.d.ts +1 -0
- package/dist/types/src/event/EventEmiter.d.ts +33 -0
- package/dist/types/src/handler/PopsHandler.d.ts +18 -16
- package/dist/types/src/handler/PopsInstHandler.d.ts +67 -0
- package/dist/types/src/types/EventEmitter.d.ts +18 -0
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +4 -0
- package/dist/types/src/types/button.d.ts +2 -1
- package/dist/types/src/types/components.d.ts +7 -0
- package/dist/types/src/types/event.d.ts +6 -2
- package/dist/types/src/types/inst.d.ts +4 -4
- package/dist/types/src/utils/PopsDOMUtils.d.ts +0 -16
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -88
- package/dist/types/src/utils/PopsUtils.d.ts +57 -0
- package/package.json +3 -3
- package/src/Pops.ts +7 -2
- package/src/PopsAnimation.ts +126 -0
- package/src/components/alert/defaultConfig.ts +1 -0
- package/src/components/alert/index.ts +9 -9
- package/src/components/confirm/defaultConfig.ts +1 -0
- package/src/components/confirm/index.ts +9 -9
- package/src/components/drawer/defaultConfig.ts +1 -0
- package/src/components/drawer/index.ts +12 -9
- package/src/components/folder/defaultConfig.ts +1 -0
- package/src/components/folder/index.ts +9 -8
- package/src/components/folder/types/index.ts +4 -0
- package/src/components/iframe/defaultConfig.ts +1 -0
- package/src/components/iframe/index.ts +18 -12
- package/src/components/iframe/types/index.ts +10 -8
- package/src/components/loading/defaultConfig.ts +1 -0
- package/src/components/loading/index.ts +12 -6
- package/src/components/panel/defaultConfig.ts +2 -0
- package/src/components/panel/handlerComponents.ts +41 -111
- package/src/components/panel/index.ts +34 -28
- package/src/components/panel/types/index.ts +7 -2
- package/src/components/prompt/defaultConfig.ts +1 -0
- package/src/components/prompt/index.ts +9 -8
- package/src/components/rightClickMenu/index.ts +17 -14
- package/src/components/searchSuggestion/index.ts +5 -1
- package/src/components/tooltip/index.ts +20 -10
- package/src/event/EventEmiter.ts +95 -0
- package/src/handler/PopsElementHandler.ts +6 -4
- package/src/handler/PopsHandler.ts +100 -58
- package/src/handler/PopsInstHandler.ts +557 -0
- package/src/types/EventEmitter.d.ts +18 -0
- package/src/types/PopsDOMUtilsEventType.d.ts +4 -0
- package/src/types/button.d.ts +2 -1
- package/src/types/components.d.ts +7 -0
- package/src/types/event.d.ts +6 -2
- package/src/types/inst.d.ts +4 -4
- package/src/utils/PopsDOMUtils.ts +1 -40
- package/src/utils/PopsInstanceUtils.ts +19 -627
- package/src/utils/PopsUtils.ts +194 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { PopsCommonCSSClassName } from "../../config/CommonCSSClassName";
|
|
2
|
+
import type { EventEmiter } from "../../event/EventEmiter";
|
|
3
|
+
import { PopsAnimation } from "../../PopsAnimation";
|
|
2
4
|
import { PopsCSS } from "../../PopsCSS";
|
|
3
5
|
import { PopsIcon } from "../../PopsIcon";
|
|
4
6
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
5
|
-
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
6
7
|
import { PopsMathFloatUtils } from "../../utils/PopsMathUtils";
|
|
7
8
|
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
8
9
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
@@ -74,6 +75,7 @@ export const PanelHandlerComponents = () => {
|
|
|
74
75
|
nodeStoreConfigKey: "data-view-config",
|
|
75
76
|
},
|
|
76
77
|
$config: {} as Required<PopsPanelConfig>,
|
|
78
|
+
emitter: null as any as EventEmiter<PopsPanelEventType>,
|
|
77
79
|
/**
|
|
78
80
|
* 初始化
|
|
79
81
|
* @param data
|
|
@@ -91,12 +93,14 @@ export const PanelHandlerComponents = () => {
|
|
|
91
93
|
$panelBottomLeftContainer: HTMLElement;
|
|
92
94
|
$panelBottomRightContainer: HTMLElement;
|
|
93
95
|
};
|
|
96
|
+
emitter: EventEmiter<PopsPanelEventType>;
|
|
94
97
|
}) {
|
|
95
98
|
const PopsType = "panel";
|
|
96
99
|
this.$el = {
|
|
97
100
|
...data.$el,
|
|
98
101
|
};
|
|
99
102
|
this.$config = data.config;
|
|
103
|
+
this.emitter = data.emitter;
|
|
100
104
|
|
|
101
105
|
this.asideULElement = this.$el.$panelLeftAside.querySelector<HTMLUListElement>(
|
|
102
106
|
`ul.pops-${PopsType}-aside-top-container`
|
|
@@ -1022,7 +1026,8 @@ export const PanelHandlerComponents = () => {
|
|
|
1022
1026
|
$target: this.$ele.button,
|
|
1023
1027
|
content: getToolTipContent,
|
|
1024
1028
|
zIndex: () => {
|
|
1025
|
-
return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
|
|
1029
|
+
// return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
|
|
1030
|
+
return popsUtils.getMaxZIndexNodeInfoFromPoint(this.$ele.button)[0].zIndex;
|
|
1026
1031
|
},
|
|
1027
1032
|
isFixed: true,
|
|
1028
1033
|
className: "github-tooltip",
|
|
@@ -3654,104 +3659,37 @@ export const PanelHandlerComponents = () => {
|
|
|
3654
3659
|
className: "pops-panel-deepMenu-container-left-arrow-icon",
|
|
3655
3660
|
innerHTML: PopsIcon.getIcon("arrowLeft")!,
|
|
3656
3661
|
});
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
popsDOMUtils.preventEvent(event);
|
|
3672
|
-
// 返回动画
|
|
3673
|
-
const leaveViewTransition = () => {
|
|
3674
|
-
const $prev = $currentSection;
|
|
3675
|
-
popsDOMUtils.cssShow($prev);
|
|
3676
|
-
$deepMenuSection.remove();
|
|
3677
|
-
};
|
|
3678
|
-
// 返回上一层菜单
|
|
3679
|
-
if (that.$config.useDeepMenuSwtichAnimation && document.startViewTransition) {
|
|
3680
|
-
const leaveTransition = document.startViewTransition(leaveViewTransition);
|
|
3681
|
-
await leaveTransition.ready;
|
|
3682
|
-
// 向右移出
|
|
3683
|
-
await Promise.all([
|
|
3684
|
-
$deepMenuSection.animate(
|
|
3685
|
-
[
|
|
3686
|
-
{
|
|
3687
|
-
// from
|
|
3688
|
-
transform: "translateX(0)",
|
|
3689
|
-
},
|
|
3690
|
-
{
|
|
3691
|
-
// to
|
|
3692
|
-
transform: "translateX(100%)",
|
|
3693
|
-
},
|
|
3694
|
-
],
|
|
3695
|
-
animOptions
|
|
3696
|
-
).finished,
|
|
3697
|
-
// 向右移入
|
|
3698
|
-
$currentSection.animate(
|
|
3699
|
-
[
|
|
3700
|
-
{
|
|
3701
|
-
// from
|
|
3702
|
-
transform: "translateX(-100%)",
|
|
3703
|
-
},
|
|
3704
|
-
{
|
|
3705
|
-
// to
|
|
3706
|
-
transform: "translateX(0)",
|
|
3707
|
-
},
|
|
3708
|
-
],
|
|
3709
|
-
animOptions
|
|
3710
|
-
).finished,
|
|
3711
|
-
]);
|
|
3712
|
-
await leaveTransition.finished;
|
|
3713
|
-
} else {
|
|
3714
|
-
leaveViewTransition();
|
|
3662
|
+
const switchAnim = PopsAnimation.createSwitchElementWithAnimation($currentSection, $deepMenuSection, {
|
|
3663
|
+
useAnimation: that.$config.useDeepMenuSwtichAnimation,
|
|
3664
|
+
enterToAddElementCallback: () => {
|
|
3665
|
+
popsDOMUtils.on(
|
|
3666
|
+
$headerLeftArrow,
|
|
3667
|
+
"click",
|
|
3668
|
+
async (event) => {
|
|
3669
|
+
popsDOMUtils.preventEvent(event);
|
|
3670
|
+
// 返回动画
|
|
3671
|
+
await switchAnim.exit();
|
|
3672
|
+
that.emitRenderRightContainer($currentSection);
|
|
3673
|
+
},
|
|
3674
|
+
{
|
|
3675
|
+
once: true,
|
|
3715
3676
|
}
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
);
|
|
3722
|
-
popsDOMUtils.before($header.firstElementChild!, $headerLeftArrow);
|
|
3723
|
-
$deepMenuHeaderUL.appendChild($header);
|
|
3724
|
-
$deepMenuSection.appendChild($deepMenuHeaderUL);
|
|
3725
|
-
$deepMenuSection.appendChild($deepMenuMain);
|
|
3677
|
+
);
|
|
3678
|
+
popsDOMUtils.before($header.firstElementChild!, $headerLeftArrow);
|
|
3679
|
+
$deepMenuHeaderUL.appendChild($header);
|
|
3680
|
+
$deepMenuSection.appendChild($deepMenuHeaderUL);
|
|
3681
|
+
$deepMenuSection.appendChild($deepMenuMain);
|
|
3726
3682
|
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3683
|
+
if (viewConfig.views && Array.isArray(viewConfig.views)) {
|
|
3684
|
+
for (let index = 0; index < viewConfig.views.length; index++) {
|
|
3685
|
+
const formItemConfig = viewConfig.views[index];
|
|
3686
|
+
this.initContainerItem($deepMenuMain, formItemConfig);
|
|
3687
|
+
}
|
|
3731
3688
|
}
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
};
|
|
3735
|
-
|
|
3736
|
-
const transition = document.startViewTransition(enterViewTransition);
|
|
3737
|
-
await transition.ready;
|
|
3738
|
-
await $deepMenuSection.animate(
|
|
3739
|
-
[
|
|
3740
|
-
{
|
|
3741
|
-
// from
|
|
3742
|
-
transform: "translateX(100%)",
|
|
3743
|
-
},
|
|
3744
|
-
{
|
|
3745
|
-
// to
|
|
3746
|
-
transform: "translateX(0)",
|
|
3747
|
-
},
|
|
3748
|
-
],
|
|
3749
|
-
animOptions
|
|
3750
|
-
).finished;
|
|
3751
|
-
await transition.finished;
|
|
3752
|
-
} else {
|
|
3753
|
-
enterViewTransition();
|
|
3754
|
-
}
|
|
3689
|
+
that.$el.$panelRightSectionWrapper.appendChild($deepMenuSection);
|
|
3690
|
+
},
|
|
3691
|
+
});
|
|
3692
|
+
await switchAnim.enter();
|
|
3755
3693
|
if (typeof viewConfig.afterEnterDeepMenuCallBack === "function") {
|
|
3756
3694
|
viewConfig.afterEnterDeepMenuCallBack(viewConfig, {
|
|
3757
3695
|
$sectionContainer: $deepMenuSection,
|
|
@@ -3916,20 +3854,12 @@ export const PanelHandlerComponents = () => {
|
|
|
3916
3854
|
* @param $container 容器
|
|
3917
3855
|
*/
|
|
3918
3856
|
emitRenderRightContainer($container: HTMLElement) {
|
|
3919
|
-
const dataViewConfig: PopsPanelEventType["pops:renderRightContainer"]["viewConfig"] =
|
|
3920
|
-
$container,
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
<keyof PopsPanelEventType>"pops:renderRightContainer",
|
|
3926
|
-
{
|
|
3927
|
-
detail: {
|
|
3928
|
-
viewConfig: dataViewConfig,
|
|
3929
|
-
},
|
|
3930
|
-
}
|
|
3931
|
-
)
|
|
3932
|
-
);
|
|
3857
|
+
const dataViewConfig: Parameters<PopsPanelEventType["pops:renderRightContainer"]>["0"]["viewConfig"] =
|
|
3858
|
+
Reflect.get($container, this.$data.nodeStoreConfigKey);
|
|
3859
|
+
|
|
3860
|
+
this.emitter.emit("pops:renderRightContainer", {
|
|
3861
|
+
viewConfig: dataViewConfig,
|
|
3862
|
+
});
|
|
3933
3863
|
},
|
|
3934
3864
|
/**
|
|
3935
3865
|
*
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
2
|
+
import { EventEmiter } from "../../event/EventEmiter";
|
|
1
3
|
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
2
4
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
5
|
+
import { PopsInstHandler } from "../../handler/PopsInstHandler";
|
|
6
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
7
|
+
import type { PopsType } from "../../types/main";
|
|
3
8
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
4
|
-
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
5
9
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
6
|
-
import type { PopsPanelConfig, PopsPanelEventType } from "./types";
|
|
7
10
|
import { PopsPanelDefaultConfig } from "./defaultConfig";
|
|
8
11
|
import { PanelHandlerComponents } from "./handlerComponents";
|
|
9
|
-
import {
|
|
10
|
-
import { PopsCSS } from "../../PopsCSS";
|
|
11
|
-
import type { PopsType } from "../../types/main";
|
|
12
|
+
import type { PopsPanelConfig, PopsPanelEventType } from "./types";
|
|
12
13
|
|
|
13
14
|
export const PopsPanel = {
|
|
14
15
|
init(__config__: PopsPanelConfig) {
|
|
15
16
|
const guid = popsUtils.getRandomGUID();
|
|
16
17
|
// 设置当前类型
|
|
17
18
|
const popsType: PopsType = "panel";
|
|
19
|
+
const emitter = new EventEmiter<PopsPanelEventType>(popsType);
|
|
18
20
|
|
|
19
21
|
let config: Required<PopsPanelConfig> = PopsPanelDefaultConfig();
|
|
20
22
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
@@ -54,7 +56,7 @@ export const PopsPanel = {
|
|
|
54
56
|
]);
|
|
55
57
|
|
|
56
58
|
// 先把z-index提取出来
|
|
57
|
-
const zIndex = PopsHandler.
|
|
59
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
58
60
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
59
61
|
|
|
60
62
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
@@ -144,6 +146,7 @@ export const PopsPanel = {
|
|
|
144
146
|
popsType,
|
|
145
147
|
$anim,
|
|
146
148
|
$pops,
|
|
149
|
+
emitter,
|
|
147
150
|
$mask
|
|
148
151
|
);
|
|
149
152
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
@@ -152,9 +155,7 @@ export const PopsPanel = {
|
|
|
152
155
|
|
|
153
156
|
// 创建到页面中
|
|
154
157
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
155
|
-
|
|
156
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
157
|
-
}
|
|
158
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
158
159
|
popsDOMUtils.appendBody($shadowContainer);
|
|
159
160
|
// 追加遮罩层元素
|
|
160
161
|
if ($mask != null) {
|
|
@@ -177,6 +178,7 @@ export const PopsPanel = {
|
|
|
177
178
|
$panelBottomLeftContainer,
|
|
178
179
|
$panelBottomRightContainer,
|
|
179
180
|
},
|
|
181
|
+
emitter,
|
|
180
182
|
});
|
|
181
183
|
|
|
182
184
|
PopsHandler.handlePush(popsType, {
|
|
@@ -187,11 +189,11 @@ export const PopsPanel = {
|
|
|
187
189
|
$shadowContainer: $shadowContainer,
|
|
188
190
|
$shadowRoot: $shadowRoot,
|
|
189
191
|
config: config,
|
|
190
|
-
|
|
192
|
+
emitter,
|
|
191
193
|
});
|
|
192
194
|
// 拖拽
|
|
193
195
|
if (config.drag) {
|
|
194
|
-
|
|
196
|
+
PopsInstHandler.drag($pops, {
|
|
195
197
|
dragElement: $title,
|
|
196
198
|
limit: config.dragLimit,
|
|
197
199
|
extraDistance: config.dragExtraDistance,
|
|
@@ -199,23 +201,27 @@ export const PopsPanel = {
|
|
|
199
201
|
endCallBack: config.dragEndCallBack,
|
|
200
202
|
});
|
|
201
203
|
}
|
|
204
|
+
if (config.listenEscapeKeyUpToExitDeepMenu) {
|
|
205
|
+
const escapeListener = popsDOMUtils.onKeyup(
|
|
206
|
+
globalThis,
|
|
207
|
+
(evt) => {
|
|
208
|
+
if (evt.key === "Escape" && !evt.ctrlKey && !evt.shiftKey && !evt.altKey && !evt.metaKey) {
|
|
209
|
+
// Esc
|
|
210
|
+
const $exitBtn = $panelRightSectionWrapper.querySelector<HTMLLIElement>(
|
|
211
|
+
".pops-panel-deepMenu-container-left-arrow-icon"
|
|
212
|
+
);
|
|
213
|
+
if ($exitBtn) {
|
|
214
|
+
$exitBtn.click();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
{ capture: true }
|
|
219
|
+
);
|
|
220
|
+
emitter.on("pops:before-destory", () => {
|
|
221
|
+
escapeListener?.off();
|
|
222
|
+
});
|
|
223
|
+
}
|
|
202
224
|
|
|
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
|
-
};
|
|
225
|
+
return result;
|
|
220
226
|
},
|
|
221
227
|
};
|
|
@@ -36,12 +36,12 @@ export type PopsPanelEventType = {
|
|
|
36
36
|
/**
|
|
37
37
|
* 该事件在右侧容器内的元素改变时触发
|
|
38
38
|
*/
|
|
39
|
-
"pops:renderRightContainer": {
|
|
39
|
+
"pops:renderRightContainer": (data: {
|
|
40
40
|
/**
|
|
41
41
|
* 视图配置
|
|
42
42
|
*/
|
|
43
43
|
viewConfig: PopsPanelContentConfig[] | PopsPanelDeepViewConfig;
|
|
44
|
-
};
|
|
44
|
+
}) => void;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -241,4 +241,9 @@ export interface PopsPanelConfig extends PopsTitleConfig, PopsDragConfig, PopsGe
|
|
|
241
241
|
* @default true
|
|
242
242
|
*/
|
|
243
243
|
useDeepMenuSwtichAnimation?: true;
|
|
244
|
+
/**
|
|
245
|
+
* 监听按键按下Esc来退出内部菜单
|
|
246
|
+
* @default true
|
|
247
|
+
*/
|
|
248
|
+
listenEscapeKeyUpToExitDeepMenu?: boolean;
|
|
244
249
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
2
|
+
import { EventEmiter } from "../../event/EventEmiter";
|
|
2
3
|
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
3
4
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
5
|
+
import { PopsInstHandler } from "../../handler/PopsInstHandler";
|
|
4
6
|
import { PopsCSS } from "../../PopsCSS";
|
|
7
|
+
import type { EventMap } from "../../types/EventEmitter";
|
|
5
8
|
import type { PopsType } from "../../types/main";
|
|
6
9
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
7
|
-
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
8
10
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
9
11
|
import { PopsPromptDefaultConfig } from "./defaultConfig";
|
|
10
12
|
import type { PopsPromptConfig } from "./types/index";
|
|
@@ -14,6 +16,7 @@ export const PopsPrompt = {
|
|
|
14
16
|
const guid = popsUtils.getRandomGUID();
|
|
15
17
|
// 设置当前类型
|
|
16
18
|
const popsType: PopsType = "prompt";
|
|
19
|
+
const emitter = new EventEmiter<EventMap>(popsType);
|
|
17
20
|
|
|
18
21
|
let config = PopsPromptDefaultConfig();
|
|
19
22
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
@@ -53,7 +56,7 @@ export const PopsPrompt = {
|
|
|
53
56
|
]);
|
|
54
57
|
|
|
55
58
|
// 先把z-index提取出来
|
|
56
|
-
const zIndex = PopsHandler.
|
|
59
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
57
60
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
58
61
|
|
|
59
62
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
@@ -131,6 +134,7 @@ export const PopsPrompt = {
|
|
|
131
134
|
popsType,
|
|
132
135
|
$anim,
|
|
133
136
|
$pops,
|
|
137
|
+
emitter,
|
|
134
138
|
$mask
|
|
135
139
|
);
|
|
136
140
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
@@ -146,10 +150,7 @@ export const PopsPrompt = {
|
|
|
146
150
|
// 创建到页面中
|
|
147
151
|
|
|
148
152
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
149
|
-
|
|
150
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
153
154
|
popsDOMUtils.appendBody($shadowContainer);
|
|
154
155
|
if ($mask != null) {
|
|
155
156
|
$anim.after($mask);
|
|
@@ -162,11 +163,11 @@ export const PopsPrompt = {
|
|
|
162
163
|
$shadowContainer: $shadowContainer,
|
|
163
164
|
$shadowRoot: $shadowRoot,
|
|
164
165
|
config: config,
|
|
165
|
-
|
|
166
|
+
emitter,
|
|
166
167
|
});
|
|
167
168
|
// 拖拽
|
|
168
169
|
if (config.drag) {
|
|
169
|
-
|
|
170
|
+
PopsInstHandler.drag($pops!, {
|
|
170
171
|
dragElement: $title!,
|
|
171
172
|
limit: config.dragLimit,
|
|
172
173
|
extraDistance: config.dragExtraDistance,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
1
2
|
import { OriginPrototype } from "../../PopsCore";
|
|
3
|
+
import { PopsIcon } from "../../PopsIcon";
|
|
2
4
|
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
5
|
+
import { EventEmiter } from "../../event/EventEmiter";
|
|
6
|
+
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
3
7
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
8
|
+
import type { EventMap } from "../../types/EventEmitter";
|
|
9
|
+
import type { PopsType } from "../../types/main";
|
|
4
10
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
5
11
|
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
6
12
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
@@ -12,16 +18,13 @@ import type {
|
|
|
12
18
|
PopsRightClickMenuItemStoreNodeValue,
|
|
13
19
|
PopsRightClickMenuRootStoreNodeValue,
|
|
14
20
|
} from "./types";
|
|
15
|
-
import { PopsCSS } from "../../PopsCSS";
|
|
16
|
-
import { PopsIcon } from "../../PopsIcon";
|
|
17
|
-
import type { PopsType } from "../../types/main";
|
|
18
|
-
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
19
21
|
|
|
20
22
|
export const PopsRightClickMenu = {
|
|
21
23
|
init(__config__: PopsRightClickMenuConfig) {
|
|
22
24
|
const guid = popsUtils.getRandomGUID();
|
|
23
25
|
// 设置当前类型
|
|
24
26
|
const popsType: PopsType = "rightClickMenu";
|
|
27
|
+
const emitter = new EventEmiter<EventMap>(popsType);
|
|
25
28
|
|
|
26
29
|
let config = PopsRightClickMenuDefaultConfig();
|
|
27
30
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
@@ -154,13 +157,14 @@ export const PopsRightClickMenu = {
|
|
|
154
157
|
guid: guid,
|
|
155
158
|
$anim: rootElement,
|
|
156
159
|
$pops: rootElement,
|
|
157
|
-
beforeRemoveCallBack(instCommonConfig) {
|
|
158
|
-
PopsContextMenu.closeAllMenu(instCommonConfig.$pops);
|
|
159
|
-
},
|
|
160
160
|
config: config,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
emitter,
|
|
162
|
+
});
|
|
163
|
+
emitter.on("pops:before-destory", () => {
|
|
164
|
+
PopsContextMenu.closeAllMenu(rootElement);
|
|
165
|
+
});
|
|
166
|
+
emitter.on("pops:destory", () => {
|
|
167
|
+
PopsContextMenu.closeAllMenu(rootElement);
|
|
164
168
|
});
|
|
165
169
|
}
|
|
166
170
|
},
|
|
@@ -254,6 +258,7 @@ export const PopsRightClickMenu = {
|
|
|
254
258
|
);
|
|
255
259
|
const zIndex = this.getMenuZIndex();
|
|
256
260
|
if (zIndex > 10000) {
|
|
261
|
+
// 大于默认值
|
|
257
262
|
$menu.style.zIndex = zIndex.toString();
|
|
258
263
|
}
|
|
259
264
|
if (isChildren) {
|
|
@@ -274,7 +279,7 @@ export const PopsRightClickMenu = {
|
|
|
274
279
|
* 动态获取配的z-index
|
|
275
280
|
*/
|
|
276
281
|
getMenuZIndex() {
|
|
277
|
-
return PopsHandler.
|
|
282
|
+
return PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
278
283
|
},
|
|
279
284
|
/**
|
|
280
285
|
* 获取left、top偏移
|
|
@@ -395,9 +400,7 @@ export const PopsRightClickMenu = {
|
|
|
395
400
|
popsDOMUtils.append($shadowRoot, menuElement);
|
|
396
401
|
// 判断容器是否存在
|
|
397
402
|
if (!document.contains($shadowContainer)) {
|
|
398
|
-
|
|
399
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
400
|
-
}
|
|
403
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
401
404
|
popsDOMUtils.appendBody($shadowContainer);
|
|
402
405
|
}
|
|
403
406
|
this.handlerShowMenuCSS(menuElement, menuEvent);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { PopsCommonCSSClassName } from "../../config/CommonCSSClassName";
|
|
2
2
|
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
3
|
+
import { EventEmiter } from "../../event/EventEmiter";
|
|
3
4
|
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
4
5
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
5
6
|
import { PopsCSS } from "../../PopsCSS";
|
|
7
|
+
import type { EventMap } from "../../types/EventEmitter";
|
|
6
8
|
import type { PopsType } from "../../types/main";
|
|
7
9
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
8
10
|
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
@@ -15,6 +17,7 @@ export const PopsSearchSuggestion = {
|
|
|
15
17
|
const guid = popsUtils.getRandomGUID();
|
|
16
18
|
// 设置当前类型
|
|
17
19
|
const popsType: PopsType = "searchSuggestion";
|
|
20
|
+
const emitter = new EventEmiter<EventMap>(popsType);
|
|
18
21
|
|
|
19
22
|
let config = PopsSearchSuggestionDefaultConfig();
|
|
20
23
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
@@ -54,6 +57,7 @@ export const PopsSearchSuggestion = {
|
|
|
54
57
|
passive: true,
|
|
55
58
|
};
|
|
56
59
|
const SearchSuggestion = {
|
|
60
|
+
emitter: emitter,
|
|
57
61
|
/**
|
|
58
62
|
* 当前的环境,可以是document,可以是shadowroot,默认是document
|
|
59
63
|
*/
|
|
@@ -282,7 +286,7 @@ export const PopsSearchSuggestion = {
|
|
|
282
286
|
border: initial;
|
|
283
287
|
overflow: initial;
|
|
284
288
|
position: ${config.isAbsolute ? "absolute" : "fixed"};
|
|
285
|
-
z-index: ${PopsHandler.
|
|
289
|
+
z-index: ${PopsHandler.getTargerOrFunctionValue(config.zIndex)};
|
|
286
290
|
}
|
|
287
291
|
.pops-${popsType}-search-suggestion-dropdown-wrapper{
|
|
288
292
|
max-height: ${config.maxHeight};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
2
|
+
import { EventEmiter } from "../../event/EventEmiter";
|
|
2
3
|
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
3
4
|
import { PopsHandler } from "../../handler/PopsHandler";
|
|
4
5
|
import { PopsCSS } from "../../PopsCSS";
|
|
6
|
+
import type { EventMap } from "../../types/EventEmitter";
|
|
5
7
|
import type { PopsType } from "../../types/main";
|
|
6
8
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
7
9
|
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
@@ -19,6 +21,7 @@ export class ToolTip {
|
|
|
19
21
|
$content: null as unknown as HTMLElement,
|
|
20
22
|
$arrow: null as unknown as HTMLElement,
|
|
21
23
|
};
|
|
24
|
+
emitter: EventEmiter<EventMap>;
|
|
22
25
|
$data = {
|
|
23
26
|
config: null as any as Required<PopsToolTipConfig>,
|
|
24
27
|
guid: null as any as string,
|
|
@@ -31,8 +34,10 @@ export class ToolTip {
|
|
|
31
34
|
ShadowInfo: {
|
|
32
35
|
$shadowContainer: HTMLDivElement;
|
|
33
36
|
$shadowRoot: ShadowRoot | HTMLElement;
|
|
34
|
-
}
|
|
37
|
+
},
|
|
38
|
+
emitter: EventEmiter<EventMap>
|
|
35
39
|
) {
|
|
40
|
+
this.emitter = emitter;
|
|
36
41
|
this.$data.config = config;
|
|
37
42
|
this.$data.guid = guid;
|
|
38
43
|
this.$el.$shadowContainer = ShadowInfo.$shadowContainer;
|
|
@@ -85,7 +90,7 @@ export class ToolTip {
|
|
|
85
90
|
// 处理className
|
|
86
91
|
popsDOMUtils.addClassName($toolTipContainer, this.$data.config.className);
|
|
87
92
|
// 添加z-index
|
|
88
|
-
$toolTipContainer.style.zIndex = PopsHandler.
|
|
93
|
+
$toolTipContainer.style.zIndex = PopsHandler.getTargerOrFunctionValue(this.$data.config.zIndex).toString();
|
|
89
94
|
// 添加自定义style
|
|
90
95
|
PopsElementHandler.addStyle($toolTipContainer, this.$data.config.style);
|
|
91
96
|
// 添加自定义浅色style
|
|
@@ -133,7 +138,7 @@ export class ToolTip {
|
|
|
133
138
|
* 获取z-index
|
|
134
139
|
*/
|
|
135
140
|
getZIndex() {
|
|
136
|
-
const zIndex = PopsHandler.
|
|
141
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(this.$data.config.zIndex);
|
|
137
142
|
return zIndex;
|
|
138
143
|
}
|
|
139
144
|
/**
|
|
@@ -328,9 +333,7 @@ export class ToolTip {
|
|
|
328
333
|
|
|
329
334
|
if (!popsUtils.contains(this.$el.$shadowContainer)) {
|
|
330
335
|
// 页面不存在Shadow,添加
|
|
331
|
-
|
|
332
|
-
this.$data.config.beforeAppendToPageCallBack(this.$el.$shadowRoot, this.$el.$shadowContainer);
|
|
333
|
-
}
|
|
336
|
+
this.emitter.emit("pops:before-append-to-page", this.$el.$shadowRoot, this.$el.$shadowContainer);
|
|
334
337
|
popsDOMUtils.append(document.body, this.$el.$shadowContainer);
|
|
335
338
|
}
|
|
336
339
|
|
|
@@ -555,6 +558,7 @@ export const PopsTooltip = {
|
|
|
555
558
|
const guid = popsUtils.getRandomGUID();
|
|
556
559
|
// 设置当前类型
|
|
557
560
|
const popsType: PopsType = "tooltip";
|
|
561
|
+
const emitter = new EventEmiter<EventMap>(popsType);
|
|
558
562
|
|
|
559
563
|
let config = PopsTooltipDefaultConfig();
|
|
560
564
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
@@ -593,10 +597,15 @@ export const PopsTooltip = {
|
|
|
593
597
|
},
|
|
594
598
|
]);
|
|
595
599
|
|
|
596
|
-
const toolTip = new ToolTip(
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
+
const toolTip = new ToolTip(
|
|
601
|
+
config,
|
|
602
|
+
guid,
|
|
603
|
+
{
|
|
604
|
+
$shadowContainer,
|
|
605
|
+
$shadowRoot,
|
|
606
|
+
},
|
|
607
|
+
emitter
|
|
608
|
+
);
|
|
600
609
|
if (config.alwaysShow) {
|
|
601
610
|
// 总是显示
|
|
602
611
|
// 直接显示
|
|
@@ -611,6 +620,7 @@ export const PopsTooltip = {
|
|
|
611
620
|
$shadowContainer,
|
|
612
621
|
$shadowRoot,
|
|
613
622
|
toolTip,
|
|
623
|
+
emitter,
|
|
614
624
|
};
|
|
615
625
|
},
|
|
616
626
|
};
|