@whitesev/pops 1.9.6 → 2.0.0

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.
@@ -313,6 +313,31 @@ var pops = (function () {
313
313
  }
314
314
  const popsUtils = new PopsUtils();
315
315
 
316
+ const PopsSafeUtils = {
317
+ /**
318
+ * 设置安全的html
319
+ */
320
+ setSafeHTML($el, text) {
321
+ // 创建 TrustedHTML 策略(需 CSP 允许)
322
+ try {
323
+ $el.innerHTML = text;
324
+ }
325
+ catch (error) {
326
+ // @ts-ignore
327
+ if (globalThis.trustedTypes) {
328
+ // @ts-ignore
329
+ const policy = globalThis.trustedTypes.createPolicy("safe-innerHTML", {
330
+ createHTML: (html) => html,
331
+ });
332
+ $el.innerHTML = policy.createHTML(text);
333
+ }
334
+ else {
335
+ throw new Error("trustedTypes is not defined");
336
+ }
337
+ }
338
+ },
339
+ };
340
+
316
341
  class PopsDOMUtilsEvent {
317
342
  on(element, eventType, selector, callback, option) {
318
343
  /**
@@ -1250,7 +1275,7 @@ var pops = (function () {
1250
1275
  attributes) {
1251
1276
  let tempElement = PopsCore.document.createElement(tagName);
1252
1277
  if (typeof property === "string") {
1253
- tempElement.innerHTML = property;
1278
+ PopsSafeUtils.setSafeHTML(tempElement, property);
1254
1279
  return tempElement;
1255
1280
  }
1256
1281
  if (property == null) {
@@ -1261,6 +1286,11 @@ var pops = (function () {
1261
1286
  }
1262
1287
  Object.keys(property).forEach((key) => {
1263
1288
  let value = property[key];
1289
+ if (key === "innerHTML") {
1290
+ PopsSafeUtils.setSafeHTML(tempElement, value);
1291
+ return;
1292
+ }
1293
+ // @ts-ignore
1264
1294
  tempElement[key] = value;
1265
1295
  });
1266
1296
  Object.keys(attributes).forEach((key) => {
@@ -1463,7 +1493,7 @@ var pops = (function () {
1463
1493
  }
1464
1494
  function parseHTMLByCreateDom() {
1465
1495
  let tempDIV = PopsCore.document.createElement("div");
1466
- tempDIV.innerHTML = html;
1496
+ PopsSafeUtils.setSafeHTML(tempDIV, html);
1467
1497
  if (isComplete) {
1468
1498
  return tempDIV;
1469
1499
  }
@@ -4859,26 +4889,29 @@ var pops = (function () {
4859
4889
  fileNameElement.className = "pops-folder-list-table__body-td";
4860
4890
  fileTimeElement.className = "pops-folder-list-table__body-td";
4861
4891
  fileFormatSize.className = "pops-folder-list-table__body-td";
4862
- fileNameElement.innerHTML = `
4863
- <div class="pops-folder-list-file-name cursor-p">
4864
- <div>
4865
- <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
4866
- <a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
4867
- ${fileName}
4868
- </a>
4869
- </div>
4870
- </div>
4871
- `;
4872
- fileTimeElement.innerHTML = `
4873
- <div class="pops-folder-list__time">
4874
- <span>${latestTime}</span>
4875
- </div>
4876
- `;
4877
- fileFormatSize.innerHTML = `
4878
- <div class="pops-folder-list-format-size">
4879
- <span>${fileSize}</span>
4880
- </div>
4881
- `;
4892
+ PopsSafeUtils.setSafeHTML(fileNameElement,
4893
+ /*html*/ `
4894
+ <div class="pops-folder-list-file-name cursor-p">
4895
+ <div>
4896
+ <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
4897
+ <a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
4898
+ ${fileName}
4899
+ </a>
4900
+ </div>
4901
+ </div>
4902
+ `);
4903
+ PopsSafeUtils.setSafeHTML(fileTimeElement,
4904
+ /*html*/ `
4905
+ <div class="pops-folder-list__time">
4906
+ <span>${latestTime}</span>
4907
+ </div>
4908
+ `);
4909
+ PopsSafeUtils.setSafeHTML(fileFormatSize,
4910
+ /*html*/ `
4911
+ <div class="pops-folder-list-format-size">
4912
+ <span>${fileSize}</span>
4913
+ </div>
4914
+ `);
4882
4915
  /* 存储原来的值 */
4883
4916
  let __value__ = {
4884
4917
  fileName: origin_fileName,
@@ -4939,17 +4972,18 @@ var pops = (function () {
4939
4972
  }
4940
4973
  folderELement.className = "pops-folder-list-table__body-row";
4941
4974
  fileNameElement.className = "pops-folder-list-table__body-td";
4942
- fileNameElement.innerHTML = `
4943
- <div class="pops-folder-list-file-name pops-mobile-folder-list-file-name cursor-p">
4944
- <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
4945
- <div>
4946
- <a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
4947
- ${fileName}
4948
- </a>
4949
- <span>${latestTime} ${fileSize}</span>
4950
- </div>
4951
- </div>
4952
- `;
4975
+ PopsSafeUtils.setSafeHTML(fileNameElement,
4976
+ /*html*/ `
4977
+ <div class="pops-folder-list-file-name pops-mobile-folder-list-file-name cursor-p">
4978
+ <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
4979
+ <div>
4980
+ <a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
4981
+ ${fileName}
4982
+ </a>
4983
+ <span>${latestTime} ${fileSize}</span>
4984
+ </div>
4985
+ </div>
4986
+ `);
4953
4987
  /* 存储原来的值 */
4954
4988
  let __value__ = {
4955
4989
  fileName: origin_fileName,
@@ -4969,7 +5003,7 @@ var pops = (function () {
4969
5003
  * 清空每行的元素
4970
5004
  */
4971
5005
  function clearFolerRow() {
4972
- folderListBodyElement.innerHTML = "";
5006
+ PopsSafeUtils.setSafeHTML(folderListBodyElement, "");
4973
5007
  }
4974
5008
  function getArrowIconElement() {
4975
5009
  let iconArrowElement = popsDOMUtils.createElement("div", {
@@ -5543,6 +5577,7 @@ var pops = (function () {
5543
5577
  disable() {
5544
5578
  return false;
5545
5579
  },
5580
+ forms: [],
5546
5581
  },
5547
5582
  {
5548
5583
  value: "text",
@@ -5550,6 +5585,7 @@ var pops = (function () {
5550
5585
  disable() {
5551
5586
  return false;
5552
5587
  },
5588
+ forms: [],
5553
5589
  },
5554
5590
  {
5555
5591
  value: "html",
@@ -5557,6 +5593,7 @@ var pops = (function () {
5557
5593
  disable() {
5558
5594
  return false;
5559
5595
  },
5596
+ forms: [],
5560
5597
  },
5561
5598
  ],
5562
5599
  },
@@ -5965,8 +6002,8 @@ var pops = (function () {
5965
6002
  * 清空container容器的元素
5966
6003
  */
5967
6004
  clearContainer() {
5968
- this.sectionContainerHeaderULElement.innerHTML = "";
5969
- this.sectionContainerULElement.innerHTML = "";
6005
+ PopsSafeUtils.setSafeHTML(this.sectionContainerHeaderULElement, "");
6006
+ PopsSafeUtils.setSafeHTML(this.sectionContainerULElement, "");
5970
6007
  this.$el.$content
5971
6008
  ?.querySelectorAll("section.pops-panel-deepMenu-container")
5972
6009
  .forEach((ele) => ele.remove());
@@ -6052,8 +6089,9 @@ var pops = (function () {
6052
6089
  createAsideItem(asideConfig) {
6053
6090
  let liElement = document.createElement("li");
6054
6091
  liElement.id = asideConfig.id;
6092
+ // @ts-ignore
6055
6093
  liElement["__forms__"] = asideConfig.forms;
6056
- liElement.innerHTML = asideConfig.title;
6094
+ PopsSafeUtils.setSafeHTML(liElement, asideConfig.title);
6057
6095
  /* 处理className */
6058
6096
  this.setElementClassName(liElement, asideConfig.className);
6059
6097
  this.setElementAttributes(liElement, asideConfig.attributes);
@@ -6076,18 +6114,19 @@ var pops = (function () {
6076
6114
  if (Boolean(formConfig.description)) {
6077
6115
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6078
6116
  }
6079
- liElement.innerHTML = /*html*/ `
6080
- <div class="pops-panel-item-left-text">
6081
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6082
- ${leftDescriptionText}
6083
- </div>
6084
- <div class="pops-panel-switch">
6085
- <input class="pops-panel-switch__input" type="checkbox">
6086
- <span class="pops-panel-switch__core">
6087
- <div class="pops-panel-switch__action">
6088
- </div>
6089
- </span>
6090
- </div>`;
6117
+ PopsSafeUtils.setSafeHTML(liElement,
6118
+ /*html*/ `
6119
+ <div class="pops-panel-item-left-text">
6120
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6121
+ ${leftDescriptionText}
6122
+ </div>
6123
+ <div class="pops-panel-switch">
6124
+ <input class="pops-panel-switch__input" type="checkbox">
6125
+ <span class="pops-panel-switch__core">
6126
+ <div class="pops-panel-switch__action">
6127
+ </div>
6128
+ </span>
6129
+ </div>`);
6091
6130
  const PopsPanelSwitch = {
6092
6131
  [Symbol.toStringTag]: "PopsPanelSwitch",
6093
6132
  $data: {
@@ -6177,14 +6216,16 @@ var pops = (function () {
6177
6216
  if (Boolean(formConfig.description)) {
6178
6217
  leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6179
6218
  }
6180
- liElement.innerHTML = `
6181
- <div class="pops-panel-item-left-text">
6182
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6183
- ${leftDescriptionText}
6184
- </div>
6185
- <div class="pops-panel-slider">
6186
- <input type="range" min="${formConfig.min}" max="${formConfig.max}">
6187
- </div>`;
6219
+ PopsSafeUtils.setSafeHTML(liElement,
6220
+ /*html*/ `
6221
+ <div class="pops-panel-item-left-text">
6222
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6223
+ ${leftDescriptionText}
6224
+ </div>
6225
+ <div class="pops-panel-slider">
6226
+ <input type="range" min="${formConfig.min}" max="${formConfig.max}">
6227
+ </div>
6228
+ `);
6188
6229
  let rangeInputElement = liElement.querySelector(".pops-panel-slider input[type=range]");
6189
6230
  if (formConfig.step) {
6190
6231
  rangeInputElement.setAttribute("step", formConfig.step.toString());
@@ -6240,19 +6281,20 @@ var pops = (function () {
6240
6281
  if (Boolean(formConfig.description)) {
6241
6282
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6242
6283
  }
6243
- liElement.innerHTML = /*html*/ `
6244
- <div class="pops-panel-item-left-text" style="flex: 1;">
6245
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6246
- ${leftDescriptionText}
6247
- </div>
6248
- <div class="pops-slider pops-slider-width">
6249
- <div class="pops-slider__runway">
6250
- <div class="pops-slider__bar" style="width: 0%; left: 0%"></div>
6251
- <div class="pops-slider__button-wrapper" style="left: 0%">
6252
- <div class="pops-slider__button"></div>
6253
- </div>
6284
+ PopsSafeUtils.setSafeHTML(liElement,
6285
+ /*html*/ `
6286
+ <div class="pops-panel-item-left-text" style="flex: 1;">
6287
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6288
+ ${leftDescriptionText}
6254
6289
  </div>
6255
- </div>`;
6290
+ <div class="pops-slider pops-slider-width">
6291
+ <div class="pops-slider__runway">
6292
+ <div class="pops-slider__bar" style="width: 0%; left: 0%"></div>
6293
+ <div class="pops-slider__button-wrapper" style="left: 0%">
6294
+ <div class="pops-slider__button"></div>
6295
+ </div>
6296
+ </div>
6297
+ </div>`);
6256
6298
  const PopsPanelSlider = {
6257
6299
  [Symbol.toStringTag]: "PopsPanelSlider",
6258
6300
  /**
@@ -6802,15 +6844,16 @@ var pops = (function () {
6802
6844
  if (Boolean(formConfig.description)) {
6803
6845
  leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6804
6846
  }
6805
- liElement.innerHTML = `
6806
- <div class="pops-panel-item-left-text">
6807
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6808
- ${leftDescriptionText}
6809
- </div>
6810
- <div class="pops-panel-input pops-user-select-none">
6811
- <input type="${inputType}" placeholder="${formConfig.placeholder}">
6812
- </div>
6813
- `;
6847
+ PopsSafeUtils.setSafeHTML(liElement,
6848
+ /*html*/ `
6849
+ <div class="pops-panel-item-left-text">
6850
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6851
+ ${leftDescriptionText}
6852
+ </div>
6853
+ <div class="pops-panel-input pops-user-select-none">
6854
+ <input type="${inputType}" placeholder="${formConfig.placeholder}">
6855
+ </div>
6856
+ `);
6814
6857
  const PopsPanelInput = {
6815
6858
  [Symbol.toStringTag]: "PopsPanelInput",
6816
6859
  $ele: {
@@ -6853,11 +6896,12 @@ var pops = (function () {
6853
6896
  initEle() {
6854
6897
  this.$ele.input.parentElement.insertBefore(this.$ele.inputSpanIcon, this.$ele.input.nextSibling);
6855
6898
  this.$ele.inputSpanIcon.className = "pops-panel-input__suffix";
6856
- this.$ele.inputSpanIcon.innerHTML = `
6857
- <span class="pops-panel-input__suffix-inner">
6858
- <i class="pops-panel-icon"></i>
6859
- </span>
6860
- `;
6899
+ PopsSafeUtils.setSafeHTML(this.$ele.inputSpanIcon,
6900
+ /*html*/ `
6901
+ <span class="pops-panel-input__suffix-inner">
6902
+ <i class="pops-panel-icon"></i>
6903
+ </span>
6904
+ `);
6861
6905
  this.$ele.inputSpanIconInner =
6862
6906
  this.$ele.inputSpanIcon.querySelector(".pops-panel-input__suffix-inner");
6863
6907
  this.$ele.icon =
@@ -6892,7 +6936,7 @@ var pops = (function () {
6892
6936
  },
6893
6937
  /**
6894
6938
  * 设置input元素的type
6895
- * @param {string} [typeValue="text"] type值
6939
+ * @param [typeValue="text"] type值
6896
6940
  */
6897
6941
  setInputType(typeValue = "text") {
6898
6942
  this.$ele.input.setAttribute("type", typeValue);
@@ -6901,14 +6945,14 @@ var pops = (function () {
6901
6945
  * 删除图标按钮
6902
6946
  */
6903
6947
  removeCircleIcon() {
6904
- this.$ele.icon.innerHTML = "";
6948
+ PopsSafeUtils.setSafeHTML(this.$ele.icon, "");
6905
6949
  },
6906
6950
  /**
6907
6951
  * 添加清空图标按钮
6908
- * @param {string} [svgHTML=pops.config.iconSVG.circleClose] svg图标,默认为清空的图标
6952
+ * @param [svgHTML=pops.config.iconSVG.circleClose] svg图标,默认为清空的图标
6909
6953
  */
6910
6954
  setCircleIcon(svgHTML = pops.config.iconSVG.circleClose) {
6911
- this.$ele.icon.innerHTML = svgHTML;
6955
+ PopsSafeUtils.setSafeHTML(this.$ele.icon, svgHTML);
6912
6956
  },
6913
6957
  /**
6914
6958
  * 添加图标按钮的点击事件
@@ -6997,16 +7041,17 @@ var pops = (function () {
6997
7041
  if (Boolean(formConfig.description)) {
6998
7042
  leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6999
7043
  }
7000
- liElement.innerHTML = `
7001
- <div class="pops-panel-item-left-text">
7002
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7003
- ${leftDescriptionText}
7004
- </div>
7005
- <div class="pops-panel-textarea">
7006
- <textarea placeholder="${formConfig.placeholder ?? ""}">
7007
- </textarea>
7008
- </div>
7009
- `;
7044
+ PopsSafeUtils.setSafeHTML(liElement,
7045
+ /*html*/ `
7046
+ <div class="pops-panel-item-left-text">
7047
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7048
+ ${leftDescriptionText}
7049
+ </div>
7050
+ <div class="pops-panel-textarea">
7051
+ <textarea placeholder="${formConfig.placeholder ?? ""}">
7052
+ </textarea>
7053
+ </div>
7054
+ `);
7010
7055
  const PopsPanelTextArea = {
7011
7056
  [Symbol.toStringTag]: "PopsPanelTextArea",
7012
7057
  $ele: {
@@ -7060,6 +7105,7 @@ var pops = (function () {
7060
7105
  * @param formConfig
7061
7106
  */
7062
7107
  createSectionContainerItem_select(formConfig) {
7108
+ const that = this;
7063
7109
  let liElement = document.createElement("li");
7064
7110
  liElement["__formConfig__"] = formConfig;
7065
7111
  this.setElementClassName(liElement, formConfig.className);
@@ -7070,15 +7116,16 @@ var pops = (function () {
7070
7116
  if (Boolean(formConfig.description)) {
7071
7117
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
7072
7118
  }
7073
- liElement.innerHTML = /*html*/ `
7074
- <div class="pops-panel-item-left-text">
7075
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7076
- ${leftDescriptionText}
7077
- </div>
7078
- <div class="pops-panel-select pops-user-select-none">
7079
- <select></select>
7080
- </div>
7081
- `;
7119
+ PopsSafeUtils.setSafeHTML(liElement,
7120
+ /*html*/ `
7121
+ <div class="pops-panel-item-left-text">
7122
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7123
+ ${leftDescriptionText}
7124
+ </div>
7125
+ <div class="pops-panel-select pops-user-select-none">
7126
+ <select></select>
7127
+ </div>
7128
+ `);
7082
7129
  const PopsPanelSelect = {
7083
7130
  [Symbol.toStringTag]: "PopsPanelSelect",
7084
7131
  $ele: {
@@ -7088,6 +7135,7 @@ var pops = (function () {
7088
7135
  $eleKey: {
7089
7136
  disable: "__disable__",
7090
7137
  value: "__value__",
7138
+ forms: "__forms__",
7091
7139
  },
7092
7140
  $data: {
7093
7141
  defaultValue: formConfig.getValue(),
@@ -7118,31 +7166,50 @@ var pops = (function () {
7118
7166
  getNodeValue($ele, key) {
7119
7167
  return Reflect.get($ele, key);
7120
7168
  },
7169
+ /**
7170
+ * 禁用选项
7171
+ */
7121
7172
  disable() {
7122
7173
  this.$ele.select.setAttribute("disabled", "true");
7123
7174
  this.$ele.panelSelect.classList.add("pops-panel-select-disable");
7124
7175
  },
7176
+ /**
7177
+ * 取消禁用
7178
+ */
7125
7179
  notDisable() {
7126
7180
  this.$ele.select.removeAttribute("disabled");
7127
7181
  this.$ele.panelSelect.classList.remove("pops-panel-select-disable");
7128
7182
  },
7183
+ /**
7184
+ * 判断是否禁用
7185
+ */
7129
7186
  isDisabled() {
7130
7187
  return (this.$ele.select.hasAttribute("disabled") ||
7131
7188
  this.$ele.panelSelect.classList.contains("pops-panel-select-disable"));
7132
7189
  },
7190
+ /**
7191
+ * 初始化选项
7192
+ */
7133
7193
  initOption() {
7134
7194
  formConfig.data.forEach((dataItem) => {
7135
7195
  // 初始化默认选中
7136
7196
  let optionElement = document.createElement("option");
7137
7197
  this.setNodeValue(optionElement, this.$eleKey.value, dataItem.value);
7138
7198
  this.setNodeValue(optionElement, this.$eleKey.disable, dataItem.disable);
7199
+ this.setNodeValue(optionElement, this.$eleKey.forms, dataItem.forms);
7139
7200
  if (dataItem.value === this.$data.defaultValue) {
7140
- optionElement.setAttribute("selected", "true");
7201
+ this.setOptionSelected(optionElement);
7141
7202
  }
7142
7203
  optionElement.innerText = dataItem.text;
7143
7204
  this.$ele.select.appendChild(optionElement);
7144
7205
  });
7145
7206
  },
7207
+ /**
7208
+ * 设置选项选中
7209
+ */
7210
+ setOptionSelected($option) {
7211
+ $option.setAttribute("selected", "true");
7212
+ },
7146
7213
  /** 检测所有option并设置禁用状态 */
7147
7214
  setSelectOptionsDisableStatus() {
7148
7215
  if (this.$ele.select.options && this.$ele.select.options.length) {
@@ -7170,9 +7237,11 @@ var pops = (function () {
7170
7237
  getSelectOptionInfo($option) {
7171
7238
  let optionValue = this.getNodeValue($option, this.$eleKey.value);
7172
7239
  let optionText = $option.innerText || $option.textContent;
7240
+ let optionForms = this.getNodeValue($option, this.$eleKey.forms);
7173
7241
  return {
7174
7242
  value: optionValue,
7175
7243
  text: optionText,
7244
+ forms: optionForms,
7176
7245
  $option: $option,
7177
7246
  };
7178
7247
  },
@@ -7181,12 +7250,34 @@ var pops = (function () {
7181
7250
  */
7182
7251
  setChangeEvent() {
7183
7252
  popsDOMUtils.on(this.$ele.select, "change", void 0, (event) => {
7253
+ let $isSelectedElement = event.target[event.target.selectedIndex];
7254
+ let selectInfo = this.getSelectOptionInfo($isSelectedElement);
7184
7255
  this.setSelectOptionsDisableStatus();
7185
7256
  if (typeof formConfig.callback === "function") {
7186
- let $isSelectedElement = event.target[event.target.selectedIndex];
7187
- let selectInfo = this.getSelectOptionInfo($isSelectedElement);
7188
7257
  formConfig.callback(event, selectInfo.value, selectInfo.text);
7189
7258
  }
7259
+ let forms = typeof selectInfo.forms === "function"
7260
+ ? selectInfo.forms()
7261
+ : selectInfo.forms;
7262
+ if (Array.isArray(forms)) {
7263
+ /* 如果成功创建,加入到中间容器中 */
7264
+ let childUListClassName = "pops-panel-select-child-forms";
7265
+ // 移除旧的元素
7266
+ while (liElement.nextElementSibling) {
7267
+ if (liElement.nextElementSibling.classList.contains(childUListClassName)) {
7268
+ liElement.nextElementSibling.remove();
7269
+ }
7270
+ else {
7271
+ break;
7272
+ }
7273
+ }
7274
+ let $childUList = document.createElement("ul");
7275
+ $childUList.className = childUListClassName;
7276
+ popsDOMUtils.after(liElement, $childUList);
7277
+ that.uListContainerAddItem(formConfig, {
7278
+ ulElement: $childUList,
7279
+ });
7280
+ }
7190
7281
  });
7191
7282
  },
7192
7283
  /**
@@ -7221,33 +7312,34 @@ var pops = (function () {
7221
7312
  if (Boolean(formConfig.description)) {
7222
7313
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
7223
7314
  }
7224
- liElement.innerHTML = /*html*/ `
7225
- <div class="pops-panel-item-left-text">
7226
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7227
- ${leftDescriptionText}
7228
- </div>
7229
- <div class="pops-panel-select-multiple">
7230
- <div class="el-select__wrapper">
7231
- <div class="el-select__selection">
7232
- <!-- 这个是用于手动输入的,这里暂不适配 -->
7233
- <div class="el-select__selected-item el-select__input-wrapper">
7234
-
7315
+ PopsSafeUtils.setSafeHTML(liElement,
7316
+ /*html*/ `
7317
+ <div class="pops-panel-item-left-text">
7318
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7319
+ ${leftDescriptionText}
7320
+ </div>
7321
+ <div class="pops-panel-select-multiple">
7322
+ <div class="el-select__wrapper">
7323
+ <div class="el-select__selection">
7324
+ <!-- 这个是用于手动输入的,这里暂不适配 -->
7325
+ <div class="el-select__selected-item el-select__input-wrapper">
7326
+
7327
+ </div>
7328
+ <!-- 这个是placeholder -->
7329
+ <div class="el-select__selected-item el-select__placeholder">
7330
+ </div>
7235
7331
  </div>
7236
- <!-- 这个是placeholder -->
7237
- <div class="el-select__selected-item el-select__placeholder">
7332
+ <!-- 下拉箭头 -->
7333
+ <div class="el-select__suffix">
7334
+ <i class="el-icon el-select__caret el-select__icon">
7335
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
7336
+ <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>
7337
+ </svg>
7338
+ </i>
7238
7339
  </div>
7239
7340
  </div>
7240
- <!-- 下拉箭头 -->
7241
- <div class="el-select__suffix">
7242
- <i class="el-icon el-select__caret el-select__icon">
7243
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
7244
- <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>
7245
- </svg>
7246
- </i>
7247
- </div>
7248
7341
  </div>
7249
- </div>
7250
- `;
7342
+ `);
7251
7343
  const PopsPanelSelectMultiple = {
7252
7344
  [Symbol.toStringTag]: "PopsPanelSelectMultiple",
7253
7345
  $el: {
@@ -7372,7 +7464,7 @@ var pops = (function () {
7372
7464
  /** 关闭图标 */
7373
7465
  const $closeIcon = $selectedItem.querySelector(".el-icon.el-tag__close");
7374
7466
  if (data.isHTML) {
7375
- $tagText.innerHTML = data.text;
7467
+ PopsSafeUtils.setSafeHTML($tagText, data.text);
7376
7468
  }
7377
7469
  else {
7378
7470
  $tagText.innerText = data.text;
@@ -7525,12 +7617,28 @@ var pops = (function () {
7525
7617
  Reflect.set($item, "data-info", dataInfo);
7526
7618
  return $item;
7527
7619
  }
7620
+ /**
7621
+ * 设置选择项的禁用状态
7622
+ */
7623
+ function setSelectItemDisabled($el) {
7624
+ $el.setAttribute("aria-disabled", "true");
7625
+ }
7626
+ /**
7627
+ * 移除选择项的禁用状态
7628
+ */
7629
+ function removeSelectItemDisabled($el) {
7630
+ $el.removeAttribute("aria-disabled");
7631
+ $el.removeAttribute("disabled");
7632
+ }
7528
7633
  /**
7529
7634
  * 设置选择项的点击事件
7530
7635
  */
7531
7636
  function setSelectElementClickEvent($ele) {
7532
7637
  popsDOMUtils.on($ele, "click", (event) => {
7533
7638
  popsDOMUtils.preventEvent(event);
7639
+ if ($ele.hasAttribute("disabled") || $ele.ariaDisabled) {
7640
+ return;
7641
+ }
7534
7642
  if (typeof formConfig.clickCallBack === "function") {
7535
7643
  let clickResult = formConfig.clickCallBack(event, getAllSelectedInfo());
7536
7644
  if (typeof clickResult === "boolean" && !clickResult) {
@@ -7596,7 +7704,6 @@ var pops = (function () {
7596
7704
  --el-fill-color-light: #f5f7fa;
7597
7705
  }
7598
7706
  .select-item{
7599
- cursor: pointer;
7600
7707
  cursor: pointer;
7601
7708
  font-size: var(--el-font-size-base);
7602
7709
  padding: 0 32px 0 20px;
@@ -7609,6 +7716,12 @@ var pops = (function () {
7609
7716
  line-height: 34px;
7610
7717
  box-sizing: border-box;
7611
7718
  }
7719
+ .select-item[aria-disabled],
7720
+ .select-item[disabled]{
7721
+ cursor: not-allowed;
7722
+ color: #a8abb2;
7723
+ background: unset;
7724
+ }
7612
7725
  .select-item:hover{
7613
7726
  background-color: var(--el-fill-color-light);
7614
7727
  }
@@ -7646,6 +7759,15 @@ var pops = (function () {
7646
7759
  $selectContainer.appendChild($select);
7647
7760
  // 设置每一项的点击事件
7648
7761
  setSelectElementClickEvent($select);
7762
+ // 设置禁用状态
7763
+ if (typeof item.disable === "function" &&
7764
+ item.disable(item.value)) {
7765
+ setSelectItemDisabled($select);
7766
+ // 后续不设置元素的选中状态
7767
+ return;
7768
+ }
7769
+ // 移除禁用状态
7770
+ removeSelectItemDisabled($select);
7649
7771
  let findValue = selectedInfo.find((value) => value.value === item.value);
7650
7772
  if (findValue) {
7651
7773
  setItemSelected($select);
@@ -7749,18 +7871,19 @@ var pops = (function () {
7749
7871
  if (Boolean(formConfig.description)) {
7750
7872
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
7751
7873
  }
7752
- liElement.innerHTML = /*html*/ `
7753
- <div class="pops-panel-item-left-text">
7754
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7755
- ${leftDescriptionText}
7756
- </div>
7757
- <div class="pops-panel-button">
7758
- <button class="pops-panel-button_inner">
7759
- <i class="pops-bottom-icon"></i>
7760
- <span class="pops-panel-button-text"></span>
7761
- </button>
7762
- </div>
7763
- `;
7874
+ PopsSafeUtils.setSafeHTML(liElement,
7875
+ /*html*/ `
7876
+ <div class="pops-panel-item-left-text">
7877
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7878
+ ${leftDescriptionText}
7879
+ </div>
7880
+ <div class="pops-panel-button">
7881
+ <button class="pops-panel-button_inner">
7882
+ <i class="pops-bottom-icon"></i>
7883
+ <span class="pops-panel-button-text"></span>
7884
+ </button>
7885
+ </div>
7886
+ `);
7764
7887
  const PopsPanelButton = {
7765
7888
  [Symbol.toStringTag]: "PopsPanelButton",
7766
7889
  $ele: {
@@ -7830,7 +7953,7 @@ var pops = (function () {
7830
7953
  * 设置icon图标的svg
7831
7954
  */
7832
7955
  setIconSVG(svgHTML) {
7833
- this.$ele.icon.innerHTML = svgHTML;
7956
+ PopsSafeUtils.setSafeHTML(this.$ele.icon, svgHTML);
7834
7957
  },
7835
7958
  /**
7836
7959
  * 设置icon图标是否旋转
@@ -7869,7 +7992,7 @@ var pops = (function () {
7869
7992
  * @param text
7870
7993
  */
7871
7994
  setButtonText(text) {
7872
- this.$ele.spanText.innerHTML = text;
7995
+ PopsSafeUtils.setSafeHTML(this.$ele.spanText, text);
7873
7996
  },
7874
7997
  setClickEvent() {
7875
7998
  popsDOMUtils.on(this.$ele.button, "click", void 0, (event) => {
@@ -7915,16 +8038,17 @@ var pops = (function () {
7915
8038
  if (formConfig.rightText) {
7916
8039
  rightText = /*html*/ `<p class="pops-panel-item-right-text">${formConfig.rightText}</p>`;
7917
8040
  }
7918
- $li.innerHTML = /*html*/ `
7919
- <div class="pops-panel-item-left-text">
7920
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7921
- ${leftDescriptionText}
7922
- </div>
7923
- <div class="pops-panel-deepMenu">
7924
- ${rightText}
7925
- ${arrowRightIconHTML}
7926
- </div>
7927
- `;
8041
+ PopsSafeUtils.setSafeHTML($li,
8042
+ /*html*/ `
8043
+ <div class="pops-panel-item-left-text">
8044
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
8045
+ ${leftDescriptionText}
8046
+ </div>
8047
+ <div class="pops-panel-deepMenu">
8048
+ ${rightText}
8049
+ ${arrowRightIconHTML}
8050
+ </div>
8051
+ `);
7928
8052
  const PopsPanelDeepMenu = {
7929
8053
  [Symbol.toStringTag]: "PopsPanelDeepMenu",
7930
8054
  $ele: {
@@ -7954,19 +8078,19 @@ var pops = (function () {
7954
8078
  let formHeaderDivElement = popsDOMUtils.createElement("div", {
7955
8079
  className: "pops-panel-forms-container-item-header-text",
7956
8080
  });
7957
- formHeaderDivElement.innerHTML = formConfig_forms["text"];
8081
+ PopsSafeUtils.setSafeHTML(formHeaderDivElement, formConfig_forms["text"]);
7958
8082
  if (formConfig_forms.isFold) {
7959
8083
  /* 添加第一个 */
7960
8084
  /* 加进容器内 */
7961
- formHeaderDivElement.innerHTML = /*html*/ `
8085
+ PopsSafeUtils.setSafeHTML(formHeaderDivElement,
8086
+ /*html*/ `
7962
8087
  <p>${formConfig_forms.text}</p>
7963
8088
  <i class="pops-panel-forms-fold-container-icon">
7964
8089
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
7965
8090
  <path d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"></path>
7966
8091
  </svg>
7967
8092
  </i>
7968
-
7969
- `;
8093
+ `);
7970
8094
  // 添加点击事件
7971
8095
  popsDOMUtils.on(formHeaderDivElement, "click", (event) => {
7972
8096
  if (formContainerListElement.hasAttribute("data-fold-enable")) {
@@ -8164,18 +8288,18 @@ var pops = (function () {
8164
8288
  let formHeaderDivElement = popsDOMUtils.createElement("div", {
8165
8289
  className: "pops-panel-forms-container-item-header-text",
8166
8290
  });
8167
- formHeaderDivElement.innerHTML = formConfig_forms["text"];
8291
+ PopsSafeUtils.setSafeHTML(formHeaderDivElement, formConfig_forms["text"]);
8168
8292
  if (formConfig_forms.isFold) {
8169
8293
  /* 加进容器内 */
8170
- formHeaderDivElement.innerHTML = /*html*/ `
8294
+ PopsSafeUtils.setSafeHTML(formHeaderDivElement,
8295
+ /*html*/ `
8171
8296
  <p>${formConfig_forms.text}</p>
8172
8297
  <i class="pops-panel-forms-fold-container-icon">
8173
8298
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
8174
8299
  <path d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"></path>
8175
8300
  </svg>
8176
8301
  </i>
8177
-
8178
- `;
8302
+ `);
8179
8303
  // 添加点击事件
8180
8304
  popsDOMUtils.on(formHeaderDivElement, "click", (event) => {
8181
8305
  if (formContainerListElement.hasAttribute("data-fold-enable")) {
@@ -8261,7 +8385,7 @@ var pops = (function () {
8261
8385
  let containerHeaderTitleLIElement = document.createElement("li");
8262
8386
  containerHeaderTitleLIElement["__asideConfig__"] =
8263
8387
  asideConfig;
8264
- containerHeaderTitleLIElement.innerHTML = headerTitleText;
8388
+ PopsSafeUtils.setSafeHTML(containerHeaderTitleLIElement, headerTitleText);
8265
8389
  this.sectionContainerHeaderULElement.appendChild(containerHeaderTitleLIElement);
8266
8390
  }
8267
8391
  let __forms__ = asideLiElement["__forms__"];
@@ -8550,9 +8674,11 @@ var pops = (function () {
8550
8674
  pops.config.cssText.rightClickMenu,
8551
8675
  ]);
8552
8676
  if (config.style != null) {
8553
- let cssNode = document.createElement("style");
8554
- cssNode.setAttribute("type", "text/css");
8555
- cssNode.innerHTML = config.style;
8677
+ let cssNode = popsDOMUtils.createElement("style", {
8678
+ innerHTML: config.style,
8679
+ }, {
8680
+ type: "text/css",
8681
+ });
8556
8682
  $shadowRoot.appendChild(cssNode);
8557
8683
  }
8558
8684
  const PopsContextMenu = {
@@ -9034,8 +9160,11 @@ var pops = (function () {
9034
9160
  ]);
9035
9161
  if (config.style != null) {
9036
9162
  let cssNode = document.createElement("style");
9037
- cssNode.setAttribute("type", "text/css");
9038
- cssNode.innerHTML = config.style;
9163
+ popsDOMUtils.createElement("style", {
9164
+ innerHTML: config.style,
9165
+ }, {
9166
+ type: "text/css",
9167
+ });
9039
9168
  $shadowRoot.appendChild(cssNode);
9040
9169
  }
9041
9170
  const SearchSuggestion = {
@@ -9412,7 +9541,7 @@ var pops = (function () {
9412
9541
  * 清空所有的搜索结果
9413
9542
  */
9414
9543
  clearAllSearchItemLi() {
9415
- SearchSuggestion.$el.$hintULContainer.innerHTML = "";
9544
+ PopsSafeUtils.setSafeHTML(SearchSuggestion.$el.$hintULContainer, "");
9416
9545
  },
9417
9546
  /**
9418
9547
  * 更新搜索建议框的位置(top、left)
@@ -9494,7 +9623,8 @@ var pops = (function () {
9494
9623
  * 动态更新CSS
9495
9624
  */
9496
9625
  updateDynamicCSS() {
9497
- this.$el.$dynamicCSS.innerHTML = this.getDynamicCSS();
9626
+ let cssText = this.getDynamicCSS();
9627
+ PopsSafeUtils.setSafeHTML(this.$el.$dynamicCSS, cssText);
9498
9628
  },
9499
9629
  /**
9500
9630
  * 更新页面显示的搜索结果
@@ -9684,7 +9814,7 @@ var pops = (function () {
9684
9814
  if (text == null) {
9685
9815
  text = this.getContent();
9686
9816
  }
9687
- this.$el.$content.innerHTML = text;
9817
+ PopsSafeUtils.setSafeHTML(this.$el.$content, text);
9688
9818
  }
9689
9819
  /**
9690
9820
  * 获取z-index
@@ -10056,7 +10186,7 @@ var pops = (function () {
10056
10186
  /** 配置 */
10057
10187
  config = {
10058
10188
  /** 版本号 */
10059
- version: "2024.12.8",
10189
+ version: "2025.3.2",
10060
10190
  cssText: {
10061
10191
  /** 主CSS */
10062
10192
  index: indexCSS,
@@ -10161,7 +10291,7 @@ var pops = (function () {
10161
10291
  /* 处理获取当前所有的动画名 */
10162
10292
  this.config.isInit = true;
10163
10293
  let animationStyle = document.createElement("style");
10164
- animationStyle.innerHTML = this.config.cssText.anim;
10294
+ PopsSafeUtils.setSafeHTML(animationStyle, this.config.cssText.anim);
10165
10295
  popsDOMUtils.appendHead(animationStyle);
10166
10296
  this.config.animation = null;
10167
10297
  this.config.animation = PopsInstanceUtils.getKeyFrames(animationStyle.sheet);