@whitesev/pops 2.0.9 → 2.0.11

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.
Files changed (57) hide show
  1. package/dist/index.amd.js +1904 -1733
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +1904 -1733
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +1904 -1733
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +1904 -1733
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +1904 -1733
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +1904 -1733
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Pops.d.ts +50 -30
  14. package/dist/types/src/PopsAnimation.d.ts +14 -0
  15. package/dist/types/src/PopsCSS.d.ts +34 -0
  16. package/dist/types/src/PopsIcon.d.ts +25 -0
  17. package/dist/types/src/PopsLayer.d.ts +3 -0
  18. package/dist/types/src/components/panel/buttonType.d.ts +2 -2
  19. package/dist/types/src/components/panel/selectMultipleType.d.ts +12 -15
  20. package/dist/types/src/components/rightClickMenu/index.d.ts +1 -2
  21. package/dist/types/src/components/rightClickMenu/indexType.d.ts +2 -2
  22. package/dist/types/src/types/button.d.ts +3 -3
  23. package/dist/types/src/types/icon.d.ts +1 -1
  24. package/dist/types/src/utils/PopsDOMUtils.d.ts +12 -0
  25. package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -6
  26. package/dist/types/src/utils/PopsUtils.d.ts +5 -6
  27. package/package.json +3 -2
  28. package/src/Pops.ts +12 -152
  29. package/src/PopsAnimation.ts +32 -0
  30. package/src/PopsCSS.ts +51 -0
  31. package/src/PopsIcon.ts +93 -0
  32. package/src/PopsLayer.ts +17 -0
  33. package/src/components/alert/index.ts +8 -8
  34. package/src/components/confirm/index.ts +8 -8
  35. package/src/components/drawer/index.ts +8 -8
  36. package/src/components/folder/index.ts +15 -15
  37. package/src/components/iframe/index.ts +9 -12
  38. package/src/components/loading/index.ts +5 -5
  39. package/src/components/panel/PanelHandleContentDetails.ts +338 -220
  40. package/src/components/panel/buttonType.ts +2 -2
  41. package/src/components/panel/config.ts +41 -11
  42. package/src/components/panel/index.css +33 -0
  43. package/src/components/panel/index.ts +9 -9
  44. package/src/components/panel/selectMultipleType.ts +18 -15
  45. package/src/components/prompt/index.ts +8 -8
  46. package/src/components/rightClickMenu/config.ts +7 -7
  47. package/src/components/rightClickMenu/index.ts +9 -10
  48. package/src/components/rightClickMenu/indexType.ts +2 -2
  49. package/src/components/searchSuggestion/index.ts +5 -5
  50. package/src/components/tooltip/index.ts +5 -5
  51. package/src/handler/PopsElementHandler.ts +17 -17
  52. package/src/handler/PopsHandler.ts +22 -19
  53. package/src/types/button.d.ts +3 -3
  54. package/src/types/icon.d.ts +1 -1
  55. package/src/utils/PopsDOMUtils.ts +34 -1
  56. package/src/utils/PopsInstanceUtils.ts +13 -31
  57. package/src/utils/PopsUtils.ts +7 -16
@@ -1,11 +1,12 @@
1
- import { pops } from "../../Pops";
1
+ import { PopsIcon } from "../../PopsIcon";
2
2
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
3
3
  import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
4
4
  import { PopsMathFloatUtils } from "../../utils/PopsMathUtils";
5
5
  import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
6
6
  import { popsUtils } from "../../utils/PopsUtils";
7
+ import { PopsAlert } from "../alert";
7
8
  import type { PopsAlertDetails } from "../alert/indexType";
8
- import type { PopsTooltip } from "../tooltip";
9
+ import { PopsTooltip } from "../tooltip";
9
10
  import type { PopsPanelButtonDetails } from "./buttonType";
10
11
  import type { PopsPanelRightAsideContainerOptions } from "./commonType";
11
12
  import type { PopsPanelDeepMenuDetails } from "./deepMenuType";
@@ -401,7 +402,7 @@ export const PanelHandleContentDetails = () => {
401
402
  return value as string;
402
403
  }
403
404
  };
404
- let tooltip = pops.tooltip({
405
+ let tooltip = PopsTooltip.init({
405
406
  target: rangeInputElement.parentElement!,
406
407
  content: () => {
407
408
  return getToolTipContent(rangeInputElement.value);
@@ -576,11 +577,11 @@ export const PanelHandleContentDetails = () => {
576
577
  let isSuccess = false;
577
578
  let oldTotalWidth = this.$data.totalWidth;
578
579
  let timer: number | undefined = void 0;
579
- let interval = popsUtils.setInterval(() => {
580
+ let interval = setInterval(() => {
580
581
  if (isSuccess) {
581
582
  this.$interval.isCheck = false;
582
- popsUtils.clearTimeout(timer);
583
- popsUtils.clearInterval(interval);
583
+ clearTimeout(timer);
584
+ clearInterval(interval);
584
585
  } else {
585
586
  this.initTotalWidth();
586
587
  if (this.$data.totalWidth !== 0) {
@@ -598,8 +599,8 @@ export const PanelHandleContentDetails = () => {
598
599
  }
599
600
  }, checkStepTime);
600
601
  /* 最长检测时间是10s */
601
- timer = popsUtils.setTimeout(() => {
602
- popsUtils.clearInterval(interval);
602
+ timer = setTimeout(() => {
603
+ clearInterval(interval);
603
604
  }, maxTime);
604
605
  },
605
606
  /**
@@ -981,16 +982,16 @@ export const PanelHandleContentDetails = () => {
981
982
  return;
982
983
  }
983
984
  this.$data.isCheckingStopDragMove = true;
984
- let interval = popsUtils.setInterval(() => {
985
+ let interval = setInterval(() => {
985
986
  if (!this.$data.isMove) {
986
987
  this.$data.isCheckingStopDragMove = false;
987
988
  this.closeToolTip();
988
- popsUtils.clearInterval(interval);
989
+ clearInterval(interval);
989
990
  }
990
991
  }, 200);
991
- popsUtils.setTimeout(() => {
992
+ setTimeout(() => {
992
993
  this.$data.isCheckingStopDragMove = false;
993
- popsUtils.clearInterval(interval);
994
+ clearInterval(interval);
994
995
  }, 2000);
995
996
  },
996
997
  /**
@@ -1008,7 +1009,7 @@ export const PanelHandleContentDetails = () => {
1008
1009
  }
1009
1010
  }
1010
1011
 
1011
- let tooltip = pops.tooltip({
1012
+ let tooltip = PopsTooltip.init({
1012
1013
  target: this.$ele.button,
1013
1014
  content: getToolTipContent,
1014
1015
  zIndex: () => {
@@ -1105,12 +1106,12 @@ export const PanelHandleContentDetails = () => {
1105
1106
  this.setInputValue(this.$data.value);
1106
1107
  /* 如果是密码框,放进图标 */
1107
1108
  if (formConfig.isPassword) {
1108
- this.setCircleIcon(pops.config.iconSVG.view);
1109
+ this.setCircleIcon(PopsIcon.getIcon("view")!);
1109
1110
  this.setCircleIconClickEvent();
1110
1111
  } else {
1111
1112
  /* 先判断预设值是否为空,不为空添加清空图标按钮 */
1112
1113
  if (this.$ele.input.value != "") {
1113
- this.setCircleIcon(pops.config.iconSVG.circleClose);
1114
+ this.setCircleIcon(PopsIcon.getIcon("circleClose")!);
1114
1115
  this.setCircleIconClickEvent();
1115
1116
  }
1116
1117
  }
@@ -1191,9 +1192,9 @@ export const PanelHandleContentDetails = () => {
1191
1192
  },
1192
1193
  /**
1193
1194
  * 添加清空图标按钮
1194
- * @param [svgHTML=pops.config.iconSVG.circleClose] svg图标,默认为清空的图标
1195
+ * @param [svgHTML=PopsIcon.getIcon("circleClose")] svg图标,默认为清空的图标
1195
1196
  */
1196
- setCircleIcon(svgHTML = pops.config.iconSVG.circleClose) {
1197
+ setCircleIcon(svgHTML = PopsIcon.getIcon("circleClose")!) {
1197
1198
  PopsSafeUtils.setSafeHTML(this.$ele.icon, svgHTML);
1198
1199
  },
1199
1200
  /**
@@ -1213,13 +1214,13 @@ export const PanelHandleContentDetails = () => {
1213
1214
  this.$data.isView = false;
1214
1215
  /* 显示输入框内容,且更换图标为隐藏图标 */
1215
1216
  this.setInputType("text");
1216
- this.setCircleIcon(pops.config.iconSVG.hide);
1217
+ this.setCircleIcon(PopsIcon.getIcon("hide")!);
1217
1218
  } else {
1218
1219
  /* 当前不可见 => 点击改变为显示 */
1219
1220
  this.$data.isView = true;
1220
1221
  /* 隐藏输入框内容,且更换图标为显示图标 */
1221
1222
  this.setInputType("password");
1222
- this.setCircleIcon(pops.config.iconSVG.view);
1223
+ this.setCircleIcon(PopsIcon.getIcon("view")!);
1223
1224
  }
1224
1225
  } else {
1225
1226
  /* 普通输入框 */
@@ -1249,7 +1250,7 @@ export const PanelHandleContentDetails = () => {
1249
1250
  this.$ele.icon.innerHTML === ""
1250
1251
  ) {
1251
1252
  /* 不为空,显示清空图标 */
1252
- this.setCircleIcon(pops.config.iconSVG.circleClose);
1253
+ this.setCircleIcon(PopsIcon.getIcon("circleClose")!);
1253
1254
  this.setCircleIconClickEvent();
1254
1255
  } else if (this.$ele.input.value === "") {
1255
1256
  this.removeCircleIcon();
@@ -1664,6 +1665,8 @@ export const PanelHandleContentDetails = () => {
1664
1665
  $suffix: void 0 as any as HTMLElement,
1665
1666
  /** 下拉箭头图标 */
1666
1667
  $suffixIcon: void 0 as any as HTMLElement,
1668
+ /** 下拉列表弹窗的下拉列表容器 */
1669
+ $selectContainer: void 0 as any as HTMLElement | null,
1667
1670
  },
1668
1671
  $data: {
1669
1672
  /** 默认值 */
@@ -1675,7 +1678,7 @@ export const PanelHandleContentDetails = () => {
1675
1678
  this.initDefault();
1676
1679
  this.inintEl();
1677
1680
  this.initPlaceHolder();
1678
- this.updateTagElement();
1681
+ this.initTagElement();
1679
1682
  this.setSelectContainerClickEvent();
1680
1683
  },
1681
1684
  /** 初始化默认值 */
@@ -1687,7 +1690,7 @@ export const PanelHandleContentDetails = () => {
1687
1690
  text: dataItem.text,
1688
1691
  value: dataItem.value,
1689
1692
  isHTML: Boolean(dataItem.isHTML),
1690
- disable: dataItem.disable,
1693
+ disable: dataItem.disable?.bind(dataItem),
1691
1694
  });
1692
1695
  }
1693
1696
  });
@@ -1735,20 +1738,17 @@ export const PanelHandleContentDetails = () => {
1735
1738
  });
1736
1739
  this.$el.$selectedPlaceHolderWrapper.appendChild($placeholder);
1737
1740
  },
1738
- /** 初始化tag */
1739
- updateTagElement() {
1741
+ /** 初始化tag元素 */
1742
+ initTagElement() {
1740
1743
  // 遍历数据,寻找对应的值
1741
1744
  formConfig.data.forEach((dataItem) => {
1742
1745
  let findValue = this.$data.selectInfo.find(
1743
1746
  (item) => item.value === dataItem.value
1744
1747
  );
1745
1748
  if (findValue) {
1746
- // 选中的值和获取的所有的值相同
1747
- let selectedInfo = this.createSelectedItem({
1748
- text: dataItem.text,
1749
- isHTML: dataItem.isHTML,
1750
- });
1751
- this.addSelectedItem(selectedInfo.$tag);
1749
+ // 存在对应的值
1750
+ let selectedInfo = this.createSelectedTagItem(dataItem);
1751
+ this.addSelectedTagItem(selectedInfo.$tag);
1752
1752
  this.setSelectedItemCloseIconClickEvent({
1753
1753
  $tag: selectedInfo.$tag,
1754
1754
  $closeIcon: selectedInfo.$closeIcon,
@@ -1763,11 +1763,7 @@ export const PanelHandleContentDetails = () => {
1763
1763
  * 生成一个tag项
1764
1764
  * @param data 配置
1765
1765
  */
1766
- createSelectedItem(data: {
1767
- /** tag的文本 */
1768
- text: string;
1769
- isHTML?: boolean;
1770
- }) {
1766
+ createSelectedTagItem(data: PopsPanelSelectMultipleDataOption<any>) {
1771
1767
  const $selectedItem = popsDOMUtils.createElement("div", {
1772
1768
  className: "el-select__selected-item el-select__choose_tag",
1773
1769
  innerHTML: /*html*/ `
@@ -1792,10 +1788,14 @@ export const PanelHandleContentDetails = () => {
1792
1788
  const $closeIcon = $selectedItem.querySelector<HTMLElement>(
1793
1789
  ".el-icon.el-tag__close"
1794
1790
  )!;
1791
+ let text =
1792
+ typeof data.text === "function"
1793
+ ? data.text(data, this.$data.selectInfo)
1794
+ : data.text;
1795
1795
  if (data.isHTML) {
1796
- PopsSafeUtils.setSafeHTML($tagText, data.text);
1796
+ PopsSafeUtils.setSafeHTML($tagText, text);
1797
1797
  } else {
1798
- $tagText.innerText = data.text;
1798
+ $tagText.innerText = text;
1799
1799
  }
1800
1800
 
1801
1801
  return {
@@ -1805,9 +1805,10 @@ export const PanelHandleContentDetails = () => {
1805
1805
  };
1806
1806
  },
1807
1807
  /**
1808
- * 添加选中项元素
1808
+ * 添加选中项的tag元素
1809
+ * @param $tag 添加的元素
1809
1810
  */
1810
- addSelectedItem($ele: HTMLElement) {
1811
+ addSelectedTagItem($tag: HTMLElement) {
1811
1812
  // 往前添加
1812
1813
  // 去除前面的空白
1813
1814
  this.setSectionIsNear();
@@ -1815,10 +1816,10 @@ export const PanelHandleContentDetails = () => {
1815
1816
  let $prev = this.$el.$selectedInputWrapper.previousElementSibling;
1816
1817
  if ($prev) {
1817
1818
  // 存在前一个元素,添加到前面的元素的后面
1818
- popsDOMUtils.after($prev, $ele);
1819
+ popsDOMUtils.after($prev, $tag);
1819
1820
  } else {
1820
1821
  // 不存在前一个元素,添加到最前面
1821
- popsDOMUtils.before(this.$el.$selectedInputWrapper, $ele);
1822
+ popsDOMUtils.before(this.$el.$selectedInputWrapper, $tag);
1822
1823
  }
1823
1824
  } else if (
1824
1825
  this.$el.$section.contains(this.$el.$selectedPlaceHolderWrapper)
@@ -1827,13 +1828,13 @@ export const PanelHandleContentDetails = () => {
1827
1828
  this.$el.$selectedPlaceHolderWrapper.previousElementSibling;
1828
1829
  if ($prev) {
1829
1830
  // 存在前一个元素,添加到前面的元素的后面
1830
- popsDOMUtils.after($prev, $ele);
1831
+ popsDOMUtils.after($prev, $tag);
1831
1832
  } else {
1832
1833
  // 不存在前一个元素,添加到最前面
1833
- popsDOMUtils.before(this.$el.$selectedPlaceHolderWrapper, $ele);
1834
+ popsDOMUtils.before(this.$el.$selectedPlaceHolderWrapper, $tag);
1834
1835
  }
1835
1836
  } else {
1836
- this.$el.$section.appendChild($ele);
1837
+ this.$el.$section.appendChild($tag);
1837
1838
  }
1838
1839
  // 隐藏元素
1839
1840
  this.hideInputWrapper();
@@ -1846,161 +1847,271 @@ export const PanelHandleContentDetails = () => {
1846
1847
  .forEach(($ele) => {
1847
1848
  $ele.remove();
1848
1849
  });
1849
- this.updateTagElement();
1850
+ this.initTagElement();
1850
1851
  },
1851
1852
  /**
1852
1853
  * 选中的值改变的回调
1853
- * @param currentSelectInfo 当前的选中信息
1854
+ * @param selectedDataList 当前的选中信息
1854
1855
  */
1855
1856
  selectValueChangeCallBack(
1856
- currentSelectInfo?: PopsPanelSelectMultipleDataOption<any>[]
1857
+ selectedDataList?: PopsPanelSelectMultipleDataOption<any>[]
1857
1858
  ) {
1859
+ // 动态更新禁用状态
1860
+ this.updateSelectItem();
1858
1861
  if (typeof formConfig.callback === "function") {
1859
- formConfig.callback(currentSelectInfo || this.$data.selectInfo);
1862
+ formConfig.callback(selectedDataList || this.$data.selectInfo);
1860
1863
  }
1861
1864
  },
1862
- /** 设置下拉列表的点击事件 */
1863
- setSelectContainerClickEvent() {
1864
- const that = this;
1865
- popsDOMUtils.on(this.$el.$container, "click", (event) => {
1866
- /** 弹窗的选中的值 */
1867
- let selectedInfo: PopsPanelSelectMultipleDataOption<any>[] = [];
1868
- selectedInfo = selectedInfo.concat(that.$data.selectInfo);
1869
- /**
1870
- * 设置项选中
1871
- * @param $ele
1872
- */
1873
- function setItemSelected($ele: HTMLElement) {
1874
- $ele.classList.add("select-item-is-selected");
1865
+ /**
1866
+ * 更新选项弹窗内的所有选项元素的状态
1867
+ *
1868
+ * + 更新禁用状态
1869
+ * + 更新选中状态
1870
+ */
1871
+ updateSelectItem() {
1872
+ this.getAllSelectItemInfo(false).forEach(($selectInfo) => {
1873
+ const { data, $select } = $selectInfo;
1874
+ // 更新文字
1875
+ this.setSelectItemText(data, $selectInfo.$select);
1876
+ // 更新禁用状态
1877
+ if (
1878
+ typeof data.disable === "function" &&
1879
+ data.disable(data.value, this.$data.selectInfo)
1880
+ ) {
1881
+ // 禁用
1882
+ this.setSelectItemDisabled($select);
1883
+ // 移除选中信息
1884
+ this.removeSelectedInfo(data, false);
1885
+ // 移除选中状态
1886
+ this.removeSelectItemSelected($select);
1887
+ } else {
1888
+ // 取消禁用
1889
+ this.removeSelectItemDisabled($select);
1875
1890
  }
1876
- /**
1877
- * 设置项取消选中
1878
- * @param $ele
1879
- */
1880
- function removeItemSelected($ele: HTMLElement) {
1881
- $ele.classList.remove("select-item-is-selected");
1891
+ // 更新选中状态
1892
+ let findValue = this.$data.selectInfo.find(
1893
+ (it) => it.value === data.value
1894
+ );
1895
+ if (findValue) {
1896
+ this.setSelectItemSelected($select);
1897
+ } else {
1898
+ this.removeSelectItemSelected($select);
1882
1899
  }
1883
- /**
1884
- * 添加选中信息
1885
- */
1886
- function addSelectedInfo($ele: HTMLElement) {
1887
- let info = getSelectedInfo($ele);
1888
- let findValue = selectedInfo.find(
1889
- (item) => item.value === info.value
1890
- );
1891
- if (!findValue) {
1892
- selectedInfo.push({
1893
- value: info.value,
1894
- text: info.text,
1895
- isHTML: Boolean(info.isHTML),
1896
- disable: info.disable,
1897
- });
1900
+ });
1901
+ },
1902
+ /**
1903
+ * 设置选项元素选中
1904
+ * @param $select 选项元素
1905
+ */
1906
+ setSelectItemSelected($select: HTMLElement) {
1907
+ if (this.isSelectItemSelected($select)) return;
1908
+ $select.classList.add("select-item-is-selected");
1909
+ },
1910
+ /**
1911
+ * 移除选项元素选中
1912
+ * @param $select 选项元素
1913
+ */
1914
+ removeSelectItemSelected($select: HTMLElement) {
1915
+ $select.classList.remove("select-item-is-selected");
1916
+ },
1917
+ /**
1918
+ * 判断选项元素是否选中
1919
+ * @param $select
1920
+ */
1921
+ isSelectItemSelected($select: HTMLElement): boolean {
1922
+ return $select.classList.contains("select-item-is-selected");
1923
+ },
1924
+ /**
1925
+ * 添加选中信息
1926
+ * @param dataList 选择项列表的数据
1927
+ * @param $select 选项元素
1928
+ */
1929
+ addSelectedItemInfo(
1930
+ dataList: PopsPanelSelectMultipleDataOption<any>[],
1931
+ $select: HTMLElement
1932
+ ) {
1933
+ let info = this.getSelectedItemInfo($select);
1934
+ let findValue = dataList.find((item) => item.value === info.value);
1935
+ if (!findValue) {
1936
+ dataList.push({
1937
+ value: info.value,
1938
+ text: info.text,
1939
+ isHTML: Boolean(info.isHTML),
1940
+ disable: info.disable?.bind(info),
1941
+ });
1942
+ }
1943
+ this.selectValueChangeCallBack(dataList);
1944
+ },
1945
+ /**
1946
+ * 获取选中的项的信息
1947
+ * @param $select 选项元素
1948
+ */
1949
+ getSelectedItemInfo($select: HTMLElement) {
1950
+ return Reflect.get(
1951
+ $select,
1952
+ "data-info"
1953
+ ) as PopsPanelSelectMultipleDataOption<any>;
1954
+ },
1955
+ /**
1956
+ * 移除选中信息
1957
+ * @param dataList 选择项的数据
1958
+ * @param $select 选项元素
1959
+ */
1960
+ removeSelectedItemInfo(
1961
+ dataList: PopsPanelSelectMultipleDataOption<any>[],
1962
+ $select: HTMLElement
1963
+ ) {
1964
+ let info = this.getSelectedItemInfo($select);
1965
+ let findIndex = dataList.findIndex(
1966
+ (item) => item.value === info.value
1967
+ );
1968
+ if (findIndex !== -1) {
1969
+ dataList.splice(findIndex, 1);
1970
+ }
1971
+ this.selectValueChangeCallBack(dataList);
1972
+ },
1973
+ /**
1974
+ * 获取所有选项的信息
1975
+ * @param [onlySelected=true] 是否仅获取选中的项的信息
1976
+ * + true (默认)仅获取选中项的信息
1977
+ * + false 获取所有选择项的信息
1978
+ */
1979
+ getAllSelectItemInfo(onlySelected: boolean = true) {
1980
+ return Array.from(
1981
+ this.$el.$selectContainer?.querySelectorAll<HTMLElement>(
1982
+ ".select-item"
1983
+ ) ?? []
1984
+ )
1985
+ .map(($select) => {
1986
+ let data = this.getSelectedItemInfo($select);
1987
+ let result = {
1988
+ /** 选项信息数据 */
1989
+ data: data,
1990
+ /** 选项元素 */
1991
+ $select: $select,
1992
+ };
1993
+ if (onlySelected) {
1994
+ // 仅选中
1995
+ let isSelected = this.isSelectItemSelected($select);
1996
+ if (isSelected) {
1997
+ return result;
1998
+ }
1999
+ return;
2000
+ } else {
2001
+ return result;
1898
2002
  }
1899
- that.selectValueChangeCallBack(selectedInfo);
1900
- }
1901
- /**
1902
- * 移除选中信息
1903
- */
1904
- function removeSelectedInfo($ele: HTMLElement) {
1905
- let info = getSelectedInfo($ele);
1906
- let findIndex = selectedInfo.findIndex(
1907
- (item) => item.value === info.value
1908
- );
1909
- if (findIndex !== -1) {
1910
- selectedInfo.splice(findIndex, 1);
2003
+ })
2004
+ .filter((item) => {
2005
+ return item != null;
2006
+ });
2007
+ },
2008
+ /**
2009
+ * 创建一个选择项元素
2010
+ * @param data 选择项的数据
2011
+ */
2012
+ createSelectItemElement(data: PopsPanelSelectMultipleDataOption<any>) {
2013
+ let $select = popsDOMUtils.createElement("li", {
2014
+ className: "select-item",
2015
+ innerHTML: /*html*/ `
2016
+ <span class="select-item-text"></span>
2017
+ `,
2018
+ });
2019
+ this.setSelectItemText(data, $select);
2020
+ Reflect.set($select, "data-info", data);
2021
+ return $select;
2022
+ },
2023
+ /**
2024
+ * 设置选择项的文字
2025
+ * @param data 选择项的数据
2026
+ * @param $select 选择项元素
2027
+ */
2028
+ setSelectItemText(
2029
+ data: PopsPanelSelectMultipleDataOption<any>,
2030
+ $select: HTMLElement
2031
+ ) {
2032
+ let text =
2033
+ typeof data.text === "function"
2034
+ ? data.text(data.value, this.$data.selectInfo)
2035
+ : data.text;
2036
+ let $selectSpan =
2037
+ $select.querySelector<HTMLElement>(".select-item-text")!;
2038
+ if (data.isHTML) {
2039
+ PopsSafeUtils.setSafeHTML($selectSpan, text);
2040
+ } else {
2041
+ $selectSpan.innerText = text;
2042
+ }
2043
+ },
2044
+ /**
2045
+ * 设置选择项的禁用状态
2046
+ * @param $select 选择项元素
2047
+ */
2048
+ setSelectItemDisabled($select: HTMLElement) {
2049
+ $select.setAttribute("aria-disabled", "true");
2050
+ $select.setAttribute("disabled", "true");
2051
+ },
2052
+ /**
2053
+ * 移除选择项的禁用状态
2054
+ * @param $select 选择项元素
2055
+ */
2056
+ removeSelectItemDisabled($select: HTMLElement) {
2057
+ $select.removeAttribute("aria-disabled");
2058
+ $select.removeAttribute("disabled");
2059
+ },
2060
+ /**
2061
+ * 判断选择项是否禁用
2062
+ * @param $select 选择项元素
2063
+ */
2064
+ isSelectItemDisabled($select: HTMLElement) {
2065
+ return $select.hasAttribute("disabled") || $select.ariaDisabled;
2066
+ },
2067
+ /**
2068
+ * 设置选择项的点击事件
2069
+ * @param dataList 选中的信息列表
2070
+ * @param $select 选择项元素
2071
+ */
2072
+ setSelectElementClickEvent(
2073
+ dataList: PopsPanelSelectMultipleDataOption<any>[],
2074
+ $select: HTMLElement
2075
+ ) {
2076
+ popsDOMUtils.on<PointerEvent | MouseEvent>(
2077
+ $select,
2078
+ "click",
2079
+ (event) => {
2080
+ popsDOMUtils.preventEvent(event);
2081
+ if (this.isSelectItemDisabled($select)) {
2082
+ return;
1911
2083
  }
1912
- that.selectValueChangeCallBack(selectedInfo);
1913
- }
1914
- /**
1915
- * 判断该项是否选中
1916
- * @param $ele
1917
- */
1918
- function isSelected($ele: HTMLElement): boolean {
1919
- return $ele.classList.contains("select-item-is-selected");
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
- }
2084
+ if (typeof formConfig.clickCallBack === "function") {
2085
+ let allSelectedInfo = this.getAllSelectItemInfo().map(
2086
+ (it) => it.data
2087
+ );
2088
+ let clickResult = formConfig.clickCallBack(
2089
+ event,
2090
+ allSelectedInfo
2091
+ );
2092
+ if (typeof clickResult === "boolean" && !clickResult) {
2093
+ return;
2001
2094
  }
2002
- );
2095
+ }
2096
+ // 修改选中状态
2097
+ if (this.isSelectItemSelected($select)) {
2098
+ this.removeSelectItemSelected($select);
2099
+ this.removeSelectedItemInfo(dataList, $select);
2100
+ } else {
2101
+ this.setSelectItemSelected($select);
2102
+ this.addSelectedItemInfo(dataList, $select);
2103
+ }
2003
2104
  }
2105
+ );
2106
+ },
2107
+ /**
2108
+ * 设置下拉列表的点击事件
2109
+ */
2110
+ setSelectContainerClickEvent() {
2111
+ const that = this;
2112
+ popsDOMUtils.on(this.$el.$container, "click", (event) => {
2113
+ /** 弹窗的选中的值 */
2114
+ let selectedInfo = that.$data.selectInfo;
2004
2115
  let { style, ...userConfirmDetails } =
2005
2116
  formConfig.selectConfirmDialogDetails || {};
2006
2117
  let confirmDetails = popsUtils.assign(
@@ -2024,6 +2135,7 @@ export const PanelHandleContentDetails = () => {
2024
2135
  callback(details, event) {
2025
2136
  that.$data.selectInfo = [...selectedInfo];
2026
2137
  that.updateSelectTagItem();
2138
+ that.$el.$selectContainer = null;
2027
2139
  details.close();
2028
2140
  },
2029
2141
  },
@@ -2034,6 +2146,7 @@ export const PanelHandleContentDetails = () => {
2034
2146
  originalRun();
2035
2147
  that.$data.selectInfo = [...selectedInfo];
2036
2148
  that.updateSelectTagItem();
2149
+ that.$el.$selectContainer = null;
2037
2150
  },
2038
2151
  clickEvent: {
2039
2152
  toClose: true,
@@ -2099,48 +2212,37 @@ export const PanelHandleContentDetails = () => {
2099
2212
  } as PopsAlertDetails,
2100
2213
  userConfirmDetails
2101
2214
  );
2102
- let $dialog = pops.alert(confirmDetails);
2215
+ let $dialog = PopsAlert.init(confirmDetails);
2103
2216
  let $selectContainer =
2104
2217
  $dialog.$shadowRoot.querySelector<HTMLUListElement>(
2105
2218
  ".select-container"
2106
2219
  )!;
2220
+ this.$el.$selectContainer = $selectContainer;
2107
2221
  // 配置选项元素
2108
2222
  formConfig.data.forEach((item) => {
2109
- let $select = createSelectItemElement(item);
2223
+ let $select = this.createSelectItemElement(item);
2110
2224
  // 添加到confirm中
2111
2225
  $selectContainer.appendChild($select);
2112
2226
  // 设置每一项的点击事件
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
- }
2227
+ this.setSelectElementClickEvent(selectedInfo, $select);
2131
2228
  });
2229
+ // 动态更新禁用状态
2230
+ this.updateSelectItem();
2132
2231
  });
2133
2232
  },
2134
- /** 设置关闭图标的点击事件 */
2233
+ /**
2234
+ * 设置关闭图标的点击事件
2235
+ * @param data 选中的信息
2236
+ */
2135
2237
  setSelectedItemCloseIconClickEvent(data: {
2136
2238
  /** 关闭图标的元素 */
2137
2239
  $closeIcon: HTMLElement;
2138
2240
  /** tag元素 */
2139
2241
  $tag: HTMLElement;
2140
2242
  /** 值 */
2141
- value: any;
2243
+ value: PopsPanelSelectMultipleDataOption<any>["value"];
2142
2244
  /** 显示的文字 */
2143
- text: string;
2245
+ text: PopsPanelSelectMultipleDataOption<any>["text"];
2144
2246
  }) {
2145
2247
  popsDOMUtils.on<PointerEvent | MouseEvent>(
2146
2248
  data.$closeIcon,
@@ -2152,13 +2254,16 @@ export const PanelHandleContentDetails = () => {
2152
2254
  $tag: data.$tag,
2153
2255
  $closeIcon: data.$closeIcon,
2154
2256
  value: data.value,
2155
- text: data.text,
2257
+ text:
2258
+ typeof data.text === "function"
2259
+ ? data.text.bind(data)
2260
+ : data.text,
2156
2261
  });
2157
2262
  if (typeof result === "boolean" && !result) {
2158
2263
  return;
2159
2264
  }
2160
2265
  }
2161
- this.removeSelectedItem(data.$tag);
2266
+ this.removeSelectedTagItem(data.$tag);
2162
2267
  this.removeSelectedInfo({
2163
2268
  value: data.value,
2164
2269
  text: data.text,
@@ -2182,13 +2287,24 @@ export const PanelHandleContentDetails = () => {
2182
2287
  this.removeSectionIsNear();
2183
2288
  }
2184
2289
  },
2185
- /** 移除选中项元素 */
2186
- removeSelectedItem($ele: HTMLElement) {
2187
- $ele.remove();
2290
+ /**
2291
+ * 移除选中项元素
2292
+ */
2293
+ removeSelectedTagItem($tag: HTMLElement) {
2294
+ $tag.remove();
2188
2295
  this.checkTagEmpty();
2189
2296
  },
2190
- /** 移除选中的信息 */
2191
- removeSelectedInfo(data: { value: any; text: string }) {
2297
+ /**
2298
+ * 从保存的已选中的信息列表中移除目标信息
2299
+ * @param data 需要移除的信息
2300
+ * @param [triggerValueChangeCallBack=true] 是否触发值改变的回调
2301
+ * + true (默认)触发值改变的回调
2302
+ * + false 不触发值改变的回调
2303
+ */
2304
+ removeSelectedInfo(
2305
+ data: PopsPanelSelectMultipleDataOption<any>,
2306
+ triggerValueChangeCallBack: boolean = true
2307
+ ) {
2192
2308
  for (let index = 0; index < this.$data.selectInfo.length; index++) {
2193
2309
  const selectInfo = this.$data.selectInfo[index];
2194
2310
  if (selectInfo.value === data.value) {
@@ -2196,7 +2312,7 @@ export const PanelHandleContentDetails = () => {
2196
2312
  break;
2197
2313
  }
2198
2314
  }
2199
- this.selectValueChangeCallBack();
2315
+ triggerValueChangeCallBack && this.selectValueChangeCallBack();
2200
2316
  },
2201
2317
  /** 显示输入框 */
2202
2318
  showInputWrapper() {
@@ -2286,8 +2402,8 @@ export const PanelHandleContentDetails = () => {
2286
2402
  formConfig.buttonIcon.trim() !== ""
2287
2403
  ) {
2288
2404
  /* 存在icon图标且不为空 */
2289
- if (formConfig.buttonIcon in pops.config.iconSVG) {
2290
- this.setIconSVG(pops.config.iconSVG[formConfig.buttonIcon]);
2405
+ if (PopsIcon.hasIcon(formConfig.buttonIcon)) {
2406
+ this.setIconSVG(PopsIcon.getIcon(formConfig.buttonIcon)!);
2291
2407
  } else {
2292
2408
  this.setIconSVG(formConfig.buttonIcon);
2293
2409
  }
@@ -2415,7 +2531,9 @@ export const PanelHandleContentDetails = () => {
2415
2531
  : true;
2416
2532
  let arrowRightIconHTML = "";
2417
2533
  if (arrowRightIcon) {
2418
- arrowRightIconHTML = `<i class="pops-panel-deepMenu-arrowRight-icon">${pops.config.iconSVG.arrowRight}</i>`;
2534
+ arrowRightIconHTML = `<i class="pops-panel-deepMenu-arrowRight-icon">${PopsIcon.getIcon(
2535
+ "arrowRight"
2536
+ )}</i>`;
2419
2537
  }
2420
2538
  let rightText = "";
2421
2539
  if (formConfig.rightText) {
@@ -2573,7 +2691,7 @@ export const PanelHandleContentDetails = () => {
2573
2691
  });
2574
2692
  let $headerLeftArrow = popsDOMUtils.createElement("i", {
2575
2693
  className: "pops-panel-deepMenu-container-left-arrow-icon",
2576
- innerHTML: pops.config.iconSVG.arrowLeft,
2694
+ innerHTML: PopsIcon.getIcon("arrowLeft")!,
2577
2695
  });
2578
2696
  popsDOMUtils.on(
2579
2697
  $headerLeftArrow,
@@ -2679,7 +2797,7 @@ export const PanelHandleContentDetails = () => {
2679
2797
  );
2680
2798
  } else if (formType === "select-multiple") {
2681
2799
  return this.createSectionContainerItem_select_multiple_new(
2682
- formConfig as PopsPanelSelectMultipleDetails
2800
+ formConfig as PopsPanelSelectMultipleDetails<any>
2683
2801
  );
2684
2802
  } else if (formType === "button") {
2685
2803
  return this.createSectionContainerItem_button(