@whitesev/pops 1.5.9 → 1.6.1

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.
Files changed (62) hide show
  1. package/dist/index.amd.js +3666 -3088
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +3666 -3088
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +3666 -3088
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +3666 -3088
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +3666 -3088
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +3666 -3088
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Pops.d.ts +56 -7
  14. package/dist/types/src/components/alert/config.d.ts +2 -0
  15. package/dist/types/src/components/confirm/config.d.ts +2 -0
  16. package/dist/types/src/components/drawer/config.d.ts +2 -0
  17. package/dist/types/src/components/folder/config.d.ts +2 -0
  18. package/dist/types/src/components/iframe/config.d.ts +2 -0
  19. package/dist/types/src/components/loading/config.d.ts +2 -0
  20. package/dist/types/src/components/panel/PanelHandleContentDetails.d.ts +149 -0
  21. package/dist/types/src/components/panel/config.d.ts +2 -0
  22. package/dist/types/src/components/panel/selectMultipleType.d.ts +49 -24
  23. package/dist/types/src/components/prompt/config.d.ts +2 -0
  24. package/dist/types/src/components/rightClickMenu/config.d.ts +2 -0
  25. package/dist/types/src/components/searchSuggestion/config.d.ts +2 -0
  26. package/dist/types/src/components/searchSuggestion/indexType.d.ts +56 -32
  27. package/dist/types/src/components/tooltip/config.d.ts +2 -0
  28. package/dist/types/src/utils/PopsDOMUtils.d.ts +42 -13
  29. package/dist/types/src/utils/PopsInstanceUtils.d.ts +22 -0
  30. package/package.json +4 -1
  31. package/src/Pops.ts +8 -2
  32. package/src/components/alert/config.ts +59 -0
  33. package/src/components/alert/index.ts +2 -57
  34. package/src/components/confirm/config.ts +94 -0
  35. package/src/components/confirm/index.ts +4 -94
  36. package/src/components/drawer/config.ts +90 -0
  37. package/src/components/drawer/index.ts +2 -88
  38. package/src/components/folder/config.ts +130 -0
  39. package/src/components/folder/index.ts +3 -129
  40. package/src/components/iframe/config.ts +58 -0
  41. package/src/components/iframe/index.ts +2 -56
  42. package/src/components/loading/config.ts +27 -0
  43. package/src/components/loading/index.ts +2 -25
  44. package/src/components/panel/PanelHandleContentDetails.ts +2612 -0
  45. package/src/components/panel/config.ts +348 -0
  46. package/src/components/panel/index.css +191 -5
  47. package/src/components/panel/index.ts +10 -2475
  48. package/src/components/panel/selectMultipleType.ts +52 -25
  49. package/src/components/prompt/config.ts +102 -0
  50. package/src/components/prompt/index.ts +2 -100
  51. package/src/components/rightClickMenu/config.ts +122 -0
  52. package/src/components/rightClickMenu/index.css +78 -0
  53. package/src/components/rightClickMenu/index.ts +26 -202
  54. package/src/components/searchSuggestion/config.ts +55 -0
  55. package/src/components/searchSuggestion/index.ts +228 -205
  56. package/src/components/searchSuggestion/indexType.ts +56 -32
  57. package/src/components/tooltip/config.ts +29 -0
  58. package/src/components/tooltip/index.ts +2 -27
  59. package/src/css/animation.css +22 -0
  60. package/src/utils/PopsDOMUtils.ts +108 -29
  61. package/src/utils/PopsInstanceUtils.ts +80 -0
  62. package/src/components/searchSuggestion/index.css +0 -0
@@ -4,6 +4,7 @@ import { pops } from "../../Pops";
4
4
  import type { PopsIcon } from "../../types/icon";
5
5
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
6
6
  import { popsUtils } from "../../utils/PopsUtils";
7
+ import { rightClickMenuConfig as PopsRightClickMenuConfig } from "./config";
7
8
  import type {
8
9
  PopsRightClickMenuDataDetails,
9
10
  PopsRightClickMenuDetails,
@@ -16,123 +17,11 @@ export class PopsRightClickMenu {
16
17
  pops.config.cssText.index,
17
18
  pops.config.cssText.anim,
18
19
  pops.config.cssText.common,
20
+ pops.config.cssText.rightClickMenu,
19
21
  ]);
20
22
 
21
- let config: Required<PopsRightClickMenuDetails> = {
22
- target: document.documentElement,
23
- targetSelector: null,
24
- data: [
25
- {
26
- icon: pops.config.iconSVG.search,
27
- iconIsLoading: false,
28
- text: "搜索",
29
- callback(clickEvent, contextMenuEvent, liElement) {
30
- console.log("点击:" + this.text, [
31
- clickEvent,
32
- contextMenuEvent,
33
- liElement,
34
- ]);
35
- },
36
- },
37
- {
38
- icon: pops.config.iconSVG.documentCopy,
39
- iconIsLoading: false,
40
- text: "复制",
41
- callback(clickEvent, contextMenuEvent, liElement) {
42
- console.log("点击:" + this.text, [
43
- clickEvent,
44
- contextMenuEvent,
45
- liElement,
46
- ]);
47
- },
48
- },
49
- {
50
- icon: pops.config.iconSVG.delete,
51
- text: "删除",
52
- iconIsLoading: false,
53
- callback(clickEvent, contextMenuEvent, liElement) {
54
- console.log("点击:" + this.text, [
55
- clickEvent,
56
- contextMenuEvent,
57
- liElement,
58
- ]);
59
- },
60
- },
61
- {
62
- icon: pops.config.iconSVG.loading,
63
- iconIsLoading: true,
64
- text: "加载",
65
- callback(clickEvent, contextMenuEvent, liElement) {
66
- console.log("点击:" + this.text, [
67
- clickEvent,
68
- contextMenuEvent,
69
- liElement,
70
- ]);
71
- return false;
72
- },
73
- },
74
- {
75
- icon: pops.config.iconSVG.elemePlus,
76
- iconIsLoading: true,
77
- text: "饿了么",
78
- callback(clickEvent, contextMenuEvent, liElement) {
79
- console.log("点击:" + this.text, [
80
- clickEvent,
81
- contextMenuEvent,
82
- liElement,
83
- ]);
84
- return false;
85
- },
86
- item: [
87
- {
88
- icon: "",
89
- iconIsLoading: false,
90
- text: "处理文件",
91
- callback(clickEvent, contextMenuEvent, liElement) {
92
- console.log("点击:" + this.text, [
93
- clickEvent,
94
- contextMenuEvent,
95
- liElement,
96
- ]);
97
- },
98
- },
99
- {
100
- icon: "",
101
- iconIsLoading: false,
102
- text: "其它处理",
103
- callback(clickEvent, contextMenuEvent, liElement) {
104
- console.log("点击:" + this.text, [
105
- clickEvent,
106
- contextMenuEvent,
107
- liElement,
108
- ]);
109
- },
110
- item: [
111
- {
112
- icon: pops.config.iconSVG.view,
113
- iconIsLoading: false,
114
- text: "查看",
115
- callback(clickEvent, contextMenuEvent, liElement) {
116
- console.log("点击:" + this.text, [
117
- clickEvent,
118
- contextMenuEvent,
119
- liElement,
120
- ]);
121
- },
122
- },
123
- ],
124
- },
125
- ],
126
- },
127
- ],
128
- className: "",
129
- isAnimation: true,
130
- only: false,
131
- zIndex: 10000,
132
- preventDefault: true,
133
- style: null,
134
- beforeAppendToPageCallBack() {},
135
- };
23
+ let config: Required<PopsRightClickMenuDetails> =
24
+ PopsRightClickMenuConfig();
136
25
  config = popsUtils.assign(config, details);
137
26
  if (config.target == null) {
138
27
  throw "config.target 不能为空";
@@ -369,93 +258,20 @@ export class PopsRightClickMenu {
369
258
  * @param isChildren 是否是rightClickMenu的某一项的子菜单
370
259
  */
371
260
  getMenuContainerElement(zIndex: number, isChildren: boolean) {
372
- let menuElement = popsUtils.parseTextToDOM(/*html*/ `
373
- <div class="pops-${PopsType}" ${isChildren ? 'is-children="true"' : ""}>
374
- <style type="text/css" data-from="pops-${PopsType}">
375
- .pops-${PopsType} *{
376
- -webkit-box-sizing: border-box;
377
- box-sizing: border-box;
378
- margin: 0;
379
- padding: 0;
380
- -webkit-tap-highlight-color: transparent;
381
- scrollbar-width: thin;
382
- }
383
- .pops-${PopsType}{
384
- position: fixed;
385
- z-index: ${zIndex};
386
- text-align: center;
387
- border-radius: 3px;
388
- font-size: 16px;
389
- font-weight: 500;
390
- background: #fff;
391
- box-shadow: 0px 1px 6px 1px #cacaca;
392
- }
393
- .pops-${PopsType}-anim-grid{
394
- display: grid;
395
- transition: 0.3s;
396
- grid-template-rows: 0fr;
397
- }
398
- .pops-${PopsType}-anim-show{
399
- grid-template-rows: 1fr;
400
- }
401
- .pops-${PopsType}-is-visited{
402
- background: #dfdfdf;
403
- }
404
- i.pops-${PopsType}-icon {
405
- height: 1em;
406
- width: 1em;
407
- line-height: 1em;
408
- display: inline-flex;
409
- justify-content: center;
410
- align-items: center;
411
- position: relative;
412
- fill: currentColor;
413
- color: inherit;
414
- font-size: inherit;
415
- margin-right: 6px;
416
- }
417
- i.pops-${PopsType}-icon[is-loading="true"]{
418
- animation: rotating 2s linear infinite;
419
- }
420
- .pops-${PopsType} li:hover{background:#dfdfdf;cursor:pointer}
421
- .pops-${PopsType} ul{
422
- margin: 0;
423
- padding: 0;
424
- display: flex;
425
- flex-direction: column;
426
- align-items: flex-start;
427
- justify-content: center;
428
- overflow: hidden;
429
- }
430
- .pops-${PopsType} ul li {
431
- padding: 5px 10px;
432
- margin: 2.5px 5px;
433
- border-radius: 3px;
434
- display: flex;
435
- width: -webkit-fill-available;
436
- width: -moz-available;
437
- text-align: left;
438
- user-select: none;
439
- -webkit-user-select: none;
440
- -moz-user-select: none;
441
- -ms-user-select: none;
442
- align-items: center;
443
- }
444
- .pops-${PopsType} ul li:first-child{
445
- margin-top: 5px;
446
- }
447
- .pops-${PopsType} ul li:last-child{
448
- margin-bottom: 5px;
261
+ let $menu = popsDOMUtils.createElement("div", {
262
+ className: `pops-${PopsType}`,
263
+ innerHTML: /*html*/ `
264
+ <ul></ul>
265
+ `,
266
+ });
267
+ if (isChildren) {
268
+ $menu.setAttribute("is-children", "true");
449
269
  }
450
- </style>
451
- <ul></ul>
452
- </div>
453
- `);
454
270
  /* 添加动画 */
455
271
  if (config.isAnimation) {
456
- popsDOMUtils.addClassName(menuElement, `pops-${PopsType}-anim-grid`);
272
+ popsDOMUtils.addClassName($menu, `pops-${PopsType}-anim-grid`);
457
273
  }
458
- return menuElement;
274
+ return $menu;
459
275
  },
460
276
  /**
461
277
  * 动态获取配的z-index
@@ -470,14 +286,22 @@ export class PopsRightClickMenu {
470
286
  * @param y
471
287
  */
472
288
  getOffset(menuElement: HTMLElement, x: number, y: number) {
289
+ let menuElementWidth = popsDOMUtils.width(
290
+ menuElement,
291
+ void 0,
292
+ $shadowRoot
293
+ );
294
+ let menuElementHeight = popsDOMUtils.height(
295
+ menuElement,
296
+ void 0,
297
+ $shadowRoot
298
+ );
473
299
  /* left最大偏移 */
474
300
  let maxLeftOffset =
475
- popsDOMUtils.width(globalThis) - popsDOMUtils.width(menuElement) - 1;
301
+ popsDOMUtils.width(globalThis) - menuElementWidth - 1;
476
302
  /* top最大偏移 */
477
303
  let maxTopOffset =
478
- popsDOMUtils.height(globalThis) -
479
- popsDOMUtils.height(menuElement) -
480
- 8;
304
+ popsDOMUtils.height(globalThis) - menuElementHeight - 8;
481
305
 
482
306
  let currentLeftOffset = x;
483
307
  let currentTopOffset = y;
@@ -0,0 +1,55 @@
1
+ import type { PopsSearchSuggestionDetails } from "./indexType";
2
+
3
+ export const searchSuggestionConfig: Required<PopsSearchSuggestionDetails> = {
4
+ // @ts-ignore
5
+ target: null,
6
+ // @ts-ignore
7
+ inputTarget: null,
8
+ selfDocument: document,
9
+ data: [
10
+ {
11
+ value: "数据1",
12
+ text: "数据1-html",
13
+ },
14
+ {
15
+ value: "数据2",
16
+ text: "数据2-html",
17
+ },
18
+ ],
19
+ deleteIcon: {
20
+ enable: true,
21
+ callback(event, liElement, data) {
22
+ console.log("删除当前项", [event, liElement, data]);
23
+ liElement.remove();
24
+ },
25
+ },
26
+ className: "",
27
+ isAbsolute: true,
28
+ isAnimation: true,
29
+ width: "250px",
30
+ maxHeight: "300px",
31
+ followTargetWidth: true,
32
+ topDistance: 0,
33
+ position: "auto",
34
+ positionTopToReverse: true,
35
+ zIndex: 10000,
36
+ searchingTip: "正在搜索中...",
37
+ toSearhNotResultHTML: '<li data-none="true">暂无其它数据</li>',
38
+ toHideWithNotResult: false,
39
+ followPosition: "target",
40
+ getItemHTML(item) {
41
+ return item.text ?? item;
42
+ },
43
+ async getData(value) {
44
+ console.log("当前输入框的值是:", value);
45
+ return [];
46
+ },
47
+ itemClickCallBack(event, liElement, data) {
48
+ console.log("item项的点击回调", [event, liElement, data]);
49
+ this.inputTarget.value = data.value;
50
+ },
51
+ selectCallBack(event, liElement, data) {
52
+ console.log("item项的选中回调", [event, liElement, data]);
53
+ },
54
+ style: "",
55
+ };