solely 0.4.11 → 0.4.12

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 (75) hide show
  1. package/dist/components/commands/modal/index.cjs +1 -1
  2. package/dist/components/commands/modal/index.js +1 -1
  3. package/dist/components/elements/alert/index.html.cjs +1 -1
  4. package/dist/components/elements/alert/index.html.js +1 -1
  5. package/dist/components/elements/backtop/index.cjs +1 -1
  6. package/dist/components/elements/backtop/index.d.ts +10 -0
  7. package/dist/components/elements/backtop/index.html.cjs +1 -1
  8. package/dist/components/elements/backtop/index.html.js +1 -1
  9. package/dist/components/elements/backtop/index.js +1 -1
  10. package/dist/components/elements/badge/index.html.cjs +1 -1
  11. package/dist/components/elements/badge/index.html.js +1 -1
  12. package/dist/components/elements/breadcrumb/index.html.cjs +1 -1
  13. package/dist/components/elements/breadcrumb/index.html.js +1 -1
  14. package/dist/components/elements/button/index.html.cjs +1 -1
  15. package/dist/components/elements/button/index.html.js +1 -1
  16. package/dist/components/elements/button/style.css.cjs +1 -1
  17. package/dist/components/elements/button/style.css.js +1 -1
  18. package/dist/components/elements/card/index.html.cjs +1 -1
  19. package/dist/components/elements/card/index.html.js +1 -1
  20. package/dist/components/elements/checkbox/index.html.cjs +1 -1
  21. package/dist/components/elements/checkbox/index.html.js +1 -1
  22. package/dist/components/elements/coordinate-input/index.html.cjs +1 -1
  23. package/dist/components/elements/coordinate-input/index.html.js +1 -1
  24. package/dist/components/elements/divider/index.html.cjs +1 -1
  25. package/dist/components/elements/divider/index.html.js +1 -1
  26. package/dist/components/elements/empty/index.html.cjs +1 -1
  27. package/dist/components/elements/empty/index.html.js +1 -1
  28. package/dist/components/elements/fab/index.html.cjs +1 -1
  29. package/dist/components/elements/fab/index.html.js +1 -1
  30. package/dist/components/elements/icon/index.html.cjs +1 -1
  31. package/dist/components/elements/icon/index.html.js +1 -1
  32. package/dist/components/elements/input/index.html.cjs +1 -1
  33. package/dist/components/elements/input/index.html.js +1 -1
  34. package/dist/components/elements/not-found/index.html.cjs +1 -1
  35. package/dist/components/elements/not-found/index.html.js +1 -1
  36. package/dist/components/elements/pagination/index.cjs +1 -1
  37. package/dist/components/elements/pagination/index.html.cjs +1 -1
  38. package/dist/components/elements/pagination/index.html.js +1 -1
  39. package/dist/components/elements/pagination/index.js +1 -1
  40. package/dist/components/elements/progress/index.html.cjs +1 -1
  41. package/dist/components/elements/progress/index.html.js +1 -1
  42. package/dist/components/elements/radio/index.html.cjs +1 -1
  43. package/dist/components/elements/radio/index.html.js +1 -1
  44. package/dist/components/elements/rate/index.html.cjs +1 -1
  45. package/dist/components/elements/rate/index.html.js +1 -1
  46. package/dist/components/elements/select/index.html.cjs +1 -1
  47. package/dist/components/elements/select/index.html.js +1 -1
  48. package/dist/components/elements/skeleton/index.html.cjs +1 -1
  49. package/dist/components/elements/skeleton/index.html.js +1 -1
  50. package/dist/components/elements/slider/index.html.cjs +1 -1
  51. package/dist/components/elements/slider/index.html.js +1 -1
  52. package/dist/components/elements/steps/index.d.ts +3 -12
  53. package/dist/components/elements/steps/index.html.cjs +1 -1
  54. package/dist/components/elements/steps/index.html.js +1 -1
  55. package/dist/components/elements/steps/types.d.ts +13 -0
  56. package/dist/components/elements/switch/index.html.cjs +1 -1
  57. package/dist/components/elements/switch/index.html.js +1 -1
  58. package/dist/components/elements/table/index.html.cjs +1 -1
  59. package/dist/components/elements/table/index.html.js +1 -1
  60. package/dist/components/elements/tabs/index.html.cjs +1 -1
  61. package/dist/components/elements/tabs/index.html.js +1 -1
  62. package/dist/components/elements/tabs/types.d.ts +10 -0
  63. package/dist/components/elements/tag/index.html.cjs +1 -1
  64. package/dist/components/elements/tag/index.html.js +1 -1
  65. package/dist/components/elements/timeline/index.html.cjs +1 -1
  66. package/dist/components/elements/timeline/index.html.js +1 -1
  67. package/dist/components/elements/tree/index.html.cjs +1 -1
  68. package/dist/components/elements/tree/index.html.js +1 -1
  69. package/dist/components/elements/tree/types.d.ts +17 -0
  70. package/dist/components/elements/upload/index.cjs +1 -1
  71. package/dist/components/elements/upload/index.d.ts +1 -0
  72. package/dist/components/elements/upload/index.html.cjs +1 -1
  73. package/dist/components/elements/upload/index.html.js +1 -1
  74. package/dist/components/elements/upload/index.js +1 -1
  75. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div\n class="timeline"\n :class="this.getTimelineClasses()"\n>\n <ul class="timeline__list">\n <For each="this.getParsedItems()" item="item" index="index">\n <li\n class="timeline__item"\n :class="this.getItemClasses(item, index)"\n >\n <div class="timeline__item-tail"></div>\n <div class="timeline__item-wrapper">\n <div class="timeline__item-head">\n <If test="item.loading">\n <div\n class="timeline__dot"\n :class="this.getDotClasses(item)"\n :style="this.getDotStyle(item)"\n ></div>\n </If>\n <ElseIf test="item.icon">\n <div\n class="timeline__icon-wrapper"\n :style="this.getIconStyle(item)"\n >{{item.icon}}</div>\n </ElseIf>\n <Else>\n <div\n class="timeline__dot"\n :class="this.getDotClasses(item)"\n :style="this.getDotStyle(item)"\n ></div>\n </Else>\n </div>\n <div class="timeline__item-content">\n <div class="timeline__title">{{item.title}}</div>\n <If test="item.content">\n <div class="timeline__content-text">{{item.content}}</div>\n </If>\n <If test="item.time">\n <div class="timeline__time">{{item.time}}</div>\n </If>\n </div>\n </div>\n </li>\n </For>\n\n <If test="$data.pending">\n <li class="timeline__item timeline__item--pending">\n <div class="timeline__item-tail"></div>\n <div class="timeline__item-wrapper">\n <div class="timeline__item-head">\n <div class="timeline__dot"></div>\n </div>\n <div class="timeline__item-content">\n <span>{{$data.pendingContent || \'待定\'}}</span>\n </div>\n </div>\n </li>\n </If>\n </ul>\n</div>\n';
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div\n part="base"\n class="timeline"\n :class="this.getTimelineClasses()"\n>\n <ul part="list" class="timeline__list">\n <For each="this.getParsedItems()" item="item" index="index">\n <li\n part="item"\n class="timeline__item"\n :class="this.getItemClasses(item, index)"\n >\n <div part="tail" class="timeline__item-tail"></div>\n <div part="item-wrapper" class="timeline__item-wrapper">\n <div part="head" class="timeline__item-head">\n <If test="item.loading">\n <div\n part="dot"\n class="timeline__dot"\n :class="this.getDotClasses(item)"\n :style="this.getDotStyle(item)"\n ></div>\n </If>\n <ElseIf test="item.icon">\n <div\n part="icon-wrapper"\n class="timeline__icon-wrapper"\n :style="this.getIconStyle(item)"\n >{{item.icon}}</div>\n </ElseIf>\n <Else>\n <div\n part="dot"\n class="timeline__dot"\n :class="this.getDotClasses(item)"\n :style="this.getDotStyle(item)"\n ></div>\n </Else>\n </div>\n <div part="item-content" class="timeline__item-content">\n <div part="title" class="timeline__title">{{item.title}}</div>\n <If test="item.content">\n <div part="content-text" class="timeline__content-text">{{item.content}}</div>\n </If>\n <If test="item.time">\n <div part="time" class="timeline__time">{{item.time}}</div>\n </If>\n </div>\n </div>\n </li>\n </For>\n\n <If test="$data.pending">\n <li part="item" class="timeline__item timeline__item--pending">\n <div part="tail" class="timeline__item-tail"></div>\n <div part="item-wrapper" class="timeline__item-wrapper">\n <div part="head" class="timeline__item-head">\n <div part="dot" class="timeline__dot"></div>\n </div>\n <div part="item-content" class="timeline__item-content">\n <span>{{$data.pendingContent || \'待定\'}}</span>\n </div>\n </div>\n </li>\n </If>\n </ul>\n</div>\n';
@@ -1 +1 @@
1
- const i='<div\n class="timeline"\n :class="this.getTimelineClasses()"\n>\n <ul class="timeline__list">\n <For each="this.getParsedItems()" item="item" index="index">\n <li\n class="timeline__item"\n :class="this.getItemClasses(item, index)"\n >\n <div class="timeline__item-tail"></div>\n <div class="timeline__item-wrapper">\n <div class="timeline__item-head">\n <If test="item.loading">\n <div\n class="timeline__dot"\n :class="this.getDotClasses(item)"\n :style="this.getDotStyle(item)"\n ></div>\n </If>\n <ElseIf test="item.icon">\n <div\n class="timeline__icon-wrapper"\n :style="this.getIconStyle(item)"\n >{{item.icon}}</div>\n </ElseIf>\n <Else>\n <div\n class="timeline__dot"\n :class="this.getDotClasses(item)"\n :style="this.getDotStyle(item)"\n ></div>\n </Else>\n </div>\n <div class="timeline__item-content">\n <div class="timeline__title">{{item.title}}</div>\n <If test="item.content">\n <div class="timeline__content-text">{{item.content}}</div>\n </If>\n <If test="item.time">\n <div class="timeline__time">{{item.time}}</div>\n </If>\n </div>\n </div>\n </li>\n </For>\n\n <If test="$data.pending">\n <li class="timeline__item timeline__item--pending">\n <div class="timeline__item-tail"></div>\n <div class="timeline__item-wrapper">\n <div class="timeline__item-head">\n <div class="timeline__dot"></div>\n </div>\n <div class="timeline__item-content">\n <span>{{$data.pendingContent || \'待定\'}}</span>\n </div>\n </div>\n </li>\n </If>\n </ul>\n</div>\n';export{i as default};
1
+ const t='<div\n part="base"\n class="timeline"\n :class="this.getTimelineClasses()"\n>\n <ul part="list" class="timeline__list">\n <For each="this.getParsedItems()" item="item" index="index">\n <li\n part="item"\n class="timeline__item"\n :class="this.getItemClasses(item, index)"\n >\n <div part="tail" class="timeline__item-tail"></div>\n <div part="item-wrapper" class="timeline__item-wrapper">\n <div part="head" class="timeline__item-head">\n <If test="item.loading">\n <div\n part="dot"\n class="timeline__dot"\n :class="this.getDotClasses(item)"\n :style="this.getDotStyle(item)"\n ></div>\n </If>\n <ElseIf test="item.icon">\n <div\n part="icon-wrapper"\n class="timeline__icon-wrapper"\n :style="this.getIconStyle(item)"\n >{{item.icon}}</div>\n </ElseIf>\n <Else>\n <div\n part="dot"\n class="timeline__dot"\n :class="this.getDotClasses(item)"\n :style="this.getDotStyle(item)"\n ></div>\n </Else>\n </div>\n <div part="item-content" class="timeline__item-content">\n <div part="title" class="timeline__title">{{item.title}}</div>\n <If test="item.content">\n <div part="content-text" class="timeline__content-text">{{item.content}}</div>\n </If>\n <If test="item.time">\n <div part="time" class="timeline__time">{{item.time}}</div>\n </If>\n </div>\n </div>\n </li>\n </For>\n\n <If test="$data.pending">\n <li part="item" class="timeline__item timeline__item--pending">\n <div part="tail" class="timeline__item-tail"></div>\n <div part="item-wrapper" class="timeline__item-wrapper">\n <div part="head" class="timeline__item-head">\n <div part="dot" class="timeline__dot"></div>\n </div>\n <div part="item-content" class="timeline__item-content">\n <span>{{$data.pendingContent || \'待定\'}}</span>\n </div>\n </div>\n </li>\n </If>\n </ul>\n</div>\n';export{t as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div class="tree" :class="this.getTreeClasses()">\n <ul class="tree__list">\n <For each="$data.flattenedTree" item="node">\n <li\n class="tree__node"\n :class="this.getNodeClasses(node)"\n :style="\'padding-left: \' + (node.level * 24 + 12) + \'px\'"\n >\n <div\n class="tree__content"\n :class="this.getContentClasses(node)"\n @click="this.handleNodeClick(node)"\n >\n \x3c!-- 展开/折叠图标 --\x3e\n <span\n class="tree__switcher"\n :class="this.getSwitcherClasses(node)"\n @click="this.handleToggle(node, event)"\n >\n ▶\n </span>\n\n \x3c!-- 复选框 --\x3e\n <If condition="$data.checkable">\n <span\n class="tree__checkbox"\n :class="this.getCheckboxClasses(node)"\n @click="this.handleCheck(node, event)"\n ></span>\n </If>\n\n \x3c!-- 节点图标 --\x3e\n <If condition="node.icon">\n <span class="tree__icon">{{node.icon}}</span>\n </If>\n\n \x3c!-- 节点标题 --\x3e\n <span class="tree__title">{{node.title}}</span>\n </div>\n </li>\n </For>\n </ul>\n</div>\n';
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div part="base" class="tree" :class="this.getTreeClasses()" role="tree">\n <ul part="list" class="tree__list">\n <For each="$data.flattenedTree" item="node">\n <li\n part="node"\n class="tree__node"\n :class="this.getNodeClasses(node)"\n :style="\'padding-left: \' + (node.level * 24 + 12) + \'px\'"\n role="treeitem"\n :aria-expanded="node.children && node.children.length > 0 ? (node.expanded ? \'true\' : \'false\') : undefined"\n :aria-selected="node.selected ? \'true\' : \'false\'"\n :aria-disabled="node.disabled ? \'true\' : \'false\'"\n :aria-level="node.level + 1"\n >\n <div\n part="content"\n class="tree__content"\n :class="this.getContentClasses(node)"\n @click="this.handleNodeClick(node)"\n >\n \x3c!-- 展开/折叠图标 --\x3e\n <span\n part="switcher"\n class="tree__switcher"\n :class="this.getSwitcherClasses(node)"\n @click="this.handleToggle(node, event)"\n role="button"\n :aria-label="node.expanded ? \'折叠\' : \'展开\'"\n tabindex="0"\n >\n ▶\n </span>\n\n \x3c!-- 复选框 --\x3e\n <If condition="$data.checkable">\n <span\n part="checkbox"\n class="tree__checkbox"\n :class="this.getCheckboxClasses(node)"\n @click="this.handleCheck(node, event)"\n role="checkbox"\n :aria-checked="node.halfChecked ? \'mixed\' : (node.checked ? \'true\' : \'false\')"\n :aria-disabled="node.disabled ? \'true\' : \'false\'"\n tabindex="0"\n ></span>\n </If>\n\n \x3c!-- 节点图标 --\x3e\n <If condition="node.icon">\n <span part="icon" class="tree__icon">{{node.icon}}</span>\n </If>\n\n \x3c!-- 节点标题 --\x3e\n <span part="title" class="tree__title">{{node.title}}</span>\n </div>\n </li>\n </For>\n </ul>\n</div>\n';
@@ -1 +1 @@
1
- const n='<div class="tree" :class="this.getTreeClasses()">\n <ul class="tree__list">\n <For each="$data.flattenedTree" item="node">\n <li\n class="tree__node"\n :class="this.getNodeClasses(node)"\n :style="\'padding-left: \' + (node.level * 24 + 12) + \'px\'"\n >\n <div\n class="tree__content"\n :class="this.getContentClasses(node)"\n @click="this.handleNodeClick(node)"\n >\n \x3c!-- 展开/折叠图标 --\x3e\n <span\n class="tree__switcher"\n :class="this.getSwitcherClasses(node)"\n @click="this.handleToggle(node, event)"\n >\n ▶\n </span>\n\n \x3c!-- 复选框 --\x3e\n <If condition="$data.checkable">\n <span\n class="tree__checkbox"\n :class="this.getCheckboxClasses(node)"\n @click="this.handleCheck(node, event)"\n ></span>\n </If>\n\n \x3c!-- 节点图标 --\x3e\n <If condition="node.icon">\n <span class="tree__icon">{{node.icon}}</span>\n </If>\n\n \x3c!-- 节点标题 --\x3e\n <span class="tree__title">{{node.title}}</span>\n </div>\n </li>\n </For>\n </ul>\n</div>\n';export{n as default};
1
+ const e='<div part="base" class="tree" :class="this.getTreeClasses()" role="tree">\n <ul part="list" class="tree__list">\n <For each="$data.flattenedTree" item="node">\n <li\n part="node"\n class="tree__node"\n :class="this.getNodeClasses(node)"\n :style="\'padding-left: \' + (node.level * 24 + 12) + \'px\'"\n role="treeitem"\n :aria-expanded="node.children && node.children.length > 0 ? (node.expanded ? \'true\' : \'false\') : undefined"\n :aria-selected="node.selected ? \'true\' : \'false\'"\n :aria-disabled="node.disabled ? \'true\' : \'false\'"\n :aria-level="node.level + 1"\n >\n <div\n part="content"\n class="tree__content"\n :class="this.getContentClasses(node)"\n @click="this.handleNodeClick(node)"\n >\n \x3c!-- 展开/折叠图标 --\x3e\n <span\n part="switcher"\n class="tree__switcher"\n :class="this.getSwitcherClasses(node)"\n @click="this.handleToggle(node, event)"\n role="button"\n :aria-label="node.expanded ? \'折叠\' : \'展开\'"\n tabindex="0"\n >\n ▶\n </span>\n\n \x3c!-- 复选框 --\x3e\n <If condition="$data.checkable">\n <span\n part="checkbox"\n class="tree__checkbox"\n :class="this.getCheckboxClasses(node)"\n @click="this.handleCheck(node, event)"\n role="checkbox"\n :aria-checked="node.halfChecked ? \'mixed\' : (node.checked ? \'true\' : \'false\')"\n :aria-disabled="node.disabled ? \'true\' : \'false\'"\n tabindex="0"\n ></span>\n </If>\n\n \x3c!-- 节点图标 --\x3e\n <If condition="node.icon">\n <span part="icon" class="tree__icon">{{node.icon}}</span>\n </If>\n\n \x3c!-- 节点标题 --\x3e\n <span part="title" class="tree__title">{{node.title}}</span>\n </div>\n </li>\n </For>\n </ul>\n</div>\n';export{e as default};
@@ -45,3 +45,20 @@ export interface TreeProps {
45
45
  /** 是否撑满父容器宽度 */
46
46
  block?: boolean;
47
47
  }
48
+ /** select 事件 detail */
49
+ export interface TreeSelectEventDetail {
50
+ selectedKeys: string[];
51
+ selectedNodes: TreeNode[];
52
+ node: TreeNode;
53
+ }
54
+ /** check 事件 detail */
55
+ export interface TreeCheckEventDetail {
56
+ checkedKeys: string[];
57
+ checkedNodes: TreeNode[];
58
+ node: TreeNode;
59
+ }
60
+ /** expand 事件 detail */
61
+ export interface TreeExpandEventDetail {
62
+ expandedKeys: string[];
63
+ node: TreeNode;
64
+ }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),s=require("../utils/helpers.cjs"),a=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyUpload=class extends a.default{getUploadClasses(){const e={};return this.$data.listType&&(e[`upload--${this.$data.listType}`]=!0),e["is-disabled"]=!!this.$data.disabled,e}get fileList(){return this.$data.parsedFileList}getDragClasses(){return{"upload__drag--active":!!this.$data.isDragging}}mounted(){this.refresh(),this.parseFileList(),this.$data.isDragging=!1}parseFileList(){this.$data.parsedFileList=s.safeJsonParse(this.$data.fileList,[])}triggerUpload(){var e;if(this.$data.disabled)return;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('input[type="file"]');t&&t.click()}handleFileChange(e){const t=e.target,s=t.files;s&&s.length>0&&this.handleFiles(s),t.value=""}handleFiles(e){const t=this.$data.maxCount||1/0,s=this.$data.maxSize||1/0;Array.from(e).forEach(e=>{if(this.$data.parsedFileList.length>=t)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件数量超过限制 (最多 ${t} 个)`});if(e.size>s)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件大小超过限制 (${this.formatSize(s)})`});const a={uid:Date.now()+Math.random().toString(36).substr(2,9),name:e.name,size:e.size,type:e.type,status:"uploading",percent:0};this.$data.parsedFileList.push(a),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.uploadFile(a,e)})}uploadFile(e,t){if(!this.$data.action)return e.status="done",e.percent=100,e.url=URL.createObjectURL(t),this.refresh(),this.emit("success",{file:e,fileList:this.$data.parsedFileList}),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));const s=new XMLHttpRequest,a=new FormData;a.append("file",t),s.upload.addEventListener("progress",t=>{t.lengthComputable&&(e.percent=Math.round(t.loaded/t.total*100),this.$data.parsedFileList=[...this.$data.parsedFileList])}),s.addEventListener("load",()=>{if(s.status>=200&&s.status<300){e.status="done",e.percent=100;try{const t=JSON.parse(s.responseText);t.url&&(e.url=t.url)}catch{}this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("success",{file:e,fileList:this.$data.parsedFileList})}else e.status="error",e.error=s.statusText,this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:s.statusText});this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.addEventListener("error",()=>{e.status="error",e.error="网络错误",this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:"网络错误"}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.open("POST",this.$data.action,!0),s.send(a)}handleDragOver(e){e.preventDefault(),this.$data.isDragging=!0}handleDragLeave(e){e.preventDefault(),this.$data.isDragging=!1}handleDrop(e){var t;e.preventDefault(),this.$data.isDragging=!1;const s=null==(t=e.dataTransfer)?void 0:t.files;s&&s.length>0&&this.handleFiles(s)}handleRemove(e){const t=this.$data.parsedFileList.findIndex(t=>t.uid===e.uid);t>-1&&(this.$data.parsedFileList.splice(t,1),this.emit("remove",{file:e,fileList:this.$data.parsedFileList}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}getStatusText(e){return{uploading:"上传中",done:"完成",error:"失败",removed:"已删除"}[e||""]||""}getFileList(){return this.$data.parsedFileList}clear(){this.$data.parsedFileList=[]}},exports.SolelyUpload=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([i.CustomElement({tagName:"solely-upload",template:t.default,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"action",type:"string"},{name:"accept",type:"string"},{name:"multiple",type:"boolean",default:!1},{name:"fileList",type:"string"},{name:"listType",type:"string"},{name:"disabled",type:"boolean",default:!1},{name:"showUploadList",type:"boolean",default:!0},{name:"buttonText",type:"string"},{name:"drag",type:"boolean",default:!1},{name:"maxCount",type:"number"},{name:"maxSize",type:"number"},{name:"block",type:"boolean",default:!1}]})],exports.SolelyUpload);
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),s=require("../utils/helpers.cjs"),a=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyUpload=class extends a.default{getUploadClasses(){const e={};return this.$data.listType&&(e[`upload--${this.$data.listType}`]=!0),e["is-disabled"]=!!this.$data.disabled,e}get fileList(){return this.$data.parsedFileList}set fileList(e){this.$data.parsedFileList=e,this.$data.fileList=JSON.stringify(e)}getDragClasses(){return{"upload__drag--active":!!this.$data.isDragging}}mounted(){this.refresh(),this.parseFileList(),this.$data.isDragging=!1}parseFileList(){this.$data.parsedFileList=s.safeJsonParse(this.$data.fileList,[])}triggerUpload(){var e;if(this.$data.disabled)return;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('input[type="file"]');t&&t.click()}handleFileChange(e){const t=e.target,s=t.files;s&&s.length>0&&this.handleFiles(s),t.value=""}handleFiles(e){const t=this.$data.maxCount||1/0,s=this.$data.maxSize||1/0;Array.from(e).forEach(e=>{if(this.$data.parsedFileList.length>=t)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件数量超过限制 (最多 ${t} 个)`});if(e.size>s)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件大小超过限制 (${this.formatSize(s)})`});const a={uid:Date.now()+Math.random().toString(36).substr(2,9),name:e.name,size:e.size,type:e.type,status:"uploading",percent:0};this.$data.parsedFileList.push(a),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.uploadFile(a,e)})}uploadFile(e,t){if(!this.$data.action)return e.status="done",e.percent=100,e.url=URL.createObjectURL(t),this.refresh(),this.emit("success",{file:e,fileList:this.$data.parsedFileList}),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));const s=new XMLHttpRequest,a=new FormData;a.append("file",t),s.upload.addEventListener("progress",t=>{t.lengthComputable&&(e.percent=Math.round(t.loaded/t.total*100),this.$data.parsedFileList=[...this.$data.parsedFileList])}),s.addEventListener("load",()=>{if(s.status>=200&&s.status<300){e.status="done",e.percent=100;try{const t=JSON.parse(s.responseText);t.url&&(e.url=t.url)}catch{}this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("success",{file:e,fileList:this.$data.parsedFileList})}else e.status="error",e.error=s.statusText,this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:s.statusText});this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.addEventListener("error",()=>{e.status="error",e.error="网络错误",this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:"网络错误"}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.open("POST",this.$data.action,!0),s.send(a)}handleDragOver(e){e.preventDefault(),this.$data.isDragging=!0}handleDragLeave(e){e.preventDefault(),this.$data.isDragging=!1}handleDrop(e){var t;e.preventDefault(),this.$data.isDragging=!1;const s=null==(t=e.dataTransfer)?void 0:t.files;s&&s.length>0&&this.handleFiles(s)}handleRemove(e){const t=this.$data.parsedFileList.findIndex(t=>t.uid===e.uid);t>-1&&(this.$data.parsedFileList.splice(t,1),this.emit("remove",{file:e,fileList:this.$data.parsedFileList}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}getStatusText(e){return{uploading:"上传中",done:"完成",error:"失败",removed:"已删除"}[e||""]||""}getFileList(){return this.$data.parsedFileList}clear(){this.$data.parsedFileList=[]}},exports.SolelyUpload=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([i.CustomElement({tagName:"solely-upload",template:t.default,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"action",type:"string"},{name:"accept",type:"string"},{name:"multiple",type:"boolean",default:!1},{name:"fileList",type:"string"},{name:"listType",type:"string"},{name:"disabled",type:"boolean",default:!1},{name:"showUploadList",type:"boolean",default:!0},{name:"buttonText",type:"string"},{name:"drag",type:"boolean",default:!1},{name:"maxCount",type:"number"},{name:"maxSize",type:"number"},{name:"block",type:"boolean",default:!1}]})],exports.SolelyUpload);
@@ -12,6 +12,7 @@ declare class SolelyUpload extends BaseElement<UploadProps & {
12
12
  * 暴露 fileList 属性,使外部可通过 event.target.fileList 访问
13
13
  */
14
14
  get fileList(): UploadFile[];
15
+ set fileList(value: UploadFile[]);
15
16
  /**
16
17
  * 获取 drag class 对象
17
18
  */
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div\n class="upload"\n :class="this.getUploadClasses()"\n>\n \x3c!-- 拖拽上传 --\x3e\n <If condition="$data.drag">\n <div\n class="upload__drag"\n :class="this.getDragClasses()"\n @click="this.triggerUpload(event)"\n @dragover="this.handleDragOver(event)"\n @dragleave="this.handleDragLeave(event)"\n @drop="this.handleDrop(event)"\n >\n <div class="upload__drag-icon">☁️</div>\n <div class="upload__drag-text">{{$data.buttonText || \'点击或拖拽文件到此区域上传\'}}</div>\n <div class="upload__drag-hint">支持单个或批量上传</div>\n </div>\n </If>\n\n \x3c!-- 普通上传按钮 --\x3e\n <If condition="!$data.drag">\n <div\n class="upload__button"\n @click="this.triggerUpload(event)"\n >\n <span>+</span>\n <span>{{$data.buttonText || \'上传文件\'}}</span>\n </div>\n </If>\n\n \x3c!-- 隐藏的文件输入 --\x3e\n <input\n ref="fileInput"\n type="file"\n class="upload__input"\n :accept="$data.accept"\n :multiple="$data.multiple"\n @change="this.handleFileChange(event)"\n />\n\n \x3c!-- 文件列表 --\x3e\n <If condition="$data.showUploadList && $data.parsedFileList?.length > 0">\n <ul class="upload__list">\n <For each="$data.parsedFileList" item="file">\n <li\n class="upload__list-item"\n :class="{ \'upload__list-item--error\': file.status === \'error\' }"\n >\n <If condition="file.url && ($data.listType === \'picture\' || $data.listType === \'picture-card\')">\n <img\n class="upload__list-thumb"\n :src="file.url"\n :alt="file.name"\n />\n </If>\n <div class="upload__list-info">\n <div class="upload__list-name">{{file.name}}</div>\n <If condition="file.size">\n <div class="upload__list-size">{{this.formatSize(file.size)}}</div>\n </If>\n <If condition="file.status === \'uploading\'">\n <div class="upload__progress">\n <div class="upload__progress-bar" :style="\'width: \' + (file.percent || 0) + \'%\'"></div>\n </div>\n </If>\n </div>\n <span\n class="upload__list-status"\n :class="\'upload__list-status--\' + file.status"\n >\n {{this.getStatusText(file.status)}}\n </span>\n <span class="upload__list-remove" @click="this.handleRemove(file)">×</span>\n </li>\n </For>\n </ul>\n </If>\n</div>\n';
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div\n part="base"\n class="upload"\n :class="this.getUploadClasses()"\n>\n \x3c!-- 拖拽上传 --\x3e\n <If condition="$data.drag">\n <div\n part="drag"\n class="upload__drag"\n :class="this.getDragClasses()"\n @click="this.triggerUpload(event)"\n @dragover="this.handleDragOver(event)"\n @dragleave="this.handleDragLeave(event)"\n @drop="this.handleDrop(event)"\n >\n <div part="drag-icon" class="upload__drag-icon">☁️</div>\n <div part="drag-text" class="upload__drag-text">{{$data.buttonText || \'点击或拖拽文件到此区域上传\'}}</div>\n <div part="drag-hint" class="upload__drag-hint">支持单个或批量上传</div>\n </div>\n </If>\n\n \x3c!-- 普通上传按钮 --\x3e\n <If condition="!$data.drag">\n <div\n part="button"\n class="upload__button"\n @click="this.triggerUpload(event)"\n >\n <span>+</span>\n <span>{{$data.buttonText || \'上传文件\'}}</span>\n </div>\n </If>\n\n \x3c!-- 隐藏的文件输入 --\x3e\n <input\n ref="fileInput"\n type="file"\n class="upload__input"\n :accept="$data.accept"\n :multiple="$data.multiple"\n @change="this.handleFileChange(event)"\n />\n\n \x3c!-- 文件列表 --\x3e\n <If condition="$data.showUploadList && $data.parsedFileList?.length > 0">\n <ul part="list" class="upload__list">\n <For each="$data.parsedFileList" item="file">\n <li\n part="list-item"\n class="upload__list-item"\n :class="{ \'upload__list-item--error\': file.status === \'error\' }"\n >\n <If condition="file.url && ($data.listType === \'picture\' || $data.listType === \'picture-card\')">\n <img\n part="thumb"\n class="upload__list-thumb"\n :src="file.url"\n :alt="file.name"\n />\n </If>\n <div part="info" class="upload__list-info">\n <div part="name" class="upload__list-name">{{file.name}}</div>\n <If condition="file.size">\n <div part="size" class="upload__list-size">{{this.formatSize(file.size)}}</div>\n </If>\n <If condition="file.status === \'uploading\'">\n <div part="progress" class="upload__progress">\n <div part="progress-bar" class="upload__progress-bar" :style="\'width: \' + (file.percent || 0) + \'%\'"></div>\n </div>\n </If>\n </div>\n <span\n part="status"\n class="upload__list-status"\n :class="\'upload__list-status--\' + file.status"\n >\n {{this.getStatusText(file.status)}}\n </span>\n <span part="remove" class="upload__list-remove" @click="this.handleRemove(file)">×</span>\n </li>\n </For>\n </ul>\n </If>\n</div>\n';
@@ -1 +1 @@
1
- const n='<div\n class="upload"\n :class="this.getUploadClasses()"\n>\n \x3c!-- 拖拽上传 --\x3e\n <If condition="$data.drag">\n <div\n class="upload__drag"\n :class="this.getDragClasses()"\n @click="this.triggerUpload(event)"\n @dragover="this.handleDragOver(event)"\n @dragleave="this.handleDragLeave(event)"\n @drop="this.handleDrop(event)"\n >\n <div class="upload__drag-icon">☁️</div>\n <div class="upload__drag-text">{{$data.buttonText || \'点击或拖拽文件到此区域上传\'}}</div>\n <div class="upload__drag-hint">支持单个或批量上传</div>\n </div>\n </If>\n\n \x3c!-- 普通上传按钮 --\x3e\n <If condition="!$data.drag">\n <div\n class="upload__button"\n @click="this.triggerUpload(event)"\n >\n <span>+</span>\n <span>{{$data.buttonText || \'上传文件\'}}</span>\n </div>\n </If>\n\n \x3c!-- 隐藏的文件输入 --\x3e\n <input\n ref="fileInput"\n type="file"\n class="upload__input"\n :accept="$data.accept"\n :multiple="$data.multiple"\n @change="this.handleFileChange(event)"\n />\n\n \x3c!-- 文件列表 --\x3e\n <If condition="$data.showUploadList && $data.parsedFileList?.length > 0">\n <ul class="upload__list">\n <For each="$data.parsedFileList" item="file">\n <li\n class="upload__list-item"\n :class="{ \'upload__list-item--error\': file.status === \'error\' }"\n >\n <If condition="file.url && ($data.listType === \'picture\' || $data.listType === \'picture-card\')">\n <img\n class="upload__list-thumb"\n :src="file.url"\n :alt="file.name"\n />\n </If>\n <div class="upload__list-info">\n <div class="upload__list-name">{{file.name}}</div>\n <If condition="file.size">\n <div class="upload__list-size">{{this.formatSize(file.size)}}</div>\n </If>\n <If condition="file.status === \'uploading\'">\n <div class="upload__progress">\n <div class="upload__progress-bar" :style="\'width: \' + (file.percent || 0) + \'%\'"></div>\n </div>\n </If>\n </div>\n <span\n class="upload__list-status"\n :class="\'upload__list-status--\' + file.status"\n >\n {{this.getStatusText(file.status)}}\n </span>\n <span class="upload__list-remove" @click="this.handleRemove(file)">×</span>\n </li>\n </For>\n </ul>\n </If>\n</div>\n';export{n as default};
1
+ const a='<div\n part="base"\n class="upload"\n :class="this.getUploadClasses()"\n>\n \x3c!-- 拖拽上传 --\x3e\n <If condition="$data.drag">\n <div\n part="drag"\n class="upload__drag"\n :class="this.getDragClasses()"\n @click="this.triggerUpload(event)"\n @dragover="this.handleDragOver(event)"\n @dragleave="this.handleDragLeave(event)"\n @drop="this.handleDrop(event)"\n >\n <div part="drag-icon" class="upload__drag-icon">☁️</div>\n <div part="drag-text" class="upload__drag-text">{{$data.buttonText || \'点击或拖拽文件到此区域上传\'}}</div>\n <div part="drag-hint" class="upload__drag-hint">支持单个或批量上传</div>\n </div>\n </If>\n\n \x3c!-- 普通上传按钮 --\x3e\n <If condition="!$data.drag">\n <div\n part="button"\n class="upload__button"\n @click="this.triggerUpload(event)"\n >\n <span>+</span>\n <span>{{$data.buttonText || \'上传文件\'}}</span>\n </div>\n </If>\n\n \x3c!-- 隐藏的文件输入 --\x3e\n <input\n ref="fileInput"\n type="file"\n class="upload__input"\n :accept="$data.accept"\n :multiple="$data.multiple"\n @change="this.handleFileChange(event)"\n />\n\n \x3c!-- 文件列表 --\x3e\n <If condition="$data.showUploadList && $data.parsedFileList?.length > 0">\n <ul part="list" class="upload__list">\n <For each="$data.parsedFileList" item="file">\n <li\n part="list-item"\n class="upload__list-item"\n :class="{ \'upload__list-item--error\': file.status === \'error\' }"\n >\n <If condition="file.url && ($data.listType === \'picture\' || $data.listType === \'picture-card\')">\n <img\n part="thumb"\n class="upload__list-thumb"\n :src="file.url"\n :alt="file.name"\n />\n </If>\n <div part="info" class="upload__list-info">\n <div part="name" class="upload__list-name">{{file.name}}</div>\n <If condition="file.size">\n <div part="size" class="upload__list-size">{{this.formatSize(file.size)}}</div>\n </If>\n <If condition="file.status === \'uploading\'">\n <div part="progress" class="upload__progress">\n <div part="progress-bar" class="upload__progress-bar" :style="\'width: \' + (file.percent || 0) + \'%\'"></div>\n </div>\n </If>\n </div>\n <span\n part="status"\n class="upload__list-status"\n :class="\'upload__list-status--\' + file.status"\n >\n {{this.getStatusText(file.status)}}\n </span>\n <span part="remove" class="upload__list-remove" @click="this.handleRemove(file)">×</span>\n </li>\n </For>\n </ul>\n </If>\n</div>\n';export{a as default};
@@ -1 +1 @@
1
- import e from"./style.css.js";import t from"./index.html.js";import{safeJsonParse as s}from"../utils/helpers.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends a{getUploadClasses(){const e={};return this.$data.listType&&(e[`upload--${this.$data.listType}`]=!0),e["is-disabled"]=!!this.$data.disabled,e}get fileList(){return this.$data.parsedFileList}getDragClasses(){return{"upload__drag--active":!!this.$data.isDragging}}mounted(){this.refresh(),this.parseFileList(),this.$data.isDragging=!1}parseFileList(){this.$data.parsedFileList=s(this.$data.fileList,[])}triggerUpload(){var e;if(this.$data.disabled)return;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('input[type="file"]');t&&t.click()}handleFileChange(e){const t=e.target,s=t.files;s&&s.length>0&&this.handleFiles(s),t.value=""}handleFiles(e){const t=this.$data.maxCount||1/0,s=this.$data.maxSize||1/0;Array.from(e).forEach(e=>{if(this.$data.parsedFileList.length>=t)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件数量超过限制 (最多 ${t} 个)`});if(e.size>s)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件大小超过限制 (${this.formatSize(s)})`});const a={uid:Date.now()+Math.random().toString(36).substr(2,9),name:e.name,size:e.size,type:e.type,status:"uploading",percent:0};this.$data.parsedFileList.push(a),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.uploadFile(a,e)})}uploadFile(e,t){if(!this.$data.action)return e.status="done",e.percent=100,e.url=URL.createObjectURL(t),this.refresh(),this.emit("success",{file:e,fileList:this.$data.parsedFileList}),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));const s=new XMLHttpRequest,a=new FormData;a.append("file",t),s.upload.addEventListener("progress",t=>{t.lengthComputable&&(e.percent=Math.round(t.loaded/t.total*100),this.$data.parsedFileList=[...this.$data.parsedFileList])}),s.addEventListener("load",()=>{if(s.status>=200&&s.status<300){e.status="done",e.percent=100;try{const t=JSON.parse(s.responseText);t.url&&(e.url=t.url)}catch{}this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("success",{file:e,fileList:this.$data.parsedFileList})}else e.status="error",e.error=s.statusText,this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:s.statusText});this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.addEventListener("error",()=>{e.status="error",e.error="网络错误",this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:"网络错误"}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.open("POST",this.$data.action,!0),s.send(a)}handleDragOver(e){e.preventDefault(),this.$data.isDragging=!0}handleDragLeave(e){e.preventDefault(),this.$data.isDragging=!1}handleDrop(e){var t;e.preventDefault(),this.$data.isDragging=!1;const s=null==(t=e.dataTransfer)?void 0:t.files;s&&s.length>0&&this.handleFiles(s)}handleRemove(e){const t=this.$data.parsedFileList.findIndex(t=>t.uid===e.uid);t>-1&&(this.$data.parsedFileList.splice(t,1),this.emit("remove",{file:e,fileList:this.$data.parsedFileList}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}getStatusText(e){return{uploading:"上传中",done:"完成",error:"失败",removed:"已删除"}[e||""]||""}getFileList(){return this.$data.parsedFileList}clear(){this.$data.parsedFileList=[]}};r=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([i({tagName:"solely-upload",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"action",type:"string"},{name:"accept",type:"string"},{name:"multiple",type:"boolean",default:!1},{name:"fileList",type:"string"},{name:"listType",type:"string"},{name:"disabled",type:"boolean",default:!1},{name:"showUploadList",type:"boolean",default:!0},{name:"buttonText",type:"string"},{name:"drag",type:"boolean",default:!1},{name:"maxCount",type:"number"},{name:"maxSize",type:"number"},{name:"block",type:"boolean",default:!1}]})],r);export{r as SolelyUpload};
1
+ import e from"./style.css.js";import t from"./index.html.js";import{safeJsonParse as s}from"../utils/helpers.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends a{getUploadClasses(){const e={};return this.$data.listType&&(e[`upload--${this.$data.listType}`]=!0),e["is-disabled"]=!!this.$data.disabled,e}get fileList(){return this.$data.parsedFileList}set fileList(e){this.$data.parsedFileList=e,this.$data.fileList=JSON.stringify(e)}getDragClasses(){return{"upload__drag--active":!!this.$data.isDragging}}mounted(){this.refresh(),this.parseFileList(),this.$data.isDragging=!1}parseFileList(){this.$data.parsedFileList=s(this.$data.fileList,[])}triggerUpload(){var e;if(this.$data.disabled)return;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('input[type="file"]');t&&t.click()}handleFileChange(e){const t=e.target,s=t.files;s&&s.length>0&&this.handleFiles(s),t.value=""}handleFiles(e){const t=this.$data.maxCount||1/0,s=this.$data.maxSize||1/0;Array.from(e).forEach(e=>{if(this.$data.parsedFileList.length>=t)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件数量超过限制 (最多 ${t} 个)`});if(e.size>s)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件大小超过限制 (${this.formatSize(s)})`});const a={uid:Date.now()+Math.random().toString(36).substr(2,9),name:e.name,size:e.size,type:e.type,status:"uploading",percent:0};this.$data.parsedFileList.push(a),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.uploadFile(a,e)})}uploadFile(e,t){if(!this.$data.action)return e.status="done",e.percent=100,e.url=URL.createObjectURL(t),this.refresh(),this.emit("success",{file:e,fileList:this.$data.parsedFileList}),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));const s=new XMLHttpRequest,a=new FormData;a.append("file",t),s.upload.addEventListener("progress",t=>{t.lengthComputable&&(e.percent=Math.round(t.loaded/t.total*100),this.$data.parsedFileList=[...this.$data.parsedFileList])}),s.addEventListener("load",()=>{if(s.status>=200&&s.status<300){e.status="done",e.percent=100;try{const t=JSON.parse(s.responseText);t.url&&(e.url=t.url)}catch{}this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("success",{file:e,fileList:this.$data.parsedFileList})}else e.status="error",e.error=s.statusText,this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:s.statusText});this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.addEventListener("error",()=>{e.status="error",e.error="网络错误",this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:"网络错误"}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.open("POST",this.$data.action,!0),s.send(a)}handleDragOver(e){e.preventDefault(),this.$data.isDragging=!0}handleDragLeave(e){e.preventDefault(),this.$data.isDragging=!1}handleDrop(e){var t;e.preventDefault(),this.$data.isDragging=!1;const s=null==(t=e.dataTransfer)?void 0:t.files;s&&s.length>0&&this.handleFiles(s)}handleRemove(e){const t=this.$data.parsedFileList.findIndex(t=>t.uid===e.uid);t>-1&&(this.$data.parsedFileList.splice(t,1),this.emit("remove",{file:e,fileList:this.$data.parsedFileList}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}getStatusText(e){return{uploading:"上传中",done:"完成",error:"失败",removed:"已删除"}[e||""]||""}getFileList(){return this.$data.parsedFileList}clear(){this.$data.parsedFileList=[]}};r=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([i({tagName:"solely-upload",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"action",type:"string"},{name:"accept",type:"string"},{name:"multiple",type:"boolean",default:!1},{name:"fileList",type:"string"},{name:"listType",type:"string"},{name:"disabled",type:"boolean",default:!1},{name:"showUploadList",type:"boolean",default:!0},{name:"buttonText",type:"string"},{name:"drag",type:"boolean",default:!1},{name:"maxCount",type:"number"},{name:"maxSize",type:"number"},{name:"block",type:"boolean",default:!1}]})],r);export{r as SolelyUpload};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.4.11",
4
+ "version": "0.4.12",
5
5
  "description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
6
6
  "type": "module",
7
7
  "sideEffects": false,