@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
package/dist/index.cjs.js
CHANGED
|
@@ -5840,40 +5840,44 @@ const PopsPanelConfig = () => {
|
|
|
5840
5840
|
value: "select-1",
|
|
5841
5841
|
text: "单选1",
|
|
5842
5842
|
isHTML: false,
|
|
5843
|
-
disable() {
|
|
5844
|
-
return
|
|
5843
|
+
disable(value, allSelectedInfo) {
|
|
5844
|
+
return (allSelectedInfo.findIndex((it) => ["select-5"].includes(it.value)) !== -1);
|
|
5845
5845
|
},
|
|
5846
5846
|
},
|
|
5847
5847
|
{
|
|
5848
5848
|
value: "select-2",
|
|
5849
5849
|
text: "单选2",
|
|
5850
5850
|
isHTML: false,
|
|
5851
|
-
disable() {
|
|
5852
|
-
return
|
|
5851
|
+
disable(value, allSelectedInfo) {
|
|
5852
|
+
return (allSelectedInfo.findIndex((it) => ["select-5"].includes(it.value)) !== -1);
|
|
5853
5853
|
},
|
|
5854
5854
|
},
|
|
5855
5855
|
{
|
|
5856
5856
|
value: "select-3",
|
|
5857
5857
|
text: "单选3",
|
|
5858
5858
|
isHTML: false,
|
|
5859
|
-
disable() {
|
|
5860
|
-
return
|
|
5859
|
+
disable(value, allSelectedInfo) {
|
|
5860
|
+
return (allSelectedInfo.findIndex((it) => ["select-2", "select-5"].includes(it.value)) !== -1);
|
|
5861
5861
|
},
|
|
5862
5862
|
},
|
|
5863
5863
|
{
|
|
5864
5864
|
value: "select-4",
|
|
5865
5865
|
text: "单选4",
|
|
5866
5866
|
isHTML: false,
|
|
5867
|
-
disable() {
|
|
5868
|
-
return
|
|
5867
|
+
disable(value, allSelectedInfo) {
|
|
5868
|
+
return (allSelectedInfo.findIndex((it) => ["select-3", "select-5"].includes(it.value)) !== -1);
|
|
5869
5869
|
},
|
|
5870
5870
|
},
|
|
5871
5871
|
{
|
|
5872
5872
|
value: "select-5",
|
|
5873
|
-
text
|
|
5873
|
+
text(value, allSelectedInfo) {
|
|
5874
|
+
return allSelectedInfo.findIndex((it) => ["select-4"].includes(it.value)) !== -1
|
|
5875
|
+
? "单选5-禁用"
|
|
5876
|
+
: "单选5";
|
|
5877
|
+
},
|
|
5874
5878
|
isHTML: false,
|
|
5875
|
-
disable() {
|
|
5876
|
-
return
|
|
5879
|
+
disable(value, allSelectedInfo) {
|
|
5880
|
+
return (allSelectedInfo.findIndex((it) => ["select-4"].includes(it.value)) !== -1);
|
|
5877
5881
|
},
|
|
5878
5882
|
},
|
|
5879
5883
|
],
|
|
@@ -7601,6 +7605,8 @@ const PanelHandleContentDetails = () => {
|
|
|
7601
7605
|
$suffix: void 0,
|
|
7602
7606
|
/** 下拉箭头图标 */
|
|
7603
7607
|
$suffixIcon: void 0,
|
|
7608
|
+
/** 下拉列表弹窗的下拉列表容器 */
|
|
7609
|
+
$selectContainer: void 0,
|
|
7604
7610
|
},
|
|
7605
7611
|
$data: {
|
|
7606
7612
|
/** 默认值 */
|
|
@@ -7612,7 +7618,7 @@ const PanelHandleContentDetails = () => {
|
|
|
7612
7618
|
this.initDefault();
|
|
7613
7619
|
this.inintEl();
|
|
7614
7620
|
this.initPlaceHolder();
|
|
7615
|
-
this.
|
|
7621
|
+
this.initTagElement();
|
|
7616
7622
|
this.setSelectContainerClickEvent();
|
|
7617
7623
|
},
|
|
7618
7624
|
/** 初始化默认值 */
|
|
@@ -7624,7 +7630,7 @@ const PanelHandleContentDetails = () => {
|
|
|
7624
7630
|
text: dataItem.text,
|
|
7625
7631
|
value: dataItem.value,
|
|
7626
7632
|
isHTML: Boolean(dataItem.isHTML),
|
|
7627
|
-
disable: dataItem.disable,
|
|
7633
|
+
disable: dataItem.disable?.bind(dataItem),
|
|
7628
7634
|
});
|
|
7629
7635
|
}
|
|
7630
7636
|
});
|
|
@@ -7660,18 +7666,15 @@ const PanelHandleContentDetails = () => {
|
|
|
7660
7666
|
});
|
|
7661
7667
|
this.$el.$selectedPlaceHolderWrapper.appendChild($placeholder);
|
|
7662
7668
|
},
|
|
7663
|
-
/** 初始化tag */
|
|
7664
|
-
|
|
7669
|
+
/** 初始化tag元素 */
|
|
7670
|
+
initTagElement() {
|
|
7665
7671
|
// 遍历数据,寻找对应的值
|
|
7666
7672
|
formConfig.data.forEach((dataItem) => {
|
|
7667
7673
|
let findValue = this.$data.selectInfo.find((item) => item.value === dataItem.value);
|
|
7668
7674
|
if (findValue) {
|
|
7669
|
-
//
|
|
7670
|
-
let selectedInfo = this.
|
|
7671
|
-
|
|
7672
|
-
isHTML: dataItem.isHTML,
|
|
7673
|
-
});
|
|
7674
|
-
this.addSelectedItem(selectedInfo.$tag);
|
|
7675
|
+
// 存在对应的值
|
|
7676
|
+
let selectedInfo = this.createSelectedTagItem(dataItem);
|
|
7677
|
+
this.addSelectedTagItem(selectedInfo.$tag);
|
|
7675
7678
|
this.setSelectedItemCloseIconClickEvent({
|
|
7676
7679
|
$tag: selectedInfo.$tag,
|
|
7677
7680
|
$closeIcon: selectedInfo.$closeIcon,
|
|
@@ -7686,7 +7689,7 @@ const PanelHandleContentDetails = () => {
|
|
|
7686
7689
|
* 生成一个tag项
|
|
7687
7690
|
* @param data 配置
|
|
7688
7691
|
*/
|
|
7689
|
-
|
|
7692
|
+
createSelectedTagItem(data) {
|
|
7690
7693
|
const $selectedItem = popsDOMUtils.createElement("div", {
|
|
7691
7694
|
className: "el-select__selected-item el-select__choose_tag",
|
|
7692
7695
|
innerHTML: /*html*/ `
|
|
@@ -7707,11 +7710,14 @@ const PanelHandleContentDetails = () => {
|
|
|
7707
7710
|
const $tagText = $selectedItem.querySelector(".el-select__tags-text");
|
|
7708
7711
|
/** 关闭图标 */
|
|
7709
7712
|
const $closeIcon = $selectedItem.querySelector(".el-icon.el-tag__close");
|
|
7713
|
+
let text = typeof data.text === "function"
|
|
7714
|
+
? data.text(data, this.$data.selectInfo)
|
|
7715
|
+
: data.text;
|
|
7710
7716
|
if (data.isHTML) {
|
|
7711
|
-
PopsSafeUtils.setSafeHTML($tagText,
|
|
7717
|
+
PopsSafeUtils.setSafeHTML($tagText, text);
|
|
7712
7718
|
}
|
|
7713
7719
|
else {
|
|
7714
|
-
$tagText.innerText =
|
|
7720
|
+
$tagText.innerText = text;
|
|
7715
7721
|
}
|
|
7716
7722
|
return {
|
|
7717
7723
|
$tag: $selectedItem,
|
|
@@ -7720,9 +7726,10 @@ const PanelHandleContentDetails = () => {
|
|
|
7720
7726
|
};
|
|
7721
7727
|
},
|
|
7722
7728
|
/**
|
|
7723
|
-
*
|
|
7729
|
+
* 添加选中项的tag元素
|
|
7730
|
+
* @param $tag 添加的元素
|
|
7724
7731
|
*/
|
|
7725
|
-
|
|
7732
|
+
addSelectedTagItem($tag) {
|
|
7726
7733
|
// 往前添加
|
|
7727
7734
|
// 去除前面的空白
|
|
7728
7735
|
this.setSectionIsNear();
|
|
@@ -7730,26 +7737,26 @@ const PanelHandleContentDetails = () => {
|
|
|
7730
7737
|
let $prev = this.$el.$selectedInputWrapper.previousElementSibling;
|
|
7731
7738
|
if ($prev) {
|
|
7732
7739
|
// 存在前一个元素,添加到前面的元素的后面
|
|
7733
|
-
popsDOMUtils.after($prev, $
|
|
7740
|
+
popsDOMUtils.after($prev, $tag);
|
|
7734
7741
|
}
|
|
7735
7742
|
else {
|
|
7736
7743
|
// 不存在前一个元素,添加到最前面
|
|
7737
|
-
popsDOMUtils.before(this.$el.$selectedInputWrapper, $
|
|
7744
|
+
popsDOMUtils.before(this.$el.$selectedInputWrapper, $tag);
|
|
7738
7745
|
}
|
|
7739
7746
|
}
|
|
7740
7747
|
else if (this.$el.$section.contains(this.$el.$selectedPlaceHolderWrapper)) {
|
|
7741
7748
|
let $prev = this.$el.$selectedPlaceHolderWrapper.previousElementSibling;
|
|
7742
7749
|
if ($prev) {
|
|
7743
7750
|
// 存在前一个元素,添加到前面的元素的后面
|
|
7744
|
-
popsDOMUtils.after($prev, $
|
|
7751
|
+
popsDOMUtils.after($prev, $tag);
|
|
7745
7752
|
}
|
|
7746
7753
|
else {
|
|
7747
7754
|
// 不存在前一个元素,添加到最前面
|
|
7748
|
-
popsDOMUtils.before(this.$el.$selectedPlaceHolderWrapper, $
|
|
7755
|
+
popsDOMUtils.before(this.$el.$selectedPlaceHolderWrapper, $tag);
|
|
7749
7756
|
}
|
|
7750
7757
|
}
|
|
7751
7758
|
else {
|
|
7752
|
-
this.$el.$section.appendChild($
|
|
7759
|
+
this.$el.$section.appendChild($tag);
|
|
7753
7760
|
}
|
|
7754
7761
|
// 隐藏元素
|
|
7755
7762
|
this.hideInputWrapper();
|
|
@@ -7762,142 +7769,239 @@ const PanelHandleContentDetails = () => {
|
|
|
7762
7769
|
.forEach(($ele) => {
|
|
7763
7770
|
$ele.remove();
|
|
7764
7771
|
});
|
|
7765
|
-
this.
|
|
7772
|
+
this.initTagElement();
|
|
7766
7773
|
},
|
|
7767
7774
|
/**
|
|
7768
7775
|
* 选中的值改变的回调
|
|
7769
|
-
* @param
|
|
7776
|
+
* @param selectedDataList 当前的选中信息
|
|
7770
7777
|
*/
|
|
7771
|
-
selectValueChangeCallBack(
|
|
7778
|
+
selectValueChangeCallBack(selectedDataList) {
|
|
7779
|
+
// 动态更新禁用状态
|
|
7780
|
+
this.updateSelectItem();
|
|
7772
7781
|
if (typeof formConfig.callback === "function") {
|
|
7773
|
-
formConfig.callback(
|
|
7782
|
+
formConfig.callback(selectedDataList || this.$data.selectInfo);
|
|
7774
7783
|
}
|
|
7775
7784
|
},
|
|
7776
|
-
/**
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7785
|
+
/**
|
|
7786
|
+
* 更新选项弹窗内的所有选项元素的状态
|
|
7787
|
+
*
|
|
7788
|
+
* + 更新禁用状态
|
|
7789
|
+
* + 更新选中状态
|
|
7790
|
+
*/
|
|
7791
|
+
updateSelectItem() {
|
|
7792
|
+
this.getAllSelectItemInfo(false).forEach(($selectInfo) => {
|
|
7793
|
+
const { data, $select } = $selectInfo;
|
|
7794
|
+
// 更新文字
|
|
7795
|
+
this.setSelectItemText(data, $selectInfo.$select);
|
|
7796
|
+
// 更新禁用状态
|
|
7797
|
+
if (typeof data.disable === "function" &&
|
|
7798
|
+
data.disable(data.value, this.$data.selectInfo)) {
|
|
7799
|
+
// 禁用
|
|
7800
|
+
this.setSelectItemDisabled($select);
|
|
7801
|
+
// 移除选中信息
|
|
7802
|
+
this.removeSelectedInfo(data, false);
|
|
7803
|
+
// 移除选中状态
|
|
7804
|
+
this.removeSelectItemSelected($select);
|
|
7796
7805
|
}
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
function addSelectedInfo($ele) {
|
|
7801
|
-
let info = getSelectedInfo($ele);
|
|
7802
|
-
let findValue = selectedInfo.find((item) => item.value === info.value);
|
|
7803
|
-
if (!findValue) {
|
|
7804
|
-
selectedInfo.push({
|
|
7805
|
-
value: info.value,
|
|
7806
|
-
text: info.text,
|
|
7807
|
-
isHTML: Boolean(info.isHTML),
|
|
7808
|
-
disable: info.disable,
|
|
7809
|
-
});
|
|
7810
|
-
}
|
|
7811
|
-
that.selectValueChangeCallBack(selectedInfo);
|
|
7806
|
+
else {
|
|
7807
|
+
// 取消禁用
|
|
7808
|
+
this.removeSelectItemDisabled($select);
|
|
7812
7809
|
}
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
let info = getSelectedInfo($ele);
|
|
7818
|
-
let findIndex = selectedInfo.findIndex((item) => item.value === info.value);
|
|
7819
|
-
if (findIndex !== -1) {
|
|
7820
|
-
selectedInfo.splice(findIndex, 1);
|
|
7821
|
-
}
|
|
7822
|
-
that.selectValueChangeCallBack(selectedInfo);
|
|
7810
|
+
// 更新选中状态
|
|
7811
|
+
let findValue = this.$data.selectInfo.find((it) => it.value === data.value);
|
|
7812
|
+
if (findValue) {
|
|
7813
|
+
this.setSelectItemSelected($select);
|
|
7823
7814
|
}
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
* @param $ele
|
|
7827
|
-
*/
|
|
7828
|
-
function isSelected($ele) {
|
|
7829
|
-
return $ele.classList.contains("select-item-is-selected");
|
|
7815
|
+
else {
|
|
7816
|
+
this.removeSelectItemSelected($select);
|
|
7830
7817
|
}
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7818
|
+
});
|
|
7819
|
+
},
|
|
7820
|
+
/**
|
|
7821
|
+
* 设置选项元素选中
|
|
7822
|
+
* @param $select 选项元素
|
|
7823
|
+
*/
|
|
7824
|
+
setSelectItemSelected($select) {
|
|
7825
|
+
if (this.isSelectItemSelected($select))
|
|
7826
|
+
return;
|
|
7827
|
+
$select.classList.add("select-item-is-selected");
|
|
7828
|
+
},
|
|
7829
|
+
/**
|
|
7830
|
+
* 移除选项元素选中
|
|
7831
|
+
* @param $select 选项元素
|
|
7832
|
+
*/
|
|
7833
|
+
removeSelectItemSelected($select) {
|
|
7834
|
+
$select.classList.remove("select-item-is-selected");
|
|
7835
|
+
},
|
|
7836
|
+
/**
|
|
7837
|
+
* 判断选项元素是否选中
|
|
7838
|
+
* @param $select
|
|
7839
|
+
*/
|
|
7840
|
+
isSelectItemSelected($select) {
|
|
7841
|
+
return $select.classList.contains("select-item-is-selected");
|
|
7842
|
+
},
|
|
7843
|
+
/**
|
|
7844
|
+
* 添加选中信息
|
|
7845
|
+
* @param dataList 选择项列表的数据
|
|
7846
|
+
* @param $select 选项元素
|
|
7847
|
+
*/
|
|
7848
|
+
addSelectedItemInfo(dataList, $select) {
|
|
7849
|
+
let info = this.getSelectedItemInfo($select);
|
|
7850
|
+
let findValue = dataList.find((item) => item.value === info.value);
|
|
7851
|
+
if (!findValue) {
|
|
7852
|
+
dataList.push({
|
|
7853
|
+
value: info.value,
|
|
7854
|
+
text: info.text,
|
|
7855
|
+
isHTML: Boolean(info.isHTML),
|
|
7856
|
+
disable: info.disable?.bind(info),
|
|
7857
|
+
});
|
|
7858
|
+
}
|
|
7859
|
+
this.selectValueChangeCallBack(dataList);
|
|
7860
|
+
},
|
|
7861
|
+
/**
|
|
7862
|
+
* 获取选中的项的信息
|
|
7863
|
+
* @param $select 选项元素
|
|
7864
|
+
*/
|
|
7865
|
+
getSelectedItemInfo($select) {
|
|
7866
|
+
return Reflect.get($select, "data-info");
|
|
7867
|
+
},
|
|
7868
|
+
/**
|
|
7869
|
+
* 移除选中信息
|
|
7870
|
+
* @param dataList 选择项的数据
|
|
7871
|
+
* @param $select 选项元素
|
|
7872
|
+
*/
|
|
7873
|
+
removeSelectedItemInfo(dataList, $select) {
|
|
7874
|
+
let info = this.getSelectedItemInfo($select);
|
|
7875
|
+
let findIndex = dataList.findIndex((item) => item.value === info.value);
|
|
7876
|
+
if (findIndex !== -1) {
|
|
7877
|
+
dataList.splice(findIndex, 1);
|
|
7878
|
+
}
|
|
7879
|
+
this.selectValueChangeCallBack(dataList);
|
|
7880
|
+
},
|
|
7881
|
+
/**
|
|
7882
|
+
* 获取所有选项的信息
|
|
7883
|
+
* @param [onlySelected=true] 是否仅获取选中的项的信息
|
|
7884
|
+
* + true (默认)仅获取选中项的信息
|
|
7885
|
+
* + false 获取所有选择项的信息
|
|
7886
|
+
*/
|
|
7887
|
+
getAllSelectItemInfo(onlySelected = true) {
|
|
7888
|
+
return Array.from(this.$el.$selectContainer?.querySelectorAll(".select-item") ?? [])
|
|
7889
|
+
.map(($select) => {
|
|
7890
|
+
let data = this.getSelectedItemInfo($select);
|
|
7891
|
+
let result = {
|
|
7892
|
+
/** 选项信息数据 */
|
|
7893
|
+
data: data,
|
|
7894
|
+
/** 选项元素 */
|
|
7895
|
+
$select: $select,
|
|
7896
|
+
};
|
|
7897
|
+
if (onlySelected) {
|
|
7898
|
+
// 仅选中
|
|
7899
|
+
let isSelected = this.isSelectItemSelected($select);
|
|
7900
|
+
if (isSelected) {
|
|
7901
|
+
return result;
|
|
7902
|
+
}
|
|
7903
|
+
return;
|
|
7836
7904
|
}
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
*/
|
|
7840
|
-
function getAllSelectedInfo() {
|
|
7841
|
-
return Array.from($selectContainer.querySelectorAll(".select-item"))
|
|
7842
|
-
.map(($ele) => {
|
|
7843
|
-
if (isSelected($ele)) {
|
|
7844
|
-
return getSelectedInfo($ele);
|
|
7845
|
-
}
|
|
7846
|
-
})
|
|
7847
|
-
.filter((item) => {
|
|
7848
|
-
return item != null;
|
|
7849
|
-
});
|
|
7905
|
+
else {
|
|
7906
|
+
return result;
|
|
7850
7907
|
}
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7908
|
+
})
|
|
7909
|
+
.filter((item) => {
|
|
7910
|
+
return item != null;
|
|
7911
|
+
});
|
|
7912
|
+
},
|
|
7913
|
+
/**
|
|
7914
|
+
* 创建一个选择项元素
|
|
7915
|
+
* @param data 选择项的数据
|
|
7916
|
+
*/
|
|
7917
|
+
createSelectItemElement(data) {
|
|
7918
|
+
let $select = popsDOMUtils.createElement("li", {
|
|
7919
|
+
className: "select-item",
|
|
7920
|
+
innerHTML: /*html*/ `
|
|
7921
|
+
<span class="select-item-text"></span>
|
|
7922
|
+
`,
|
|
7923
|
+
});
|
|
7924
|
+
this.setSelectItemText(data, $select);
|
|
7925
|
+
Reflect.set($select, "data-info", data);
|
|
7926
|
+
return $select;
|
|
7927
|
+
},
|
|
7928
|
+
/**
|
|
7929
|
+
* 设置选择项的文字
|
|
7930
|
+
* @param data 选择项的数据
|
|
7931
|
+
* @param $select 选择项元素
|
|
7932
|
+
*/
|
|
7933
|
+
setSelectItemText(data, $select) {
|
|
7934
|
+
let text = typeof data.text === "function"
|
|
7935
|
+
? data.text(data.value, this.$data.selectInfo)
|
|
7936
|
+
: data.text;
|
|
7937
|
+
let $selectSpan = $select.querySelector(".select-item-text");
|
|
7938
|
+
if (data.isHTML) {
|
|
7939
|
+
PopsSafeUtils.setSafeHTML($selectSpan, text);
|
|
7940
|
+
}
|
|
7941
|
+
else {
|
|
7942
|
+
$selectSpan.innerText = text;
|
|
7943
|
+
}
|
|
7944
|
+
},
|
|
7945
|
+
/**
|
|
7946
|
+
* 设置选择项的禁用状态
|
|
7947
|
+
* @param $select 选择项元素
|
|
7948
|
+
*/
|
|
7949
|
+
setSelectItemDisabled($select) {
|
|
7950
|
+
$select.setAttribute("aria-disabled", "true");
|
|
7951
|
+
$select.setAttribute("disabled", "true");
|
|
7952
|
+
},
|
|
7953
|
+
/**
|
|
7954
|
+
* 移除选择项的禁用状态
|
|
7955
|
+
* @param $select 选择项元素
|
|
7956
|
+
*/
|
|
7957
|
+
removeSelectItemDisabled($select) {
|
|
7958
|
+
$select.removeAttribute("aria-disabled");
|
|
7959
|
+
$select.removeAttribute("disabled");
|
|
7960
|
+
},
|
|
7961
|
+
/**
|
|
7962
|
+
* 判断选择项是否禁用
|
|
7963
|
+
* @param $select 选择项元素
|
|
7964
|
+
*/
|
|
7965
|
+
isSelectItemDisabled($select) {
|
|
7966
|
+
return $select.hasAttribute("disabled") || $select.ariaDisabled;
|
|
7967
|
+
},
|
|
7968
|
+
/**
|
|
7969
|
+
* 设置选择项的点击事件
|
|
7970
|
+
* @param dataList 选中的信息列表
|
|
7971
|
+
* @param $select 选择项元素
|
|
7972
|
+
*/
|
|
7973
|
+
setSelectElementClickEvent(dataList, $select) {
|
|
7974
|
+
popsDOMUtils.on($select, "click", (event) => {
|
|
7975
|
+
popsDOMUtils.preventEvent(event);
|
|
7976
|
+
if (this.isSelectItemDisabled($select)) {
|
|
7977
|
+
return;
|
|
7861
7978
|
}
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7979
|
+
if (typeof formConfig.clickCallBack === "function") {
|
|
7980
|
+
let allSelectedInfo = this.getAllSelectItemInfo().map((it) => it.data);
|
|
7981
|
+
let clickResult = formConfig.clickCallBack(event, allSelectedInfo);
|
|
7982
|
+
if (typeof clickResult === "boolean" && !clickResult) {
|
|
7983
|
+
return;
|
|
7984
|
+
}
|
|
7867
7985
|
}
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
$el.removeAttribute("aria-disabled");
|
|
7873
|
-
$el.removeAttribute("disabled");
|
|
7986
|
+
// 修改选中状态
|
|
7987
|
+
if (this.isSelectItemSelected($select)) {
|
|
7988
|
+
this.removeSelectItemSelected($select);
|
|
7989
|
+
this.removeSelectedItemInfo(dataList, $select);
|
|
7874
7990
|
}
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
function setSelectElementClickEvent($ele) {
|
|
7879
|
-
popsDOMUtils.on($ele, "click", (event) => {
|
|
7880
|
-
popsDOMUtils.preventEvent(event);
|
|
7881
|
-
if ($ele.hasAttribute("disabled") || $ele.ariaDisabled) {
|
|
7882
|
-
return;
|
|
7883
|
-
}
|
|
7884
|
-
if (typeof formConfig.clickCallBack === "function") {
|
|
7885
|
-
let clickResult = formConfig.clickCallBack(event, getAllSelectedInfo());
|
|
7886
|
-
if (typeof clickResult === "boolean" && !clickResult) {
|
|
7887
|
-
return;
|
|
7888
|
-
}
|
|
7889
|
-
}
|
|
7890
|
-
// 修改选中状态
|
|
7891
|
-
if (isSelected($ele)) {
|
|
7892
|
-
removeItemSelected($ele);
|
|
7893
|
-
removeSelectedInfo($ele);
|
|
7894
|
-
}
|
|
7895
|
-
else {
|
|
7896
|
-
setItemSelected($ele);
|
|
7897
|
-
addSelectedInfo($ele);
|
|
7898
|
-
}
|
|
7899
|
-
});
|
|
7991
|
+
else {
|
|
7992
|
+
this.setSelectItemSelected($select);
|
|
7993
|
+
this.addSelectedItemInfo(dataList, $select);
|
|
7900
7994
|
}
|
|
7995
|
+
});
|
|
7996
|
+
},
|
|
7997
|
+
/**
|
|
7998
|
+
* 设置下拉列表的点击事件
|
|
7999
|
+
*/
|
|
8000
|
+
setSelectContainerClickEvent() {
|
|
8001
|
+
const that = this;
|
|
8002
|
+
popsDOMUtils.on(this.$el.$container, "click", (event) => {
|
|
8003
|
+
/** 弹窗的选中的值 */
|
|
8004
|
+
let selectedInfo = that.$data.selectInfo;
|
|
7901
8005
|
let { style, ...userConfirmDetails } = formConfig.selectConfirmDialogDetails || {};
|
|
7902
8006
|
let confirmDetails = popsUtils.assign({
|
|
7903
8007
|
title: {
|
|
@@ -7919,6 +8023,7 @@ const PanelHandleContentDetails = () => {
|
|
|
7919
8023
|
callback(details, event) {
|
|
7920
8024
|
that.$data.selectInfo = [...selectedInfo];
|
|
7921
8025
|
that.updateSelectTagItem();
|
|
8026
|
+
that.$el.$selectContainer = null;
|
|
7922
8027
|
details.close();
|
|
7923
8028
|
},
|
|
7924
8029
|
},
|
|
@@ -7929,6 +8034,7 @@ const PanelHandleContentDetails = () => {
|
|
|
7929
8034
|
originalRun();
|
|
7930
8035
|
that.$data.selectInfo = [...selectedInfo];
|
|
7931
8036
|
that.updateSelectTagItem();
|
|
8037
|
+
that.$el.$selectContainer = null;
|
|
7932
8038
|
},
|
|
7933
8039
|
clickEvent: {
|
|
7934
8040
|
toClose: true,
|
|
@@ -7994,30 +8100,23 @@ const PanelHandleContentDetails = () => {
|
|
|
7994
8100
|
}, userConfirmDetails);
|
|
7995
8101
|
let $dialog = pops.alert(confirmDetails);
|
|
7996
8102
|
let $selectContainer = $dialog.$shadowRoot.querySelector(".select-container");
|
|
8103
|
+
this.$el.$selectContainer = $selectContainer;
|
|
7997
8104
|
// 配置选项元素
|
|
7998
8105
|
formConfig.data.forEach((item) => {
|
|
7999
|
-
let $select = createSelectItemElement(item);
|
|
8106
|
+
let $select = this.createSelectItemElement(item);
|
|
8000
8107
|
// 添加到confirm中
|
|
8001
8108
|
$selectContainer.appendChild($select);
|
|
8002
8109
|
// 设置每一项的点击事件
|
|
8003
|
-
setSelectElementClickEvent($select);
|
|
8004
|
-
// 设置禁用状态
|
|
8005
|
-
if (typeof item.disable === "function" &&
|
|
8006
|
-
item.disable(item.value)) {
|
|
8007
|
-
setSelectItemDisabled($select);
|
|
8008
|
-
// 后续不设置元素的选中状态
|
|
8009
|
-
return;
|
|
8010
|
-
}
|
|
8011
|
-
// 移除禁用状态
|
|
8012
|
-
removeSelectItemDisabled($select);
|
|
8013
|
-
let findValue = selectedInfo.find((value) => value.value === item.value);
|
|
8014
|
-
if (findValue) {
|
|
8015
|
-
setItemSelected($select);
|
|
8016
|
-
}
|
|
8110
|
+
this.setSelectElementClickEvent(selectedInfo, $select);
|
|
8017
8111
|
});
|
|
8112
|
+
// 动态更新禁用状态
|
|
8113
|
+
this.updateSelectItem();
|
|
8018
8114
|
});
|
|
8019
8115
|
},
|
|
8020
|
-
/**
|
|
8116
|
+
/**
|
|
8117
|
+
* 设置关闭图标的点击事件
|
|
8118
|
+
* @param data 选中的信息
|
|
8119
|
+
*/
|
|
8021
8120
|
setSelectedItemCloseIconClickEvent(data) {
|
|
8022
8121
|
popsDOMUtils.on(data.$closeIcon, "click", (event) => {
|
|
8023
8122
|
popsDOMUtils.preventEvent(event);
|
|
@@ -8026,13 +8125,15 @@ const PanelHandleContentDetails = () => {
|
|
|
8026
8125
|
$tag: data.$tag,
|
|
8027
8126
|
$closeIcon: data.$closeIcon,
|
|
8028
8127
|
value: data.value,
|
|
8029
|
-
text: data.text
|
|
8128
|
+
text: typeof data.text === "function"
|
|
8129
|
+
? data.text.bind(data)
|
|
8130
|
+
: data.text,
|
|
8030
8131
|
});
|
|
8031
8132
|
if (typeof result === "boolean" && !result) {
|
|
8032
8133
|
return;
|
|
8033
8134
|
}
|
|
8034
8135
|
}
|
|
8035
|
-
this.
|
|
8136
|
+
this.removeSelectedTagItem(data.$tag);
|
|
8036
8137
|
this.removeSelectedInfo({
|
|
8037
8138
|
value: data.value,
|
|
8038
8139
|
text: data.text,
|
|
@@ -8052,13 +8153,21 @@ const PanelHandleContentDetails = () => {
|
|
|
8052
8153
|
this.removeSectionIsNear();
|
|
8053
8154
|
}
|
|
8054
8155
|
},
|
|
8055
|
-
/**
|
|
8056
|
-
|
|
8057
|
-
|
|
8156
|
+
/**
|
|
8157
|
+
* 移除选中项元素
|
|
8158
|
+
*/
|
|
8159
|
+
removeSelectedTagItem($tag) {
|
|
8160
|
+
$tag.remove();
|
|
8058
8161
|
this.checkTagEmpty();
|
|
8059
8162
|
},
|
|
8060
|
-
/**
|
|
8061
|
-
|
|
8163
|
+
/**
|
|
8164
|
+
* 从保存的已选中的信息列表中移除目标信息
|
|
8165
|
+
* @param data 需要移除的信息
|
|
8166
|
+
* @param [triggerValueChangeCallBack=true] 是否触发值改变的回调
|
|
8167
|
+
* + true (默认)触发值改变的回调
|
|
8168
|
+
* + false 不触发值改变的回调
|
|
8169
|
+
*/
|
|
8170
|
+
removeSelectedInfo(data, triggerValueChangeCallBack = true) {
|
|
8062
8171
|
for (let index = 0; index < this.$data.selectInfo.length; index++) {
|
|
8063
8172
|
const selectInfo = this.$data.selectInfo[index];
|
|
8064
8173
|
if (selectInfo.value === data.value) {
|
|
@@ -8066,7 +8175,7 @@ const PanelHandleContentDetails = () => {
|
|
|
8066
8175
|
break;
|
|
8067
8176
|
}
|
|
8068
8177
|
}
|
|
8069
|
-
this.selectValueChangeCallBack();
|
|
8178
|
+
triggerValueChangeCallBack && this.selectValueChangeCallBack();
|
|
8070
8179
|
},
|
|
8071
8180
|
/** 显示输入框 */
|
|
8072
8181
|
showInputWrapper() {
|
|
@@ -9915,6 +10024,7 @@ const PopsTooltipConfig = () => {
|
|
|
9915
10024
|
useShadowRoot: true,
|
|
9916
10025
|
target: null,
|
|
9917
10026
|
content: "默认文字",
|
|
10027
|
+
isDiffContent: false,
|
|
9918
10028
|
position: "top",
|
|
9919
10029
|
className: "",
|
|
9920
10030
|
isFixed: false,
|
|
@@ -10040,6 +10150,19 @@ class ToolTip {
|
|
|
10040
10150
|
if (text == null) {
|
|
10041
10151
|
text = this.getContent();
|
|
10042
10152
|
}
|
|
10153
|
+
if (this.$data.config.isDiffContent) {
|
|
10154
|
+
let contentPropKey = "data-content";
|
|
10155
|
+
// @ts-ignore
|
|
10156
|
+
let originContentText = this.$el.$content[contentPropKey];
|
|
10157
|
+
if (typeof originContentText === "string") {
|
|
10158
|
+
if (originContentText === text) {
|
|
10159
|
+
// 内容未改变,不修改避免渲染
|
|
10160
|
+
return;
|
|
10161
|
+
}
|
|
10162
|
+
}
|
|
10163
|
+
// @ts-ignore
|
|
10164
|
+
this.$el.$content[contentPropKey] = text;
|
|
10165
|
+
}
|
|
10043
10166
|
PopsSafeUtils.setSafeHTML(this.$el.$content, text);
|
|
10044
10167
|
}
|
|
10045
10168
|
/**
|