@whitesev/pops 2.1.7 → 2.1.9

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 (52) hide show
  1. package/dist/index.amd.js +398 -111
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +398 -111
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +398 -111
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +398 -111
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +397 -110
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +398 -111
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Pops.d.ts +1 -0
  14. package/dist/types/src/components/panel/handlerComponents.d.ts +5 -1
  15. package/dist/types/src/components/panel/types/components-button.d.ts +3 -1
  16. package/dist/types/src/components/panel/types/components-deepMenu.d.ts +3 -1
  17. package/dist/types/src/components/panel/types/components-forms.d.ts +3 -1
  18. package/dist/types/src/components/panel/types/components-input.d.ts +3 -1
  19. package/dist/types/src/components/panel/types/components-select.d.ts +3 -1
  20. package/dist/types/src/components/panel/types/components-selectMultiple.d.ts +3 -1
  21. package/dist/types/src/components/panel/types/components-slider.d.ts +3 -1
  22. package/dist/types/src/components/panel/types/components-switch.d.ts +3 -1
  23. package/dist/types/src/components/panel/types/components-textarea.d.ts +3 -1
  24. package/dist/types/src/components/panel/types/index.d.ts +44 -19
  25. package/dist/types/src/handler/PopsHandler.d.ts +6 -3
  26. package/package.json +5 -5
  27. package/src/Pops.ts +1 -1
  28. package/src/components/alert/index.ts +30 -9
  29. package/src/components/confirm/index.ts +30 -9
  30. package/src/components/drawer/index.ts +30 -9
  31. package/src/components/folder/index.ts +29 -8
  32. package/src/components/iframe/index.ts +25 -7
  33. package/src/components/loading/index.ts +3 -1
  34. package/src/components/panel/config.ts +46 -0
  35. package/src/components/panel/handlerComponents.ts +92 -33
  36. package/src/components/panel/index.css +132 -73
  37. package/src/components/panel/index.ts +33 -11
  38. package/src/components/panel/types/components-button.ts +7 -3
  39. package/src/components/panel/types/components-deepMenu.ts +7 -3
  40. package/src/components/panel/types/components-forms.ts +7 -3
  41. package/src/components/panel/types/components-input.ts +7 -3
  42. package/src/components/panel/types/components-select.ts +7 -3
  43. package/src/components/panel/types/components-selectMultiple.ts +7 -3
  44. package/src/components/panel/types/components-slider.ts +7 -3
  45. package/src/components/panel/types/components-switch.ts +7 -3
  46. package/src/components/panel/types/components-textarea.ts +7 -3
  47. package/src/components/panel/types/index.ts +59 -27
  48. package/src/components/prompt/index.ts +29 -8
  49. package/src/components/rightClickMenu/index.ts +16 -4
  50. package/src/components/searchSuggestion/index.ts +12 -3
  51. package/src/components/tooltip/index.ts +16 -4
  52. package/src/handler/PopsHandler.ts +42 -11
@@ -47,9 +47,13 @@ export interface PopsPanelSelectMultipleDetails<T = any>
47
47
  /**
48
48
  * (可选)自定义元素属性
49
49
  */
50
- attributes?: {
51
- [key: string]: any;
52
- };
50
+ attributes?:
51
+ | {
52
+ [key: string]: any;
53
+ }
54
+ | {
55
+ [key: string]: any;
56
+ }[];
53
57
  /**
54
58
  * (可选)自定义属性
55
59
  */
@@ -13,9 +13,13 @@ export interface PopsPanelSliderDetails
13
13
  /**
14
14
  * 自定义元素属性
15
15
  */
16
- attributes?: {
17
- [key: string]: any;
18
- };
16
+ attributes?:
17
+ | {
18
+ [key: string]: any;
19
+ }
20
+ | {
21
+ [key: string]: any;
22
+ }[];
19
23
  /**
20
24
  * 自定义属性
21
25
  */
@@ -12,9 +12,13 @@ export interface PopsPanelSwitchDetails
12
12
  /**
13
13
  * (可选)自定义元素属性
14
14
  */
15
- attributes?: {
16
- [key: string]: any;
17
- };
15
+ attributes?:
16
+ | {
17
+ [key: string]: any;
18
+ }
19
+ | {
20
+ [key: string]: any;
21
+ }[];
18
22
  /**
19
23
  * (可选)自定义属性
20
24
  */
@@ -12,9 +12,13 @@ export interface PopsPanelTextAreaDetails
12
12
  /**
13
13
  * (可选)自定义元素属性
14
14
  */
15
- attributes?: {
16
- [key: string]: any;
17
- };
15
+ attributes?:
16
+ | {
17
+ [key: string]: any;
18
+ }
19
+ | {
20
+ [key: string]: any;
21
+ }[];
18
22
  /**
19
23
  * (可选)自定义属性
20
24
  */
@@ -51,37 +51,52 @@ export interface PopsPanelContentConfig {
51
51
  */
52
52
  id: string;
53
53
  /**
54
- * 元素的className
54
+ * (可选)元素的className,值为空的话就不设置
55
+ * @default ""
55
56
  */
56
57
  className?: string | string[];
57
58
  /**
58
59
  * 左侧的标题,可以是html格式
59
60
  */
60
- title: string;
61
+ title: string | (() => string);
61
62
  /**
62
- * (可选)中间顶部的标题
63
+ * (可选)中间顶部的标题,如果为空,则使用title的值代替
64
+ * @default title
63
65
  */
64
- headerTitle?: string;
66
+ headerTitle?: string | (() => string);
65
67
  /**
66
- * (可选)内容高度是否自动适应(与headerTitle的高度有关)
68
+ * (可选)是否是默认的,指打开弹窗的先显示出来的内容,默认为首位第一个项,如果多个配置都设置了isDefault的值为true,那么只有第一个值生效
69
+ * @default false
67
70
  */
68
- autoAdaptionContentHeight?: string;
71
+ isDefault?: boolean | (() => boolean);
69
72
  /**
70
- * (可选)是否是默认的,指打开弹窗的先显示出来的内容
73
+ * (可选)是否是位于底部的
74
+ *
75
+ * 自上而下排序
76
+ * @default false
71
77
  */
72
- isDefault?: boolean | (() => boolean);
78
+ isBottom?: boolean | (() => boolean);
79
+ /**
80
+ * (可选)是否禁用左侧项的hover的CSS样式
81
+ */
82
+ disableAsideItemHoverCSS?: boolean | (() => boolean);
73
83
  /**
74
84
  * (可选)是否自动滚动到默认的项
85
+ * @default false
75
86
  */
76
87
  scrollToDefaultView?: boolean;
77
88
  /**
78
- * (可选)自定义元素属性
89
+ * (可选)自定义元素属性.setAttribute、.getAttribute
79
90
  */
80
- attributes?: {
81
- [key: string]: any;
82
- };
91
+ attributes?:
92
+ | {
93
+ [key: string]: any;
94
+ }
95
+ | {
96
+ [key: string]: any;
97
+ }[];
83
98
  /**
84
- * (可选)自定义属性
99
+ * (可选)自定义元素内部的属性值
85
100
  */
86
101
  props?: {
87
102
  [K in keyof HTMLElement]?: HTMLElement[K];
@@ -90,25 +105,40 @@ export interface PopsPanelContentConfig {
90
105
  * 子配置
91
106
  */
92
107
  forms: (PopsPanelFormsDetails | PopsPanelFormsTotalDetails)[];
108
+ /**
109
+ * 左侧容器的点击回调(点击后第一个触发该回调)
110
+ * @returns
111
+ * + false 阻止默认行为
112
+ */
113
+ clickFirstCallback?: (
114
+ event: MouseEvent | PointerEvent,
115
+ rightHeaderElement: HTMLUListElement,
116
+ rightContainerElement: HTMLUListElement
117
+ ) => void | boolean | Promise<void | boolean>;
93
118
  /**
94
119
  * 左侧容器的点击回调
120
+ * @returns
121
+ * + false 阻止默认进入菜单详情
95
122
  */
96
- callback?: (
123
+ clickCallback?: (
97
124
  event: MouseEvent | PointerEvent,
98
125
  rightHeaderElement: HTMLUListElement,
99
126
  rightContainerElement: HTMLUListElement
100
- ) => void;
127
+ ) => void | boolean | Promise<void | boolean>;
101
128
  /**
102
- * 左侧容器添加到panel后的回调
103
- * @param rightHeaderElement
104
- * @param rightContainerElement
129
+ * 左侧项添加到panel后的回调
105
130
  */
106
- afterRender?: (data: {
107
- /** 容器配置 */
108
- asideConfig: PopsPanelContentConfig;
109
- /** 左侧容器的元素 */
110
- $asideLiElement: HTMLLIElement;
111
- }) => void;
131
+ afterRender?: (
132
+ /**
133
+ * 配置
134
+ */
135
+ data: {
136
+ /** 容器配置 */
137
+ asideConfig: PopsPanelContentConfig;
138
+ /** 左侧容器的元素 */
139
+ $asideLiElement: HTMLLIElement;
140
+ }
141
+ ) => void;
112
142
  }
113
143
 
114
144
  /**
@@ -123,16 +153,18 @@ export interface PopsPanelDetails
123
153
  */
124
154
  content: PopsPanelContentConfig[];
125
155
  /**
126
- * 按钮配置
156
+ * 右上角的按钮配置
127
157
  */
128
158
  btn?: {
129
159
  /**
130
- * 右上角的关闭按钮
160
+ * 关闭按钮
131
161
  */
132
162
  close?: PopsHeaderCloseButtonDetails;
133
163
  };
134
164
  /**
135
- * 移动端适配的的className,默认为pops-panel-is-mobile
165
+ * 移动端适配的的className
166
+ *
167
+ * @default "pops-panel-is-mobile"
136
168
  */
137
169
  mobileClassName?: string;
138
170
  /**
@@ -21,13 +21,34 @@ export const PopsPrompt = {
21
21
 
22
22
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
23
23
  PopsHandler.handleInit($shadowRoot, [
24
- PopsCSS.index,
25
- PopsCSS.ninePalaceGridPosition,
26
- PopsCSS.scrollbar,
27
- PopsCSS.button,
28
- PopsCSS.anim,
29
- PopsCSS.common,
30
- PopsCSS.promptCSS,
24
+ {
25
+ name: "index",
26
+ css: PopsCSS.index,
27
+ },
28
+ {
29
+ name: "ninePalaceGridPosition",
30
+ css: PopsCSS.ninePalaceGridPosition,
31
+ },
32
+ {
33
+ name: "scrollbar",
34
+ css: PopsCSS.scrollbar,
35
+ },
36
+ {
37
+ name: "button",
38
+ css: PopsCSS.button,
39
+ },
40
+ {
41
+ name: "anim",
42
+ css: PopsCSS.anim,
43
+ },
44
+ {
45
+ name: "common",
46
+ css: PopsCSS.common,
47
+ },
48
+ {
49
+ name: "promptCSS",
50
+ css: PopsCSS.promptCSS,
51
+ },
31
52
  ]);
32
53
 
33
54
  // 先把z-index提取出来
@@ -54,7 +75,7 @@ export const PopsPrompt = {
54
75
  };${headerStyle}">${
55
76
  config.title.html
56
77
  ? config.title.text
57
- : `<p pops style="${headerPStyle}">${config.title.text}</p>`
78
+ : `<p pops class="pops-${PopsType}-title-text" style="${headerPStyle}">${config.title.text}</p>`
58
79
  }${headerBtnHTML}</div>
59
80
  <div class="pops-content pops-${PopsType}-content" style="${contentPStyle}">${
60
81
  config.content.row
@@ -31,10 +31,22 @@ export const PopsRightClickMenu = {
31
31
  }
32
32
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
33
33
  PopsHandler.handleInit($shadowRoot, [
34
- PopsCSS.index,
35
- PopsCSS.anim,
36
- PopsCSS.common,
37
- PopsCSS.rightClickMenu,
34
+ {
35
+ name: "index",
36
+ css: PopsCSS.index,
37
+ },
38
+ {
39
+ name: "anim",
40
+ css: PopsCSS.anim,
41
+ },
42
+ {
43
+ name: "common",
44
+ css: PopsCSS.common,
45
+ },
46
+ {
47
+ name: "rightClickMenu",
48
+ css: PopsCSS.rightClickMenu,
49
+ },
38
50
  ]);
39
51
 
40
52
  if (config.style != null) {
@@ -29,9 +29,18 @@ export const PopsSearchSuggestion = {
29
29
 
30
30
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
31
31
  PopsHandler.handleInit($shadowRoot, [
32
- PopsCSS.index,
33
- PopsCSS.anim,
34
- PopsCSS.common,
32
+ {
33
+ name: "index",
34
+ css: PopsCSS.index,
35
+ },
36
+ {
37
+ name: "anim",
38
+ css: PopsCSS.anim,
39
+ },
40
+ {
41
+ name: "common",
42
+ css: PopsCSS.common,
43
+ },
35
44
  ]);
36
45
 
37
46
  if (config.style != null) {
@@ -613,10 +613,22 @@ export const PopsTooltip = {
613
613
 
614
614
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
615
615
  PopsHandler.handleInit($shadowRoot, [
616
- PopsCSS.index,
617
- PopsCSS.anim,
618
- PopsCSS.common,
619
- PopsCSS.tooltipCSS,
616
+ {
617
+ name: "index",
618
+ css: PopsCSS.index,
619
+ },
620
+ {
621
+ name: "anim",
622
+ css: PopsCSS.anim,
623
+ },
624
+ {
625
+ name: "common",
626
+ css: PopsCSS.common,
627
+ },
628
+ {
629
+ name: "tooltipCSS",
630
+ css: PopsCSS.tooltipCSS,
631
+ },
620
632
  ]);
621
633
 
622
634
  let toolTip = new ToolTip(config, guid, {
@@ -44,32 +44,63 @@ export const PopsHandler = {
44
44
  },
45
45
  /**
46
46
  * 处理初始化
47
- * @param $shadowRoot 所在的shadowRoot
48
- * @param cssText 添加进ShadowRoot的CSS
47
+ * @param $styleParent style元素的父元素
48
+ * @param css 添加进ShadowRoot的CSS
49
49
  */
50
50
  handleInit(
51
- $shadowRoot?: ShadowRoot | HTMLElement,
52
- cssText?: string | string[]
51
+ $styleParent?: ShadowRoot | HTMLElement,
52
+ css?:
53
+ | string
54
+ | string[]
55
+ | {
56
+ name?: string;
57
+ css: string;
58
+ }[]
53
59
  ) {
54
60
  PopsAnimation.init();
55
61
  if (!arguments.length) {
56
62
  return;
57
63
  }
58
- if (Array.isArray(cssText)) {
59
- for (let index = 0; index < cssText.length; index++) {
60
- this.handleInit($shadowRoot, cssText[index]);
64
+ if ($styleParent == null) {
65
+ return;
66
+ }
67
+ if (css == null) {
68
+ return;
69
+ }
70
+
71
+ if (typeof css === "string") {
72
+ if (css.trim() === "") {
73
+ return;
61
74
  }
75
+ css = [
76
+ {
77
+ css: css,
78
+ },
79
+ ];
62
80
  } else {
81
+ css = css.map((item) => {
82
+ if (typeof item === "string") {
83
+ return {
84
+ css: item,
85
+ };
86
+ } else {
87
+ return item;
88
+ }
89
+ });
90
+ }
91
+ for (const cssItem of css) {
63
92
  let $css = popsDOMUtils.createElement(
64
93
  "style",
65
- {
66
- innerHTML: cssText,
67
- },
94
+ {},
68
95
  {
69
96
  "data-type": "PopsHandler.handleInit",
70
97
  }
71
98
  );
72
- $shadowRoot!.appendChild($css);
99
+ $css.textContent = cssItem.css;
100
+ if (typeof cssItem.name === "string") {
101
+ $css.setAttribute("data-name", cssItem.name);
102
+ }
103
+ $styleParent.appendChild($css);
73
104
  }
74
105
  },
75
106
  /**