@whitesev/pops 3.0.0 → 3.0.1

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 (59) hide show
  1. package/dist/index.amd.js +1417 -579
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.amd.min.js +1 -1
  4. package/dist/index.amd.min.js.map +1 -1
  5. package/dist/index.cjs.js +1417 -579
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.cjs.min.js +1 -1
  8. package/dist/index.cjs.min.js.map +1 -1
  9. package/dist/index.esm.js +1417 -579
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.esm.min.js +1 -1
  12. package/dist/index.esm.min.js.map +1 -1
  13. package/dist/index.iife.js +1417 -579
  14. package/dist/index.iife.js.map +1 -1
  15. package/dist/index.iife.min.js +1 -1
  16. package/dist/index.iife.min.js.map +1 -1
  17. package/dist/index.system.js +1417 -579
  18. package/dist/index.system.js.map +1 -1
  19. package/dist/index.system.min.js +1 -1
  20. package/dist/index.system.min.js.map +1 -1
  21. package/dist/index.umd.js +1417 -579
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/index.umd.min.js +1 -1
  24. package/dist/index.umd.min.js.map +1 -1
  25. package/dist/types/src/Pops.d.ts +372 -21
  26. package/dist/types/src/PopsCSS.d.ts +3 -1
  27. package/dist/types/src/PopsIcon.d.ts +1 -1
  28. package/dist/types/src/components/panel/handlerComponents.d.ts +956 -21
  29. package/dist/types/src/components/panel/index.d.ts +1 -1
  30. package/dist/types/src/components/panel/types/components-button.d.ts +1 -1
  31. package/dist/types/src/components/panel/types/components-container.d.ts +1 -1
  32. package/dist/types/src/components/panel/types/components-deepMenu.d.ts +1 -1
  33. package/dist/types/src/components/panel/types/components-input.d.ts +41 -16
  34. package/dist/types/src/components/panel/types/components-own.d.ts +3 -3
  35. package/dist/types/src/components/panel/types/components-select.d.ts +89 -30
  36. package/dist/types/src/components/panel/types/components-selectMultiple.d.ts +10 -15
  37. package/dist/types/src/components/panel/types/components-slider.d.ts +2 -3
  38. package/dist/types/src/components/panel/types/components-switch.d.ts +1 -1
  39. package/dist/types/src/components/panel/types/components-textarea.d.ts +1 -1
  40. package/dist/types/src/components/searchSuggestion/index.d.ts +3 -3
  41. package/dist/types/src/types/global.d.ts +3 -1
  42. package/package.json +8 -8
  43. package/src/PopsCSS.ts +4 -1
  44. package/src/components/panel/css/components-select.css +84 -0
  45. package/src/components/panel/defaultConfig.ts +290 -80
  46. package/src/components/panel/handlerComponents.ts +1112 -461
  47. package/src/components/panel/index.css +85 -5
  48. package/src/components/panel/types/components-button.ts +1 -1
  49. package/src/components/panel/types/components-container.ts +1 -1
  50. package/src/components/panel/types/components-deepMenu.ts +1 -1
  51. package/src/components/panel/types/components-input.ts +51 -16
  52. package/src/components/panel/types/components-own.ts +3 -3
  53. package/src/components/panel/types/components-select.ts +94 -32
  54. package/src/components/panel/types/components-selectMultiple.ts +11 -16
  55. package/src/components/panel/types/components-slider.ts +2 -3
  56. package/src/components/panel/types/components-switch.ts +1 -1
  57. package/src/components/panel/types/components-textarea.ts +1 -1
  58. package/src/components/searchSuggestion/index.ts +20 -65
  59. package/src/types/global.d.ts +3 -1
@@ -19,16 +19,17 @@ import type {
19
19
  PopsPanelEventType,
20
20
  PopsPanelViewConfig,
21
21
  } from "./types";
22
- import type { PopsPanelInputConfig } from "./types/components-input";
22
+ import type { PopsPanelInputConfig, PopsPanelInputType } from "./types/components-input";
23
23
  import type { PopsPanelOwnConfig } from "./types/components-own";
24
24
  import type {
25
25
  PopsPanelSelectMultipleDataOption,
26
26
  PopsPanelSelectMultipleConfig,
27
27
  } from "./types/components-selectMultiple";
28
- import type { PopsPanelSelectConfig } from "./types/components-select";
28
+ import type { PopsPanelSelectConfig, PopsPanelSelectDataOption } from "./types/components-select";
29
29
  import type { PopsPanelSliderConfig } from "./types/components-slider";
30
30
  import type { PopsPanelSwitchConfig } from "./types/components-switch";
31
31
  import type { PopsPanelTextAreaConfig } from "./types/components-textarea";
32
+ import { PopsCSS } from "../../PopsCSS";
32
33
  /**
33
34
  * 处理组件(把组件配置转为组件元素)
34
35
  */
@@ -118,7 +119,7 @@ export const PanelHandlerComponents = () => {
118
119
  // 初始化内容配置
119
120
  data.config.content.forEach((asideItemConfig) => {
120
121
  const $asideLiElement = this.createAsideItem(asideItemConfig);
121
- this.setAsideItemClickEvent($asideLiElement, asideItemConfig);
122
+ this.onAsideItemClick($asideLiElement, asideItemConfig);
122
123
  // 是否处于底部
123
124
  const isBottom =
124
125
  typeof asideItemConfig.isBottom === "function" ? asideItemConfig.isBottom() : asideItemConfig.isBottom;
@@ -150,7 +151,7 @@ export const PanelHandlerComponents = () => {
150
151
  // 初始化底部内容配置
151
152
  (data.config?.bottomContentConfig || []).forEach((bottomItemConfig) => {
152
153
  const $bottomLiElement = this.createBottomItem(bottomItemConfig);
153
- this.setBottomItemClickEvent($bottomLiElement, bottomItemConfig);
154
+ this.onBottomItemClick($bottomLiElement, bottomItemConfig);
154
155
  if (bottomItemConfig.position === "left" || bottomItemConfig.position == null) {
155
156
  this.$el.$panelBottomLeftContainer.appendChild($bottomLiElement);
156
157
  } else if (bottomItemConfig.position === "right") {
@@ -298,7 +299,7 @@ export const PanelHandlerComponents = () => {
298
299
  * @param $bottomItem 底部<li>元素
299
300
  * @param bottomItemConfig 配置
300
301
  */
301
- setBottomItemClickEvent($bottomItem: HTMLElement, bottomItemConfig: PopsPanelBottomContentConfig) {
302
+ onBottomItemClick($bottomItem: HTMLElement, bottomItemConfig: PopsPanelBottomContentConfig) {
302
303
  popsDOMUtils.on<MouseEvent | PointerEvent>($bottomItem, "click", async (event) => {
303
304
  if (typeof bottomItemConfig.clickCallback === "function") {
304
305
  // 执行回调
@@ -388,12 +389,12 @@ export const PanelHandlerComponents = () => {
388
389
  if (disabled) {
389
390
  this.disable();
390
391
  }
391
- this.setClickEvent();
392
+ this.onClick();
392
393
  },
393
394
  /**
394
395
  * 设置点击事件
395
396
  */
396
- setClickEvent() {
397
+ onClick() {
397
398
  const that = this;
398
399
  popsDOMUtils.on(this.$ele.core, "click", function (event) {
399
400
  if (that.$ele.input.disabled || that.$ele.switch.hasAttribute("data-disabled")) {
@@ -448,71 +449,10 @@ export const PanelHandlerComponents = () => {
448
449
 
449
450
  PopsPanelSwitch.init();
450
451
  Reflect.set($li, "data-switch", PopsPanelSwitch);
451
- return $li;
452
- },
453
- /**
454
- * type ==> slider
455
- * 获取中间容器的元素<li>
456
- * @param viewConfig
457
- */
458
- createSectionContainerItem_slider(viewConfig: PopsPanelSliderConfig) {
459
- const $li = popsDOMUtils.createElement("li");
460
- Reflect.set($li, this.$data.nodeStoreConfigKey, viewConfig);
461
- this.setElementClassName($li, viewConfig.className);
462
- this.setElementAttributes($li, viewConfig.attributes);
463
- this.setElementProps($li, viewConfig.props);
464
- // 左边底部的描述的文字
465
- let leftDescriptionText = "";
466
- if (viewConfig.description) {
467
- leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${viewConfig.description}</p>`;
468
- }
469
- PopsSafeUtils.setSafeHTML(
470
- $li,
471
- /*html*/ `
472
- <div class="pops-panel-item-left-text">
473
- <p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
474
- <div class="pops-panel-slider">
475
- <input type="range" min="${viewConfig.min}" max="${viewConfig.max}">
476
- </div>
477
- `
478
- );
479
- const $rangeInput = $li.querySelector<HTMLInputElement>(".pops-panel-slider input[type=range]")!;
480
- if (viewConfig.step) {
481
- $rangeInput.setAttribute("step", viewConfig.step.toString());
482
- }
483
- $rangeInput.value = viewConfig.getValue().toString();
484
- /**
485
- * 获取提示的内容
486
- * @param value
487
- */
488
- const getToolTipContent = function (value: number | string) {
489
- if (typeof viewConfig.getToolTipContent === "function") {
490
- return viewConfig.getToolTipContent(value as number);
491
- } else {
492
- return value as string;
493
- }
452
+ return {
453
+ $el: $li,
454
+ handler: PopsPanelSwitch,
494
455
  };
495
- const tooltip = PopsTooltip.init({
496
- $target: $rangeInput.parentElement!,
497
- content: () => {
498
- return getToolTipContent($rangeInput.value);
499
- },
500
- zIndex: () => {
501
- return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
502
- },
503
- className: "github-tooltip",
504
- alwaysShow: false,
505
- only: false,
506
- position: "top",
507
- arrowDistance: 10,
508
- });
509
- popsDOMUtils.on<InputEvent>($rangeInput, ["input", "propertychange"], void 0, function (event) {
510
- tooltip.toolTip.changeContent(getToolTipContent($rangeInput.value));
511
- if (typeof viewConfig.callback === "function") {
512
- viewConfig.callback(event, $rangeInput.valueAsNumber);
513
- }
514
- });
515
- return $li;
516
456
  },
517
457
  /**
518
458
  * type ==> slider
@@ -631,7 +571,7 @@ export const PanelHandlerComponents = () => {
631
571
  this.initEleData();
632
572
  this.setToolTipEvent();
633
573
  this.setPanEvent();
634
- this.setRunAwayClickEvent();
574
+ this.onRunAwayClick();
635
575
  this.intervalInit();
636
576
  if (this.isDisabledDragWithConfig()) {
637
577
  this.disableDrag();
@@ -901,7 +841,7 @@ export const PanelHandlerComponents = () => {
901
841
  /**
902
842
  * 设置进度条点击定位的事件
903
843
  */
904
- setRunAwayClickEvent() {
844
+ onRunAwayClick() {
905
845
  popsDOMUtils.on<PointerEvent | MouseEvent>(
906
846
  this.$ele.runAway,
907
847
  "click",
@@ -1108,7 +1048,10 @@ export const PanelHandlerComponents = () => {
1108
1048
  };
1109
1049
  PopsPanelSlider.init();
1110
1050
  Reflect.set($li, "data-slider", PopsPanelSlider);
1111
- return $li;
1051
+ return {
1052
+ $el: $li,
1053
+ handler: PopsPanelSlider,
1054
+ };
1112
1055
  },
1113
1056
  /**
1114
1057
  * type ==> input
@@ -1121,12 +1064,8 @@ export const PanelHandlerComponents = () => {
1121
1064
  this.setElementClassName($li, viewConfig.className);
1122
1065
  this.setElementAttributes($li, viewConfig.attributes);
1123
1066
  this.setElementProps($li, viewConfig.props);
1124
- let inputType = "text";
1125
- if (viewConfig.isPassword) {
1126
- inputType = "password";
1127
- } else if (viewConfig.isNumber) {
1128
- inputType = "number";
1129
- }
1067
+ const defaultInputType: PopsPanelInputType = "text";
1068
+ const inputType = viewConfig.inputType || defaultInputType;
1130
1069
  // 左边底部的描述的文字
1131
1070
  let leftDescriptionText = "";
1132
1071
  if (viewConfig.description) {
@@ -1138,139 +1077,194 @@ export const PanelHandlerComponents = () => {
1138
1077
  <div class="pops-panel-item-left-text">
1139
1078
  <p class="pops-panel-item-left-main-text">${viewConfig.text}</p>${leftDescriptionText}</div>
1140
1079
  <div class="pops-panel-input">
1141
- <input type="${inputType}" placeholder="${viewConfig.placeholder ?? ""}">
1080
+ <div class="pops-panel-input_inner">
1081
+ <input type="${inputType}" placeholder="${viewConfig.placeholder ?? ""}">
1082
+ </div>
1142
1083
  </div>
1143
1084
  `
1144
1085
  );
1145
1086
  const PopsPanelInput = {
1146
1087
  [Symbol.toStringTag]: "PopsPanelInput",
1147
- $ele: {
1088
+ $el: {
1148
1089
  itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
1149
1090
  panelInput: $li.querySelector<HTMLDivElement>(".pops-panel-input")!,
1091
+ panelInputInner: $li.querySelector<HTMLDivElement>(".pops-panel-input_inner")!,
1150
1092
  input: $li.querySelector<HTMLInputElement>("input")!,
1151
- inputSpanIcon: popsDOMUtils.createElement("span"),
1152
- inputSpanIconInner: null as any as HTMLSpanElement,
1093
+ /** span.pops-panel-input__suffix */
1094
+ suffix: popsDOMUtils.createElement("span"),
1095
+ /** span.pops-panel-input__suffix-inner */
1096
+ suffixInner: null as any as HTMLSpanElement,
1097
+ /** i.pops-panel-icon */
1153
1098
  icon: null as any as HTMLElement,
1154
1099
  },
1155
1100
  $data: {
1156
1101
  value: viewConfig.getValue(),
1157
- isView: false,
1102
+ /**
1103
+ * inputType 为 password时使用该值
1104
+ *
1105
+ * 当前内容的可见性
1106
+ */
1107
+ isVisible: false,
1158
1108
  },
1159
1109
  init() {
1160
1110
  this.initEle();
1161
1111
  this.setInputValue(this.$data.value);
1162
1112
  // 如果是密码框,放进图标
1163
- if (viewConfig.isPassword) {
1113
+ if (viewConfig.inputType === "password") {
1114
+ // 显示密码
1164
1115
  this.setCircleIcon(PopsIcon.getIcon("view")!);
1165
- this.setCircleIconClickEvent();
1116
+ this.onIconClick();
1166
1117
  } else {
1167
1118
  // 先判断预设值是否为空,不为空添加清空图标按钮
1168
- if (this.$ele.input.value != "") {
1119
+ // 且为普通的输入框
1120
+ if (this.$el.input.value != "" && this.isTextInputType()) {
1121
+ // 清除内容的图标
1169
1122
  this.setCircleIcon(PopsIcon.getIcon("circleClose")!);
1170
- this.setCircleIconClickEvent();
1123
+ this.onIconClick();
1124
+ } else {
1125
+ // 隐藏图标
1126
+ this.hideCircleIconWrapper();
1171
1127
  }
1172
1128
  }
1173
1129
 
1174
- this.setInputChangeEvent();
1130
+ this.onValueChange();
1175
1131
  // 是否禁用复选框
1176
1132
  const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
1177
1133
  if (disabled) {
1178
1134
  this.disable();
1179
1135
  }
1180
1136
  if (typeof viewConfig.handlerCallBack === "function") {
1181
- viewConfig.handlerCallBack($li, this.$ele.input);
1137
+ viewConfig.handlerCallBack($li, this.$el.input);
1182
1138
  }
1183
1139
  },
1184
1140
  /**
1185
1141
  * 初始化$ele的配置
1186
1142
  */
1187
1143
  initEle() {
1188
- this.$ele.input.parentElement!.insertBefore(this.$ele.inputSpanIcon, this.$ele.input.nextSibling);
1189
- popsDOMUtils.addClassName(this.$ele.inputSpanIcon, "pops-panel-input__suffix");
1144
+ this.$el.input.parentElement!.insertBefore(this.$el.suffix, this.$el.input.nextSibling);
1145
+ popsDOMUtils.addClassName(this.$el.suffix, "pops-panel-input__suffix");
1190
1146
  PopsSafeUtils.setSafeHTML(
1191
- this.$ele.inputSpanIcon,
1147
+ this.$el.suffix,
1192
1148
  /*html*/ `
1193
1149
  <span class="pops-panel-input__suffix-inner">
1194
1150
  <i class="pops-panel-icon"></i>
1195
1151
  </span>
1196
1152
  `
1197
1153
  );
1198
- this.$ele.inputSpanIconInner = this.$ele.inputSpanIcon.querySelector<HTMLElement>(
1199
- ".pops-panel-input__suffix-inner"
1200
- )!;
1201
- this.$ele.icon = this.$ele.inputSpanIcon.querySelector<HTMLElement>(".pops-panel-icon")!;
1202
- popsDOMUtils.addClassName(this.$ele.panelInput, PopsCommonCSSClassName.userSelectNone);
1154
+ this.$el.suffixInner = this.$el.suffix.querySelector<HTMLElement>(".pops-panel-input__suffix-inner")!;
1155
+ this.$el.icon = this.$el.suffix.querySelector<HTMLElement>(".pops-panel-icon")!;
1156
+ popsDOMUtils.addClassName(this.$el.panelInput, PopsCommonCSSClassName.userSelectNone);
1157
+ },
1158
+ /**
1159
+ * 校验输入框类型是否是字符串输入框类型
1160
+ */
1161
+ isTextInputType() {
1162
+ const typeList: PopsPanelInputType[] = ["text", "search", "email", "tel", "url"];
1163
+ return typeList.includes(viewConfig.inputType || defaultInputType);
1164
+ },
1165
+ /**
1166
+ * 是否是时间输入框类型
1167
+ */
1168
+ isDateInputType() {
1169
+ const typeList: PopsPanelInputType[] = ["date", "datetime-local", "month", "time", "week"];
1170
+ return typeList.includes(viewConfig.inputType || defaultInputType);
1171
+ },
1172
+ /**
1173
+ * 是否是数字输入框类型
1174
+ */
1175
+ isNumberInputType() {
1176
+ const typeList: PopsPanelInputType[] = ["number"];
1177
+ return typeList.includes(viewConfig.inputType || defaultInputType);
1203
1178
  },
1204
1179
  /**
1205
1180
  * 禁用
1206
1181
  */
1207
1182
  disable() {
1208
- this.$ele.input.disabled = true;
1209
- popsDOMUtils.addClassName(this.$ele.panelInput, "pops-input-disabled");
1210
- popsDOMUtils.addClassName(this.$ele.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
1183
+ this.$el.input.disabled = true;
1184
+ popsDOMUtils.addClassName(this.$el.panelInput, "pops-input-disabled");
1185
+ popsDOMUtils.addClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
1211
1186
  },
1212
1187
  /**
1213
1188
  * 取消禁用
1214
1189
  */
1215
1190
  notDisable() {
1216
- this.$ele.input.disabled = false;
1217
- popsDOMUtils.removeClassName(this.$ele.panelInput, "pops-input-disabled");
1218
- popsDOMUtils.removeClassName(this.$ele.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
1191
+ this.$el.input.disabled = false;
1192
+ popsDOMUtils.removeClassName(this.$el.panelInput, "pops-input-disabled");
1193
+ popsDOMUtils.removeClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
1219
1194
  },
1220
1195
  /**
1221
1196
  * 判断是否已被禁用
1222
1197
  */
1223
1198
  isDisabled() {
1224
- return this.$ele.input.disabled;
1199
+ return this.$el.input.disabled;
1225
1200
  },
1226
1201
  /**
1227
1202
  * 设置输入框内容
1228
- * @param {string} [value=""]
1203
+ * @param value 值
1229
1204
  */
1230
- setInputValue(value = "") {
1231
- this.$ele.input.value = value;
1205
+ setInputValue(value: string | number | Date = "") {
1206
+ if (typeof value === "number" && this.isNumberInputType()) {
1207
+ this.$el.input.valueAsNumber = value;
1208
+ } else if (typeof value === "object" && value instanceof Date && this.isDateInputType()) {
1209
+ this.$el.input.valueAsDate = value;
1210
+ } else {
1211
+ this.$el.input.value = value.toString();
1212
+ }
1232
1213
  },
1233
1214
  /**
1234
1215
  * 设置input元素的type
1235
- * @param [typeValue="text"] type值
1216
+ * @param typeValue type值
1236
1217
  */
1237
- setInputType(typeValue = "text") {
1238
- this.$ele.input.setAttribute("type", typeValue);
1218
+ setInputType(typeValue: PopsPanelInputType = "text") {
1219
+ this.$el.input.setAttribute("type", typeValue);
1239
1220
  },
1240
1221
  /**
1241
1222
  * 删除图标按钮
1242
1223
  */
1243
1224
  removeCircleIcon() {
1244
- PopsSafeUtils.setSafeHTML(this.$ele.icon, "");
1225
+ PopsSafeUtils.setSafeHTML(this.$el.icon, "");
1245
1226
  },
1246
1227
  /**
1247
1228
  * 添加清空图标按钮
1248
- * @param [svgHTML=PopsIcon.getIcon("circleClose")] svg图标,默认为清空的图标
1229
+ * @param svgHTML svg图标,默认为清空的图标
1249
1230
  */
1250
- setCircleIcon(svgHTML = PopsIcon.getIcon("circleClose")!) {
1251
- PopsSafeUtils.setSafeHTML(this.$ele.icon, svgHTML);
1231
+ setCircleIcon(svgHTML: string = PopsIcon.getIcon("circleClose")!) {
1232
+ PopsSafeUtils.setSafeHTML(this.$el.icon, svgHTML);
1233
+ },
1234
+ /**
1235
+ * 隐藏图标容器
1236
+ */
1237
+ hideCircleIconWrapper() {
1238
+ popsDOMUtils.cssHide(this.$el.suffix, true);
1239
+ },
1240
+ /**
1241
+ * 显示图标容器
1242
+ */
1243
+ showCircleIconWrapper() {
1244
+ popsDOMUtils.cssShow(this.$el.suffix);
1252
1245
  },
1253
1246
  /**
1254
1247
  * 添加图标按钮的点击事件
1255
1248
  */
1256
- setCircleIconClickEvent() {
1257
- popsDOMUtils.on(this.$ele.icon, "click", void 0, () => {
1249
+ onIconClick() {
1250
+ popsDOMUtils.on(this.$el.icon, "click", (evt) => {
1251
+ popsDOMUtils.preventEvent(evt);
1258
1252
  if (this.isDisabled()) {
1259
1253
  return;
1260
1254
  }
1261
1255
  // 删除图标
1262
1256
  this.removeCircleIcon();
1263
- if (viewConfig.isPassword) {
1264
- // 密码输入框
1265
- if (this.$data.isView) {
1257
+ if (inputType === "password") {
1258
+ // 配置类型为密码输入框
1259
+ if (this.$data.isVisible) {
1266
1260
  // 当前可见 => 点击改变为隐藏
1267
- this.$data.isView = false;
1261
+ this.$data.isVisible = false;
1268
1262
  // 显示输入框内容,且更换图标为隐藏图标
1269
1263
  this.setInputType("text");
1270
1264
  this.setCircleIcon(PopsIcon.getIcon("hide")!);
1271
1265
  } else {
1272
1266
  // 当前不可见 => 点击改变为显示
1273
- this.$data.isView = true;
1267
+ this.$data.isVisible = true;
1274
1268
  // 隐藏输入框内容,且更换图标为显示图标
1275
1269
  this.setInputType("password");
1276
1270
  this.setCircleIcon(PopsIcon.getIcon("view")!);
@@ -1280,41 +1274,98 @@ export const PanelHandlerComponents = () => {
1280
1274
  // 清空内容
1281
1275
  this.setInputValue("");
1282
1276
  // 获取焦点
1283
- this.$ele.input.focus();
1277
+ this.$el.input.focus();
1284
1278
  // 触发内容改变事件
1285
- this.$ele.input.dispatchEvent(new Event("input"));
1279
+ this.$el.input.dispatchEvent(new Event("input"));
1286
1280
  }
1287
1281
  });
1288
1282
  },
1289
1283
  /**
1290
1284
  * 监听输入框内容改变
1291
1285
  */
1292
- setInputChangeEvent() {
1293
- popsDOMUtils.on<InputEvent>(this.$ele.input, ["input", "propertychange"], void 0, (event) => {
1294
- this.$data.value = this.$ele.input.value;
1295
- if (!viewConfig.isPassword) {
1286
+ onValueChange() {
1287
+ popsDOMUtils.on<InputEvent>(this.$el.input, ["input", "propertychange"], void 0, (event) => {
1288
+ this.$data.value = this.$el.input.value;
1289
+ if (inputType !== "password") {
1296
1290
  // 不是密码框
1297
- if (this.$ele.input.value !== "" && this.$ele.icon.innerHTML === "") {
1291
+ if (this.$el.input.value !== "" && this.$el.icon.innerHTML === "" && this.isTextInputType()) {
1298
1292
  // 不为空,显示清空图标
1299
1293
  this.setCircleIcon(PopsIcon.getIcon("circleClose")!);
1300
- this.setCircleIconClickEvent();
1301
- } else if (this.$ele.input.value === "") {
1294
+ this.onIconClick();
1295
+ this.showCircleIconWrapper();
1296
+ } else if (this.$el.input.value === "") {
1302
1297
  this.removeCircleIcon();
1303
1298
  }
1304
1299
  }
1305
1300
  if (typeof viewConfig.callback === "function") {
1306
- if (viewConfig.isNumber) {
1307
- viewConfig.callback(event, this.$ele.input.value, this.$ele.input.valueAsNumber);
1301
+ let ret;
1302
+ if (viewConfig.inputType === "number") {
1303
+ ret = viewConfig.callback(event, this.$el.input.value, this.$el.input.valueAsNumber);
1304
+ } else if (this.isDateInputType()) {
1305
+ ret = viewConfig.callback(
1306
+ event,
1307
+ this.$el.input.value,
1308
+ this.$el.input.valueAsNumber,
1309
+ this.$el.input.valueAsDate
1310
+ );
1308
1311
  } else {
1309
- viewConfig.callback(event, this.$ele.input.value);
1312
+ ret = viewConfig.callback(event, this.$el.input.value);
1313
+ }
1314
+ if (ret) {
1315
+ if (ret.valid) {
1316
+ // 校验通过
1317
+ this.removeValidErrorMsg();
1318
+ } else {
1319
+ // 校验失败
1320
+ // 显示失败提示
1321
+ this.addValidErrorMsg(ret.message);
1322
+ }
1323
+ } else {
1324
+ this.removeValidErrorMsg();
1310
1325
  }
1311
1326
  }
1312
1327
  });
1313
1328
  },
1329
+ /**
1330
+ * 主动触发输入框改变事件
1331
+ */
1332
+ triggerValueChange() {
1333
+ this.$el.input.dispatchEvent(new Event("input"));
1334
+ },
1335
+ /**
1336
+ * 添加校验失败的提示信息
1337
+ * @param msg 提示信息
1338
+ */
1339
+ addValidErrorMsg(msg?: string) {
1340
+ if (msg == null) return;
1341
+ const $validErrorMsg =
1342
+ this.$el.panelInput.querySelector<HTMLDivElement>(".pops-panel-input-valid-error") ||
1343
+ popsDOMUtils.createElement("div", {
1344
+ className: "pops-panel-input-valid-error",
1345
+ innerHTML: /*html*/ `<span></span>`,
1346
+ });
1347
+ const $validErrorMsgSpan = $validErrorMsg.querySelector("span")!;
1348
+ if ($validErrorMsgSpan.innerHTML !== msg) {
1349
+ PopsSafeUtils.setSafeHTML($validErrorMsgSpan, msg);
1350
+ }
1351
+ if (!$validErrorMsg.parentElement) {
1352
+ popsDOMUtils.after(this.$el.panelInputInner, $validErrorMsg);
1353
+ }
1354
+ },
1355
+ /**
1356
+ * 移除校验失败的提示信息
1357
+ */
1358
+ removeValidErrorMsg() {
1359
+ const $validErrorMsg = this.$el.panelInput.querySelector(".pops-panel-input-valid-error");
1360
+ $validErrorMsg?.remove();
1361
+ },
1314
1362
  };
1315
1363
  PopsPanelInput.init();
1316
1364
  Reflect.set($li, "data-input", PopsPanelInput);
1317
- return $li;
1365
+ return {
1366
+ $el: $li,
1367
+ handler: PopsPanelInput,
1368
+ };
1318
1369
  },
1319
1370
  /**
1320
1371
  * type ==> textarea
@@ -1356,7 +1407,7 @@ export const PanelHandlerComponents = () => {
1356
1407
  },
1357
1408
  init() {
1358
1409
  this.setValue(this.$data.value);
1359
- this.setChangeEvent();
1410
+ this.onValueChange();
1360
1411
  const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
1361
1412
  if (disabled) {
1362
1413
  this.disable();
@@ -1384,7 +1435,7 @@ export const PanelHandlerComponents = () => {
1384
1435
  /**
1385
1436
  * 监听选择内容改变
1386
1437
  */
1387
- setChangeEvent() {
1438
+ onValueChange() {
1388
1439
  popsDOMUtils.on<InputEvent>(this.$ele.textarea, ["input", "propertychange"], (event) => {
1389
1440
  const value = this.$ele.textarea.value;
1390
1441
  this.$data.value = value;
@@ -1403,7 +1454,10 @@ export const PanelHandlerComponents = () => {
1403
1454
  PopsPanelTextArea.init();
1404
1455
  Reflect.set($li, "data-textarea", PopsPanelTextArea);
1405
1456
 
1406
- return $li;
1457
+ return {
1458
+ $el: $li,
1459
+ handler: PopsPanelTextArea,
1460
+ };
1407
1461
  },
1408
1462
  /**
1409
1463
  * type ==> select
@@ -1432,180 +1486,828 @@ export const PanelHandlerComponents = () => {
1432
1486
  </div>
1433
1487
  `
1434
1488
  );
1489
+ let handler;
1490
+ if (viewConfig.useDialog) {
1491
+ const PopsPanelSelect = {
1492
+ [Symbol.toStringTag]: "PopsPanelSelect",
1493
+ $el: {
1494
+ itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
1495
+ /** 选择框容器 */
1496
+ $container: void 0 as any as HTMLElement,
1497
+ /** 选择框包裹的容器 */
1498
+ $wrapper: void 0 as any as HTMLElement,
1499
+ /** 内容区域 */
1500
+ $section: void 0 as any as HTMLElement,
1501
+ /** 手动输入 */
1502
+ $selectedInputWrapper: void 0 as any as HTMLElement,
1503
+ /** 灰色提示语 */
1504
+ $selectedPlaceHolderWrapper: void 0 as any as HTMLElement,
1505
+ /** 下拉箭头区域 */
1506
+ $suffix: void 0 as any as HTMLElement,
1507
+ /** 下拉箭头图标 */
1508
+ $suffixIcon: void 0 as any as HTMLElement,
1509
+ /** 下拉列表弹窗的下拉列表容器 */
1510
+ $selectDialogContainer: void 0 as any as HTMLElement | null,
1511
+ },
1512
+ $data: {
1513
+ /**
1514
+ * 数据
1515
+ */
1516
+ data: [] as PopsPanelSelectDataOption<any>[],
1517
+ /**
1518
+ * 默认值
1519
+ */
1520
+ defaultValue: viewConfig.getValue(),
1521
+ /**
1522
+ * 选择的信息
1523
+ */
1524
+ selectedData: void 0 as PopsPanelSelectDataOption<any> | undefined,
1525
+ /**
1526
+ * 是否验证通过
1527
+ */
1528
+ isValidSuccess: true,
1529
+ /**
1530
+ * 箭头旋转的属性
1531
+ */
1532
+ rotateKey: "data-show-option",
1533
+ },
1534
+ /** 初始化 */
1535
+ init() {
1536
+ this.initDefault();
1537
+ this.initEl();
1538
+ this.initPlaceHolder();
1539
+ this.renderSelectText();
1540
+ this.onShowSelectDialogClick();
1435
1541
 
1436
- const PopsPanelSelect = {
1437
- [Symbol.toStringTag]: "PopsPanelSelect",
1438
- $ele: {
1439
- itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
1440
- panelSelect: $li.querySelector<HTMLDivElement>(".pops-panel-select")!,
1441
- select: $li.querySelector<HTMLSelectElement>(".pops-panel-select select")!,
1442
- },
1443
- $eleKey: {
1444
- disable: "__disable__",
1445
- value: "__value__",
1446
- viewConfig: "data-view-config",
1447
- },
1448
- $data: {
1449
- defaultValue: viewConfig.getValue(),
1450
- },
1451
- init() {
1452
- popsDOMUtils.addClassName(this.$ele.panelSelect, PopsCommonCSSClassName.userSelectNone);
1453
- this.initOption();
1454
- this.setChangeEvent();
1455
- this.setClickEvent();
1456
- const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
1457
- if (disabled) {
1458
- this.disable();
1459
- }
1460
- },
1461
- /**
1462
- * 给option元素设置属性
1463
- * @param $ele
1464
- * @param key
1465
- * @param value
1466
- */
1467
- setNodeValue($ele: HTMLElement, key: string, value: any) {
1468
- Reflect.set($ele, key, value);
1469
- },
1470
- /**
1471
- * 获取option元素上设置的属性
1472
- * @param $ele
1473
- * @param value
1474
- * @param key
1475
- */
1476
- getNodeValue($ele: HTMLElement, key: string) {
1477
- return Reflect.get($ele, key);
1478
- },
1479
- /**
1480
- * 禁用选项
1481
- */
1482
- disable() {
1483
- this.$ele.select.setAttribute("disabled", "true");
1484
- popsDOMUtils.addClassName(this.$ele.panelSelect, "pops-panel-select-disable");
1485
- popsDOMUtils.addClassName(this.$ele.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
1486
- },
1487
- /**
1488
- * 取消禁用
1489
- */
1490
- notDisable() {
1491
- this.$ele.select.removeAttribute("disabled");
1492
- popsDOMUtils.removeClassName(this.$ele.panelSelect, "pops-panel-select-disable");
1493
- popsDOMUtils.removeClassName(this.$ele.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
1494
- },
1495
- /**
1496
- * 判断是否禁用
1497
- */
1498
- isDisabled() {
1499
- return (
1500
- this.$ele.select.hasAttribute("disabled") ||
1501
- popsDOMUtils.containsClassName(this.$ele.panelSelect, "pops-panel-select-disable")
1502
- );
1503
- },
1504
- /**
1505
- * 初始化选项
1506
- */
1507
- initOption() {
1508
- viewConfig.data.forEach((dataItem) => {
1509
- // 初始化默认选中
1510
- const optionElement = popsDOMUtils.createElement("option");
1511
- this.setNodeValue(optionElement, this.$eleKey.value, dataItem.value);
1512
- this.setNodeValue(optionElement, this.$eleKey.disable, dataItem.disable);
1513
- this.setNodeValue(optionElement, this.$eleKey.viewConfig, dataItem.views);
1514
- if (dataItem.value === this.$data.defaultValue) {
1515
- this.setOptionSelected(optionElement);
1542
+ const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
1543
+ if (disabled) {
1544
+ this.disable();
1516
1545
  }
1517
- optionElement.innerText = dataItem.text;
1518
- this.$ele.select.appendChild(optionElement);
1519
- });
1520
- },
1521
- /**
1522
- * 设置选项选中
1523
- */
1524
- setOptionSelected($option: HTMLOptionElement) {
1525
- $option.setAttribute("selected", "true");
1526
- },
1527
- /** 检测所有option并设置禁用状态 */
1528
- setSelectOptionsDisableStatus() {
1529
- if (this.$ele.select.options && this.$ele.select.options.length) {
1530
- Array.from(this.$ele.select.options).forEach((optionItem) => {
1531
- this.setOptionDisableStatus(optionItem);
1546
+ },
1547
+ /** 初始化默认值 */
1548
+ initDefault() {
1549
+ this.$data.data = typeof viewConfig.data === "function" ? viewConfig.data() : viewConfig.data;
1550
+ this.$data.data.forEach((dataItem) => {
1551
+ if (this.$data.defaultValue.includes(dataItem.value)) {
1552
+ // 初始化选中的配置
1553
+ this.resetCurrentSelectedInfo();
1554
+ this.updateSelectedInfo(dataItem);
1555
+ }
1532
1556
  });
1533
- }
1534
- },
1535
- /** 设置禁用状态 */
1536
- setOptionDisableStatus(optionElement: HTMLOptionElement) {
1537
- let disable = false;
1538
- const optionDisableAttr = this.getNodeValue(optionElement, this.$eleKey.disable);
1539
- if (optionDisableAttr === "function") {
1540
- const value = this.getNodeValue(optionElement, this.$eleKey.value);
1541
- disable = Boolean(optionDisableAttr(value));
1542
- }
1543
- if (disable) {
1544
- optionElement.setAttribute("disabled", "true");
1545
- } else {
1546
- optionElement.removeAttribute("disabled");
1547
- }
1548
- },
1549
- /** 获取option上的信息 */
1550
- getSelectOptionInfo($option: HTMLOptionElement) {
1551
- const optionValue = this.getNodeValue($option, this.$eleKey.value);
1552
- const optionText = $option.innerText || $option.textContent!;
1553
- const views = this.getNodeValue($option, this.$eleKey.viewConfig) as (typeof viewConfig.data)[0]["views"];
1554
- return {
1555
- value: optionValue,
1556
- text: optionText,
1557
- views: views,
1558
- $option: $option,
1559
- };
1560
- },
1561
- /**
1562
- * 监听选择内容改变
1563
- */
1564
- setChangeEvent() {
1565
- popsDOMUtils.on<PointerEvent | TouchEvent>(this.$ele.select, "change", void 0, (event) => {
1566
- const $isSelectedElement = this.$ele.select[this.$ele.select.selectedIndex] as HTMLOptionElement;
1567
- const selectInfo = this.getSelectOptionInfo($isSelectedElement);
1568
- this.setSelectOptionsDisableStatus();
1557
+ },
1558
+ /** 初始化$ele变量 */
1559
+ initEl() {
1560
+ this.$el.$container = $li.querySelector<HTMLElement>(".pops-panel-select")!;
1561
+ PopsSafeUtils.setSafeHTML(
1562
+ this.$el.$container,
1563
+ /*html*/ `
1564
+ <div class="el-select__wrapper">
1565
+ <div class="el-select__selection">
1566
+ <!-- 这个是用于手动输入的,这里暂不适配 -->
1567
+ <div class="el-select__selected-item el-select__input-wrapper"></div>
1568
+ <!-- 这个是placeholder -->
1569
+ <div class="el-select__selected-item el-select__placeholder"></div>
1570
+ </div>
1571
+ <!-- 下拉箭头 -->
1572
+ <div class="el-select__suffix">
1573
+ <i class="el-icon el-select__caret el-select__icon">
1574
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
1575
+ <path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>
1576
+ </svg>
1577
+ </i>
1578
+ </div>
1579
+ </div>`
1580
+ );
1581
+ this.$el.$wrapper = $li.querySelector<HTMLElement>(".el-select__wrapper")!;
1582
+ this.$el.$section = $li.querySelector<HTMLElement>(".el-select__selection")!;
1583
+ this.$el.$selectedInputWrapper = $li.querySelector<HTMLElement>(
1584
+ ".el-select__selected-item.el-select__input-wrapper"
1585
+ )!;
1586
+ this.$el.$selectedPlaceHolderWrapper = $li.querySelector<HTMLElement>(
1587
+ ".el-select__selected-item.el-select__placeholder"
1588
+ )!;
1589
+ this.$el.$suffix = $li.querySelector<HTMLElement>(".el-select__suffix")!;
1590
+ this.$el.$suffixIcon = $li.querySelector<HTMLElement>(".el-select__suffix .el-icon")!;
1591
+
1592
+ // 先把手动输入框隐藏
1593
+ this.hideInputWrapper();
1594
+ },
1595
+ /**
1596
+ * 初始化提示文字
1597
+ */
1598
+ initPlaceHolder() {
1599
+ let placeholder = "--请选择--";
1600
+ if (typeof viewConfig.placeholder === "string") {
1601
+ placeholder = viewConfig.placeholder;
1602
+ } else if (typeof viewConfig.placeholder === "function") {
1603
+ const placeholderResult = viewConfig.placeholder();
1604
+ if (typeof placeholderResult === "string") {
1605
+ placeholder = placeholderResult;
1606
+ }
1607
+ }
1608
+ /**
1609
+ * 默认提示文字的位置
1610
+ */
1611
+ const defaultSelectedTextAlign: NonNullable<PopsPanelSelectConfig<any>["selectedTextAlign"]> = "left";
1612
+ this.$el.$section.setAttribute(
1613
+ "data-selected-text-align",
1614
+ viewConfig.selectedTextAlign || defaultSelectedTextAlign
1615
+ );
1616
+
1617
+ const $placeholder = popsDOMUtils.createElement("span", {
1618
+ innerText: placeholder,
1619
+ });
1620
+ this.$el.$selectedPlaceHolderWrapper.appendChild($placeholder);
1621
+ },
1622
+ /**
1623
+ * 重新渲染外面的已选择项的文本
1624
+ *
1625
+ * 如果未选择,显示提示文字
1626
+ */
1627
+ renderSelectText() {
1628
+ let item = this.$data.data.find((dataItem) => {
1629
+ return dataItem.value === this.$data.selectedData?.value;
1630
+ });
1631
+ if (item == null) {
1632
+ // 未找到但是有选中信息,且是自定义输入的
1633
+ if (this.$data.selectedData && this.$data.selectedData.addCustomInput) {
1634
+ item = this.$data.selectedData;
1635
+ }
1636
+ }
1637
+ if (item != null) {
1638
+ // 默认值在数据中
1639
+ // 显示该数据项的文本
1640
+ // 隐藏placeholder
1641
+ const text = typeof item.text === "function" ? item.text(item.value, item) : item.text;
1642
+ if (item.isHTML) {
1643
+ PopsSafeUtils.setSafeHTML(this.$el.$selectedInputWrapper, text);
1644
+ } else {
1645
+ PopsSafeUtils.setSafeHTML(
1646
+ this.$el.$selectedInputWrapper,
1647
+ /*html*/ `
1648
+ <span>${text}</span>
1649
+ `
1650
+ );
1651
+ }
1652
+ // 显示选中的内容
1653
+ this.showInputWrapper();
1654
+ // 隐藏placeholder
1655
+ this.hidePlaceHolderWrapper();
1656
+ } else {
1657
+ // 仅显示placeholder
1658
+ this.hideInputWrapper();
1659
+ this.showPlaceHolderWrapper();
1660
+ }
1661
+ },
1662
+ /**
1663
+ * 禁用选项容器
1664
+ */
1665
+ disable() {
1666
+ popsDOMUtils.addClassName(this.$el.$container, "pops-panel-select-multiple-disable");
1667
+ popsDOMUtils.addClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
1668
+ },
1669
+ /**
1670
+ * 取消禁用选项容器
1671
+ */
1672
+ cancleDisable() {
1673
+ popsDOMUtils.removeClassName(this.$el.$container, "pops-panel-select-multiple-disable");
1674
+ popsDOMUtils.removeClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
1675
+ },
1676
+ /**
1677
+ * 判断当前是否已禁用选项容器
1678
+ */
1679
+ isDisabled() {
1680
+ return (
1681
+ popsDOMUtils.containsClassName(this.$el.$container, "pops-panel-select-multiple-disable") ||
1682
+ popsDOMUtils.containsClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled)
1683
+ );
1684
+ },
1685
+ /**
1686
+ * 设置选择列表的点击事件
1687
+ *
1688
+ * 点击显示选择列表的弹窗
1689
+ */
1690
+ onShowSelectDialogClick() {
1691
+ const defaultCSS = PopsCSS.panelComponents_Select;
1692
+ popsDOMUtils.on(this.$el.$container, "click", () => {
1693
+ if (this.isDisabled()) {
1694
+ return;
1695
+ }
1696
+ /** 当前已选中的值 */
1697
+ const { style, ...userConfirmConfig } = viewConfig.selectConfirmDialogConfig || {};
1698
+ /**
1699
+ * 弹窗关闭的回调
1700
+ */
1701
+ const dialogCloseCallback = () => {
1702
+ if (this.$data.selectedData?.addCustomInput && !this.$data.isValidSuccess) {
1703
+ // 当前是自定义输入的且未通过校验
1704
+ return false;
1705
+ } else {
1706
+ // 清除自定义输入的值
1707
+ this.getAllSelectItems(false).forEach((it) => {
1708
+ if (!it.data.addCustomInput) return;
1709
+ it.data.value = "";
1710
+ it.data.text = "";
1711
+ this.onValueChangeCallback(it.data);
1712
+ });
1713
+ }
1714
+ this.renderSelectText();
1715
+ this.$el.$selectDialogContainer = null;
1716
+ this.$el.$container.removeAttribute(this.$data.rotateKey);
1717
+ };
1718
+ this.$el.$container.setAttribute(this.$data.rotateKey, String(true));
1719
+ const confirmConfig = popsUtils.assign(
1720
+ <PopsAlertConfig>{
1721
+ title: {
1722
+ text: "请勾选需要选择的选项",
1723
+ position: "center",
1724
+ },
1725
+ content: {
1726
+ text: /*html*/ `<ul class="select-container"></ul>`,
1727
+ html: true,
1728
+ },
1729
+ btn: {
1730
+ ok: {
1731
+ enable: false,
1732
+ },
1733
+ close: {
1734
+ enable: true,
1735
+ callback(evtConfig) {
1736
+ const ret = dialogCloseCallback();
1737
+ if (typeof ret === "boolean" && !ret) {
1738
+ return;
1739
+ }
1740
+ evtConfig.close();
1741
+ },
1742
+ },
1743
+ },
1744
+ mask: {
1745
+ enable: true,
1746
+ clickCallBack(originalRun) {
1747
+ const ret = dialogCloseCallback();
1748
+ if (typeof ret === "boolean" && !ret) {
1749
+ return;
1750
+ }
1751
+ originalRun();
1752
+ },
1753
+ clickEvent: {
1754
+ toClose: true,
1755
+ },
1756
+ },
1757
+ drag: true,
1758
+ dragLimit: true,
1759
+ width: "300px",
1760
+ height: "auto",
1761
+ style: /*css*/ `
1762
+ ${defaultCSS}
1763
+
1764
+ ${PopsCSS.panelCSS}
1765
+
1766
+ ${style || ""}
1767
+ `,
1768
+ },
1769
+ userConfirmConfig
1770
+ );
1771
+ const $dialog = PopsAlert.init(confirmConfig);
1772
+ const $selectContainer = $dialog.$shadowRoot.querySelector<HTMLUListElement>(".select-container")!;
1773
+ // 初始化选项元素
1774
+ this.$data.data.forEach((item) => {
1775
+ if (item.addCustomInput) {
1776
+ // 添加自定义输入的
1777
+ const customInputDataOption = item;
1778
+ const $customInputSelecItem = this.createSelectItemElement(customInputDataOption);
1779
+ const context = this;
1780
+ const PanelInput = that.createSectionContainerItem_input({
1781
+ type: "input",
1782
+ text: "",
1783
+ getValue() {
1784
+ return customInputDataOption.value;
1785
+ },
1786
+ callback(evt, value) {
1787
+ customInputDataOption.text = value;
1788
+ customInputDataOption.value = value;
1789
+ if (typeof customInputDataOption.onValid === "function") {
1790
+ const ret = customInputDataOption.onValid(customInputDataOption);
1791
+ context.$data.isValidSuccess = ret.valid;
1792
+ if (ret.valid) {
1793
+ PanelInputHandler.removeValidErrorMsg();
1794
+ } else {
1795
+ PanelInputHandler.addValidErrorMsg(ret.message);
1796
+ return ret;
1797
+ }
1798
+ }
1799
+
1800
+ context.updateSelectedInfo(customInputDataOption);
1801
+ context.onValueChangeCallback(customInputDataOption);
1802
+ },
1803
+ });
1804
+ // 获取输入框处理函数
1805
+ const PanelInputHandler = PanelInput.handler;
1806
+
1807
+ const $inputContainer = PanelInput.$el.querySelector<HTMLElement>(".pops-panel-input")!;
1808
+ PopsSafeUtils.setSafeHTML($customInputSelecItem, "");
1809
+
1810
+ $customInputSelecItem.appendChild($inputContainer);
1811
+ // 添加到confirm中
1812
+ $selectContainer.appendChild($customInputSelecItem);
1813
+ // 设置项的点击事件
1814
+ this.onSelectItemClick(customInputDataOption, $customInputSelecItem);
1815
+ } else {
1816
+ const $select = this.createSelectItemElement(item);
1817
+ // 添加到confirm中
1818
+ $selectContainer.appendChild($select);
1819
+ // 设置项的点击事件
1820
+ this.onSelectItemClick(item, $select);
1821
+ }
1822
+ });
1823
+ this.$el.$selectDialogContainer = $selectContainer;
1824
+ // 初始化状态
1825
+ this.updateAllSelectItemStatus();
1826
+ });
1827
+ },
1828
+ /**
1829
+ * 选中的值改变的回调
1830
+ * @param data 当前的选中信息
1831
+ */
1832
+ onValueChangeCallback(data?: PopsPanelSelectDataOption<any>, isUpdateSelectItem: boolean = true) {
1833
+ // 动态更新禁用状态、选中状态
1834
+ isUpdateSelectItem && this.updateAllSelectItemStatus();
1835
+ // 触发回调
1569
1836
  if (typeof viewConfig.callback === "function") {
1570
- viewConfig.callback(event, selectInfo.value, selectInfo.text);
1837
+ viewConfig.callback(data || this.$data.selectedData!);
1838
+ }
1839
+ },
1840
+ /**
1841
+ * 更新选项弹窗内的所有选项元素的状态
1842
+ *
1843
+ * + 更新禁用状态
1844
+ * + 更新选中状态
1845
+ */
1846
+ updateAllSelectItemStatus() {
1847
+ const allSelectItems = this.getAllSelectItems(false);
1848
+ allSelectItems.forEach(($selectInfo) => {
1849
+ const { data, $select } = $selectInfo;
1850
+ // 更新文字
1851
+ this.setSelectItemText(data, $selectInfo.$select);
1852
+ if (typeof data.disable === "function" && data.disable(data.value, this.$data.selectedData)) {
1853
+ // 移除选中状态
1854
+ this.removeItemSelected($select);
1855
+ // 禁用
1856
+ this.setSelectItemDisabled($select);
1857
+ } else {
1858
+ // 移除禁用状态
1859
+ this.removeSelectItemDisabled($select);
1860
+ }
1861
+ // 根据当前已选择的信息,判断并更新选中状态
1862
+ if (this.$data.selectedData != null && this.$data.selectedData.value === data.value) {
1863
+ // 就是这个项
1864
+ // 设置选中
1865
+ this.setItemSelected($select);
1866
+ } else {
1867
+ // 不是这个项
1868
+ // 移除选中状态
1869
+ this.removeItemSelected($select);
1870
+ }
1871
+ });
1872
+ },
1873
+ /**
1874
+ * 重置所有已选中的项以下状态
1875
+ *
1876
+ * + 更新选项显示的文字
1877
+ * + 移除禁用状态
1878
+ * + 移除选中状态
1879
+ */
1880
+ resetAllSelectedItemStatus() {
1881
+ const allSelectedItems = this.getAllSelectItems(true);
1882
+ if (allSelectedItems.length) {
1883
+ // 移除选中信息
1884
+ this.resetCurrentSelectedInfo();
1885
+ }
1886
+ allSelectedItems.forEach(($selectInfo) => {
1887
+ const { data, $select } = $selectInfo;
1888
+ // 更新文字
1889
+ this.setSelectItemText(data, $selectInfo.$select);
1890
+ // 移除选中状态
1891
+ this.removeItemSelected($select);
1892
+ // 取消禁用
1893
+ this.removeSelectItemDisabled($select);
1894
+ });
1895
+ },
1896
+ /**
1897
+ * 设置选项元素选中
1898
+ * @param $el 选项元素
1899
+ */
1900
+ setItemSelected($el: HTMLElement) {
1901
+ if (this.isItemSelected($el)) return;
1902
+ $el.classList.add("select-item-is-selected");
1903
+ },
1904
+ /**
1905
+ * 移除选项元素选中
1906
+ * @param $el 选项元素
1907
+ */
1908
+ removeItemSelected($el: HTMLElement) {
1909
+ $el.classList.remove("select-item-is-selected");
1910
+ },
1911
+ /**
1912
+ * 判断选项元素是否选中
1913
+ * @param $el
1914
+ */
1915
+ isItemSelected($el: HTMLElement): boolean {
1916
+ return $el.classList.contains("select-item-is-selected");
1917
+ },
1918
+ /**
1919
+ * 添加选中信息
1920
+ * @param data 选择项的数据
1921
+ * @param [triggerValueChangeCallBack=true] 主动触发值改变回调
1922
+ */
1923
+ addSelectedItemInfo(data: PopsPanelSelectDataOption<any>) {
1924
+ this.resetCurrentSelectedInfo();
1925
+ this.updateSelectedInfo(data);
1926
+ this.onValueChangeCallback(data);
1927
+ },
1928
+ /**
1929
+ * 获取项上存储的信息
1930
+ * @param $el 选项元素
1931
+ */
1932
+ getItemDataOption($el: HTMLElement): PopsPanelSelectDataOption<any> {
1933
+ return Reflect.get($el, "data-info");
1934
+ },
1935
+ /**
1936
+ * 移除选中信息
1937
+ * @param data 选择项的数据
1938
+ */
1939
+ removeSelectedItemInfo() {
1940
+ // 删除
1941
+ this.updateSelectedInfo();
1942
+ this.onValueChangeCallback();
1943
+ },
1944
+ /**
1945
+ * 更新选中信息
1946
+ * @param data 数据
1947
+ */
1948
+ updateSelectedInfo(data?: PopsPanelSelectDataOption<any>) {
1949
+ // 先删除再赋值
1950
+ this.$data.selectedData = void 0;
1951
+ if (data) {
1952
+ if (data.addCustomInput && data.value.toString() === "") {
1953
+ // 自定义输入框,但是内容是空字符串
1954
+ // 不更新选中信息
1955
+ return;
1956
+ }
1957
+ this.$data.selectedData = data;
1571
1958
  }
1572
- const views = typeof selectInfo.views === "function" ? selectInfo.views() : selectInfo.views;
1573
- if (Array.isArray(views)) {
1574
- // 如果成功创建,加入到中间容器中
1575
- const childUListClassName = "pops-panel-select-child-forms";
1576
- // 移除旧的元素
1577
- while ($li.nextElementSibling) {
1578
- if ($li.nextElementSibling.classList.contains(childUListClassName)) {
1579
- $li.nextElementSibling.remove();
1959
+ },
1960
+ /**
1961
+ * 从保存的已选中的信息列表中移除目标信息
1962
+ */
1963
+ resetCurrentSelectedInfo() {
1964
+ this.updateSelectedInfo();
1965
+ },
1966
+ /**
1967
+ * 获取所有选项的信息
1968
+ * @param [onlySelected=true] 是否仅获取选中的项的信息
1969
+ * + true (默认)仅获取选中项的信息
1970
+ * + false 获取所有选择项的信息
1971
+ */
1972
+ getAllSelectItems(onlySelected: boolean = true) {
1973
+ return Array.from(this.$el.$selectDialogContainer?.querySelectorAll<HTMLElement>(".select-item") ?? [])
1974
+ .map(($select) => {
1975
+ const data = this.getItemDataOption($select);
1976
+ const result = {
1977
+ /** 选项信息数据 */
1978
+ data: data,
1979
+ /** 选项元素 */
1980
+ $select: $select,
1981
+ };
1982
+ if (onlySelected) {
1983
+ // 仅选中
1984
+ const isSelected = this.isItemSelected($select);
1985
+ if (isSelected) {
1986
+ return result;
1987
+ }
1988
+ return;
1580
1989
  } else {
1581
- break;
1990
+ return result;
1582
1991
  }
1992
+ })
1993
+ .filter((item) => {
1994
+ return item != null;
1995
+ });
1996
+ },
1997
+ /**
1998
+ * 创建一个选择项元素
1999
+ * @param data 选择项的数据
2000
+ */
2001
+ createSelectItemElement(data: PopsPanelSelectDataOption<any>) {
2002
+ const $select = popsDOMUtils.createElement("li", {
2003
+ className: "select-item",
2004
+ innerHTML: /*html*/ `<span class="select-item-text"></span>`,
2005
+ });
2006
+ this.setSelectItemText(data, $select);
2007
+ Reflect.set($select, "data-info", data);
2008
+ return $select;
2009
+ },
2010
+ /**
2011
+ * 设置选择项的文字
2012
+ * @param data 选择项的数据
2013
+ * @param $select 选择项元素
2014
+ */
2015
+ setSelectItemText(data: PopsPanelSelectDataOption<any>, $select: HTMLElement) {
2016
+ const text = typeof data.text === "function" ? data.text(data.value, this.$data.selectedData) : data.text;
2017
+ const $selectSpan = $select.querySelector<HTMLElement>(".select-item-text");
2018
+ if (!$selectSpan) return;
2019
+ if (data.isHTML) {
2020
+ PopsSafeUtils.setSafeHTML($selectSpan, text);
2021
+ } else {
2022
+ $selectSpan.innerText = text;
2023
+ }
2024
+ },
2025
+ /**
2026
+ * 设置选择项禁用
2027
+ * @param $select 选择项元素
2028
+ */
2029
+ setSelectItemDisabled($select: HTMLElement) {
2030
+ $select.setAttribute("aria-disabled", "true");
2031
+ $select.setAttribute("disabled", "true");
2032
+ },
2033
+ /**
2034
+ * 移除选择项的禁用状态
2035
+ * @param $select 选择项元素
2036
+ */
2037
+ removeSelectItemDisabled($select: HTMLElement) {
2038
+ $select.removeAttribute("aria-disabled");
2039
+ $select.removeAttribute("disabled");
2040
+ },
2041
+ /**
2042
+ * 判断选择项是否禁用
2043
+ * @param $select 选择项元素
2044
+ */
2045
+ isSelectItemDisabled($select: HTMLElement) {
2046
+ return $select.hasAttribute("disabled") || $select.ariaDisabled;
2047
+ },
2048
+ /**
2049
+ * 设置选择项的点击事件
2050
+ * @param data 该选择项的信息
2051
+ * @param $select 该选择项元素
2052
+ */
2053
+ onSelectItemClick(data: PopsPanelSelectDataOption<any> | undefined, $select: HTMLElement) {
2054
+ const updateCustomInputStatus = () => {
2055
+ this.setItemSelected($select);
2056
+ this.addSelectedItemInfo(data!);
2057
+ };
2058
+ popsDOMUtils.on<PointerEvent | MouseEvent>($select, "click", (event) => {
2059
+ popsDOMUtils.preventEvent(event);
2060
+ const $click = event.target as HTMLElement;
2061
+ if (data?.addCustomInput && $click instanceof HTMLInputElement) {
2062
+ // 自定义输入框 单独处理值更新,选中
2063
+ updateCustomInputStatus();
2064
+ return;
2065
+ }
2066
+ if (this.isSelectItemDisabled($select)) {
2067
+ // 被禁用了
2068
+ return;
2069
+ }
2070
+ if (typeof viewConfig.clickCallBack === "function") {
2071
+ const clickResult = viewConfig.clickCallBack(event, this.$data.selectedData!);
2072
+ if (typeof clickResult === "boolean" && !clickResult) {
2073
+ return;
2074
+ }
2075
+ }
2076
+ if (data?.addCustomInput) {
2077
+ // 自定义输入框 添加选中
2078
+ updateCustomInputStatus();
2079
+ } else {
2080
+ // 修改选中状态
2081
+ if (this.isItemSelected($select)) {
2082
+ // 移除选中
2083
+ this.removeItemSelected($select);
2084
+ this.removeSelectedItemInfo();
2085
+ } else {
2086
+ // 添加选中
2087
+ this.setItemSelected($select);
2088
+ this.addSelectedItemInfo(data!);
2089
+ }
2090
+ }
2091
+ });
2092
+ },
2093
+ /** 显示输入框 */
2094
+ showInputWrapper() {
2095
+ popsDOMUtils.cssShow(this.$el.$selectedInputWrapper);
2096
+ },
2097
+ /** 隐藏输入框 */
2098
+ hideInputWrapper() {
2099
+ popsDOMUtils.cssHide(this.$el.$selectedInputWrapper, true);
2100
+ },
2101
+ /** 显示palceholder */
2102
+ showPlaceHolderWrapper() {
2103
+ popsDOMUtils.cssShow(this.$el.$selectedPlaceHolderWrapper);
2104
+ },
2105
+ /** 隐藏palceholder */
2106
+ hidePlaceHolderWrapper() {
2107
+ popsDOMUtils.cssHide(this.$el.$selectedPlaceHolderWrapper, true);
2108
+ },
2109
+ };
2110
+ PopsPanelSelect.init();
2111
+ Reflect.set($li, "data-select", PopsPanelSelect);
2112
+ handler = PopsPanelSelect;
2113
+ } else {
2114
+ const PopsPanelSelectNative = {
2115
+ [Symbol.toStringTag]: "PopsPanelSelectNative",
2116
+ $el: {
2117
+ itemLeftTextContainer: $li.querySelector<HTMLElement>(".pops-panel-item-left-text"),
2118
+ panelSelect: $li.querySelector<HTMLDivElement>(".pops-panel-select")!,
2119
+ select: $li.querySelector<HTMLSelectElement>(".pops-panel-select select")!,
2120
+ },
2121
+ $eleKey: {
2122
+ disable: "__disable__",
2123
+ value: "__value__",
2124
+ viewConfig: "data-view-config",
2125
+ },
2126
+ $data: {
2127
+ data: [] as PopsPanelSelectDataOption<any>[],
2128
+ defaultValue: viewConfig.getValue(),
2129
+ },
2130
+ init() {
2131
+ this.$data.data = typeof viewConfig.data === "function" ? viewConfig.data() : viewConfig.data;
2132
+ popsDOMUtils.addClassName(this.$el.panelSelect, PopsCommonCSSClassName.userSelectNone);
2133
+ this.initOption();
2134
+ this.onValueChange();
2135
+ this.onClick();
2136
+ const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
2137
+ if (disabled) {
2138
+ this.disable();
2139
+ }
2140
+ },
2141
+ /**
2142
+ * 给option元素设置属性
2143
+ * @param $ele
2144
+ * @param key
2145
+ * @param value
2146
+ */
2147
+ setNodeValue($ele: HTMLElement, key: string, value: any) {
2148
+ Reflect.set($ele, key, value);
2149
+ },
2150
+ /**
2151
+ * 获取option元素上设置的属性
2152
+ * @param $ele
2153
+ * @param value
2154
+ * @param key
2155
+ */
2156
+ getNodeValue($ele: HTMLElement, key: string) {
2157
+ return Reflect.get($ele, key);
2158
+ },
2159
+ /**
2160
+ * 禁用选项
2161
+ */
2162
+ disable() {
2163
+ this.$el.select.setAttribute("disabled", "true");
2164
+ popsDOMUtils.addClassName(this.$el.panelSelect, "pops-panel-select-disable");
2165
+ popsDOMUtils.addClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
2166
+ },
2167
+ /**
2168
+ * 取消禁用
2169
+ */
2170
+ notDisable() {
2171
+ this.$el.select.removeAttribute("disabled");
2172
+ popsDOMUtils.removeClassName(this.$el.panelSelect, "pops-panel-select-disable");
2173
+ popsDOMUtils.removeClassName(this.$el.itemLeftTextContainer, PopsCommonCSSClassName.textIsDisabled);
2174
+ },
2175
+ /**
2176
+ * 判断是否禁用
2177
+ */
2178
+ isDisabled() {
2179
+ return (
2180
+ this.$el.select.hasAttribute("disabled") ||
2181
+ popsDOMUtils.containsClassName(this.$el.panelSelect, "pops-panel-select-disable")
2182
+ );
2183
+ },
2184
+ /**
2185
+ * 初始化选项
2186
+ */
2187
+ initOption() {
2188
+ this.$data.data.forEach((dataItem) => {
2189
+ // 初始化默认选中
2190
+ const optionElement = popsDOMUtils.createElement("option");
2191
+ this.setNodeValue(optionElement, this.$eleKey.value, dataItem.value);
2192
+ this.setNodeValue(optionElement, this.$eleKey.disable, dataItem.disable);
2193
+ this.setNodeValue(optionElement, this.$eleKey.viewConfig, dataItem.views);
2194
+ if (dataItem.value === this.$data.defaultValue) {
2195
+ this.setOptionSelected(optionElement);
1583
2196
  }
1584
- const $childUList = popsDOMUtils.createElement("ul");
1585
- $childUList.className = childUListClassName;
1586
- popsDOMUtils.after($li, $childUList);
1587
- that.uListContainerAddItem(viewConfig, {
1588
- ulElement: $childUList,
2197
+ if (typeof dataItem.text === "function") {
2198
+ optionElement.innerText = dataItem.text(dataItem.value, dataItem);
2199
+ } else {
2200
+ optionElement.innerText = dataItem.text;
2201
+ }
2202
+ this.$el.select.appendChild(optionElement);
2203
+ });
2204
+ },
2205
+ /**
2206
+ * 设置选项选中
2207
+ * @param $option
2208
+ */
2209
+ setOptionSelected($option: HTMLOptionElement) {
2210
+ $option.setAttribute("selected", "true");
2211
+ },
2212
+ /**
2213
+ * 检测所有option并设置禁用状态
2214
+ */
2215
+ setSelectOptionsDisableStatus() {
2216
+ if (this.$el.select.options && this.$el.select.options.length) {
2217
+ Array.from(this.$el.select.options).forEach((optionItem) => {
2218
+ this.setOptionDisableStatus(optionItem);
1589
2219
  });
1590
2220
  }
1591
- });
1592
- },
1593
- /**
1594
- * 监听点击事件
1595
- */
1596
- setClickEvent() {
1597
- popsDOMUtils.on(this.$ele.select, "click", void 0, (event) => {
1598
- this.setSelectOptionsDisableStatus();
1599
- if (typeof viewConfig.clickCallBack === "function") {
1600
- viewConfig.clickCallBack(event, this.$ele.select);
2221
+ },
2222
+ /**
2223
+ * 设置禁用状态
2224
+ * @param $option
2225
+ */
2226
+ setOptionDisableStatus($option: HTMLOptionElement) {
2227
+ let disable = false;
2228
+ const optionDisableAttr = this.getNodeValue($option, this.$eleKey.disable);
2229
+ if (optionDisableAttr === "function") {
2230
+ const value = this.getNodeValue($option, this.$eleKey.value);
2231
+ disable = Boolean(optionDisableAttr(value));
1601
2232
  }
1602
- });
1603
- },
1604
- };
2233
+ if (disable) {
2234
+ $option.setAttribute("disabled", "true");
2235
+ } else {
2236
+ $option.removeAttribute("disabled");
2237
+ }
2238
+ },
2239
+ /**
2240
+ * 获取option上的信息
2241
+ * @param $option
2242
+ */
2243
+ getSelectOptionInfo($option: HTMLOptionElement) {
2244
+ const optionValue = this.getNodeValue($option, this.$eleKey.value);
2245
+ const optionText = $option.innerText || $option.textContent!;
2246
+ const views = this.getNodeValue($option, this.$eleKey.viewConfig) as NonNullable<
2247
+ PopsPanelSelectDataOption<any>["views"]
2248
+ >;
2249
+ return {
2250
+ value: optionValue,
2251
+ text: optionText,
2252
+ views: views,
2253
+ $option: $option,
2254
+ };
2255
+ },
2256
+ /**
2257
+ * 监听选择内容改变
2258
+ */
2259
+ onValueChange() {
2260
+ popsDOMUtils.on<PointerEvent | TouchEvent>(this.$el.select, "change", () => {
2261
+ const $isSelectedElement = this.$el.select[this.$el.select.selectedIndex] as HTMLOptionElement;
2262
+ const selectInfo = this.getSelectOptionInfo($isSelectedElement);
2263
+ this.setSelectOptionsDisableStatus();
2264
+ if (typeof viewConfig.callback === "function") {
2265
+ viewConfig.callback(selectInfo);
2266
+ }
2267
+ const views = typeof selectInfo.views === "function" ? selectInfo.views() : selectInfo.views;
2268
+ if (Array.isArray(views)) {
2269
+ // 如果成功创建,加入到中间容器中
2270
+ const childUListClassName = "pops-panel-select-child-forms";
2271
+ // 移除旧的元素
2272
+ while ($li.nextElementSibling) {
2273
+ if ($li.nextElementSibling.classList.contains(childUListClassName)) {
2274
+ $li.nextElementSibling.remove();
2275
+ } else {
2276
+ break;
2277
+ }
2278
+ }
2279
+ const $childUList = popsDOMUtils.createElement("ul");
2280
+ $childUList.className = childUListClassName;
2281
+ popsDOMUtils.after($li, $childUList);
2282
+ that.uListContainerAddItem(viewConfig, {
2283
+ ulElement: $childUList,
2284
+ });
2285
+ }
2286
+ });
2287
+ },
2288
+ /**
2289
+ * 监听点击事件
2290
+ */
2291
+ onClick() {
2292
+ popsDOMUtils.on(this.$el.select, "click", void 0, (event) => {
2293
+ this.setSelectOptionsDisableStatus();
2294
+ if (typeof viewConfig.clickCallBack === "function") {
2295
+ const $isSelectedElement = this.$el.select[this.$el.select.selectedIndex] as HTMLOptionElement;
2296
+ const selectInfo = this.getSelectOptionInfo($isSelectedElement);
2297
+ viewConfig.clickCallBack(event, selectInfo);
2298
+ }
2299
+ });
2300
+ },
2301
+ };
1605
2302
 
1606
- PopsPanelSelect.init();
1607
- Reflect.set($li, "data-select", PopsPanelSelect);
1608
- return $li;
2303
+ PopsPanelSelectNative.init();
2304
+ Reflect.set($li, "data-select", PopsPanelSelectNative);
2305
+ handler = PopsPanelSelectNative;
2306
+ }
2307
+ return {
2308
+ $el: $li,
2309
+ handler: handler,
2310
+ };
1609
2311
  },
1610
2312
  /**
1611
2313
  * type ==> select-multiple
@@ -1677,9 +2379,9 @@ export const PanelHandlerComponents = () => {
1677
2379
  /** 默认值 */
1678
2380
  defaultValue: viewConfig.getValue(),
1679
2381
  /**
1680
- * 选择的信息
2382
+ * 已选择的信息
1681
2383
  */
1682
- selectInfo: [] as PopsPanelSelectMultipleDataOption<any>[],
2384
+ selectedDataList: [] as PopsPanelSelectMultipleDataOption<any>[],
1683
2385
  /**
1684
2386
  * 箭头旋转的属性
1685
2387
  */
@@ -1691,7 +2393,7 @@ export const PanelHandlerComponents = () => {
1691
2393
  this.inintEl();
1692
2394
  this.initPlaceHolder();
1693
2395
  this.initTagElement();
1694
- this.setSelectContainerClickEvent();
2396
+ this.onShowSelectDialogClick();
1695
2397
 
1696
2398
  const disabled = typeof viewConfig.disabled === "function" ? viewConfig.disabled() : viewConfig.disabled;
1697
2399
  if (disabled) {
@@ -1703,12 +2405,7 @@ export const PanelHandlerComponents = () => {
1703
2405
  viewConfig.data.forEach((dataItem) => {
1704
2406
  if (this.$data.defaultValue.includes(dataItem.value)) {
1705
2407
  // 初始化选中的配置
1706
- this.$data.selectInfo.push({
1707
- text: dataItem.text,
1708
- value: dataItem.value,
1709
- isHTML: Boolean(dataItem.isHTML),
1710
- disable: dataItem.disable?.bind(dataItem),
1711
- });
2408
+ this.$data.selectedDataList.push(dataItem);
1712
2409
  }
1713
2410
  });
1714
2411
  },
@@ -1729,7 +2426,9 @@ export const PanelHandlerComponents = () => {
1729
2426
  // 先把手动输入框隐藏
1730
2427
  this.hideInputWrapper();
1731
2428
  },
1732
- /** 初始化提示文字 */
2429
+ /**
2430
+ * 初始化提示文字
2431
+ */
1733
2432
  initPlaceHolder() {
1734
2433
  let placeholder = "";
1735
2434
  if (typeof viewConfig.placeholder === "string") {
@@ -1745,16 +2444,18 @@ export const PanelHandlerComponents = () => {
1745
2444
  });
1746
2445
  this.$el.$selectedPlaceHolderWrapper.appendChild($placeholder);
1747
2446
  },
1748
- /** 初始化tag元素 */
2447
+ /**
2448
+ * 初始化tag元素
2449
+ */
1749
2450
  initTagElement() {
1750
2451
  // 遍历数据,寻找对应的值
1751
2452
  viewConfig.data.forEach((dataItem) => {
1752
- const findValue = this.$data.selectInfo.find((item) => item.value === dataItem.value);
2453
+ const findValue = this.$data.selectedDataList.find((item) => item.value === dataItem.value);
1753
2454
  if (findValue) {
1754
2455
  // 存在对应的值
1755
- const selectedInfo = this.createSelectedTagItem(dataItem);
1756
- this.addSelectedTagItem(selectedInfo.$tag);
1757
- this.setSelectedItemCloseIconClickEvent({
2456
+ const selectedInfo = this.createTagItem(dataItem);
2457
+ this.addTagItem(selectedInfo.$tag);
2458
+ this.onSelectItemCloseIconClick({
1758
2459
  $tag: selectedInfo.$tag,
1759
2460
  $closeIcon: selectedInfo.$closeIcon,
1760
2461
  value: dataItem.value,
@@ -1768,8 +2469,8 @@ export const PanelHandlerComponents = () => {
1768
2469
  * 生成一个tag项
1769
2470
  * @param data 配置
1770
2471
  */
1771
- createSelectedTagItem(data: PopsPanelSelectMultipleDataOption<any>) {
1772
- const $selectedItem = popsDOMUtils.createElement("div", {
2472
+ createTagItem(data: PopsPanelSelectMultipleDataOption<any>) {
2473
+ const $tag = popsDOMUtils.createElement("div", {
1773
2474
  className: "el-select__selected-item el-select__choose_tag",
1774
2475
  innerHTML: /*html*/ `
1775
2476
  <span class="el-tag is-closable el-tag--info el-tag--default el-tag--light">
@@ -1786,10 +2487,10 @@ export const PanelHandlerComponents = () => {
1786
2487
  `,
1787
2488
  });
1788
2489
  /** 标签 */
1789
- const $tagText = $selectedItem.querySelector<HTMLSpanElement>(".el-select__tags-text")!;
2490
+ const $tagText = $tag.querySelector<HTMLSpanElement>(".el-select__tags-text")!;
1790
2491
  /** 关闭图标 */
1791
- const $closeIcon = $selectedItem.querySelector<HTMLElement>(".el-icon.el-tag__close")!;
1792
- const text = typeof data.text === "function" ? data.text(data, this.$data.selectInfo) : data.text;
2492
+ const $closeIcon = $tag.querySelector<HTMLElement>(".el-icon.el-tag__close")!;
2493
+ const text = typeof data.text === "function" ? data.text(data, this.$data.selectedDataList) : data.text;
1793
2494
  if (data.isHTML) {
1794
2495
  PopsSafeUtils.setSafeHTML($tagText, text);
1795
2496
  } else {
@@ -1797,7 +2498,7 @@ export const PanelHandlerComponents = () => {
1797
2498
  }
1798
2499
 
1799
2500
  return {
1800
- $tag: $selectedItem,
2501
+ $tag: $tag,
1801
2502
  $tagText: $tagText,
1802
2503
  $closeIcon: $closeIcon,
1803
2504
  };
@@ -1806,7 +2507,7 @@ export const PanelHandlerComponents = () => {
1806
2507
  * 添加选中项的tag元素
1807
2508
  * @param $tag 添加的元素
1808
2509
  */
1809
- addSelectedTagItem($tag: HTMLElement) {
2510
+ addTagItem($tag: HTMLElement) {
1810
2511
  // 往前添加
1811
2512
  // 去除前面的空白
1812
2513
  this.setSectionIsNear();
@@ -1835,8 +2536,10 @@ export const PanelHandlerComponents = () => {
1835
2536
  this.hideInputWrapper();
1836
2537
  this.hidePlaceHolderWrapper();
1837
2538
  },
1838
- /** 更新tag信息 */
1839
- updateSelectTagItem() {
2539
+ /**
2540
+ * 更新tag信息
2541
+ */
2542
+ updateTagItem() {
1840
2543
  this.$el.$section.querySelectorAll<HTMLElement>(".el-select__choose_tag").forEach(($ele) => {
1841
2544
  $ele.remove();
1842
2545
  });
@@ -1846,11 +2549,11 @@ export const PanelHandlerComponents = () => {
1846
2549
  * 选中的值改变的回调
1847
2550
  * @param selectedDataList 当前的选中信息
1848
2551
  */
1849
- selectValueChangeCallBack(selectedDataList?: PopsPanelSelectMultipleDataOption<any>[]) {
2552
+ onValueChange(selectedDataList?: PopsPanelSelectMultipleDataOption<any>[]) {
1850
2553
  // 动态更新禁用状态
1851
- this.updateSelectItem();
2554
+ this.updateAllSelectItems();
1852
2555
  if (typeof viewConfig.callback === "function") {
1853
- viewConfig.callback(selectedDataList || this.$data.selectInfo);
2556
+ viewConfig.callback(selectedDataList || this.$data.selectedDataList);
1854
2557
  }
1855
2558
  },
1856
2559
  /**
@@ -1859,29 +2562,29 @@ export const PanelHandlerComponents = () => {
1859
2562
  * + 更新禁用状态
1860
2563
  * + 更新选中状态
1861
2564
  */
1862
- updateSelectItem() {
2565
+ updateAllSelectItems() {
1863
2566
  this.getAllSelectItemInfo(false).forEach(($selectInfo) => {
1864
2567
  const { data, $select } = $selectInfo;
1865
2568
  // 更新文字
1866
2569
  this.setSelectItemText(data, $selectInfo.$select);
1867
2570
  // 更新禁用状态
1868
- if (typeof data.disable === "function" && data.disable(data.value, this.$data.selectInfo)) {
2571
+ if (typeof data.disable === "function" && data.disable(data.value, this.$data.selectedDataList)) {
1869
2572
  // 禁用
1870
- this.setSelectItemDisabled($select);
2573
+ this.disableSelectItem($select);
1871
2574
  // 移除选中信息
1872
2575
  this.removeSelectedInfo(data, false);
1873
2576
  // 移除选中状态
1874
- this.removeSelectItemSelected($select);
2577
+ this.removeItemSelected($select);
1875
2578
  } else {
1876
2579
  // 取消禁用
1877
- this.removeSelectItemDisabled($select);
2580
+ this.cancleDisableSelectItem($select);
1878
2581
  }
1879
2582
  // 更新选中状态
1880
- const findValue = this.$data.selectInfo.find((it) => it.value === data.value);
2583
+ const findValue = this.$data.selectedDataList.find((it) => it.value === data.value);
1881
2584
  if (findValue) {
1882
- this.setSelectItemSelected($select);
2585
+ this.setItemSelected($select);
1883
2586
  } else {
1884
- this.removeSelectItemSelected($select);
2587
+ this.removeItemSelected($select);
1885
2588
  }
1886
2589
  });
1887
2590
  },
@@ -1889,22 +2592,22 @@ export const PanelHandlerComponents = () => {
1889
2592
  * 设置选项元素选中
1890
2593
  * @param $select 选项元素
1891
2594
  */
1892
- setSelectItemSelected($select: HTMLElement) {
1893
- if (this.isSelectItemSelected($select)) return;
2595
+ setItemSelected($select: HTMLElement) {
2596
+ if (this.isItemSelected($select)) return;
1894
2597
  $select.classList.add("select-item-is-selected");
1895
2598
  },
1896
2599
  /**
1897
2600
  * 移除选项元素选中
1898
2601
  * @param $select 选项元素
1899
2602
  */
1900
- removeSelectItemSelected($select: HTMLElement) {
2603
+ removeItemSelected($select: HTMLElement) {
1901
2604
  $select.classList.remove("select-item-is-selected");
1902
2605
  },
1903
2606
  /**
1904
2607
  * 判断选项元素是否选中
1905
2608
  * @param $select
1906
2609
  */
1907
- isSelectItemSelected($select: HTMLElement): boolean {
2610
+ isItemSelected($select: HTMLElement): boolean {
1908
2611
  return $select.classList.contains("select-item-is-selected");
1909
2612
  },
1910
2613
  /**
@@ -1912,25 +2615,20 @@ export const PanelHandlerComponents = () => {
1912
2615
  * @param dataList 选择项列表的数据
1913
2616
  * @param $select 选项元素
1914
2617
  */
1915
- addSelectedItemInfo(dataList: PopsPanelSelectMultipleDataOption<any>[], $select: HTMLElement) {
2618
+ addItemSelected(dataList: PopsPanelSelectMultipleDataOption<any>[], $select: HTMLElement) {
1916
2619
  const info = this.getSelectedItemInfo($select);
1917
2620
  const findValue = dataList.find((item) => item.value === info.value);
1918
2621
  if (!findValue) {
1919
- dataList.push({
1920
- value: info.value,
1921
- text: info.text,
1922
- isHTML: Boolean(info.isHTML),
1923
- disable: info.disable?.bind(info),
1924
- });
2622
+ dataList.push(info);
1925
2623
  }
1926
- this.selectValueChangeCallBack(dataList);
2624
+ this.onValueChange(dataList);
1927
2625
  },
1928
2626
  /**
1929
2627
  * 获取选中的项的信息
1930
2628
  * @param $select 选项元素
1931
2629
  */
1932
- getSelectedItemInfo($select: HTMLElement) {
1933
- return Reflect.get($select, "data-info") as PopsPanelSelectMultipleDataOption<any>;
2630
+ getSelectedItemInfo($select: HTMLElement): PopsPanelSelectMultipleDataOption<any> {
2631
+ return Reflect.get($select, "data-info");
1934
2632
  },
1935
2633
  /**
1936
2634
  * 移除选中信息
@@ -1943,7 +2641,7 @@ export const PanelHandlerComponents = () => {
1943
2641
  if (findIndex !== -1) {
1944
2642
  dataList.splice(findIndex, 1);
1945
2643
  }
1946
- this.selectValueChangeCallBack(dataList);
2644
+ this.onValueChange(dataList);
1947
2645
  },
1948
2646
  /**
1949
2647
  * 获取所有选项的信息
@@ -1963,7 +2661,7 @@ export const PanelHandlerComponents = () => {
1963
2661
  };
1964
2662
  if (onlySelected) {
1965
2663
  // 仅选中
1966
- const isSelected = this.isSelectItemSelected($select);
2664
+ const isSelected = this.isItemSelected($select);
1967
2665
  if (isSelected) {
1968
2666
  return result;
1969
2667
  }
@@ -1997,7 +2695,7 @@ export const PanelHandlerComponents = () => {
1997
2695
  * @param $select 选择项元素
1998
2696
  */
1999
2697
  setSelectItemText(data: PopsPanelSelectMultipleDataOption<any>, $select: HTMLElement) {
2000
- const text = typeof data.text === "function" ? data.text(data.value, this.$data.selectInfo) : data.text;
2698
+ const text = typeof data.text === "function" ? data.text(data.value, this.$data.selectedDataList) : data.text;
2001
2699
  const $selectSpan = $select.querySelector<HTMLElement>(".select-item-text")!;
2002
2700
  if (data.isHTML) {
2003
2701
  PopsSafeUtils.setSafeHTML($selectSpan, text);
@@ -2009,7 +2707,7 @@ export const PanelHandlerComponents = () => {
2009
2707
  * 设置选择项的禁用状态
2010
2708
  * @param $select 选择项元素
2011
2709
  */
2012
- setSelectItemDisabled($select: HTMLElement) {
2710
+ disableSelectItem($select: HTMLElement) {
2013
2711
  $select.setAttribute("aria-disabled", "true");
2014
2712
  $select.setAttribute("disabled", "true");
2015
2713
  },
@@ -2017,7 +2715,7 @@ export const PanelHandlerComponents = () => {
2017
2715
  * 移除选择项的禁用状态
2018
2716
  * @param $select 选择项元素
2019
2717
  */
2020
- removeSelectItemDisabled($select: HTMLElement) {
2718
+ cancleDisableSelectItem($select: HTMLElement) {
2021
2719
  $select.removeAttribute("aria-disabled");
2022
2720
  $select.removeAttribute("disabled");
2023
2721
  },
@@ -2033,7 +2731,7 @@ export const PanelHandlerComponents = () => {
2033
2731
  * @param dataList 选中的信息列表
2034
2732
  * @param $select 选择项元素
2035
2733
  */
2036
- setSelectElementClickEvent(dataList: PopsPanelSelectMultipleDataOption<any>[], $select: HTMLElement) {
2734
+ onSelectItemClick(dataList: PopsPanelSelectMultipleDataOption<any>[], $select: HTMLElement) {
2037
2735
  popsDOMUtils.on<PointerEvent | MouseEvent>($select, "click", (event) => {
2038
2736
  popsDOMUtils.preventEvent(event);
2039
2737
  if (this.isSelectItemDisabled($select)) {
@@ -2047,12 +2745,12 @@ export const PanelHandlerComponents = () => {
2047
2745
  }
2048
2746
  }
2049
2747
  // 修改选中状态
2050
- if (this.isSelectItemSelected($select)) {
2051
- this.removeSelectItemSelected($select);
2748
+ if (this.isItemSelected($select)) {
2749
+ this.removeItemSelected($select);
2052
2750
  this.removeSelectedItemInfo(dataList, $select);
2053
2751
  } else {
2054
- this.setSelectItemSelected($select);
2055
- this.addSelectedItemInfo(dataList, $select);
2752
+ this.setItemSelected($select);
2753
+ this.addItemSelected(dataList, $select);
2056
2754
  }
2057
2755
  });
2058
2756
  },
@@ -2061,79 +2759,18 @@ export const PanelHandlerComponents = () => {
2061
2759
  *
2062
2760
  * 点击显示下拉列表弹窗
2063
2761
  */
2064
- setSelectContainerClickEvent() {
2065
- const defaultCSS = /*css*/ `
2066
- .select-container{
2067
- --el-font-size-base: 14px;
2068
- --el-text-color-regular: #606266;
2069
- --el-color-primary: #409eff;
2070
- --el-fill-color-light: #f5f7fa;
2071
- --el-disable-color: #a8abb2;
2072
- }
2073
- .select-item{
2074
- cursor: pointer;
2075
- font-size: var(--el-font-size-base);
2076
- padding: 0 32px 0 20px;
2077
- position: relative;
2078
- white-space: nowrap;
2079
- overflow: hidden;
2080
- text-overflow: ellipsis;
2081
- color: var(--el-text-color-regular);
2082
- height: 34px;
2083
- line-height: 34px;
2084
- box-sizing: border-box;
2085
- }
2086
- .select-item[aria-disabled],
2087
- .select-item[disabled]{
2088
- cursor: not-allowed;
2089
- color: var(--el-disable-color);
2090
- background: unset;
2091
- }
2092
- .select-item:hover{
2093
- background-color: var(--el-fill-color-light);
2094
- }
2095
- .select-item.select-item-is-selected{
2096
- color: var(--el-color-primary);
2097
- font-weight: 700;
2098
- }
2099
- .select-item.select-item-is-selected::after{
2100
- content: "";
2101
- position: absolute;
2102
- top: 50%;
2103
- right: 20px;
2104
- border-top: none;
2105
- border-right: none;
2106
- background-repeat: no-repeat;
2107
- background-position: center;
2108
- background-color: var(--el-color-primary);
2109
- mask: url("data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E") no-repeat;
2110
- mask-size: 100% 100%;
2111
- -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E") no-repeat;
2112
- -webkit-mask-size: 100% 100%;
2113
- transform: translateY(-50%);
2114
- width: 12px;
2115
- height: 12px;
2116
- }
2117
-
2118
-
2119
- @media (prefers-color-scheme: dark) {
2120
- .select-container{
2121
- --el-text-color-regular: #f2f2f2;
2122
- --el-disable-color: #8D9095;
2123
- --el-fill-color-light: #262727;
2124
- }
2125
- }
2126
- `;
2762
+ onShowSelectDialogClick() {
2763
+ const defaultCSS = PopsCSS.panelComponents_Select;
2127
2764
  popsDOMUtils.on(this.$el.$container, "click", () => {
2128
2765
  if (this.isDisabled()) {
2129
2766
  return;
2130
2767
  }
2131
2768
  /** 当前已选中的值 */
2132
- const selectInfo = this.$data.selectInfo;
2769
+ const selectInfo = this.$data.selectedDataList;
2133
2770
  const { style, ...userConfirmConfig } = viewConfig.selectConfirmDialogConfig || {};
2134
2771
  const dialogCloseCallback = () => {
2135
- this.$data.selectInfo = [...selectInfo];
2136
- this.updateSelectTagItem();
2772
+ this.$data.selectedDataList = [...selectInfo];
2773
+ this.updateTagItem();
2137
2774
  this.$el.$selectContainer = null;
2138
2775
  this.$el.$container.removeAttribute(this.$data.rotateKey);
2139
2776
  };
@@ -2145,9 +2782,7 @@ export const PanelHandlerComponents = () => {
2145
2782
  position: "center",
2146
2783
  },
2147
2784
  content: {
2148
- text: /*html*/ `
2149
- <ul class="select-container"></ul>
2150
- `,
2785
+ text: /*html*/ `<ul class="select-container"></ul>`,
2151
2786
  html: true,
2152
2787
  },
2153
2788
  btn: {
@@ -2175,7 +2810,7 @@ export const PanelHandlerComponents = () => {
2175
2810
  drag: true,
2176
2811
  dragLimit: true,
2177
2812
  width: "300px",
2178
- height: "300px",
2813
+ height: "auto",
2179
2814
  style: /*css*/ `
2180
2815
  ${defaultCSS}
2181
2816
 
@@ -2192,18 +2827,18 @@ export const PanelHandlerComponents = () => {
2192
2827
  // 添加到confirm中
2193
2828
  $selectContainer.appendChild($select);
2194
2829
  // 设置每一项的点击事件
2195
- this.setSelectElementClickEvent(selectInfo, $select);
2830
+ this.onSelectItemClick(selectInfo, $select);
2196
2831
  });
2197
2832
  this.$el.$selectContainer = $selectContainer;
2198
2833
  // 动态更新禁用状态
2199
- this.updateSelectItem();
2834
+ this.updateAllSelectItems();
2200
2835
  });
2201
2836
  },
2202
2837
  /**
2203
2838
  * 设置关闭图标的点击事件
2204
2839
  * @param data 选中的信息
2205
2840
  */
2206
- setSelectedItemCloseIconClickEvent(data: {
2841
+ onSelectItemCloseIconClick(data: {
2207
2842
  /** 关闭图标的元素 */
2208
2843
  $closeIcon: HTMLElement;
2209
2844
  /** tag元素 */
@@ -2244,7 +2879,9 @@ export const PanelHandlerComponents = () => {
2244
2879
  );
2245
2880
  },
2246
2881
  /**
2247
- * 检测tag是否为空,为空显示placeholder
2882
+ * 检测tag是否为空
2883
+ *
2884
+ * 如果为空则显示placeholder
2248
2885
  */
2249
2886
  checkTagEmpty() {
2250
2887
  if (!this.$el.$section.querySelectorAll(".el-select__choose_tag").length) {
@@ -2269,14 +2906,14 @@ export const PanelHandlerComponents = () => {
2269
2906
  * + false 不触发值改变的回调
2270
2907
  */
2271
2908
  removeSelectedInfo(data: PopsPanelSelectMultipleDataOption<any>, triggerValueChangeCallBack: boolean = true) {
2272
- for (let index = 0; index < this.$data.selectInfo.length; index++) {
2273
- const selectInfo = this.$data.selectInfo[index];
2909
+ for (let index = 0; index < this.$data.selectedDataList.length; index++) {
2910
+ const selectInfo = this.$data.selectedDataList[index];
2274
2911
  if (selectInfo.value === data.value) {
2275
- this.$data.selectInfo.splice(index, 1);
2912
+ this.$data.selectedDataList.splice(index, 1);
2276
2913
  break;
2277
2914
  }
2278
2915
  }
2279
- triggerValueChangeCallBack && this.selectValueChangeCallBack();
2916
+ triggerValueChangeCallBack && this.onValueChange();
2280
2917
  },
2281
2918
  /** 显示输入框 */
2282
2919
  showInputWrapper() {
@@ -2326,7 +2963,10 @@ export const PanelHandlerComponents = () => {
2326
2963
 
2327
2964
  PopsPanelSelectMultiple.init();
2328
2965
  Reflect.set($li, "data-select-multiple", PopsPanelSelectMultiple);
2329
- return $li;
2966
+ return {
2967
+ $el: $li,
2968
+ handler: PopsPanelSelectMultiple,
2969
+ };
2330
2970
  },
2331
2971
  /**
2332
2972
  * type ==> button
@@ -2371,7 +3011,7 @@ export const PanelHandlerComponents = () => {
2371
3011
  init() {
2372
3012
  this.$ele.panelButton.appendChild(this.$ele.button);
2373
3013
  this.initButton();
2374
- this.setClickEvent();
3014
+ this.onButtonClick();
2375
3015
  },
2376
3016
  initButton() {
2377
3017
  if (typeof viewConfig.buttonIcon === "string" && viewConfig.buttonIcon.trim() !== "") {
@@ -2465,7 +3105,10 @@ export const PanelHandlerComponents = () => {
2465
3105
  setButtonText(text: string) {
2466
3106
  PopsSafeUtils.setSafeHTML(this.$ele.spanText, text);
2467
3107
  },
2468
- setClickEvent() {
3108
+ /**
3109
+ * 设置按钮的点击事件
3110
+ */
3111
+ onButtonClick() {
2469
3112
  popsDOMUtils.on(this.$ele.button, "click", void 0, (event) => {
2470
3113
  if (typeof viewConfig.callback === "function") {
2471
3114
  viewConfig.callback(event);
@@ -2475,7 +3118,10 @@ export const PanelHandlerComponents = () => {
2475
3118
  };
2476
3119
  PopsPanelButton.init();
2477
3120
  Reflect.set($li, "data-button", PopsPanelButton);
2478
- return $li;
3121
+ return {
3122
+ $el: $li,
3123
+ handler: PopsPanelButton,
3124
+ };
2479
3125
  },
2480
3126
  /**
2481
3127
  * type ==> deepMenu
@@ -2525,7 +3171,7 @@ export const PanelHandlerComponents = () => {
2525
3171
  },
2526
3172
  },
2527
3173
  init() {
2528
- this.setLiClickEvent();
3174
+ this.onLiClick();
2529
3175
  },
2530
3176
  /**
2531
3177
  * 生成配置每一项的元素
@@ -2748,7 +3394,7 @@ export const PanelHandlerComponents = () => {
2748
3394
  that.triggerRenderRightContainer($deepMenuSection);
2749
3395
  },
2750
3396
  /** 设置项的点击事件 */
2751
- setLiClickEvent() {
3397
+ onLiClick() {
2752
3398
  popsDOMUtils.on($li, "click", void 0, async (event) => {
2753
3399
  if (typeof viewConfig.clickCallBack === "function") {
2754
3400
  const result = await viewConfig.clickCallBack(event, viewConfig);
@@ -2764,7 +3410,10 @@ export const PanelHandlerComponents = () => {
2764
3410
  PopsPanelDeepMenu.init();
2765
3411
  Reflect.set($li, "data-deepMenu", PopsPanelDeepMenu);
2766
3412
 
2767
- return $li;
3413
+ return {
3414
+ $el: $li,
3415
+ handler: PopsPanelDeepMenu,
3416
+ };
2768
3417
  },
2769
3418
  /**
2770
3419
  * type ===> own
@@ -2777,8 +3426,10 @@ export const PanelHandlerComponents = () => {
2777
3426
  this.setElementClassName($li, viewConfig.className);
2778
3427
  this.setElementAttributes($li, viewConfig.attributes);
2779
3428
  this.setElementProps($li, viewConfig.props);
2780
- $li = viewConfig.getLiElementCallBack($li);
2781
- return $li;
3429
+ $li = viewConfig.createLIElement($li);
3430
+ return {
3431
+ $el: $li,
3432
+ };
2782
3433
  },
2783
3434
  /**
2784
3435
  * 获取中间容器的元素<li>
@@ -2789,23 +3440,23 @@ export const PanelHandlerComponents = () => {
2789
3440
  const componentType = viewConfig.type;
2790
3441
 
2791
3442
  if (componentType === "switch") {
2792
- return this.createSectionContainerItem_switch(viewConfig as PopsPanelSwitchConfig);
3443
+ return this.createSectionContainerItem_switch(viewConfig);
2793
3444
  } else if (componentType === "slider") {
2794
- return this.createSectionContainerItem_slider_new(viewConfig as PopsPanelSliderConfig);
3445
+ return this.createSectionContainerItem_slider_new(viewConfig);
2795
3446
  } else if (componentType === "input") {
2796
- return this.createSectionContainerItem_input(viewConfig as PopsPanelInputConfig);
3447
+ return this.createSectionContainerItem_input(viewConfig);
2797
3448
  } else if (componentType === "textarea") {
2798
- return this.createSectionContainerItem_textarea(viewConfig as PopsPanelTextAreaConfig);
3449
+ return this.createSectionContainerItem_textarea(viewConfig);
2799
3450
  } else if (componentType === "select") {
2800
- return this.createSectionContainerItem_select(viewConfig as PopsPanelSelectConfig);
3451
+ return this.createSectionContainerItem_select(viewConfig);
2801
3452
  } else if (componentType === "select-multiple") {
2802
- return this.createSectionContainerItem_select_multiple(viewConfig as PopsPanelSelectMultipleConfig<any>);
3453
+ return this.createSectionContainerItem_select_multiple(viewConfig);
2803
3454
  } else if (componentType === "button") {
2804
- return this.createSectionContainerItem_button(viewConfig as PopsPanelButtonConfig);
3455
+ return this.createSectionContainerItem_button(viewConfig);
2805
3456
  } else if (componentType === "deepMenu") {
2806
- return this.createSectionContainerItem_deepMenu(viewConfig as PopsPanelDeepViewConfig);
3457
+ return this.createSectionContainerItem_deepMenu(viewConfig);
2807
3458
  } else if (componentType === "own") {
2808
- return this.createSectionContainerItem_own(viewConfig as PopsPanelOwnConfig);
3459
+ return this.createSectionContainerItem_own(viewConfig);
2809
3460
  } else {
2810
3461
  console.error("尚未实现的type类型", viewConfig);
2811
3462
  }
@@ -2920,14 +3571,14 @@ export const PanelHandlerComponents = () => {
2920
3571
  viewConfig: PopsPanelViewConfig,
2921
3572
  containerOptions: Omit<PopsPanelRightAsideContainerConfig, "target">
2922
3573
  ) {
2923
- const itemLiElement = this.createSectionContainerItem(viewConfig);
2924
- if (itemLiElement) {
2925
- containerOptions["ulElement"].appendChild(itemLiElement);
3574
+ const itemInfo = this.createSectionContainerItem(viewConfig);
3575
+ if (itemInfo) {
3576
+ containerOptions["ulElement"].appendChild(itemInfo.$el);
2926
3577
  }
2927
3578
  if (typeof viewConfig.afterAddToUListCallBack === "function") {
2928
3579
  viewConfig.afterAddToUListCallBack(viewConfig as any, {
2929
3580
  ...containerOptions,
2930
- target: itemLiElement,
3581
+ target: itemInfo?.$el,
2931
3582
  });
2932
3583
  }
2933
3584
  },
@@ -2936,7 +3587,7 @@ export const PanelHandlerComponents = () => {
2936
3587
  * @param $asideItem 左侧的容器<li>元素
2937
3588
  * @param asideConfig 配置
2938
3589
  */
2939
- setAsideItemClickEvent($asideItem: HTMLElement, asideConfig: PopsPanelContentConfig) {
3590
+ onAsideItemClick($asideItem: HTMLElement, asideConfig: PopsPanelContentConfig) {
2940
3591
  popsDOMUtils.on<MouseEvent | PointerEvent>($asideItem, "click", async (event) => {
2941
3592
  if (typeof asideConfig.clickFirstCallback === "function") {
2942
3593
  const clickFirstCallbackResult = await asideConfig.clickFirstCallback(