@whitesev/pops 2.6.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +2513 -1534
- 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 +2513 -1534
- 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 +2513 -1534
- 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 +2513 -1534
- 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 +2513 -1534
- 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 +2513 -1534
- 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 +449 -103
- package/dist/types/src/PopsCSS.d.ts +3 -1
- package/dist/types/src/PopsIcon.d.ts +1 -1
- 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 +988 -49
- package/dist/types/src/components/panel/index.d.ts +2 -2
- 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 +14 -14
- package/dist/types/src/components/panel/types/components-input.d.ts +46 -21
- package/dist/types/src/components/panel/types/components-own.d.ts +5 -5
- package/dist/types/src/components/panel/types/components-select.d.ts +95 -36
- package/dist/types/src/components/panel/types/components-selectMultiple.d.ts +15 -20
- package/dist/types/src/components/panel/types/components-slider.d.ts +7 -8
- 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 +24 -9
- 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 +4 -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 +12 -12
- package/src/Pops.ts +44 -44
- package/src/PopsAnimation.ts +1 -1
- package/src/PopsCSS.ts +4 -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/css/components-select.css +84 -0
- package/src/components/panel/defaultConfig.ts +818 -0
- package/src/components/panel/handlerComponents.ts +1431 -762
- package/src/components/panel/index.css +90 -6
- 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 +14 -14
- package/src/components/panel/types/components-input.ts +56 -21
- package/src/components/panel/types/components-own.ts +5 -5
- package/src/components/panel/types/components-select.ts +100 -38
- package/src/components/panel/types/components-selectMultiple.ts +16 -22
- package/src/components/panel/types/components-slider.ts +7 -8
- 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 +130 -155
- 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/handler/PopsElementHandler.ts +29 -30
- package/src/handler/PopsHandler.ts +43 -43
- 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 +4 -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/config.ts +0 -530
- package/src/components/panel/types/components-forms.ts +0 -24
|
@@ -7,28 +7,29 @@ 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, PopsPanelInputType } 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, PopsPanelSelectDataOption } 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
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
32
33
|
/**
|
|
33
34
|
* 处理组件(把组件配置转为组件元素)
|
|
34
35
|
*/
|
|
@@ -69,13 +70,16 @@ export const PanelHandlerComponents = () => {
|
|
|
69
70
|
$panelBottomLeftContainer: null as any as HTMLElement,
|
|
70
71
|
$panelBottomRightContainer: null as any as HTMLElement,
|
|
71
72
|
},
|
|
72
|
-
$
|
|
73
|
+
$data: {
|
|
74
|
+
nodeStoreConfigKey: "data-view-config",
|
|
75
|
+
},
|
|
76
|
+
$config: {} as Required<PopsPanelConfig>,
|
|
73
77
|
/**
|
|
74
78
|
* 初始化
|
|
75
|
-
* @param
|
|
79
|
+
* @param data
|
|
76
80
|
*/
|
|
77
|
-
init(
|
|
78
|
-
config: Required<
|
|
81
|
+
init(data: {
|
|
82
|
+
config: Required<PopsPanelConfig>;
|
|
79
83
|
$el: {
|
|
80
84
|
$pops: HTMLElement;
|
|
81
85
|
$content: HTMLElement;
|
|
@@ -90,9 +94,9 @@ export const PanelHandlerComponents = () => {
|
|
|
90
94
|
}) {
|
|
91
95
|
const PopsType = "panel";
|
|
92
96
|
this.$el = {
|
|
93
|
-
...
|
|
97
|
+
...data.$el,
|
|
94
98
|
};
|
|
95
|
-
this.$config =
|
|
99
|
+
this.$config = data.config;
|
|
96
100
|
|
|
97
101
|
this.asideULElement = this.$el.$panelLeftAside.querySelector<HTMLUListElement>(
|
|
98
102
|
`ul.pops-${PopsType}-aside-top-container`
|
|
@@ -113,9 +117,9 @@ export const PanelHandlerComponents = () => {
|
|
|
113
117
|
/** 是否滚动到默认位置(第一个项) */
|
|
114
118
|
let isScrollToDefaultView = false;
|
|
115
119
|
// 初始化内容配置
|
|
116
|
-
|
|
120
|
+
data.config.content.forEach((asideItemConfig) => {
|
|
117
121
|
const $asideLiElement = this.createAsideItem(asideItemConfig);
|
|
118
|
-
this.
|
|
122
|
+
this.onAsideItemClick($asideLiElement, asideItemConfig);
|
|
119
123
|
// 是否处于底部
|
|
120
124
|
const isBottom =
|
|
121
125
|
typeof asideItemConfig.isBottom === "function" ? asideItemConfig.isBottom() : asideItemConfig.isBottom;
|
|
@@ -145,9 +149,9 @@ export const PanelHandlerComponents = () => {
|
|
|
145
149
|
}
|
|
146
150
|
});
|
|
147
151
|
// 初始化底部内容配置
|
|
148
|
-
(
|
|
152
|
+
(data.config?.bottomContentConfig || []).forEach((bottomItemConfig) => {
|
|
149
153
|
const $bottomLiElement = this.createBottomItem(bottomItemConfig);
|
|
150
|
-
this.
|
|
154
|
+
this.onBottomItemClick($bottomLiElement, bottomItemConfig);
|
|
151
155
|
if (bottomItemConfig.position === "left" || bottomItemConfig.position == null) {
|
|
152
156
|
this.$el.$panelBottomLeftContainer.appendChild($bottomLiElement);
|
|
153
157
|
} else if (bottomItemConfig.position === "right") {
|
|
@@ -166,13 +170,13 @@ export const PanelHandlerComponents = () => {
|
|
|
166
170
|
}
|
|
167
171
|
});
|
|
168
172
|
|
|
169
|
-
|
|
173
|
+
// 点击左侧列表
|
|
170
174
|
if ($defaultAsideItem == null && this.asideULElement.children.length) {
|
|
171
|
-
|
|
175
|
+
// 默认第一个
|
|
172
176
|
$defaultAsideItem = <HTMLLIElement>this.asideULElement.children[0];
|
|
173
177
|
}
|
|
174
178
|
if ($defaultAsideItem) {
|
|
175
|
-
|
|
179
|
+
// 点击选择的那一项
|
|
176
180
|
$defaultAsideItem.click();
|
|
177
181
|
if (isScrollToDefaultView) {
|
|
178
182
|
$defaultAsideItem?.scrollIntoView();
|
|
@@ -185,7 +189,7 @@ export const PanelHandlerComponents = () => {
|
|
|
185
189
|
* 清空container容器的元素
|
|
186
190
|
*/
|
|
187
191
|
clearContainer() {
|
|
188
|
-
Reflect.deleteProperty(this.$el.$panelContentSectionContainer,
|
|
192
|
+
Reflect.deleteProperty(this.$el.$panelContentSectionContainer, this.$data.nodeStoreConfigKey);
|
|
189
193
|
PopsSafeUtils.setSafeHTML(this.sectionContainerHeaderULElement, "");
|
|
190
194
|
PopsSafeUtils.setSafeHTML(this.sectionContainerULElement, "");
|
|
191
195
|
this.clearDeepMenuContainer();
|
|
@@ -255,7 +259,7 @@ export const PanelHandlerComponents = () => {
|
|
|
255
259
|
* @param $el 元素
|
|
256
260
|
* @param className
|
|
257
261
|
*/
|
|
258
|
-
setElementClassName($el: HTMLElement, className?:
|
|
262
|
+
setElementClassName($el: HTMLElement, className?: PopsPanelGeneralConfig<any>["className"]) {
|
|
259
263
|
popsDOMUtils.addClassName($el, className);
|
|
260
264
|
},
|
|
261
265
|
/**
|
|
@@ -272,9 +276,9 @@ export const PanelHandlerComponents = () => {
|
|
|
272
276
|
className: ["pops-panel-bottom-item", "pops-user-select-none", className].join(" "),
|
|
273
277
|
innerHTML: text,
|
|
274
278
|
});
|
|
275
|
-
|
|
279
|
+
// 处理attr
|
|
276
280
|
this.setElementAttributes($li, bottomItemConfig.attributes);
|
|
277
|
-
|
|
281
|
+
// 处理props
|
|
278
282
|
this.setElementProps($li, bottomItemConfig.props);
|
|
279
283
|
/** 禁用左侧项的hover的CSS样式的类名 */
|
|
280
284
|
const disablHoverCSSClassName = "pops-panel-disable-bottom-item-hover-css";
|
|
@@ -295,10 +299,10 @@ export const PanelHandlerComponents = () => {
|
|
|
295
299
|
* @param $bottomItem 底部<li>元素
|
|
296
300
|
* @param bottomItemConfig 配置
|
|
297
301
|
*/
|
|
298
|
-
|
|
302
|
+
onBottomItemClick($bottomItem: HTMLElement, bottomItemConfig: PopsPanelBottomContentConfig) {
|
|
299
303
|
popsDOMUtils.on<MouseEvent | PointerEvent>($bottomItem, "click", async (event) => {
|
|
300
304
|
if (typeof bottomItemConfig.clickCallback === "function") {
|
|
301
|
-
|
|
305
|
+
// 执行回调
|
|
302
306
|
const asideClickCallbackResult = await bottomItemConfig.clickCallback(event);
|
|
303
307
|
if (typeof asideClickCallbackResult === "boolean" && !asideClickCallbackResult) {
|
|
304
308
|
return;
|
|
@@ -317,13 +321,13 @@ export const PanelHandlerComponents = () => {
|
|
|
317
321
|
id: asideConfig.id,
|
|
318
322
|
innerHTML: text,
|
|
319
323
|
});
|
|
320
|
-
Reflect.set($li, "__forms__", asideConfig.
|
|
321
|
-
|
|
324
|
+
Reflect.set($li, "__forms__", asideConfig.views);
|
|
325
|
+
// 处理className
|
|
322
326
|
this.setElementClassName($li, "pops-panel-aside-item");
|
|
323
327
|
this.setElementClassName($li, asideConfig.className);
|
|
324
|
-
|
|
328
|
+
// 处理attr
|
|
325
329
|
this.setElementAttributes($li, asideConfig.attributes);
|
|
326
|
-
|
|
330
|
+
// 处理props
|
|
327
331
|
this.setElementProps($li, asideConfig.props);
|
|
328
332
|
/** 禁用左侧项的hover的CSS样式的类名 */
|
|
329
333
|
const disablHoverCSSClassName = "pops-panel-disabled-aside-hover-css";
|
|
@@ -342,24 +346,24 @@ export const PanelHandlerComponents = () => {
|
|
|
342
346
|
/**
|
|
343
347
|
* type ==> switch
|
|
344
348
|
* 创建中间容器的元素<li>
|
|
345
|
-
* @param
|
|
349
|
+
* @param viewConfig
|
|
346
350
|
*/
|
|
347
|
-
createSectionContainerItem_switch(
|
|
351
|
+
createSectionContainerItem_switch(viewConfig: PopsPanelSwitchConfig) {
|
|
348
352
|
const $li = popsDOMUtils.createElement("li");
|
|
349
|
-
Reflect.set($li,
|
|
350
|
-
this.setElementClassName($li,
|
|
351
|
-
this.setElementAttributes($li,
|
|
352
|
-
this.setElementProps($li,
|
|
353
|
-
|
|
353
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
354
|
+
this.setElementClassName($li, viewConfig.className);
|
|
355
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
356
|
+
this.setElementProps($li, viewConfig.props);
|
|
357
|
+
// 左边底部的描述的文字
|
|
354
358
|
let leftDescriptionText = "";
|
|
355
|
-
if (
|
|
356
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
359
|
+
if (viewConfig.description) {
|
|
360
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
357
361
|
}
|
|
358
362
|
PopsSafeUtils.setSafeHTML(
|
|
359
363
|
$li,
|
|
360
364
|
/*html*/ `
|
|
361
365
|
<div class="pops-panel-item-left-text">
|
|
362
|
-
<p class="pops-panel-item-left-main-text">${
|
|
366
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
363
367
|
<div class="pops-panel-switch">
|
|
364
368
|
<input class="pops-panel-switch__input" type="checkbox">
|
|
365
369
|
<span class="pops-panel-switch__core">
|
|
@@ -371,7 +375,7 @@ export const PanelHandlerComponents = () => {
|
|
|
371
375
|
const PopsPanelSwitch = {
|
|
372
376
|
[Symbol.toStringTag]: "PopsPanelSwitch",
|
|
373
377
|
$data: {
|
|
374
|
-
value: Boolean(
|
|
378
|
+
value: Boolean(viewConfig.getValue()),
|
|
375
379
|
},
|
|
376
380
|
$ele: {
|
|
377
381
|
itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
|
|
@@ -381,16 +385,16 @@ export const PanelHandlerComponents = () => {
|
|
|
381
385
|
},
|
|
382
386
|
init() {
|
|
383
387
|
this.setStatus(this.$data.value);
|
|
384
|
-
const disabled = typeof
|
|
388
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
385
389
|
if (disabled) {
|
|
386
390
|
this.disable();
|
|
387
391
|
}
|
|
388
|
-
this.
|
|
392
|
+
this.onClick();
|
|
389
393
|
},
|
|
390
394
|
/**
|
|
391
395
|
* 设置点击事件
|
|
392
396
|
*/
|
|
393
|
-
|
|
397
|
+
onClick() {
|
|
394
398
|
const that = this;
|
|
395
399
|
popsDOMUtils.on(this.$ele.core, "click", function (event) {
|
|
396
400
|
if (that.$ele.input.disabled || that.$ele.switch.hasAttribute("data-disabled")) {
|
|
@@ -398,8 +402,8 @@ export const PanelHandlerComponents = () => {
|
|
|
398
402
|
}
|
|
399
403
|
that.$data.value = that.getStatus();
|
|
400
404
|
that.setStatus(that.$data.value);
|
|
401
|
-
if (typeof
|
|
402
|
-
|
|
405
|
+
if (typeof viewConfig.callback === "function") {
|
|
406
|
+
viewConfig.callback(event, that.$data.value);
|
|
403
407
|
}
|
|
404
408
|
});
|
|
405
409
|
},
|
|
@@ -445,93 +449,32 @@ export const PanelHandlerComponents = () => {
|
|
|
445
449
|
|
|
446
450
|
PopsPanelSwitch.init();
|
|
447
451
|
Reflect.set($li, "data-switch", PopsPanelSwitch);
|
|
448
|
-
return
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
* type ==> slider
|
|
452
|
-
* 获取中间容器的元素<li>
|
|
453
|
-
* @param formConfig
|
|
454
|
-
*/
|
|
455
|
-
createSectionContainerItem_slider(formConfig: PopsPanelSliderDetails) {
|
|
456
|
-
const $li = popsDOMUtils.createElement("li");
|
|
457
|
-
Reflect.set($li, "__formConfig__", formConfig);
|
|
458
|
-
this.setElementClassName($li, formConfig.className);
|
|
459
|
-
this.setElementAttributes($li, formConfig.attributes);
|
|
460
|
-
this.setElementProps($li, formConfig.props);
|
|
461
|
-
/* 左边底部的描述的文字 */
|
|
462
|
-
let leftDescriptionText = "";
|
|
463
|
-
if (formConfig.description) {
|
|
464
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
465
|
-
}
|
|
466
|
-
PopsSafeUtils.setSafeHTML(
|
|
467
|
-
$li,
|
|
468
|
-
/*html*/ `
|
|
469
|
-
<div class="pops-panel-item-left-text">
|
|
470
|
-
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>${leftDescriptionText}</div>
|
|
471
|
-
<div class="pops-panel-slider">
|
|
472
|
-
<input type="range" min="${formConfig.min}" max="${formConfig.max}">
|
|
473
|
-
</div>
|
|
474
|
-
`
|
|
475
|
-
);
|
|
476
|
-
const $rangeInput = $li.querySelector<HTMLInputElement>(".pops-panel-slider input[type=range]")!;
|
|
477
|
-
if (formConfig.step) {
|
|
478
|
-
$rangeInput.setAttribute("step", formConfig.step.toString());
|
|
479
|
-
}
|
|
480
|
-
$rangeInput.value = formConfig.getValue().toString();
|
|
481
|
-
/**
|
|
482
|
-
* 获取提示的内容
|
|
483
|
-
* @param value
|
|
484
|
-
*/
|
|
485
|
-
const getToolTipContent = function (value: number | string) {
|
|
486
|
-
if (typeof formConfig.getToolTipContent === "function") {
|
|
487
|
-
return formConfig.getToolTipContent(value as number);
|
|
488
|
-
} else {
|
|
489
|
-
return value as string;
|
|
490
|
-
}
|
|
452
|
+
return {
|
|
453
|
+
$el: $li,
|
|
454
|
+
handler: PopsPanelSwitch,
|
|
491
455
|
};
|
|
492
|
-
const tooltip = PopsTooltip.init({
|
|
493
|
-
target: $rangeInput.parentElement!,
|
|
494
|
-
content: () => {
|
|
495
|
-
return getToolTipContent($rangeInput.value);
|
|
496
|
-
},
|
|
497
|
-
zIndex: () => {
|
|
498
|
-
return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
|
|
499
|
-
},
|
|
500
|
-
className: "github-tooltip",
|
|
501
|
-
alwaysShow: false,
|
|
502
|
-
only: false,
|
|
503
|
-
position: "top",
|
|
504
|
-
arrowDistance: 10,
|
|
505
|
-
});
|
|
506
|
-
popsDOMUtils.on<InputEvent>($rangeInput, ["input", "propertychange"], void 0, function (event) {
|
|
507
|
-
tooltip.toolTip.changeContent(getToolTipContent($rangeInput.value));
|
|
508
|
-
if (typeof formConfig.callback === "function") {
|
|
509
|
-
formConfig.callback(event, $rangeInput.valueAsNumber);
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
return $li;
|
|
513
456
|
},
|
|
514
457
|
/**
|
|
515
458
|
* type ==> slider
|
|
516
459
|
* 获取中间容器的元素<li>
|
|
517
|
-
* @param
|
|
460
|
+
* @param viewConfig
|
|
518
461
|
*/
|
|
519
|
-
createSectionContainerItem_slider_new(
|
|
462
|
+
createSectionContainerItem_slider_new(viewConfig: PopsPanelSliderConfig) {
|
|
520
463
|
const $li = popsDOMUtils.createElement("li");
|
|
521
|
-
Reflect.set($li,
|
|
522
|
-
this.setElementClassName($li,
|
|
523
|
-
this.setElementAttributes($li,
|
|
524
|
-
this.setElementProps($li,
|
|
525
|
-
|
|
464
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
465
|
+
this.setElementClassName($li, viewConfig.className);
|
|
466
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
467
|
+
this.setElementProps($li, viewConfig.props);
|
|
468
|
+
// 左边底部的描述的文字
|
|
526
469
|
let leftDescriptionText = "";
|
|
527
|
-
if (
|
|
528
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
470
|
+
if (viewConfig.description) {
|
|
471
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
529
472
|
}
|
|
530
473
|
PopsSafeUtils.setSafeHTML(
|
|
531
474
|
$li,
|
|
532
475
|
/*html*/ `
|
|
533
476
|
<div class="pops-panel-item-left-text" style="flex: 1;">
|
|
534
|
-
<p class="pops-panel-item-left-main-text">${
|
|
477
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
535
478
|
<div class="pops-slider pops-slider-width">
|
|
536
479
|
<div class="pops-slider__runway">
|
|
537
480
|
<div class="pops-slider__bar" style="width: 0%; left: 0%"></div>
|
|
@@ -546,19 +489,19 @@ export const PanelHandlerComponents = () => {
|
|
|
546
489
|
/**
|
|
547
490
|
* 值
|
|
548
491
|
*/
|
|
549
|
-
value:
|
|
492
|
+
value: viewConfig.getValue(),
|
|
550
493
|
/**
|
|
551
494
|
* 最小值
|
|
552
495
|
*/
|
|
553
|
-
min:
|
|
496
|
+
min: viewConfig.min,
|
|
554
497
|
/**
|
|
555
498
|
* 最大值
|
|
556
499
|
*/
|
|
557
|
-
max:
|
|
500
|
+
max: viewConfig.max,
|
|
558
501
|
/**
|
|
559
502
|
* 间隔
|
|
560
503
|
*/
|
|
561
|
-
step:
|
|
504
|
+
step: viewConfig.step || 1,
|
|
562
505
|
$data: {
|
|
563
506
|
/**
|
|
564
507
|
* 是否正在移动
|
|
@@ -628,9 +571,9 @@ export const PanelHandlerComponents = () => {
|
|
|
628
571
|
this.initEleData();
|
|
629
572
|
this.setToolTipEvent();
|
|
630
573
|
this.setPanEvent();
|
|
631
|
-
this.
|
|
574
|
+
this.onRunAwayClick();
|
|
632
575
|
this.intervalInit();
|
|
633
|
-
if (this.
|
|
576
|
+
if (this.isDisabledDragWithConfig()) {
|
|
634
577
|
this.disableDrag();
|
|
635
578
|
}
|
|
636
579
|
},
|
|
@@ -658,7 +601,7 @@ export const PanelHandlerComponents = () => {
|
|
|
658
601
|
if (this.$data.totalWidth !== 0) {
|
|
659
602
|
isSuccess = true;
|
|
660
603
|
if (this.$data.totalWidth !== oldTotalWidth) {
|
|
661
|
-
|
|
604
|
+
// slider的总宽度改变了
|
|
662
605
|
if (PopsMathFloatUtils.isFloat(this.step)) {
|
|
663
606
|
this.initFloatStepMap();
|
|
664
607
|
} else {
|
|
@@ -669,7 +612,7 @@ export const PanelHandlerComponents = () => {
|
|
|
669
612
|
}
|
|
670
613
|
}
|
|
671
614
|
}, checkStepTime);
|
|
672
|
-
|
|
615
|
+
// 最长检测时间是10s
|
|
673
616
|
timer = setTimeout(() => {
|
|
674
617
|
clearInterval(interval);
|
|
675
618
|
}, maxTime);
|
|
@@ -707,7 +650,7 @@ export const PanelHandlerComponents = () => {
|
|
|
707
650
|
const value = this.formatValue(stepValue);
|
|
708
651
|
let info;
|
|
709
652
|
if (value === this.min) {
|
|
710
|
-
|
|
653
|
+
// 起始
|
|
711
654
|
info = {
|
|
712
655
|
value: value,
|
|
713
656
|
px: 0,
|
|
@@ -753,7 +696,7 @@ export const PanelHandlerComponents = () => {
|
|
|
753
696
|
const value = this.formatValue(stepValue);
|
|
754
697
|
let info;
|
|
755
698
|
if (value === this.min) {
|
|
756
|
-
|
|
699
|
+
// 起始
|
|
757
700
|
info = {
|
|
758
701
|
value: value,
|
|
759
702
|
px: 0,
|
|
@@ -785,10 +728,10 @@ export const PanelHandlerComponents = () => {
|
|
|
785
728
|
* 初始化slider的默认起始left的百分比值
|
|
786
729
|
*/
|
|
787
730
|
initSliderPosition() {
|
|
788
|
-
|
|
731
|
+
// 设置起始默认style的left值
|
|
789
732
|
let percent = 0;
|
|
790
733
|
for (const [, stepBlockInfo] of this.$data.stepBlockMap.entries()) {
|
|
791
|
-
|
|
734
|
+
// 判断值是否和区域内的值相等
|
|
792
735
|
if (stepBlockInfo.value == this.value) {
|
|
793
736
|
percent = stepBlockInfo.percent;
|
|
794
737
|
this.$data.dragWidth = stepBlockInfo.px;
|
|
@@ -811,8 +754,8 @@ export const PanelHandlerComponents = () => {
|
|
|
811
754
|
* @param value
|
|
812
755
|
*/
|
|
813
756
|
valueChangeCallBack(event: any, value: number) {
|
|
814
|
-
if (typeof
|
|
815
|
-
|
|
757
|
+
if (typeof viewConfig.callback === "function") {
|
|
758
|
+
viewConfig.callback(event, value);
|
|
816
759
|
}
|
|
817
760
|
},
|
|
818
761
|
/**
|
|
@@ -859,9 +802,9 @@ export const PanelHandlerComponents = () => {
|
|
|
859
802
|
if (percent > 1) {
|
|
860
803
|
percent = percent / 100;
|
|
861
804
|
}
|
|
862
|
-
|
|
805
|
+
// 滑块按钮的偏移
|
|
863
806
|
this.$ele.buttonWrapper.style.left = `${percent * 100}%`;
|
|
864
|
-
|
|
807
|
+
// 滑块进度的宽度
|
|
865
808
|
this.$ele.bar.style.width = `${percent * 100}%`;
|
|
866
809
|
},
|
|
867
810
|
/**
|
|
@@ -887,8 +830,8 @@ export const PanelHandlerComponents = () => {
|
|
|
887
830
|
/**
|
|
888
831
|
* 判断当前滑块是否被禁用(配置中判断)
|
|
889
832
|
*/
|
|
890
|
-
|
|
891
|
-
const isDisabled = typeof
|
|
833
|
+
isDisabledDragWithConfig() {
|
|
834
|
+
const isDisabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
892
835
|
if (typeof isDisabled === "boolean") {
|
|
893
836
|
return isDisabled;
|
|
894
837
|
} else {
|
|
@@ -898,7 +841,7 @@ export const PanelHandlerComponents = () => {
|
|
|
898
841
|
/**
|
|
899
842
|
* 设置进度条点击定位的事件
|
|
900
843
|
*/
|
|
901
|
-
|
|
844
|
+
onRunAwayClick() {
|
|
902
845
|
popsDOMUtils.on<PointerEvent | MouseEvent>(
|
|
903
846
|
this.$ele.runAway,
|
|
904
847
|
"click",
|
|
@@ -923,7 +866,7 @@ export const PanelHandlerComponents = () => {
|
|
|
923
866
|
* 拖拽开始的回调,如果返回false,禁止拖拽
|
|
924
867
|
*/
|
|
925
868
|
dragStartCallBack() {
|
|
926
|
-
if (this.
|
|
869
|
+
if (this.isDisabledDragWithConfig()) {
|
|
927
870
|
// 禁止
|
|
928
871
|
this.disableDrag();
|
|
929
872
|
return false;
|
|
@@ -993,7 +936,7 @@ export const PanelHandlerComponents = () => {
|
|
|
993
936
|
* 当前的拖拽的距离px
|
|
994
937
|
*/
|
|
995
938
|
let currentDragX = 0;
|
|
996
|
-
|
|
939
|
+
// 监听拖拽
|
|
997
940
|
this.$tooltip.on("at:move", (event) => {
|
|
998
941
|
if (!this.dragStartCallBack()) {
|
|
999
942
|
return;
|
|
@@ -1007,10 +950,10 @@ export const PanelHandlerComponents = () => {
|
|
|
1007
950
|
displacementX = runAwayRect.width;
|
|
1008
951
|
}
|
|
1009
952
|
currentDragX = displacementX;
|
|
1010
|
-
|
|
953
|
+
// 拖拽移动
|
|
1011
954
|
this.dragMoveCallBack(event, currentDragX, oldValue);
|
|
1012
955
|
});
|
|
1013
|
-
|
|
956
|
+
// 监听触点离开,处理某些情况下,拖拽松开,但是未触发pan事件,可以通过设置这个来关闭tooltip
|
|
1014
957
|
this.$tooltip.on("at:end", () => {
|
|
1015
958
|
this.dragEndCallBack(currentDragX);
|
|
1016
959
|
});
|
|
@@ -1055,15 +998,15 @@ export const PanelHandlerComponents = () => {
|
|
|
1055
998
|
* 获取提示的内容
|
|
1056
999
|
*/
|
|
1057
1000
|
function getToolTipContent() {
|
|
1058
|
-
if (typeof
|
|
1059
|
-
return
|
|
1001
|
+
if (typeof viewConfig.getToolTipContent === "function") {
|
|
1002
|
+
return viewConfig.getToolTipContent(PopsPanelSlider.value);
|
|
1060
1003
|
} else {
|
|
1061
1004
|
return PopsPanelSlider.value.toString();
|
|
1062
1005
|
}
|
|
1063
1006
|
}
|
|
1064
1007
|
|
|
1065
1008
|
const tooltip = PopsTooltip.init({
|
|
1066
|
-
target: this.$ele.button,
|
|
1009
|
+
$target: this.$ele.button,
|
|
1067
1010
|
content: getToolTipContent,
|
|
1068
1011
|
zIndex: () => {
|
|
1069
1012
|
return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
|
|
@@ -1077,10 +1020,10 @@ export const PanelHandlerComponents = () => {
|
|
|
1077
1020
|
},
|
|
1078
1021
|
showBeforeCallBack: () => {
|
|
1079
1022
|
const isShowHoverTip =
|
|
1080
|
-
typeof
|
|
1081
|
-
?
|
|
1082
|
-
: typeof
|
|
1083
|
-
?
|
|
1023
|
+
typeof viewConfig.isShowHoverTip === "function"
|
|
1024
|
+
? viewConfig.isShowHoverTip()
|
|
1025
|
+
: typeof viewConfig.isShowHoverTip === "boolean"
|
|
1026
|
+
? viewConfig.isShowHoverTip
|
|
1084
1027
|
: true;
|
|
1085
1028
|
if (!isShowHoverTip) {
|
|
1086
1029
|
return false;
|
|
@@ -1105,238 +1048,349 @@ export const PanelHandlerComponents = () => {
|
|
|
1105
1048
|
};
|
|
1106
1049
|
PopsPanelSlider.init();
|
|
1107
1050
|
Reflect.set($li, "data-slider", PopsPanelSlider);
|
|
1108
|
-
return
|
|
1051
|
+
return {
|
|
1052
|
+
$el: $li,
|
|
1053
|
+
handler: PopsPanelSlider,
|
|
1054
|
+
};
|
|
1109
1055
|
},
|
|
1110
1056
|
/**
|
|
1111
1057
|
* type ==> input
|
|
1112
1058
|
* 获取中间容器的元素<li>
|
|
1113
|
-
* @param
|
|
1059
|
+
* @param viewConfig
|
|
1114
1060
|
*/
|
|
1115
|
-
createSectionContainerItem_input(
|
|
1061
|
+
createSectionContainerItem_input(viewConfig: PopsPanelInputConfig) {
|
|
1116
1062
|
const $li = popsDOMUtils.createElement("li");
|
|
1117
|
-
Reflect.set($li,
|
|
1118
|
-
this.setElementClassName($li,
|
|
1119
|
-
this.setElementAttributes($li,
|
|
1120
|
-
this.setElementProps($li,
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
} else if (formConfig.isNumber) {
|
|
1125
|
-
inputType = "number";
|
|
1126
|
-
}
|
|
1127
|
-
/* 左边底部的描述的文字 */
|
|
1063
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
1064
|
+
this.setElementClassName($li, viewConfig.className);
|
|
1065
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
1066
|
+
this.setElementProps($li, viewConfig.props);
|
|
1067
|
+
const defaultInputType: PopsPanelInputType = "text";
|
|
1068
|
+
const inputType = viewConfig.inputType || defaultInputType;
|
|
1069
|
+
// 左边底部的描述的文字
|
|
1128
1070
|
let leftDescriptionText = "";
|
|
1129
|
-
if (
|
|
1130
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${
|
|
1071
|
+
if (viewConfig.description) {
|
|
1072
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
1131
1073
|
}
|
|
1132
1074
|
PopsSafeUtils.setSafeHTML(
|
|
1133
1075
|
$li,
|
|
1134
1076
|
/*html*/ `
|
|
1135
1077
|
<div class="pops-panel-item-left-text">
|
|
1136
|
-
<p class="pops-panel-item-left-main-text">${
|
|
1078
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
1137
1079
|
<div class="pops-panel-input">
|
|
1138
|
-
|
|
1080
|
+
<div class="pops-panel-input_inner">
|
|
1081
|
+
<input type="${inputType}" placeholder="${viewConfig.placeholder ?? ""}">
|
|
1082
|
+
</div>
|
|
1139
1083
|
</div>
|
|
1140
1084
|
`
|
|
1141
1085
|
);
|
|
1142
1086
|
const PopsPanelInput = {
|
|
1143
1087
|
[Symbol.toStringTag]: "PopsPanelInput",
|
|
1144
|
-
$
|
|
1088
|
+
$el: {
|
|
1145
1089
|
itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
|
|
1146
1090
|
panelInput: $li.querySelector<HTMLDivElement>(".pops-panel-input")!,
|
|
1091
|
+
panelInputInner: $li.querySelector<HTMLDivElement>(".pops-panel-input_inner")!,
|
|
1147
1092
|
input: $li.querySelector<HTMLInputElement>("input")!,
|
|
1148
|
-
|
|
1149
|
-
|
|
1093
|
+
/** span.pops-panel-input__suffix */
|
|
1094
|
+
suffix: popsDOMUtils.createElement("span"),
|
|
1095
|
+
/** span.pops-panel-input__suffix-inner */
|
|
1096
|
+
suffixInner: null as any as HTMLSpanElement,
|
|
1097
|
+
/** i.pops-panel-icon */
|
|
1150
1098
|
icon: null as any as HTMLElement,
|
|
1151
1099
|
},
|
|
1152
1100
|
$data: {
|
|
1153
|
-
value:
|
|
1154
|
-
|
|
1101
|
+
value: viewConfig.getValue(),
|
|
1102
|
+
/**
|
|
1103
|
+
* inputType 为 password时使用该值
|
|
1104
|
+
*
|
|
1105
|
+
* 当前内容的可见性
|
|
1106
|
+
*/
|
|
1107
|
+
isVisible: false,
|
|
1155
1108
|
},
|
|
1156
1109
|
init() {
|
|
1157
1110
|
this.initEle();
|
|
1158
1111
|
this.setInputValue(this.$data.value);
|
|
1159
|
-
|
|
1160
|
-
if (
|
|
1112
|
+
// 如果是密码框,放进图标
|
|
1113
|
+
if (viewConfig.inputType === "password") {
|
|
1114
|
+
// 显示密码
|
|
1161
1115
|
this.setCircleIcon(PopsIcon.getIcon("view")!);
|
|
1162
|
-
this.
|
|
1116
|
+
this.onIconClick();
|
|
1163
1117
|
} else {
|
|
1164
|
-
|
|
1165
|
-
|
|
1118
|
+
// 先判断预设值是否为空,不为空添加清空图标按钮
|
|
1119
|
+
// 且为普通的输入框
|
|
1120
|
+
if (this.$el.input.value != "" && this.isTextInputType()) {
|
|
1121
|
+
// 清除内容的图标
|
|
1166
1122
|
this.setCircleIcon(PopsIcon.getIcon("circleClose")!);
|
|
1167
|
-
this.
|
|
1123
|
+
this.onIconClick();
|
|
1124
|
+
} else {
|
|
1125
|
+
// 隐藏图标
|
|
1126
|
+
this.hideCircleIconWrapper();
|
|
1168
1127
|
}
|
|
1169
1128
|
}
|
|
1170
1129
|
|
|
1171
|
-
this.
|
|
1130
|
+
this.onValueChange();
|
|
1172
1131
|
// 是否禁用复选框
|
|
1173
|
-
const disabled = typeof
|
|
1132
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
1174
1133
|
if (disabled) {
|
|
1175
1134
|
this.disable();
|
|
1176
1135
|
}
|
|
1177
|
-
if (typeof
|
|
1178
|
-
|
|
1136
|
+
if (typeof viewConfig.handlerCallBack === "function") {
|
|
1137
|
+
viewConfig.handlerCallBack($li, this.$el.input);
|
|
1179
1138
|
}
|
|
1180
1139
|
},
|
|
1181
1140
|
/**
|
|
1182
1141
|
* 初始化$ele的配置
|
|
1183
1142
|
*/
|
|
1184
1143
|
initEle() {
|
|
1185
|
-
this.$
|
|
1186
|
-
popsDOMUtils.addClassName(this.$
|
|
1144
|
+
this.$el.input.parentElement!.insertBefore(this.$el.suffix, this.$el.input.nextSibling);
|
|
1145
|
+
popsDOMUtils.addClassName(this.$el.suffix, "pops-panel-input__suffix");
|
|
1187
1146
|
PopsSafeUtils.setSafeHTML(
|
|
1188
|
-
this.$
|
|
1147
|
+
this.$el.suffix,
|
|
1189
1148
|
/*html*/ `
|
|
1190
1149
|
<span class="pops-panel-input__suffix-inner">
|
|
1191
1150
|
<i class="pops-panel-icon"></i>
|
|
1192
1151
|
</span>
|
|
1193
1152
|
`
|
|
1194
1153
|
);
|
|
1195
|
-
this.$
|
|
1196
|
-
|
|
1197
|
-
)
|
|
1198
|
-
|
|
1199
|
-
|
|
1154
|
+
this.$el.suffixInner = this.$el.suffix.querySelector<HTMLElement>(".pops-panel-input__suffix-inner")!;
|
|
1155
|
+
this.$el.icon = this.$el.suffix.querySelector<HTMLElement>(".pops-panel-icon")!;
|
|
1156
|
+
popsDOMUtils.addClassName(this.$el.panelInput, PopsCommonCSSClassName.userSelectNone);
|
|
1157
|
+
},
|
|
1158
|
+
/**
|
|
1159
|
+
* 校验输入框类型是否是字符串输入框类型
|
|
1160
|
+
*/
|
|
1161
|
+
isTextInputType() {
|
|
1162
|
+
const typeList: PopsPanelInputType[] = ["text", "search", "email", "tel", "url"];
|
|
1163
|
+
return typeList.includes(viewConfig.inputType || defaultInputType);
|
|
1164
|
+
},
|
|
1165
|
+
/**
|
|
1166
|
+
* 是否是时间输入框类型
|
|
1167
|
+
*/
|
|
1168
|
+
isDateInputType() {
|
|
1169
|
+
const typeList: PopsPanelInputType[] = ["date", "datetime-local", "month", "time", "week"];
|
|
1170
|
+
return typeList.includes(viewConfig.inputType || defaultInputType);
|
|
1171
|
+
},
|
|
1172
|
+
/**
|
|
1173
|
+
* 是否是数字输入框类型
|
|
1174
|
+
*/
|
|
1175
|
+
isNumberInputType() {
|
|
1176
|
+
const typeList: PopsPanelInputType[] = ["number"];
|
|
1177
|
+
return typeList.includes(viewConfig.inputType || defaultInputType);
|
|
1200
1178
|
},
|
|
1201
1179
|
/**
|
|
1202
1180
|
* 禁用
|
|
1203
1181
|
*/
|
|
1204
1182
|
disable() {
|
|
1205
|
-
this.$
|
|
1206
|
-
popsDOMUtils.addClassName(this.$
|
|
1207
|
-
popsDOMUtils.addClassName(this.$
|
|
1183
|
+
this.$el.input.disabled = true;
|
|
1184
|
+
popsDOMUtils.addClassName(this.$el.panelInput, "pops-input-disabled");
|
|
1185
|
+
popsDOMUtils.addClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
|
|
1208
1186
|
},
|
|
1209
1187
|
/**
|
|
1210
1188
|
* 取消禁用
|
|
1211
1189
|
*/
|
|
1212
1190
|
notDisable() {
|
|
1213
|
-
this.$
|
|
1214
|
-
popsDOMUtils.removeClassName(this.$
|
|
1215
|
-
popsDOMUtils.removeClassName(this.$
|
|
1191
|
+
this.$el.input.disabled = false;
|
|
1192
|
+
popsDOMUtils.removeClassName(this.$el.panelInput, "pops-input-disabled");
|
|
1193
|
+
popsDOMUtils.removeClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
|
|
1216
1194
|
},
|
|
1217
1195
|
/**
|
|
1218
1196
|
* 判断是否已被禁用
|
|
1219
1197
|
*/
|
|
1220
1198
|
isDisabled() {
|
|
1221
|
-
return this.$
|
|
1199
|
+
return this.$el.input.disabled;
|
|
1222
1200
|
},
|
|
1223
1201
|
/**
|
|
1224
1202
|
* 设置输入框内容
|
|
1225
|
-
* @param
|
|
1203
|
+
* @param value 值
|
|
1226
1204
|
*/
|
|
1227
|
-
setInputValue(value = "") {
|
|
1228
|
-
this
|
|
1205
|
+
setInputValue(value: string | number | Date = "") {
|
|
1206
|
+
if (typeof value === "number" && this.isNumberInputType()) {
|
|
1207
|
+
this.$el.input.valueAsNumber = value;
|
|
1208
|
+
} else if (typeof value === "object" && value instanceof Date && this.isDateInputType()) {
|
|
1209
|
+
this.$el.input.valueAsDate = value;
|
|
1210
|
+
} else {
|
|
1211
|
+
this.$el.input.value = value.toString();
|
|
1212
|
+
}
|
|
1229
1213
|
},
|
|
1230
1214
|
/**
|
|
1231
1215
|
* 设置input元素的type
|
|
1232
|
-
* @param
|
|
1216
|
+
* @param typeValue type值
|
|
1233
1217
|
*/
|
|
1234
|
-
setInputType(typeValue = "text") {
|
|
1235
|
-
this.$
|
|
1218
|
+
setInputType(typeValue: PopsPanelInputType = "text") {
|
|
1219
|
+
this.$el.input.setAttribute("type", typeValue);
|
|
1236
1220
|
},
|
|
1237
1221
|
/**
|
|
1238
1222
|
* 删除图标按钮
|
|
1239
1223
|
*/
|
|
1240
1224
|
removeCircleIcon() {
|
|
1241
|
-
PopsSafeUtils.setSafeHTML(this.$
|
|
1225
|
+
PopsSafeUtils.setSafeHTML(this.$el.icon, "");
|
|
1242
1226
|
},
|
|
1243
1227
|
/**
|
|
1244
1228
|
* 添加清空图标按钮
|
|
1245
|
-
* @param
|
|
1229
|
+
* @param svgHTML svg图标,默认为清空的图标
|
|
1246
1230
|
*/
|
|
1247
|
-
setCircleIcon(svgHTML = PopsIcon.getIcon("circleClose")!) {
|
|
1248
|
-
PopsSafeUtils.setSafeHTML(this.$
|
|
1231
|
+
setCircleIcon(svgHTML: string = PopsIcon.getIcon("circleClose")!) {
|
|
1232
|
+
PopsSafeUtils.setSafeHTML(this.$el.icon, svgHTML);
|
|
1233
|
+
},
|
|
1234
|
+
/**
|
|
1235
|
+
* 隐藏图标容器
|
|
1236
|
+
*/
|
|
1237
|
+
hideCircleIconWrapper() {
|
|
1238
|
+
popsDOMUtils.cssHide(this.$el.suffix, true);
|
|
1239
|
+
},
|
|
1240
|
+
/**
|
|
1241
|
+
* 显示图标容器
|
|
1242
|
+
*/
|
|
1243
|
+
showCircleIconWrapper() {
|
|
1244
|
+
popsDOMUtils.cssShow(this.$el.suffix);
|
|
1249
1245
|
},
|
|
1250
1246
|
/**
|
|
1251
1247
|
* 添加图标按钮的点击事件
|
|
1252
1248
|
*/
|
|
1253
|
-
|
|
1254
|
-
popsDOMUtils.on(this.$
|
|
1249
|
+
onIconClick() {
|
|
1250
|
+
popsDOMUtils.on(this.$el.icon, "click", (evt) => {
|
|
1251
|
+
popsDOMUtils.preventEvent(evt);
|
|
1255
1252
|
if (this.isDisabled()) {
|
|
1256
1253
|
return;
|
|
1257
1254
|
}
|
|
1258
|
-
|
|
1255
|
+
// 删除图标
|
|
1259
1256
|
this.removeCircleIcon();
|
|
1260
|
-
if (
|
|
1261
|
-
|
|
1262
|
-
if (this.$data.
|
|
1263
|
-
|
|
1264
|
-
this.$data.
|
|
1265
|
-
|
|
1257
|
+
if (inputType === "password") {
|
|
1258
|
+
// 配置类型为密码输入框
|
|
1259
|
+
if (this.$data.isVisible) {
|
|
1260
|
+
// 当前可见 => 点击改变为隐藏
|
|
1261
|
+
this.$data.isVisible = false;
|
|
1262
|
+
// 显示输入框内容,且更换图标为隐藏图标
|
|
1266
1263
|
this.setInputType("text");
|
|
1267
1264
|
this.setCircleIcon(PopsIcon.getIcon("hide")!);
|
|
1268
1265
|
} else {
|
|
1269
|
-
|
|
1270
|
-
this.$data.
|
|
1271
|
-
|
|
1266
|
+
// 当前不可见 => 点击改变为显示
|
|
1267
|
+
this.$data.isVisible = true;
|
|
1268
|
+
// 隐藏输入框内容,且更换图标为显示图标
|
|
1272
1269
|
this.setInputType("password");
|
|
1273
1270
|
this.setCircleIcon(PopsIcon.getIcon("view")!);
|
|
1274
1271
|
}
|
|
1275
1272
|
} else {
|
|
1276
|
-
|
|
1277
|
-
|
|
1273
|
+
// 普通输入框
|
|
1274
|
+
// 清空内容
|
|
1278
1275
|
this.setInputValue("");
|
|
1279
|
-
|
|
1280
|
-
this.$
|
|
1281
|
-
|
|
1282
|
-
this.$
|
|
1276
|
+
// 获取焦点
|
|
1277
|
+
this.$el.input.focus();
|
|
1278
|
+
// 触发内容改变事件
|
|
1279
|
+
this.$el.input.dispatchEvent(new Event("input"));
|
|
1283
1280
|
}
|
|
1284
1281
|
});
|
|
1285
1282
|
},
|
|
1286
1283
|
/**
|
|
1287
1284
|
* 监听输入框内容改变
|
|
1288
1285
|
*/
|
|
1289
|
-
|
|
1290
|
-
popsDOMUtils.on<InputEvent>(this.$
|
|
1291
|
-
this.$data.value = this.$
|
|
1292
|
-
if (
|
|
1293
|
-
|
|
1294
|
-
if (this.$
|
|
1295
|
-
|
|
1286
|
+
onValueChange() {
|
|
1287
|
+
popsDOMUtils.on<InputEvent>(this.$el.input, ["input", "propertychange"], void 0, (event) => {
|
|
1288
|
+
this.$data.value = this.$el.input.value;
|
|
1289
|
+
if (inputType !== "password") {
|
|
1290
|
+
// 不是密码框
|
|
1291
|
+
if (this.$el.input.value !== "" && this.$el.icon.innerHTML === "" && this.isTextInputType()) {
|
|
1292
|
+
// 不为空,显示清空图标
|
|
1296
1293
|
this.setCircleIcon(PopsIcon.getIcon("circleClose")!);
|
|
1297
|
-
this.
|
|
1298
|
-
|
|
1294
|
+
this.onIconClick();
|
|
1295
|
+
this.showCircleIconWrapper();
|
|
1296
|
+
} else if (this.$el.input.value === "") {
|
|
1299
1297
|
this.removeCircleIcon();
|
|
1300
1298
|
}
|
|
1301
1299
|
}
|
|
1302
|
-
if (typeof
|
|
1303
|
-
|
|
1304
|
-
|
|
1300
|
+
if (typeof viewConfig.callback === "function") {
|
|
1301
|
+
let ret;
|
|
1302
|
+
if (viewConfig.inputType === "number") {
|
|
1303
|
+
ret = viewConfig.callback(event, this.$el.input.value, this.$el.input.valueAsNumber);
|
|
1304
|
+
} else if (this.isDateInputType()) {
|
|
1305
|
+
ret = viewConfig.callback(
|
|
1306
|
+
event,
|
|
1307
|
+
this.$el.input.value,
|
|
1308
|
+
this.$el.input.valueAsNumber,
|
|
1309
|
+
this.$el.input.valueAsDate
|
|
1310
|
+
);
|
|
1311
|
+
} else {
|
|
1312
|
+
ret = viewConfig.callback(event, this.$el.input.value);
|
|
1313
|
+
}
|
|
1314
|
+
if (ret) {
|
|
1315
|
+
if (ret.valid) {
|
|
1316
|
+
// 校验通过
|
|
1317
|
+
this.removeValidErrorMsg();
|
|
1318
|
+
} else {
|
|
1319
|
+
// 校验失败
|
|
1320
|
+
// 显示失败提示
|
|
1321
|
+
this.addValidErrorMsg(ret.message);
|
|
1322
|
+
}
|
|
1305
1323
|
} else {
|
|
1306
|
-
|
|
1324
|
+
this.removeValidErrorMsg();
|
|
1307
1325
|
}
|
|
1308
1326
|
}
|
|
1309
1327
|
});
|
|
1310
1328
|
},
|
|
1329
|
+
/**
|
|
1330
|
+
* 主动触发输入框改变事件
|
|
1331
|
+
*/
|
|
1332
|
+
triggerValueChange() {
|
|
1333
|
+
this.$el.input.dispatchEvent(new Event("input"));
|
|
1334
|
+
},
|
|
1335
|
+
/**
|
|
1336
|
+
* 添加校验失败的提示信息
|
|
1337
|
+
* @param msg 提示信息
|
|
1338
|
+
*/
|
|
1339
|
+
addValidErrorMsg(msg?: string) {
|
|
1340
|
+
if (msg == null) return;
|
|
1341
|
+
const $validErrorMsg =
|
|
1342
|
+
this.$el.panelInput.querySelector<HTMLDivElement>(".pops-panel-input-valid-error") ||
|
|
1343
|
+
popsDOMUtils.createElement("div", {
|
|
1344
|
+
className: "pops-panel-input-valid-error",
|
|
1345
|
+
innerHTML: /*html*/ `<span></span>`,
|
|
1346
|
+
});
|
|
1347
|
+
const $validErrorMsgSpan = $validErrorMsg.querySelector("span")!;
|
|
1348
|
+
if ($validErrorMsgSpan.innerHTML !== msg) {
|
|
1349
|
+
PopsSafeUtils.setSafeHTML($validErrorMsgSpan, msg);
|
|
1350
|
+
}
|
|
1351
|
+
if (!$validErrorMsg.parentElement) {
|
|
1352
|
+
popsDOMUtils.after(this.$el.panelInputInner, $validErrorMsg);
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
/**
|
|
1356
|
+
* 移除校验失败的提示信息
|
|
1357
|
+
*/
|
|
1358
|
+
removeValidErrorMsg() {
|
|
1359
|
+
const $validErrorMsg = this.$el.panelInput.querySelector(".pops-panel-input-valid-error");
|
|
1360
|
+
$validErrorMsg?.remove();
|
|
1361
|
+
},
|
|
1311
1362
|
};
|
|
1312
1363
|
PopsPanelInput.init();
|
|
1313
1364
|
Reflect.set($li, "data-input", PopsPanelInput);
|
|
1314
|
-
return
|
|
1365
|
+
return {
|
|
1366
|
+
$el: $li,
|
|
1367
|
+
handler: PopsPanelInput,
|
|
1368
|
+
};
|
|
1315
1369
|
},
|
|
1316
1370
|
/**
|
|
1317
1371
|
* type ==> textarea
|
|
1318
1372
|
* 获取中间容器的元素<li>
|
|
1319
|
-
* @param
|
|
1373
|
+
* @param viewConfig
|
|
1320
1374
|
*/
|
|
1321
|
-
createSectionContainerItem_textarea(
|
|
1375
|
+
createSectionContainerItem_textarea(viewConfig: PopsPanelTextAreaConfig) {
|
|
1322
1376
|
const $li = popsDOMUtils.createElement("li");
|
|
1323
|
-
Reflect.set($li,
|
|
1324
|
-
this.setElementClassName($li,
|
|
1325
|
-
this.setElementAttributes($li,
|
|
1326
|
-
this.setElementProps($li,
|
|
1377
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
1378
|
+
this.setElementClassName($li, viewConfig.className);
|
|
1379
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
1380
|
+
this.setElementProps($li, viewConfig.props);
|
|
1327
1381
|
|
|
1328
|
-
|
|
1382
|
+
// 左边底部的描述的文字
|
|
1329
1383
|
let leftDescriptionText = "";
|
|
1330
|
-
if (
|
|
1331
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${
|
|
1384
|
+
if (viewConfig.description) {
|
|
1385
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
1332
1386
|
}
|
|
1333
1387
|
PopsSafeUtils.setSafeHTML(
|
|
1334
1388
|
$li,
|
|
1335
1389
|
/*html*/ `
|
|
1336
1390
|
<div class="pops-panel-item-left-text">
|
|
1337
|
-
<p class="pops-panel-item-left-main-text">${
|
|
1391
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
1338
1392
|
<div class="pops-panel-textarea">
|
|
1339
|
-
<textarea placeholder="${
|
|
1393
|
+
<textarea placeholder="${viewConfig.placeholder ?? ""}"></textarea>
|
|
1340
1394
|
</div>
|
|
1341
1395
|
`
|
|
1342
1396
|
);
|
|
@@ -1349,12 +1403,12 @@ export const PanelHandlerComponents = () => {
|
|
|
1349
1403
|
textarea: $li.querySelector<HTMLTextAreaElement>(".pops-panel-textarea textarea")!,
|
|
1350
1404
|
},
|
|
1351
1405
|
$data: {
|
|
1352
|
-
value:
|
|
1406
|
+
value: viewConfig.getValue(),
|
|
1353
1407
|
},
|
|
1354
1408
|
init() {
|
|
1355
1409
|
this.setValue(this.$data.value);
|
|
1356
|
-
this.
|
|
1357
|
-
const disabled = typeof
|
|
1410
|
+
this.onValueChange();
|
|
1411
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
1358
1412
|
if (disabled) {
|
|
1359
1413
|
this.disable();
|
|
1360
1414
|
}
|
|
@@ -1381,12 +1435,12 @@ export const PanelHandlerComponents = () => {
|
|
|
1381
1435
|
/**
|
|
1382
1436
|
* 监听选择内容改变
|
|
1383
1437
|
*/
|
|
1384
|
-
|
|
1438
|
+
onValueChange() {
|
|
1385
1439
|
popsDOMUtils.on<InputEvent>(this.$ele.textarea, ["input", "propertychange"], (event) => {
|
|
1386
1440
|
const value = this.$ele.textarea.value;
|
|
1387
1441
|
this.$data.value = value;
|
|
1388
|
-
if (typeof
|
|
1389
|
-
|
|
1442
|
+
if (typeof viewConfig.callback === "function") {
|
|
1443
|
+
viewConfig.callback(
|
|
1390
1444
|
event as InputEvent & {
|
|
1391
1445
|
target: HTMLTextAreaElement;
|
|
1392
1446
|
},
|
|
@@ -1400,231 +1454,882 @@ export const PanelHandlerComponents = () => {
|
|
|
1400
1454
|
PopsPanelTextArea.init();
|
|
1401
1455
|
Reflect.set($li, "data-textarea", PopsPanelTextArea);
|
|
1402
1456
|
|
|
1403
|
-
return
|
|
1457
|
+
return {
|
|
1458
|
+
$el: $li,
|
|
1459
|
+
handler: PopsPanelTextArea,
|
|
1460
|
+
};
|
|
1404
1461
|
},
|
|
1405
1462
|
/**
|
|
1406
1463
|
* type ==> select
|
|
1407
1464
|
* 获取中间容器的元素<li>
|
|
1408
|
-
* @param
|
|
1465
|
+
* @param viewConfig
|
|
1409
1466
|
*/
|
|
1410
|
-
createSectionContainerItem_select(
|
|
1467
|
+
createSectionContainerItem_select(viewConfig: PopsPanelSelectConfig<any>) {
|
|
1411
1468
|
const that = this;
|
|
1412
1469
|
const $li = popsDOMUtils.createElement("li");
|
|
1413
|
-
Reflect.set($li,
|
|
1414
|
-
this.setElementClassName($li,
|
|
1415
|
-
this.setElementAttributes($li,
|
|
1416
|
-
this.setElementProps($li,
|
|
1417
|
-
|
|
1470
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
1471
|
+
this.setElementClassName($li, viewConfig.className);
|
|
1472
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
1473
|
+
this.setElementProps($li, viewConfig.props);
|
|
1474
|
+
// 左边底部的描述的文字
|
|
1418
1475
|
let leftDescriptionText = "";
|
|
1419
|
-
if (
|
|
1420
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
1476
|
+
if (viewConfig.description) {
|
|
1477
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
1421
1478
|
}
|
|
1422
1479
|
PopsSafeUtils.setSafeHTML(
|
|
1423
1480
|
$li,
|
|
1424
1481
|
/*html*/ `
|
|
1425
1482
|
<div class="pops-panel-item-left-text">
|
|
1426
|
-
<p class="pops-panel-item-left-main-text">${
|
|
1483
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
1427
1484
|
<div class="pops-panel-select">
|
|
1428
1485
|
<select></select>
|
|
1429
1486
|
</div>
|
|
1430
1487
|
`
|
|
1431
1488
|
);
|
|
1489
|
+
let handler;
|
|
1490
|
+
if (viewConfig.useDialog) {
|
|
1491
|
+
const PopsPanelSelect = {
|
|
1492
|
+
[Symbol.toStringTag]: "PopsPanelSelect",
|
|
1493
|
+
$el: {
|
|
1494
|
+
itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
|
|
1495
|
+
/** 选择框容器 */
|
|
1496
|
+
$container: void 0 as any as HTMLElement,
|
|
1497
|
+
/** 选择框包裹的容器 */
|
|
1498
|
+
$wrapper: void 0 as any as HTMLElement,
|
|
1499
|
+
/** 内容区域 */
|
|
1500
|
+
$section: void 0 as any as HTMLElement,
|
|
1501
|
+
/** 手动输入 */
|
|
1502
|
+
$selectedInputWrapper: void 0 as any as HTMLElement,
|
|
1503
|
+
/** 灰色提示语 */
|
|
1504
|
+
$selectedPlaceHolderWrapper: void 0 as any as HTMLElement,
|
|
1505
|
+
/** 下拉箭头区域 */
|
|
1506
|
+
$suffix: void 0 as any as HTMLElement,
|
|
1507
|
+
/** 下拉箭头图标 */
|
|
1508
|
+
$suffixIcon: void 0 as any as HTMLElement,
|
|
1509
|
+
/** 下拉列表弹窗的下拉列表容器 */
|
|
1510
|
+
$selectDialogContainer: void 0 as any as HTMLElement | null,
|
|
1511
|
+
},
|
|
1512
|
+
$data: {
|
|
1513
|
+
/**
|
|
1514
|
+
* 数据
|
|
1515
|
+
*/
|
|
1516
|
+
data: [] as PopsPanelSelectDataOption<any>[],
|
|
1517
|
+
/**
|
|
1518
|
+
* 默认值
|
|
1519
|
+
*/
|
|
1520
|
+
defaultValue: viewConfig.getValue(),
|
|
1521
|
+
/**
|
|
1522
|
+
* 选择的信息
|
|
1523
|
+
*/
|
|
1524
|
+
selectedData: void 0 as PopsPanelSelectDataOption<any> | undefined,
|
|
1525
|
+
/**
|
|
1526
|
+
* 是否验证通过
|
|
1527
|
+
*/
|
|
1528
|
+
isValidSuccess: true,
|
|
1529
|
+
/**
|
|
1530
|
+
* 箭头旋转的属性
|
|
1531
|
+
*/
|
|
1532
|
+
rotateKey: "data-show-option",
|
|
1533
|
+
},
|
|
1534
|
+
/** 初始化 */
|
|
1535
|
+
init() {
|
|
1536
|
+
this.initDefault();
|
|
1537
|
+
this.initEl();
|
|
1538
|
+
this.initPlaceHolder();
|
|
1539
|
+
this.renderSelectText();
|
|
1540
|
+
this.onShowSelectDialogClick();
|
|
1432
1541
|
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
|
|
1437
|
-
panelSelect: $li.querySelector<HTMLDivElement>(".pops-panel-select")!,
|
|
1438
|
-
select: $li.querySelector<HTMLSelectElement>(".pops-panel-select select")!,
|
|
1439
|
-
},
|
|
1440
|
-
$eleKey: {
|
|
1441
|
-
disable: "__disable__",
|
|
1442
|
-
value: "__value__",
|
|
1443
|
-
forms: "__forms__",
|
|
1444
|
-
},
|
|
1445
|
-
$data: {
|
|
1446
|
-
defaultValue: formConfig.getValue(),
|
|
1447
|
-
},
|
|
1448
|
-
init() {
|
|
1449
|
-
popsDOMUtils.addClassName(this.$ele.panelSelect, PopsCommonCSSClassName.userSelectNone);
|
|
1450
|
-
this.initOption();
|
|
1451
|
-
this.setChangeEvent();
|
|
1452
|
-
this.setClickEvent();
|
|
1453
|
-
const disabled = typeof formConfig.disabled === "function" ? formConfig.disabled() : formConfig.disabled;
|
|
1454
|
-
if (disabled) {
|
|
1455
|
-
this.disable();
|
|
1456
|
-
}
|
|
1457
|
-
},
|
|
1458
|
-
/**
|
|
1459
|
-
* 给option元素设置属性
|
|
1460
|
-
* @param $ele
|
|
1461
|
-
* @param key
|
|
1462
|
-
* @param value
|
|
1463
|
-
*/
|
|
1464
|
-
setNodeValue($ele: HTMLElement, key: string, value: any) {
|
|
1465
|
-
Reflect.set($ele, key, value);
|
|
1466
|
-
},
|
|
1467
|
-
/**
|
|
1468
|
-
* 获取option元素上设置的属性
|
|
1469
|
-
* @param $ele
|
|
1470
|
-
* @param value
|
|
1471
|
-
* @param key
|
|
1472
|
-
*/
|
|
1473
|
-
getNodeValue($ele: HTMLElement, key: string) {
|
|
1474
|
-
return Reflect.get($ele, key);
|
|
1475
|
-
},
|
|
1476
|
-
/**
|
|
1477
|
-
* 禁用选项
|
|
1478
|
-
*/
|
|
1479
|
-
disable() {
|
|
1480
|
-
this.$ele.select.setAttribute("disabled", "true");
|
|
1481
|
-
popsDOMUtils.addClassName(this.$ele.panelSelect, "pops-panel-select-disable");
|
|
1482
|
-
popsDOMUtils.addClassName(this.$ele.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
|
|
1483
|
-
},
|
|
1484
|
-
/**
|
|
1485
|
-
* 取消禁用
|
|
1486
|
-
*/
|
|
1487
|
-
notDisable() {
|
|
1488
|
-
this.$ele.select.removeAttribute("disabled");
|
|
1489
|
-
popsDOMUtils.removeClassName(this.$ele.panelSelect, "pops-panel-select-disable");
|
|
1490
|
-
popsDOMUtils.removeClassName(this.$ele.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
|
|
1491
|
-
},
|
|
1492
|
-
/**
|
|
1493
|
-
* 判断是否禁用
|
|
1494
|
-
*/
|
|
1495
|
-
isDisabled() {
|
|
1496
|
-
return (
|
|
1497
|
-
this.$ele.select.hasAttribute("disabled") ||
|
|
1498
|
-
popsDOMUtils.containsClassName(this.$ele.panelSelect, "pops-panel-select-disable")
|
|
1499
|
-
);
|
|
1500
|
-
},
|
|
1501
|
-
/**
|
|
1502
|
-
* 初始化选项
|
|
1503
|
-
*/
|
|
1504
|
-
initOption() {
|
|
1505
|
-
formConfig.data.forEach((dataItem) => {
|
|
1506
|
-
// 初始化默认选中
|
|
1507
|
-
const optionElement = popsDOMUtils.createElement("option");
|
|
1508
|
-
this.setNodeValue(optionElement, this.$eleKey.value, dataItem.value);
|
|
1509
|
-
this.setNodeValue(optionElement, this.$eleKey.disable, dataItem.disable);
|
|
1510
|
-
this.setNodeValue(optionElement, this.$eleKey.forms, dataItem.forms);
|
|
1511
|
-
if (dataItem.value === this.$data.defaultValue) {
|
|
1512
|
-
this.setOptionSelected(optionElement);
|
|
1542
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
1543
|
+
if (disabled) {
|
|
1544
|
+
this.disable();
|
|
1513
1545
|
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
/** 检测所有option并设置禁用状态 */
|
|
1525
|
-
setSelectOptionsDisableStatus() {
|
|
1526
|
-
if (this.$ele.select.options && this.$ele.select.options.length) {
|
|
1527
|
-
Array.from(this.$ele.select.options).forEach((optionItem) => {
|
|
1528
|
-
this.setOptionDisableStatus(optionItem);
|
|
1546
|
+
},
|
|
1547
|
+
/** 初始化默认值 */
|
|
1548
|
+
initDefault() {
|
|
1549
|
+
this.$data.data = typeof viewConfig.data === "function" ? viewConfig.data() : viewConfig.data;
|
|
1550
|
+
this.$data.data.forEach((dataItem) => {
|
|
1551
|
+
if (this.$data.defaultValue.includes(dataItem.value)) {
|
|
1552
|
+
// 初始化选中的配置
|
|
1553
|
+
this.resetCurrentSelectedInfo();
|
|
1554
|
+
this.updateSelectedInfo(dataItem);
|
|
1555
|
+
}
|
|
1529
1556
|
});
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1557
|
+
},
|
|
1558
|
+
/** 初始化$ele变量 */
|
|
1559
|
+
initEl() {
|
|
1560
|
+
this.$el.$container = $li.querySelector<HTMLElement>(".pops-panel-select")!;
|
|
1561
|
+
PopsSafeUtils.setSafeHTML(
|
|
1562
|
+
this.$el.$container,
|
|
1563
|
+
/*html*/ `
|
|
1564
|
+
<div class="el-select__wrapper">
|
|
1565
|
+
<div class="el-select__selection">
|
|
1566
|
+
<!-- 这个是用于手动输入的,这里暂不适配 -->
|
|
1567
|
+
<div class="el-select__selected-item el-select__input-wrapper"></div>
|
|
1568
|
+
<!-- 这个是placeholder -->
|
|
1569
|
+
<div class="el-select__selected-item el-select__placeholder"></div>
|
|
1570
|
+
</div>
|
|
1571
|
+
<!-- 下拉箭头 -->
|
|
1572
|
+
<div class="el-select__suffix">
|
|
1573
|
+
<i class="el-icon el-select__caret el-select__icon">
|
|
1574
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
1575
|
+
<path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>
|
|
1576
|
+
</svg>
|
|
1577
|
+
</i>
|
|
1578
|
+
</div>
|
|
1579
|
+
</div>`
|
|
1580
|
+
);
|
|
1581
|
+
this.$el.$wrapper = $li.querySelector<HTMLElement>(".el-select__wrapper")!;
|
|
1582
|
+
this.$el.$section = $li.querySelector<HTMLElement>(".el-select__selection")!;
|
|
1583
|
+
this.$el.$selectedInputWrapper = $li.querySelector<HTMLElement>(
|
|
1584
|
+
".el-select__selected-item.el-select__input-wrapper"
|
|
1585
|
+
)!;
|
|
1586
|
+
this.$el.$selectedPlaceHolderWrapper = $li.querySelector<HTMLElement>(
|
|
1587
|
+
".el-select__selected-item.el-select__placeholder"
|
|
1588
|
+
)!;
|
|
1589
|
+
this.$el.$suffix = $li.querySelector<HTMLElement>(".el-select__suffix")!;
|
|
1590
|
+
this.$el.$suffixIcon = $li.querySelector<HTMLElement>(".el-select__suffix .el-icon")!;
|
|
1591
|
+
|
|
1592
|
+
// 先把手动输入框隐藏
|
|
1593
|
+
this.hideInputWrapper();
|
|
1594
|
+
},
|
|
1595
|
+
/**
|
|
1596
|
+
* 初始化提示文字
|
|
1597
|
+
*/
|
|
1598
|
+
initPlaceHolder() {
|
|
1599
|
+
let placeholder = "--请选择--";
|
|
1600
|
+
if (typeof viewConfig.placeholder === "string") {
|
|
1601
|
+
placeholder = viewConfig.placeholder;
|
|
1602
|
+
} else if (typeof viewConfig.placeholder === "function") {
|
|
1603
|
+
const placeholderResult = viewConfig.placeholder();
|
|
1604
|
+
if (typeof placeholderResult === "string") {
|
|
1605
|
+
placeholder = placeholderResult;
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* 默认提示文字的位置
|
|
1610
|
+
*/
|
|
1611
|
+
const defaultSelectedTextAlign: NonNullable<PopsPanelSelectConfig<any>["selectedTextAlign"]> = "left";
|
|
1612
|
+
this.$el.$section.setAttribute(
|
|
1613
|
+
"data-selected-text-align",
|
|
1614
|
+
viewConfig.selectedTextAlign || defaultSelectedTextAlign
|
|
1615
|
+
);
|
|
1616
|
+
|
|
1617
|
+
const $placeholder = popsDOMUtils.createElement("span", {
|
|
1618
|
+
innerText: placeholder,
|
|
1619
|
+
});
|
|
1620
|
+
this.$el.$selectedPlaceHolderWrapper.appendChild($placeholder);
|
|
1621
|
+
},
|
|
1622
|
+
/**
|
|
1623
|
+
* 重新渲染外面的已选择项的文本
|
|
1624
|
+
*
|
|
1625
|
+
* 如果未选择,显示提示文字
|
|
1626
|
+
*/
|
|
1627
|
+
renderSelectText() {
|
|
1628
|
+
let item = this.$data.data.find((dataItem) => {
|
|
1629
|
+
return dataItem.value === this.$data.selectedData?.value;
|
|
1630
|
+
});
|
|
1631
|
+
if (item == null) {
|
|
1632
|
+
// 未找到但是有选中信息,且是自定义输入的
|
|
1633
|
+
if (this.$data.selectedData && this.$data.selectedData.addCustomInput) {
|
|
1634
|
+
item = this.$data.selectedData;
|
|
1635
|
+
}
|
|
1568
1636
|
}
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1637
|
+
if (item != null) {
|
|
1638
|
+
// 默认值在数据中
|
|
1639
|
+
// 显示该数据项的文本
|
|
1640
|
+
// 隐藏placeholder
|
|
1641
|
+
const text = typeof item.text === "function" ? item.text(item.value, item) : item.text;
|
|
1642
|
+
if (item.isHTML) {
|
|
1643
|
+
PopsSafeUtils.setSafeHTML(this.$el.$selectedInputWrapper, text);
|
|
1644
|
+
} else {
|
|
1645
|
+
PopsSafeUtils.setSafeHTML(
|
|
1646
|
+
this.$el.$selectedInputWrapper,
|
|
1647
|
+
/*html*/ `
|
|
1648
|
+
<span>${text}</span>
|
|
1649
|
+
`
|
|
1650
|
+
);
|
|
1651
|
+
}
|
|
1652
|
+
// 显示选中的内容
|
|
1653
|
+
this.showInputWrapper();
|
|
1654
|
+
// 隐藏placeholder
|
|
1655
|
+
this.hidePlaceHolderWrapper();
|
|
1656
|
+
} else {
|
|
1657
|
+
// 仅显示placeholder
|
|
1658
|
+
this.hideInputWrapper();
|
|
1659
|
+
this.showPlaceHolderWrapper();
|
|
1660
|
+
}
|
|
1661
|
+
},
|
|
1662
|
+
/**
|
|
1663
|
+
* 禁用选项容器
|
|
1664
|
+
*/
|
|
1665
|
+
disable() {
|
|
1666
|
+
popsDOMUtils.addClassName(this.$el.$container, "pops-panel-select-multiple-disable");
|
|
1667
|
+
popsDOMUtils.addClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
|
|
1668
|
+
},
|
|
1669
|
+
/**
|
|
1670
|
+
* 取消禁用选项容器
|
|
1671
|
+
*/
|
|
1672
|
+
cancleDisable() {
|
|
1673
|
+
popsDOMUtils.removeClassName(this.$el.$container, "pops-panel-select-multiple-disable");
|
|
1674
|
+
popsDOMUtils.removeClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
|
|
1675
|
+
},
|
|
1676
|
+
/**
|
|
1677
|
+
* 判断当前是否已禁用选项容器
|
|
1678
|
+
*/
|
|
1679
|
+
isDisabled() {
|
|
1680
|
+
return (
|
|
1681
|
+
popsDOMUtils.containsClassName(this.$el.$container, "pops-panel-select-multiple-disable") ||
|
|
1682
|
+
popsDOMUtils.containsClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled)
|
|
1683
|
+
);
|
|
1684
|
+
},
|
|
1685
|
+
/**
|
|
1686
|
+
* 设置选择列表的点击事件
|
|
1687
|
+
*
|
|
1688
|
+
* 点击显示选择列表的弹窗
|
|
1689
|
+
*/
|
|
1690
|
+
onShowSelectDialogClick() {
|
|
1691
|
+
const defaultCSS = PopsCSS.panelComponents_Select;
|
|
1692
|
+
popsDOMUtils.on(this.$el.$container, "click", () => {
|
|
1693
|
+
if (this.isDisabled()) {
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
/** 当前已选中的值 */
|
|
1697
|
+
const { style, ...userConfirmConfig } = viewConfig.selectConfirmDialogConfig || {};
|
|
1698
|
+
/**
|
|
1699
|
+
* 弹窗关闭的回调
|
|
1700
|
+
*/
|
|
1701
|
+
const dialogCloseCallback = () => {
|
|
1702
|
+
if (this.$data.selectedData?.addCustomInput && !this.$data.isValidSuccess) {
|
|
1703
|
+
// 当前是自定义输入的且未通过校验
|
|
1704
|
+
return false;
|
|
1705
|
+
} else {
|
|
1706
|
+
// 清除自定义输入的值
|
|
1707
|
+
this.getAllSelectItems(false).forEach((it) => {
|
|
1708
|
+
if (!it.data.addCustomInput) return;
|
|
1709
|
+
it.data.value = "";
|
|
1710
|
+
it.data.text = "";
|
|
1711
|
+
this.onValueChangeCallback(it.data);
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
this.renderSelectText();
|
|
1715
|
+
this.$el.$selectDialogContainer = null;
|
|
1716
|
+
this.$el.$container.removeAttribute(this.$data.rotateKey);
|
|
1717
|
+
};
|
|
1718
|
+
this.$el.$container.setAttribute(this.$data.rotateKey, String(true));
|
|
1719
|
+
const confirmConfig = popsUtils.assign(
|
|
1720
|
+
<PopsAlertConfig>{
|
|
1721
|
+
title: {
|
|
1722
|
+
text: "请勾选需要选择的选项",
|
|
1723
|
+
position: "center",
|
|
1724
|
+
},
|
|
1725
|
+
content: {
|
|
1726
|
+
text: /*html*/ `<ul class="select-container"></ul>`,
|
|
1727
|
+
html: true,
|
|
1728
|
+
},
|
|
1729
|
+
btn: {
|
|
1730
|
+
ok: {
|
|
1731
|
+
enable: false,
|
|
1732
|
+
},
|
|
1733
|
+
close: {
|
|
1734
|
+
enable: true,
|
|
1735
|
+
callback(evtConfig) {
|
|
1736
|
+
const ret = dialogCloseCallback();
|
|
1737
|
+
if (typeof ret === "boolean" && !ret) {
|
|
1738
|
+
return;
|
|
1739
|
+
}
|
|
1740
|
+
evtConfig.close();
|
|
1741
|
+
},
|
|
1742
|
+
},
|
|
1743
|
+
},
|
|
1744
|
+
mask: {
|
|
1745
|
+
enable: true,
|
|
1746
|
+
clickCallBack(originalRun) {
|
|
1747
|
+
const ret = dialogCloseCallback();
|
|
1748
|
+
if (typeof ret === "boolean" && !ret) {
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
originalRun();
|
|
1752
|
+
},
|
|
1753
|
+
clickEvent: {
|
|
1754
|
+
toClose: true,
|
|
1755
|
+
},
|
|
1756
|
+
},
|
|
1757
|
+
drag: true,
|
|
1758
|
+
dragLimit: true,
|
|
1759
|
+
width: "300px",
|
|
1760
|
+
height: "auto",
|
|
1761
|
+
style: /*css*/ `
|
|
1762
|
+
${defaultCSS}
|
|
1763
|
+
|
|
1764
|
+
${PopsCSS.panelCSS}
|
|
1765
|
+
|
|
1766
|
+
${style || ""}
|
|
1767
|
+
`,
|
|
1768
|
+
},
|
|
1769
|
+
userConfirmConfig
|
|
1770
|
+
);
|
|
1771
|
+
const $dialog = PopsAlert.init(confirmConfig);
|
|
1772
|
+
const $selectContainer = $dialog.$shadowRoot.querySelector<HTMLUListElement>(".select-container")!;
|
|
1773
|
+
// 初始化选项元素
|
|
1774
|
+
this.$data.data.forEach((item) => {
|
|
1775
|
+
if (item.addCustomInput) {
|
|
1776
|
+
// 添加自定义输入的
|
|
1777
|
+
const customInputDataOption = item;
|
|
1778
|
+
const $customInputSelecItem = this.createSelectItemElement(customInputDataOption);
|
|
1779
|
+
const context = this;
|
|
1780
|
+
const PanelInput = that.createSectionContainerItem_input({
|
|
1781
|
+
type: "input",
|
|
1782
|
+
text: "",
|
|
1783
|
+
getValue() {
|
|
1784
|
+
return customInputDataOption.value;
|
|
1785
|
+
},
|
|
1786
|
+
callback(evt, value) {
|
|
1787
|
+
customInputDataOption.text = value;
|
|
1788
|
+
customInputDataOption.value = value;
|
|
1789
|
+
if (typeof customInputDataOption.onValid === "function") {
|
|
1790
|
+
const ret = customInputDataOption.onValid(customInputDataOption);
|
|
1791
|
+
context.$data.isValidSuccess = ret.valid;
|
|
1792
|
+
if (ret.valid) {
|
|
1793
|
+
PanelInputHandler.removeValidErrorMsg();
|
|
1794
|
+
} else {
|
|
1795
|
+
PanelInputHandler.addValidErrorMsg(ret.message);
|
|
1796
|
+
return ret;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
context.updateSelectedInfo(customInputDataOption);
|
|
1801
|
+
context.onValueChangeCallback(customInputDataOption);
|
|
1802
|
+
},
|
|
1803
|
+
});
|
|
1804
|
+
// 获取输入框处理函数
|
|
1805
|
+
const PanelInputHandler = PanelInput.handler;
|
|
1806
|
+
|
|
1807
|
+
const $inputContainer = PanelInput.$el.querySelector<HTMLElement>(".pops-panel-input")!;
|
|
1808
|
+
PopsSafeUtils.setSafeHTML($customInputSelecItem, "");
|
|
1809
|
+
|
|
1810
|
+
$customInputSelecItem.appendChild($inputContainer);
|
|
1811
|
+
// 添加到confirm中
|
|
1812
|
+
$selectContainer.appendChild($customInputSelecItem);
|
|
1813
|
+
// 设置项的点击事件
|
|
1814
|
+
this.onSelectItemClick(customInputDataOption, $customInputSelecItem);
|
|
1577
1815
|
} else {
|
|
1578
|
-
|
|
1816
|
+
const $select = this.createSelectItemElement(item);
|
|
1817
|
+
// 添加到confirm中
|
|
1818
|
+
$selectContainer.appendChild($select);
|
|
1819
|
+
// 设置项的点击事件
|
|
1820
|
+
this.onSelectItemClick(item, $select);
|
|
1579
1821
|
}
|
|
1822
|
+
});
|
|
1823
|
+
this.$el.$selectDialogContainer = $selectContainer;
|
|
1824
|
+
// 初始化状态
|
|
1825
|
+
this.updateAllSelectItemStatus();
|
|
1826
|
+
});
|
|
1827
|
+
},
|
|
1828
|
+
/**
|
|
1829
|
+
* 选中的值改变的回调
|
|
1830
|
+
* @param data 当前的选中信息
|
|
1831
|
+
*/
|
|
1832
|
+
onValueChangeCallback(data?: PopsPanelSelectDataOption<any>, isUpdateSelectItem: boolean = true) {
|
|
1833
|
+
// 动态更新禁用状态、选中状态
|
|
1834
|
+
isUpdateSelectItem && this.updateAllSelectItemStatus();
|
|
1835
|
+
// 触发回调
|
|
1836
|
+
if (typeof viewConfig.callback === "function") {
|
|
1837
|
+
viewConfig.callback(data || this.$data.selectedData!);
|
|
1838
|
+
}
|
|
1839
|
+
},
|
|
1840
|
+
/**
|
|
1841
|
+
* 更新选项弹窗内的所有选项元素的状态
|
|
1842
|
+
*
|
|
1843
|
+
* + 更新禁用状态
|
|
1844
|
+
* + 更新选中状态
|
|
1845
|
+
*/
|
|
1846
|
+
updateAllSelectItemStatus() {
|
|
1847
|
+
const allSelectItems = this.getAllSelectItems(false);
|
|
1848
|
+
allSelectItems.forEach(($selectInfo) => {
|
|
1849
|
+
const { data, $select } = $selectInfo;
|
|
1850
|
+
// 更新文字
|
|
1851
|
+
this.setSelectItemText(data, $selectInfo.$select);
|
|
1852
|
+
if (typeof data.disable === "function" && data.disable(data.value, this.$data.selectedData)) {
|
|
1853
|
+
// 移除选中状态
|
|
1854
|
+
this.removeItemSelected($select);
|
|
1855
|
+
// 禁用
|
|
1856
|
+
this.setSelectItemDisabled($select);
|
|
1857
|
+
} else {
|
|
1858
|
+
// 移除禁用状态
|
|
1859
|
+
this.removeSelectItemDisabled($select);
|
|
1860
|
+
}
|
|
1861
|
+
// 根据当前已选择的信息,判断并更新选中状态
|
|
1862
|
+
if (this.$data.selectedData != null && this.$data.selectedData.value === data.value) {
|
|
1863
|
+
// 就是这个项
|
|
1864
|
+
// 设置选中
|
|
1865
|
+
this.setItemSelected($select);
|
|
1866
|
+
} else {
|
|
1867
|
+
// 不是这个项
|
|
1868
|
+
// 移除选中状态
|
|
1869
|
+
this.removeItemSelected($select);
|
|
1580
1870
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1871
|
+
});
|
|
1872
|
+
},
|
|
1873
|
+
/**
|
|
1874
|
+
* 重置所有已选中的项以下状态
|
|
1875
|
+
*
|
|
1876
|
+
* + 更新选项显示的文字
|
|
1877
|
+
* + 移除禁用状态
|
|
1878
|
+
* + 移除选中状态
|
|
1879
|
+
*/
|
|
1880
|
+
resetAllSelectedItemStatus() {
|
|
1881
|
+
const allSelectedItems = this.getAllSelectItems(true);
|
|
1882
|
+
if (allSelectedItems.length) {
|
|
1883
|
+
// 移除选中信息
|
|
1884
|
+
this.resetCurrentSelectedInfo();
|
|
1885
|
+
}
|
|
1886
|
+
allSelectedItems.forEach(($selectInfo) => {
|
|
1887
|
+
const { data, $select } = $selectInfo;
|
|
1888
|
+
// 更新文字
|
|
1889
|
+
this.setSelectItemText(data, $selectInfo.$select);
|
|
1890
|
+
// 移除选中状态
|
|
1891
|
+
this.removeItemSelected($select);
|
|
1892
|
+
// 取消禁用
|
|
1893
|
+
this.removeSelectItemDisabled($select);
|
|
1894
|
+
});
|
|
1895
|
+
},
|
|
1896
|
+
/**
|
|
1897
|
+
* 设置选项元素选中
|
|
1898
|
+
* @param $el 选项元素
|
|
1899
|
+
*/
|
|
1900
|
+
setItemSelected($el: HTMLElement) {
|
|
1901
|
+
if (this.isItemSelected($el)) return;
|
|
1902
|
+
$el.classList.add("select-item-is-selected");
|
|
1903
|
+
},
|
|
1904
|
+
/**
|
|
1905
|
+
* 移除选项元素选中
|
|
1906
|
+
* @param $el 选项元素
|
|
1907
|
+
*/
|
|
1908
|
+
removeItemSelected($el: HTMLElement) {
|
|
1909
|
+
$el.classList.remove("select-item-is-selected");
|
|
1910
|
+
},
|
|
1911
|
+
/**
|
|
1912
|
+
* 判断选项元素是否选中
|
|
1913
|
+
* @param $el
|
|
1914
|
+
*/
|
|
1915
|
+
isItemSelected($el: HTMLElement): boolean {
|
|
1916
|
+
return $el.classList.contains("select-item-is-selected");
|
|
1917
|
+
},
|
|
1918
|
+
/**
|
|
1919
|
+
* 添加选中信息
|
|
1920
|
+
* @param data 选择项的数据
|
|
1921
|
+
* @param [triggerValueChangeCallBack=true] 主动触发值改变回调
|
|
1922
|
+
*/
|
|
1923
|
+
addSelectedItemInfo(data: PopsPanelSelectDataOption<any>) {
|
|
1924
|
+
this.resetCurrentSelectedInfo();
|
|
1925
|
+
this.updateSelectedInfo(data);
|
|
1926
|
+
this.onValueChangeCallback(data);
|
|
1927
|
+
},
|
|
1928
|
+
/**
|
|
1929
|
+
* 获取项上存储的信息
|
|
1930
|
+
* @param $el 选项元素
|
|
1931
|
+
*/
|
|
1932
|
+
getItemDataOption($el: HTMLElement): PopsPanelSelectDataOption<any> {
|
|
1933
|
+
return Reflect.get($el, "data-info");
|
|
1934
|
+
},
|
|
1935
|
+
/**
|
|
1936
|
+
* 移除选中信息
|
|
1937
|
+
* @param data 选择项的数据
|
|
1938
|
+
*/
|
|
1939
|
+
removeSelectedItemInfo() {
|
|
1940
|
+
// 删除
|
|
1941
|
+
this.updateSelectedInfo();
|
|
1942
|
+
this.onValueChangeCallback();
|
|
1943
|
+
},
|
|
1944
|
+
/**
|
|
1945
|
+
* 更新选中信息
|
|
1946
|
+
* @param data 数据
|
|
1947
|
+
*/
|
|
1948
|
+
updateSelectedInfo(data?: PopsPanelSelectDataOption<any>) {
|
|
1949
|
+
// 先删除再赋值
|
|
1950
|
+
this.$data.selectedData = void 0;
|
|
1951
|
+
if (data) {
|
|
1952
|
+
if (data.addCustomInput && data.value.toString() === "") {
|
|
1953
|
+
// 自定义输入框,但是内容是空字符串
|
|
1954
|
+
// 不更新选中信息
|
|
1955
|
+
return;
|
|
1956
|
+
}
|
|
1957
|
+
this.$data.selectedData = data;
|
|
1958
|
+
}
|
|
1959
|
+
},
|
|
1960
|
+
/**
|
|
1961
|
+
* 从保存的已选中的信息列表中移除目标信息
|
|
1962
|
+
*/
|
|
1963
|
+
resetCurrentSelectedInfo() {
|
|
1964
|
+
this.updateSelectedInfo();
|
|
1965
|
+
},
|
|
1966
|
+
/**
|
|
1967
|
+
* 获取所有选项的信息
|
|
1968
|
+
* @param [onlySelected=true] 是否仅获取选中的项的信息
|
|
1969
|
+
* + true (默认)仅获取选中项的信息
|
|
1970
|
+
* + false 获取所有选择项的信息
|
|
1971
|
+
*/
|
|
1972
|
+
getAllSelectItems(onlySelected: boolean = true) {
|
|
1973
|
+
return Array.from(this.$el.$selectDialogContainer?.querySelectorAll<HTMLElement>(".select-item") ?? [])
|
|
1974
|
+
.map(($select) => {
|
|
1975
|
+
const data = this.getItemDataOption($select);
|
|
1976
|
+
const result = {
|
|
1977
|
+
/** 选项信息数据 */
|
|
1978
|
+
data: data,
|
|
1979
|
+
/** 选项元素 */
|
|
1980
|
+
$select: $select,
|
|
1981
|
+
};
|
|
1982
|
+
if (onlySelected) {
|
|
1983
|
+
// 仅选中
|
|
1984
|
+
const isSelected = this.isItemSelected($select);
|
|
1985
|
+
if (isSelected) {
|
|
1986
|
+
return result;
|
|
1987
|
+
}
|
|
1988
|
+
return;
|
|
1989
|
+
} else {
|
|
1990
|
+
return result;
|
|
1991
|
+
}
|
|
1992
|
+
})
|
|
1993
|
+
.filter((item) => {
|
|
1994
|
+
return item != null;
|
|
1586
1995
|
});
|
|
1996
|
+
},
|
|
1997
|
+
/**
|
|
1998
|
+
* 创建一个选择项元素
|
|
1999
|
+
* @param data 选择项的数据
|
|
2000
|
+
*/
|
|
2001
|
+
createSelectItemElement(data: PopsPanelSelectDataOption<any>) {
|
|
2002
|
+
const $select = popsDOMUtils.createElement("li", {
|
|
2003
|
+
className: "select-item",
|
|
2004
|
+
innerHTML: /*html*/ `<span class="select-item-text"></span>`,
|
|
2005
|
+
});
|
|
2006
|
+
this.setSelectItemText(data, $select);
|
|
2007
|
+
Reflect.set($select, "data-info", data);
|
|
2008
|
+
return $select;
|
|
2009
|
+
},
|
|
2010
|
+
/**
|
|
2011
|
+
* 设置选择项的文字
|
|
2012
|
+
* @param data 选择项的数据
|
|
2013
|
+
* @param $select 选择项元素
|
|
2014
|
+
*/
|
|
2015
|
+
setSelectItemText(data: PopsPanelSelectDataOption<any>, $select: HTMLElement) {
|
|
2016
|
+
const text = typeof data.text === "function" ? data.text(data.value, this.$data.selectedData) : data.text;
|
|
2017
|
+
const $selectSpan = $select.querySelector<HTMLElement>(".select-item-text");
|
|
2018
|
+
if (!$selectSpan) return;
|
|
2019
|
+
if (data.isHTML) {
|
|
2020
|
+
PopsSafeUtils.setSafeHTML($selectSpan, text);
|
|
2021
|
+
} else {
|
|
2022
|
+
$selectSpan.innerText = text;
|
|
1587
2023
|
}
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
2024
|
+
},
|
|
2025
|
+
/**
|
|
2026
|
+
* 设置选择项禁用
|
|
2027
|
+
* @param $select 选择项元素
|
|
2028
|
+
*/
|
|
2029
|
+
setSelectItemDisabled($select: HTMLElement) {
|
|
2030
|
+
$select.setAttribute("aria-disabled", "true");
|
|
2031
|
+
$select.setAttribute("disabled", "true");
|
|
2032
|
+
},
|
|
2033
|
+
/**
|
|
2034
|
+
* 移除选择项的禁用状态
|
|
2035
|
+
* @param $select 选择项元素
|
|
2036
|
+
*/
|
|
2037
|
+
removeSelectItemDisabled($select: HTMLElement) {
|
|
2038
|
+
$select.removeAttribute("aria-disabled");
|
|
2039
|
+
$select.removeAttribute("disabled");
|
|
2040
|
+
},
|
|
2041
|
+
/**
|
|
2042
|
+
* 判断选择项是否禁用
|
|
2043
|
+
* @param $select 选择项元素
|
|
2044
|
+
*/
|
|
2045
|
+
isSelectItemDisabled($select: HTMLElement) {
|
|
2046
|
+
return $select.hasAttribute("disabled") || $select.ariaDisabled;
|
|
2047
|
+
},
|
|
2048
|
+
/**
|
|
2049
|
+
* 设置选择项的点击事件
|
|
2050
|
+
* @param data 该选择项的信息
|
|
2051
|
+
* @param $select 该选择项元素
|
|
2052
|
+
*/
|
|
2053
|
+
onSelectItemClick(data: PopsPanelSelectDataOption<any> | undefined, $select: HTMLElement) {
|
|
2054
|
+
const updateCustomInputStatus = () => {
|
|
2055
|
+
this.setItemSelected($select);
|
|
2056
|
+
this.addSelectedItemInfo(data!);
|
|
2057
|
+
};
|
|
2058
|
+
popsDOMUtils.on<PointerEvent | MouseEvent>($select, "click", (event) => {
|
|
2059
|
+
popsDOMUtils.preventEvent(event);
|
|
2060
|
+
const $click = event.target as HTMLElement;
|
|
2061
|
+
if (data?.addCustomInput && $click instanceof HTMLInputElement) {
|
|
2062
|
+
// 自定义输入框 单独处理值更新,选中
|
|
2063
|
+
updateCustomInputStatus();
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
if (this.isSelectItemDisabled($select)) {
|
|
2067
|
+
// 被禁用了
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
if (typeof viewConfig.clickCallBack === "function") {
|
|
2071
|
+
const clickResult = viewConfig.clickCallBack(event, this.$data.selectedData!);
|
|
2072
|
+
if (typeof clickResult === "boolean" && !clickResult) {
|
|
2073
|
+
return;
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
if (data?.addCustomInput) {
|
|
2077
|
+
// 自定义输入框 添加选中
|
|
2078
|
+
updateCustomInputStatus();
|
|
2079
|
+
} else {
|
|
2080
|
+
// 修改选中状态
|
|
2081
|
+
if (this.isItemSelected($select)) {
|
|
2082
|
+
// 移除选中
|
|
2083
|
+
this.removeItemSelected($select);
|
|
2084
|
+
this.removeSelectedItemInfo();
|
|
2085
|
+
} else {
|
|
2086
|
+
// 添加选中
|
|
2087
|
+
this.setItemSelected($select);
|
|
2088
|
+
this.addSelectedItemInfo(data!);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
});
|
|
2092
|
+
},
|
|
2093
|
+
/** 显示输入框 */
|
|
2094
|
+
showInputWrapper() {
|
|
2095
|
+
popsDOMUtils.cssShow(this.$el.$selectedInputWrapper);
|
|
2096
|
+
},
|
|
2097
|
+
/** 隐藏输入框 */
|
|
2098
|
+
hideInputWrapper() {
|
|
2099
|
+
popsDOMUtils.cssHide(this.$el.$selectedInputWrapper, true);
|
|
2100
|
+
},
|
|
2101
|
+
/** 显示palceholder */
|
|
2102
|
+
showPlaceHolderWrapper() {
|
|
2103
|
+
popsDOMUtils.cssShow(this.$el.$selectedPlaceHolderWrapper);
|
|
2104
|
+
},
|
|
2105
|
+
/** 隐藏palceholder */
|
|
2106
|
+
hidePlaceHolderWrapper() {
|
|
2107
|
+
popsDOMUtils.cssHide(this.$el.$selectedPlaceHolderWrapper, true);
|
|
2108
|
+
},
|
|
2109
|
+
};
|
|
2110
|
+
PopsPanelSelect.init();
|
|
2111
|
+
Reflect.set($li, "data-select", PopsPanelSelect);
|
|
2112
|
+
handler = PopsPanelSelect;
|
|
2113
|
+
} else {
|
|
2114
|
+
const PopsPanelSelectNative = {
|
|
2115
|
+
[Symbol.toStringTag]: "PopsPanelSelectNative",
|
|
2116
|
+
$el: {
|
|
2117
|
+
itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
|
|
2118
|
+
panelSelect: $li.querySelector<HTMLDivElement>(".pops-panel-select")!,
|
|
2119
|
+
select: $li.querySelector<HTMLSelectElement>(".pops-panel-select select")!,
|
|
2120
|
+
},
|
|
2121
|
+
$eleKey: {
|
|
2122
|
+
disable: "__disable__",
|
|
2123
|
+
value: "__value__",
|
|
2124
|
+
viewConfig: "data-view-config",
|
|
2125
|
+
},
|
|
2126
|
+
$data: {
|
|
2127
|
+
data: [] as PopsPanelSelectDataOption<any>[],
|
|
2128
|
+
defaultValue: viewConfig.getValue(),
|
|
2129
|
+
},
|
|
2130
|
+
init() {
|
|
2131
|
+
this.$data.data = typeof viewConfig.data === "function" ? viewConfig.data() : viewConfig.data;
|
|
2132
|
+
popsDOMUtils.addClassName(this.$el.panelSelect, PopsCommonCSSClassName.userSelectNone);
|
|
2133
|
+
this.initOption();
|
|
2134
|
+
this.onValueChange();
|
|
2135
|
+
this.onClick();
|
|
2136
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
2137
|
+
if (disabled) {
|
|
2138
|
+
this.disable();
|
|
1598
2139
|
}
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
|
|
2140
|
+
},
|
|
2141
|
+
/**
|
|
2142
|
+
* 给option元素设置属性
|
|
2143
|
+
* @param $ele
|
|
2144
|
+
* @param key
|
|
2145
|
+
* @param value
|
|
2146
|
+
*/
|
|
2147
|
+
setNodeValue($ele: HTMLElement, key: string, value: any) {
|
|
2148
|
+
Reflect.set($ele, key, value);
|
|
2149
|
+
},
|
|
2150
|
+
/**
|
|
2151
|
+
* 获取option元素上设置的属性
|
|
2152
|
+
* @param $ele
|
|
2153
|
+
* @param value
|
|
2154
|
+
* @param key
|
|
2155
|
+
*/
|
|
2156
|
+
getNodeValue($ele: HTMLElement, key: string) {
|
|
2157
|
+
return Reflect.get($ele, key);
|
|
2158
|
+
},
|
|
2159
|
+
/**
|
|
2160
|
+
* 禁用选项
|
|
2161
|
+
*/
|
|
2162
|
+
disable() {
|
|
2163
|
+
this.$el.select.setAttribute("disabled", "true");
|
|
2164
|
+
popsDOMUtils.addClassName(this.$el.panelSelect, "pops-panel-select-disable");
|
|
2165
|
+
popsDOMUtils.addClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
|
|
2166
|
+
},
|
|
2167
|
+
/**
|
|
2168
|
+
* 取消禁用
|
|
2169
|
+
*/
|
|
2170
|
+
notDisable() {
|
|
2171
|
+
this.$el.select.removeAttribute("disabled");
|
|
2172
|
+
popsDOMUtils.removeClassName(this.$el.panelSelect, "pops-panel-select-disable");
|
|
2173
|
+
popsDOMUtils.removeClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
|
|
2174
|
+
},
|
|
2175
|
+
/**
|
|
2176
|
+
* 判断是否禁用
|
|
2177
|
+
*/
|
|
2178
|
+
isDisabled() {
|
|
2179
|
+
return (
|
|
2180
|
+
this.$el.select.hasAttribute("disabled") ||
|
|
2181
|
+
popsDOMUtils.containsClassName(this.$el.panelSelect, "pops-panel-select-disable")
|
|
2182
|
+
);
|
|
2183
|
+
},
|
|
2184
|
+
/**
|
|
2185
|
+
* 初始化选项
|
|
2186
|
+
*/
|
|
2187
|
+
initOption() {
|
|
2188
|
+
this.$data.data.forEach((dataItem) => {
|
|
2189
|
+
// 初始化默认选中
|
|
2190
|
+
const optionElement = popsDOMUtils.createElement("option");
|
|
2191
|
+
this.setNodeValue(optionElement, this.$eleKey.value, dataItem.value);
|
|
2192
|
+
this.setNodeValue(optionElement, this.$eleKey.disable, dataItem.disable);
|
|
2193
|
+
this.setNodeValue(optionElement, this.$eleKey.viewConfig, dataItem.views);
|
|
2194
|
+
if (dataItem.value === this.$data.defaultValue) {
|
|
2195
|
+
this.setOptionSelected(optionElement);
|
|
2196
|
+
}
|
|
2197
|
+
if (typeof dataItem.text === "function") {
|
|
2198
|
+
optionElement.innerText = dataItem.text(dataItem.value, dataItem);
|
|
2199
|
+
} else {
|
|
2200
|
+
optionElement.innerText = dataItem.text;
|
|
2201
|
+
}
|
|
2202
|
+
this.$el.select.appendChild(optionElement);
|
|
2203
|
+
});
|
|
2204
|
+
},
|
|
2205
|
+
/**
|
|
2206
|
+
* 设置选项选中
|
|
2207
|
+
* @param $option
|
|
2208
|
+
*/
|
|
2209
|
+
setOptionSelected($option: HTMLOptionElement) {
|
|
2210
|
+
$option.setAttribute("selected", "true");
|
|
2211
|
+
},
|
|
2212
|
+
/**
|
|
2213
|
+
* 检测所有option并设置禁用状态
|
|
2214
|
+
*/
|
|
2215
|
+
setSelectOptionsDisableStatus() {
|
|
2216
|
+
if (this.$el.select.options && this.$el.select.options.length) {
|
|
2217
|
+
Array.from(this.$el.select.options).forEach((optionItem) => {
|
|
2218
|
+
this.setOptionDisableStatus(optionItem);
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
},
|
|
2222
|
+
/**
|
|
2223
|
+
* 设置禁用状态
|
|
2224
|
+
* @param $option
|
|
2225
|
+
*/
|
|
2226
|
+
setOptionDisableStatus($option: HTMLOptionElement) {
|
|
2227
|
+
let disable = false;
|
|
2228
|
+
const optionDisableAttr = this.getNodeValue($option, this.$eleKey.disable);
|
|
2229
|
+
if (optionDisableAttr === "function") {
|
|
2230
|
+
const value = this.getNodeValue($option, this.$eleKey.value);
|
|
2231
|
+
disable = Boolean(optionDisableAttr(value));
|
|
2232
|
+
}
|
|
2233
|
+
if (disable) {
|
|
2234
|
+
$option.setAttribute("disabled", "true");
|
|
2235
|
+
} else {
|
|
2236
|
+
$option.removeAttribute("disabled");
|
|
2237
|
+
}
|
|
2238
|
+
},
|
|
2239
|
+
/**
|
|
2240
|
+
* 获取option上的信息
|
|
2241
|
+
* @param $option
|
|
2242
|
+
*/
|
|
2243
|
+
getSelectOptionInfo($option: HTMLOptionElement) {
|
|
2244
|
+
const optionValue = this.getNodeValue($option, this.$eleKey.value);
|
|
2245
|
+
const optionText = $option.innerText || $option.textContent!;
|
|
2246
|
+
const views = this.getNodeValue($option, this.$eleKey.viewConfig) as NonNullable<
|
|
2247
|
+
PopsPanelSelectDataOption<any>["views"]
|
|
2248
|
+
>;
|
|
2249
|
+
return {
|
|
2250
|
+
value: optionValue,
|
|
2251
|
+
text: optionText,
|
|
2252
|
+
views: views,
|
|
2253
|
+
$option: $option,
|
|
2254
|
+
};
|
|
2255
|
+
},
|
|
2256
|
+
/**
|
|
2257
|
+
* 监听选择内容改变
|
|
2258
|
+
*/
|
|
2259
|
+
onValueChange() {
|
|
2260
|
+
popsDOMUtils.on<PointerEvent | TouchEvent>(this.$el.select, "change", () => {
|
|
2261
|
+
const $isSelectedElement = this.$el.select[this.$el.select.selectedIndex] as HTMLOptionElement;
|
|
2262
|
+
const selectInfo = this.getSelectOptionInfo($isSelectedElement);
|
|
2263
|
+
this.setSelectOptionsDisableStatus();
|
|
2264
|
+
if (typeof viewConfig.callback === "function") {
|
|
2265
|
+
viewConfig.callback(selectInfo);
|
|
2266
|
+
}
|
|
2267
|
+
const views = typeof selectInfo.views === "function" ? selectInfo.views() : selectInfo.views;
|
|
2268
|
+
if (Array.isArray(views)) {
|
|
2269
|
+
// 如果成功创建,加入到中间容器中
|
|
2270
|
+
const childUListClassName = "pops-panel-select-child-forms";
|
|
2271
|
+
// 移除旧的元素
|
|
2272
|
+
while ($li.nextElementSibling) {
|
|
2273
|
+
if ($li.nextElementSibling.classList.contains(childUListClassName)) {
|
|
2274
|
+
$li.nextElementSibling.remove();
|
|
2275
|
+
} else {
|
|
2276
|
+
break;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
const $childUList = popsDOMUtils.createElement("ul");
|
|
2280
|
+
$childUList.className = childUListClassName;
|
|
2281
|
+
popsDOMUtils.after($li, $childUList);
|
|
2282
|
+
that.uListContainerAddItem(viewConfig, {
|
|
2283
|
+
ulElement: $childUList,
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
},
|
|
2288
|
+
/**
|
|
2289
|
+
* 监听点击事件
|
|
2290
|
+
*/
|
|
2291
|
+
onClick() {
|
|
2292
|
+
popsDOMUtils.on(this.$el.select, "click", void 0, (event) => {
|
|
2293
|
+
this.setSelectOptionsDisableStatus();
|
|
2294
|
+
if (typeof viewConfig.clickCallBack === "function") {
|
|
2295
|
+
const $isSelectedElement = this.$el.select[this.$el.select.selectedIndex] as HTMLOptionElement;
|
|
2296
|
+
const selectInfo = this.getSelectOptionInfo($isSelectedElement);
|
|
2297
|
+
viewConfig.clickCallBack(event, selectInfo);
|
|
2298
|
+
}
|
|
2299
|
+
});
|
|
2300
|
+
},
|
|
2301
|
+
};
|
|
1602
2302
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
2303
|
+
PopsPanelSelectNative.init();
|
|
2304
|
+
Reflect.set($li, "data-select", PopsPanelSelectNative);
|
|
2305
|
+
handler = PopsPanelSelectNative;
|
|
2306
|
+
}
|
|
2307
|
+
return {
|
|
2308
|
+
$el: $li,
|
|
2309
|
+
handler: handler,
|
|
2310
|
+
};
|
|
1606
2311
|
},
|
|
1607
2312
|
/**
|
|
1608
2313
|
* type ==> select-multiple
|
|
1609
2314
|
* 获取中间容器的元素<li>
|
|
1610
|
-
* @param
|
|
2315
|
+
* @param viewConfig
|
|
1611
2316
|
*/
|
|
1612
|
-
|
|
2317
|
+
createSectionContainerItem_select_multiple(viewConfig: PopsPanelSelectMultipleConfig<any>) {
|
|
1613
2318
|
const $li = popsDOMUtils.createElement("li");
|
|
1614
|
-
Reflect.set($li,
|
|
1615
|
-
this.setElementClassName($li,
|
|
1616
|
-
this.setElementAttributes($li,
|
|
1617
|
-
this.setElementProps($li,
|
|
1618
|
-
|
|
2319
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
2320
|
+
this.setElementClassName($li, viewConfig.className);
|
|
2321
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
2322
|
+
this.setElementProps($li, viewConfig.props);
|
|
2323
|
+
// 左边底部的描述的文字
|
|
1619
2324
|
let leftDescriptionText = "";
|
|
1620
|
-
if (
|
|
1621
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
2325
|
+
if (viewConfig.description) {
|
|
2326
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
1622
2327
|
}
|
|
1623
2328
|
PopsSafeUtils.setSafeHTML(
|
|
1624
2329
|
$li,
|
|
1625
2330
|
/*html*/ `
|
|
1626
2331
|
<div class="pops-panel-item-left-text">
|
|
1627
|
-
<p class="pops-panel-item-left-main-text">${
|
|
2332
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
1628
2333
|
<div class="pops-panel-select-multiple">
|
|
1629
2334
|
<div class="el-select__wrapper">
|
|
1630
2335
|
<div class="el-select__selection">
|
|
@@ -1653,9 +2358,9 @@ export const PanelHandlerComponents = () => {
|
|
|
1653
2358
|
$el: {
|
|
1654
2359
|
/** 左侧文本容器 */
|
|
1655
2360
|
itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
|
|
1656
|
-
/**
|
|
2361
|
+
/** 选择框容器 */
|
|
1657
2362
|
$container: void 0 as any as HTMLElement,
|
|
1658
|
-
/**
|
|
2363
|
+
/** 选择框包裹的容器 */
|
|
1659
2364
|
$wrapper: void 0 as any as HTMLElement,
|
|
1660
2365
|
/** 内容区域 */
|
|
1661
2366
|
$section: void 0 as any as HTMLElement,
|
|
@@ -1672,8 +2377,15 @@ export const PanelHandlerComponents = () => {
|
|
|
1672
2377
|
},
|
|
1673
2378
|
$data: {
|
|
1674
2379
|
/** 默认值 */
|
|
1675
|
-
defaultValue:
|
|
1676
|
-
|
|
2380
|
+
defaultValue: viewConfig.getValue(),
|
|
2381
|
+
/**
|
|
2382
|
+
* 已选择的信息
|
|
2383
|
+
*/
|
|
2384
|
+
selectedDataList: [] as PopsPanelSelectMultipleDataOption<any>[],
|
|
2385
|
+
/**
|
|
2386
|
+
* 箭头旋转的属性
|
|
2387
|
+
*/
|
|
2388
|
+
rotateKey: "data-show-option",
|
|
1677
2389
|
},
|
|
1678
2390
|
/** 初始化 */
|
|
1679
2391
|
init() {
|
|
@@ -1681,24 +2393,19 @@ export const PanelHandlerComponents = () => {
|
|
|
1681
2393
|
this.inintEl();
|
|
1682
2394
|
this.initPlaceHolder();
|
|
1683
2395
|
this.initTagElement();
|
|
1684
|
-
this.
|
|
2396
|
+
this.onShowSelectDialogClick();
|
|
1685
2397
|
|
|
1686
|
-
const disabled = typeof
|
|
2398
|
+
const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
|
|
1687
2399
|
if (disabled) {
|
|
1688
2400
|
this.disable();
|
|
1689
2401
|
}
|
|
1690
2402
|
},
|
|
1691
2403
|
/** 初始化默认值 */
|
|
1692
2404
|
initDefault() {
|
|
1693
|
-
|
|
2405
|
+
viewConfig.data.forEach((dataItem) => {
|
|
1694
2406
|
if (this.$data.defaultValue.includes(dataItem.value)) {
|
|
1695
2407
|
// 初始化选中的配置
|
|
1696
|
-
this.$data.
|
|
1697
|
-
text: dataItem.text,
|
|
1698
|
-
value: dataItem.value,
|
|
1699
|
-
isHTML: Boolean(dataItem.isHTML),
|
|
1700
|
-
disable: dataItem.disable?.bind(dataItem),
|
|
1701
|
-
});
|
|
2408
|
+
this.$data.selectedDataList.push(dataItem);
|
|
1702
2409
|
}
|
|
1703
2410
|
});
|
|
1704
2411
|
},
|
|
@@ -1719,13 +2426,15 @@ export const PanelHandlerComponents = () => {
|
|
|
1719
2426
|
// 先把手动输入框隐藏
|
|
1720
2427
|
this.hideInputWrapper();
|
|
1721
2428
|
},
|
|
1722
|
-
/**
|
|
2429
|
+
/**
|
|
2430
|
+
* 初始化提示文字
|
|
2431
|
+
*/
|
|
1723
2432
|
initPlaceHolder() {
|
|
1724
2433
|
let placeholder = "";
|
|
1725
|
-
if (typeof
|
|
1726
|
-
placeholder =
|
|
1727
|
-
} else if (typeof
|
|
1728
|
-
const placeholderResult =
|
|
2434
|
+
if (typeof viewConfig.placeholder === "string") {
|
|
2435
|
+
placeholder = viewConfig.placeholder;
|
|
2436
|
+
} else if (typeof viewConfig.placeholder === "function") {
|
|
2437
|
+
const placeholderResult = viewConfig.placeholder();
|
|
1729
2438
|
if (typeof placeholderResult === "string") {
|
|
1730
2439
|
placeholder = placeholderResult;
|
|
1731
2440
|
}
|
|
@@ -1735,16 +2444,18 @@ export const PanelHandlerComponents = () => {
|
|
|
1735
2444
|
});
|
|
1736
2445
|
this.$el.$selectedPlaceHolderWrapper.appendChild($placeholder);
|
|
1737
2446
|
},
|
|
1738
|
-
/**
|
|
2447
|
+
/**
|
|
2448
|
+
* 初始化tag元素
|
|
2449
|
+
*/
|
|
1739
2450
|
initTagElement() {
|
|
1740
2451
|
// 遍历数据,寻找对应的值
|
|
1741
|
-
|
|
1742
|
-
const findValue = this.$data.
|
|
2452
|
+
viewConfig.data.forEach((dataItem) => {
|
|
2453
|
+
const findValue = this.$data.selectedDataList.find((item) => item.value === dataItem.value);
|
|
1743
2454
|
if (findValue) {
|
|
1744
2455
|
// 存在对应的值
|
|
1745
|
-
const selectedInfo = this.
|
|
1746
|
-
this.
|
|
1747
|
-
this.
|
|
2456
|
+
const selectedInfo = this.createTagItem(dataItem);
|
|
2457
|
+
this.addTagItem(selectedInfo.$tag);
|
|
2458
|
+
this.onSelectItemCloseIconClick({
|
|
1748
2459
|
$tag: selectedInfo.$tag,
|
|
1749
2460
|
$closeIcon: selectedInfo.$closeIcon,
|
|
1750
2461
|
value: dataItem.value,
|
|
@@ -1758,8 +2469,8 @@ export const PanelHandlerComponents = () => {
|
|
|
1758
2469
|
* 生成一个tag项
|
|
1759
2470
|
* @param data 配置
|
|
1760
2471
|
*/
|
|
1761
|
-
|
|
1762
|
-
const $
|
|
2472
|
+
createTagItem(data: PopsPanelSelectMultipleDataOption<any>) {
|
|
2473
|
+
const $tag = popsDOMUtils.createElement("div", {
|
|
1763
2474
|
className: "el-select__selected-item el-select__choose_tag",
|
|
1764
2475
|
innerHTML: /*html*/ `
|
|
1765
2476
|
<span class="el-tag is-closable el-tag--info el-tag--default el-tag--light">
|
|
@@ -1776,10 +2487,10 @@ export const PanelHandlerComponents = () => {
|
|
|
1776
2487
|
`,
|
|
1777
2488
|
});
|
|
1778
2489
|
/** 标签 */
|
|
1779
|
-
const $tagText = $
|
|
2490
|
+
const $tagText = $tag.querySelector<HTMLSpanElement>(".el-select__tags-text")!;
|
|
1780
2491
|
/** 关闭图标 */
|
|
1781
|
-
const $closeIcon = $
|
|
1782
|
-
const text = typeof data.text === "function" ? data.text(data, this.$data.
|
|
2492
|
+
const $closeIcon = $tag.querySelector<HTMLElement>(".el-icon.el-tag__close")!;
|
|
2493
|
+
const text = typeof data.text === "function" ? data.text(data, this.$data.selectedDataList) : data.text;
|
|
1783
2494
|
if (data.isHTML) {
|
|
1784
2495
|
PopsSafeUtils.setSafeHTML($tagText, text);
|
|
1785
2496
|
} else {
|
|
@@ -1787,7 +2498,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1787
2498
|
}
|
|
1788
2499
|
|
|
1789
2500
|
return {
|
|
1790
|
-
$tag: $
|
|
2501
|
+
$tag: $tag,
|
|
1791
2502
|
$tagText: $tagText,
|
|
1792
2503
|
$closeIcon: $closeIcon,
|
|
1793
2504
|
};
|
|
@@ -1796,7 +2507,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1796
2507
|
* 添加选中项的tag元素
|
|
1797
2508
|
* @param $tag 添加的元素
|
|
1798
2509
|
*/
|
|
1799
|
-
|
|
2510
|
+
addTagItem($tag: HTMLElement) {
|
|
1800
2511
|
// 往前添加
|
|
1801
2512
|
// 去除前面的空白
|
|
1802
2513
|
this.setSectionIsNear();
|
|
@@ -1825,8 +2536,10 @@ export const PanelHandlerComponents = () => {
|
|
|
1825
2536
|
this.hideInputWrapper();
|
|
1826
2537
|
this.hidePlaceHolderWrapper();
|
|
1827
2538
|
},
|
|
1828
|
-
/**
|
|
1829
|
-
|
|
2539
|
+
/**
|
|
2540
|
+
* 更新tag信息
|
|
2541
|
+
*/
|
|
2542
|
+
updateTagItem() {
|
|
1830
2543
|
this.$el.$section.querySelectorAll<HTMLElement>(".el-select__choose_tag").forEach(($ele) => {
|
|
1831
2544
|
$ele.remove();
|
|
1832
2545
|
});
|
|
@@ -1836,11 +2549,11 @@ export const PanelHandlerComponents = () => {
|
|
|
1836
2549
|
* 选中的值改变的回调
|
|
1837
2550
|
* @param selectedDataList 当前的选中信息
|
|
1838
2551
|
*/
|
|
1839
|
-
|
|
2552
|
+
onValueChange(selectedDataList?: PopsPanelSelectMultipleDataOption<any>[]) {
|
|
1840
2553
|
// 动态更新禁用状态
|
|
1841
|
-
this.
|
|
1842
|
-
if (typeof
|
|
1843
|
-
|
|
2554
|
+
this.updateAllSelectItems();
|
|
2555
|
+
if (typeof viewConfig.callback === "function") {
|
|
2556
|
+
viewConfig.callback(selectedDataList || this.$data.selectedDataList);
|
|
1844
2557
|
}
|
|
1845
2558
|
},
|
|
1846
2559
|
/**
|
|
@@ -1849,29 +2562,29 @@ export const PanelHandlerComponents = () => {
|
|
|
1849
2562
|
* + 更新禁用状态
|
|
1850
2563
|
* + 更新选中状态
|
|
1851
2564
|
*/
|
|
1852
|
-
|
|
2565
|
+
updateAllSelectItems() {
|
|
1853
2566
|
this.getAllSelectItemInfo(false).forEach(($selectInfo) => {
|
|
1854
2567
|
const { data, $select } = $selectInfo;
|
|
1855
2568
|
// 更新文字
|
|
1856
2569
|
this.setSelectItemText(data, $selectInfo.$select);
|
|
1857
2570
|
// 更新禁用状态
|
|
1858
|
-
if (typeof data.disable === "function" && data.disable(data.value, this.$data.
|
|
2571
|
+
if (typeof data.disable === "function" && data.disable(data.value, this.$data.selectedDataList)) {
|
|
1859
2572
|
// 禁用
|
|
1860
|
-
this.
|
|
2573
|
+
this.disableSelectItem($select);
|
|
1861
2574
|
// 移除选中信息
|
|
1862
2575
|
this.removeSelectedInfo(data, false);
|
|
1863
2576
|
// 移除选中状态
|
|
1864
|
-
this.
|
|
2577
|
+
this.removeItemSelected($select);
|
|
1865
2578
|
} else {
|
|
1866
2579
|
// 取消禁用
|
|
1867
|
-
this.
|
|
2580
|
+
this.cancleDisableSelectItem($select);
|
|
1868
2581
|
}
|
|
1869
2582
|
// 更新选中状态
|
|
1870
|
-
const findValue = this.$data.
|
|
2583
|
+
const findValue = this.$data.selectedDataList.find((it) => it.value === data.value);
|
|
1871
2584
|
if (findValue) {
|
|
1872
|
-
this.
|
|
2585
|
+
this.setItemSelected($select);
|
|
1873
2586
|
} else {
|
|
1874
|
-
this.
|
|
2587
|
+
this.removeItemSelected($select);
|
|
1875
2588
|
}
|
|
1876
2589
|
});
|
|
1877
2590
|
},
|
|
@@ -1879,22 +2592,22 @@ export const PanelHandlerComponents = () => {
|
|
|
1879
2592
|
* 设置选项元素选中
|
|
1880
2593
|
* @param $select 选项元素
|
|
1881
2594
|
*/
|
|
1882
|
-
|
|
1883
|
-
if (this.
|
|
2595
|
+
setItemSelected($select: HTMLElement) {
|
|
2596
|
+
if (this.isItemSelected($select)) return;
|
|
1884
2597
|
$select.classList.add("select-item-is-selected");
|
|
1885
2598
|
},
|
|
1886
2599
|
/**
|
|
1887
2600
|
* 移除选项元素选中
|
|
1888
2601
|
* @param $select 选项元素
|
|
1889
2602
|
*/
|
|
1890
|
-
|
|
2603
|
+
removeItemSelected($select: HTMLElement) {
|
|
1891
2604
|
$select.classList.remove("select-item-is-selected");
|
|
1892
2605
|
},
|
|
1893
2606
|
/**
|
|
1894
2607
|
* 判断选项元素是否选中
|
|
1895
2608
|
* @param $select
|
|
1896
2609
|
*/
|
|
1897
|
-
|
|
2610
|
+
isItemSelected($select: HTMLElement): boolean {
|
|
1898
2611
|
return $select.classList.contains("select-item-is-selected");
|
|
1899
2612
|
},
|
|
1900
2613
|
/**
|
|
@@ -1902,25 +2615,20 @@ export const PanelHandlerComponents = () => {
|
|
|
1902
2615
|
* @param dataList 选择项列表的数据
|
|
1903
2616
|
* @param $select 选项元素
|
|
1904
2617
|
*/
|
|
1905
|
-
|
|
2618
|
+
addItemSelected(dataList: PopsPanelSelectMultipleDataOption<any>[], $select: HTMLElement) {
|
|
1906
2619
|
const info = this.getSelectedItemInfo($select);
|
|
1907
2620
|
const findValue = dataList.find((item) => item.value === info.value);
|
|
1908
2621
|
if (!findValue) {
|
|
1909
|
-
dataList.push(
|
|
1910
|
-
value: info.value,
|
|
1911
|
-
text: info.text,
|
|
1912
|
-
isHTML: Boolean(info.isHTML),
|
|
1913
|
-
disable: info.disable?.bind(info),
|
|
1914
|
-
});
|
|
2622
|
+
dataList.push(info);
|
|
1915
2623
|
}
|
|
1916
|
-
this.
|
|
2624
|
+
this.onValueChange(dataList);
|
|
1917
2625
|
},
|
|
1918
2626
|
/**
|
|
1919
2627
|
* 获取选中的项的信息
|
|
1920
2628
|
* @param $select 选项元素
|
|
1921
2629
|
*/
|
|
1922
|
-
getSelectedItemInfo($select: HTMLElement) {
|
|
1923
|
-
return Reflect.get($select, "data-info")
|
|
2630
|
+
getSelectedItemInfo($select: HTMLElement): PopsPanelSelectMultipleDataOption<any> {
|
|
2631
|
+
return Reflect.get($select, "data-info");
|
|
1924
2632
|
},
|
|
1925
2633
|
/**
|
|
1926
2634
|
* 移除选中信息
|
|
@@ -1933,7 +2641,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1933
2641
|
if (findIndex !== -1) {
|
|
1934
2642
|
dataList.splice(findIndex, 1);
|
|
1935
2643
|
}
|
|
1936
|
-
this.
|
|
2644
|
+
this.onValueChange(dataList);
|
|
1937
2645
|
},
|
|
1938
2646
|
/**
|
|
1939
2647
|
* 获取所有选项的信息
|
|
@@ -1953,7 +2661,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1953
2661
|
};
|
|
1954
2662
|
if (onlySelected) {
|
|
1955
2663
|
// 仅选中
|
|
1956
|
-
const isSelected = this.
|
|
2664
|
+
const isSelected = this.isItemSelected($select);
|
|
1957
2665
|
if (isSelected) {
|
|
1958
2666
|
return result;
|
|
1959
2667
|
}
|
|
@@ -1987,7 +2695,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1987
2695
|
* @param $select 选择项元素
|
|
1988
2696
|
*/
|
|
1989
2697
|
setSelectItemText(data: PopsPanelSelectMultipleDataOption<any>, $select: HTMLElement) {
|
|
1990
|
-
const text = typeof data.text === "function" ? data.text(data.value, this.$data.
|
|
2698
|
+
const text = typeof data.text === "function" ? data.text(data.value, this.$data.selectedDataList) : data.text;
|
|
1991
2699
|
const $selectSpan = $select.querySelector<HTMLElement>(".select-item-text")!;
|
|
1992
2700
|
if (data.isHTML) {
|
|
1993
2701
|
PopsSafeUtils.setSafeHTML($selectSpan, text);
|
|
@@ -1999,7 +2707,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1999
2707
|
* 设置选择项的禁用状态
|
|
2000
2708
|
* @param $select 选择项元素
|
|
2001
2709
|
*/
|
|
2002
|
-
|
|
2710
|
+
disableSelectItem($select: HTMLElement) {
|
|
2003
2711
|
$select.setAttribute("aria-disabled", "true");
|
|
2004
2712
|
$select.setAttribute("disabled", "true");
|
|
2005
2713
|
},
|
|
@@ -2007,7 +2715,7 @@ export const PanelHandlerComponents = () => {
|
|
|
2007
2715
|
* 移除选择项的禁用状态
|
|
2008
2716
|
* @param $select 选择项元素
|
|
2009
2717
|
*/
|
|
2010
|
-
|
|
2718
|
+
cancleDisableSelectItem($select: HTMLElement) {
|
|
2011
2719
|
$select.removeAttribute("aria-disabled");
|
|
2012
2720
|
$select.removeAttribute("disabled");
|
|
2013
2721
|
},
|
|
@@ -2023,51 +2731,58 @@ export const PanelHandlerComponents = () => {
|
|
|
2023
2731
|
* @param dataList 选中的信息列表
|
|
2024
2732
|
* @param $select 选择项元素
|
|
2025
2733
|
*/
|
|
2026
|
-
|
|
2734
|
+
onSelectItemClick(dataList: PopsPanelSelectMultipleDataOption<any>[], $select: HTMLElement) {
|
|
2027
2735
|
popsDOMUtils.on<PointerEvent | MouseEvent>($select, "click", (event) => {
|
|
2028
2736
|
popsDOMUtils.preventEvent(event);
|
|
2029
2737
|
if (this.isSelectItemDisabled($select)) {
|
|
2030
2738
|
return;
|
|
2031
2739
|
}
|
|
2032
|
-
if (typeof
|
|
2740
|
+
if (typeof viewConfig.clickCallBack === "function") {
|
|
2033
2741
|
const allSelectedInfo = this.getAllSelectItemInfo().map((it) => it.data);
|
|
2034
|
-
const clickResult =
|
|
2742
|
+
const clickResult = viewConfig.clickCallBack(event, allSelectedInfo);
|
|
2035
2743
|
if (typeof clickResult === "boolean" && !clickResult) {
|
|
2036
2744
|
return;
|
|
2037
2745
|
}
|
|
2038
2746
|
}
|
|
2039
2747
|
// 修改选中状态
|
|
2040
|
-
if (this.
|
|
2041
|
-
this.
|
|
2748
|
+
if (this.isItemSelected($select)) {
|
|
2749
|
+
this.removeItemSelected($select);
|
|
2042
2750
|
this.removeSelectedItemInfo(dataList, $select);
|
|
2043
2751
|
} else {
|
|
2044
|
-
this.
|
|
2045
|
-
this.
|
|
2752
|
+
this.setItemSelected($select);
|
|
2753
|
+
this.addItemSelected(dataList, $select);
|
|
2046
2754
|
}
|
|
2047
2755
|
});
|
|
2048
2756
|
},
|
|
2049
2757
|
/**
|
|
2050
2758
|
* 设置下拉列表的点击事件
|
|
2759
|
+
*
|
|
2760
|
+
* 点击显示下拉列表弹窗
|
|
2051
2761
|
*/
|
|
2052
|
-
|
|
2053
|
-
const
|
|
2762
|
+
onShowSelectDialogClick() {
|
|
2763
|
+
const defaultCSS = PopsCSS.panelComponents_Select;
|
|
2054
2764
|
popsDOMUtils.on(this.$el.$container, "click", () => {
|
|
2055
2765
|
if (this.isDisabled()) {
|
|
2056
2766
|
return;
|
|
2057
2767
|
}
|
|
2058
|
-
/**
|
|
2059
|
-
const
|
|
2060
|
-
const { style, ...
|
|
2061
|
-
const
|
|
2062
|
-
|
|
2768
|
+
/** 当前已选中的值 */
|
|
2769
|
+
const selectInfo = this.$data.selectedDataList;
|
|
2770
|
+
const { style, ...userConfirmConfig } = viewConfig.selectConfirmDialogConfig || {};
|
|
2771
|
+
const dialogCloseCallback = () => {
|
|
2772
|
+
this.$data.selectedDataList = [...selectInfo];
|
|
2773
|
+
this.updateTagItem();
|
|
2774
|
+
this.$el.$selectContainer = null;
|
|
2775
|
+
this.$el.$container.removeAttribute(this.$data.rotateKey);
|
|
2776
|
+
};
|
|
2777
|
+
this.$el.$container.setAttribute(this.$data.rotateKey, String(true));
|
|
2778
|
+
const confirmConfig = popsUtils.assign(
|
|
2779
|
+
<PopsAlertConfig>{
|
|
2063
2780
|
title: {
|
|
2064
2781
|
text: "请勾选需要选择的选项",
|
|
2065
2782
|
position: "center",
|
|
2066
2783
|
},
|
|
2067
2784
|
content: {
|
|
2068
|
-
text: /*html*/
|
|
2069
|
-
<ul class="select-container"></ul>
|
|
2070
|
-
`,
|
|
2785
|
+
text: /*html*/ `<ul class="select-container"></ul>`,
|
|
2071
2786
|
html: true,
|
|
2072
2787
|
},
|
|
2073
2788
|
btn: {
|
|
@@ -2076,11 +2791,9 @@ export const PanelHandlerComponents = () => {
|
|
|
2076
2791
|
},
|
|
2077
2792
|
close: {
|
|
2078
2793
|
enable: true,
|
|
2079
|
-
callback(
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
that.$el.$selectContainer = null;
|
|
2083
|
-
details.close();
|
|
2794
|
+
callback(evtConfig) {
|
|
2795
|
+
evtConfig.close();
|
|
2796
|
+
dialogCloseCallback();
|
|
2084
2797
|
},
|
|
2085
2798
|
},
|
|
2086
2799
|
},
|
|
@@ -2088,9 +2801,7 @@ export const PanelHandlerComponents = () => {
|
|
|
2088
2801
|
enable: true,
|
|
2089
2802
|
clickCallBack(originalRun) {
|
|
2090
2803
|
originalRun();
|
|
2091
|
-
|
|
2092
|
-
that.updateSelectTagItem();
|
|
2093
|
-
that.$el.$selectContainer = null;
|
|
2804
|
+
dialogCloseCallback();
|
|
2094
2805
|
},
|
|
2095
2806
|
clickEvent: {
|
|
2096
2807
|
toClose: true,
|
|
@@ -2099,94 +2810,35 @@ export const PanelHandlerComponents = () => {
|
|
|
2099
2810
|
drag: true,
|
|
2100
2811
|
dragLimit: true,
|
|
2101
2812
|
width: "300px",
|
|
2102
|
-
height: "
|
|
2813
|
+
height: "auto",
|
|
2103
2814
|
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
|
-
}
|
|
2815
|
+
${defaultCSS}
|
|
2164
2816
|
|
|
2165
|
-
|
|
2817
|
+
${style || ""}
|
|
2166
2818
|
`,
|
|
2167
2819
|
},
|
|
2168
|
-
|
|
2820
|
+
userConfirmConfig
|
|
2169
2821
|
);
|
|
2170
|
-
const $dialog = PopsAlert.init(
|
|
2822
|
+
const $dialog = PopsAlert.init(confirmConfig);
|
|
2171
2823
|
const $selectContainer = $dialog.$shadowRoot.querySelector<HTMLUListElement>(".select-container")!;
|
|
2172
|
-
this.$el.$selectContainer = $selectContainer;
|
|
2173
2824
|
// 配置选项元素
|
|
2174
|
-
|
|
2825
|
+
viewConfig.data.forEach((item) => {
|
|
2175
2826
|
const $select = this.createSelectItemElement(item);
|
|
2176
2827
|
// 添加到confirm中
|
|
2177
2828
|
$selectContainer.appendChild($select);
|
|
2178
2829
|
// 设置每一项的点击事件
|
|
2179
|
-
this.
|
|
2830
|
+
this.onSelectItemClick(selectInfo, $select);
|
|
2180
2831
|
});
|
|
2832
|
+
this.$el.$selectContainer = $selectContainer;
|
|
2181
2833
|
// 动态更新禁用状态
|
|
2182
|
-
this.
|
|
2834
|
+
this.updateAllSelectItems();
|
|
2183
2835
|
});
|
|
2184
2836
|
},
|
|
2185
2837
|
/**
|
|
2186
2838
|
* 设置关闭图标的点击事件
|
|
2187
2839
|
* @param data 选中的信息
|
|
2188
2840
|
*/
|
|
2189
|
-
|
|
2841
|
+
onSelectItemCloseIconClick(data: {
|
|
2190
2842
|
/** 关闭图标的元素 */
|
|
2191
2843
|
$closeIcon: HTMLElement;
|
|
2192
2844
|
/** tag元素 */
|
|
@@ -2204,8 +2856,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2204
2856
|
if (this.isDisabled()) {
|
|
2205
2857
|
return;
|
|
2206
2858
|
}
|
|
2207
|
-
if (typeof
|
|
2208
|
-
const result =
|
|
2859
|
+
if (typeof viewConfig.closeIconClickCallBack === "function") {
|
|
2860
|
+
const result = viewConfig.closeIconClickCallBack(event, {
|
|
2209
2861
|
$tag: data.$tag,
|
|
2210
2862
|
$closeIcon: data.$closeIcon,
|
|
2211
2863
|
value: data.value,
|
|
@@ -2227,7 +2879,9 @@ export const PanelHandlerComponents = () => {
|
|
|
2227
2879
|
);
|
|
2228
2880
|
},
|
|
2229
2881
|
/**
|
|
2230
|
-
* 检测tag
|
|
2882
|
+
* 检测tag是否为空
|
|
2883
|
+
*
|
|
2884
|
+
* 如果为空则显示placeholder
|
|
2231
2885
|
*/
|
|
2232
2886
|
checkTagEmpty() {
|
|
2233
2887
|
if (!this.$el.$section.querySelectorAll(".el-select__choose_tag").length) {
|
|
@@ -2252,14 +2906,14 @@ export const PanelHandlerComponents = () => {
|
|
|
2252
2906
|
* + false 不触发值改变的回调
|
|
2253
2907
|
*/
|
|
2254
2908
|
removeSelectedInfo(data: PopsPanelSelectMultipleDataOption<any>, triggerValueChangeCallBack: boolean = true) {
|
|
2255
|
-
for (let index = 0; index < this.$data.
|
|
2256
|
-
const selectInfo = this.$data.
|
|
2909
|
+
for (let index = 0; index < this.$data.selectedDataList.length; index++) {
|
|
2910
|
+
const selectInfo = this.$data.selectedDataList[index];
|
|
2257
2911
|
if (selectInfo.value === data.value) {
|
|
2258
|
-
this.$data.
|
|
2912
|
+
this.$data.selectedDataList.splice(index, 1);
|
|
2259
2913
|
break;
|
|
2260
2914
|
}
|
|
2261
2915
|
}
|
|
2262
|
-
triggerValueChangeCallBack && this.
|
|
2916
|
+
triggerValueChangeCallBack && this.onValueChange();
|
|
2263
2917
|
},
|
|
2264
2918
|
/** 显示输入框 */
|
|
2265
2919
|
showInputWrapper() {
|
|
@@ -2309,30 +2963,33 @@ export const PanelHandlerComponents = () => {
|
|
|
2309
2963
|
|
|
2310
2964
|
PopsPanelSelectMultiple.init();
|
|
2311
2965
|
Reflect.set($li, "data-select-multiple", PopsPanelSelectMultiple);
|
|
2312
|
-
return
|
|
2966
|
+
return {
|
|
2967
|
+
$el: $li,
|
|
2968
|
+
handler: PopsPanelSelectMultiple,
|
|
2969
|
+
};
|
|
2313
2970
|
},
|
|
2314
2971
|
/**
|
|
2315
2972
|
* type ==> button
|
|
2316
2973
|
* 获取中间容器的元素<li>
|
|
2317
|
-
* @param
|
|
2974
|
+
* @param viewConfig
|
|
2318
2975
|
*/
|
|
2319
|
-
createSectionContainerItem_button(
|
|
2976
|
+
createSectionContainerItem_button(viewConfig: PopsPanelButtonConfig) {
|
|
2320
2977
|
const $li = popsDOMUtils.createElement("li");
|
|
2321
|
-
Reflect.set($li,
|
|
2322
|
-
this.setElementClassName($li,
|
|
2323
|
-
this.setElementAttributes($li,
|
|
2324
|
-
this.setElementProps($li,
|
|
2978
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
2979
|
+
this.setElementClassName($li, viewConfig.className);
|
|
2980
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
2981
|
+
this.setElementProps($li, viewConfig.props);
|
|
2325
2982
|
|
|
2326
|
-
|
|
2983
|
+
// 左边底部的描述的文字
|
|
2327
2984
|
let leftDescriptionText = "";
|
|
2328
|
-
if (
|
|
2329
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${
|
|
2985
|
+
if (viewConfig.description) {
|
|
2986
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
2330
2987
|
}
|
|
2331
2988
|
PopsSafeUtils.setSafeHTML(
|
|
2332
2989
|
$li,
|
|
2333
2990
|
/*html*/ `
|
|
2334
2991
|
<div class="pops-panel-item-left-text">
|
|
2335
|
-
<p class="pops-panel-item-left-main-text">${
|
|
2992
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
2336
2993
|
<div class="pops-panel-button">
|
|
2337
2994
|
<button class="pops-panel-button_inner" type="button">
|
|
2338
2995
|
<i class="pops-bottom-icon"></i>
|
|
@@ -2354,36 +3011,36 @@ export const PanelHandlerComponents = () => {
|
|
|
2354
3011
|
init() {
|
|
2355
3012
|
this.$ele.panelButton.appendChild(this.$ele.button);
|
|
2356
3013
|
this.initButton();
|
|
2357
|
-
this.
|
|
3014
|
+
this.onButtonClick();
|
|
2358
3015
|
},
|
|
2359
3016
|
initButton() {
|
|
2360
|
-
if (typeof
|
|
2361
|
-
|
|
2362
|
-
if (PopsIcon.hasIcon(
|
|
2363
|
-
this.setIconSVG(PopsIcon.getIcon(
|
|
3017
|
+
if (typeof viewConfig.buttonIcon === "string" && viewConfig.buttonIcon.trim() !== "") {
|
|
3018
|
+
// 存在icon图标且不为空
|
|
3019
|
+
if (PopsIcon.hasIcon(viewConfig.buttonIcon)) {
|
|
3020
|
+
this.setIconSVG(PopsIcon.getIcon(viewConfig.buttonIcon)!);
|
|
2364
3021
|
} else {
|
|
2365
|
-
this.setIconSVG(
|
|
3022
|
+
this.setIconSVG(viewConfig.buttonIcon);
|
|
2366
3023
|
}
|
|
2367
3024
|
this.showIcon();
|
|
2368
3025
|
} else {
|
|
2369
3026
|
this.hideIcon();
|
|
2370
3027
|
}
|
|
2371
|
-
|
|
2372
|
-
let buttonText =
|
|
2373
|
-
if (typeof
|
|
2374
|
-
buttonText =
|
|
3028
|
+
// 按钮文字
|
|
3029
|
+
let buttonText = viewConfig.buttonText;
|
|
3030
|
+
if (typeof viewConfig.buttonText === "function") {
|
|
3031
|
+
buttonText = viewConfig.buttonText();
|
|
2375
3032
|
}
|
|
2376
|
-
this.setButtonType(
|
|
2377
|
-
if (
|
|
3033
|
+
this.setButtonType(viewConfig.buttonType);
|
|
3034
|
+
if (viewConfig.buttonIsRightIcon) {
|
|
2378
3035
|
this.setIconRight();
|
|
2379
3036
|
} else {
|
|
2380
3037
|
this.setIconLeft();
|
|
2381
3038
|
}
|
|
2382
|
-
if (
|
|
3039
|
+
if (viewConfig.disable) {
|
|
2383
3040
|
this.disable();
|
|
2384
3041
|
}
|
|
2385
3042
|
this.setButtonText(buttonText as string);
|
|
2386
|
-
this.setIconLoadingStatus(
|
|
3043
|
+
this.setIconLoadingStatus(viewConfig.buttonIconIsLoading);
|
|
2387
3044
|
},
|
|
2388
3045
|
disable() {
|
|
2389
3046
|
this.$ele.button.setAttribute("disabled", "true");
|
|
@@ -2448,55 +3105,61 @@ export const PanelHandlerComponents = () => {
|
|
|
2448
3105
|
setButtonText(text: string) {
|
|
2449
3106
|
PopsSafeUtils.setSafeHTML(this.$ele.spanText, text);
|
|
2450
3107
|
},
|
|
2451
|
-
|
|
3108
|
+
/**
|
|
3109
|
+
* 设置按钮的点击事件
|
|
3110
|
+
*/
|
|
3111
|
+
onButtonClick() {
|
|
2452
3112
|
popsDOMUtils.on(this.$ele.button, "click", void 0, (event) => {
|
|
2453
|
-
if (typeof
|
|
2454
|
-
|
|
3113
|
+
if (typeof viewConfig.callback === "function") {
|
|
3114
|
+
viewConfig.callback(event);
|
|
2455
3115
|
}
|
|
2456
3116
|
});
|
|
2457
3117
|
},
|
|
2458
3118
|
};
|
|
2459
3119
|
PopsPanelButton.init();
|
|
2460
3120
|
Reflect.set($li, "data-button", PopsPanelButton);
|
|
2461
|
-
return
|
|
3121
|
+
return {
|
|
3122
|
+
$el: $li,
|
|
3123
|
+
handler: PopsPanelButton,
|
|
3124
|
+
};
|
|
2462
3125
|
},
|
|
2463
3126
|
/**
|
|
2464
3127
|
* type ==> deepMenu
|
|
2465
3128
|
* 获取深层容器的元素<li>
|
|
2466
|
-
* @param
|
|
3129
|
+
* @param viewConfig
|
|
2467
3130
|
*/
|
|
2468
|
-
createSectionContainerItem_deepMenu(
|
|
3131
|
+
createSectionContainerItem_deepMenu(viewConfig: PopsPanelDeepViewConfig) {
|
|
2469
3132
|
const that = this;
|
|
2470
3133
|
const $li = popsDOMUtils.createElement("li");
|
|
2471
3134
|
popsDOMUtils.addClassName($li, "pops-panel-deepMenu-nav-item");
|
|
2472
|
-
Reflect.set($li,
|
|
2473
|
-
this.setElementClassName($li,
|
|
3135
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
3136
|
+
this.setElementClassName($li, viewConfig.className);
|
|
2474
3137
|
// 设置属性
|
|
2475
|
-
this.setElementAttributes($li,
|
|
3138
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
2476
3139
|
// 设置元素上的属性
|
|
2477
|
-
this.setElementProps($li,
|
|
3140
|
+
this.setElementProps($li, viewConfig.props);
|
|
2478
3141
|
|
|
2479
|
-
|
|
3142
|
+
// 左边底部的描述的文字
|
|
2480
3143
|
let leftDescriptionText = "";
|
|
2481
|
-
if (
|
|
3144
|
+
if (viewConfig.description) {
|
|
2482
3145
|
// 设置描述
|
|
2483
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${
|
|
3146
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
|
|
2484
3147
|
}
|
|
2485
3148
|
// 箭头图标
|
|
2486
|
-
const arrowRightIcon = typeof
|
|
3149
|
+
const arrowRightIcon = typeof viewConfig.arrowRightIcon === "boolean" ? viewConfig.arrowRightIcon : true;
|
|
2487
3150
|
let arrowRightIconHTML = "";
|
|
2488
3151
|
if (arrowRightIcon) {
|
|
2489
3152
|
arrowRightIconHTML = `<i class="pops-panel-deepMenu-arrowRight-icon">${PopsIcon.getIcon("arrowRight")}</i>`;
|
|
2490
3153
|
}
|
|
2491
3154
|
let rightText = "";
|
|
2492
|
-
if (
|
|
2493
|
-
rightText = /*html*/ `<p class="pops-panel-item-right-text">${
|
|
3155
|
+
if (viewConfig.rightText) {
|
|
3156
|
+
rightText = /*html*/ `<p class="pops-panel-item-right-text">${viewConfig.rightText}</p>`;
|
|
2494
3157
|
}
|
|
2495
3158
|
PopsSafeUtils.setSafeHTML(
|
|
2496
3159
|
$li,
|
|
2497
3160
|
/*html*/ `
|
|
2498
3161
|
<div class="pops-panel-item-left-text">
|
|
2499
|
-
<p class="pops-panel-item-left-main-text">${
|
|
3162
|
+
<p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
|
|
2500
3163
|
<div class="pops-panel-deepMenu">${rightText}${arrowRightIconHTML}</div>
|
|
2501
3164
|
`
|
|
2502
3165
|
);
|
|
@@ -2508,36 +3171,36 @@ export const PanelHandlerComponents = () => {
|
|
|
2508
3171
|
},
|
|
2509
3172
|
},
|
|
2510
3173
|
init() {
|
|
2511
|
-
this.
|
|
3174
|
+
this.onLiClick();
|
|
2512
3175
|
},
|
|
2513
3176
|
/**
|
|
2514
3177
|
* 生成配置每一项的元素
|
|
2515
3178
|
* @param $container
|
|
2516
3179
|
* @param formItemConfig
|
|
2517
3180
|
*/
|
|
2518
|
-
|
|
2519
|
-
const
|
|
2520
|
-
if (
|
|
2521
|
-
const childForms =
|
|
2522
|
-
|
|
3181
|
+
initContainerItem($container: HTMLElement, formItemConfig: PopsPanelViewConfig | PopsPanelContainerConfig) {
|
|
3182
|
+
const containerViewConfig = formItemConfig as PopsPanelContainerConfig;
|
|
3183
|
+
if (containerViewConfig.type === "container") {
|
|
3184
|
+
const childForms = containerViewConfig["views"];
|
|
3185
|
+
// 每一项<li>元素
|
|
2523
3186
|
const formContainerListElement = popsDOMUtils.createElement("li");
|
|
2524
|
-
|
|
3187
|
+
// 每一项<li>内的子<ul>元素
|
|
2525
3188
|
const formContainerULElement = popsDOMUtils.createElement("ul");
|
|
2526
3189
|
formContainerULElement.classList.add("pops-panel-forms-container-item-formlist");
|
|
2527
3190
|
formContainerListElement.classList.add("pops-panel-forms-container-item");
|
|
2528
|
-
|
|
3191
|
+
// 区域头部的文字
|
|
2529
3192
|
const formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
2530
3193
|
className: "pops-panel-forms-container-item-header-text",
|
|
2531
3194
|
});
|
|
2532
|
-
PopsSafeUtils.setSafeHTML(formHeaderDivElement,
|
|
3195
|
+
PopsSafeUtils.setSafeHTML(formHeaderDivElement, containerViewConfig["text"]);
|
|
2533
3196
|
|
|
2534
|
-
if (
|
|
2535
|
-
|
|
2536
|
-
|
|
3197
|
+
if (containerViewConfig.isFold) {
|
|
3198
|
+
// 添加第一个
|
|
3199
|
+
// 加进容器内
|
|
2537
3200
|
PopsSafeUtils.setSafeHTML(
|
|
2538
3201
|
formHeaderDivElement,
|
|
2539
3202
|
/*html*/ `
|
|
2540
|
-
<p>${
|
|
3203
|
+
<p>${containerViewConfig.text}</p>
|
|
2541
3204
|
<i class="pops-panel-forms-fold-container-icon">
|
|
2542
3205
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
2543
3206
|
<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 +3222,15 @@ export const PanelHandlerComponents = () => {
|
|
|
2559
3222
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold");
|
|
2560
3223
|
formContainerListElement.appendChild(formHeaderDivElement);
|
|
2561
3224
|
} else {
|
|
2562
|
-
|
|
3225
|
+
// 加进容器内
|
|
2563
3226
|
formContainerListElement.appendChild(formHeaderDivElement);
|
|
2564
3227
|
}
|
|
2565
3228
|
|
|
2566
3229
|
that.setElementClassName(formContainerListElement, formItemConfig.className);
|
|
2567
3230
|
that.setElementAttributes(formContainerListElement, formItemConfig.attributes);
|
|
2568
3231
|
that.setElementProps(formContainerListElement, formItemConfig.props);
|
|
2569
|
-
childForms.forEach((
|
|
2570
|
-
that.uListContainerAddItem(
|
|
3232
|
+
childForms.forEach((childViewConfig) => {
|
|
3233
|
+
that.uListContainerAddItem(childViewConfig, {
|
|
2571
3234
|
ulElement: formContainerULElement,
|
|
2572
3235
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
2573
3236
|
formContainerListElement: formContainerListElement,
|
|
@@ -2576,8 +3239,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2576
3239
|
});
|
|
2577
3240
|
formContainerListElement.appendChild(formContainerULElement);
|
|
2578
3241
|
$container.appendChild(formContainerListElement);
|
|
2579
|
-
if (typeof
|
|
2580
|
-
|
|
3242
|
+
if (typeof containerViewConfig.afterAddToUListCallBack === "function") {
|
|
3243
|
+
containerViewConfig.afterAddToUListCallBack(viewConfig as any as PopsPanelContainerConfig, {
|
|
2581
3244
|
target: formContainerListElement,
|
|
2582
3245
|
ulElement: formContainerULElement,
|
|
2583
3246
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
@@ -2586,8 +3249,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2586
3249
|
});
|
|
2587
3250
|
}
|
|
2588
3251
|
} else {
|
|
2589
|
-
|
|
2590
|
-
that.uListContainerAddItem(
|
|
3252
|
+
// 如果成功创建,加入到中间容器中
|
|
3253
|
+
that.uListContainerAddItem(viewConfig, {
|
|
2591
3254
|
ulElement: that.sectionContainerULElement,
|
|
2592
3255
|
});
|
|
2593
3256
|
}
|
|
@@ -2604,7 +3267,7 @@ export const PanelHandlerComponents = () => {
|
|
|
2604
3267
|
const $deepMenuSection = popsDOMUtils.createElement("section", {
|
|
2605
3268
|
className: "pops-panel-container pops-panel-deepMenu-container",
|
|
2606
3269
|
});
|
|
2607
|
-
Reflect.set($deepMenuSection,
|
|
3270
|
+
Reflect.set($deepMenuSection, that.$data.nodeStoreConfigKey, viewConfig);
|
|
2608
3271
|
const $deepMenuHeaderUL = popsDOMUtils.createElement("ul", {
|
|
2609
3272
|
className: "pops-panel-container-header-ul pops-panel-deepMenu-container-header-ul",
|
|
2610
3273
|
});
|
|
@@ -2612,7 +3275,7 @@ export const PanelHandlerComponents = () => {
|
|
|
2612
3275
|
className: "pops-panel-container-main-ul",
|
|
2613
3276
|
});
|
|
2614
3277
|
// 标题文字
|
|
2615
|
-
const headerTitleText =
|
|
3278
|
+
const headerTitleText = viewConfig.headerTitle ?? viewConfig.text;
|
|
2616
3279
|
const $header = popsDOMUtils.createElement("li", {
|
|
2617
3280
|
className: "pops-panel-container-header-title-text pops-panel-deepMenu-container-header",
|
|
2618
3281
|
innerHTML: /*html*/ `<p class="pops-panel-deepMenu-container-header-title-text">${headerTitleText}</p>`,
|
|
@@ -2692,10 +3355,10 @@ export const PanelHandlerComponents = () => {
|
|
|
2692
3355
|
$deepMenuSection.appendChild($deepMenuHeaderUL);
|
|
2693
3356
|
$deepMenuSection.appendChild($deepMenuMain);
|
|
2694
3357
|
|
|
2695
|
-
if (
|
|
2696
|
-
for (let index = 0; index <
|
|
2697
|
-
const formItemConfig =
|
|
2698
|
-
this.
|
|
3358
|
+
if (viewConfig.views && Array.isArray(viewConfig.views)) {
|
|
3359
|
+
for (let index = 0; index < viewConfig.views.length; index++) {
|
|
3360
|
+
const formItemConfig = viewConfig.views[index];
|
|
3361
|
+
this.initContainerItem($deepMenuMain, formItemConfig);
|
|
2699
3362
|
}
|
|
2700
3363
|
}
|
|
2701
3364
|
that.$el.$panelRightSectionWrapper.appendChild($deepMenuSection);
|
|
@@ -2720,21 +3383,21 @@ export const PanelHandlerComponents = () => {
|
|
|
2720
3383
|
} else {
|
|
2721
3384
|
enterViewTransition();
|
|
2722
3385
|
}
|
|
2723
|
-
if (typeof
|
|
2724
|
-
|
|
2725
|
-
sectionContainer: $deepMenuSection,
|
|
2726
|
-
sectionContainerHeaderContainer: $deepMenuHeaderUL,
|
|
2727
|
-
sectionContainerHeader: $header,
|
|
2728
|
-
sectionBodyContainer: $deepMenuMain,
|
|
3386
|
+
if (typeof viewConfig.afterEnterDeepMenuCallBack === "function") {
|
|
3387
|
+
viewConfig.afterEnterDeepMenuCallBack(viewConfig, {
|
|
3388
|
+
$sectionContainer: $deepMenuSection,
|
|
3389
|
+
$sectionContainerHeaderContainer: $deepMenuHeaderUL,
|
|
3390
|
+
$sectionContainerHeader: $header,
|
|
3391
|
+
$sectionBodyContainer: $deepMenuMain,
|
|
2729
3392
|
});
|
|
2730
3393
|
}
|
|
2731
3394
|
that.triggerRenderRightContainer($deepMenuSection);
|
|
2732
3395
|
},
|
|
2733
3396
|
/** 设置项的点击事件 */
|
|
2734
|
-
|
|
3397
|
+
onLiClick() {
|
|
2735
3398
|
popsDOMUtils.on($li, "click", void 0, async (event) => {
|
|
2736
|
-
if (typeof
|
|
2737
|
-
const result = await
|
|
3399
|
+
if (typeof viewConfig.clickCallBack === "function") {
|
|
3400
|
+
const result = await viewConfig.clickCallBack(event, viewConfig);
|
|
2738
3401
|
if (result) {
|
|
2739
3402
|
return;
|
|
2740
3403
|
}
|
|
@@ -2747,79 +3410,84 @@ export const PanelHandlerComponents = () => {
|
|
|
2747
3410
|
PopsPanelDeepMenu.init();
|
|
2748
3411
|
Reflect.set($li, "data-deepMenu", PopsPanelDeepMenu);
|
|
2749
3412
|
|
|
2750
|
-
return
|
|
3413
|
+
return {
|
|
3414
|
+
$el: $li,
|
|
3415
|
+
handler: PopsPanelDeepMenu,
|
|
3416
|
+
};
|
|
2751
3417
|
},
|
|
2752
3418
|
/**
|
|
2753
3419
|
* type ===> own
|
|
2754
3420
|
* 获取中间容器的元素<li>
|
|
2755
|
-
* @param
|
|
3421
|
+
* @param viewConfig
|
|
2756
3422
|
*/
|
|
2757
|
-
createSectionContainerItem_own(
|
|
3423
|
+
createSectionContainerItem_own(viewConfig: PopsPanelOwnConfig) {
|
|
2758
3424
|
let $li = popsDOMUtils.createElement("li");
|
|
2759
|
-
Reflect.set($li,
|
|
2760
|
-
this.setElementClassName($li,
|
|
2761
|
-
this.setElementAttributes($li,
|
|
2762
|
-
this.setElementProps($li,
|
|
2763
|
-
$li =
|
|
2764
|
-
return
|
|
3425
|
+
Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
|
|
3426
|
+
this.setElementClassName($li, viewConfig.className);
|
|
3427
|
+
this.setElementAttributes($li, viewConfig.attributes);
|
|
3428
|
+
this.setElementProps($li, viewConfig.props);
|
|
3429
|
+
$li = viewConfig.createLIElement($li);
|
|
3430
|
+
return {
|
|
3431
|
+
$el: $li,
|
|
3432
|
+
};
|
|
2765
3433
|
},
|
|
2766
3434
|
/**
|
|
2767
3435
|
* 获取中间容器的元素<li>
|
|
2768
|
-
* @param
|
|
3436
|
+
* @param viewConfig 视图配置
|
|
2769
3437
|
*/
|
|
2770
|
-
createSectionContainerItem(
|
|
3438
|
+
createSectionContainerItem(viewConfig: PopsPanelViewConfig) {
|
|
2771
3439
|
/** 配置项的类型 */
|
|
2772
|
-
const
|
|
3440
|
+
const componentType = viewConfig.type;
|
|
2773
3441
|
|
|
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(
|
|
3442
|
+
if (componentType === "switch") {
|
|
3443
|
+
return this.createSectionContainerItem_switch(viewConfig);
|
|
3444
|
+
} else if (componentType === "slider") {
|
|
3445
|
+
return this.createSectionContainerItem_slider_new(viewConfig);
|
|
3446
|
+
} else if (componentType === "input") {
|
|
3447
|
+
return this.createSectionContainerItem_input(viewConfig);
|
|
3448
|
+
} else if (componentType === "textarea") {
|
|
3449
|
+
return this.createSectionContainerItem_textarea(viewConfig);
|
|
3450
|
+
} else if (componentType === "select") {
|
|
3451
|
+
return this.createSectionContainerItem_select(viewConfig);
|
|
3452
|
+
} else if (componentType === "select-multiple") {
|
|
3453
|
+
return this.createSectionContainerItem_select_multiple(viewConfig);
|
|
3454
|
+
} else if (componentType === "button") {
|
|
3455
|
+
return this.createSectionContainerItem_button(viewConfig);
|
|
3456
|
+
} else if (componentType === "deepMenu") {
|
|
3457
|
+
return this.createSectionContainerItem_deepMenu(viewConfig);
|
|
3458
|
+
} else if (componentType === "own") {
|
|
3459
|
+
return this.createSectionContainerItem_own(viewConfig);
|
|
2792
3460
|
} else {
|
|
2793
|
-
console.error("尚未实现的type类型",
|
|
3461
|
+
console.error("尚未实现的type类型", viewConfig);
|
|
2794
3462
|
}
|
|
2795
3463
|
},
|
|
2796
3464
|
/**
|
|
2797
3465
|
* 生成配置项forms
|
|
2798
3466
|
* 生成配置每一项的元素
|
|
2799
|
-
* @param
|
|
3467
|
+
* @param viewConfig
|
|
2800
3468
|
*/
|
|
2801
|
-
createSectionContainerItem_forms(
|
|
3469
|
+
createSectionContainerItem_forms(viewConfig: PopsPanelContentConfig | PopsPanelContainerConfig) {
|
|
2802
3470
|
const that = this;
|
|
2803
|
-
const
|
|
2804
|
-
if (
|
|
2805
|
-
const childForms =
|
|
2806
|
-
|
|
3471
|
+
const containerConfig = viewConfig as PopsPanelContainerConfig;
|
|
3472
|
+
if (containerConfig.type === "container") {
|
|
3473
|
+
const childForms = viewConfig["views"];
|
|
3474
|
+
// 每一项<li>元素
|
|
2807
3475
|
const formContainerListElement = popsDOMUtils.createElement("li");
|
|
2808
|
-
|
|
3476
|
+
// 每一项<li>内的子<ul>元素
|
|
2809
3477
|
const formContainerULElement = popsDOMUtils.createElement("ul");
|
|
2810
3478
|
formContainerListElement.classList.add("pops-panel-forms-container-item");
|
|
2811
3479
|
formContainerULElement.classList.add("pops-panel-forms-container-item-formlist");
|
|
2812
|
-
|
|
3480
|
+
// 区域头部的文字
|
|
2813
3481
|
const formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
2814
3482
|
className: "pops-panel-forms-container-item-header-text",
|
|
2815
3483
|
});
|
|
2816
|
-
PopsSafeUtils.setSafeHTML(formHeaderDivElement,
|
|
2817
|
-
if (
|
|
2818
|
-
|
|
3484
|
+
PopsSafeUtils.setSafeHTML(formHeaderDivElement, containerConfig["text"]);
|
|
3485
|
+
if (containerConfig.isFold) {
|
|
3486
|
+
// 加进容器内
|
|
2819
3487
|
PopsSafeUtils.setSafeHTML(
|
|
2820
3488
|
formHeaderDivElement,
|
|
2821
3489
|
/*html*/ `
|
|
2822
|
-
<p>${
|
|
3490
|
+
<p>${containerConfig.text}</p>
|
|
2823
3491
|
<i class="pops-panel-forms-fold-container-icon">
|
|
2824
3492
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
2825
3493
|
<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 +3509,14 @@ export const PanelHandlerComponents = () => {
|
|
|
2841
3509
|
popsDOMUtils.addClassName(formContainerListElement, "pops-panel-forms-fold");
|
|
2842
3510
|
formContainerListElement.appendChild(formHeaderDivElement);
|
|
2843
3511
|
} else {
|
|
2844
|
-
|
|
3512
|
+
// 加进容器内
|
|
2845
3513
|
formContainerListElement.appendChild(formHeaderDivElement);
|
|
2846
3514
|
}
|
|
2847
|
-
that.setElementClassName(formContainerListElement,
|
|
2848
|
-
that.setElementAttributes(formContainerListElement,
|
|
2849
|
-
that.setElementProps(formContainerListElement,
|
|
2850
|
-
childForms.forEach((
|
|
2851
|
-
that.uListContainerAddItem(
|
|
3515
|
+
that.setElementClassName(formContainerListElement, viewConfig.className);
|
|
3516
|
+
that.setElementAttributes(formContainerListElement, viewConfig.attributes);
|
|
3517
|
+
that.setElementProps(formContainerListElement, viewConfig.props);
|
|
3518
|
+
childForms.forEach((childViewConfig) => {
|
|
3519
|
+
that.uListContainerAddItem(childViewConfig as PopsPanelViewConfig, {
|
|
2852
3520
|
ulElement: formContainerULElement,
|
|
2853
3521
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
2854
3522
|
formContainerListElement: formContainerListElement,
|
|
@@ -2858,8 +3526,8 @@ export const PanelHandlerComponents = () => {
|
|
|
2858
3526
|
formContainerListElement.appendChild(formContainerULElement);
|
|
2859
3527
|
that.sectionContainerULElement.appendChild(formContainerListElement);
|
|
2860
3528
|
|
|
2861
|
-
if (typeof
|
|
2862
|
-
|
|
3529
|
+
if (typeof containerConfig.afterAddToUListCallBack === "function") {
|
|
3530
|
+
containerConfig.afterAddToUListCallBack(containerConfig, {
|
|
2863
3531
|
target: formContainerListElement,
|
|
2864
3532
|
ulElement: formContainerULElement,
|
|
2865
3533
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
@@ -2868,26 +3536,27 @@ export const PanelHandlerComponents = () => {
|
|
|
2868
3536
|
});
|
|
2869
3537
|
}
|
|
2870
3538
|
} else {
|
|
2871
|
-
|
|
2872
|
-
that.uListContainerAddItem(
|
|
3539
|
+
// 如果成功创建,加入到中间容器中
|
|
3540
|
+
that.uListContainerAddItem(viewConfig as any as PopsPanelViewConfig, {
|
|
2873
3541
|
ulElement: that.sectionContainerULElement,
|
|
2874
3542
|
});
|
|
2875
3543
|
}
|
|
2876
3544
|
},
|
|
2877
3545
|
/**
|
|
2878
3546
|
* 主动触发触发渲染右侧容器的事件
|
|
3547
|
+
* @param $container 容器
|
|
2879
3548
|
*/
|
|
2880
3549
|
triggerRenderRightContainer($container: HTMLElement) {
|
|
2881
|
-
const
|
|
3550
|
+
const dataViewConfig: PopsPanelEventType["pops:renderRightContainer"]["viewConfig"] = Reflect.get(
|
|
2882
3551
|
$container,
|
|
2883
|
-
|
|
3552
|
+
this.$data.nodeStoreConfigKey
|
|
2884
3553
|
);
|
|
2885
3554
|
this.$el.$pops.dispatchEvent(
|
|
2886
3555
|
new CustomEvent<PopsPanelEventType["pops:renderRightContainer"]>(
|
|
2887
3556
|
<keyof PopsPanelEventType>"pops:renderRightContainer",
|
|
2888
3557
|
{
|
|
2889
3558
|
detail: {
|
|
2890
|
-
|
|
3559
|
+
viewConfig: dataViewConfig,
|
|
2891
3560
|
},
|
|
2892
3561
|
}
|
|
2893
3562
|
)
|
|
@@ -2895,21 +3564,21 @@ export const PanelHandlerComponents = () => {
|
|
|
2895
3564
|
},
|
|
2896
3565
|
/**
|
|
2897
3566
|
*
|
|
2898
|
-
* @param
|
|
3567
|
+
* @param viewConfig
|
|
2899
3568
|
* @param containerOptions
|
|
2900
3569
|
*/
|
|
2901
3570
|
uListContainerAddItem(
|
|
2902
|
-
|
|
2903
|
-
containerOptions: Omit<
|
|
3571
|
+
viewConfig: PopsPanelViewConfig,
|
|
3572
|
+
containerOptions: Omit<PopsPanelRightAsideContainerConfig, "target">
|
|
2904
3573
|
) {
|
|
2905
|
-
const
|
|
2906
|
-
if (
|
|
2907
|
-
containerOptions["ulElement"].appendChild(
|
|
3574
|
+
const itemInfo = this.createSectionContainerItem(viewConfig);
|
|
3575
|
+
if (itemInfo) {
|
|
3576
|
+
containerOptions["ulElement"].appendChild(itemInfo.$el);
|
|
2908
3577
|
}
|
|
2909
|
-
if (typeof
|
|
2910
|
-
|
|
3578
|
+
if (typeof viewConfig.afterAddToUListCallBack === "function") {
|
|
3579
|
+
viewConfig.afterAddToUListCallBack(viewConfig as any, {
|
|
2911
3580
|
...containerOptions,
|
|
2912
|
-
target:
|
|
3581
|
+
target: itemInfo?.$el,
|
|
2913
3582
|
});
|
|
2914
3583
|
}
|
|
2915
3584
|
},
|
|
@@ -2918,7 +3587,7 @@ export const PanelHandlerComponents = () => {
|
|
|
2918
3587
|
* @param $asideItem 左侧的容器<li>元素
|
|
2919
3588
|
* @param asideConfig 配置
|
|
2920
3589
|
*/
|
|
2921
|
-
|
|
3590
|
+
onAsideItemClick($asideItem: HTMLElement, asideConfig: PopsPanelContentConfig) {
|
|
2922
3591
|
popsDOMUtils.on<MouseEvent | PointerEvent>($asideItem, "click", async (event) => {
|
|
2923
3592
|
if (typeof asideConfig.clickFirstCallback === "function") {
|
|
2924
3593
|
const clickFirstCallbackResult = await asideConfig.clickFirstCallback(
|
|
@@ -2931,13 +3600,13 @@ export const PanelHandlerComponents = () => {
|
|
|
2931
3600
|
}
|
|
2932
3601
|
}
|
|
2933
3602
|
this.clearContainer();
|
|
2934
|
-
const
|
|
3603
|
+
const rightContainerViewConfig: PopsPanelContentConfig[] = Reflect.get($asideItem, "__forms__");
|
|
2935
3604
|
|
|
2936
|
-
Reflect.set(this.$el.$panelContentSectionContainer,
|
|
3605
|
+
Reflect.set(this.$el.$panelContentSectionContainer, this.$data.nodeStoreConfigKey, rightContainerViewConfig);
|
|
2937
3606
|
popsDOMUtils.cssShow(this.$el.$panelContentSectionContainer);
|
|
2938
3607
|
this.clearAsideItemIsVisited();
|
|
2939
3608
|
this.setAsideItemIsVisited($asideItem);
|
|
2940
|
-
|
|
3609
|
+
// 顶部标题栏,存在就设置
|
|
2941
3610
|
const title = typeof asideConfig.title === "function" ? asideConfig.title() : asideConfig.title;
|
|
2942
3611
|
let headerTitleText =
|
|
2943
3612
|
typeof asideConfig.headerTitle === "function" ? asideConfig.headerTitle() : asideConfig.headerTitle;
|
|
@@ -2950,12 +3619,12 @@ export const PanelHandlerComponents = () => {
|
|
|
2950
3619
|
this.sectionContainerHeaderULElement.appendChild($containerHeaderTitle);
|
|
2951
3620
|
}
|
|
2952
3621
|
|
|
2953
|
-
|
|
2954
|
-
this.createSectionContainerItem_forms(
|
|
3622
|
+
rightContainerViewConfig.forEach((viewConfig) => {
|
|
3623
|
+
this.createSectionContainerItem_forms(viewConfig);
|
|
2955
3624
|
});
|
|
2956
3625
|
|
|
2957
3626
|
if (typeof asideConfig.clickCallback === "function") {
|
|
2958
|
-
|
|
3627
|
+
// 执行回调
|
|
2959
3628
|
const asideClickCallbackResult = await asideConfig.clickCallback(
|
|
2960
3629
|
event,
|
|
2961
3630
|
this.sectionContainerHeaderULElement,
|