@whitesev/pops 3.3.5 → 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 -12932
- 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 +761 -575
- 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 +761 -575
- 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 -12933
- 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 -12936
- 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 -12935
- 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 +66 -52
- 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/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 +5 -1
- package/dist/types/src/event/EventEmiter.d.ts +33 -0
- package/dist/types/src/handler/PopsHandler.d.ts +16 -11
- 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/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/index.ts +9 -9
- package/src/components/confirm/index.ts +9 -9
- package/src/components/drawer/index.ts +12 -9
- package/src/components/folder/index.ts +9 -8
- package/src/components/iframe/index.ts +18 -12
- package/src/components/iframe/types/index.ts +10 -8
- package/src/components/loading/index.ts +12 -6
- package/src/components/panel/defaultConfig.ts +1 -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/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 +66 -48
- 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/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,10 @@
|
|
|
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";
|
|
5
6
|
import type { PopsHandlerEventConfig } from "../../types/event";
|
|
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 { popsUtils } from "../../utils/PopsUtils";
|
|
@@ -14,12 +16,12 @@ export const PopsDrawer = {
|
|
|
14
16
|
const guid = popsUtils.getRandomGUID();
|
|
15
17
|
// 设置当前类型
|
|
16
18
|
const popsType: PopsType = "drawer";
|
|
19
|
+
const emitter = new EventEmiter<EventMap>(popsType);
|
|
17
20
|
|
|
18
21
|
let config = PopsDrawerDefaultConfig();
|
|
19
22
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
20
23
|
config = popsUtils.assign(config, __config__);
|
|
21
24
|
config = PopsHandler.handleOnly(popsType, config);
|
|
22
|
-
|
|
23
25
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
24
26
|
PopsHandler.handleInit($shadowRoot, [
|
|
25
27
|
{
|
|
@@ -53,7 +55,7 @@ export const PopsDrawer = {
|
|
|
53
55
|
]);
|
|
54
56
|
|
|
55
57
|
// 先把z-index提取出来
|
|
56
|
-
const zIndex = PopsHandler.
|
|
58
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
57
59
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
58
60
|
|
|
59
61
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
@@ -126,6 +128,7 @@ export const PopsDrawer = {
|
|
|
126
128
|
popsType,
|
|
127
129
|
$anim,
|
|
128
130
|
$pops,
|
|
131
|
+
emitter,
|
|
129
132
|
$mask
|
|
130
133
|
);
|
|
131
134
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
@@ -155,13 +158,16 @@ export const PopsDrawer = {
|
|
|
155
158
|
|
|
156
159
|
// 按下Esc键触发关闭
|
|
157
160
|
if (config.closeOnPressEscape) {
|
|
158
|
-
PopsHandler.handleKeyboardEvent("Escape", [], function () {
|
|
161
|
+
const listener = PopsHandler.handleKeyboardEvent("Escape", [], function () {
|
|
159
162
|
evtConfig.close();
|
|
160
163
|
});
|
|
164
|
+
emitter.on("pops:destory", () => {
|
|
165
|
+
listener.off();
|
|
166
|
+
});
|
|
161
167
|
}
|
|
162
168
|
// 待处理的点击事件列表
|
|
163
169
|
const needHandleClickEventList: {
|
|
164
|
-
type: PopsHandlerEventConfig["type"];
|
|
170
|
+
type: PopsHandlerEventConfig<typeof emitter>["type"];
|
|
165
171
|
ele: HTMLElement;
|
|
166
172
|
}[] = [
|
|
167
173
|
{
|
|
@@ -215,10 +221,7 @@ export const PopsDrawer = {
|
|
|
215
221
|
// 创建到页面中
|
|
216
222
|
|
|
217
223
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
218
|
-
|
|
219
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
220
|
-
}
|
|
221
|
-
|
|
224
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
222
225
|
popsDOMUtils.appendBody($shadowContainer);
|
|
223
226
|
popsUtils.setTimeout(() => {
|
|
224
227
|
popsUtils.setTimeout(() => {
|
|
@@ -238,7 +241,7 @@ export const PopsDrawer = {
|
|
|
238
241
|
$shadowContainer: $shadowContainer,
|
|
239
242
|
$shadowRoot: $shadowRoot,
|
|
240
243
|
config: config,
|
|
241
|
-
|
|
244
|
+
emitter: emitter,
|
|
242
245
|
});
|
|
243
246
|
return result;
|
|
244
247
|
},
|
|
@@ -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 { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
9
11
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
10
12
|
import { PopsLoading } from "../loading";
|
|
@@ -17,6 +19,7 @@ export const PopsFolder = {
|
|
|
17
19
|
const guid = popsUtils.getRandomGUID();
|
|
18
20
|
// 设置当前类型
|
|
19
21
|
const popsType: PopsType = "folder";
|
|
22
|
+
const emitter = new EventEmiter<EventMap>(popsType);
|
|
20
23
|
|
|
21
24
|
let config = PopsFolderDefaultConfig();
|
|
22
25
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
@@ -110,7 +113,7 @@ export const PopsFolder = {
|
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
// 先把z-index提取出来
|
|
113
|
-
const zIndex = PopsHandler.
|
|
116
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
114
117
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
115
118
|
|
|
116
119
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
@@ -278,6 +281,7 @@ export const PopsFolder = {
|
|
|
278
281
|
popsType,
|
|
279
282
|
$anim,
|
|
280
283
|
$pops,
|
|
284
|
+
emitter,
|
|
281
285
|
$mask
|
|
282
286
|
);
|
|
283
287
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
@@ -288,10 +292,7 @@ export const PopsFolder = {
|
|
|
288
292
|
// 创建到页面中
|
|
289
293
|
|
|
290
294
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
291
|
-
|
|
292
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
295
296
|
popsDOMUtils.appendBody($shadowContainer);
|
|
296
297
|
if ($mask != null) {
|
|
297
298
|
$anim.after($mask);
|
|
@@ -955,7 +956,7 @@ export const PopsFolder = {
|
|
|
955
956
|
Reflect.set($pops, "data-pops-folder", popsFolder);
|
|
956
957
|
// 拖拽
|
|
957
958
|
if (config.drag) {
|
|
958
|
-
|
|
959
|
+
PopsInstHandler.drag($pops, {
|
|
959
960
|
dragElement: $title,
|
|
960
961
|
limit: config.dragLimit,
|
|
961
962
|
extraDistance: config.dragExtraDistance,
|
|
@@ -971,7 +972,7 @@ export const PopsFolder = {
|
|
|
971
972
|
$shadowContainer: $shadowContainer,
|
|
972
973
|
$shadowRoot: $shadowRoot,
|
|
973
974
|
config: config,
|
|
974
|
-
|
|
975
|
+
emitter,
|
|
975
976
|
});
|
|
976
977
|
return result;
|
|
977
978
|
},
|
|
@@ -1,11 +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";
|
|
5
7
|
import { PopsInstData } from "../../PopsInst";
|
|
6
8
|
import type { PopsType } from "../../types/main";
|
|
7
9
|
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
8
|
-
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
9
10
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
10
11
|
import { PopsIframeDefaultConfig } from "./defaultConfig";
|
|
11
12
|
import type { PopsIframeClickEventConfig, PopsIframeConfig } from "./types";
|
|
@@ -15,7 +16,11 @@ export const PopsIframe = {
|
|
|
15
16
|
const guid = popsUtils.getRandomGUID();
|
|
16
17
|
// 设置当前类型
|
|
17
18
|
const popsType: PopsType = "iframe";
|
|
18
|
-
|
|
19
|
+
const emitter = new EventEmiter<{
|
|
20
|
+
"pops:iframe-min": (eventConfig: PopsIframeClickEventConfig, event: MouseEvent | PointerEvent) => void;
|
|
21
|
+
"pops:iframe-mise": (eventConfig: PopsIframeClickEventConfig, event: MouseEvent | PointerEvent) => void;
|
|
22
|
+
"pops:iframe-max": (eventConfig: PopsIframeClickEventConfig, event: MouseEvent | PointerEvent) => void;
|
|
23
|
+
}>(popsType);
|
|
19
24
|
let config = PopsIframeDefaultConfig();
|
|
20
25
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
21
26
|
config = popsUtils.assign(config, __config__);
|
|
@@ -55,7 +60,7 @@ export const PopsIframe = {
|
|
|
55
60
|
const maskExtraStyle = config.animation != null && <string>config.animation != "" ? "position:absolute;" : "";
|
|
56
61
|
|
|
57
62
|
// 先把z-index提取出来
|
|
58
|
-
const zIndex = PopsHandler.
|
|
63
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
59
64
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
|
|
60
65
|
|
|
61
66
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
@@ -140,10 +145,11 @@ export const PopsIframe = {
|
|
|
140
145
|
popsType,
|
|
141
146
|
$anim,
|
|
142
147
|
$pops,
|
|
148
|
+
emitter,
|
|
143
149
|
$mask
|
|
144
|
-
) as PopsIframeClickEventConfig
|
|
150
|
+
) as PopsIframeClickEventConfig<typeof emitter>;
|
|
145
151
|
// 赋值额外的$iframe参数
|
|
146
|
-
evtConfig.$iframe = $iframe
|
|
152
|
+
evtConfig.$iframe = $iframe;
|
|
147
153
|
|
|
148
154
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
149
155
|
|
|
@@ -172,17 +178,14 @@ export const PopsIframe = {
|
|
|
172
178
|
// 创建到页面中
|
|
173
179
|
|
|
174
180
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
175
|
-
|
|
176
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
177
|
-
}
|
|
178
|
-
|
|
181
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
179
182
|
$iframeContainer.appendChild($shadowContainer);
|
|
180
183
|
if ($mask != null) {
|
|
181
184
|
$anim.after($mask);
|
|
182
185
|
}
|
|
183
186
|
// 拖拽
|
|
184
187
|
if (config.drag) {
|
|
185
|
-
|
|
188
|
+
PopsInstHandler.drag($pops!, {
|
|
186
189
|
dragElement: $title!,
|
|
187
190
|
limit: config.dragLimit,
|
|
188
191
|
extraDistance: config.dragExtraDistance,
|
|
@@ -217,6 +220,7 @@ export const PopsIframe = {
|
|
|
217
220
|
if (typeof config?.btn?.min?.callback === "function") {
|
|
218
221
|
config.btn.min.callback(evtConfig, event);
|
|
219
222
|
}
|
|
223
|
+
emitter.emit("pops:iframe-min", evtConfig, event);
|
|
220
224
|
},
|
|
221
225
|
{
|
|
222
226
|
capture: true,
|
|
@@ -251,6 +255,7 @@ export const PopsIframe = {
|
|
|
251
255
|
if (typeof config?.btn?.max?.callback === "function") {
|
|
252
256
|
config.btn.max.callback(evtConfig, event);
|
|
253
257
|
}
|
|
258
|
+
emitter.emit("pops:iframe-max", evtConfig, event);
|
|
254
259
|
},
|
|
255
260
|
{
|
|
256
261
|
capture: true,
|
|
@@ -293,6 +298,7 @@ export const PopsIframe = {
|
|
|
293
298
|
if (typeof config?.btn?.mise?.callback === "function") {
|
|
294
299
|
config.btn.mise.callback(evtConfig, event);
|
|
295
300
|
}
|
|
301
|
+
emitter.emit("pops:iframe-mise", evtConfig, event);
|
|
296
302
|
},
|
|
297
303
|
{
|
|
298
304
|
capture: true,
|
|
@@ -305,7 +311,7 @@ export const PopsIframe = {
|
|
|
305
311
|
async (event) => {
|
|
306
312
|
event.preventDefault();
|
|
307
313
|
event.stopPropagation();
|
|
308
|
-
await
|
|
314
|
+
await PopsInstHandler.removeInstance([PopsInstData.iframe], guid, false);
|
|
309
315
|
if (typeof config?.btn?.close?.callback === "function") {
|
|
310
316
|
config.btn.close.callback(evtConfig, event);
|
|
311
317
|
}
|
|
@@ -323,7 +329,7 @@ export const PopsIframe = {
|
|
|
323
329
|
$shadowContainer: $shadowContainer,
|
|
324
330
|
$shadowRoot: $shadowRoot,
|
|
325
331
|
config: config,
|
|
326
|
-
|
|
332
|
+
emitter,
|
|
327
333
|
});
|
|
328
334
|
return result;
|
|
329
335
|
},
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { EventEmiter } from "../../../event/EventEmiter";
|
|
2
|
+
import type { PopsDragConfig, PopsGeneralConfig, PopsTitleConfig } from "../../../types/components";
|
|
3
3
|
import type { PopsEventConfig } from "../../../types/event";
|
|
4
|
+
import type { CustomEventMap } from "../../../types/EventEmitter";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* pops.iframe的按钮点击事件回调的配置参数
|
|
7
8
|
*/
|
|
8
|
-
export type PopsIframeClickEventConfig =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export type PopsIframeClickEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>> =
|
|
10
|
+
PopsEventConfig<E> & {
|
|
11
|
+
/**
|
|
12
|
+
* iframe元素
|
|
13
|
+
*/
|
|
14
|
+
$iframe: HTMLIFrameElement;
|
|
15
|
+
};
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* pops.iframe
|
|
@@ -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 { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
6
8
|
import { popsUtils } from "../../utils/PopsUtils";
|
|
7
9
|
import { PopsLoadingDefaultConfig } from "./defaultConfig";
|
|
@@ -12,14 +14,15 @@ export const PopsLoading = {
|
|
|
12
14
|
const guid = popsUtils.getRandomGUID();
|
|
13
15
|
// 设置当前类型
|
|
14
16
|
const PopsType = "loading";
|
|
17
|
+
const emitter = new EventEmiter<EventMap>(PopsType);
|
|
18
|
+
|
|
15
19
|
let config = PopsLoadingDefaultConfig();
|
|
16
20
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
17
21
|
config = popsUtils.assign(config, __config__);
|
|
18
|
-
|
|
19
22
|
config = PopsHandler.handleOnly(PopsType, config);
|
|
20
23
|
|
|
21
24
|
// 先把z-index提取出来
|
|
22
|
-
const zIndex = PopsHandler.
|
|
25
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
23
26
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
24
27
|
|
|
25
28
|
const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
|
|
@@ -76,17 +79,20 @@ export const PopsLoading = {
|
|
|
76
79
|
$mask = handleMask.maskElement;
|
|
77
80
|
$elList.push($mask);
|
|
78
81
|
}
|
|
79
|
-
const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, $mask);
|
|
82
|
+
const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
|
|
80
83
|
popsDOMUtils.append(config.$parent, $elList);
|
|
81
84
|
if ($mask != null) {
|
|
82
85
|
$anim.after($mask);
|
|
83
86
|
}
|
|
84
|
-
// @ts-ignore
|
|
85
87
|
PopsHandler.handlePush(PopsType, {
|
|
88
|
+
$shadowContainer: $pops,
|
|
89
|
+
$shadowRoot: $pops,
|
|
86
90
|
guid: guid,
|
|
87
91
|
$anim: $anim,
|
|
88
|
-
$pops: $pops
|
|
89
|
-
$mask: $mask
|
|
92
|
+
$pops: $pops,
|
|
93
|
+
$mask: $mask,
|
|
94
|
+
emitter: emitter,
|
|
95
|
+
config: config,
|
|
90
96
|
});
|
|
91
97
|
|
|
92
98
|
if (config.isAbsolute) {
|
|
@@ -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
|
};
|