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