@whitesev/pops 2.6.0 → 3.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 +1233 -1092
- 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 +1233 -1092
- 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 +1233 -1092
- 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 +1233 -1092
- 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 +1233 -1092
- 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 +1233 -1092
- 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/eslint.config.d.mts +2 -0
- package/dist/types/src/Pops.d.ts +98 -103
- package/dist/types/src/PopsInst.d.ts +2 -2
- package/dist/types/src/components/alert/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/alert/index.d.ts +2 -2
- package/dist/types/src/components/alert/types/index.d.ts +4 -4
- package/dist/types/src/components/confirm/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/confirm/index.d.ts +2 -2
- package/dist/types/src/components/confirm/types/index.d.ts +2 -2
- package/dist/types/src/components/drawer/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/drawer/index.d.ts +2 -2
- package/dist/types/src/components/drawer/types/index.d.ts +2 -2
- package/dist/types/src/components/folder/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/folder/index.d.ts +2 -2
- package/dist/types/src/components/folder/types/index.d.ts +31 -7
- package/dist/types/src/components/iframe/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/iframe/index.d.ts +2 -5
- package/dist/types/src/components/iframe/types/index.d.ts +13 -42
- package/dist/types/src/components/loading/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/loading/index.d.ts +2 -2
- package/dist/types/src/components/loading/types/index.d.ts +4 -4
- package/dist/types/src/components/panel/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/panel/handlerComponents.d.ts +47 -43
- package/dist/types/src/components/panel/index.d.ts +3 -3
- package/dist/types/src/components/panel/types/components-button.d.ts +7 -6
- package/dist/types/src/components/panel/types/components-common.d.ts +7 -7
- package/dist/types/src/components/panel/types/components-container.d.ts +24 -0
- package/dist/types/src/components/panel/types/components-deepMenu.d.ts +13 -13
- package/dist/types/src/components/panel/types/components-input.d.ts +6 -6
- package/dist/types/src/components/panel/types/components-own.d.ts +2 -2
- package/dist/types/src/components/panel/types/components-select.d.ts +9 -9
- package/dist/types/src/components/panel/types/components-selectMultiple.d.ts +8 -8
- package/dist/types/src/components/panel/types/components-slider.d.ts +7 -7
- package/dist/types/src/components/panel/types/components-switch.d.ts +6 -6
- package/dist/types/src/components/panel/types/components-textarea.d.ts +6 -6
- package/dist/types/src/components/panel/types/index.d.ts +36 -28
- package/dist/types/src/components/prompt/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/prompt/index.d.ts +2 -2
- package/dist/types/src/components/prompt/types/index.d.ts +4 -3
- package/dist/types/src/components/rightClickMenu/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/rightClickMenu/index.d.ts +29 -27
- package/dist/types/src/components/rightClickMenu/types/index.d.ts +32 -11
- package/dist/types/src/components/searchSuggestion/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/searchSuggestion/index.d.ts +21 -6
- package/dist/types/src/components/searchSuggestion/types/index.d.ts +15 -13
- package/dist/types/src/components/tooltip/defaultConfig.d.ts +2 -0
- package/dist/types/src/components/tooltip/index.d.ts +6 -21
- package/dist/types/src/components/tooltip/types/index.d.ts +8 -6
- package/dist/types/src/config/GlobalConfig.d.ts +3 -3
- package/dist/types/src/handler/PopsElementHandler.d.ts +6 -6
- package/dist/types/src/handler/PopsHandler.d.ts +18 -18
- package/dist/types/src/types/button.d.ts +4 -97
- package/dist/types/src/types/components.d.ts +8 -8
- package/dist/types/src/types/event.d.ts +0 -30
- package/dist/types/src/types/global.d.ts +2 -0
- package/dist/types/src/types/inst.d.ts +5 -5
- package/dist/types/src/types/main.d.ts +35 -80
- package/dist/types/src/types/mask.d.ts +18 -15
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +15 -15
- package/dist/types/src/utils/PopsUtils.d.ts +4 -0
- package/package.json +10 -10
- package/src/Pops.ts +44 -44
- package/src/PopsAnimation.ts +1 -1
- package/src/PopsInst.ts +2 -2
- package/src/components/alert/{config.ts → defaultConfig.ts} +7 -7
- package/src/components/alert/index.ts +16 -18
- package/src/components/alert/types/index.ts +4 -4
- package/src/components/confirm/{config.ts → defaultConfig.ts} +11 -11
- package/src/components/confirm/index.ts +11 -13
- package/src/components/confirm/types/index.ts +3 -3
- package/src/components/drawer/{config.ts → defaultConfig.ts} +10 -10
- package/src/components/drawer/index.ts +18 -17
- package/src/components/drawer/types/index.ts +3 -3
- package/src/components/folder/{config.ts → defaultConfig.ts} +22 -18
- package/src/components/folder/index.ts +61 -60
- package/src/components/folder/types/index.ts +31 -18
- package/src/components/iframe/{config.ts → defaultConfig.ts} +2 -2
- package/src/components/iframe/index.ts +24 -29
- package/src/components/iframe/types/index.ts +13 -56
- package/src/components/loading/{config.ts → defaultConfig.ts} +3 -3
- package/src/components/loading/index.ts +13 -11
- package/src/components/loading/types/index.ts +5 -5
- package/src/components/panel/{config.ts → defaultConfig.ts} +115 -37
- package/src/components/panel/handlerComponents.ts +446 -428
- package/src/components/panel/index.css +11 -3
- package/src/components/panel/index.ts +15 -28
- package/src/components/panel/types/components-button.ts +7 -6
- package/src/components/panel/types/components-common.ts +7 -7
- package/src/components/panel/types/components-container.ts +25 -0
- package/src/components/panel/types/components-deepMenu.ts +13 -13
- package/src/components/panel/types/components-input.ts +6 -6
- package/src/components/panel/types/components-own.ts +2 -2
- package/src/components/panel/types/components-select.ts +11 -11
- package/src/components/panel/types/components-selectMultiple.ts +8 -9
- package/src/components/panel/types/components-slider.ts +7 -7
- package/src/components/panel/types/components-switch.ts +6 -6
- package/src/components/panel/types/components-textarea.ts +6 -6
- package/src/components/panel/types/index.ts +45 -38
- package/src/components/prompt/{config.ts → defaultConfig.ts} +10 -10
- package/src/components/prompt/index.ts +13 -15
- package/src/components/prompt/types/index.ts +4 -3
- package/src/components/rightClickMenu/{config.ts → defaultConfig.ts} +20 -19
- package/src/components/rightClickMenu/index.ts +125 -108
- package/src/components/rightClickMenu/types/index.ts +36 -14
- package/src/components/searchSuggestion/{config.ts → defaultConfig.ts} +18 -11
- package/src/components/searchSuggestion/index.ts +116 -96
- package/src/components/searchSuggestion/types/index.ts +17 -15
- package/src/components/tooltip/{config.ts → defaultConfig.ts} +5 -6
- package/src/components/tooltip/index.ts +21 -21
- package/src/components/tooltip/types/index.ts +9 -7
- package/src/config/GlobalConfig.ts +2 -2
- package/src/css/common.css +6 -0
- package/src/handler/PopsElementHandler.ts +29 -30
- package/src/handler/PopsHandler.ts +43 -43
- package/src/svg/cpu.svg +7 -7
- package/src/svg/delete.svg +4 -4
- package/src/svg/documentCopy.svg +4 -4
- package/src/svg/edit.svg +7 -7
- package/src/svg/eleme.svg +4 -4
- package/src/svg/elemePlus.svg +4 -4
- package/src/svg/headset.svg +4 -4
- package/src/svg/hide.svg +7 -7
- package/src/svg/keyboard.svg +7 -7
- package/src/svg/loading.svg +4 -4
- package/src/svg/max.svg +4 -4
- package/src/svg/min.svg +2 -4
- package/src/svg/mise.svg +4 -4
- package/src/svg/monitor.svg +4 -4
- package/src/svg/next.svg +4 -4
- package/src/svg/picture.svg +7 -7
- package/src/svg/prev.svg +4 -4
- package/src/svg/search.svg +4 -4
- package/src/svg/share.svg +4 -4
- package/src/svg/upload.svg +4 -4
- package/src/svg/videoPause.svg +4 -4
- package/src/svg/videoPlay.svg +4 -4
- package/src/svg/view.svg +4 -4
- package/src/types/button.d.ts +4 -97
- package/src/types/components.d.ts +8 -8
- package/src/types/event.d.ts +0 -30
- package/src/types/global.d.ts +2 -0
- package/src/types/inst.d.ts +5 -5
- package/src/types/main.d.ts +35 -80
- package/src/types/mask.d.ts +18 -15
- package/src/utils/PopsDOMUtils.ts +34 -34
- package/src/utils/PopsInstanceUtils.ts +129 -139
- package/src/utils/PopsUtils.ts +60 -45
- package/dist/types/src/components/alert/config.d.ts +0 -2
- package/dist/types/src/components/confirm/config.d.ts +0 -2
- package/dist/types/src/components/drawer/config.d.ts +0 -2
- package/dist/types/src/components/folder/config.d.ts +0 -2
- package/dist/types/src/components/iframe/config.d.ts +0 -2
- package/dist/types/src/components/loading/config.d.ts +0 -2
- package/dist/types/src/components/panel/config.d.ts +0 -2
- package/dist/types/src/components/panel/types/components-forms.d.ts +0 -23
- package/dist/types/src/components/prompt/config.d.ts +0 -2
- package/dist/types/src/components/rightClickMenu/config.d.ts +0 -2
- package/dist/types/src/components/searchSuggestion/config.d.ts +0 -2
- package/dist/types/src/components/tooltip/config.d.ts +0 -2
- package/src/components/panel/types/components-forms.ts +0 -24
|
@@ -7,28 +7,28 @@ import { popsUtils } from "../../utils/PopsUtils";
|
|
|
7
7
|
import { PopsAlert } from "../alert";
|
|
8
8
|
import { PopsTooltip } from "../tooltip";
|
|
9
9
|
import { PopsCommonCSSClassName } from "../../config/CommonCSSClassName";
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
10
|
+
import type { PopsAlertConfig } from "../alert/types";
|
|
11
|
+
import type { PopsPanelButtonConfig } from "./types/components-button";
|
|
12
|
+
import type { PopsPanelGeneralConfig, PopsPanelRightAsideContainerConfig } from "./types/components-common";
|
|
13
|
+
import type { PopsPanelDeepViewConfig } from "./types/components-deepMenu";
|
|
14
|
+
import type { PopsPanelContainerConfig } from "./types/components-container";
|
|
15
15
|
import type {
|
|
16
16
|
PopsPanelBottomContentConfig,
|
|
17
17
|
PopsPanelContentConfig,
|
|
18
|
-
|
|
18
|
+
PopsPanelConfig,
|
|
19
19
|
PopsPanelEventType,
|
|
20
|
-
|
|
20
|
+
PopsPanelViewConfig,
|
|
21
21
|
} from "./types";
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
22
|
+
import type { PopsPanelInputConfig } from "./types/components-input";
|
|
23
|
+
import type { PopsPanelOwnConfig } from "./types/components-own";
|
|
24
24
|
import type {
|
|
25
25
|
PopsPanelSelectMultipleDataOption,
|
|
26
|
-
|
|
26
|
+
PopsPanelSelectMultipleConfig,
|
|
27
27
|
} from "./types/components-selectMultiple";
|
|
28
|
-
import type {
|
|
29
|
-
import type {
|
|
30
|
-
import type {
|
|
31
|
-
import type {
|
|
28
|
+
import type { PopsPanelSelectConfig } from "./types/components-select";
|
|
29
|
+
import type { PopsPanelSliderConfig } from "./types/components-slider";
|
|
30
|
+
import type { PopsPanelSwitchConfig } from "./types/components-switch";
|
|
31
|
+
import type { PopsPanelTextAreaConfig } from "./types/components-textarea";
|
|
32
32
|
/**
|
|
33
33
|
* 处理组件(把组件配置转为组件元素)
|
|
34
34
|
*/
|
|
@@ -69,13 +69,16 @@ export const PanelHandlerComponents = () => {
|
|
|
69
69
|
$panelBottomLeftContainer: null as any as HTMLElement,
|
|
70
70
|
$panelBottomRightContainer: null as any as HTMLElement,
|
|
71
71
|
},
|
|
72
|
-
$
|
|
72
|
+
$data: {
|
|
73
|
+
nodeStoreConfigKey: "data-view-config",
|
|
74
|
+
},
|
|
75
|
+
$config: {} as Required<PopsPanelConfig>,
|
|
73
76
|
/**
|
|
74
77
|
* 初始化
|
|
75
|
-
* @param
|
|
78
|
+
* @param data
|
|
76
79
|
*/
|
|
77
|
-
init(
|
|
78
|
-
config: Required<
|
|
80
|
+
init(data: {
|
|
81
|
+
config: Required<PopsPanelConfig>;
|
|
79
82
|
$el: {
|
|
80
83
|
$pops: HTMLElement;
|
|
81
84
|
$content: HTMLElement;
|
|
@@ -90,9 +93,9 @@ export const PanelHandlerComponents = () => {
|
|
|
90
93
|
}) {
|
|
91
94
|
const PopsType = "panel";
|
|
92
95
|
this.$el = {
|
|
93
|
-
...
|
|
96
|
+
...data.$el,
|
|
94
97
|
};
|
|
95
|
-
this.$config =
|
|
98
|
+
this.$config = data.config;
|
|
96
99
|
|
|
97
100
|
this.asideULElement = this.$el.$panelLeftAside.querySelector<HTMLUListElement>(
|
|
98
101
|
`ul.pops-${PopsType}-aside-top-container`
|
|
@@ -113,7 +116,7 @@ export const PanelHandlerComponents = () => {
|
|
|
113
116
|
/** 是否滚动到默认位置(第一个项) */
|
|
114
117
|
let isScrollToDefaultView = false;
|
|
115
118
|
// 初始化内容配置
|
|
116
|
-
|
|
119
|
+
data.config.content.forEach((asideItemConfig) => {
|
|
117
120
|
const $asideLiElement = this.createAsideItem(asideItemConfig);
|
|
118
121
|
this.setAsideItemClickEvent($asideLiElement, asideItemConfig);
|
|
119
122
|
// 是否处于底部
|
|
@@ -145,7 +148,7 @@ export const PanelHandlerComponents = () => {
|
|
|
145
148
|
}
|
|
146
149
|
});
|
|
147
150
|
// 初始化底部内容配置
|
|
148
|
-
(
|
|
151
|
+
(data.config?.bottomContentConfig || []).forEach((bottomItemConfig) => {
|
|
149
152
|
const $bottomLiElement = this.createBottomItem(bottomItemConfig);
|
|
150
153
|
this.setBottomItemClickEvent($bottomLiElement, bottomItemConfig);
|
|
151
154
|
if (bottomItemConfig.position === "left" || bottomItemConfig.position == null) {
|
|
@@ -166,13 +169,13 @@ export const PanelHandlerComponents = () => {
|
|
|
166
169
|
}
|
|
167
170
|
});
|
|
168
171
|
|
|
169
|
-
|
|
172
|
+
// 点击左侧列表
|
|
170
173
|
if ($defaultAsideItem == null && this.asideULElement.children.length) {
|
|
171
|
-
|
|
174
|
+
// 默认第一个
|
|
172
175
|
$defaultAsideItem = <HTMLLIElement>this.asideULElement.children[0];
|
|
173
176
|
}
|
|
174
177
|
if ($defaultAsideItem) {
|
|
175
|
-
|
|
178
|
+
// 点击选择的那一项
|
|
176
179
|
$defaultAsideItem.click();
|
|
177
180
|
if (isScrollToDefaultView) {
|
|
178
181
|
$defaultAsideItem?.scrollIntoView();
|
|
@@ -185,7 +188,7 @@ export const PanelHandlerComponents = () => {
|
|
|
185
188
|
* 清空container容器的元素
|
|
186
189
|
*/
|
|
187
190
|
clearContainer() {
|
|
188
|
-
Reflect.deleteProperty(this.$el.$panelContentSectionContainer,
|
|
191
|
+
Reflect.deleteProperty(this.$el.$panelContentSectionContainer, this.$data.nodeStoreConfigKey);
|
|
189
192
|
PopsSafeUtils.setSafeHTML(this.sectionContainerHeaderULElement, "");
|
|
190
193
|
PopsSafeUtils.setSafeHTML(this.sectionContainerULElement, "");
|
|
191
194
|
this.clearDeepMenuContainer();
|
|
@@ -255,7 +258,7 @@ export const PanelHandlerComponents = () => {
|
|
|
255
258
|
* @param $el 元素
|
|
256
259
|
* @param className
|
|
257
260
|
*/
|
|
258
|
-
setElementClassName($el: HTMLElement, className?:
|
|
261
|
+
setElementClassName($el: HTMLElement, className?: PopsPanelGeneralConfig<any>["className"]) {
|
|
259
262
|
popsDOMUtils.addClassName($el, className);
|
|
260
263
|
},
|
|
261
264
|
/**
|
|
@@ -272,9 +275,9 @@ export const PanelHandlerComponents = () => {
|
|
|
272
275
|
className: ["pops-panel-bottom-item", "pops-user-select-none", className].join(" "),
|
|
273
276
|
innerHTML: text,
|
|
274
277
|
});
|
|
275
|
-
|
|
278
|
+
// 处理attr
|
|
276
279
|
this.setElementAttributes($li, bottomItemConfig.attributes);
|
|
277
|
-
|
|
280
|
+
// 处理props
|
|
278
281
|
this.setElementProps($li, bottomItemConfig.props);
|
|
279
282
|
/** 禁用左侧项的hover的CSS样式的类名 */
|
|
280
283
|
const disablHoverCSSClassName = "pops-panel-disable-bottom-item-hover-css";
|
|
@@ -298,7 +301,7 @@ export const PanelHandlerComponents = () => {
|
|
|
298
301
|
setBottomItemClickEvent($bottomItem: HTMLElement, bottomItemConfig: PopsPanelBottomContentConfig) {
|
|
299
302
|
popsDOMUtils.on<MouseEvent | PointerEvent>($bottomItem, "click", async (event) => {
|
|
300
303
|
if (typeof bottomItemConfig.clickCallback === "function") {
|
|
301
|
-
|
|
304
|
+
// 执行回调
|
|
302
305
|
const asideClickCallbackResult = await bottomItemConfig.clickCallback(event);
|
|
303
306
|
if (typeof asideClickCallbackResult === "boolean" && !asideClickCallbackResult) {
|
|
304
307
|
return;
|
|
@@ -317,13 +320,13 @@ export const PanelHandlerComponents = () => {
|
|
|
317
320
|
id: asideConfig.id,
|
|
318
321
|
innerHTML: text,
|
|
319
322
|
});
|
|
320
|
-
Reflect.set($li, "__forms__", asideConfig.
|
|
321
|
-
|
|
323
|
+
Reflect.set($li, "__forms__", asideConfig.views);
|
|
324
|
+
// 处理className
|
|
322
325
|
this.setElementClassName($li, "pops-panel-aside-item");
|
|
323
326
|
this.setElementClassName($li, asideConfig.className);
|
|
324
|
-
|
|
327
|
+
// 处理attr
|
|
325
328
|
this.setElementAttributes($li, asideConfig.attributes);
|
|
326
|
-
|
|
329
|
+
// 处理props
|
|
327
330
|
this.setElementProps($li, asideConfig.props);
|
|
328
331
|
/** 禁用左侧项的hover的CSS样式的类名 */
|
|
329
332
|
const disablHoverCSSClassName = "pops-panel-disabled-aside-hover-css";
|
|
@@ -342,24 +345,24 @@ export const PanelHandlerComponents = () => {
|
|
|
342
345
|
/**
|
|
343
346
|
* type ==> switch
|
|
344
347
|
* 创建中间容器的元素<li>
|
|
345
|
-
* @param
|
|
348
|
+
* @param viewConfig
|
|
346
349
|
*/
|
|
347
|
-
createSectionContainerItem_switch(
|
|
350
|
+
createSectionContainerItem_switch(viewConfig: PopsPanelSwitchConfig) {
|
|
348
351
|
const $li = popsDOMUtils.createElement("li");
|
|
349
|
-
Reflect.set($li,
|
|
350
|
-
this.setElementClassName($li,
|
|
351
|
-
this.setElementAttributes($li,
|
|
352
|
-
this.setElementProps($li,
|
|
353
|
-
|
|
352
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
353
|
+
this.setElementClassName($li, viewConfig.className);
|
|
354
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
355
|
+
this.setElementProps($li, viewConfig.props);
|
|
356
|
+
// 左边底部的描述的文字
|
|
354
357
|
let leftDescriptionText = "";
|
|
355
|
-
if (
|
|
356
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
358
|
+
if (viewConfig.description) {
|
|
359
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
357
360
|
}
|
|
358
361
|
PopsSafeUtils.setSafeHTML(
|
|
359
362
|
$li,
|
|
360
363
|
/*html*/ `
|
|
361
364
|
<div class="pops-panel-item-left-text">
|
|
362
|
-
<p class="pops-panel-item-left-main-text">${
|
|
365
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
363
366
|
<div class="pops-panel-switch">
|
|
364
367
|
<input class="pops-panel-switch__input" type="checkbox">
|
|
365
368
|
<span class="pops-panel-switch__core">
|
|
@@ -371,7 +374,7 @@ export const PanelHandlerComponents = () => {
|
|
|
371
374
|
const PopsPanelSwitch = {
|
|
372
375
|
[Symbol.toStringTag]: "PopsPanelSwitch",
|
|
373
376
|
$data: {
|
|
374
|
-
value: Boolean(
|
|
377
|
+
value: Boolean(viewConfig.getValue()),
|
|
375
378
|
},
|
|
376
379
|
$ele: {
|
|
377
380
|
itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
|
|
@@ -381,7 +384,7 @@ export const PanelHandlerComponents = () => {
|
|
|
381
384
|
},
|
|
382
385
|
init() {
|
|
383
386
|
this.setStatus(this.$data.value);
|
|
384
|
-
const disabled = typeof
|
|
387
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
385
388
|
if (disabled) {
|
|
386
389
|
this.disable();
|
|
387
390
|
}
|
|
@@ -398,8 +401,8 @@ export const PanelHandlerComponents = () => {
|
|
|
398
401
|
}
|
|
399
402
|
that.$data.value = that.getStatus();
|
|
400
403
|
that.setStatus(that.$data.value);
|
|
401
|
-
if (typeof
|
|
402
|
-
|
|
404
|
+
if (typeof viewConfig.callback === "function") {
|
|
405
|
+
viewConfig.callback(event, that.$data.value);
|
|
403
406
|
}
|
|
404
407
|
});
|
|
405
408
|
},
|
|
@@ -450,47 +453,47 @@ export const PanelHandlerComponents = () => {
|
|
|
450
453
|
/**
|
|
451
454
|
* type ==> slider
|
|
452
455
|
* 获取中间容器的元素<li>
|
|
453
|
-
* @param
|
|
456
|
+
* @param viewConfig
|
|
454
457
|
*/
|
|
455
|
-
createSectionContainerItem_slider(
|
|
458
|
+
createSectionContainerItem_slider(viewConfig: PopsPanelSliderConfig) {
|
|
456
459
|
const $li = popsDOMUtils.createElement("li");
|
|
457
|
-
Reflect.set($li,
|
|
458
|
-
this.setElementClassName($li,
|
|
459
|
-
this.setElementAttributes($li,
|
|
460
|
-
this.setElementProps($li,
|
|
461
|
-
|
|
460
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
461
|
+
this.setElementClassName($li, viewConfig.className);
|
|
462
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
463
|
+
this.setElementProps($li, viewConfig.props);
|
|
464
|
+
// 左边底部的描述的文字
|
|
462
465
|
let leftDescriptionText = "";
|
|
463
|
-
if (
|
|
464
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${
|
|
466
|
+
if (viewConfig.description) {
|
|
467
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
465
468
|
}
|
|
466
469
|
PopsSafeUtils.setSafeHTML(
|
|
467
470
|
$li,
|
|
468
471
|
/*html*/ `
|
|
469
472
|
<div class="pops-panel-item-left-text">
|
|
470
|
-
<p class="pops-panel-item-left-main-text">${
|
|
473
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
471
474
|
<div class="pops-panel-slider">
|
|
472
|
-
<input type="range" min="${
|
|
475
|
+
<input type="range" min="${viewConfig.min}" max="${viewConfig.max}">
|
|
473
476
|
</div>
|
|
474
477
|
`
|
|
475
478
|
);
|
|
476
479
|
const $rangeInput = $li.querySelector<HTMLInputElement>(".pops-panel-slider input[type=range]")!;
|
|
477
|
-
if (
|
|
478
|
-
$rangeInput.setAttribute("step",
|
|
480
|
+
if (viewConfig.step) {
|
|
481
|
+
$rangeInput.setAttribute("step", viewConfig.step.toString());
|
|
479
482
|
}
|
|
480
|
-
$rangeInput.value =
|
|
483
|
+
$rangeInput.value = viewConfig.getValue().toString();
|
|
481
484
|
/**
|
|
482
485
|
* 获取提示的内容
|
|
483
486
|
* @param value
|
|
484
487
|
*/
|
|
485
488
|
const getToolTipContent = function (value: number | string) {
|
|
486
|
-
if (typeof
|
|
487
|
-
return
|
|
489
|
+
if (typeof viewConfig.getToolTipContent === "function") {
|
|
490
|
+
return viewConfig.getToolTipContent(value as number);
|
|
488
491
|
} else {
|
|
489
492
|
return value as string;
|
|
490
493
|
}
|
|
491
494
|
};
|
|
492
495
|
const tooltip = PopsTooltip.init({
|
|
493
|
-
target: $rangeInput.parentElement!,
|
|
496
|
+
$target: $rangeInput.parentElement!,
|
|
494
497
|
content: () => {
|
|
495
498
|
return getToolTipContent($rangeInput.value);
|
|
496
499
|
},
|
|
@@ -505,8 +508,8 @@ export const PanelHandlerComponents = () => {
|
|
|
505
508
|
});
|
|
506
509
|
popsDOMUtils.on<InputEvent>($rangeInput, ["input", "propertychange"], void 0, function (event) {
|
|
507
510
|
tooltip.toolTip.changeContent(getToolTipContent($rangeInput.value));
|
|
508
|
-
if (typeof
|
|
509
|
-
|
|
511
|
+
if (typeof viewConfig.callback === "function") {
|
|
512
|
+
viewConfig.callback(event, $rangeInput.valueAsNumber);
|
|
510
513
|
}
|
|
511
514
|
});
|
|
512
515
|
return $li;
|
|
@@ -514,24 +517,24 @@ export const PanelHandlerComponents = () => {
|
|
|
514
517
|
/**
|
|
515
518
|
* type ==> slider
|
|
516
519
|
* 获取中间容器的元素<li>
|
|
517
|
-
* @param
|
|
520
|
+
* @param viewConfig
|
|
518
521
|
*/
|
|
519
|
-
createSectionContainerItem_slider_new(
|
|
522
|
+
createSectionContainerItem_slider_new(viewConfig: PopsPanelSliderConfig) {
|
|
520
523
|
const $li = popsDOMUtils.createElement("li");
|
|
521
|
-
Reflect.set($li,
|
|
522
|
-
this.setElementClassName($li,
|
|
523
|
-
this.setElementAttributes($li,
|
|
524
|
-
this.setElementProps($li,
|
|
525
|
-
|
|
524
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
525
|
+
this.setElementClassName($li, viewConfig.className);
|
|
526
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
527
|
+
this.setElementProps($li, viewConfig.props);
|
|
528
|
+
// 左边底部的描述的文字
|
|
526
529
|
let leftDescriptionText = "";
|
|
527
|
-
if (
|
|
528
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
530
|
+
if (viewConfig.description) {
|
|
531
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
529
532
|
}
|
|
530
533
|
PopsSafeUtils.setSafeHTML(
|
|
531
534
|
$li,
|
|
532
535
|
/*html*/ `
|
|
533
536
|
<div class="pops-panel-item-left-text" style="flex: 1;">
|
|
534
|
-
<p class="pops-panel-item-left-main-text">${
|
|
537
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
535
538
|
<div class="pops-slider pops-slider-width">
|
|
536
539
|
<div class="pops-slider__runway">
|
|
537
540
|
<div class="pops-slider__bar" style="width: 0%; left: 0%"></div>
|
|
@@ -546,19 +549,19 @@ export const PanelHandlerComponents = () => {
|
|
|
546
549
|
/**
|
|
547
550
|
* 值
|
|
548
551
|
*/
|
|
549
|
-
value:
|
|
552
|
+
value: viewConfig.getValue(),
|
|
550
553
|
/**
|
|
551
554
|
* 最小值
|
|
552
555
|
*/
|
|
553
|
-
min:
|
|
556
|
+
min: viewConfig.min,
|
|
554
557
|
/**
|
|
555
558
|
* 最大值
|
|
556
559
|
*/
|
|
557
|
-
max:
|
|
560
|
+
max: viewConfig.max,
|
|
558
561
|
/**
|
|
559
562
|
* 间隔
|
|
560
563
|
*/
|
|
561
|
-
step:
|
|
564
|
+
step: viewConfig.step || 1,
|
|
562
565
|
$data: {
|
|
563
566
|
/**
|
|
564
567
|
* 是否正在移动
|
|
@@ -630,7 +633,7 @@ export const PanelHandlerComponents = () => {
|
|
|
630
633
|
this.setPanEvent();
|
|
631
634
|
this.setRunAwayClickEvent();
|
|
632
635
|
this.intervalInit();
|
|
633
|
-
if (this.
|
|
636
|
+
if (this.isDisabledDragWithConfig()) {
|
|
634
637
|
this.disableDrag();
|
|
635
638
|
}
|
|
636
639
|
},
|
|
@@ -658,7 +661,7 @@ export const PanelHandlerComponents = () => {
|
|
|
658
661
|
if (this.$data.totalWidth !== 0) {
|
|
659
662
|
isSuccess = true;
|
|
660
663
|
if (this.$data.totalWidth !== oldTotalWidth) {
|
|
661
|
-
|
|
664
|
+
// slider的总宽度改变了
|
|
662
665
|
if (PopsMathFloatUtils.isFloat(this.step)) {
|
|
663
666
|
this.initFloatStepMap();
|
|
664
667
|
} else {
|
|
@@ -669,7 +672,7 @@ export const PanelHandlerComponents = () => {
|
|
|
669
672
|
}
|
|
670
673
|
}
|
|
671
674
|
}, checkStepTime);
|
|
672
|
-
|
|
675
|
+
// 最长检测时间是10s
|
|
673
676
|
timer = setTimeout(() => {
|
|
674
677
|
clearInterval(interval);
|
|
675
678
|
}, maxTime);
|
|
@@ -707,7 +710,7 @@ export const PanelHandlerComponents = () => {
|
|
|
707
710
|
const value = this.formatValue(stepValue);
|
|
708
711
|
let info;
|
|
709
712
|
if (value === this.min) {
|
|
710
|
-
|
|
713
|
+
// 起始
|
|
711
714
|
info = {
|
|
712
715
|
value: value,
|
|
713
716
|
px: 0,
|
|
@@ -753,7 +756,7 @@ export const PanelHandlerComponents = () => {
|
|
|
753
756
|
const value = this.formatValue(stepValue);
|
|
754
757
|
let info;
|
|
755
758
|
if (value === this.min) {
|
|
756
|
-
|
|
759
|
+
// 起始
|
|
757
760
|
info = {
|
|
758
761
|
value: value,
|
|
759
762
|
px: 0,
|
|
@@ -785,10 +788,10 @@ export const PanelHandlerComponents = () => {
|
|
|
785
788
|
* 初始化slider的默认起始left的百分比值
|
|
786
789
|
*/
|
|
787
790
|
initSliderPosition() {
|
|
788
|
-
|
|
791
|
+
// 设置起始默认style的left值
|
|
789
792
|
let percent = 0;
|
|
790
793
|
for (const [, stepBlockInfo] of this.$data.stepBlockMap.entries()) {
|
|
791
|
-
|
|
794
|
+
// 判断值是否和区域内的值相等
|
|
792
795
|
if (stepBlockInfo.value == this.value) {
|
|
793
796
|
percent = stepBlockInfo.percent;
|
|
794
797
|
this.$data.dragWidth = stepBlockInfo.px;
|
|
@@ -811,8 +814,8 @@ export const PanelHandlerComponents = () => {
|
|
|
811
814
|
* @param value
|
|
812
815
|
*/
|
|
813
816
|
valueChangeCallBack(event: any, value: number) {
|
|
814
|
-
if (typeof
|
|
815
|
-
|
|
817
|
+
if (typeof viewConfig.callback === "function") {
|
|
818
|
+
viewConfig.callback(event, value);
|
|
816
819
|
}
|
|
817
820
|
},
|
|
818
821
|
/**
|
|
@@ -859,9 +862,9 @@ export const PanelHandlerComponents = () => {
|
|
|
859
862
|
if (percent > 1) {
|
|
860
863
|
percent = percent / 100;
|
|
861
864
|
}
|
|
862
|
-
|
|
865
|
+
// 滑块按钮的偏移
|
|
863
866
|
this.$ele.buttonWrapper.style.left = `${percent * 100}%`;
|
|
864
|
-
|
|
867
|
+
// 滑块进度的宽度
|
|
865
868
|
this.$ele.bar.style.width = `${percent * 100}%`;
|
|
866
869
|
},
|
|
867
870
|
/**
|
|
@@ -887,8 +890,8 @@ export const PanelHandlerComponents = () => {
|
|
|
887
890
|
/**
|
|
888
891
|
* 判断当前滑块是否被禁用(配置中判断)
|
|
889
892
|
*/
|
|
890
|
-
|
|
891
|
-
const isDisabled = typeof
|
|
893
|
+
isDisabledDragWithConfig() {
|
|
894
|
+
const isDisabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
892
895
|
if (typeof isDisabled === "boolean") {
|
|
893
896
|
return isDisabled;
|
|
894
897
|
} else {
|
|
@@ -923,7 +926,7 @@ export const PanelHandlerComponents = () => {
|
|
|
923
926
|
* 拖拽开始的回调,如果返回false,禁止拖拽
|
|
924
927
|
*/
|
|
925
928
|
dragStartCallBack() {
|
|
926
|
-
if (this.
|
|
929
|
+
if (this.isDisabledDragWithConfig()) {
|
|
927
930
|
// 禁止
|
|
928
931
|
this.disableDrag();
|
|
929
932
|
return false;
|
|
@@ -993,7 +996,7 @@ export const PanelHandlerComponents = () => {
|
|
|
993
996
|
* 当前的拖拽的距离px
|
|
994
997
|
*/
|
|
995
998
|
let currentDragX = 0;
|
|
996
|
-
|
|
999
|
+
// 监听拖拽
|
|
997
1000
|
this.$tooltip.on("at:move", (event) => {
|
|
998
1001
|
if (!this.dragStartCallBack()) {
|
|
999
1002
|
return;
|
|
@@ -1007,10 +1010,10 @@ export const PanelHandlerComponents = () => {
|
|
|
1007
1010
|
displacementX = runAwayRect.width;
|
|
1008
1011
|
}
|
|
1009
1012
|
currentDragX = displacementX;
|
|
1010
|
-
|
|
1013
|
+
// 拖拽移动
|
|
1011
1014
|
this.dragMoveCallBack(event, currentDragX, oldValue);
|
|
1012
1015
|
});
|
|
1013
|
-
|
|
1016
|
+
// 监听触点离开,处理某些情况下,拖拽松开,但是未触发pan事件,可以通过设置这个来关闭tooltip
|
|
1014
1017
|
this.$tooltip.on("at:end", () => {
|
|
1015
1018
|
this.dragEndCallBack(currentDragX);
|
|
1016
1019
|
});
|
|
@@ -1055,15 +1058,15 @@ export const PanelHandlerComponents = () => {
|
|
|
1055
1058
|
* 获取提示的内容
|
|
1056
1059
|
*/
|
|
1057
1060
|
function getToolTipContent() {
|
|
1058
|
-
if (typeof
|
|
1059
|
-
return
|
|
1061
|
+
if (typeof viewConfig.getToolTipContent === "function") {
|
|
1062
|
+
return viewConfig.getToolTipContent(PopsPanelSlider.value);
|
|
1060
1063
|
} else {
|
|
1061
1064
|
return PopsPanelSlider.value.toString();
|
|
1062
1065
|
}
|
|
1063
1066
|
}
|
|
1064
1067
|
|
|
1065
1068
|
const tooltip = PopsTooltip.init({
|
|
1066
|
-
target: this.$ele.button,
|
|
1069
|
+
$target: this.$ele.button,
|
|
1067
1070
|
content: getToolTipContent,
|
|
1068
1071
|
zIndex: () => {
|
|
1069
1072
|
return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
|
|
@@ -1077,10 +1080,10 @@ export const PanelHandlerComponents = () => {
|
|
|
1077
1080
|
},
|
|
1078
1081
|
showBeforeCallBack: () => {
|
|
1079
1082
|
const isShowHoverTip =
|
|
1080
|
-
typeof
|
|
1081
|
-
?
|
|
1082
|
-
: typeof
|
|
1083
|
-
?
|
|
1083
|
+
typeof viewConfig.isShowHoverTip === "function"
|
|
1084
|
+
? viewConfig.isShowHoverTip()
|
|
1085
|
+
: typeof viewConfig.isShowHoverTip === "boolean"
|
|
1086
|
+
? viewConfig.isShowHoverTip
|
|
1084
1087
|
: true;
|
|
1085
1088
|
if (!isShowHoverTip) {
|
|
1086
1089
|
return false;
|
|
@@ -1110,32 +1113,32 @@ export const PanelHandlerComponents = () => {
|
|
|
1110
1113
|
/**
|
|
1111
1114
|
* type ==> input
|
|
1112
1115
|
* 获取中间容器的元素<li>
|
|
1113
|
-
* @param
|
|
1116
|
+
* @param viewConfig
|
|
1114
1117
|
*/
|
|
1115
|
-
createSectionContainerItem_input(
|
|
1118
|
+
createSectionContainerItem_input(viewConfig: PopsPanelInputConfig) {
|
|
1116
1119
|
const $li = popsDOMUtils.createElement("li");
|
|
1117
|
-
Reflect.set($li,
|
|
1118
|
-
this.setElementClassName($li,
|
|
1119
|
-
this.setElementAttributes($li,
|
|
1120
|
-
this.setElementProps($li,
|
|
1120
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
1121
|
+
this.setElementClassName($li, viewConfig.className);
|
|
1122
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
1123
|
+
this.setElementProps($li, viewConfig.props);
|
|
1121
1124
|
let inputType = "text";
|
|
1122
|
-
if (
|
|
1125
|
+
if (viewConfig.isPassword) {
|
|
1123
1126
|
inputType = "password";
|
|
1124
|
-
} else if (
|
|
1127
|
+
} else if (viewConfig.isNumber) {
|
|
1125
1128
|
inputType = "number";
|
|
1126
1129
|
}
|
|
1127
|
-
|
|
1130
|
+
// 左边底部的描述的文字
|
|
1128
1131
|
let leftDescriptionText = "";
|
|
1129
|
-
if (
|
|
1130
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${
|
|
1132
|
+
if (viewConfig.description) {
|
|
1133
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
1131
1134
|
}
|
|
1132
1135
|
PopsSafeUtils.setSafeHTML(
|
|
1133
1136
|
$li,
|
|
1134
1137
|
/*html*/ `
|
|
1135
1138
|
<div class="pops-panel-item-left-text">
|
|
1136
|
-
<p class="pops-panel-item-left-main-text">${
|
|
1139
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
1137
1140
|
<div class="pops-panel-input">
|
|
1138
|
-
<input type="${inputType}" placeholder="${
|
|
1141
|
+
<input type="${inputType}" placeholder="${viewConfig.placeholder ?? ""}">
|
|
1139
1142
|
</div>
|
|
1140
1143
|
`
|
|
1141
1144
|
);
|
|
@@ -1150,18 +1153,18 @@ export const PanelHandlerComponents = () => {
|
|
|
1150
1153
|
icon: null as any as HTMLElement,
|
|
1151
1154
|
},
|
|
1152
1155
|
$data: {
|
|
1153
|
-
value:
|
|
1156
|
+
value: viewConfig.getValue(),
|
|
1154
1157
|
isView: false,
|
|
1155
1158
|
},
|
|
1156
1159
|
init() {
|
|
1157
1160
|
this.initEle();
|
|
1158
1161
|
this.setInputValue(this.$data.value);
|
|
1159
|
-
|
|
1160
|
-
if (
|
|
1162
|
+
// 如果是密码框,放进图标
|
|
1163
|
+
if (viewConfig.isPassword) {
|
|
1161
1164
|
this.setCircleIcon(PopsIcon.getIcon("view")!);
|
|
1162
1165
|
this.setCircleIconClickEvent();
|
|
1163
1166
|
} else {
|
|
1164
|
-
|
|
1167
|
+
// 先判断预设值是否为空,不为空添加清空图标按钮
|
|
1165
1168
|
if (this.$ele.input.value != "") {
|
|
1166
1169
|
this.setCircleIcon(PopsIcon.getIcon("circleClose")!);
|
|
1167
1170
|
this.setCircleIconClickEvent();
|
|
@@ -1170,12 +1173,12 @@ export const PanelHandlerComponents = () => {
|
|
|
1170
1173
|
|
|
1171
1174
|
this.setInputChangeEvent();
|
|
1172
1175
|
// 是否禁用复选框
|
|
1173
|
-
const disabled = typeof
|
|
1176
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
1174
1177
|
if (disabled) {
|
|
1175
1178
|
this.disable();
|
|
1176
1179
|
}
|
|
1177
|
-
if (typeof
|
|
1178
|
-
|
|
1180
|
+
if (typeof viewConfig.handlerCallBack === "function") {
|
|
1181
|
+
viewConfig.handlerCallBack($li, this.$ele.input);
|
|
1179
1182
|
}
|
|
1180
1183
|
},
|
|
1181
1184
|
/**
|
|
@@ -1183,7 +1186,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1183
1186
|
*/
|
|
1184
1187
|
initEle() {
|
|
1185
1188
|
this.$ele.input.parentElement!.insertBefore(this.$ele.inputSpanIcon, this.$ele.input.nextSibling);
|
|
1186
|
-
this.$ele.inputSpanIcon
|
|
1189
|
+
popsDOMUtils.addClassName(this.$ele.inputSpanIcon, "pops-panel-input__suffix");
|
|
1187
1190
|
PopsSafeUtils.setSafeHTML(
|
|
1188
1191
|
this.$ele.inputSpanIcon,
|
|
1189
1192
|
/*html*/ `
|
|
@@ -1255,30 +1258,30 @@ export const PanelHandlerComponents = () => {
|
|
|
1255
1258
|
if (this.isDisabled()) {
|
|
1256
1259
|
return;
|
|
1257
1260
|
}
|
|
1258
|
-
|
|
1261
|
+
// 删除图标
|
|
1259
1262
|
this.removeCircleIcon();
|
|
1260
|
-
if (
|
|
1261
|
-
|
|
1263
|
+
if (viewConfig.isPassword) {
|
|
1264
|
+
// 密码输入框
|
|
1262
1265
|
if (this.$data.isView) {
|
|
1263
|
-
|
|
1266
|
+
// 当前可见 => 点击改变为隐藏
|
|
1264
1267
|
this.$data.isView = false;
|
|
1265
|
-
|
|
1268
|
+
// 显示输入框内容,且更换图标为隐藏图标
|
|
1266
1269
|
this.setInputType("text");
|
|
1267
1270
|
this.setCircleIcon(PopsIcon.getIcon("hide")!);
|
|
1268
1271
|
} else {
|
|
1269
|
-
|
|
1272
|
+
// 当前不可见 => 点击改变为显示
|
|
1270
1273
|
this.$data.isView = true;
|
|
1271
|
-
|
|
1274
|
+
// 隐藏输入框内容,且更换图标为显示图标
|
|
1272
1275
|
this.setInputType("password");
|
|
1273
1276
|
this.setCircleIcon(PopsIcon.getIcon("view")!);
|
|
1274
1277
|
}
|
|
1275
1278
|
} else {
|
|
1276
|
-
|
|
1277
|
-
|
|
1279
|
+
// 普通输入框
|
|
1280
|
+
// 清空内容
|
|
1278
1281
|
this.setInputValue("");
|
|
1279
|
-
|
|
1282
|
+
// 获取焦点
|
|
1280
1283
|
this.$ele.input.focus();
|
|
1281
|
-
|
|
1284
|
+
// 触发内容改变事件
|
|
1282
1285
|
this.$ele.input.dispatchEvent(new Event("input"));
|
|
1283
1286
|
}
|
|
1284
1287
|
});
|
|
@@ -1289,21 +1292,21 @@ export const PanelHandlerComponents = () => {
|
|
|
1289
1292
|
setInputChangeEvent() {
|
|
1290
1293
|
popsDOMUtils.on<InputEvent>(this.$ele.input, ["input", "propertychange"], void 0, (event) => {
|
|
1291
1294
|
this.$data.value = this.$ele.input.value;
|
|
1292
|
-
if (!
|
|
1293
|
-
|
|
1295
|
+
if (!viewConfig.isPassword) {
|
|
1296
|
+
// 不是密码框
|
|
1294
1297
|
if (this.$ele.input.value !== "" && this.$ele.icon.innerHTML === "") {
|
|
1295
|
-
|
|
1298
|
+
// 不为空,显示清空图标
|
|
1296
1299
|
this.setCircleIcon(PopsIcon.getIcon("circleClose")!);
|
|
1297
1300
|
this.setCircleIconClickEvent();
|
|
1298
1301
|
} else if (this.$ele.input.value === "") {
|
|
1299
1302
|
this.removeCircleIcon();
|
|
1300
1303
|
}
|
|
1301
1304
|
}
|
|
1302
|
-
if (typeof
|
|
1303
|
-
if (
|
|
1304
|
-
|
|
1305
|
+
if (typeof viewConfig.callback === "function") {
|
|
1306
|
+
if (viewConfig.isNumber) {
|
|
1307
|
+
viewConfig.callback(event, this.$ele.input.value, this.$ele.input.valueAsNumber);
|
|
1305
1308
|
} else {
|
|
1306
|
-
|
|
1309
|
+
viewConfig.callback(event, this.$ele.input.value);
|
|
1307
1310
|
}
|
|
1308
1311
|
}
|
|
1309
1312
|
});
|
|
@@ -1316,27 +1319,27 @@ export const PanelHandlerComponents = () => {
|
|
|
1316
1319
|
/**
|
|
1317
1320
|
* type ==> textarea
|
|
1318
1321
|
* 获取中间容器的元素<li>
|
|
1319
|
-
* @param
|
|
1322
|
+
* @param viewConfig
|
|
1320
1323
|
*/
|
|
1321
|
-
createSectionContainerItem_textarea(
|
|
1324
|
+
createSectionContainerItem_textarea(viewConfig: PopsPanelTextAreaConfig) {
|
|
1322
1325
|
const $li = popsDOMUtils.createElement("li");
|
|
1323
|
-
Reflect.set($li,
|
|
1324
|
-
this.setElementClassName($li,
|
|
1325
|
-
this.setElementAttributes($li,
|
|
1326
|
-
this.setElementProps($li,
|
|
1326
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
1327
|
+
this.setElementClassName($li, viewConfig.className);
|
|
1328
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
1329
|
+
this.setElementProps($li, viewConfig.props);
|
|
1327
1330
|
|
|
1328
|
-
|
|
1331
|
+
// 左边底部的描述的文字
|
|
1329
1332
|
let leftDescriptionText = "";
|
|
1330
|
-
if (
|
|
1331
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${
|
|
1333
|
+
if (viewConfig.description) {
|
|
1334
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
1332
1335
|
}
|
|
1333
1336
|
PopsSafeUtils.setSafeHTML(
|
|
1334
1337
|
$li,
|
|
1335
1338
|
/*html*/ `
|
|
1336
1339
|
<div class="pops-panel-item-left-text">
|
|
1337
|
-
<p class="pops-panel-item-left-main-text">${
|
|
1340
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
1338
1341
|
<div class="pops-panel-textarea">
|
|
1339
|
-
<textarea placeholder="${
|
|
1342
|
+
<textarea placeholder="${viewConfig.placeholder ?? ""}"></textarea>
|
|
1340
1343
|
</div>
|
|
1341
1344
|
`
|
|
1342
1345
|
);
|
|
@@ -1349,12 +1352,12 @@ export const PanelHandlerComponents = () => {
|
|
|
1349
1352
|
textarea: $li.querySelector<HTMLTextAreaElement>(".pops-panel-textarea textarea")!,
|
|
1350
1353
|
},
|
|
1351
1354
|
$data: {
|
|
1352
|
-
value:
|
|
1355
|
+
value: viewConfig.getValue(),
|
|
1353
1356
|
},
|
|
1354
1357
|
init() {
|
|
1355
1358
|
this.setValue(this.$data.value);
|
|
1356
1359
|
this.setChangeEvent();
|
|
1357
|
-
const disabled = typeof
|
|
1360
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
1358
1361
|
if (disabled) {
|
|
1359
1362
|
this.disable();
|
|
1360
1363
|
}
|
|
@@ -1385,8 +1388,8 @@ export const PanelHandlerComponents = () => {
|
|
|
1385
1388
|
popsDOMUtils.on<InputEvent>(this.$ele.textarea, ["input", "propertychange"], (event) => {
|
|
1386
1389
|
const value = this.$ele.textarea.value;
|
|
1387
1390
|
this.$data.value = value;
|
|
1388
|
-
if (typeof
|
|
1389
|
-
|
|
1391
|
+
if (typeof viewConfig.callback === "function") {
|
|
1392
|
+
viewConfig.callback(
|
|
1390
1393
|
event as InputEvent & {
|
|
1391
1394
|
target: HTMLTextAreaElement;
|
|
1392
1395
|
},
|
|
@@ -1405,25 +1408,25 @@ export const PanelHandlerComponents = () => {
|
|
|
1405
1408
|
/**
|
|
1406
1409
|
* type ==> select
|
|
1407
1410
|
* 获取中间容器的元素<li>
|
|
1408
|
-
* @param
|
|
1411
|
+
* @param viewConfig
|
|
1409
1412
|
*/
|
|
1410
|
-
createSectionContainerItem_select(
|
|
1413
|
+
createSectionContainerItem_select(viewConfig: PopsPanelSelectConfig<any>) {
|
|
1411
1414
|
const that = this;
|
|
1412
1415
|
const $li = popsDOMUtils.createElement("li");
|
|
1413
|
-
Reflect.set($li,
|
|
1414
|
-
this.setElementClassName($li,
|
|
1415
|
-
this.setElementAttributes($li,
|
|
1416
|
-
this.setElementProps($li,
|
|
1417
|
-
|
|
1416
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
1417
|
+
this.setElementClassName($li, viewConfig.className);
|
|
1418
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
1419
|
+
this.setElementProps($li, viewConfig.props);
|
|
1420
|
+
// 左边底部的描述的文字
|
|
1418
1421
|
let leftDescriptionText = "";
|
|
1419
|
-
if (
|
|
1420
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
1422
|
+
if (viewConfig.description) {
|
|
1423
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
1421
1424
|
}
|
|
1422
1425
|
PopsSafeUtils.setSafeHTML(
|
|
1423
1426
|
$li,
|
|
1424
1427
|
/*html*/ `
|
|
1425
1428
|
<div class="pops-panel-item-left-text">
|
|
1426
|
-
<p class="pops-panel-item-left-main-text">${
|
|
1429
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
1427
1430
|
<div class="pops-panel-select">
|
|
1428
1431
|
<select></select>
|
|
1429
1432
|
</div>
|
|
@@ -1440,17 +1443,17 @@ export const PanelHandlerComponents = () => {
|
|
|
1440
1443
|
$eleKey: {
|
|
1441
1444
|
disable: "__disable__",
|
|
1442
1445
|
value: "__value__",
|
|
1443
|
-
|
|
1446
|
+
viewConfig: "data-view-config",
|
|
1444
1447
|
},
|
|
1445
1448
|
$data: {
|
|
1446
|
-
defaultValue:
|
|
1449
|
+
defaultValue: viewConfig.getValue(),
|
|
1447
1450
|
},
|
|
1448
1451
|
init() {
|
|
1449
1452
|
popsDOMUtils.addClassName(this.$ele.panelSelect, PopsCommonCSSClassName.userSelectNone);
|
|
1450
1453
|
this.initOption();
|
|
1451
1454
|
this.setChangeEvent();
|
|
1452
1455
|
this.setClickEvent();
|
|
1453
|
-
const disabled = typeof
|
|
1456
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
1454
1457
|
if (disabled) {
|
|
1455
1458
|
this.disable();
|
|
1456
1459
|
}
|
|
@@ -1502,12 +1505,12 @@ export const PanelHandlerComponents = () => {
|
|
|
1502
1505
|
* 初始化选项
|
|
1503
1506
|
*/
|
|
1504
1507
|
initOption() {
|
|
1505
|
-
|
|
1508
|
+
viewConfig.data.forEach((dataItem) => {
|
|
1506
1509
|
// 初始化默认选中
|
|
1507
1510
|
const optionElement = popsDOMUtils.createElement("option");
|
|
1508
1511
|
this.setNodeValue(optionElement, this.$eleKey.value, dataItem.value);
|
|
1509
1512
|
this.setNodeValue(optionElement, this.$eleKey.disable, dataItem.disable);
|
|
1510
|
-
this.setNodeValue(optionElement, this.$eleKey.
|
|
1513
|
+
this.setNodeValue(optionElement, this.$eleKey.viewConfig, dataItem.views);
|
|
1511
1514
|
if (dataItem.value === this.$data.defaultValue) {
|
|
1512
1515
|
this.setOptionSelected(optionElement);
|
|
1513
1516
|
}
|
|
@@ -1547,11 +1550,11 @@ export const PanelHandlerComponents = () => {
|
|
|
1547
1550
|
getSelectOptionInfo($option: HTMLOptionElement) {
|
|
1548
1551
|
const optionValue = this.getNodeValue($option, this.$eleKey.value);
|
|
1549
1552
|
const optionText = $option.innerText || $option.textContent!;
|
|
1550
|
-
const
|
|
1553
|
+
const views = this.getNodeValue($option, this.$eleKey.viewConfig) as (typeof viewConfig.data)[0]["views"];
|
|
1551
1554
|
return {
|
|
1552
1555
|
value: optionValue,
|
|
1553
1556
|
text: optionText,
|
|
1554
|
-
|
|
1557
|
+
views: views,
|
|
1555
1558
|
$option: $option,
|
|
1556
1559
|
};
|
|
1557
1560
|
},
|
|
@@ -1563,12 +1566,12 @@ export const PanelHandlerComponents = () => {
|
|
|
1563
1566
|
const $isSelectedElement = this.$ele.select[this.$ele.select.selectedIndex] as HTMLOptionElement;
|
|
1564
1567
|
const selectInfo = this.getSelectOptionInfo($isSelectedElement);
|
|
1565
1568
|
this.setSelectOptionsDisableStatus();
|
|
1566
|
-
if (typeof
|
|
1567
|
-
|
|
1569
|
+
if (typeof viewConfig.callback === "function") {
|
|
1570
|
+
viewConfig.callback(event, selectInfo.value, selectInfo.text);
|
|
1568
1571
|
}
|
|
1569
|
-
const
|
|
1570
|
-
if (Array.isArray(
|
|
1571
|
-
|
|
1572
|
+
const views = typeof selectInfo.views === "function" ? selectInfo.views() : selectInfo.views;
|
|
1573
|
+
if (Array.isArray(views)) {
|
|
1574
|
+
// 如果成功创建,加入到中间容器中
|
|
1572
1575
|
const childUListClassName = "pops-panel-select-child-forms";
|
|
1573
1576
|
// 移除旧的元素
|
|
1574
1577
|
while ($li.nextElementSibling) {
|
|
@@ -1581,7 +1584,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1581
1584
|
const $childUList = popsDOMUtils.createElement("ul");
|
|
1582
1585
|
$childUList.className = childUListClassName;
|
|
1583
1586
|
popsDOMUtils.after($li, $childUList);
|
|
1584
|
-
that.uListContainerAddItem(
|
|
1587
|
+
that.uListContainerAddItem(viewConfig, {
|
|
1585
1588
|
ulElement: $childUList,
|
|
1586
1589
|
});
|
|
1587
1590
|
}
|
|
@@ -1593,8 +1596,8 @@ export const PanelHandlerComponents = () => {
|
|
|
1593
1596
|
setClickEvent() {
|
|
1594
1597
|
popsDOMUtils.on(this.$ele.select, "click", void 0, (event) => {
|
|
1595
1598
|
this.setSelectOptionsDisableStatus();
|
|
1596
|
-
if (typeof
|
|
1597
|
-
|
|
1599
|
+
if (typeof viewConfig.clickCallBack === "function") {
|
|
1600
|
+
viewConfig.clickCallBack(event, this.$ele.select);
|
|
1598
1601
|
}
|
|
1599
1602
|
});
|
|
1600
1603
|
},
|
|
@@ -1607,24 +1610,24 @@ export const PanelHandlerComponents = () => {
|
|
|
1607
1610
|
/**
|
|
1608
1611
|
* type ==> select-multiple
|
|
1609
1612
|
* 获取中间容器的元素<li>
|
|
1610
|
-
* @param
|
|
1613
|
+
* @param viewConfig
|
|
1611
1614
|
*/
|
|
1612
|
-
|
|
1615
|
+
createSectionContainerItem_select_multiple(viewConfig: PopsPanelSelectMultipleConfig<any>) {
|
|
1613
1616
|
const $li = popsDOMUtils.createElement("li");
|
|
1614
|
-
Reflect.set($li,
|
|
1615
|
-
this.setElementClassName($li,
|
|
1616
|
-
this.setElementAttributes($li,
|
|
1617
|
-
this.setElementProps($li,
|
|
1618
|
-
|
|
1617
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
1618
|
+
this.setElementClassName($li, viewConfig.className);
|
|
1619
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
1620
|
+
this.setElementProps($li, viewConfig.props);
|
|
1621
|
+
// 左边底部的描述的文字
|
|
1619
1622
|
let leftDescriptionText = "";
|
|
1620
|
-
if (
|
|
1621
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
1623
|
+
if (viewConfig.description) {
|
|
1624
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
1622
1625
|
}
|
|
1623
1626
|
PopsSafeUtils.setSafeHTML(
|
|
1624
1627
|
$li,
|
|
1625
1628
|
/*html*/ `
|
|
1626
1629
|
<div class="pops-panel-item-left-text">
|
|
1627
|
-
<p class="pops-panel-item-left-main-text">${
|
|
1630
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
1628
1631
|
<div class="pops-panel-select-multiple">
|
|
1629
1632
|
<div class="el-select__wrapper">
|
|
1630
1633
|
<div class="el-select__selection">
|
|
@@ -1653,9 +1656,9 @@ export const PanelHandlerComponents = () => {
|
|
|
1653
1656
|
$el: {
|
|
1654
1657
|
/** 左侧文本容器 */
|
|
1655
1658
|
itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
|
|
1656
|
-
/**
|
|
1659
|
+
/** 选择框容器 */
|
|
1657
1660
|
$container: void 0 as any as HTMLElement,
|
|
1658
|
-
/**
|
|
1661
|
+
/** 选择框包裹的容器 */
|
|
1659
1662
|
$wrapper: void 0 as any as HTMLElement,
|
|
1660
1663
|
/** 内容区域 */
|
|
1661
1664
|
$section: void 0 as any as HTMLElement,
|
|
@@ -1672,8 +1675,15 @@ export const PanelHandlerComponents = () => {
|
|
|
1672
1675
|
},
|
|
1673
1676
|
$data: {
|
|
1674
1677
|
/** 默认值 */
|
|
1675
|
-
defaultValue:
|
|
1676
|
-
|
|
1678
|
+
defaultValue: viewConfig.getValue(),
|
|
1679
|
+
/**
|
|
1680
|
+
* 选择的信息
|
|
1681
|
+
*/
|
|
1682
|
+
selectInfo: [] as PopsPanelSelectMultipleDataOption<any>[],
|
|
1683
|
+
/**
|
|
1684
|
+
* 箭头旋转的属性
|
|
1685
|
+
*/
|
|
1686
|
+
rotateKey: "data-show-option",
|
|
1677
1687
|
},
|
|
1678
1688
|
/** 初始化 */
|
|
1679
1689
|
init() {
|
|
@@ -1683,14 +1693,14 @@ export const PanelHandlerComponents = () => {
|
|
|
1683
1693
|
this.initTagElement();
|
|
1684
1694
|
this.setSelectContainerClickEvent();
|
|
1685
1695
|
|
|
1686
|
-
const disabled = typeof
|
|
1696
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
1687
1697
|
if (disabled) {
|
|
1688
1698
|
this.disable();
|
|
1689
1699
|
}
|
|
1690
1700
|
},
|
|
1691
1701
|
/** 初始化默认值 */
|
|
1692
1702
|
initDefault() {
|
|
1693
|
-
|
|
1703
|
+
viewConfig.data.forEach((dataItem) => {
|
|
1694
1704
|
if (this.$data.defaultValue.includes(dataItem.value)) {
|
|
1695
1705
|
// 初始化选中的配置
|
|
1696
1706
|
this.$data.selectInfo.push({
|
|
@@ -1722,10 +1732,10 @@ export const PanelHandlerComponents = () => {
|
|
|
1722
1732
|
/** 初始化提示文字 */
|
|
1723
1733
|
initPlaceHolder() {
|
|
1724
1734
|
let placeholder = "";
|
|
1725
|
-
if (typeof
|
|
1726
|
-
placeholder =
|
|
1727
|
-
} else if (typeof
|
|
1728
|
-
const placeholderResult =
|
|
1735
|
+
if (typeof viewConfig.placeholder === "string") {
|
|
1736
|
+
placeholder = viewConfig.placeholder;
|
|
1737
|
+
} else if (typeof viewConfig.placeholder === "function") {
|
|
1738
|
+
const placeholderResult = viewConfig.placeholder();
|
|
1729
1739
|
if (typeof placeholderResult === "string") {
|
|
1730
1740
|
placeholder = placeholderResult;
|
|
1731
1741
|
}
|
|
@@ -1738,7 +1748,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1738
1748
|
/** 初始化tag元素 */
|
|
1739
1749
|
initTagElement() {
|
|
1740
1750
|
// 遍历数据,寻找对应的值
|
|
1741
|
-
|
|
1751
|
+
viewConfig.data.forEach((dataItem) => {
|
|
1742
1752
|
const findValue = this.$data.selectInfo.find((item) => item.value === dataItem.value);
|
|
1743
1753
|
if (findValue) {
|
|
1744
1754
|
// 存在对应的值
|
|
@@ -1839,8 +1849,8 @@ export const PanelHandlerComponents = () => {
|
|
|
1839
1849
|
selectValueChangeCallBack(selectedDataList?: PopsPanelSelectMultipleDataOption<any>[]) {
|
|
1840
1850
|
// 动态更新禁用状态
|
|
1841
1851
|
this.updateSelectItem();
|
|
1842
|
-
if (typeof
|
|
1843
|
-
|
|
1852
|
+
if (typeof viewConfig.callback === "function") {
|
|
1853
|
+
viewConfig.callback(selectedDataList || this.$data.selectInfo);
|
|
1844
1854
|
}
|
|
1845
1855
|
},
|
|
1846
1856
|
/**
|
|
@@ -2029,9 +2039,9 @@ export const PanelHandlerComponents = () => {
|
|
|
2029
2039
|
if (this.isSelectItemDisabled($select)) {
|
|
2030
2040
|
return;
|
|
2031
2041
|
}
|
|
2032
|
-
if (typeof
|
|
2042
|
+
if (typeof viewConfig.clickCallBack === "function") {
|
|
2033
2043
|
const allSelectedInfo = this.getAllSelectItemInfo().map((it) => it.data);
|
|
2034
|
-
const clickResult =
|
|
2044
|
+
const clickResult = viewConfig.clickCallBack(event, allSelectedInfo);
|
|
2035
2045
|
if (typeof clickResult === "boolean" && !clickResult) {
|
|
2036
2046
|
return;
|
|
2037
2047
|
}
|
|
@@ -2048,18 +2058,88 @@ export const PanelHandlerComponents = () => {
|
|
|
2048
2058
|
},
|
|
2049
2059
|
/**
|
|
2050
2060
|
* 设置下拉列表的点击事件
|
|
2061
|
+
*
|
|
2062
|
+
* 点击显示下拉列表弹窗
|
|
2051
2063
|
*/
|
|
2052
2064
|
setSelectContainerClickEvent() {
|
|
2053
|
-
const
|
|
2065
|
+
const defaultCSS = /*css*/ `
|
|
2066
|
+
.select-container{
|
|
2067
|
+
--el-font-size-base: 14px;
|
|
2068
|
+
--el-text-color-regular: #606266;
|
|
2069
|
+
--el-color-primary: #409eff;
|
|
2070
|
+
--el-fill-color-light: #f5f7fa;
|
|
2071
|
+
--el-disable-color: #a8abb2;
|
|
2072
|
+
}
|
|
2073
|
+
.select-item{
|
|
2074
|
+
cursor: pointer;
|
|
2075
|
+
font-size: var(--el-font-size-base);
|
|
2076
|
+
padding: 0 32px 0 20px;
|
|
2077
|
+
position: relative;
|
|
2078
|
+
white-space: nowrap;
|
|
2079
|
+
overflow: hidden;
|
|
2080
|
+
text-overflow: ellipsis;
|
|
2081
|
+
color: var(--el-text-color-regular);
|
|
2082
|
+
height: 34px;
|
|
2083
|
+
line-height: 34px;
|
|
2084
|
+
box-sizing: border-box;
|
|
2085
|
+
}
|
|
2086
|
+
.select-item[aria-disabled],
|
|
2087
|
+
.select-item[disabled]{
|
|
2088
|
+
cursor: not-allowed;
|
|
2089
|
+
color: var(--el-disable-color);
|
|
2090
|
+
background: unset;
|
|
2091
|
+
}
|
|
2092
|
+
.select-item:hover{
|
|
2093
|
+
background-color: var(--el-fill-color-light);
|
|
2094
|
+
}
|
|
2095
|
+
.select-item.select-item-is-selected{
|
|
2096
|
+
color: var(--el-color-primary);
|
|
2097
|
+
font-weight: 700;
|
|
2098
|
+
}
|
|
2099
|
+
.select-item.select-item-is-selected::after{
|
|
2100
|
+
content: "";
|
|
2101
|
+
position: absolute;
|
|
2102
|
+
top: 50%;
|
|
2103
|
+
right: 20px;
|
|
2104
|
+
border-top: none;
|
|
2105
|
+
border-right: none;
|
|
2106
|
+
background-repeat: no-repeat;
|
|
2107
|
+
background-position: center;
|
|
2108
|
+
background-color: var(--el-color-primary);
|
|
2109
|
+
mask: url("data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E") no-repeat;
|
|
2110
|
+
mask-size: 100% 100%;
|
|
2111
|
+
-webkit-mask: url("data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E") no-repeat;
|
|
2112
|
+
-webkit-mask-size: 100% 100%;
|
|
2113
|
+
transform: translateY(-50%);
|
|
2114
|
+
width: 12px;
|
|
2115
|
+
height: 12px;
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
|
|
2119
|
+
@media (prefers-color-scheme: dark) {
|
|
2120
|
+
.select-container{
|
|
2121
|
+
--el-text-color-regular: #f2f2f2;
|
|
2122
|
+
--el-disable-color: #8D9095;
|
|
2123
|
+
--el-fill-color-light: #262727;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
`;
|
|
2054
2127
|
popsDOMUtils.on(this.$el.$container, "click", () => {
|
|
2055
2128
|
if (this.isDisabled()) {
|
|
2056
2129
|
return;
|
|
2057
2130
|
}
|
|
2058
|
-
/**
|
|
2059
|
-
const
|
|
2060
|
-
const { style, ...
|
|
2061
|
-
const
|
|
2062
|
-
|
|
2131
|
+
/** 当前已选中的值 */
|
|
2132
|
+
const selectInfo = this.$data.selectInfo;
|
|
2133
|
+
const { style, ...userConfirmConfig } = viewConfig.selectConfirmDialogConfig || {};
|
|
2134
|
+
const dialogCloseCallback = () => {
|
|
2135
|
+
this.$data.selectInfo = [...selectInfo];
|
|
2136
|
+
this.updateSelectTagItem();
|
|
2137
|
+
this.$el.$selectContainer = null;
|
|
2138
|
+
this.$el.$container.removeAttribute(this.$data.rotateKey);
|
|
2139
|
+
};
|
|
2140
|
+
this.$el.$container.setAttribute(this.$data.rotateKey, String(true));
|
|
2141
|
+
const confirmConfig = popsUtils.assign(
|
|
2142
|
+
<PopsAlertConfig>{
|
|
2063
2143
|
title: {
|
|
2064
2144
|
text: "请勾选需要选择的选项",
|
|
2065
2145
|
position: "center",
|
|
@@ -2076,11 +2156,9 @@ export const PanelHandlerComponents = () => {
|
|
|
2076
2156
|
},
|
|
2077
2157
|
close: {
|
|
2078
2158
|
enable: true,
|
|
2079
|
-
callback(
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
that.$el.$selectContainer = null;
|
|
2083
|
-
details.close();
|
|
2159
|
+
callback(evtConfig) {
|
|
2160
|
+
evtConfig.close();
|
|
2161
|
+
dialogCloseCallback();
|
|
2084
2162
|
},
|
|
2085
2163
|
},
|
|
2086
2164
|
},
|
|
@@ -2088,9 +2166,7 @@ export const PanelHandlerComponents = () => {
|
|
|
2088
2166
|
enable: true,
|
|
2089
2167
|
clickCallBack(originalRun) {
|
|
2090
2168
|
originalRun();
|
|
2091
|
-
|
|
2092
|
-
that.updateSelectTagItem();
|
|
2093
|
-
that.$el.$selectContainer = null;
|
|
2169
|
+
dialogCloseCallback();
|
|
2094
2170
|
},
|
|
2095
2171
|
clickEvent: {
|
|
2096
2172
|
toClose: true,
|
|
@@ -2101,83 +2177,24 @@ export const PanelHandlerComponents = () => {
|
|
|
2101
2177
|
width: "300px",
|
|
2102
2178
|
height: "300px",
|
|
2103
2179
|
style: /*css*/ `
|
|
2104
|
-
|
|
2105
|
-
--el-font-size-base: 14px;
|
|
2106
|
-
--el-text-color-regular: #606266;
|
|
2107
|
-
--el-color-primary: #409eff;
|
|
2108
|
-
--el-fill-color-light: #f5f7fa;
|
|
2109
|
-
--el-disable-color: #a8abb2;
|
|
2110
|
-
}
|
|
2111
|
-
.select-item{
|
|
2112
|
-
cursor: pointer;
|
|
2113
|
-
font-size: var(--el-font-size-base);
|
|
2114
|
-
padding: 0 32px 0 20px;
|
|
2115
|
-
position: relative;
|
|
2116
|
-
white-space: nowrap;
|
|
2117
|
-
overflow: hidden;
|
|
2118
|
-
text-overflow: ellipsis;
|
|
2119
|
-
color: var(--el-text-color-regular);
|
|
2120
|
-
height: 34px;
|
|
2121
|
-
line-height: 34px;
|
|
2122
|
-
box-sizing: border-box;
|
|
2123
|
-
}
|
|
2124
|
-
.select-item[aria-disabled],
|
|
2125
|
-
.select-item[disabled]{
|
|
2126
|
-
cursor: not-allowed;
|
|
2127
|
-
color: var(--el-disable-color);
|
|
2128
|
-
background: unset;
|
|
2129
|
-
}
|
|
2130
|
-
.select-item:hover{
|
|
2131
|
-
background-color: var(--el-fill-color-light);
|
|
2132
|
-
}
|
|
2133
|
-
.select-item.select-item-is-selected{
|
|
2134
|
-
color: var(--el-color-primary);
|
|
2135
|
-
font-weight: 700;
|
|
2136
|
-
}
|
|
2137
|
-
.select-item.select-item-is-selected::after{
|
|
2138
|
-
content: "";
|
|
2139
|
-
position: absolute;
|
|
2140
|
-
top: 50%;
|
|
2141
|
-
right: 20px;
|
|
2142
|
-
border-top: none;
|
|
2143
|
-
border-right: none;
|
|
2144
|
-
background-repeat: no-repeat;
|
|
2145
|
-
background-position: center;
|
|
2146
|
-
background-color: var(--el-color-primary);
|
|
2147
|
-
mask: url("data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E") no-repeat;
|
|
2148
|
-
mask-size: 100% 100%;
|
|
2149
|
-
-webkit-mask: url("data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E") no-repeat;
|
|
2150
|
-
-webkit-mask-size: 100% 100%;
|
|
2151
|
-
transform: translateY(-50%);
|
|
2152
|
-
width: 12px;
|
|
2153
|
-
height: 12px;
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
@media (prefers-color-scheme: dark) {
|
|
2158
|
-
.select-container{
|
|
2159
|
-
--el-text-color-regular: #f2f2f2;
|
|
2160
|
-
--el-disable-color: #8D9095;
|
|
2161
|
-
--el-fill-color-light: #262727;
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2180
|
+
${defaultCSS}
|
|
2164
2181
|
|
|
2165
|
-
|
|
2182
|
+
${style || ""}
|
|
2166
2183
|
`,
|
|
2167
2184
|
},
|
|
2168
|
-
|
|
2185
|
+
userConfirmConfig
|
|
2169
2186
|
);
|
|
2170
|
-
const $dialog = PopsAlert.init(
|
|
2187
|
+
const $dialog = PopsAlert.init(confirmConfig);
|
|
2171
2188
|
const $selectContainer = $dialog.$shadowRoot.querySelector<HTMLUListElement>(".select-container")!;
|
|
2172
|
-
this.$el.$selectContainer = $selectContainer;
|
|
2173
2189
|
// 配置选项元素
|
|
2174
|
-
|
|
2190
|
+
viewConfig.data.forEach((item) => {
|
|
2175
2191
|
const $select = this.createSelectItemElement(item);
|
|
2176
2192
|
// 添加到confirm中
|
|
2177
2193
|
$selectContainer.appendChild($select);
|
|
2178
2194
|
// 设置每一项的点击事件
|
|
2179
|
-
this.setSelectElementClickEvent(
|
|
2195
|
+
this.setSelectElementClickEvent(selectInfo, $select);
|
|
2180
2196
|
});
|
|
2197
|
+
this.$el.$selectContainer = $selectContainer;
|
|
2181
2198
|
// 动态更新禁用状态
|
|
2182
2199
|
this.updateSelectItem();
|
|
2183
2200
|
});
|
|
@@ -2204,8 +2221,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2204
2221
|
if (this.isDisabled()) {
|
|
2205
2222
|
return;
|
|
2206
2223
|
}
|
|
2207
|
-
if (typeof
|
|
2208
|
-
const result =
|
|
2224
|
+
if (typeof viewConfig.closeIconClickCallBack === "function") {
|
|
2225
|
+
const result = viewConfig.closeIconClickCallBack(event, {
|
|
2209
2226
|
$tag: data.$tag,
|
|
2210
2227
|
$closeIcon: data.$closeIcon,
|
|
2211
2228
|
value: data.value,
|
|
@@ -2314,25 +2331,25 @@ export const PanelHandlerComponents = () => {
|
|
|
2314
2331
|
/**
|
|
2315
2332
|
* type ==> button
|
|
2316
2333
|
* 获取中间容器的元素<li>
|
|
2317
|
-
* @param
|
|
2334
|
+
* @param viewConfig
|
|
2318
2335
|
*/
|
|
2319
|
-
createSectionContainerItem_button(
|
|
2336
|
+
createSectionContainerItem_button(viewConfig: PopsPanelButtonConfig) {
|
|
2320
2337
|
const $li = popsDOMUtils.createElement("li");
|
|
2321
|
-
Reflect.set($li,
|
|
2322
|
-
this.setElementClassName($li,
|
|
2323
|
-
this.setElementAttributes($li,
|
|
2324
|
-
this.setElementProps($li,
|
|
2338
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
2339
|
+
this.setElementClassName($li, viewConfig.className);
|
|
2340
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
2341
|
+
this.setElementProps($li, viewConfig.props);
|
|
2325
2342
|
|
|
2326
|
-
|
|
2343
|
+
// 左边底部的描述的文字
|
|
2327
2344
|
let leftDescriptionText = "";
|
|
2328
|
-
if (
|
|
2329
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
2345
|
+
if (viewConfig.description) {
|
|
2346
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
2330
2347
|
}
|
|
2331
2348
|
PopsSafeUtils.setSafeHTML(
|
|
2332
2349
|
$li,
|
|
2333
2350
|
/*html*/ `
|
|
2334
2351
|
<div class="pops-panel-item-left-text">
|
|
2335
|
-
<p class="pops-panel-item-left-main-text">${
|
|
2352
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
2336
2353
|
<div class="pops-panel-button">
|
|
2337
2354
|
<button class="pops-panel-button_inner" type="button">
|
|
2338
2355
|
<i class="pops-bottom-icon"></i>
|
|
@@ -2357,33 +2374,33 @@ export const PanelHandlerComponents = () => {
|
|
|
2357
2374
|
this.setClickEvent();
|
|
2358
2375
|
},
|
|
2359
2376
|
initButton() {
|
|
2360
|
-
if (typeof
|
|
2361
|
-
|
|
2362
|
-
if (PopsIcon.hasIcon(
|
|
2363
|
-
this.setIconSVG(PopsIcon.getIcon(
|
|
2377
|
+
if (typeof viewConfig.buttonIcon === "string" && viewConfig.buttonIcon.trim() !== "") {
|
|
2378
|
+
// 存在icon图标且不为空
|
|
2379
|
+
if (PopsIcon.hasIcon(viewConfig.buttonIcon)) {
|
|
2380
|
+
this.setIconSVG(PopsIcon.getIcon(viewConfig.buttonIcon)!);
|
|
2364
2381
|
} else {
|
|
2365
|
-
this.setIconSVG(
|
|
2382
|
+
this.setIconSVG(viewConfig.buttonIcon);
|
|
2366
2383
|
}
|
|
2367
2384
|
this.showIcon();
|
|
2368
2385
|
} else {
|
|
2369
2386
|
this.hideIcon();
|
|
2370
2387
|
}
|
|
2371
|
-
|
|
2372
|
-
let buttonText =
|
|
2373
|
-
if (typeof
|
|
2374
|
-
buttonText =
|
|
2388
|
+
// 按钮文字
|
|
2389
|
+
let buttonText = viewConfig.buttonText;
|
|
2390
|
+
if (typeof viewConfig.buttonText === "function") {
|
|
2391
|
+
buttonText = viewConfig.buttonText();
|
|
2375
2392
|
}
|
|
2376
|
-
this.setButtonType(
|
|
2377
|
-
if (
|
|
2393
|
+
this.setButtonType(viewConfig.buttonType);
|
|
2394
|
+
if (viewConfig.buttonIsRightIcon) {
|
|
2378
2395
|
this.setIconRight();
|
|
2379
2396
|
} else {
|
|
2380
2397
|
this.setIconLeft();
|
|
2381
2398
|
}
|
|
2382
|
-
if (
|
|
2399
|
+
if (viewConfig.disable) {
|
|
2383
2400
|
this.disable();
|
|
2384
2401
|
}
|
|
2385
2402
|
this.setButtonText(buttonText as string);
|
|
2386
|
-
this.setIconLoadingStatus(
|
|
2403
|
+
this.setIconLoadingStatus(viewConfig.buttonIconIsLoading);
|
|
2387
2404
|
},
|
|
2388
2405
|
disable() {
|
|
2389
2406
|
this.$ele.button.setAttribute("disabled", "true");
|
|
@@ -2450,8 +2467,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2450
2467
|
},
|
|
2451
2468
|
setClickEvent() {
|
|
2452
2469
|
popsDOMUtils.on(this.$ele.button, "click", void 0, (event) => {
|
|
2453
|
-
if (typeof
|
|
2454
|
-
|
|
2470
|
+
if (typeof viewConfig.callback === "function") {
|
|
2471
|
+
viewConfig.callback(event);
|
|
2455
2472
|
}
|
|
2456
2473
|
});
|
|
2457
2474
|
},
|
|
@@ -2463,40 +2480,40 @@ export const PanelHandlerComponents = () => {
|
|
|
2463
2480
|
/**
|
|
2464
2481
|
* type ==> deepMenu
|
|
2465
2482
|
* 获取深层容器的元素<li>
|
|
2466
|
-
* @param
|
|
2483
|
+
* @param viewConfig
|
|
2467
2484
|
*/
|
|
2468
|
-
createSectionContainerItem_deepMenu(
|
|
2485
|
+
createSectionContainerItem_deepMenu(viewConfig: PopsPanelDeepViewConfig) {
|
|
2469
2486
|
const that = this;
|
|
2470
2487
|
const $li = popsDOMUtils.createElement("li");
|
|
2471
2488
|
popsDOMUtils.addClassName($li, "pops-panel-deepMenu-nav-item");
|
|
2472
|
-
Reflect.set($li,
|
|
2473
|
-
this.setElementClassName($li,
|
|
2489
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
2490
|
+
this.setElementClassName($li, viewConfig.className);
|
|
2474
2491
|
// 设置属性
|
|
2475
|
-
this.setElementAttributes($li,
|
|
2492
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
2476
2493
|
// 设置元素上的属性
|
|
2477
|
-
this.setElementProps($li,
|
|
2494
|
+
this.setElementProps($li, viewConfig.props);
|
|
2478
2495
|
|
|
2479
|
-
|
|
2496
|
+
// 左边底部的描述的文字
|
|
2480
2497
|
let leftDescriptionText = "";
|
|
2481
|
-
if (
|
|
2498
|
+
if (viewConfig.description) {
|
|
2482
2499
|
// 设置描述
|
|
2483
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${
|
|
2500
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
2484
2501
|
}
|
|
2485
2502
|
// 箭头图标
|
|
2486
|
-
const arrowRightIcon = typeof
|
|
2503
|
+
const arrowRightIcon = typeof viewConfig.arrowRightIcon === "boolean" ? viewConfig.arrowRightIcon : true;
|
|
2487
2504
|
let arrowRightIconHTML = "";
|
|
2488
2505
|
if (arrowRightIcon) {
|
|
2489
2506
|
arrowRightIconHTML = `<i class="pops-panel-deepMenu-arrowRight-icon">${PopsIcon.getIcon("arrowRight")}</i>`;
|
|
2490
2507
|
}
|
|
2491
2508
|
let rightText = "";
|
|
2492
|
-
if (
|
|
2493
|
-
rightText = /*html*/ `<p class="pops-panel-item-right-text">${
|
|
2509
|
+
if (viewConfig.rightText) {
|
|
2510
|
+
rightText = /*html*/ `<p class="pops-panel-item-right-text">${viewConfig.rightText}</p>`;
|
|
2494
2511
|
}
|
|
2495
2512
|
PopsSafeUtils.setSafeHTML(
|
|
2496
2513
|
$li,
|
|
2497
2514
|
/*html*/ `
|
|
2498
2515
|
<div class="pops-panel-item-left-text">
|
|
2499
|
-
<p class="pops-panel-item-left-main-text">${
|
|
2516
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
2500
2517
|
<div class="pops-panel-deepMenu">${rightText}${arrowRightIconHTML}</div>
|
|
2501
2518
|
`
|
|
2502
2519
|
);
|
|
@@ -2515,29 +2532,29 @@ export const PanelHandlerComponents = () => {
|
|
|
2515
2532
|
* @param $container
|
|
2516
2533
|
* @param formItemConfig
|
|
2517
2534
|
*/
|
|
2518
|
-
|
|
2519
|
-
const
|
|
2520
|
-
if (
|
|
2521
|
-
const childForms =
|
|
2522
|
-
|
|
2535
|
+
initContainerItem($container: HTMLElement, formItemConfig: PopsPanelViewConfig | PopsPanelContainerConfig) {
|
|
2536
|
+
const containerViewConfig = formItemConfig as PopsPanelContainerConfig;
|
|
2537
|
+
if (containerViewConfig.type === "container") {
|
|
2538
|
+
const childForms = containerViewConfig["views"];
|
|
2539
|
+
// 每一项<li>元素
|
|
2523
2540
|
const formContainerListElement = popsDOMUtils.createElement("li");
|
|
2524
|
-
|
|
2541
|
+
// 每一项<li>内的子<ul>元素
|
|
2525
2542
|
const formContainerULElement = popsDOMUtils.createElement("ul");
|
|
2526
2543
|
formContainerULElement.classList.add("pops-panel-forms-container-item-formlist");
|
|
2527
2544
|
formContainerListElement.classList.add("pops-panel-forms-container-item");
|
|
2528
|
-
|
|
2545
|
+
// 区域头部的文字
|
|
2529
2546
|
const formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
2530
2547
|
className: "pops-panel-forms-container-item-header-text",
|
|
2531
2548
|
});
|
|
2532
|
-
PopsSafeUtils.setSafeHTML(formHeaderDivElement,
|
|
2549
|
+
PopsSafeUtils.setSafeHTML(formHeaderDivElement, containerViewConfig["text"]);
|
|
2533
2550
|
|
|
2534
|
-
if (
|
|
2535
|
-
|
|
2536
|
-
|
|
2551
|
+
if (containerViewConfig.isFold) {
|
|
2552
|
+
// 添加第一个
|
|
2553
|
+
// 加进容器内
|
|
2537
2554
|
PopsSafeUtils.setSafeHTML(
|
|
2538
2555
|
formHeaderDivElement,
|
|
2539
2556
|
/*html*/ `
|
|
2540
|
-
<p>${
|
|
2557
|
+
<p>${containerViewConfig.text}</p>
|
|
2541
2558
|
<i class="pops-panel-forms-fold-container-icon">
|
|
2542
2559
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
2543
2560
|
<path d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"></path>
|
|
@@ -2559,15 +2576,15 @@ export const PanelHandlerComponents = () => {
|
|
|
2559
2576
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold");
|
|
2560
2577
|
formContainerListElement.appendChild(formHeaderDivElement);
|
|
2561
2578
|
} else {
|
|
2562
|
-
|
|
2579
|
+
// 加进容器内
|
|
2563
2580
|
formContainerListElement.appendChild(formHeaderDivElement);
|
|
2564
2581
|
}
|
|
2565
2582
|
|
|
2566
2583
|
that.setElementClassName(formContainerListElement, formItemConfig.className);
|
|
2567
2584
|
that.setElementAttributes(formContainerListElement, formItemConfig.attributes);
|
|
2568
2585
|
that.setElementProps(formContainerListElement, formItemConfig.props);
|
|
2569
|
-
childForms.forEach((
|
|
2570
|
-
that.uListContainerAddItem(
|
|
2586
|
+
childForms.forEach((childViewConfig) => {
|
|
2587
|
+
that.uListContainerAddItem(childViewConfig, {
|
|
2571
2588
|
ulElement: formContainerULElement,
|
|
2572
2589
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
2573
2590
|
formContainerListElement: formContainerListElement,
|
|
@@ -2576,8 +2593,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2576
2593
|
});
|
|
2577
2594
|
formContainerListElement.appendChild(formContainerULElement);
|
|
2578
2595
|
$container.appendChild(formContainerListElement);
|
|
2579
|
-
if (typeof
|
|
2580
|
-
|
|
2596
|
+
if (typeof containerViewConfig.afterAddToUListCallBack === "function") {
|
|
2597
|
+
containerViewConfig.afterAddToUListCallBack(viewConfig as any as PopsPanelContainerConfig, {
|
|
2581
2598
|
target: formContainerListElement,
|
|
2582
2599
|
ulElement: formContainerULElement,
|
|
2583
2600
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
@@ -2586,8 +2603,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2586
2603
|
});
|
|
2587
2604
|
}
|
|
2588
2605
|
} else {
|
|
2589
|
-
|
|
2590
|
-
that.uListContainerAddItem(
|
|
2606
|
+
// 如果成功创建,加入到中间容器中
|
|
2607
|
+
that.uListContainerAddItem(viewConfig, {
|
|
2591
2608
|
ulElement: that.sectionContainerULElement,
|
|
2592
2609
|
});
|
|
2593
2610
|
}
|
|
@@ -2604,7 +2621,7 @@ export const PanelHandlerComponents = () => {
|
|
|
2604
2621
|
const $deepMenuSection = popsDOMUtils.createElement("section", {
|
|
2605
2622
|
className: "pops-panel-container pops-panel-deepMenu-container",
|
|
2606
2623
|
});
|
|
2607
|
-
Reflect.set($deepMenuSection,
|
|
2624
|
+
Reflect.set($deepMenuSection, that.$data.nodeStoreConfigKey, viewConfig);
|
|
2608
2625
|
const $deepMenuHeaderUL = popsDOMUtils.createElement("ul", {
|
|
2609
2626
|
className: "pops-panel-container-header-ul pops-panel-deepMenu-container-header-ul",
|
|
2610
2627
|
});
|
|
@@ -2612,7 +2629,7 @@ export const PanelHandlerComponents = () => {
|
|
|
2612
2629
|
className: "pops-panel-container-main-ul",
|
|
2613
2630
|
});
|
|
2614
2631
|
// 标题文字
|
|
2615
|
-
const headerTitleText =
|
|
2632
|
+
const headerTitleText = viewConfig.headerTitle ?? viewConfig.text;
|
|
2616
2633
|
const $header = popsDOMUtils.createElement("li", {
|
|
2617
2634
|
className: "pops-panel-container-header-title-text pops-panel-deepMenu-container-header",
|
|
2618
2635
|
innerHTML: /*html*/ `<p class="pops-panel-deepMenu-container-header-title-text">${headerTitleText}</p>`,
|
|
@@ -2692,10 +2709,10 @@ export const PanelHandlerComponents = () => {
|
|
|
2692
2709
|
$deepMenuSection.appendChild($deepMenuHeaderUL);
|
|
2693
2710
|
$deepMenuSection.appendChild($deepMenuMain);
|
|
2694
2711
|
|
|
2695
|
-
if (
|
|
2696
|
-
for (let index = 0; index <
|
|
2697
|
-
const formItemConfig =
|
|
2698
|
-
this.
|
|
2712
|
+
if (viewConfig.views && Array.isArray(viewConfig.views)) {
|
|
2713
|
+
for (let index = 0; index < viewConfig.views.length; index++) {
|
|
2714
|
+
const formItemConfig = viewConfig.views[index];
|
|
2715
|
+
this.initContainerItem($deepMenuMain, formItemConfig);
|
|
2699
2716
|
}
|
|
2700
2717
|
}
|
|
2701
2718
|
that.$el.$panelRightSectionWrapper.appendChild($deepMenuSection);
|
|
@@ -2720,12 +2737,12 @@ export const PanelHandlerComponents = () => {
|
|
|
2720
2737
|
} else {
|
|
2721
2738
|
enterViewTransition();
|
|
2722
2739
|
}
|
|
2723
|
-
if (typeof
|
|
2724
|
-
|
|
2725
|
-
sectionContainer: $deepMenuSection,
|
|
2726
|
-
sectionContainerHeaderContainer: $deepMenuHeaderUL,
|
|
2727
|
-
sectionContainerHeader: $header,
|
|
2728
|
-
sectionBodyContainer: $deepMenuMain,
|
|
2740
|
+
if (typeof viewConfig.afterEnterDeepMenuCallBack === "function") {
|
|
2741
|
+
viewConfig.afterEnterDeepMenuCallBack(viewConfig, {
|
|
2742
|
+
$sectionContainer: $deepMenuSection,
|
|
2743
|
+
$sectionContainerHeaderContainer: $deepMenuHeaderUL,
|
|
2744
|
+
$sectionContainerHeader: $header,
|
|
2745
|
+
$sectionBodyContainer: $deepMenuMain,
|
|
2729
2746
|
});
|
|
2730
2747
|
}
|
|
2731
2748
|
that.triggerRenderRightContainer($deepMenuSection);
|
|
@@ -2733,8 +2750,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2733
2750
|
/** 设置项的点击事件 */
|
|
2734
2751
|
setLiClickEvent() {
|
|
2735
2752
|
popsDOMUtils.on($li, "click", void 0, async (event) => {
|
|
2736
|
-
if (typeof
|
|
2737
|
-
const result = await
|
|
2753
|
+
if (typeof viewConfig.clickCallBack === "function") {
|
|
2754
|
+
const result = await viewConfig.clickCallBack(event, viewConfig);
|
|
2738
2755
|
if (result) {
|
|
2739
2756
|
return;
|
|
2740
2757
|
}
|
|
@@ -2752,74 +2769,74 @@ export const PanelHandlerComponents = () => {
|
|
|
2752
2769
|
/**
|
|
2753
2770
|
* type ===> own
|
|
2754
2771
|
* 获取中间容器的元素<li>
|
|
2755
|
-
* @param
|
|
2772
|
+
* @param viewConfig
|
|
2756
2773
|
*/
|
|
2757
|
-
createSectionContainerItem_own(
|
|
2774
|
+
createSectionContainerItem_own(viewConfig: PopsPanelOwnConfig) {
|
|
2758
2775
|
let $li = popsDOMUtils.createElement("li");
|
|
2759
|
-
Reflect.set($li,
|
|
2760
|
-
this.setElementClassName($li,
|
|
2761
|
-
this.setElementAttributes($li,
|
|
2762
|
-
this.setElementProps($li,
|
|
2763
|
-
$li =
|
|
2776
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
2777
|
+
this.setElementClassName($li, viewConfig.className);
|
|
2778
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
2779
|
+
this.setElementProps($li, viewConfig.props);
|
|
2780
|
+
$li = viewConfig.getLiElementCallBack($li);
|
|
2764
2781
|
return $li;
|
|
2765
2782
|
},
|
|
2766
2783
|
/**
|
|
2767
2784
|
* 获取中间容器的元素<li>
|
|
2768
|
-
* @param
|
|
2785
|
+
* @param viewConfig 视图配置
|
|
2769
2786
|
*/
|
|
2770
|
-
createSectionContainerItem(
|
|
2787
|
+
createSectionContainerItem(viewConfig: PopsPanelViewConfig) {
|
|
2771
2788
|
/** 配置项的类型 */
|
|
2772
|
-
const
|
|
2789
|
+
const componentType = viewConfig.type;
|
|
2773
2790
|
|
|
2774
|
-
if (
|
|
2775
|
-
return this.createSectionContainerItem_switch(
|
|
2776
|
-
} else if (
|
|
2777
|
-
return this.createSectionContainerItem_slider_new(
|
|
2778
|
-
} else if (
|
|
2779
|
-
return this.createSectionContainerItem_input(
|
|
2780
|
-
} else if (
|
|
2781
|
-
return this.createSectionContainerItem_textarea(
|
|
2782
|
-
} else if (
|
|
2783
|
-
return this.createSectionContainerItem_select(
|
|
2784
|
-
} else if (
|
|
2785
|
-
return this.
|
|
2786
|
-
} else if (
|
|
2787
|
-
return this.createSectionContainerItem_button(
|
|
2788
|
-
} else if (
|
|
2789
|
-
return this.createSectionContainerItem_deepMenu(
|
|
2790
|
-
} else if (
|
|
2791
|
-
return this.createSectionContainerItem_own(
|
|
2791
|
+
if (componentType === "switch") {
|
|
2792
|
+
return this.createSectionContainerItem_switch(viewConfig as PopsPanelSwitchConfig);
|
|
2793
|
+
} else if (componentType === "slider") {
|
|
2794
|
+
return this.createSectionContainerItem_slider_new(viewConfig as PopsPanelSliderConfig);
|
|
2795
|
+
} else if (componentType === "input") {
|
|
2796
|
+
return this.createSectionContainerItem_input(viewConfig as PopsPanelInputConfig);
|
|
2797
|
+
} else if (componentType === "textarea") {
|
|
2798
|
+
return this.createSectionContainerItem_textarea(viewConfig as PopsPanelTextAreaConfig);
|
|
2799
|
+
} else if (componentType === "select") {
|
|
2800
|
+
return this.createSectionContainerItem_select(viewConfig as PopsPanelSelectConfig);
|
|
2801
|
+
} else if (componentType === "select-multiple") {
|
|
2802
|
+
return this.createSectionContainerItem_select_multiple(viewConfig as PopsPanelSelectMultipleConfig<any>);
|
|
2803
|
+
} else if (componentType === "button") {
|
|
2804
|
+
return this.createSectionContainerItem_button(viewConfig as PopsPanelButtonConfig);
|
|
2805
|
+
} else if (componentType === "deepMenu") {
|
|
2806
|
+
return this.createSectionContainerItem_deepMenu(viewConfig as PopsPanelDeepViewConfig);
|
|
2807
|
+
} else if (componentType === "own") {
|
|
2808
|
+
return this.createSectionContainerItem_own(viewConfig as PopsPanelOwnConfig);
|
|
2792
2809
|
} else {
|
|
2793
|
-
console.error("尚未实现的type类型",
|
|
2810
|
+
console.error("尚未实现的type类型", viewConfig);
|
|
2794
2811
|
}
|
|
2795
2812
|
},
|
|
2796
2813
|
/**
|
|
2797
2814
|
* 生成配置项forms
|
|
2798
2815
|
* 生成配置每一项的元素
|
|
2799
|
-
* @param
|
|
2816
|
+
* @param viewConfig
|
|
2800
2817
|
*/
|
|
2801
|
-
createSectionContainerItem_forms(
|
|
2818
|
+
createSectionContainerItem_forms(viewConfig: PopsPanelContentConfig | PopsPanelContainerConfig) {
|
|
2802
2819
|
const that = this;
|
|
2803
|
-
const
|
|
2804
|
-
if (
|
|
2805
|
-
const childForms =
|
|
2806
|
-
|
|
2820
|
+
const containerConfig = viewConfig as PopsPanelContainerConfig;
|
|
2821
|
+
if (containerConfig.type === "container") {
|
|
2822
|
+
const childForms = viewConfig["views"];
|
|
2823
|
+
// 每一项<li>元素
|
|
2807
2824
|
const formContainerListElement = popsDOMUtils.createElement("li");
|
|
2808
|
-
|
|
2825
|
+
// 每一项<li>内的子<ul>元素
|
|
2809
2826
|
const formContainerULElement = popsDOMUtils.createElement("ul");
|
|
2810
2827
|
formContainerListElement.classList.add("pops-panel-forms-container-item");
|
|
2811
2828
|
formContainerULElement.classList.add("pops-panel-forms-container-item-formlist");
|
|
2812
|
-
|
|
2829
|
+
// 区域头部的文字
|
|
2813
2830
|
const formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
2814
2831
|
className: "pops-panel-forms-container-item-header-text",
|
|
2815
2832
|
});
|
|
2816
|
-
PopsSafeUtils.setSafeHTML(formHeaderDivElement,
|
|
2817
|
-
if (
|
|
2818
|
-
|
|
2833
|
+
PopsSafeUtils.setSafeHTML(formHeaderDivElement, containerConfig["text"]);
|
|
2834
|
+
if (containerConfig.isFold) {
|
|
2835
|
+
// 加进容器内
|
|
2819
2836
|
PopsSafeUtils.setSafeHTML(
|
|
2820
2837
|
formHeaderDivElement,
|
|
2821
2838
|
/*html*/ `
|
|
2822
|
-
<p>${
|
|
2839
|
+
<p>${containerConfig.text}</p>
|
|
2823
2840
|
<i class="pops-panel-forms-fold-container-icon">
|
|
2824
2841
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
2825
2842
|
<path d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"></path>
|
|
@@ -2841,14 +2858,14 @@ export const PanelHandlerComponents = () => {
|
|
|
2841
2858
|
popsDOMUtils.addClassName(formContainerListElement, "pops-panel-forms-fold");
|
|
2842
2859
|
formContainerListElement.appendChild(formHeaderDivElement);
|
|
2843
2860
|
} else {
|
|
2844
|
-
|
|
2861
|
+
// 加进容器内
|
|
2845
2862
|
formContainerListElement.appendChild(formHeaderDivElement);
|
|
2846
2863
|
}
|
|
2847
|
-
that.setElementClassName(formContainerListElement,
|
|
2848
|
-
that.setElementAttributes(formContainerListElement,
|
|
2849
|
-
that.setElementProps(formContainerListElement,
|
|
2850
|
-
childForms.forEach((
|
|
2851
|
-
that.uListContainerAddItem(
|
|
2864
|
+
that.setElementClassName(formContainerListElement, viewConfig.className);
|
|
2865
|
+
that.setElementAttributes(formContainerListElement, viewConfig.attributes);
|
|
2866
|
+
that.setElementProps(formContainerListElement, viewConfig.props);
|
|
2867
|
+
childForms.forEach((childViewConfig) => {
|
|
2868
|
+
that.uListContainerAddItem(childViewConfig as PopsPanelViewConfig, {
|
|
2852
2869
|
ulElement: formContainerULElement,
|
|
2853
2870
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
2854
2871
|
formContainerListElement: formContainerListElement,
|
|
@@ -2858,8 +2875,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2858
2875
|
formContainerListElement.appendChild(formContainerULElement);
|
|
2859
2876
|
that.sectionContainerULElement.appendChild(formContainerListElement);
|
|
2860
2877
|
|
|
2861
|
-
if (typeof
|
|
2862
|
-
|
|
2878
|
+
if (typeof containerConfig.afterAddToUListCallBack === "function") {
|
|
2879
|
+
containerConfig.afterAddToUListCallBack(containerConfig, {
|
|
2863
2880
|
target: formContainerListElement,
|
|
2864
2881
|
ulElement: formContainerULElement,
|
|
2865
2882
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
@@ -2868,26 +2885,27 @@ export const PanelHandlerComponents = () => {
|
|
|
2868
2885
|
});
|
|
2869
2886
|
}
|
|
2870
2887
|
} else {
|
|
2871
|
-
|
|
2872
|
-
that.uListContainerAddItem(
|
|
2888
|
+
// 如果成功创建,加入到中间容器中
|
|
2889
|
+
that.uListContainerAddItem(viewConfig as any as PopsPanelViewConfig, {
|
|
2873
2890
|
ulElement: that.sectionContainerULElement,
|
|
2874
2891
|
});
|
|
2875
2892
|
}
|
|
2876
2893
|
},
|
|
2877
2894
|
/**
|
|
2878
2895
|
* 主动触发触发渲染右侧容器的事件
|
|
2896
|
+
* @param $container 容器
|
|
2879
2897
|
*/
|
|
2880
2898
|
triggerRenderRightContainer($container: HTMLElement) {
|
|
2881
|
-
const
|
|
2899
|
+
const dataViewConfig: PopsPanelEventType["pops:renderRightContainer"]["viewConfig"] = Reflect.get(
|
|
2882
2900
|
$container,
|
|
2883
|
-
|
|
2901
|
+
this.$data.nodeStoreConfigKey
|
|
2884
2902
|
);
|
|
2885
2903
|
this.$el.$pops.dispatchEvent(
|
|
2886
2904
|
new CustomEvent<PopsPanelEventType["pops:renderRightContainer"]>(
|
|
2887
2905
|
<keyof PopsPanelEventType>"pops:renderRightContainer",
|
|
2888
2906
|
{
|
|
2889
2907
|
detail: {
|
|
2890
|
-
|
|
2908
|
+
viewConfig: dataViewConfig,
|
|
2891
2909
|
},
|
|
2892
2910
|
}
|
|
2893
2911
|
)
|
|
@@ -2895,19 +2913,19 @@ export const PanelHandlerComponents = () => {
|
|
|
2895
2913
|
},
|
|
2896
2914
|
/**
|
|
2897
2915
|
*
|
|
2898
|
-
* @param
|
|
2916
|
+
* @param viewConfig
|
|
2899
2917
|
* @param containerOptions
|
|
2900
2918
|
*/
|
|
2901
2919
|
uListContainerAddItem(
|
|
2902
|
-
|
|
2903
|
-
containerOptions: Omit<
|
|
2920
|
+
viewConfig: PopsPanelViewConfig,
|
|
2921
|
+
containerOptions: Omit<PopsPanelRightAsideContainerConfig, "target">
|
|
2904
2922
|
) {
|
|
2905
|
-
const itemLiElement = this.createSectionContainerItem(
|
|
2923
|
+
const itemLiElement = this.createSectionContainerItem(viewConfig);
|
|
2906
2924
|
if (itemLiElement) {
|
|
2907
2925
|
containerOptions["ulElement"].appendChild(itemLiElement);
|
|
2908
2926
|
}
|
|
2909
|
-
if (typeof
|
|
2910
|
-
|
|
2927
|
+
if (typeof viewConfig.afterAddToUListCallBack === "function") {
|
|
2928
|
+
viewConfig.afterAddToUListCallBack(viewConfig as any, {
|
|
2911
2929
|
...containerOptions,
|
|
2912
2930
|
target: itemLiElement,
|
|
2913
2931
|
});
|
|
@@ -2931,13 +2949,13 @@ export const PanelHandlerComponents = () => {
|
|
|
2931
2949
|
}
|
|
2932
2950
|
}
|
|
2933
2951
|
this.clearContainer();
|
|
2934
|
-
const
|
|
2952
|
+
const rightContainerViewConfig: PopsPanelContentConfig[] = Reflect.get($asideItem, "__forms__");
|
|
2935
2953
|
|
|
2936
|
-
Reflect.set(this.$el.$panelContentSectionContainer,
|
|
2954
|
+
Reflect.set(this.$el.$panelContentSectionContainer, this.$data.nodeStoreConfigKey, rightContainerViewConfig);
|
|
2937
2955
|
popsDOMUtils.cssShow(this.$el.$panelContentSectionContainer);
|
|
2938
2956
|
this.clearAsideItemIsVisited();
|
|
2939
2957
|
this.setAsideItemIsVisited($asideItem);
|
|
2940
|
-
|
|
2958
|
+
// 顶部标题栏,存在就设置
|
|
2941
2959
|
const title = typeof asideConfig.title === "function" ? asideConfig.title() : asideConfig.title;
|
|
2942
2960
|
let headerTitleText =
|
|
2943
2961
|
typeof asideConfig.headerTitle === "function" ? asideConfig.headerTitle() : asideConfig.headerTitle;
|
|
@@ -2950,12 +2968,12 @@ export const PanelHandlerComponents = () => {
|
|
|
2950
2968
|
this.sectionContainerHeaderULElement.appendChild($containerHeaderTitle);
|
|
2951
2969
|
}
|
|
2952
2970
|
|
|
2953
|
-
|
|
2954
|
-
this.createSectionContainerItem_forms(
|
|
2971
|
+
rightContainerViewConfig.forEach((viewConfig) => {
|
|
2972
|
+
this.createSectionContainerItem_forms(viewConfig);
|
|
2955
2973
|
});
|
|
2956
2974
|
|
|
2957
2975
|
if (typeof asideConfig.clickCallback === "function") {
|
|
2958
|
-
|
|
2976
|
+
// 执行回调
|
|
2959
2977
|
const asideClickCallbackResult = await asideConfig.clickCallback(
|
|
2960
2978
|
event,
|
|
2961
2979
|
this.sectionContainerHeaderULElement,
|