@whitesev/pops 2.0.8 → 2.0.10
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 +297 -174
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +297 -174
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +297 -174
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +297 -174
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +297 -174
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +297 -174
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +1 -0
- package/dist/types/src/components/panel/selectMultipleType.d.ts +12 -15
- package/dist/types/src/components/tooltip/index.d.ts +1 -0
- package/dist/types/src/components/tooltip/indexType.d.ts +7 -0
- package/package.json +3 -2
- package/src/components/panel/PanelHandleContentDetails.ts +310 -195
- package/src/components/panel/config.ts +37 -11
- package/src/components/panel/selectMultipleType.ts +18 -15
- package/src/components/tooltip/config.ts +1 -0
- package/src/components/tooltip/index.ts +13 -0
- package/src/components/tooltip/indexType.ts +7 -0
|
@@ -1664,6 +1664,8 @@ export const PanelHandleContentDetails = () => {
|
|
|
1664
1664
|
$suffix: void 0 as any as HTMLElement,
|
|
1665
1665
|
/** 下拉箭头图标 */
|
|
1666
1666
|
$suffixIcon: void 0 as any as HTMLElement,
|
|
1667
|
+
/** 下拉列表弹窗的下拉列表容器 */
|
|
1668
|
+
$selectContainer: void 0 as any as HTMLElement | null,
|
|
1667
1669
|
},
|
|
1668
1670
|
$data: {
|
|
1669
1671
|
/** 默认值 */
|
|
@@ -1675,7 +1677,7 @@ export const PanelHandleContentDetails = () => {
|
|
|
1675
1677
|
this.initDefault();
|
|
1676
1678
|
this.inintEl();
|
|
1677
1679
|
this.initPlaceHolder();
|
|
1678
|
-
this.
|
|
1680
|
+
this.initTagElement();
|
|
1679
1681
|
this.setSelectContainerClickEvent();
|
|
1680
1682
|
},
|
|
1681
1683
|
/** 初始化默认值 */
|
|
@@ -1687,7 +1689,7 @@ export const PanelHandleContentDetails = () => {
|
|
|
1687
1689
|
text: dataItem.text,
|
|
1688
1690
|
value: dataItem.value,
|
|
1689
1691
|
isHTML: Boolean(dataItem.isHTML),
|
|
1690
|
-
disable: dataItem.disable,
|
|
1692
|
+
disable: dataItem.disable?.bind(dataItem),
|
|
1691
1693
|
});
|
|
1692
1694
|
}
|
|
1693
1695
|
});
|
|
@@ -1735,20 +1737,17 @@ export const PanelHandleContentDetails = () => {
|
|
|
1735
1737
|
});
|
|
1736
1738
|
this.$el.$selectedPlaceHolderWrapper.appendChild($placeholder);
|
|
1737
1739
|
},
|
|
1738
|
-
/** 初始化tag */
|
|
1739
|
-
|
|
1740
|
+
/** 初始化tag元素 */
|
|
1741
|
+
initTagElement() {
|
|
1740
1742
|
// 遍历数据,寻找对应的值
|
|
1741
1743
|
formConfig.data.forEach((dataItem) => {
|
|
1742
1744
|
let findValue = this.$data.selectInfo.find(
|
|
1743
1745
|
(item) => item.value === dataItem.value
|
|
1744
1746
|
);
|
|
1745
1747
|
if (findValue) {
|
|
1746
|
-
//
|
|
1747
|
-
let selectedInfo = this.
|
|
1748
|
-
|
|
1749
|
-
isHTML: dataItem.isHTML,
|
|
1750
|
-
});
|
|
1751
|
-
this.addSelectedItem(selectedInfo.$tag);
|
|
1748
|
+
// 存在对应的值
|
|
1749
|
+
let selectedInfo = this.createSelectedTagItem(dataItem);
|
|
1750
|
+
this.addSelectedTagItem(selectedInfo.$tag);
|
|
1752
1751
|
this.setSelectedItemCloseIconClickEvent({
|
|
1753
1752
|
$tag: selectedInfo.$tag,
|
|
1754
1753
|
$closeIcon: selectedInfo.$closeIcon,
|
|
@@ -1763,11 +1762,7 @@ export const PanelHandleContentDetails = () => {
|
|
|
1763
1762
|
* 生成一个tag项
|
|
1764
1763
|
* @param data 配置
|
|
1765
1764
|
*/
|
|
1766
|
-
|
|
1767
|
-
/** tag的文本 */
|
|
1768
|
-
text: string;
|
|
1769
|
-
isHTML?: boolean;
|
|
1770
|
-
}) {
|
|
1765
|
+
createSelectedTagItem(data: PopsPanelSelectMultipleDataOption<any>) {
|
|
1771
1766
|
const $selectedItem = popsDOMUtils.createElement("div", {
|
|
1772
1767
|
className: "el-select__selected-item el-select__choose_tag",
|
|
1773
1768
|
innerHTML: /*html*/ `
|
|
@@ -1792,10 +1787,14 @@ export const PanelHandleContentDetails = () => {
|
|
|
1792
1787
|
const $closeIcon = $selectedItem.querySelector<HTMLElement>(
|
|
1793
1788
|
".el-icon.el-tag__close"
|
|
1794
1789
|
)!;
|
|
1790
|
+
let text =
|
|
1791
|
+
typeof data.text === "function"
|
|
1792
|
+
? data.text(data, this.$data.selectInfo)
|
|
1793
|
+
: data.text;
|
|
1795
1794
|
if (data.isHTML) {
|
|
1796
|
-
PopsSafeUtils.setSafeHTML($tagText,
|
|
1795
|
+
PopsSafeUtils.setSafeHTML($tagText, text);
|
|
1797
1796
|
} else {
|
|
1798
|
-
$tagText.innerText =
|
|
1797
|
+
$tagText.innerText = text;
|
|
1799
1798
|
}
|
|
1800
1799
|
|
|
1801
1800
|
return {
|
|
@@ -1805,9 +1804,10 @@ export const PanelHandleContentDetails = () => {
|
|
|
1805
1804
|
};
|
|
1806
1805
|
},
|
|
1807
1806
|
/**
|
|
1808
|
-
*
|
|
1807
|
+
* 添加选中项的tag元素
|
|
1808
|
+
* @param $tag 添加的元素
|
|
1809
1809
|
*/
|
|
1810
|
-
|
|
1810
|
+
addSelectedTagItem($tag: HTMLElement) {
|
|
1811
1811
|
// 往前添加
|
|
1812
1812
|
// 去除前面的空白
|
|
1813
1813
|
this.setSectionIsNear();
|
|
@@ -1815,10 +1815,10 @@ export const PanelHandleContentDetails = () => {
|
|
|
1815
1815
|
let $prev = this.$el.$selectedInputWrapper.previousElementSibling;
|
|
1816
1816
|
if ($prev) {
|
|
1817
1817
|
// 存在前一个元素,添加到前面的元素的后面
|
|
1818
|
-
popsDOMUtils.after($prev, $
|
|
1818
|
+
popsDOMUtils.after($prev, $tag);
|
|
1819
1819
|
} else {
|
|
1820
1820
|
// 不存在前一个元素,添加到最前面
|
|
1821
|
-
popsDOMUtils.before(this.$el.$selectedInputWrapper, $
|
|
1821
|
+
popsDOMUtils.before(this.$el.$selectedInputWrapper, $tag);
|
|
1822
1822
|
}
|
|
1823
1823
|
} else if (
|
|
1824
1824
|
this.$el.$section.contains(this.$el.$selectedPlaceHolderWrapper)
|
|
@@ -1827,13 +1827,13 @@ export const PanelHandleContentDetails = () => {
|
|
|
1827
1827
|
this.$el.$selectedPlaceHolderWrapper.previousElementSibling;
|
|
1828
1828
|
if ($prev) {
|
|
1829
1829
|
// 存在前一个元素,添加到前面的元素的后面
|
|
1830
|
-
popsDOMUtils.after($prev, $
|
|
1830
|
+
popsDOMUtils.after($prev, $tag);
|
|
1831
1831
|
} else {
|
|
1832
1832
|
// 不存在前一个元素,添加到最前面
|
|
1833
|
-
popsDOMUtils.before(this.$el.$selectedPlaceHolderWrapper, $
|
|
1833
|
+
popsDOMUtils.before(this.$el.$selectedPlaceHolderWrapper, $tag);
|
|
1834
1834
|
}
|
|
1835
1835
|
} else {
|
|
1836
|
-
this.$el.$section.appendChild($
|
|
1836
|
+
this.$el.$section.appendChild($tag);
|
|
1837
1837
|
}
|
|
1838
1838
|
// 隐藏元素
|
|
1839
1839
|
this.hideInputWrapper();
|
|
@@ -1846,161 +1846,271 @@ export const PanelHandleContentDetails = () => {
|
|
|
1846
1846
|
.forEach(($ele) => {
|
|
1847
1847
|
$ele.remove();
|
|
1848
1848
|
});
|
|
1849
|
-
this.
|
|
1849
|
+
this.initTagElement();
|
|
1850
1850
|
},
|
|
1851
1851
|
/**
|
|
1852
1852
|
* 选中的值改变的回调
|
|
1853
|
-
* @param
|
|
1853
|
+
* @param selectedDataList 当前的选中信息
|
|
1854
1854
|
*/
|
|
1855
1855
|
selectValueChangeCallBack(
|
|
1856
|
-
|
|
1856
|
+
selectedDataList?: PopsPanelSelectMultipleDataOption<any>[]
|
|
1857
1857
|
) {
|
|
1858
|
+
// 动态更新禁用状态
|
|
1859
|
+
this.updateSelectItem();
|
|
1858
1860
|
if (typeof formConfig.callback === "function") {
|
|
1859
|
-
formConfig.callback(
|
|
1861
|
+
formConfig.callback(selectedDataList || this.$data.selectInfo);
|
|
1860
1862
|
}
|
|
1861
1863
|
},
|
|
1862
|
-
/**
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1864
|
+
/**
|
|
1865
|
+
* 更新选项弹窗内的所有选项元素的状态
|
|
1866
|
+
*
|
|
1867
|
+
* + 更新禁用状态
|
|
1868
|
+
* + 更新选中状态
|
|
1869
|
+
*/
|
|
1870
|
+
updateSelectItem() {
|
|
1871
|
+
this.getAllSelectItemInfo(false).forEach(($selectInfo) => {
|
|
1872
|
+
const { data, $select } = $selectInfo;
|
|
1873
|
+
// 更新文字
|
|
1874
|
+
this.setSelectItemText(data, $selectInfo.$select);
|
|
1875
|
+
// 更新禁用状态
|
|
1876
|
+
if (
|
|
1877
|
+
typeof data.disable === "function" &&
|
|
1878
|
+
data.disable(data.value, this.$data.selectInfo)
|
|
1879
|
+
) {
|
|
1880
|
+
// 禁用
|
|
1881
|
+
this.setSelectItemDisabled($select);
|
|
1882
|
+
// 移除选中信息
|
|
1883
|
+
this.removeSelectedInfo(data, false);
|
|
1884
|
+
// 移除选中状态
|
|
1885
|
+
this.removeSelectItemSelected($select);
|
|
1886
|
+
} else {
|
|
1887
|
+
// 取消禁用
|
|
1888
|
+
this.removeSelectItemDisabled($select);
|
|
1875
1889
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1890
|
+
// 更新选中状态
|
|
1891
|
+
let findValue = this.$data.selectInfo.find(
|
|
1892
|
+
(it) => it.value === data.value
|
|
1893
|
+
);
|
|
1894
|
+
if (findValue) {
|
|
1895
|
+
this.setSelectItemSelected($select);
|
|
1896
|
+
} else {
|
|
1897
|
+
this.removeSelectItemSelected($select);
|
|
1882
1898
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1899
|
+
});
|
|
1900
|
+
},
|
|
1901
|
+
/**
|
|
1902
|
+
* 设置选项元素选中
|
|
1903
|
+
* @param $select 选项元素
|
|
1904
|
+
*/
|
|
1905
|
+
setSelectItemSelected($select: HTMLElement) {
|
|
1906
|
+
if (this.isSelectItemSelected($select)) return;
|
|
1907
|
+
$select.classList.add("select-item-is-selected");
|
|
1908
|
+
},
|
|
1909
|
+
/**
|
|
1910
|
+
* 移除选项元素选中
|
|
1911
|
+
* @param $select 选项元素
|
|
1912
|
+
*/
|
|
1913
|
+
removeSelectItemSelected($select: HTMLElement) {
|
|
1914
|
+
$select.classList.remove("select-item-is-selected");
|
|
1915
|
+
},
|
|
1916
|
+
/**
|
|
1917
|
+
* 判断选项元素是否选中
|
|
1918
|
+
* @param $select
|
|
1919
|
+
*/
|
|
1920
|
+
isSelectItemSelected($select: HTMLElement): boolean {
|
|
1921
|
+
return $select.classList.contains("select-item-is-selected");
|
|
1922
|
+
},
|
|
1923
|
+
/**
|
|
1924
|
+
* 添加选中信息
|
|
1925
|
+
* @param dataList 选择项列表的数据
|
|
1926
|
+
* @param $select 选项元素
|
|
1927
|
+
*/
|
|
1928
|
+
addSelectedItemInfo(
|
|
1929
|
+
dataList: PopsPanelSelectMultipleDataOption<any>[],
|
|
1930
|
+
$select: HTMLElement
|
|
1931
|
+
) {
|
|
1932
|
+
let info = this.getSelectedItemInfo($select);
|
|
1933
|
+
let findValue = dataList.find((item) => item.value === info.value);
|
|
1934
|
+
if (!findValue) {
|
|
1935
|
+
dataList.push({
|
|
1936
|
+
value: info.value,
|
|
1937
|
+
text: info.text,
|
|
1938
|
+
isHTML: Boolean(info.isHTML),
|
|
1939
|
+
disable: info.disable?.bind(info),
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
this.selectValueChangeCallBack(dataList);
|
|
1943
|
+
},
|
|
1944
|
+
/**
|
|
1945
|
+
* 获取选中的项的信息
|
|
1946
|
+
* @param $select 选项元素
|
|
1947
|
+
*/
|
|
1948
|
+
getSelectedItemInfo($select: HTMLElement) {
|
|
1949
|
+
return Reflect.get(
|
|
1950
|
+
$select,
|
|
1951
|
+
"data-info"
|
|
1952
|
+
) as PopsPanelSelectMultipleDataOption<any>;
|
|
1953
|
+
},
|
|
1954
|
+
/**
|
|
1955
|
+
* 移除选中信息
|
|
1956
|
+
* @param dataList 选择项的数据
|
|
1957
|
+
* @param $select 选项元素
|
|
1958
|
+
*/
|
|
1959
|
+
removeSelectedItemInfo(
|
|
1960
|
+
dataList: PopsPanelSelectMultipleDataOption<any>[],
|
|
1961
|
+
$select: HTMLElement
|
|
1962
|
+
) {
|
|
1963
|
+
let info = this.getSelectedItemInfo($select);
|
|
1964
|
+
let findIndex = dataList.findIndex(
|
|
1965
|
+
(item) => item.value === info.value
|
|
1966
|
+
);
|
|
1967
|
+
if (findIndex !== -1) {
|
|
1968
|
+
dataList.splice(findIndex, 1);
|
|
1969
|
+
}
|
|
1970
|
+
this.selectValueChangeCallBack(dataList);
|
|
1971
|
+
},
|
|
1972
|
+
/**
|
|
1973
|
+
* 获取所有选项的信息
|
|
1974
|
+
* @param [onlySelected=true] 是否仅获取选中的项的信息
|
|
1975
|
+
* + true (默认)仅获取选中项的信息
|
|
1976
|
+
* + false 获取所有选择项的信息
|
|
1977
|
+
*/
|
|
1978
|
+
getAllSelectItemInfo(onlySelected: boolean = true) {
|
|
1979
|
+
return Array.from(
|
|
1980
|
+
this.$el.$selectContainer?.querySelectorAll<HTMLElement>(
|
|
1981
|
+
".select-item"
|
|
1982
|
+
) ?? []
|
|
1983
|
+
)
|
|
1984
|
+
.map(($select) => {
|
|
1985
|
+
let data = this.getSelectedItemInfo($select);
|
|
1986
|
+
let result = {
|
|
1987
|
+
/** 选项信息数据 */
|
|
1988
|
+
data: data,
|
|
1989
|
+
/** 选项元素 */
|
|
1990
|
+
$select: $select,
|
|
1991
|
+
};
|
|
1992
|
+
if (onlySelected) {
|
|
1993
|
+
// 仅选中
|
|
1994
|
+
let isSelected = this.isSelectItemSelected($select);
|
|
1995
|
+
if (isSelected) {
|
|
1996
|
+
return result;
|
|
1997
|
+
}
|
|
1998
|
+
return;
|
|
1999
|
+
} else {
|
|
2000
|
+
return result;
|
|
1898
2001
|
}
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
2002
|
+
})
|
|
2003
|
+
.filter((item) => {
|
|
2004
|
+
return item != null;
|
|
2005
|
+
});
|
|
2006
|
+
},
|
|
2007
|
+
/**
|
|
2008
|
+
* 创建一个选择项元素
|
|
2009
|
+
* @param data 选择项的数据
|
|
2010
|
+
*/
|
|
2011
|
+
createSelectItemElement(data: PopsPanelSelectMultipleDataOption<any>) {
|
|
2012
|
+
let $select = popsDOMUtils.createElement("li", {
|
|
2013
|
+
className: "select-item",
|
|
2014
|
+
innerHTML: /*html*/ `
|
|
2015
|
+
<span class="select-item-text"></span>
|
|
2016
|
+
`,
|
|
2017
|
+
});
|
|
2018
|
+
this.setSelectItemText(data, $select);
|
|
2019
|
+
Reflect.set($select, "data-info", data);
|
|
2020
|
+
return $select;
|
|
2021
|
+
},
|
|
2022
|
+
/**
|
|
2023
|
+
* 设置选择项的文字
|
|
2024
|
+
* @param data 选择项的数据
|
|
2025
|
+
* @param $select 选择项元素
|
|
2026
|
+
*/
|
|
2027
|
+
setSelectItemText(
|
|
2028
|
+
data: PopsPanelSelectMultipleDataOption<any>,
|
|
2029
|
+
$select: HTMLElement
|
|
2030
|
+
) {
|
|
2031
|
+
let text =
|
|
2032
|
+
typeof data.text === "function"
|
|
2033
|
+
? data.text(data.value, this.$data.selectInfo)
|
|
2034
|
+
: data.text;
|
|
2035
|
+
let $selectSpan =
|
|
2036
|
+
$select.querySelector<HTMLElement>(".select-item-text")!;
|
|
2037
|
+
if (data.isHTML) {
|
|
2038
|
+
PopsSafeUtils.setSafeHTML($selectSpan, text);
|
|
2039
|
+
} else {
|
|
2040
|
+
$selectSpan.innerText = text;
|
|
2041
|
+
}
|
|
2042
|
+
},
|
|
2043
|
+
/**
|
|
2044
|
+
* 设置选择项的禁用状态
|
|
2045
|
+
* @param $select 选择项元素
|
|
2046
|
+
*/
|
|
2047
|
+
setSelectItemDisabled($select: HTMLElement) {
|
|
2048
|
+
$select.setAttribute("aria-disabled", "true");
|
|
2049
|
+
$select.setAttribute("disabled", "true");
|
|
2050
|
+
},
|
|
2051
|
+
/**
|
|
2052
|
+
* 移除选择项的禁用状态
|
|
2053
|
+
* @param $select 选择项元素
|
|
2054
|
+
*/
|
|
2055
|
+
removeSelectItemDisabled($select: HTMLElement) {
|
|
2056
|
+
$select.removeAttribute("aria-disabled");
|
|
2057
|
+
$select.removeAttribute("disabled");
|
|
2058
|
+
},
|
|
2059
|
+
/**
|
|
2060
|
+
* 判断选择项是否禁用
|
|
2061
|
+
* @param $select 选择项元素
|
|
2062
|
+
*/
|
|
2063
|
+
isSelectItemDisabled($select: HTMLElement) {
|
|
2064
|
+
return $select.hasAttribute("disabled") || $select.ariaDisabled;
|
|
2065
|
+
},
|
|
2066
|
+
/**
|
|
2067
|
+
* 设置选择项的点击事件
|
|
2068
|
+
* @param dataList 选中的信息列表
|
|
2069
|
+
* @param $select 选择项元素
|
|
2070
|
+
*/
|
|
2071
|
+
setSelectElementClickEvent(
|
|
2072
|
+
dataList: PopsPanelSelectMultipleDataOption<any>[],
|
|
2073
|
+
$select: HTMLElement
|
|
2074
|
+
) {
|
|
2075
|
+
popsDOMUtils.on<PointerEvent | MouseEvent>(
|
|
2076
|
+
$select,
|
|
2077
|
+
"click",
|
|
2078
|
+
(event) => {
|
|
2079
|
+
popsDOMUtils.preventEvent(event);
|
|
2080
|
+
if (this.isSelectItemDisabled($select)) {
|
|
2081
|
+
return;
|
|
1911
2082
|
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
* 获取选中的项的信息
|
|
1923
|
-
*/
|
|
1924
|
-
function getSelectedInfo($ele: HTMLElement) {
|
|
1925
|
-
return Reflect.get($ele, "data-info") as {
|
|
1926
|
-
value: any;
|
|
1927
|
-
text: string;
|
|
1928
|
-
isHTML?: boolean;
|
|
1929
|
-
disable?(value: any): boolean;
|
|
1930
|
-
};
|
|
1931
|
-
}
|
|
1932
|
-
/**
|
|
1933
|
-
* 获取所有选中的项的信息
|
|
1934
|
-
*/
|
|
1935
|
-
function getAllSelectedInfo() {
|
|
1936
|
-
return Array.from(
|
|
1937
|
-
$selectContainer.querySelectorAll<HTMLElement>(".select-item")
|
|
1938
|
-
)
|
|
1939
|
-
.map(($ele) => {
|
|
1940
|
-
if (isSelected($ele)) {
|
|
1941
|
-
return getSelectedInfo($ele);
|
|
1942
|
-
}
|
|
1943
|
-
})
|
|
1944
|
-
.filter((item) => {
|
|
1945
|
-
return item != null;
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
/**
|
|
1949
|
-
* 创建一个选择项元素
|
|
1950
|
-
*/
|
|
1951
|
-
function createSelectItemElement(dataInfo: { text: string }) {
|
|
1952
|
-
let $item = popsDOMUtils.createElement("li", {
|
|
1953
|
-
className: "select-item",
|
|
1954
|
-
innerHTML: /*html*/ `<span>${dataInfo.text}</span>`,
|
|
1955
|
-
});
|
|
1956
|
-
Reflect.set($item, "data-info", dataInfo);
|
|
1957
|
-
return $item;
|
|
1958
|
-
}
|
|
1959
|
-
/**
|
|
1960
|
-
* 设置选择项的禁用状态
|
|
1961
|
-
*/
|
|
1962
|
-
function setSelectItemDisabled($el: HTMLElement) {
|
|
1963
|
-
$el.setAttribute("aria-disabled", "true");
|
|
1964
|
-
}
|
|
1965
|
-
/**
|
|
1966
|
-
* 移除选择项的禁用状态
|
|
1967
|
-
*/
|
|
1968
|
-
function removeSelectItemDisabled($el: HTMLElement) {
|
|
1969
|
-
$el.removeAttribute("aria-disabled");
|
|
1970
|
-
$el.removeAttribute("disabled");
|
|
1971
|
-
}
|
|
1972
|
-
/**
|
|
1973
|
-
* 设置选择项的点击事件
|
|
1974
|
-
*/
|
|
1975
|
-
function setSelectElementClickEvent($ele: HTMLElement) {
|
|
1976
|
-
popsDOMUtils.on<PointerEvent | MouseEvent>(
|
|
1977
|
-
$ele,
|
|
1978
|
-
"click",
|
|
1979
|
-
(event) => {
|
|
1980
|
-
popsDOMUtils.preventEvent(event);
|
|
1981
|
-
if ($ele.hasAttribute("disabled") || $ele.ariaDisabled) {
|
|
1982
|
-
return;
|
|
1983
|
-
}
|
|
1984
|
-
if (typeof formConfig.clickCallBack === "function") {
|
|
1985
|
-
let clickResult = formConfig.clickCallBack(
|
|
1986
|
-
event,
|
|
1987
|
-
getAllSelectedInfo()
|
|
1988
|
-
);
|
|
1989
|
-
if (typeof clickResult === "boolean" && !clickResult) {
|
|
1990
|
-
return;
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
// 修改选中状态
|
|
1994
|
-
if (isSelected($ele)) {
|
|
1995
|
-
removeItemSelected($ele);
|
|
1996
|
-
removeSelectedInfo($ele);
|
|
1997
|
-
} else {
|
|
1998
|
-
setItemSelected($ele);
|
|
1999
|
-
addSelectedInfo($ele);
|
|
2000
|
-
}
|
|
2083
|
+
if (typeof formConfig.clickCallBack === "function") {
|
|
2084
|
+
let allSelectedInfo = this.getAllSelectItemInfo().map(
|
|
2085
|
+
(it) => it.data
|
|
2086
|
+
);
|
|
2087
|
+
let clickResult = formConfig.clickCallBack(
|
|
2088
|
+
event,
|
|
2089
|
+
allSelectedInfo
|
|
2090
|
+
);
|
|
2091
|
+
if (typeof clickResult === "boolean" && !clickResult) {
|
|
2092
|
+
return;
|
|
2001
2093
|
}
|
|
2002
|
-
|
|
2094
|
+
}
|
|
2095
|
+
// 修改选中状态
|
|
2096
|
+
if (this.isSelectItemSelected($select)) {
|
|
2097
|
+
this.removeSelectItemSelected($select);
|
|
2098
|
+
this.removeSelectedItemInfo(dataList, $select);
|
|
2099
|
+
} else {
|
|
2100
|
+
this.setSelectItemSelected($select);
|
|
2101
|
+
this.addSelectedItemInfo(dataList, $select);
|
|
2102
|
+
}
|
|
2003
2103
|
}
|
|
2104
|
+
);
|
|
2105
|
+
},
|
|
2106
|
+
/**
|
|
2107
|
+
* 设置下拉列表的点击事件
|
|
2108
|
+
*/
|
|
2109
|
+
setSelectContainerClickEvent() {
|
|
2110
|
+
const that = this;
|
|
2111
|
+
popsDOMUtils.on(this.$el.$container, "click", (event) => {
|
|
2112
|
+
/** 弹窗的选中的值 */
|
|
2113
|
+
let selectedInfo = that.$data.selectInfo;
|
|
2004
2114
|
let { style, ...userConfirmDetails } =
|
|
2005
2115
|
formConfig.selectConfirmDialogDetails || {};
|
|
2006
2116
|
let confirmDetails = popsUtils.assign(
|
|
@@ -2024,6 +2134,7 @@ export const PanelHandleContentDetails = () => {
|
|
|
2024
2134
|
callback(details, event) {
|
|
2025
2135
|
that.$data.selectInfo = [...selectedInfo];
|
|
2026
2136
|
that.updateSelectTagItem();
|
|
2137
|
+
that.$el.$selectContainer = null;
|
|
2027
2138
|
details.close();
|
|
2028
2139
|
},
|
|
2029
2140
|
},
|
|
@@ -2034,6 +2145,7 @@ export const PanelHandleContentDetails = () => {
|
|
|
2034
2145
|
originalRun();
|
|
2035
2146
|
that.$data.selectInfo = [...selectedInfo];
|
|
2036
2147
|
that.updateSelectTagItem();
|
|
2148
|
+
that.$el.$selectContainer = null;
|
|
2037
2149
|
},
|
|
2038
2150
|
clickEvent: {
|
|
2039
2151
|
toClose: true,
|
|
@@ -2104,43 +2216,32 @@ export const PanelHandleContentDetails = () => {
|
|
|
2104
2216
|
$dialog.$shadowRoot.querySelector<HTMLUListElement>(
|
|
2105
2217
|
".select-container"
|
|
2106
2218
|
)!;
|
|
2219
|
+
this.$el.$selectContainer = $selectContainer;
|
|
2107
2220
|
// 配置选项元素
|
|
2108
2221
|
formConfig.data.forEach((item) => {
|
|
2109
|
-
let $select = createSelectItemElement(item);
|
|
2222
|
+
let $select = this.createSelectItemElement(item);
|
|
2110
2223
|
// 添加到confirm中
|
|
2111
2224
|
$selectContainer.appendChild($select);
|
|
2112
2225
|
// 设置每一项的点击事件
|
|
2113
|
-
setSelectElementClickEvent($select);
|
|
2114
|
-
// 设置禁用状态
|
|
2115
|
-
if (
|
|
2116
|
-
typeof item.disable === "function" &&
|
|
2117
|
-
item.disable(item.value)
|
|
2118
|
-
) {
|
|
2119
|
-
setSelectItemDisabled($select);
|
|
2120
|
-
// 后续不设置元素的选中状态
|
|
2121
|
-
return;
|
|
2122
|
-
}
|
|
2123
|
-
// 移除禁用状态
|
|
2124
|
-
removeSelectItemDisabled($select);
|
|
2125
|
-
let findValue = selectedInfo.find(
|
|
2126
|
-
(value) => value.value === item.value
|
|
2127
|
-
);
|
|
2128
|
-
if (findValue) {
|
|
2129
|
-
setItemSelected($select);
|
|
2130
|
-
}
|
|
2226
|
+
this.setSelectElementClickEvent(selectedInfo, $select);
|
|
2131
2227
|
});
|
|
2228
|
+
// 动态更新禁用状态
|
|
2229
|
+
this.updateSelectItem();
|
|
2132
2230
|
});
|
|
2133
2231
|
},
|
|
2134
|
-
/**
|
|
2232
|
+
/**
|
|
2233
|
+
* 设置关闭图标的点击事件
|
|
2234
|
+
* @param data 选中的信息
|
|
2235
|
+
*/
|
|
2135
2236
|
setSelectedItemCloseIconClickEvent(data: {
|
|
2136
2237
|
/** 关闭图标的元素 */
|
|
2137
2238
|
$closeIcon: HTMLElement;
|
|
2138
2239
|
/** tag元素 */
|
|
2139
2240
|
$tag: HTMLElement;
|
|
2140
2241
|
/** 值 */
|
|
2141
|
-
value: any;
|
|
2242
|
+
value: PopsPanelSelectMultipleDataOption<any>["value"];
|
|
2142
2243
|
/** 显示的文字 */
|
|
2143
|
-
text:
|
|
2244
|
+
text: PopsPanelSelectMultipleDataOption<any>["text"];
|
|
2144
2245
|
}) {
|
|
2145
2246
|
popsDOMUtils.on<PointerEvent | MouseEvent>(
|
|
2146
2247
|
data.$closeIcon,
|
|
@@ -2152,13 +2253,16 @@ export const PanelHandleContentDetails = () => {
|
|
|
2152
2253
|
$tag: data.$tag,
|
|
2153
2254
|
$closeIcon: data.$closeIcon,
|
|
2154
2255
|
value: data.value,
|
|
2155
|
-
text:
|
|
2256
|
+
text:
|
|
2257
|
+
typeof data.text === "function"
|
|
2258
|
+
? data.text.bind(data)
|
|
2259
|
+
: data.text,
|
|
2156
2260
|
});
|
|
2157
2261
|
if (typeof result === "boolean" && !result) {
|
|
2158
2262
|
return;
|
|
2159
2263
|
}
|
|
2160
2264
|
}
|
|
2161
|
-
this.
|
|
2265
|
+
this.removeSelectedTagItem(data.$tag);
|
|
2162
2266
|
this.removeSelectedInfo({
|
|
2163
2267
|
value: data.value,
|
|
2164
2268
|
text: data.text,
|
|
@@ -2182,13 +2286,24 @@ export const PanelHandleContentDetails = () => {
|
|
|
2182
2286
|
this.removeSectionIsNear();
|
|
2183
2287
|
}
|
|
2184
2288
|
},
|
|
2185
|
-
/**
|
|
2186
|
-
|
|
2187
|
-
|
|
2289
|
+
/**
|
|
2290
|
+
* 移除选中项元素
|
|
2291
|
+
*/
|
|
2292
|
+
removeSelectedTagItem($tag: HTMLElement) {
|
|
2293
|
+
$tag.remove();
|
|
2188
2294
|
this.checkTagEmpty();
|
|
2189
2295
|
},
|
|
2190
|
-
/**
|
|
2191
|
-
|
|
2296
|
+
/**
|
|
2297
|
+
* 从保存的已选中的信息列表中移除目标信息
|
|
2298
|
+
* @param data 需要移除的信息
|
|
2299
|
+
* @param [triggerValueChangeCallBack=true] 是否触发值改变的回调
|
|
2300
|
+
* + true (默认)触发值改变的回调
|
|
2301
|
+
* + false 不触发值改变的回调
|
|
2302
|
+
*/
|
|
2303
|
+
removeSelectedInfo(
|
|
2304
|
+
data: PopsPanelSelectMultipleDataOption<any>,
|
|
2305
|
+
triggerValueChangeCallBack: boolean = true
|
|
2306
|
+
) {
|
|
2192
2307
|
for (let index = 0; index < this.$data.selectInfo.length; index++) {
|
|
2193
2308
|
const selectInfo = this.$data.selectInfo[index];
|
|
2194
2309
|
if (selectInfo.value === data.value) {
|
|
@@ -2196,7 +2311,7 @@ export const PanelHandleContentDetails = () => {
|
|
|
2196
2311
|
break;
|
|
2197
2312
|
}
|
|
2198
2313
|
}
|
|
2199
|
-
this.selectValueChangeCallBack();
|
|
2314
|
+
triggerValueChangeCallBack && this.selectValueChangeCallBack();
|
|
2200
2315
|
},
|
|
2201
2316
|
/** 显示输入框 */
|
|
2202
2317
|
showInputWrapper() {
|
|
@@ -2679,7 +2794,7 @@ export const PanelHandleContentDetails = () => {
|
|
|
2679
2794
|
);
|
|
2680
2795
|
} else if (formType === "select-multiple") {
|
|
2681
2796
|
return this.createSectionContainerItem_select_multiple_new(
|
|
2682
|
-
formConfig as PopsPanelSelectMultipleDetails
|
|
2797
|
+
formConfig as PopsPanelSelectMultipleDetails<any>
|
|
2683
2798
|
);
|
|
2684
2799
|
} else if (formType === "button") {
|
|
2685
2800
|
return this.createSectionContainerItem_button(
|