@whitesev/pops 1.5.6 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +216 -18
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +216 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +216 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +216 -18
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +216 -18
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +216 -18
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/components/folder/indexType.d.ts +5 -5
- package/dist/types/src/components/panel/indexType.d.ts +2 -1
- package/dist/types/src/components/panel/selectMultipleType.d.ts +89 -0
- package/dist/types/src/types/layer.d.ts +2 -0
- package/dist/types/src/types/main.d.ts +1 -1
- package/dist/types/src/types/mask.d.ts +1 -1
- package/package.json +1 -1
- package/src/Pops.ts +2 -1
- package/src/components/folder/index.ts +2 -1
- package/src/components/folder/indexType.ts +21 -10
- package/src/components/panel/index.css +6 -0
- package/src/components/panel/index.ts +205 -7
- package/src/components/panel/indexType.ts +2 -0
- package/src/components/panel/selectMultipleType.ts +95 -0
- package/src/components/rightClickMenu/index.ts +20 -4
- package/src/handler/PopsHandler.ts +5 -6
- package/src/types/layer.d.ts +2 -0
- package/src/types/main.d.ts +1 -1
- package/src/types/mask.d.ts +1 -1
- package/src/utils/PopsInstanceUtils.ts +15 -5
|
@@ -10,9 +10,9 @@ export interface PopsFolderDataConfig {
|
|
|
10
10
|
/**
|
|
11
11
|
* 文件大小,如果是文件夹的话,为0
|
|
12
12
|
*/
|
|
13
|
-
fileSize: number;
|
|
13
|
+
fileSize: number | string;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 文件类型,如果是文件夹,填入空字符串
|
|
16
16
|
*/
|
|
17
17
|
fileType: string;
|
|
18
18
|
/**
|
|
@@ -34,11 +34,11 @@ export interface PopsFolderDataConfig {
|
|
|
34
34
|
/**
|
|
35
35
|
* 点击事件
|
|
36
36
|
*/
|
|
37
|
-
clickEvent
|
|
37
|
+
clickEvent?: (event: MouseEvent | PointerEvent, config: PopsFolderDataConfig) => Promise<{
|
|
38
38
|
autoDownload: boolean;
|
|
39
39
|
url: string;
|
|
40
40
|
mode: "a" | "aBlank" | "iframe" | "open" | "openBlank";
|
|
41
|
-
}> | null;
|
|
41
|
+
} | null | undefined | void | PopsFolderDataConfig[]> | null | undefined | void | PopsFolderDataConfig[];
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* pops.folder
|
|
@@ -59,7 +59,7 @@ export interface PopsFolderDetails extends PopsTitleConfig, PopsDragConfig, Pops
|
|
|
59
59
|
/**
|
|
60
60
|
* 触发排序的回调,如果返回true,则中止内部的排序
|
|
61
61
|
*/
|
|
62
|
-
callback
|
|
62
|
+
callback?: (targert: HTMLElement, event: PointerEvent | MouseEvent, sortName: "fileName" | "fileSize" | "latestTime", sortDesc: boolean) => boolean | undefined | void;
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
65
65
|
* 文件夹信息
|
|
@@ -9,8 +9,9 @@ import type { PopsPanelButtonDetails } from "./buttonType";
|
|
|
9
9
|
import type { PopsPanelDeepMenuDetails } from "./deepMenuType";
|
|
10
10
|
import type { PopsPanelOwnDetails } from "./ownType";
|
|
11
11
|
import type { PopsHeaderCloseButtonDetails } from "../../types/button";
|
|
12
|
+
import { PopsPanelSelectMultipleDetails } from "./selectMultipleType";
|
|
12
13
|
/** panel的各种类型的配置项 */
|
|
13
|
-
export type PopsPanelFormsTotalDetails = PopsPanelSwitchDetails | PopsPanelSliderDetails | PopsPanelInputDetails | PopsPanelTextAreaDetails | PopsPanelSelectDetails<any> | PopsPanelButtonDetails | PopsPanelDeepMenuDetails | PopsPanelOwnDetails;
|
|
14
|
+
export type PopsPanelFormsTotalDetails = PopsPanelSwitchDetails | PopsPanelSliderDetails | PopsPanelInputDetails | PopsPanelTextAreaDetails | PopsPanelSelectDetails<any> | PopsPanelSelectMultipleDetails<any> | PopsPanelButtonDetails | PopsPanelDeepMenuDetails | PopsPanelOwnDetails;
|
|
14
15
|
/**
|
|
15
16
|
* pops.panel的content配置信息
|
|
16
17
|
*/
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { PopsPanelCommonDetails } from "./commonType";
|
|
2
|
+
/**
|
|
3
|
+
* pops.panel的 select
|
|
4
|
+
*/
|
|
5
|
+
export interface PopsPanelSelectMultipleDetails<T = any> extends PopsPanelCommonDetails {
|
|
6
|
+
/**
|
|
7
|
+
* (可选)className属性
|
|
8
|
+
*/
|
|
9
|
+
className?: string;
|
|
10
|
+
/**
|
|
11
|
+
* (可选)自定义元素属性
|
|
12
|
+
*/
|
|
13
|
+
attributes?: any;
|
|
14
|
+
/**
|
|
15
|
+
* (可选)自定义属性
|
|
16
|
+
*/
|
|
17
|
+
props?: HTMLElement;
|
|
18
|
+
/**
|
|
19
|
+
* 显示在左边的文字
|
|
20
|
+
*/
|
|
21
|
+
text: string;
|
|
22
|
+
/**
|
|
23
|
+
* (可选)左边的文字下面的描述
|
|
24
|
+
*/
|
|
25
|
+
description?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 类型
|
|
28
|
+
*/
|
|
29
|
+
type: "select-multiple";
|
|
30
|
+
/**
|
|
31
|
+
* (可选)是否禁用
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean | ((value: T) => boolean);
|
|
34
|
+
/**
|
|
35
|
+
* 获取该项的值的回调函数
|
|
36
|
+
*/
|
|
37
|
+
getValue(): T[];
|
|
38
|
+
/**
|
|
39
|
+
* 选择器的值改变触发的回调函数
|
|
40
|
+
* @param event 事件
|
|
41
|
+
* @param isSelectedValue 当前选中的值,也就是元素属性上的__value__
|
|
42
|
+
* @param isSelectedText 当前选中的文本
|
|
43
|
+
*/
|
|
44
|
+
callback?(event: PointerEvent | TouchEvent,
|
|
45
|
+
/** 当前已选中的信息 */
|
|
46
|
+
isSelectedInfo: {
|
|
47
|
+
/** 值 */
|
|
48
|
+
value: T;
|
|
49
|
+
/** 显示的文字 */
|
|
50
|
+
text: string;
|
|
51
|
+
/** 选中的元素 */
|
|
52
|
+
$option: HTMLOptionElement;
|
|
53
|
+
}[]): void;
|
|
54
|
+
/**
|
|
55
|
+
* 点击select元素触发该回调
|
|
56
|
+
* @param event 点击事件
|
|
57
|
+
* @param selectElement 当前的select元素
|
|
58
|
+
*/
|
|
59
|
+
clickCallBack?(event: PointerEvent | MouseEvent,
|
|
60
|
+
/** 当前已选中的信息 */
|
|
61
|
+
isSelectedInfo: {
|
|
62
|
+
/** 值 */
|
|
63
|
+
value: T;
|
|
64
|
+
/** 显示的文字 */
|
|
65
|
+
text: string;
|
|
66
|
+
/** 选中的元素 */
|
|
67
|
+
$option: HTMLOptionElement;
|
|
68
|
+
}[]): void;
|
|
69
|
+
/**
|
|
70
|
+
* 选择器内的数据组
|
|
71
|
+
*/
|
|
72
|
+
data: {
|
|
73
|
+
/**
|
|
74
|
+
* 真正的值
|
|
75
|
+
*/
|
|
76
|
+
value: T;
|
|
77
|
+
/**
|
|
78
|
+
* 显示的文字
|
|
79
|
+
*/
|
|
80
|
+
text: string;
|
|
81
|
+
/**
|
|
82
|
+
* (可选)是否禁用项
|
|
83
|
+
* 触发条件:
|
|
84
|
+
* + 点击select元素
|
|
85
|
+
* + select元素触发change事件
|
|
86
|
+
*/
|
|
87
|
+
disable?(value: T): boolean;
|
|
88
|
+
}[];
|
|
89
|
+
}
|
|
@@ -48,7 +48,7 @@ export type PopsType = keyof PopsTypeDetails;
|
|
|
48
48
|
export type PopsMode = PopsType | "tooltip" | "rightClickMenu";
|
|
49
49
|
|
|
50
50
|
/** 存储实例的类型 9个 */
|
|
51
|
-
export type PopsLayerMode = PopsType | "tooltip";
|
|
51
|
+
export type PopsLayerMode = PopsType | "tooltip" | "rightClickMenu";
|
|
52
52
|
|
|
53
53
|
/** pops弹窗支持动画元素的配置 */
|
|
54
54
|
export interface PopsSupportAnim {
|
package/package.json
CHANGED
package/src/Pops.ts
CHANGED
|
@@ -80,7 +80,7 @@ class Pops {
|
|
|
80
80
|
/** 配置 */
|
|
81
81
|
config = {
|
|
82
82
|
/** 版本号 */
|
|
83
|
-
version: "2024.9.
|
|
83
|
+
version: "2024.9.16",
|
|
84
84
|
cssText: {
|
|
85
85
|
/** 主CSS */
|
|
86
86
|
index: indexCSS,
|
|
@@ -163,6 +163,7 @@ class Pops {
|
|
|
163
163
|
drawer: [],
|
|
164
164
|
folder: [],
|
|
165
165
|
panel: [],
|
|
166
|
+
rightClickMenu: [],
|
|
166
167
|
} as any as {
|
|
167
168
|
[key in PopsLayerMode]: PopsLayerCommonConfig[];
|
|
168
169
|
},
|
|
@@ -778,7 +778,9 @@ export class PopsFolder {
|
|
|
778
778
|
if (typeof _config_.clickEvent === "function") {
|
|
779
779
|
let downloadInfo = await _config_.clickEvent(event, _config_)!;
|
|
780
780
|
if (
|
|
781
|
+
downloadInfo != null &&
|
|
781
782
|
typeof downloadInfo === "object" &&
|
|
783
|
+
!Array.isArray(downloadInfo) &&
|
|
782
784
|
typeof downloadInfo.url === "string" &&
|
|
783
785
|
downloadInfo.url.trim() !== ""
|
|
784
786
|
) {
|
|
@@ -851,7 +853,6 @@ export class PopsFolder {
|
|
|
851
853
|
sortName: "fileName" | "fileSize" | "latestTime" = "fileName",
|
|
852
854
|
isDesc = false
|
|
853
855
|
) {
|
|
854
|
-
console.log(folderDataConfigList, sortName, isDesc);
|
|
855
856
|
if (sortName === "fileName") {
|
|
856
857
|
// 如果是以文件名排序,文件夹优先放前面
|
|
857
858
|
let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
|
|
@@ -16,9 +16,9 @@ export interface PopsFolderDataConfig {
|
|
|
16
16
|
/**
|
|
17
17
|
* 文件大小,如果是文件夹的话,为0
|
|
18
18
|
*/
|
|
19
|
-
fileSize: number;
|
|
19
|
+
fileSize: number | string;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* 文件类型,如果是文件夹,填入空字符串
|
|
22
22
|
*/
|
|
23
23
|
fileType: string;
|
|
24
24
|
/**
|
|
@@ -40,14 +40,25 @@ export interface PopsFolderDataConfig {
|
|
|
40
40
|
/**
|
|
41
41
|
* 点击事件
|
|
42
42
|
*/
|
|
43
|
-
clickEvent
|
|
43
|
+
clickEvent?: (
|
|
44
44
|
event: MouseEvent | PointerEvent,
|
|
45
45
|
config: PopsFolderDataConfig
|
|
46
|
-
) =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
) =>
|
|
47
|
+
| Promise<
|
|
48
|
+
| {
|
|
49
|
+
autoDownload: boolean;
|
|
50
|
+
url: string;
|
|
51
|
+
mode: "a" | "aBlank" | "iframe" | "open" | "openBlank";
|
|
52
|
+
}
|
|
53
|
+
| null
|
|
54
|
+
| undefined
|
|
55
|
+
| void
|
|
56
|
+
| PopsFolderDataConfig[]
|
|
57
|
+
>
|
|
58
|
+
| null
|
|
59
|
+
| undefined
|
|
60
|
+
| void
|
|
61
|
+
| PopsFolderDataConfig[];
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
/**
|
|
@@ -73,12 +84,12 @@ export interface PopsFolderDetails
|
|
|
73
84
|
/**
|
|
74
85
|
* 触发排序的回调,如果返回true,则中止内部的排序
|
|
75
86
|
*/
|
|
76
|
-
callback
|
|
87
|
+
callback?: (
|
|
77
88
|
targert: HTMLElement,
|
|
78
89
|
event: PointerEvent | MouseEvent,
|
|
79
90
|
sortName: "fileName" | "fileSize" | "latestTime",
|
|
80
91
|
sortDesc: boolean
|
|
81
|
-
) => boolean;
|
|
92
|
+
) => boolean | undefined | void;
|
|
82
93
|
};
|
|
83
94
|
/**
|
|
84
95
|
* 文件夹信息
|
|
@@ -715,6 +715,12 @@ section.pops-panel-container
|
|
|
715
715
|
}
|
|
716
716
|
/* select的CSS */
|
|
717
717
|
|
|
718
|
+
/* select-multiple的CSS */
|
|
719
|
+
.pops-panel-select-multiple select {
|
|
720
|
+
height: auto;
|
|
721
|
+
}
|
|
722
|
+
/* select-multiple的CSS */
|
|
723
|
+
|
|
718
724
|
/* deepMenu的css */
|
|
719
725
|
.pops-panel-deepMenu-nav-item {
|
|
720
726
|
cursor: pointer;
|
|
@@ -21,6 +21,7 @@ import type { PopsPanelSelectDetails } from "./selectType";
|
|
|
21
21
|
import type { PopsPanelSliderDetails } from "./sliderType";
|
|
22
22
|
import type { PopsPanelSwitchDetails } from "./switchType";
|
|
23
23
|
import type { PopsPanelTextAreaDetails } from "./textareaType";
|
|
24
|
+
import { PopsPanelSelectMultipleDetails } from "./selectMultipleType";
|
|
24
25
|
|
|
25
26
|
export class PopsPanel {
|
|
26
27
|
constructor(details: PopsPanelDetails) {
|
|
@@ -608,9 +609,9 @@ export class PopsPanel {
|
|
|
608
609
|
/* 左边底部的描述的文字 */
|
|
609
610
|
let leftDescriptionText = "";
|
|
610
611
|
if (Boolean(formConfig.description)) {
|
|
611
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
612
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
612
613
|
}
|
|
613
|
-
liElement.innerHTML = `
|
|
614
|
+
liElement.innerHTML = /*html*/ `
|
|
614
615
|
<div class="pops-panel-item-left-text">
|
|
615
616
|
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
616
617
|
${leftDescriptionText}
|
|
@@ -1714,7 +1715,6 @@ export class PopsPanel {
|
|
|
1714
1715
|
* 获取中间容器的元素<li>
|
|
1715
1716
|
* type ==> select
|
|
1716
1717
|
* @param formConfig
|
|
1717
|
-
* @returns
|
|
1718
1718
|
*/
|
|
1719
1719
|
getSectionContainerItem_select(formConfig: PopsPanelSelectDetails<any>) {
|
|
1720
1720
|
let liElement = document.createElement("li");
|
|
@@ -1727,9 +1727,9 @@ export class PopsPanel {
|
|
|
1727
1727
|
/* 左边底部的描述的文字 */
|
|
1728
1728
|
let leftDescriptionText = "";
|
|
1729
1729
|
if (Boolean(formConfig.description)) {
|
|
1730
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
1730
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
1731
1731
|
}
|
|
1732
|
-
liElement.innerHTML = `
|
|
1732
|
+
liElement.innerHTML = /*html*/ `
|
|
1733
1733
|
<div class="pops-panel-item-left-text">
|
|
1734
1734
|
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
1735
1735
|
${leftDescriptionText}
|
|
@@ -1841,14 +1841,208 @@ export class PopsPanel {
|
|
|
1841
1841
|
};
|
|
1842
1842
|
|
|
1843
1843
|
PopsPanelSelect.init();
|
|
1844
|
-
(liElement
|
|
1844
|
+
Reflect.set(liElement, "data-select", PopsPanelSelect);
|
|
1845
|
+
return liElement;
|
|
1846
|
+
},
|
|
1847
|
+
/**
|
|
1848
|
+
* 获取中间容器的元素<li>
|
|
1849
|
+
* type ==> select-multiple
|
|
1850
|
+
* @param formConfig
|
|
1851
|
+
*/
|
|
1852
|
+
getSectionContainerItem_select_multiple(
|
|
1853
|
+
formConfig: PopsPanelSelectMultipleDetails<any>
|
|
1854
|
+
) {
|
|
1855
|
+
let liElement = document.createElement("li");
|
|
1856
|
+
Reflect.set(liElement, "__formConfig__", formConfig);
|
|
1857
|
+
if (formConfig.className) {
|
|
1858
|
+
liElement.className = formConfig.className;
|
|
1859
|
+
}
|
|
1860
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
1861
|
+
this.setElementProps(liElement, formConfig.props);
|
|
1862
|
+
/* 左边底部的描述的文字 */
|
|
1863
|
+
let leftDescriptionText = "";
|
|
1864
|
+
if (Boolean(formConfig.description)) {
|
|
1865
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
1866
|
+
}
|
|
1867
|
+
liElement.innerHTML = /*html*/ `
|
|
1868
|
+
<div class="pops-panel-item-left-text">
|
|
1869
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
1870
|
+
${leftDescriptionText}
|
|
1871
|
+
</div>
|
|
1872
|
+
<div class="pops-panel-select-multiple pops-panel-select">
|
|
1873
|
+
<select multiple="true"></select>
|
|
1874
|
+
</div>
|
|
1875
|
+
`;
|
|
1876
|
+
|
|
1877
|
+
const PopsPanelSelectMultiple = {
|
|
1878
|
+
[Symbol.toStringTag]: "PopsPanelSelectMultiple",
|
|
1879
|
+
$ele: {
|
|
1880
|
+
panelSelect: liElement.querySelector<HTMLDivElement>(
|
|
1881
|
+
".pops-panel-select-multiple"
|
|
1882
|
+
)!,
|
|
1883
|
+
select: liElement.querySelector<HTMLSelectElement>(
|
|
1884
|
+
".pops-panel-select-multiple select"
|
|
1885
|
+
)!,
|
|
1886
|
+
},
|
|
1887
|
+
$eleKey: {
|
|
1888
|
+
disable: "__disable__",
|
|
1889
|
+
value: "__value__",
|
|
1890
|
+
},
|
|
1891
|
+
$data: {
|
|
1892
|
+
defaultValue: formConfig.getValue(),
|
|
1893
|
+
},
|
|
1894
|
+
init() {
|
|
1895
|
+
this.initOption();
|
|
1896
|
+
this.setChangeEvent();
|
|
1897
|
+
this.setClickEvent();
|
|
1898
|
+
if (formConfig.disabled) {
|
|
1899
|
+
this.disable();
|
|
1900
|
+
}
|
|
1901
|
+
},
|
|
1902
|
+
/** 禁用 */
|
|
1903
|
+
disable() {
|
|
1904
|
+
this.$ele.select.setAttribute("disabled", "true");
|
|
1905
|
+
this.$ele.panelSelect.classList.add("pops-panel-select-disable");
|
|
1906
|
+
},
|
|
1907
|
+
/** 取消禁用 */
|
|
1908
|
+
notDisable() {
|
|
1909
|
+
this.$ele.select.removeAttribute("disabled");
|
|
1910
|
+
this.$ele.panelSelect.classList.remove("pops-panel-select-disable");
|
|
1911
|
+
},
|
|
1912
|
+
/** 判断是否禁用 */
|
|
1913
|
+
isDisabled() {
|
|
1914
|
+
return (
|
|
1915
|
+
this.$ele.select.hasAttribute("disabled") ||
|
|
1916
|
+
this.$ele.panelSelect.classList.contains(
|
|
1917
|
+
"pops-panel-select-disable"
|
|
1918
|
+
)
|
|
1919
|
+
);
|
|
1920
|
+
},
|
|
1921
|
+
/** 初始化配置 */
|
|
1922
|
+
initOption() {
|
|
1923
|
+
formConfig.data.forEach((dataItem) => {
|
|
1924
|
+
// 初始化默认选中
|
|
1925
|
+
let optionElement = document.createElement("option");
|
|
1926
|
+
this.setNodeValue(
|
|
1927
|
+
optionElement,
|
|
1928
|
+
this.$eleKey.value,
|
|
1929
|
+
dataItem.value
|
|
1930
|
+
);
|
|
1931
|
+
this.setNodeValue(
|
|
1932
|
+
optionElement,
|
|
1933
|
+
this.$eleKey.disable,
|
|
1934
|
+
dataItem.disable
|
|
1935
|
+
);
|
|
1936
|
+
if (dataItem.value === this.$data.defaultValue) {
|
|
1937
|
+
optionElement.setAttribute("selected", "true");
|
|
1938
|
+
}
|
|
1939
|
+
optionElement.innerText = dataItem.text;
|
|
1940
|
+
this.$ele.select.appendChild(optionElement);
|
|
1941
|
+
});
|
|
1942
|
+
},
|
|
1943
|
+
/**
|
|
1944
|
+
* 给option元素设置属性
|
|
1945
|
+
* @param $ele
|
|
1946
|
+
* @param key
|
|
1947
|
+
* @param value
|
|
1948
|
+
*/
|
|
1949
|
+
setNodeValue($ele: HTMLElement, key: string, value: any) {
|
|
1950
|
+
Reflect.set($ele, key, value);
|
|
1951
|
+
},
|
|
1952
|
+
/**
|
|
1953
|
+
* 获取option元素上设置的属性
|
|
1954
|
+
* @param $ele
|
|
1955
|
+
* @param value
|
|
1956
|
+
* @param key
|
|
1957
|
+
*/
|
|
1958
|
+
getNodeValue($ele: HTMLElement, key: string) {
|
|
1959
|
+
return Reflect.get($ele, key);
|
|
1960
|
+
},
|
|
1961
|
+
/** 检测所有option并设置禁用状态 */
|
|
1962
|
+
setSelectOptionsDisableStatus() {
|
|
1963
|
+
if (this.$ele.select.options && this.$ele.select.options.length) {
|
|
1964
|
+
Array.from(this.$ele.select.options).forEach((optionItem) => {
|
|
1965
|
+
this.setOptionDisableStatus(optionItem);
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
},
|
|
1969
|
+
/** 设置禁用状态 */
|
|
1970
|
+
setOptionDisableStatus(optionElement: HTMLOptionElement) {
|
|
1971
|
+
let disable = false;
|
|
1972
|
+
let optionDisableAttr = this.getNodeValue(
|
|
1973
|
+
optionElement,
|
|
1974
|
+
this.$eleKey.disable
|
|
1975
|
+
);
|
|
1976
|
+
if (optionDisableAttr === "function") {
|
|
1977
|
+
let value = this.getNodeValue(optionElement, this.$eleKey.value);
|
|
1978
|
+
disable = Boolean(optionDisableAttr(value));
|
|
1979
|
+
}
|
|
1980
|
+
if (disable) {
|
|
1981
|
+
optionElement.setAttribute("disabled", "true");
|
|
1982
|
+
} else {
|
|
1983
|
+
optionElement.removeAttribute("disabled");
|
|
1984
|
+
}
|
|
1985
|
+
},
|
|
1986
|
+
/** 获取option上的信息 */
|
|
1987
|
+
getSelectOptionInfo($option: HTMLOptionElement) {
|
|
1988
|
+
let optionValue = this.getNodeValue($option, this.$eleKey.value);
|
|
1989
|
+
let optionText = $option.innerText || $option.textContent!;
|
|
1990
|
+
return {
|
|
1991
|
+
value: optionValue,
|
|
1992
|
+
text: optionText,
|
|
1993
|
+
$option: $option,
|
|
1994
|
+
};
|
|
1995
|
+
},
|
|
1996
|
+
/** 获取选中信息 */
|
|
1997
|
+
getSelectInfoList($select: HTMLSelectElement) {
|
|
1998
|
+
let selectedInfo: {
|
|
1999
|
+
value: any;
|
|
2000
|
+
text: string;
|
|
2001
|
+
$option: HTMLOptionElement;
|
|
2002
|
+
}[] = [];
|
|
2003
|
+
Array.from($select.selectedOptions).forEach(($selectedOption) => {
|
|
2004
|
+
selectedInfo.push(this.getSelectOptionInfo($selectedOption));
|
|
2005
|
+
});
|
|
2006
|
+
return selectedInfo;
|
|
2007
|
+
},
|
|
2008
|
+
/**
|
|
2009
|
+
* 监听选择内容改变
|
|
2010
|
+
*/
|
|
2011
|
+
setChangeEvent() {
|
|
2012
|
+
popsDOMUtils.on(this.$ele.select, "change", void 0, (event) => {
|
|
2013
|
+
this.setSelectOptionsDisableStatus();
|
|
2014
|
+
if (typeof formConfig.callback === "function") {
|
|
2015
|
+
formConfig.callback(
|
|
2016
|
+
event as any,
|
|
2017
|
+
this.getSelectInfoList(this.$ele.select)
|
|
2018
|
+
);
|
|
2019
|
+
}
|
|
2020
|
+
});
|
|
2021
|
+
},
|
|
2022
|
+
/**
|
|
2023
|
+
* 监听点击事件
|
|
2024
|
+
*/
|
|
2025
|
+
setClickEvent() {
|
|
2026
|
+
popsDOMUtils.on(this.$ele.select, "click", void 0, (event) => {
|
|
2027
|
+
this.setSelectOptionsDisableStatus();
|
|
2028
|
+
if (typeof formConfig.clickCallBack === "function") {
|
|
2029
|
+
formConfig.clickCallBack(
|
|
2030
|
+
event,
|
|
2031
|
+
this.getSelectInfoList(this.$ele.select)
|
|
2032
|
+
);
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2035
|
+
},
|
|
2036
|
+
};
|
|
2037
|
+
|
|
2038
|
+
PopsPanelSelectMultiple.init();
|
|
2039
|
+
Reflect.set(liElement, "data-select", PopsPanelSelectMultiple);
|
|
1845
2040
|
return liElement;
|
|
1846
2041
|
},
|
|
1847
2042
|
/**
|
|
1848
2043
|
* 获取中间容器的元素<li>
|
|
1849
2044
|
* type ==> button
|
|
1850
2045
|
* @param formConfig
|
|
1851
|
-
* @returns
|
|
1852
2046
|
*/
|
|
1853
2047
|
getSectionContainerItem_button(formConfig: PopsPanelButtonDetails) {
|
|
1854
2048
|
let liElement = document.createElement("li");
|
|
@@ -2259,6 +2453,10 @@ export class PopsPanel {
|
|
|
2259
2453
|
return this.getSectionContainerItem_select(
|
|
2260
2454
|
formConfig as PopsPanelSelectDetails
|
|
2261
2455
|
);
|
|
2456
|
+
} else if (formType === "select-multiple") {
|
|
2457
|
+
return this.getSectionContainerItem_select_multiple(
|
|
2458
|
+
formConfig as PopsPanelSelectMultipleDetails
|
|
2459
|
+
);
|
|
2262
2460
|
} else if (formType === "button") {
|
|
2263
2461
|
return this.getSectionContainerItem_button(
|
|
2264
2462
|
formConfig as PopsPanelButtonDetails
|
|
@@ -13,6 +13,7 @@ import type { PopsPanelButtonDetails } from "./buttonType";
|
|
|
13
13
|
import type { PopsPanelDeepMenuDetails } from "./deepMenuType";
|
|
14
14
|
import type { PopsPanelOwnDetails } from "./ownType";
|
|
15
15
|
import type { PopsHeaderCloseButtonDetails } from "../../types/button";
|
|
16
|
+
import { PopsPanelSelectMultipleDetails } from "./selectMultipleType";
|
|
16
17
|
|
|
17
18
|
/** panel的各种类型的配置项 */
|
|
18
19
|
export type PopsPanelFormsTotalDetails =
|
|
@@ -21,6 +22,7 @@ export type PopsPanelFormsTotalDetails =
|
|
|
21
22
|
| PopsPanelInputDetails
|
|
22
23
|
| PopsPanelTextAreaDetails
|
|
23
24
|
| PopsPanelSelectDetails<any>
|
|
25
|
+
| PopsPanelSelectMultipleDetails<any>
|
|
24
26
|
| PopsPanelButtonDetails
|
|
25
27
|
| PopsPanelDeepMenuDetails
|
|
26
28
|
| PopsPanelOwnDetails;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { PopsPanelCommonDetails } from "./commonType";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* pops.panel的 select
|
|
5
|
+
*/
|
|
6
|
+
export interface PopsPanelSelectMultipleDetails<T = any>
|
|
7
|
+
extends PopsPanelCommonDetails {
|
|
8
|
+
/**
|
|
9
|
+
* (可选)className属性
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* (可选)自定义元素属性
|
|
14
|
+
*/
|
|
15
|
+
attributes?: any;
|
|
16
|
+
/**
|
|
17
|
+
* (可选)自定义属性
|
|
18
|
+
*/
|
|
19
|
+
props?: HTMLElement;
|
|
20
|
+
/**
|
|
21
|
+
* 显示在左边的文字
|
|
22
|
+
*/
|
|
23
|
+
text: string;
|
|
24
|
+
/**
|
|
25
|
+
* (可选)左边的文字下面的描述
|
|
26
|
+
*/
|
|
27
|
+
description?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 类型
|
|
30
|
+
*/
|
|
31
|
+
type: "select-multiple";
|
|
32
|
+
/**
|
|
33
|
+
* (可选)是否禁用
|
|
34
|
+
*/
|
|
35
|
+
disabled?: boolean | ((value: T) => boolean);
|
|
36
|
+
/**
|
|
37
|
+
* 获取该项的值的回调函数
|
|
38
|
+
*/
|
|
39
|
+
getValue(): T[];
|
|
40
|
+
/**
|
|
41
|
+
* 选择器的值改变触发的回调函数
|
|
42
|
+
* @param event 事件
|
|
43
|
+
* @param isSelectedValue 当前选中的值,也就是元素属性上的__value__
|
|
44
|
+
* @param isSelectedText 当前选中的文本
|
|
45
|
+
*/
|
|
46
|
+
callback?(
|
|
47
|
+
event: PointerEvent | TouchEvent,
|
|
48
|
+
/** 当前已选中的信息 */
|
|
49
|
+
isSelectedInfo: {
|
|
50
|
+
/** 值 */
|
|
51
|
+
value: T;
|
|
52
|
+
/** 显示的文字 */
|
|
53
|
+
text: string;
|
|
54
|
+
/** 选中的元素 */
|
|
55
|
+
$option: HTMLOptionElement;
|
|
56
|
+
}[]
|
|
57
|
+
): void;
|
|
58
|
+
/**
|
|
59
|
+
* 点击select元素触发该回调
|
|
60
|
+
* @param event 点击事件
|
|
61
|
+
* @param selectElement 当前的select元素
|
|
62
|
+
*/
|
|
63
|
+
clickCallBack?(
|
|
64
|
+
event: PointerEvent | MouseEvent,
|
|
65
|
+
/** 当前已选中的信息 */
|
|
66
|
+
isSelectedInfo: {
|
|
67
|
+
/** 值 */
|
|
68
|
+
value: T;
|
|
69
|
+
/** 显示的文字 */
|
|
70
|
+
text: string;
|
|
71
|
+
/** 选中的元素 */
|
|
72
|
+
$option: HTMLOptionElement;
|
|
73
|
+
}[]
|
|
74
|
+
): void;
|
|
75
|
+
/**
|
|
76
|
+
* 选择器内的数据组
|
|
77
|
+
*/
|
|
78
|
+
data: {
|
|
79
|
+
/**
|
|
80
|
+
* 真正的值
|
|
81
|
+
*/
|
|
82
|
+
value: T;
|
|
83
|
+
/**
|
|
84
|
+
* 显示的文字
|
|
85
|
+
*/
|
|
86
|
+
text: string;
|
|
87
|
+
/**
|
|
88
|
+
* (可选)是否禁用项
|
|
89
|
+
* 触发条件:
|
|
90
|
+
* + 点击select元素
|
|
91
|
+
* + select元素触发change事件
|
|
92
|
+
*/
|
|
93
|
+
disable?(value: T): boolean;
|
|
94
|
+
}[];
|
|
95
|
+
}
|