@whitesev/pops 2.3.6 → 2.3.8

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.
@@ -1157,6 +1157,7 @@ System.register('pops', [], (function (exports) {
1157
1157
  * })
1158
1158
  */
1159
1159
  ready(callback) {
1160
+ const that = this;
1160
1161
  if (typeof callback !== "function") {
1161
1162
  return;
1162
1163
  }
@@ -1202,7 +1203,7 @@ System.register('pops', [], (function (exports) {
1202
1203
  function addDomReadyListener() {
1203
1204
  for (let index = 0; index < targetList.length; index++) {
1204
1205
  let item = targetList[index];
1205
- item.target.addEventListener(item.eventType, item.callback);
1206
+ that.on(item.target, item.eventType, item.callback);
1206
1207
  }
1207
1208
  }
1208
1209
  /**
@@ -1211,7 +1212,7 @@ System.register('pops', [], (function (exports) {
1211
1212
  function removeDomReadyListener() {
1212
1213
  for (let index = 0; index < targetList.length; index++) {
1213
1214
  let item = targetList[index];
1214
- item.target.removeEventListener(item.eventType, item.callback);
1215
+ that.off(item.target, item.eventType, item.callback);
1215
1216
  }
1216
1217
  }
1217
1218
  if (checkDOMReadyState()) {
@@ -1493,9 +1494,7 @@ System.register('pops', [], (function (exports) {
1493
1494
  eventNameList = [eventNameList];
1494
1495
  }
1495
1496
  eventNameList.forEach((eventName) => {
1496
- element.addEventListener(eventName, stopEvent, {
1497
- capture: Boolean(capture),
1498
- });
1497
+ this.on(element, eventName, stopEvent, { capture: Boolean(capture) });
1499
1498
  });
1500
1499
  }
1501
1500
  }
@@ -5144,57 +5143,101 @@ System.register('pops', [], (function (exports) {
5144
5143
  if ($mask != null) {
5145
5144
  $anim.after($mask);
5146
5145
  }
5147
- /* 添加文件信息 */
5148
- config.folder.sort();
5149
- /**
5150
- * 创建文件夹元素
5151
- * @param fileName
5152
- * @param latestTime
5153
- * @param [fileSize="-"]
5154
- * @param isFolder
5155
- */
5156
- function createFolderRowElement(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
5157
- let origin_fileName = fileName;
5158
- let origin_latestTime = latestTime;
5159
- let origin_fileSize = fileSize;
5160
- let folderELement = popsDOMUtils.createElement("tr");
5161
- let fileNameElement = popsDOMUtils.createElement("td");
5162
- let fileTimeElement = popsDOMUtils.createElement("td");
5163
- let fileFormatSize = popsDOMUtils.createElement("td");
5164
- let fileType = "";
5165
- let fileIcon = Folder_ICON.folder;
5166
- if (isFolder) {
5167
- /* 文件夹 */
5168
- latestTime = "";
5169
- fileSize = "";
5170
- }
5171
- else {
5172
- /* 文件 */
5173
- fileIcon = "";
5174
- if (typeof latestTime === "number") {
5175
- latestTime = popsUtils.formatTime(latestTime);
5176
- }
5177
- if (typeof fileSize === "number") {
5178
- fileSize = popsUtils.formatByteToSize(fileSize);
5179
- }
5180
- for (let keyName in Folder_ICON) {
5181
- if (fileName.toLowerCase().endsWith("." + keyName)) {
5182
- fileType = keyName;
5183
- fileIcon = Folder_ICON[keyName];
5184
- break;
5185
- }
5146
+ class PopsFolder {
5147
+ init() {
5148
+ config.folder.sort();
5149
+ this.initFolderView(config.folder);
5150
+ /* 将数据存到全部文件的属性_config_中 */
5151
+ let allFilesElement = folderFileListBreadcrumbPrimaryElement.querySelector(".pops-folder-list .pops-folder-file-list-breadcrumb-allFiles:first-child");
5152
+ Reflect.set(allFilesElement, "_config_", config.folder);
5153
+ /* 设置点击顶部的全部文件事件 */
5154
+ popsDOMUtils.on(allFilesElement, "click", (event) => {
5155
+ this.setBreadcrumbClickEvent(event, true, config.folder);
5156
+ });
5157
+ // 文件名的点击排序
5158
+ popsDOMUtils.on(folderListSortFileNameElement.closest("th"), "click", (event) => {
5159
+ this.arrowToSortFolderInfoView(folderListSortFileNameElement, event, "fileName");
5160
+ }, {
5161
+ capture: true,
5162
+ });
5163
+ // 修改事件的点击排序
5164
+ popsDOMUtils.on(folderListSortLatestTimeElement.closest("th"), "click", (event) => {
5165
+ this.arrowToSortFolderInfoView(folderListSortLatestTimeElement, event, "latestTime");
5166
+ }, {
5167
+ capture: true,
5168
+ });
5169
+ // 文件大小的点击排序
5170
+ popsDOMUtils.on(folderListSortFileSizeElement.closest("th"), "click", (event) => {
5171
+ this.arrowToSortFolderInfoView(folderListSortFileSizeElement, event, "fileSize");
5172
+ }, {
5173
+ capture: true,
5174
+ });
5175
+ /* 设置默认触发的arrow */
5176
+ if (config.sort.name === "fileName") {
5177
+ popsDOMUtils.trigger(folderListSortFileNameElement, "click", {
5178
+ notChangeSortRule: true,
5179
+ });
5186
5180
  }
5187
- if (!Boolean(fileIcon)) {
5188
- fileType = "Null";
5189
- fileIcon = Folder_ICON.Null;
5181
+ else if (config.sort.name === "latestTime") {
5182
+ popsDOMUtils.trigger(folderListSortLatestTimeElement, "click", {
5183
+ notChangeSortRule: true,
5184
+ });
5185
+ }
5186
+ else if (config.sort.name === "fileSize") {
5187
+ popsDOMUtils.trigger(folderListSortFileSizeElement, "click", {
5188
+ notChangeSortRule: true,
5189
+ });
5190
5190
  }
5191
5191
  }
5192
- folderELement.className = "pops-folder-list-table__body-row";
5193
- fileNameElement.className = "pops-folder-list-table__body-td";
5194
- fileTimeElement.className = "pops-folder-list-table__body-td";
5195
- fileFormatSize.className = "pops-folder-list-table__body-td";
5196
- PopsSafeUtils.setSafeHTML(fileNameElement,
5197
- /*html*/ `
5192
+ /**
5193
+ * 创建文件夹元素
5194
+ * @param fileName 文件名
5195
+ * @param latestTime 修改时间
5196
+ * @param [fileSize="-"] 文件大小
5197
+ * @param isFolder 是否是文件夹
5198
+ */
5199
+ createFolderRowElement(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
5200
+ let origin_fileName = fileName;
5201
+ let origin_latestTime = latestTime;
5202
+ let origin_fileSize = fileSize;
5203
+ let folderElement = popsDOMUtils.createElement("tr");
5204
+ let fileNameElement = popsDOMUtils.createElement("td");
5205
+ let fileTimeElement = popsDOMUtils.createElement("td");
5206
+ let fileFormatSize = popsDOMUtils.createElement("td");
5207
+ let fileType = "";
5208
+ let fileIcon = Folder_ICON.folder;
5209
+ if (isFolder) {
5210
+ /* 文件夹 */
5211
+ latestTime = "";
5212
+ fileSize = "";
5213
+ }
5214
+ else {
5215
+ /* 文件 */
5216
+ fileIcon = "";
5217
+ if (typeof latestTime === "number") {
5218
+ latestTime = popsUtils.formatTime(latestTime);
5219
+ }
5220
+ if (typeof fileSize === "number") {
5221
+ fileSize = popsUtils.formatByteToSize(fileSize);
5222
+ }
5223
+ for (let keyName in Folder_ICON) {
5224
+ if (fileName.toLowerCase().endsWith("." + keyName)) {
5225
+ fileType = keyName;
5226
+ fileIcon = Folder_ICON[keyName];
5227
+ break;
5228
+ }
5229
+ }
5230
+ if (!Boolean(fileIcon)) {
5231
+ fileType = "Null";
5232
+ fileIcon = Folder_ICON.Null;
5233
+ }
5234
+ }
5235
+ folderElement.className = "pops-folder-list-table__body-row";
5236
+ fileNameElement.className = "pops-folder-list-table__body-td";
5237
+ fileTimeElement.className = "pops-folder-list-table__body-td";
5238
+ fileFormatSize.className = "pops-folder-list-table__body-td";
5239
+ PopsSafeUtils.setSafeHTML(fileNameElement,
5240
+ /*html*/ `
5198
5241
  <div class="pops-folder-list-file-name cursor-p">
5199
5242
  <div>
5200
5243
  <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
@@ -5204,80 +5247,84 @@ System.register('pops', [], (function (exports) {
5204
5247
  </div>
5205
5248
  </div>
5206
5249
  `);
5207
- PopsSafeUtils.setSafeHTML(fileTimeElement,
5208
- /*html*/ `
5250
+ PopsSafeUtils.setSafeHTML(fileTimeElement,
5251
+ /*html*/ `
5209
5252
  <div class="pops-folder-list__time">
5210
5253
  <span>${latestTime}</span>
5211
5254
  </div>
5212
5255
  `);
5213
- PopsSafeUtils.setSafeHTML(fileFormatSize,
5214
- /*html*/ `
5256
+ PopsSafeUtils.setSafeHTML(fileFormatSize,
5257
+ /*html*/ `
5215
5258
  <div class="pops-folder-list-format-size">
5216
5259
  <span>${fileSize}</span>
5217
5260
  </div>
5218
5261
  `);
5219
- /* 存储原来的值 */
5220
- let __value__ = {
5221
- fileName: origin_fileName,
5222
- latestTime: origin_latestTime,
5223
- fileSize: origin_fileSize,
5224
- isFolder: isFolder,
5225
- };
5226
- Reflect.set(fileNameElement, "__value__", __value__);
5227
- Reflect.set(fileTimeElement, "__value__", __value__);
5228
- Reflect.set(fileFormatSize, "__value__", __value__);
5229
- Reflect.set(folderELement, "__value__", __value__);
5230
- folderELement.appendChild(fileNameElement);
5231
- folderELement.appendChild(fileTimeElement);
5232
- folderELement.appendChild(fileFormatSize);
5233
- return {
5234
- folderELement,
5235
- fileNameElement,
5236
- fileTimeElement,
5237
- fileFormatSize,
5238
- };
5239
- }
5240
- /**
5241
- * 创建移动端文件夹元素
5242
- */
5243
- function createMobileFolderRowElement(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
5244
- let origin_fileName = fileName;
5245
- let origin_latestTime = latestTime;
5246
- let origin_fileSize = fileSize;
5247
- let folderELement = popsDOMUtils.createElement("tr");
5248
- let fileNameElement = popsDOMUtils.createElement("td");
5249
- let fileType = "";
5250
- let fileIcon = Folder_ICON.folder;
5251
- if (isFolder) {
5252
- /* 文件夹 */
5253
- latestTime = "";
5254
- fileSize = "";
5262
+ /* 存储原来的值 */
5263
+ let __value__ = {
5264
+ fileName: origin_fileName,
5265
+ latestTime: origin_latestTime,
5266
+ fileSize: origin_fileSize,
5267
+ isFolder: isFolder,
5268
+ };
5269
+ Reflect.set(fileNameElement, "__value__", __value__);
5270
+ Reflect.set(fileTimeElement, "__value__", __value__);
5271
+ Reflect.set(fileFormatSize, "__value__", __value__);
5272
+ Reflect.set(folderElement, "__value__", __value__);
5273
+ folderElement.appendChild(fileNameElement);
5274
+ folderElement.appendChild(fileTimeElement);
5275
+ folderElement.appendChild(fileFormatSize);
5276
+ return {
5277
+ folderElement,
5278
+ fileNameElement,
5279
+ fileTimeElement,
5280
+ fileFormatSize,
5281
+ };
5255
5282
  }
5256
- else {
5257
- /* 文件 */
5258
- fileIcon = "";
5259
- if (typeof latestTime === "number") {
5260
- latestTime = popsUtils.formatTime(latestTime);
5261
- }
5262
- if (typeof fileSize === "number") {
5263
- fileSize = popsUtils.formatByteToSize(fileSize);
5264
- }
5265
- for (let keyName in Folder_ICON) {
5266
- if (fileName.toLowerCase().endsWith("." + keyName)) {
5267
- fileType = keyName;
5268
- fileIcon = Folder_ICON[keyName];
5269
- break;
5270
- }
5283
+ /**
5284
+ * 创建移动端文件夹元素
5285
+ * @param fileName 文件名
5286
+ * @param latestTime 创建时间
5287
+ * @param [fileSize="-"] 文件大小
5288
+ * @param isFolder 是否是文件夹
5289
+ */
5290
+ createFolderRowElementByMobile(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
5291
+ let origin_fileName = fileName;
5292
+ let origin_latestTime = latestTime;
5293
+ let origin_fileSize = fileSize;
5294
+ let folderElement = popsDOMUtils.createElement("tr");
5295
+ let fileNameElement = popsDOMUtils.createElement("td");
5296
+ let fileType = "";
5297
+ let fileIcon = Folder_ICON.folder;
5298
+ if (isFolder) {
5299
+ /* 文件夹 */
5300
+ latestTime = "";
5301
+ fileSize = "";
5271
5302
  }
5272
- if (!Boolean(fileIcon)) {
5273
- fileType = "Null";
5274
- fileIcon = Folder_ICON.Null;
5303
+ else {
5304
+ /* 文件 */
5305
+ fileIcon = "";
5306
+ if (typeof latestTime === "number") {
5307
+ latestTime = popsUtils.formatTime(latestTime);
5308
+ }
5309
+ if (typeof fileSize === "number") {
5310
+ fileSize = popsUtils.formatByteToSize(fileSize);
5311
+ }
5312
+ for (let keyName in Folder_ICON) {
5313
+ if (fileName.toLowerCase().endsWith("." + keyName)) {
5314
+ fileType = keyName;
5315
+ fileIcon = Folder_ICON[keyName];
5316
+ break;
5317
+ }
5318
+ }
5319
+ if (!Boolean(fileIcon)) {
5320
+ fileType = "Null";
5321
+ fileIcon = Folder_ICON.Null;
5322
+ }
5275
5323
  }
5276
- }
5277
- folderELement.className = "pops-folder-list-table__body-row";
5278
- fileNameElement.className = "pops-folder-list-table__body-td";
5279
- PopsSafeUtils.setSafeHTML(fileNameElement,
5280
- /*html*/ `
5324
+ folderElement.className = "pops-folder-list-table__body-row";
5325
+ fileNameElement.className = "pops-folder-list-table__body-td";
5326
+ PopsSafeUtils.setSafeHTML(fileNameElement,
5327
+ /*html*/ `
5281
5328
  <div class="pops-folder-list-file-name pops-mobile-folder-list-file-name cursor-p">
5282
5329
  <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
5283
5330
  <div>
@@ -5286,139 +5333,138 @@ System.register('pops', [], (function (exports) {
5286
5333
  </div>
5287
5334
  </div>
5288
5335
  `);
5289
- /* 存储原来的值 */
5290
- let __value__ = {
5291
- fileName: origin_fileName,
5292
- latestTime: origin_latestTime,
5293
- fileSize: origin_fileSize,
5294
- isFolder: isFolder,
5295
- };
5296
- Reflect.set(fileNameElement, "__value__", __value__);
5297
- Reflect.set(folderELement, "__value__", __value__);
5298
- folderELement.appendChild(fileNameElement);
5299
- return {
5300
- folderELement,
5301
- fileNameElement,
5302
- };
5303
- }
5304
- /**
5305
- * 清空每行的元素
5306
- */
5307
- function clearFolderRow() {
5308
- PopsSafeUtils.setSafeHTML(folderListBodyElement, "");
5309
- }
5310
- /**
5311
- * 创建顶部导航的箭头图标
5312
- */
5313
- function createHeaderArrowIcon() {
5314
- let iconArrowElement = popsDOMUtils.createElement("div", {
5315
- className: "iconArrow",
5316
- });
5317
- return iconArrowElement;
5318
- }
5319
- /**
5320
- * 添加顶部导航
5321
- * @param folderName 文件夹名
5322
- * @param folderDataConfig 文件夹配置
5323
- */
5324
- function createHeaderFileLinkNavgiation(folderName, folderDataConfig) {
5325
- let spanElement = popsDOMUtils.createElement("span", {
5326
- className: "pops-folder-file-list-breadcrumb-allFiles cursor-p",
5327
- innerHTML: `<a>${folderName}</a>`,
5328
- _config_: folderDataConfig,
5329
- }, {
5330
- title: folderName,
5331
- });
5332
- return spanElement;
5333
- }
5334
- /**
5335
- * 顶部导航的点击事件
5336
- * @param event
5337
- * @param isTop 是否是全部文件按钮
5338
- * @param folderDataConfigList 配置
5339
- */
5340
- function breadcrumbAllFilesElementClickEvent(event, isTop, folderDataConfigList) {
5341
- clearFolderRow();
5342
- /* 获取当前的导航元素 */
5343
- let $click = event.target;
5344
- let currentBreadcrumb = $click.closest("span.pops-folder-file-list-breadcrumb-allFiles");
5345
- if (currentBreadcrumb) {
5346
- while (currentBreadcrumb.nextElementSibling) {
5347
- currentBreadcrumb.nextElementSibling.remove();
5336
+ /* 存储原来的值 */
5337
+ let __value__ = {
5338
+ fileName: origin_fileName,
5339
+ latestTime: origin_latestTime,
5340
+ fileSize: origin_fileSize,
5341
+ isFolder: isFolder,
5342
+ };
5343
+ Reflect.set(fileNameElement, "__value__", __value__);
5344
+ Reflect.set(folderElement, "__value__", __value__);
5345
+ folderElement.appendChild(fileNameElement);
5346
+ return {
5347
+ folderElement,
5348
+ fileNameElement,
5349
+ };
5350
+ }
5351
+ /**
5352
+ * 清空文件夹信息页面
5353
+ */
5354
+ clearFolderInfoView() {
5355
+ PopsSafeUtils.setSafeHTML(folderListBodyElement, "");
5356
+ }
5357
+ /**
5358
+ * 创建顶部导航的箭头图标
5359
+ */
5360
+ createHeaderArrowIcon() {
5361
+ let $arrowIcon = popsDOMUtils.createElement("div", {
5362
+ className: "iconArrow",
5363
+ });
5364
+ return $arrowIcon;
5365
+ }
5366
+ /**
5367
+ * 添加顶部导航元素
5368
+ * @param folderName 文件夹名
5369
+ * @param folderDataConfig 文件夹配置
5370
+ */
5371
+ createBreadcrumb(folderName, folderDataConfig) {
5372
+ let $breadcrumb = popsDOMUtils.createElement("span", {
5373
+ className: "pops-folder-file-list-breadcrumb-allFiles cursor-p",
5374
+ innerHTML: `<a>${folderName}</a>`,
5375
+ _config_: folderDataConfig,
5376
+ }, {
5377
+ title: folderName,
5378
+ });
5379
+ return $breadcrumb;
5380
+ }
5381
+ /**
5382
+ * 顶部导航的点击事件
5383
+ * @param clickEvent
5384
+ * @param isTop 是否是全部文件按钮
5385
+ * @param dataConfigList 配置
5386
+ */
5387
+ setBreadcrumbClickEvent(clickEvent, isTop, dataConfigList) {
5388
+ this.clearFolderInfoView();
5389
+ /* 获取当前的导航元素 */
5390
+ let $click = clickEvent.target;
5391
+ let currentBreadcrumb = $click.closest("span.pops-folder-file-list-breadcrumb-allFiles");
5392
+ if (currentBreadcrumb) {
5393
+ while (currentBreadcrumb.nextElementSibling) {
5394
+ currentBreadcrumb.nextElementSibling.remove();
5395
+ }
5348
5396
  }
5397
+ else {
5398
+ console.error("获取导航按钮失败");
5399
+ }
5400
+ let loadingMask = PopsLoading.init({
5401
+ parent: $content,
5402
+ content: {
5403
+ text: "获取文件列表中...",
5404
+ },
5405
+ mask: {
5406
+ enable: true,
5407
+ clickEvent: {
5408
+ toClose: false,
5409
+ toHide: false,
5410
+ },
5411
+ },
5412
+ addIndexCSS: false,
5413
+ });
5414
+ this.initFolderView(dataConfigList);
5415
+ loadingMask.close();
5349
5416
  }
5350
- else {
5351
- console.error("获取导航按钮失败");
5352
- }
5353
- let loadingMask = PopsLoading.init({
5354
- parent: $content,
5355
- content: {
5356
- text: "获取文件列表中...",
5357
- },
5358
- mask: {
5359
- enable: true,
5360
- clickEvent: {
5361
- toClose: false,
5362
- toHide: false,
5417
+ /**
5418
+ * 文件夹的点击事件 - 进入文件夹
5419
+ *
5420
+ * 先情况页面元素
5421
+ * @param clickEvent
5422
+ * @param dataConfig
5423
+ */
5424
+ async enterFolder(clickEvent, dataConfig) {
5425
+ this.clearFolderInfoView();
5426
+ let loadingMask = PopsLoading.init({
5427
+ parent: $content,
5428
+ content: {
5429
+ text: "获取文件列表中...",
5363
5430
  },
5364
- },
5365
- addIndexCSS: false,
5366
- });
5367
- addFolderElement(folderDataConfigList);
5368
- loadingMask.close();
5369
- }
5370
- /**
5371
- * 刷新文件列表界面信息
5372
- * @param event
5373
- * @param folderDataConfig
5374
- */
5375
- async function refreshFolderInfoClickEvent(event, folderDataConfig) {
5376
- clearFolderRow();
5377
- let loadingMask = PopsLoading.init({
5378
- parent: $content,
5379
- content: {
5380
- text: "获取文件列表中...",
5381
- },
5382
- mask: {
5383
- enable: true,
5384
- },
5385
- addIndexCSS: false,
5386
- });
5387
- if (typeof folderDataConfig.clickEvent === "function") {
5388
- let childConfig = await folderDataConfig.clickEvent(event, folderDataConfig);
5389
- /* 添加顶部导航的箭头 */
5390
- folderFileListBreadcrumbPrimaryElement.appendChild(createHeaderArrowIcon());
5391
- /* 添加顶部导航的链接文字 */
5392
- let breadcrumbAllFilesElement = createHeaderFileLinkNavgiation(folderDataConfig.fileName, childConfig);
5393
- folderFileListBreadcrumbPrimaryElement.appendChild(breadcrumbAllFilesElement);
5394
- /* 设置顶部导航点击事件 */
5395
- popsDOMUtils.on(breadcrumbAllFilesElement, "click", function (event) {
5396
- breadcrumbAllFilesElementClickEvent(event, false, childConfig);
5431
+ mask: {
5432
+ enable: true,
5433
+ },
5434
+ addIndexCSS: false,
5397
5435
  });
5398
- addFolderElement(childConfig);
5436
+ if (typeof dataConfig.clickEvent === "function") {
5437
+ let childConfig = await dataConfig.clickEvent(clickEvent, dataConfig);
5438
+ /* 添加顶部导航的箭头 */
5439
+ folderFileListBreadcrumbPrimaryElement.appendChild(this.createHeaderArrowIcon());
5440
+ /* 添加顶部导航的链接文字 */
5441
+ let breadcrumbAllFilesElement = this.createBreadcrumb(dataConfig.fileName, childConfig);
5442
+ folderFileListBreadcrumbPrimaryElement.appendChild(breadcrumbAllFilesElement);
5443
+ /* 设置顶部导航点击事件 */
5444
+ popsDOMUtils.on(breadcrumbAllFilesElement, "click", (event) => {
5445
+ this.setBreadcrumbClickEvent(event, false, childConfig);
5446
+ });
5447
+ this.initFolderView(childConfig);
5448
+ }
5449
+ loadingMask.close();
5399
5450
  }
5400
- loadingMask.close();
5401
- }
5402
- /**
5403
- * 设置文件点击事件
5404
- * @param targetElement
5405
- * @param _config_
5406
- */
5407
- function setFileClickEvent(targetElement, _config_) {
5408
- popsDOMUtils.on(targetElement, "click", async function (event) {
5409
- event?.preventDefault();
5410
- event?.stopPropagation();
5411
- event?.stopImmediatePropagation();
5412
- let linkElement = targetElement.querySelector("a");
5413
- if (typeof _config_.clickEvent === "function") {
5414
- let downloadInfo = await _config_.clickEvent(event, _config_);
5451
+ /**
5452
+ * 文件的点击事件 - 下载文件
5453
+ * @param $target
5454
+ * @param dataConfig
5455
+ */
5456
+ async downloadFile(clickEvent, $row, dataConfig) {
5457
+ popsDOMUtils.preventEvent(clickEvent);
5458
+ let $link = $row.querySelector("a");
5459
+ if (typeof dataConfig.clickEvent === "function") {
5460
+ let downloadInfo = await dataConfig.clickEvent(clickEvent, dataConfig);
5415
5461
  if (downloadInfo != null &&
5416
5462
  typeof downloadInfo === "object" &&
5417
5463
  !Array.isArray(downloadInfo) &&
5418
5464
  typeof downloadInfo.url === "string" &&
5419
5465
  downloadInfo.url.trim() !== "") {
5420
- linkElement.setAttribute("href", downloadInfo.url);
5421
- linkElement.setAttribute("target", "_blank");
5466
+ $link.setAttribute("href", downloadInfo.url);
5467
+ $link.setAttribute("target", "_blank");
5422
5468
  if (downloadInfo.autoDownload) {
5423
5469
  if (downloadInfo.mode == null || downloadInfo.mode === "") {
5424
5470
  /* 未设置mode的话默认为aBlank */
@@ -5462,215 +5508,190 @@ System.register('pops', [], (function (exports) {
5462
5508
  }
5463
5509
  }
5464
5510
  }
5465
- });
5466
- }
5467
- /**
5468
- * 对配置进行排序
5469
- * @param folderDataConfigList
5470
- * @param sortName 比较的属性,默认fileName
5471
- * @param isDesc 是否降序,默认false(升序)
5472
- */
5473
- function sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
5474
- if (sortName === "fileName") {
5475
- // 如果是以文件名排序,文件夹优先放前面
5476
- let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
5477
- return value.isFolder;
5478
- });
5479
- let onlyFileDataConfigList = folderDataConfigList.filter((value) => {
5480
- return !value.isFolder;
5481
- });
5482
- // 文件夹排序
5483
- onlyFolderDataConfigList.sort((leftConfig, rightConfig) => {
5484
- let beforeVal = leftConfig[sortName].toString();
5485
- let afterVal = rightConfig[sortName].toString();
5486
- let compareVal = beforeVal.localeCompare(afterVal);
5487
- if (isDesc) {
5488
- /* 降序 */
5489
- if (compareVal > 0) {
5490
- compareVal = -1;
5511
+ }
5512
+ /**
5513
+ * 对配置进行排序
5514
+ * @param folderDataConfigList
5515
+ * @param sortName 比较的属性,默认fileName
5516
+ * @param isDesc 是否降序,默认false(升序)
5517
+ */
5518
+ sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
5519
+ if (sortName === "fileName") {
5520
+ // 如果是以文件名排序,文件夹优先放前面
5521
+ let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
5522
+ return value.isFolder;
5523
+ });
5524
+ let onlyFileDataConfigList = folderDataConfigList.filter((value) => {
5525
+ return !value.isFolder;
5526
+ });
5527
+ // 文件夹排序
5528
+ onlyFolderDataConfigList.sort((leftConfig, rightConfig) => {
5529
+ let beforeVal = leftConfig[sortName].toString();
5530
+ let afterVal = rightConfig[sortName].toString();
5531
+ let compareVal = beforeVal.localeCompare(afterVal);
5532
+ if (isDesc) {
5533
+ /* 降序 */
5534
+ if (compareVal > 0) {
5535
+ compareVal = -1;
5536
+ }
5537
+ else if (compareVal < 0) {
5538
+ compareVal = 1;
5539
+ }
5491
5540
  }
5492
- else if (compareVal < 0) {
5493
- compareVal = 1;
5541
+ return compareVal;
5542
+ });
5543
+ // 文件名排序
5544
+ onlyFileDataConfigList.sort((leftConfig, rightConfig) => {
5545
+ let beforeVal = leftConfig[sortName].toString();
5546
+ let afterVal = rightConfig[sortName].toString();
5547
+ let compareVal = beforeVal.localeCompare(afterVal);
5548
+ if (isDesc) {
5549
+ /* 降序 */
5550
+ if (compareVal > 0) {
5551
+ compareVal = -1;
5552
+ }
5553
+ else if (compareVal < 0) {
5554
+ compareVal = 1;
5555
+ }
5494
5556
  }
5495
- }
5496
- return compareVal;
5497
- });
5498
- // 文件名排序
5499
- onlyFileDataConfigList.sort((leftConfig, rightConfig) => {
5500
- let beforeVal = leftConfig[sortName].toString();
5501
- let afterVal = rightConfig[sortName].toString();
5502
- let compareVal = beforeVal.localeCompare(afterVal);
5557
+ return compareVal;
5558
+ });
5503
5559
  if (isDesc) {
5504
- /* 降序 */
5505
- if (compareVal > 0) {
5506
- compareVal = -1;
5507
- }
5508
- else if (compareVal < 0) {
5509
- compareVal = 1;
5510
- }
5560
+ // 降序,文件夹在下面
5561
+ return [...onlyFileDataConfigList, ...onlyFolderDataConfigList];
5562
+ }
5563
+ else {
5564
+ // 升序,文件夹在上面
5565
+ return [...onlyFolderDataConfigList, ...onlyFileDataConfigList];
5511
5566
  }
5512
- return compareVal;
5513
- });
5514
- if (isDesc) {
5515
- // 降序,文件夹在下面
5516
- return [...onlyFileDataConfigList, ...onlyFolderDataConfigList];
5517
5567
  }
5518
5568
  else {
5519
- // 升序,文件夹在上面
5520
- return [...onlyFolderDataConfigList, ...onlyFileDataConfigList];
5521
- }
5522
- }
5523
- else {
5524
- folderDataConfigList.sort((beforeConfig, afterConfig) => {
5525
- let beforeVal = beforeConfig[sortName];
5526
- let afterVal = afterConfig[sortName];
5527
- if (sortName === "fileSize") {
5528
- /* 文件大小,进行Float转换 */
5529
- beforeVal = parseFloat(beforeVal.toString());
5530
- afterVal = parseFloat(afterVal.toString());
5531
- }
5532
- else if (sortName === "latestTime") {
5533
- /* 文件时间 */
5534
- beforeVal = new Date(beforeVal).getTime();
5535
- afterVal = new Date(afterVal).getTime();
5536
- }
5537
- if (beforeVal > afterVal) {
5538
- if (isDesc) {
5539
- /* 降序 */
5540
- return -1;
5569
+ folderDataConfigList.sort((beforeConfig, afterConfig) => {
5570
+ let beforeVal = beforeConfig[sortName];
5571
+ let afterVal = afterConfig[sortName];
5572
+ if (sortName === "fileSize") {
5573
+ /* 文件大小,进行Float转换 */
5574
+ beforeVal = parseFloat(beforeVal.toString());
5575
+ afterVal = parseFloat(afterVal.toString());
5541
5576
  }
5542
- else {
5543
- return 1;
5577
+ else if (sortName === "latestTime") {
5578
+ /* 文件时间 */
5579
+ beforeVal = new Date(beforeVal).getTime();
5580
+ afterVal = new Date(afterVal).getTime();
5544
5581
  }
5545
- }
5546
- else if (beforeVal < afterVal) {
5547
- if (isDesc) {
5548
- /* 降序 */
5549
- return 1;
5582
+ if (beforeVal > afterVal) {
5583
+ if (isDesc) {
5584
+ /* 降序 */
5585
+ return -1;
5586
+ }
5587
+ else {
5588
+ return 1;
5589
+ }
5590
+ }
5591
+ else if (beforeVal < afterVal) {
5592
+ if (isDesc) {
5593
+ /* 降序 */
5594
+ return 1;
5595
+ }
5596
+ else {
5597
+ return -1;
5598
+ }
5550
5599
  }
5551
5600
  else {
5552
- return -1;
5601
+ return 0;
5553
5602
  }
5603
+ });
5604
+ return folderDataConfigList;
5605
+ }
5606
+ }
5607
+ /**
5608
+ * 添加文件夹/文件行元素
5609
+ * @param dataConfig 配置
5610
+ */
5611
+ initFolderView(dataConfig) {
5612
+ // 先对文件夹、文件进行排序
5613
+ this.sortFolderConfig(dataConfig, config.sort.name, config.sort.isDesc);
5614
+ dataConfig.forEach((item) => {
5615
+ if (item.isFolder) {
5616
+ let { folderElement, fileNameElement } = popsUtils.isPhone()
5617
+ ? this.createFolderRowElementByMobile(item.fileName, "", "", true)
5618
+ : this.createFolderRowElement(item.fileName, "", "", true);
5619
+ // 文件夹 - 点击事件
5620
+ popsDOMUtils.on(fileNameElement, "click", (event) => {
5621
+ // 进入文件夹
5622
+ this.enterFolder(event, item);
5623
+ });
5624
+ folderListBodyElement.appendChild(folderElement);
5554
5625
  }
5555
5626
  else {
5556
- return 0;
5627
+ let { folderElement, fileNameElement } = popsUtils.isPhone()
5628
+ ? this.createFolderRowElementByMobile(item.fileName, item.latestTime, item.fileSize, false)
5629
+ : this.createFolderRowElement(item.fileName, item.latestTime, item.fileSize, false);
5630
+ // 文件 - 点击事件
5631
+ popsDOMUtils.on(fileNameElement, "click", (event) => {
5632
+ // 下载文件
5633
+ this.downloadFile(event, fileNameElement, item);
5634
+ });
5635
+ folderListBodyElement.appendChild(folderElement);
5557
5636
  }
5558
5637
  });
5559
- return folderDataConfigList;
5560
5638
  }
5561
- }
5562
- /**
5563
- * 添加元素
5564
- * @param _config_
5565
- */
5566
- function addFolderElement(_config_) {
5567
- sortFolderConfig(_config_, config.sort.name, config.sort.isDesc);
5568
- _config_.forEach((item) => {
5569
- if (item["isFolder"]) {
5570
- let { folderELement, fileNameElement } = popsUtils.isPhone()
5571
- ? createMobileFolderRowElement(item["fileName"], "", "", true)
5572
- : createFolderRowElement(item["fileName"], "", "", true);
5573
- popsDOMUtils.on(fileNameElement, "click", (event) => {
5574
- refreshFolderInfoClickEvent(event, item);
5575
- });
5576
- folderListBodyElement.appendChild(folderELement);
5639
+ /**
5640
+ * 移除所有箭头的被访问状态
5641
+ */
5642
+ removeArrowActiveStatus() {
5643
+ [
5644
+ ...Array.from(folderListSortFileNameElement.querySelectorAll(".pops-folder-icon-active")),
5645
+ ...Array.from(folderListSortLatestTimeElement.querySelectorAll(".pops-folder-icon-active")),
5646
+ ...Array.from(folderListSortFileSizeElement.querySelectorAll(".pops-folder-icon-active")),
5647
+ ].forEach((ele) => ele.classList.remove("pops-folder-icon-active"));
5648
+ }
5649
+ /**
5650
+ * 修改导航箭头的状态
5651
+ */
5652
+ changeArrowActive(arrowUp, arrowDown, isDesc) {
5653
+ this.removeArrowActiveStatus();
5654
+ if (isDesc) {
5655
+ arrowDown.classList.add("pops-folder-icon-active");
5577
5656
  }
5578
5657
  else {
5579
- let { folderELement, fileNameElement } = popsUtils.isPhone()
5580
- ? createMobileFolderRowElement(item["fileName"], item.latestTime, item.fileSize, false)
5581
- : createFolderRowElement(item["fileName"], item.latestTime, item.fileSize, false);
5582
- setFileClickEvent(fileNameElement, item);
5583
- folderListBodyElement.appendChild(folderELement);
5658
+ arrowUp.classList.add("pops-folder-icon-active");
5584
5659
  }
5585
- });
5586
- }
5587
- addFolderElement(config.folder);
5588
- /* 将数据存到全部文件的属性_config_中 */
5589
- let allFilesElement = folderFileListBreadcrumbPrimaryElement.querySelector(".pops-folder-list .pops-folder-file-list-breadcrumb-allFiles:first-child");
5590
- allFilesElement._config_ = config.folder;
5591
- /* 设置点击顶部的全部文件事件 */
5592
- popsDOMUtils.on(allFilesElement, "click", (event) => {
5593
- breadcrumbAllFilesElementClickEvent(event, true, config.folder);
5594
- });
5595
- /* 移除所有的当前排序的arrow */
5596
- function removeAllArrowActive() {
5597
- [
5598
- ...Array.from(folderListSortFileNameElement.querySelectorAll(".pops-folder-icon-active")),
5599
- ...Array.from(folderListSortLatestTimeElement.querySelectorAll(".pops-folder-icon-active")),
5600
- ...Array.from(folderListSortFileSizeElement.querySelectorAll(".pops-folder-icon-active")),
5601
- ].forEach((ele) => ele.classList.remove("pops-folder-icon-active"));
5602
- }
5603
- /* 设置当前的排序的arrow */
5604
- function changeArrowActive(arrowUp, arrowDown, isDesc) {
5605
- removeAllArrowActive();
5606
- if (isDesc) {
5607
- arrowDown.classList.add("pops-folder-icon-active");
5608
5660
  }
5609
- else {
5610
- arrowUp.classList.add("pops-folder-icon-active");
5611
- }
5612
- }
5613
- /**
5614
- * 排序按钮的点击事件
5615
- * @param {PointerEvent} target
5616
- * @param {HTMLElement} event
5617
- * @param {string} sortName
5618
- */
5619
- function arrowSortClickEvent(target, event, sortName) {
5620
- if (!event["notChangeSortRule"]) {
5621
- config.sort.name = sortName;
5622
- config.sort.isDesc = !config.sort.isDesc;
5623
- }
5624
- let arrowUp = target.querySelector(".pops-folder-icon-arrow-up");
5625
- let arrowDown = target.querySelector(".pops-folder-icon-arrow-down");
5626
- changeArrowActive(arrowUp, arrowDown, config.sort.isDesc);
5627
- if (typeof config.sort.callback === "function" &&
5628
- config.sort.callback(target, event, config.sort.name, config.sort.isDesc)) {
5629
- return;
5661
+ /**
5662
+ * 排序按钮的点击事件
5663
+ * @param target
5664
+ * @param event
5665
+ * @param sortName
5666
+ */
5667
+ arrowToSortFolderInfoView(target, event, sortName) {
5668
+ const notChangeSortRule = Reflect.get(event, "notChangeSortRule");
5669
+ if (!notChangeSortRule) {
5670
+ config.sort.name = sortName;
5671
+ config.sort.isDesc = !config.sort.isDesc;
5672
+ }
5673
+ let arrowUp = target.querySelector(".pops-folder-icon-arrow-up");
5674
+ let arrowDown = target.querySelector(".pops-folder-icon-arrow-down");
5675
+ this.changeArrowActive(arrowUp, arrowDown, config.sort.isDesc);
5676
+ if (typeof config.sort.callback === "function" &&
5677
+ config.sort.callback(target, event, config.sort.name, config.sort.isDesc)) {
5678
+ return;
5679
+ }
5680
+ let childrenList = [];
5681
+ Array.from(folderListBodyElement.children).forEach((trElement) => {
5682
+ let __value__ = Reflect.get(trElement, "__value__");
5683
+ Reflect.set(__value__, "target", trElement);
5684
+ childrenList.push(__value__);
5685
+ });
5686
+ let sortedConfigList = this.sortFolderConfig(childrenList, config.sort.name, config.sort.isDesc);
5687
+ sortedConfigList.forEach((item) => {
5688
+ folderListBodyElement.appendChild(item.target);
5689
+ });
5630
5690
  }
5631
- let childrenList = [];
5632
- Array.from(folderListBodyElement.children).forEach((trElement) => {
5633
- let __value__ = trElement["__value__"];
5634
- __value__["target"] = trElement;
5635
- childrenList.push(__value__);
5636
- });
5637
- let sortedConfigList = sortFolderConfig(childrenList, config.sort.name, config.sort.isDesc);
5638
- sortedConfigList.forEach((item) => {
5639
- folderListBodyElement.appendChild(item.target);
5640
- });
5641
- }
5642
- /* 设置当前排序的图标按钮 */
5643
- popsDOMUtils.on(folderListSortFileNameElement.closest("th"), "click", function (event) {
5644
- arrowSortClickEvent(folderListSortFileNameElement, event, "fileName");
5645
- }, {
5646
- capture: true,
5647
- });
5648
- popsDOMUtils.on(folderListSortLatestTimeElement.closest("th"), "click", void 0, function (event) {
5649
- arrowSortClickEvent(folderListSortLatestTimeElement, event, "latestTime");
5650
- }, {
5651
- capture: true,
5652
- });
5653
- popsDOMUtils.on(folderListSortFileSizeElement.closest("th"), "click", void 0, function (event) {
5654
- arrowSortClickEvent(folderListSortFileSizeElement, event, "fileSize");
5655
- }, {
5656
- capture: true,
5657
- });
5658
- /* 设置默认触发的arrow */
5659
- if (config.sort.name === "fileName") {
5660
- popsDOMUtils.trigger(folderListSortFileNameElement, "click", {
5661
- notChangeSortRule: true,
5662
- });
5663
- }
5664
- else if (config.sort.name === "latestTime") {
5665
- popsDOMUtils.trigger(folderListSortLatestTimeElement, "click", {
5666
- notChangeSortRule: true,
5667
- });
5668
- }
5669
- else if (config.sort.name === "fileSize") {
5670
- popsDOMUtils.trigger(folderListSortFileSizeElement, "click", {
5671
- notChangeSortRule: true,
5672
- });
5673
5691
  }
5692
+ const popsFolder = new PopsFolder();
5693
+ popsFolder.init();
5694
+ Reflect.set($pops, "data-pops-folder", popsFolder);
5674
5695
  /* 拖拽 */
5675
5696
  if (config.drag) {
5676
5697
  PopsInstanceUtils.drag($pops, {
@@ -11015,7 +11036,7 @@ System.register('pops', [], (function (exports) {
11015
11036
  let $el = popsDOMUtils.createElement("div", {
11016
11037
  className: `pops pops-${popsType}-search-suggestion`,
11017
11038
  innerHTML: /*html*/ `
11018
- <style>
11039
+ <style type="text/css">
11019
11040
  .pops-${popsType}-animation{
11020
11041
  -moz-animation: searchSelectFalIn 0.5s 1 linear;
11021
11042
  -webkit-animation: searchSelectFalIn 0.5s 1 linear;
@@ -11023,7 +11044,7 @@ System.register('pops', [], (function (exports) {
11023
11044
  -ms-animation: searchSelectFalIn 0.5s 1 linear;
11024
11045
  }
11025
11046
  </style>
11026
- <style>
11047
+ <style type="text/css">
11027
11048
  .pops-${popsType}-search-suggestion-arrow{
11028
11049
  --suggestion-arrow-box-shadow-left-color: rgba(0, 0, 0, 0.24);
11029
11050
  --suggestion-arrow-box-shadow-right-color: rgba(0, 0, 0, 0.12);
@@ -11089,7 +11110,7 @@ System.register('pops', [], (function (exports) {
11089
11110
  content: "";
11090
11111
  }
11091
11112
  </style>
11092
- <style data-dynamic="true">
11113
+ <style type="text/css" data-dynamic="true">
11093
11114
  ${this.getDynamicCSS()}
11094
11115
  </style>
11095
11116
  <style>
@@ -11111,6 +11132,9 @@ System.register('pops', [], (function (exports) {
11111
11132
  transform: scaleY(1);
11112
11133
  }
11113
11134
  </style>
11135
+ <style type="text/css" data-user-css>
11136
+ ${config.style || ""}
11137
+ </style>
11114
11138
  <ul class="pops-${popsType}-search-suggestion-hint ${PopsCommonCSSClassName.userSelectNone}">${config.toSearhNotResultHTML}</ul>
11115
11139
  ${config.useArrow ? /*html*/ `<div class="pops-${popsType}-search-suggestion-arrow"></div>` : ""}
11116
11140
  `,
@@ -11627,7 +11651,7 @@ System.register('pops', [], (function (exports) {
11627
11651
  /** 配置 */
11628
11652
  config = {
11629
11653
  /** 版本号 */
11630
- version: "2025.8.17",
11654
+ version: "2025.9.2",
11631
11655
  cssText: PopsCSS,
11632
11656
  /** icon图标的svg代码 */
11633
11657
  iconSVG: PopsIcon.$data,