solely 0.4.8 → 0.4.10

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 (104) hide show
  1. package/dist/components/commands/utils.cjs +1 -1
  2. package/dist/components/commands/utils.js +1 -1
  3. package/dist/components/elements/alert/index.cjs +1 -1
  4. package/dist/components/elements/alert/index.d.ts +4 -0
  5. package/dist/components/elements/alert/index.html.cjs +1 -1
  6. package/dist/components/elements/alert/index.html.js +1 -1
  7. package/dist/components/elements/alert/index.js +1 -1
  8. package/dist/components/elements/alert/style.css.cjs +1 -1
  9. package/dist/components/elements/alert/style.css.js +1 -1
  10. package/dist/components/elements/backtop/index.cjs +1 -1
  11. package/dist/components/elements/backtop/index.js +1 -1
  12. package/dist/components/elements/badge/index.cjs +1 -1
  13. package/dist/components/elements/badge/index.d.ts +4 -0
  14. package/dist/components/elements/badge/index.js +1 -1
  15. package/dist/components/elements/button/index.cjs +1 -1
  16. package/dist/components/elements/button/index.d.ts +9 -1
  17. package/dist/components/elements/button/index.html.cjs +1 -1
  18. package/dist/components/elements/button/index.html.js +1 -1
  19. package/dist/components/elements/button/index.js +1 -1
  20. package/dist/components/elements/button/style.css.cjs +1 -1
  21. package/dist/components/elements/button/style.css.js +1 -1
  22. package/dist/components/elements/card/index.cjs +1 -1
  23. package/dist/components/elements/card/index.d.ts +4 -0
  24. package/dist/components/elements/card/index.js +1 -1
  25. package/dist/components/elements/checkbox/index.cjs +1 -1
  26. package/dist/components/elements/checkbox/index.js +1 -1
  27. package/dist/components/elements/coordinate-input/index.cjs +1 -1
  28. package/dist/components/elements/coordinate-input/index.js +1 -1
  29. package/dist/components/elements/divider/index.cjs +1 -1
  30. package/dist/components/elements/divider/index.js +1 -1
  31. package/dist/components/elements/empty/index.cjs +1 -1
  32. package/dist/components/elements/empty/index.d.ts +4 -0
  33. package/dist/components/elements/empty/index.html.cjs +1 -1
  34. package/dist/components/elements/empty/index.html.js +1 -1
  35. package/dist/components/elements/empty/index.js +1 -1
  36. package/dist/components/elements/fab/index.cjs +1 -1
  37. package/dist/components/elements/fab/index.d.ts +4 -0
  38. package/dist/components/elements/fab/index.js +1 -1
  39. package/dist/components/elements/icon/index.cjs +1 -1
  40. package/dist/components/elements/icon/index.js +1 -1
  41. package/dist/components/elements/input/index.cjs +1 -1
  42. package/dist/components/elements/input/index.html.cjs +1 -1
  43. package/dist/components/elements/input/index.html.js +1 -1
  44. package/dist/components/elements/input/index.js +1 -1
  45. package/dist/components/elements/pagination/index.cjs +1 -1
  46. package/dist/components/elements/pagination/index.js +1 -1
  47. package/dist/components/elements/progress/index.cjs +1 -1
  48. package/dist/components/elements/progress/index.d.ts +4 -0
  49. package/dist/components/elements/progress/index.js +1 -1
  50. package/dist/components/elements/radio/index.cjs +1 -1
  51. package/dist/components/elements/radio/index.d.ts +4 -0
  52. package/dist/components/elements/radio/index.html.cjs +1 -1
  53. package/dist/components/elements/radio/index.html.js +1 -1
  54. package/dist/components/elements/radio/index.js +1 -1
  55. package/dist/components/elements/rate/index.cjs +1 -1
  56. package/dist/components/elements/rate/index.js +1 -1
  57. package/dist/components/elements/select/index.cjs +1 -1
  58. package/dist/components/elements/select/index.html.cjs +1 -1
  59. package/dist/components/elements/select/index.html.js +1 -1
  60. package/dist/components/elements/select/index.js +1 -1
  61. package/dist/components/elements/skeleton/index.cjs +1 -1
  62. package/dist/components/elements/skeleton/index.d.ts +4 -0
  63. package/dist/components/elements/skeleton/index.js +1 -1
  64. package/dist/components/elements/slider/index.cjs +1 -1
  65. package/dist/components/elements/slider/index.js +1 -1
  66. package/dist/components/elements/steps/index.cjs +1 -1
  67. package/dist/components/elements/steps/index.d.ts +4 -2
  68. package/dist/components/elements/steps/index.html.cjs +1 -1
  69. package/dist/components/elements/steps/index.html.js +1 -1
  70. package/dist/components/elements/steps/index.js +1 -1
  71. package/dist/components/elements/switch/index.cjs +1 -1
  72. package/dist/components/elements/switch/index.d.ts +8 -0
  73. package/dist/components/elements/switch/index.html.cjs +1 -1
  74. package/dist/components/elements/switch/index.html.js +1 -1
  75. package/dist/components/elements/switch/index.js +1 -1
  76. package/dist/components/elements/table/index.cjs +1 -1
  77. package/dist/components/elements/table/index.d.ts +9 -8
  78. package/dist/components/elements/table/index.html.cjs +1 -1
  79. package/dist/components/elements/table/index.html.js +1 -1
  80. package/dist/components/elements/table/index.js +1 -1
  81. package/dist/components/elements/tabs/index.cjs +1 -1
  82. package/dist/components/elements/tabs/index.d.ts +3 -5
  83. package/dist/components/elements/tabs/index.html.cjs +1 -1
  84. package/dist/components/elements/tabs/index.html.js +1 -1
  85. package/dist/components/elements/tabs/index.js +1 -1
  86. package/dist/components/elements/tag/index.cjs +1 -1
  87. package/dist/components/elements/tag/index.d.ts +4 -0
  88. package/dist/components/elements/tag/index.html.cjs +1 -1
  89. package/dist/components/elements/tag/index.html.js +1 -1
  90. package/dist/components/elements/tag/index.js +1 -1
  91. package/dist/components/elements/timeline/index.cjs +1 -1
  92. package/dist/components/elements/timeline/index.d.ts +2 -4
  93. package/dist/components/elements/timeline/index.html.cjs +1 -1
  94. package/dist/components/elements/timeline/index.html.js +1 -1
  95. package/dist/components/elements/timeline/index.js +1 -1
  96. package/dist/components/elements/tree/index.cjs +1 -1
  97. package/dist/components/elements/tree/index.js +1 -1
  98. package/dist/components/elements/upload/index.cjs +1 -1
  99. package/dist/components/elements/upload/index.js +1 -1
  100. package/dist/runtime/component/base-element.cjs +1 -1
  101. package/dist/runtime/component/base-element.js +1 -1
  102. package/dist/runtime/component/decorators.cjs +1 -1
  103. package/dist/runtime/component/decorators.js +1 -1
  104. package/package.json +1 -1
@@ -1 +1 @@
1
- import e from"./style.css.js";import t from"./index.html.js";import{safeJsonParse as r}from"../utils/helpers.js";import o from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";var a=Object.defineProperty;Object.getOwnPropertyDescriptor;let n=class extends o{isHorizontal(){var e;return(null==(e=this.$data.mode)?void 0:e.startsWith("horizontal-"))??!1}isAlternate(){return"alternate"===this.$data.mode||"horizontal-alternate"===this.$data.mode}getTimelineClasses(){const e={};return this.$data.mode&&(e[`timeline--${this.$data.mode}`]=!0),"filled"===this.$data.variant&&(e["timeline--filled"]=!0),e}getItemClasses(e,t){const r="alternate"===this.$data.mode,o="horizontal-alternate"===this.$data.mode;let i=!1,a=!1,n=!1,s=!1;return r?"left"===e.position?i=!0:"right"===e.position?a=!0:(i=t%2==0,a=t%2==1):o&&("top"===e.verticalPosition?n=!0:"bottom"===e.verticalPosition?s=!0:(n=t%2==0,s=t%2==1)),{"timeline__item--left":i,"timeline__item--right":a,"timeline__item--top":n,"timeline__item--bottom":s,"timeline__item--loading":!!e.loading}}getDotClasses(e){const t={};return e.color&&["blue","green","red","orange","gray"].includes(e.color)&&(t[`timeline__dot--${e.color}`]=!0),t}getDotStyle(e){const t=e.color;return!t||n.PRESET_COLORS.includes(t)?"":"filled"===this.$data.variant?`background-color: ${t};`:`border-color: ${t};`}getIconStyle(e){const t=e.color;return!t||n.PRESET_COLORS.includes(t)?"":`color: ${t}; background-color: ${t}15;`}mounted(){this.parseItems()}parseItems(){let e=r(this.$data.items,[]);this.$data.reverse&&(e=e.reverse()),this.$data.parsedItems=e}setItems(e){this.$data.items=JSON.stringify(e),this.parseItems()}};var s,l,m;m=["blue","green","red","orange","gray"],(l="PRESET_COLORS")in(s=n)?a(s,l,{enumerable:!0,configurable:!0,writable:!0,value:m}):s[l]=m,n=((e,t)=>{for(var r,o=t,i=e.length-1;i>=0;i--)(r=e[i])&&(o=r(o)||o);return o})([i({tagName:"solely-timeline",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"mode",type:"string",default:"left"},{name:"items",type:"string",default:"[]"},{name:"pending",type:"boolean",default:!1},{name:"pendingContent",type:"string",default:"待定"},{name:"reverse",type:"boolean",default:!1},{name:"variant",type:"string",default:"outlined"}]})],n);export{n as SolelyTimeline};
1
+ import e from"./style.css.js";import t from"./index.html.js";import{safeJsonParse as r}from"../utils/helpers.js";import o from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";var n=Object.defineProperty;Object.getOwnPropertyDescriptor;let a=class extends o{isHorizontal(){var e;return(null==(e=this.$data.mode)?void 0:e.startsWith("horizontal-"))??!1}isAlternate(){return"alternate"===this.$data.mode||"horizontal-alternate"===this.$data.mode}getTimelineClasses(){const e={};return this.$data.mode&&(e[`timeline--${this.$data.mode}`]=!0),"filled"===this.$data.variant&&(e["timeline--filled"]=!0),e}getItemClasses(e,t){const r="alternate"===this.$data.mode,o="horizontal-alternate"===this.$data.mode;let i=!1,n=!1,a=!1,l=!1;return r?"left"===e.position?i=!0:"right"===e.position?n=!0:(i=t%2==0,n=t%2==1):o&&("top"===e.verticalPosition?a=!0:"bottom"===e.verticalPosition?l=!0:(a=t%2==0,l=t%2==1)),{"timeline__item--left":i,"timeline__item--right":n,"timeline__item--top":a,"timeline__item--bottom":l,"timeline__item--loading":!!e.loading}}getDotClasses(e){const t={};return e.color&&["blue","green","red","orange","gray"].includes(e.color)&&(t[`timeline__dot--${e.color}`]=!0),t}getDotStyle(e){const t=e.color;return!t||a.PRESET_COLORS.includes(t)?"":"filled"===this.$data.variant?`background-color: ${t};`:`border-color: ${t};`}getIconStyle(e){const t=e.color;return!t||a.PRESET_COLORS.includes(t)?"":`color: ${t}; background-color: ${t}15;`}mounted(){this.refresh()}getParsedItems(){const e=this.$data.items;if(Array.isArray(e))return e;if("string"==typeof e&&e){let t=r(e,[]);return this.$data.reverse&&(t=t.reverse()),t}return[]}setItems(e){this.$data.items=JSON.stringify(e)}};var l,s,m;m=["blue","green","red","orange","gray"],(s="PRESET_COLORS")in(l=a)?n(l,s,{enumerable:!0,configurable:!0,writable:!0,value:m}):l[s]=m,a=((e,t)=>{for(var r,o=t,i=e.length-1;i>=0;i--)(r=e[i])&&(o=r(o)||o);return o})([i({tagName:"solely-timeline",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"mode",type:"string",default:"left"},{name:"items",type:"string",default:"[]"},{name:"pending",type:"boolean",default:!1},{name:"pendingContent",type:"string",default:"待定"},{name:"reverse",type:"boolean",default:!1},{name:"variant",type:"string",default:"outlined"}]})],a);export{a as SolelyTimeline};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),s=require("./index.html.cjs"),n=require("../utils/helpers.cjs"),a=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyTree=class extends a.default{constructor(){var t;super(...arguments),((t,s,n)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n})(this,"symbol"!=typeof(t="treeData")?t+"":t,[])}getTreeClasses(){return{"tree--show-line":!!this.$data.showLine}}getNodeClasses(e){const t={"tree__node--filtered":!!e.isFiltered,"tree__node--last-child":!!e.isLastChild};return void 0!==e.level&&(t[`tree__node--level-${e.level}`]=!0),t}getContentClasses(e){return{"tree__content--selected":!!e.selected,"tree__content--disabled":!!e.disabled}}getSwitcherClasses(e){return{"tree__switcher--expanded":!!e.expanded,"tree__switcher--leaf":!e.children||0===e.children.length}}getCheckboxClasses(e){return{"tree__checkbox--checked":!!e.checked,"tree__checkbox--half-checked":!!e.halfChecked,"tree__checkbox--disabled":!!e.disabled}}getTitleClasses(e){return{"tree__title--highlight":!!e.highlight}}mounted(){this.parseTreeData()}parseTreeData(){this.treeData=n.safeJsonParse(this.$data.treeData,[]),this.flattenTree()}flattenTree(){const e=[],t=this.$data.searchable?(this.$data.searchValue||"").toLowerCase():"",s=(n,a)=>{for(let r=0;r<n.length;r++){const d=n[r],c=d.children&&d.children.length>0,h=this.$data.defaultExpandAll||d.expanded,i=t&&d.title.toLowerCase().includes(t),l={...d,level:a,expanded:h,isFiltered:!(!t||i||this.hasMatchingDescendant(d,t)),highlight:!!i,isLastChild:r===n.length-1};e.push(l),c&&h&&d.children&&s(d.children,a+1)}};s(this.treeData,0),this.$data.flattenedTree=e}hasMatchingDescendant(e,t){if(!e.children||0===e.children.length)return!1;for(const s of e.children){if(s.title.toLowerCase().includes(t))return!0;if(this.hasMatchingDescendant(s,t))return!0}return!1}handleToggle(e,t){if(t.stopPropagation(),this.$data.disabled)return;const s=this.findNode(this.treeData,e.key);s&&(s.expanded=!s.expanded,this.flattenTree(),this.emit("expand",{expandedKeys:this.getExpandedKeys(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleNodeClick(e){if(this.$data.disabled||e.disabled)return;this.$data.multiple||this.clearSelection();const t=this.findNode(this.treeData,e.key);t&&(t.selected=!t.selected,this.flattenTree(),this.emit("select",{selectedKeys:this.getSelectedKeys(),selectedNodes:this.getSelectedNodes(),node:t}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleCheck(e,t){if(t.stopPropagation(),this.$data.disabled||e.disabled)return;const s=this.findNode(this.treeData,e.key);if(s){const e=!s.checked;this.updateNodeCheckState(s,e),this.flattenTree(),this.emit("check",{checkedKeys:this.getCheckedKeys(),checkedNodes:this.getCheckedNodes(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}updateNodeCheckState(e,t){if(e.checked=t,e.halfChecked=!1,e.children)for(const s of e.children)this.updateNodeCheckState(s,t);this.updateParentCheckState(this.treeData,e)}updateParentCheckState(e,t){for(const s of e)if(s.children){if(s.children.includes(t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}if(this.updateParentCheckState(s.children,t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}}return!1}findNode(e,t){for(const s of e){if(s.key===t)return s;if(s.children){const e=this.findNode(s.children,t);if(e)return e}}return null}clearSelection(){const e=t=>{for(const s of t)s.selected=!1,s.children&&e(s.children)};e(this.treeData)}getCheckedKeys(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set checkedKeys(e){const t=e=>{for(const s of e)s.checked=!1,s.halfChecked=!1,s.children&&t(s.children)};t(this.treeData);const s=(e,t)=>{for(const n of e)t.includes(n.key)&&(n.checked=!0),n.children&&s(n.children,t)};s(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getExpandedKeys(){const e=[],t=s=>{for(const n of s)n.expanded&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set expandedKeys(e){const t=s=>{for(const n of s)n.expanded=e.includes(n.key),n.children&&t(n.children)};t(this.treeData),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getSelectedKeys(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}getSelectedNodes(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}getCheckedNodes(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}setTreeData(e){this.treeData=e,this.$data.treeData=JSON.stringify(e),this.flattenTree()}getTreeData(){return this.treeData}get value(){return this.getSelectedKeys()}set value(e){this.clearSelection();const t=(e,s)=>{for(const n of e)s.includes(n.key)&&(n.selected=!0),n.children&&t(n.children,s)};t(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get selectedKeys(){return this.getSelectedKeys()}set selectedKeys(e){this.value=e}},exports.SolelyTree=((e,t)=>{for(var s,n=t,a=e.length-1;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n})([r.CustomElement({tagName:"solely-tree",template:s.default,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"treeData",type:"string"},{name:"showLine",type:"boolean",default:!1},{name:"multiple",type:"boolean",default:!1},{name:"checkable",type:"boolean",default:!1},{name:"defaultExpandAll",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"searchable",type:"boolean",default:!1},{name:"searchValue",type:"string"},{name:"block",type:"boolean",default:!1}]})],exports.SolelyTree);
1
+ "use strict";var e=Object.defineProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),s=require("./index.html.cjs"),n=require("../utils/helpers.cjs"),a=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyTree=class extends a.default{constructor(){var t;super(...arguments),((t,s,n)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n})(this,"symbol"!=typeof(t="treeData")?t+"":t,[])}getTreeClasses(){return{"tree--show-line":!!this.$data.showLine}}getNodeClasses(e){const t={"tree__node--filtered":!!e.isFiltered,"tree__node--last-child":!!e.isLastChild};return void 0!==e.level&&(t[`tree__node--level-${e.level}`]=!0),t}getContentClasses(e){return{"tree__content--selected":!!e.selected,"tree__content--disabled":!!e.disabled}}getSwitcherClasses(e){return{"tree__switcher--expanded":!!e.expanded,"tree__switcher--leaf":!e.children||0===e.children.length}}getCheckboxClasses(e){return{"tree__checkbox--checked":!!e.checked,"tree__checkbox--half-checked":!!e.halfChecked,"tree__checkbox--disabled":!!e.disabled}}getTitleClasses(e){return{"tree__title--highlight":!!e.highlight}}mounted(){this.refresh(),this.parseTreeData()}parseTreeData(){this.treeData=n.safeJsonParse(this.$data.treeData,[]),this.flattenTree()}flattenTree(){const e=[],t=this.$data.searchable?(this.$data.searchValue||"").toLowerCase():"",s=(n,a)=>{for(let r=0;r<n.length;r++){const d=n[r],c=d.children&&d.children.length>0,h=this.$data.defaultExpandAll||d.expanded,i=t&&d.title.toLowerCase().includes(t),l={...d,level:a,expanded:h,isFiltered:!(!t||i||this.hasMatchingDescendant(d,t)),highlight:!!i,isLastChild:r===n.length-1};e.push(l),c&&h&&d.children&&s(d.children,a+1)}};s(this.treeData,0),this.$data.flattenedTree=e}hasMatchingDescendant(e,t){if(!e.children||0===e.children.length)return!1;for(const s of e.children){if(s.title.toLowerCase().includes(t))return!0;if(this.hasMatchingDescendant(s,t))return!0}return!1}handleToggle(e,t){if(t.stopPropagation(),this.$data.disabled)return;const s=this.findNode(this.treeData,e.key);s&&(s.expanded=!s.expanded,this.flattenTree(),this.emit("expand",{expandedKeys:this.getExpandedKeys(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleNodeClick(e){if(this.$data.disabled||e.disabled)return;this.$data.multiple||this.clearSelection();const t=this.findNode(this.treeData,e.key);t&&(t.selected=!t.selected,this.flattenTree(),this.emit("select",{selectedKeys:this.getSelectedKeys(),selectedNodes:this.getSelectedNodes(),node:t}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleCheck(e,t){if(t.stopPropagation(),this.$data.disabled||e.disabled)return;const s=this.findNode(this.treeData,e.key);if(s){const e=!s.checked;this.updateNodeCheckState(s,e),this.flattenTree(),this.emit("check",{checkedKeys:this.getCheckedKeys(),checkedNodes:this.getCheckedNodes(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}updateNodeCheckState(e,t){if(e.checked=t,e.halfChecked=!1,e.children)for(const s of e.children)this.updateNodeCheckState(s,t);this.updateParentCheckState(this.treeData,e)}updateParentCheckState(e,t){for(const s of e)if(s.children){if(s.children.includes(t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}if(this.updateParentCheckState(s.children,t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}}return!1}findNode(e,t){for(const s of e){if(s.key===t)return s;if(s.children){const e=this.findNode(s.children,t);if(e)return e}}return null}clearSelection(){const e=t=>{for(const s of t)s.selected=!1,s.children&&e(s.children)};e(this.treeData)}getCheckedKeys(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set checkedKeys(e){const t=e=>{for(const s of e)s.checked=!1,s.halfChecked=!1,s.children&&t(s.children)};t(this.treeData);const s=(e,t)=>{for(const n of e)t.includes(n.key)&&(n.checked=!0),n.children&&s(n.children,t)};s(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getExpandedKeys(){const e=[],t=s=>{for(const n of s)n.expanded&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set expandedKeys(e){const t=s=>{for(const n of s)n.expanded=e.includes(n.key),n.children&&t(n.children)};t(this.treeData),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getSelectedKeys(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}getSelectedNodes(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}getCheckedNodes(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}setTreeData(e){this.treeData=e,this.$data.treeData=JSON.stringify(e),this.flattenTree()}getTreeData(){return this.treeData}get value(){return this.getSelectedKeys()}set value(e){this.clearSelection();const t=(e,s)=>{for(const n of e)s.includes(n.key)&&(n.selected=!0),n.children&&t(n.children,s)};t(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get selectedKeys(){return this.getSelectedKeys()}set selectedKeys(e){this.value=e}},exports.SolelyTree=((e,t)=>{for(var s,n=t,a=e.length-1;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n})([r.CustomElement({tagName:"solely-tree",template:s.default,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"treeData",type:"string"},{name:"showLine",type:"boolean",default:!1},{name:"multiple",type:"boolean",default:!1},{name:"checkable",type:"boolean",default:!1},{name:"defaultExpandAll",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"searchable",type:"boolean",default:!1},{name:"searchValue",type:"string"},{name:"block",type:"boolean",default:!1}]})],exports.SolelyTree);
@@ -1 +1 @@
1
- var e=Object.defineProperty;import t from"./style.css.js";import s from"./index.html.js";import{safeJsonParse as n}from"../utils/helpers.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as d}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends a{constructor(){var t;super(...arguments),((t,s,n)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n})(this,"symbol"!=typeof(t="treeData")?t+"":t,[])}getTreeClasses(){return{"tree--show-line":!!this.$data.showLine}}getNodeClasses(e){const t={"tree__node--filtered":!!e.isFiltered,"tree__node--last-child":!!e.isLastChild};return void 0!==e.level&&(t[`tree__node--level-${e.level}`]=!0),t}getContentClasses(e){return{"tree__content--selected":!!e.selected,"tree__content--disabled":!!e.disabled}}getSwitcherClasses(e){return{"tree__switcher--expanded":!!e.expanded,"tree__switcher--leaf":!e.children||0===e.children.length}}getCheckboxClasses(e){return{"tree__checkbox--checked":!!e.checked,"tree__checkbox--half-checked":!!e.halfChecked,"tree__checkbox--disabled":!!e.disabled}}getTitleClasses(e){return{"tree__title--highlight":!!e.highlight}}mounted(){this.parseTreeData()}parseTreeData(){this.treeData=n(this.$data.treeData,[]),this.flattenTree()}flattenTree(){const e=[],t=this.$data.searchable?(this.$data.searchValue||"").toLowerCase():"",s=(n,a)=>{for(let d=0;d<n.length;d++){const r=n[d],c=r.children&&r.children.length>0,h=this.$data.defaultExpandAll||r.expanded,i=t&&r.title.toLowerCase().includes(t),l={...r,level:a,expanded:h,isFiltered:!(!t||i||this.hasMatchingDescendant(r,t)),highlight:!!i,isLastChild:d===n.length-1};e.push(l),c&&h&&r.children&&s(r.children,a+1)}};s(this.treeData,0),this.$data.flattenedTree=e}hasMatchingDescendant(e,t){if(!e.children||0===e.children.length)return!1;for(const s of e.children){if(s.title.toLowerCase().includes(t))return!0;if(this.hasMatchingDescendant(s,t))return!0}return!1}handleToggle(e,t){if(t.stopPropagation(),this.$data.disabled)return;const s=this.findNode(this.treeData,e.key);s&&(s.expanded=!s.expanded,this.flattenTree(),this.emit("expand",{expandedKeys:this.getExpandedKeys(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleNodeClick(e){if(this.$data.disabled||e.disabled)return;this.$data.multiple||this.clearSelection();const t=this.findNode(this.treeData,e.key);t&&(t.selected=!t.selected,this.flattenTree(),this.emit("select",{selectedKeys:this.getSelectedKeys(),selectedNodes:this.getSelectedNodes(),node:t}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleCheck(e,t){if(t.stopPropagation(),this.$data.disabled||e.disabled)return;const s=this.findNode(this.treeData,e.key);if(s){const e=!s.checked;this.updateNodeCheckState(s,e),this.flattenTree(),this.emit("check",{checkedKeys:this.getCheckedKeys(),checkedNodes:this.getCheckedNodes(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}updateNodeCheckState(e,t){if(e.checked=t,e.halfChecked=!1,e.children)for(const s of e.children)this.updateNodeCheckState(s,t);this.updateParentCheckState(this.treeData,e)}updateParentCheckState(e,t){for(const s of e)if(s.children){if(s.children.includes(t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}if(this.updateParentCheckState(s.children,t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}}return!1}findNode(e,t){for(const s of e){if(s.key===t)return s;if(s.children){const e=this.findNode(s.children,t);if(e)return e}}return null}clearSelection(){const e=t=>{for(const s of t)s.selected=!1,s.children&&e(s.children)};e(this.treeData)}getCheckedKeys(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set checkedKeys(e){const t=e=>{for(const s of e)s.checked=!1,s.halfChecked=!1,s.children&&t(s.children)};t(this.treeData);const s=(e,t)=>{for(const n of e)t.includes(n.key)&&(n.checked=!0),n.children&&s(n.children,t)};s(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getExpandedKeys(){const e=[],t=s=>{for(const n of s)n.expanded&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set expandedKeys(e){const t=s=>{for(const n of s)n.expanded=e.includes(n.key),n.children&&t(n.children)};t(this.treeData),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getSelectedKeys(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}getSelectedNodes(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}getCheckedNodes(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}setTreeData(e){this.treeData=e,this.$data.treeData=JSON.stringify(e),this.flattenTree()}getTreeData(){return this.treeData}get value(){return this.getSelectedKeys()}set value(e){this.clearSelection();const t=(e,s)=>{for(const n of e)s.includes(n.key)&&(n.selected=!0),n.children&&t(n.children,s)};t(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get selectedKeys(){return this.getSelectedKeys()}set selectedKeys(e){this.value=e}};r=((e,t)=>{for(var s,n=t,a=e.length-1;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n})([d({tagName:"solely-tree",template:s,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"treeData",type:"string"},{name:"showLine",type:"boolean",default:!1},{name:"multiple",type:"boolean",default:!1},{name:"checkable",type:"boolean",default:!1},{name:"defaultExpandAll",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"searchable",type:"boolean",default:!1},{name:"searchValue",type:"string"},{name:"block",type:"boolean",default:!1}]})],r);export{r as SolelyTree};
1
+ var e=Object.defineProperty;import t from"./style.css.js";import s from"./index.html.js";import{safeJsonParse as n}from"../utils/helpers.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as d}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends a{constructor(){var t;super(...arguments),((t,s,n)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n})(this,"symbol"!=typeof(t="treeData")?t+"":t,[])}getTreeClasses(){return{"tree--show-line":!!this.$data.showLine}}getNodeClasses(e){const t={"tree__node--filtered":!!e.isFiltered,"tree__node--last-child":!!e.isLastChild};return void 0!==e.level&&(t[`tree__node--level-${e.level}`]=!0),t}getContentClasses(e){return{"tree__content--selected":!!e.selected,"tree__content--disabled":!!e.disabled}}getSwitcherClasses(e){return{"tree__switcher--expanded":!!e.expanded,"tree__switcher--leaf":!e.children||0===e.children.length}}getCheckboxClasses(e){return{"tree__checkbox--checked":!!e.checked,"tree__checkbox--half-checked":!!e.halfChecked,"tree__checkbox--disabled":!!e.disabled}}getTitleClasses(e){return{"tree__title--highlight":!!e.highlight}}mounted(){this.refresh(),this.parseTreeData()}parseTreeData(){this.treeData=n(this.$data.treeData,[]),this.flattenTree()}flattenTree(){const e=[],t=this.$data.searchable?(this.$data.searchValue||"").toLowerCase():"",s=(n,a)=>{for(let d=0;d<n.length;d++){const r=n[d],h=r.children&&r.children.length>0,c=this.$data.defaultExpandAll||r.expanded,i=t&&r.title.toLowerCase().includes(t),l={...r,level:a,expanded:c,isFiltered:!(!t||i||this.hasMatchingDescendant(r,t)),highlight:!!i,isLastChild:d===n.length-1};e.push(l),h&&c&&r.children&&s(r.children,a+1)}};s(this.treeData,0),this.$data.flattenedTree=e}hasMatchingDescendant(e,t){if(!e.children||0===e.children.length)return!1;for(const s of e.children){if(s.title.toLowerCase().includes(t))return!0;if(this.hasMatchingDescendant(s,t))return!0}return!1}handleToggle(e,t){if(t.stopPropagation(),this.$data.disabled)return;const s=this.findNode(this.treeData,e.key);s&&(s.expanded=!s.expanded,this.flattenTree(),this.emit("expand",{expandedKeys:this.getExpandedKeys(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleNodeClick(e){if(this.$data.disabled||e.disabled)return;this.$data.multiple||this.clearSelection();const t=this.findNode(this.treeData,e.key);t&&(t.selected=!t.selected,this.flattenTree(),this.emit("select",{selectedKeys:this.getSelectedKeys(),selectedNodes:this.getSelectedNodes(),node:t}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleCheck(e,t){if(t.stopPropagation(),this.$data.disabled||e.disabled)return;const s=this.findNode(this.treeData,e.key);if(s){const e=!s.checked;this.updateNodeCheckState(s,e),this.flattenTree(),this.emit("check",{checkedKeys:this.getCheckedKeys(),checkedNodes:this.getCheckedNodes(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}updateNodeCheckState(e,t){if(e.checked=t,e.halfChecked=!1,e.children)for(const s of e.children)this.updateNodeCheckState(s,t);this.updateParentCheckState(this.treeData,e)}updateParentCheckState(e,t){for(const s of e)if(s.children){if(s.children.includes(t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}if(this.updateParentCheckState(s.children,t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}}return!1}findNode(e,t){for(const s of e){if(s.key===t)return s;if(s.children){const e=this.findNode(s.children,t);if(e)return e}}return null}clearSelection(){const e=t=>{for(const s of t)s.selected=!1,s.children&&e(s.children)};e(this.treeData)}getCheckedKeys(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set checkedKeys(e){const t=e=>{for(const s of e)s.checked=!1,s.halfChecked=!1,s.children&&t(s.children)};t(this.treeData);const s=(e,t)=>{for(const n of e)t.includes(n.key)&&(n.checked=!0),n.children&&s(n.children,t)};s(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getExpandedKeys(){const e=[],t=s=>{for(const n of s)n.expanded&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set expandedKeys(e){const t=s=>{for(const n of s)n.expanded=e.includes(n.key),n.children&&t(n.children)};t(this.treeData),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getSelectedKeys(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}getSelectedNodes(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}getCheckedNodes(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}setTreeData(e){this.treeData=e,this.$data.treeData=JSON.stringify(e),this.flattenTree()}getTreeData(){return this.treeData}get value(){return this.getSelectedKeys()}set value(e){this.clearSelection();const t=(e,s)=>{for(const n of e)s.includes(n.key)&&(n.selected=!0),n.children&&t(n.children,s)};t(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get selectedKeys(){return this.getSelectedKeys()}set selectedKeys(e){this.value=e}};r=((e,t)=>{for(var s,n=t,a=e.length-1;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n})([d({tagName:"solely-tree",template:s,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"treeData",type:"string"},{name:"showLine",type:"boolean",default:!1},{name:"multiple",type:"boolean",default:!1},{name:"checkable",type:"boolean",default:!1},{name:"defaultExpandAll",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"searchable",type:"boolean",default:!1},{name:"searchValue",type:"string"},{name:"block",type:"boolean",default:!1}]})],r);export{r as SolelyTree};
@@ -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.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}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 +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.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}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 +1 @@
1
- "use strict";var t,e,s,i,a,n,o,r,h,l,c,u,d,p,f,b,m,y,v,w,g,M,S,$,k=Object.defineProperty,O=t=>{throw TypeError(t)},j=(t,e,s)=>e.has(t)||O("Cannot "+s),C=(t,e,s)=>(j(t,e,"read from private field"),s?s.call(t):e.get(t)),A=(t,e,s)=>e.has(t)?O("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),W=(t,e,s,i)=>(j(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),N=(t,e,s)=>(j(t,e,"access private method"),s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=require("../../shared/is-object.cjs"),D=require("../../shared/env.cjs"),P=require("../reactivity/observe.cjs"),U=require("../renderer/renderIR.cjs"),q=Symbol.for("solely.manifest"),I=class m extends HTMLElement{constructor(d={}){var f,m;super(),A(this,p),((t,e,s)=>{e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(m="$refs")?m+"":m,{}),A(this,t),A(this,e),A(this,s),A(this,i),A(this,a),A(this,n),A(this,o,!1),A(this,r,!1),A(this,h,!1),A(this,l,!1),A(this,c,!1),A(this,u,!1);const v=this.constructor;W(this,t,v[q]||{tagName:"base-element"});const w=C(this,t);W(this,a,(null==(f=w.shadowDOM)?void 0:f.use)?this.attachShadow({mode:w.shadowDOM.mode||"open"}):this),N(this,p,b).call(this,d),N(this,p,y).call(this,w),queueMicrotask(()=>N(this,p,$).call(this))}static get observedAttributes(){const t=this[q];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return C(this,i)}set $data(t){var e;E.isObject(t)||(t={}),t!==C(this,i)&&(null==(e=C(this,n))||e.call(this),N(this,p,b).call(this,t),N(this,p,g).call(this))}refresh(){N(this,p,g).call(this)}connectedCallback(){var i;W(this,c,!0);const n=C(this,t);if(N(this,p,$).call(this),(n.className||n.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),N(this,p,S).call(this),n.attributeMap&&E.isObject(this.$data)){N(this,p,v).call(this);for(const[t,e]of n.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=N(this,p,w).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}N(this,p,f).call(this),C(this,s)&&!C(this,e)&&W(this,e,U.createRender(C(this,s),C(this,a),this)),C(this,u)&&(W(this,u,!1),N(this,p,g).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){var e,s;W(this,c,!1);const i=C(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${i.tagName}`,e=C(m,d).get(t)||0;e<=1?(null==(s=document.head.querySelector(`#${t}`))||s.remove(),C(m,d).delete(t)):C(m,d).set(t,e-1)}this.unmounted()}attributeChangedCallback(e,s,i){var a;if(s===i||!E.isObject(this.$data))return;const n=null==(a=C(this,t).attributeMap)?void 0:a.get(e);if(!n)return;const o=n.name,r=this.$data[o],l=N(this,p,w).call(this,i,n.default??r,n.type);this.$data[o]=l,W(this,h,!0),this.attributeChanged(e,r,l)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(D.IS_DEV&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(D.IS_DEV&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakSet,f=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=new Set(["$data","$refs","constructor","onInit","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","refresh"]);for(const i of t){if(s.has(i))continue;if(e.some(t=>i.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,i);if(!t||!("value"in t))continue;const a=t.value;let n,o=this;for(;o&&(n=Object.getOwnPropertyDescriptor(o,i),!(null==n?void 0:n.set));)o=Object.getPrototypeOf(o);(null==n?void 0:n.set)&&(delete this[i],this[i]=a)}},b=function(e){const{proxy:s,dispose:a}=P.observe(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,n=C(this,t),o=String(i),r=null==(s=n.propMap)?void 0:s.get(o);(null==r?void 0:r.reflect)&&N(this,p,m).call(this,r,a)}this.emit("dataChange",{...e}),N(this,p,g).call(this)});W(this,i,s),W(this,n,a)},m=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},y=function(t){t.ir&&W(this,s,t.ir)},v=function(){const e=C(this,t);if(e.attributeMap)for(const[t,s]of e.attributeMap){if(!1===s.reactive)continue;const t=Object.getOwnPropertyDescriptor(this.constructor.prototype,s.name);if(!(null==t?void 0:t.get)&&!(null==t?void 0:t.set)){const t=Object.getOwnPropertyDescriptor(this,s.name);t&&"value"in t&&(this.$data[s.name]=t.value,delete this[s.name]),Object.defineProperty(this,s.name,{get:()=>this.$data[s.name],set:t=>{this.$data[s.name]=t},configurable:!0,enumerable:!0})}}},w=function(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=t.replace(/'/g,'"'),i=JSON.parse(s);return Array.isArray(i)?i:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},g=function(){C(this,c)?!C(this,r)&&C(this,e)&&(W(this,r,!0),queueMicrotask(()=>{W(this,r,!1),N(this,p,M).call(this)})):W(this,u,!0)},M=function(){if(!C(this,o)&&C(this,c)){W(this,o,!0);try{C(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),C(this,e).update(),this.updated(),C(this,h)&&(this.afterAttributesUpdate(),W(this,h,!1))}finally{W(this,o,!1)}}},S=function(){var e;const s=C(this,t);if(!s.styles)return;const i=C(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i)return void(i.adoptedStyleSheets.includes(s.sheet)||(i.adoptedStyleSheets=[...i.adoptedStyleSheets,s.sheet]));const n=i instanceof ShadowRoot?i:document.head,o=`solely-style-${s.tagName}`,r=!(null==(e=s.shadowDOM)?void 0:e.use);if(!n.querySelector(`#${o}`)){const t=document.createElement("style");t.id=o,t.textContent=s.styles,n.appendChild(t)}if(r){const t=C(I,d).get(o)||0;C(I,d).set(o,t+1)}},$=function(){C(this,l)||(W(this,l,!0),this.created())},A(I,d,new Map),(()=>{if(D.IS_DEV&&"undefined"!=typeof customElements){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,a){if(I.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,a=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of a)t[e]!==I.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,a)}}})();let _=I;exports.default=_;
1
+ "use strict";var t,e,s,i,a,n,o,r,h,l,c,u,d,p,f,b,m,y,v,w,g,M,S,$,k=Object.defineProperty,O=t=>{throw TypeError(t)},j=(t,e,s)=>e.has(t)||O("Cannot "+s),C=(t,e,s)=>(j(t,e,"read from private field"),s?s.call(t):e.get(t)),A=(t,e,s)=>e.has(t)?O("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),W=(t,e,s,i)=>(j(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),N=(t,e,s)=>(j(t,e,"access private method"),s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=require("../../shared/is-object.cjs"),D=require("../../shared/env.cjs"),P=require("../reactivity/observe.cjs"),U=require("../renderer/renderIR.cjs"),q=Symbol.for("solely.manifest"),I=class m extends HTMLElement{constructor(d={}){var f,m;super(),A(this,p),((t,e,s)=>{e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(m="$refs")?m+"":m,{}),A(this,t),A(this,e),A(this,s),A(this,i),A(this,a),A(this,n),A(this,o,!1),A(this,r,!1),A(this,h,!1),A(this,l,!1),A(this,c,!1),A(this,u,!1);const v=this.constructor;W(this,t,v[q]||{tagName:"base-element"});const w=C(this,t);W(this,a,(null==(f=w.shadowDOM)?void 0:f.use)?this.attachShadow({mode:w.shadowDOM.mode||"open"}):this),N(this,p,b).call(this,d),N(this,p,y).call(this,w),queueMicrotask(()=>N(this,p,$).call(this))}static get observedAttributes(){const t=this[q];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return C(this,i)}set $data(t){var e;E.isObject(t)||(t={}),t!==C(this,i)&&(null==(e=C(this,n))||e.call(this),N(this,p,b).call(this,t),N(this,p,g).call(this))}refresh(){N(this,p,g).call(this)}connectedCallback(){var i;W(this,c,!0);const n=C(this,t);if(N(this,p,$).call(this),(n.className||n.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),N(this,p,S).call(this),n.attributeMap&&E.isObject(this.$data)){N(this,p,v).call(this);for(const[t,e]of n.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=N(this,p,w).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}N(this,p,f).call(this),C(this,s)&&!C(this,e)&&W(this,e,U.createRender(C(this,s),C(this,a),this)),C(this,u)&&(W(this,u,!1),N(this,p,g).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){var e,s;W(this,c,!1);const i=C(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${i.tagName}`,e=C(m,d).get(t)||0;e<=1?(null==(s=document.head.querySelector(`#${t}`))||s.remove(),C(m,d).delete(t)):C(m,d).set(t,e-1)}this.unmounted()}attributeChangedCallback(e,s,i){var a;if(s===i||!E.isObject(this.$data))return;const n=null==(a=C(this,t).attributeMap)?void 0:a.get(e);if(!n)return;const o=n.name,r=this.$data[o],l=N(this,p,w).call(this,i,n.default??r,n.type);this.$data[o]=l,W(this,h,!0),this.attributeChanged(e,r,l)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(D.IS_DEV&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(D.IS_DEV&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakSet,f=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=new Set(["$data","$refs","constructor","onInit","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","refresh"]);for(const i of t){if(s.has(i))continue;if(e.some(t=>i.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,i);if(!t||!("value"in t))continue;const a=t.value;let n,o=this;for(;o&&(n=Object.getOwnPropertyDescriptor(o,i),!(null==n?void 0:n.set));)o=Object.getPrototypeOf(o);(null==n?void 0:n.set)&&(delete this[i],this[i]=a)}},b=function(e){const{proxy:s,dispose:a}=P.observe(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,n=C(this,t),o=String(i),r=null==(s=n.propMap)?void 0:s.get(o);(null==r?void 0:r.reflect)&&N(this,p,m).call(this,r,a)}this.emit("dataChange",{...e}),N(this,p,g).call(this)});W(this,i,s),W(this,n,a)},m=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},y=function(t){t.ir&&W(this,s,t.ir)},v=function(){const e=C(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;const e=Object.getOwnPropertyDescriptor(this.constructor.prototype,t.name);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},w=function(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=t.replace(/'/g,'"'),i=JSON.parse(s);return Array.isArray(i)?i:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},g=function(){C(this,c)?!C(this,r)&&C(this,e)&&(W(this,r,!0),queueMicrotask(()=>{W(this,r,!1),N(this,p,M).call(this)})):W(this,u,!0)},M=function(){if(!C(this,o)&&C(this,c)){W(this,o,!0);try{C(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),C(this,e).update(),this.updated(),C(this,h)&&(this.afterAttributesUpdate(),W(this,h,!1))}finally{W(this,o,!1)}}},S=function(){var e;const s=C(this,t);if(!s.styles)return;const i=C(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i)return void(i.adoptedStyleSheets.includes(s.sheet)||(i.adoptedStyleSheets=[...i.adoptedStyleSheets,s.sheet]));const n=i instanceof ShadowRoot?i:document.head,o=`solely-style-${s.tagName}`,r=!(null==(e=s.shadowDOM)?void 0:e.use);if(!n.querySelector(`#${o}`)){const t=document.createElement("style");t.id=o,t.textContent=s.styles,n.appendChild(t)}if(r){const t=C(I,d).get(o)||0;C(I,d).set(o,t+1)}},$=function(){C(this,l)||(W(this,l,!0),this.created())},A(I,d,new Map),(()=>{if(D.IS_DEV&&"undefined"!=typeof customElements){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,a){if(I.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,a=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of a)t[e]!==I.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,a)}}})();let _=I;exports.default=_;
@@ -1 +1 @@
1
- var t,e,s,i,a,o,n,r,h,l,c,u,d,p,f,b,m,y,v,w,g,M,$,k,S=Object.defineProperty,O=t=>{throw TypeError(t)},C=(t,e,s)=>e.has(t)||O("Cannot "+s),A=(t,e,s)=>(C(t,e,"read from private field"),s?s.call(t):e.get(t)),W=(t,e,s)=>e.has(t)?O("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),j=(t,e,s,i)=>(C(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),N=(t,e,s)=>(C(t,e,"access private method"),s);import{isObject as E}from"../../shared/is-object.js";import{IS_DEV as P}from"../../shared/env.js";import{observe as U}from"../reactivity/observe.js";import{createRender as D}from"../renderer/renderIR.js";const L=Symbol.for("solely.manifest"),q=class m extends HTMLElement{constructor(d={}){var f,m;super(),W(this,p),((t,e,s)=>{e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(m="$refs")?m+"":m,{}),W(this,t),W(this,e),W(this,s),W(this,i),W(this,a),W(this,o),W(this,n,!1),W(this,r,!1),W(this,h,!1),W(this,l,!1),W(this,c,!1),W(this,u,!1);const v=this.constructor;j(this,t,v[L]||{tagName:"base-element"});const w=A(this,t);j(this,a,(null==(f=w.shadowDOM)?void 0:f.use)?this.attachShadow({mode:w.shadowDOM.mode||"open"}):this),N(this,p,b).call(this,d),N(this,p,y).call(this,w),queueMicrotask(()=>N(this,p,k).call(this))}static get observedAttributes(){const t=this[L];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return A(this,i)}set $data(t){var e;E(t)||(t={}),t!==A(this,i)&&(null==(e=A(this,o))||e.call(this),N(this,p,b).call(this,t),N(this,p,g).call(this))}refresh(){N(this,p,g).call(this)}connectedCallback(){var i;j(this,c,!0);const o=A(this,t);if(N(this,p,k).call(this),(o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),N(this,p,$).call(this),o.attributeMap&&E(this.$data)){N(this,p,v).call(this);for(const[t,e]of o.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=N(this,p,w).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}N(this,p,f).call(this),A(this,s)&&!A(this,e)&&j(this,e,D(A(this,s),A(this,a),this)),A(this,u)&&(j(this,u,!1),N(this,p,g).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){var e,s;j(this,c,!1);const i=A(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${i.tagName}`,e=A(m,d).get(t)||0;e<=1?(null==(s=document.head.querySelector(`#${t}`))||s.remove(),A(m,d).delete(t)):A(m,d).set(t,e-1)}this.unmounted()}attributeChangedCallback(e,s,i){var a;if(s===i||!E(this.$data))return;const o=null==(a=A(this,t).attributeMap)?void 0:a.get(e);if(!o)return;const n=o.name,r=this.$data[n],l=N(this,p,w).call(this,i,o.default??r,o.type);this.$data[n]=l,j(this,h,!0),this.attributeChanged(e,r,l)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(P&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(P&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakMap,r=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakSet,f=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=new Set(["$data","$refs","constructor","onInit","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","refresh"]);for(const i of t){if(s.has(i))continue;if(e.some(t=>i.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,i);if(!t||!("value"in t))continue;const a=t.value;let o,n=this;for(;n&&(o=Object.getOwnPropertyDescriptor(n,i),!(null==o?void 0:o.set));)n=Object.getPrototypeOf(n);(null==o?void 0:o.set)&&(delete this[i],this[i]=a)}},b=function(e){const{proxy:s,dispose:a}=U(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,o=A(this,t),n=String(i),r=null==(s=o.propMap)?void 0:s.get(n);(null==r?void 0:r.reflect)&&N(this,p,m).call(this,r,a)}this.emit("dataChange",{...e}),N(this,p,g).call(this)});j(this,i,s),j(this,o,a)},m=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},y=function(t){t.ir&&j(this,s,t.ir)},v=function(){const e=A(this,t);if(e.attributeMap)for(const[t,s]of e.attributeMap){if(!1===s.reactive)continue;const t=Object.getOwnPropertyDescriptor(this.constructor.prototype,s.name);if(!(null==t?void 0:t.get)&&!(null==t?void 0:t.set)){const t=Object.getOwnPropertyDescriptor(this,s.name);t&&"value"in t&&(this.$data[s.name]=t.value,delete this[s.name]),Object.defineProperty(this,s.name,{get:()=>this.$data[s.name],set:t=>{this.$data[s.name]=t},configurable:!0,enumerable:!0})}}},w=function(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=t.replace(/'/g,'"'),i=JSON.parse(s);return Array.isArray(i)?i:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},g=function(){A(this,c)?!A(this,r)&&A(this,e)&&(j(this,r,!0),queueMicrotask(()=>{j(this,r,!1),N(this,p,M).call(this)})):j(this,u,!0)},M=function(){if(!A(this,n)&&A(this,c)){j(this,n,!0);try{A(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),A(this,e).update(),this.updated(),A(this,h)&&(this.afterAttributesUpdate(),j(this,h,!1))}finally{j(this,n,!1)}}},$=function(){var e;const s=A(this,t);if(!s.styles)return;const i=A(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i)return void(i.adoptedStyleSheets.includes(s.sheet)||(i.adoptedStyleSheets=[...i.adoptedStyleSheets,s.sheet]));const o=i instanceof ShadowRoot?i:document.head,n=`solely-style-${s.tagName}`,r=!(null==(e=s.shadowDOM)?void 0:e.use);if(!o.querySelector(`#${n}`)){const t=document.createElement("style");t.id=n,t.textContent=s.styles,o.appendChild(t)}if(r){const t=A(q,d).get(n)||0;A(q,d).set(n,t+1)}},k=function(){A(this,l)||(j(this,l,!0),this.created())},W(q,d,new Map),(()=>{if(P&&"undefined"!=typeof customElements){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,a){if(q.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,a=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of a)t[e]!==q.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,a)}}})();let x=q;export{x as default};
1
+ var t,e,s,i,a,o,n,r,h,l,c,u,d,p,f,b,m,y,v,w,g,M,$,k,S=Object.defineProperty,O=t=>{throw TypeError(t)},C=(t,e,s)=>e.has(t)||O("Cannot "+s),A=(t,e,s)=>(C(t,e,"read from private field"),s?s.call(t):e.get(t)),W=(t,e,s)=>e.has(t)?O("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),j=(t,e,s,i)=>(C(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),N=(t,e,s)=>(C(t,e,"access private method"),s);import{isObject as E}from"../../shared/is-object.js";import{IS_DEV as P}from"../../shared/env.js";import{observe as U}from"../reactivity/observe.js";import{createRender as D}from"../renderer/renderIR.js";const L=Symbol.for("solely.manifest"),q=class m extends HTMLElement{constructor(d={}){var f,m;super(),W(this,p),((t,e,s)=>{e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(m="$refs")?m+"":m,{}),W(this,t),W(this,e),W(this,s),W(this,i),W(this,a),W(this,o),W(this,n,!1),W(this,r,!1),W(this,h,!1),W(this,l,!1),W(this,c,!1),W(this,u,!1);const v=this.constructor;j(this,t,v[L]||{tagName:"base-element"});const w=A(this,t);j(this,a,(null==(f=w.shadowDOM)?void 0:f.use)?this.attachShadow({mode:w.shadowDOM.mode||"open"}):this),N(this,p,b).call(this,d),N(this,p,y).call(this,w),queueMicrotask(()=>N(this,p,k).call(this))}static get observedAttributes(){const t=this[L];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return A(this,i)}set $data(t){var e;E(t)||(t={}),t!==A(this,i)&&(null==(e=A(this,o))||e.call(this),N(this,p,b).call(this,t),N(this,p,g).call(this))}refresh(){N(this,p,g).call(this)}connectedCallback(){var i;j(this,c,!0);const o=A(this,t);if(N(this,p,k).call(this),(o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),N(this,p,$).call(this),o.attributeMap&&E(this.$data)){N(this,p,v).call(this);for(const[t,e]of o.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=N(this,p,w).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}N(this,p,f).call(this),A(this,s)&&!A(this,e)&&j(this,e,D(A(this,s),A(this,a),this)),A(this,u)&&(j(this,u,!1),N(this,p,g).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){var e,s;j(this,c,!1);const i=A(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${i.tagName}`,e=A(m,d).get(t)||0;e<=1?(null==(s=document.head.querySelector(`#${t}`))||s.remove(),A(m,d).delete(t)):A(m,d).set(t,e-1)}this.unmounted()}attributeChangedCallback(e,s,i){var a;if(s===i||!E(this.$data))return;const o=null==(a=A(this,t).attributeMap)?void 0:a.get(e);if(!o)return;const n=o.name,r=this.$data[n],l=N(this,p,w).call(this,i,o.default??r,o.type);this.$data[n]=l,j(this,h,!0),this.attributeChanged(e,r,l)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(P&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(P&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakMap,r=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakSet,f=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=new Set(["$data","$refs","constructor","onInit","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","refresh"]);for(const i of t){if(s.has(i))continue;if(e.some(t=>i.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,i);if(!t||!("value"in t))continue;const a=t.value;let o,n=this;for(;n&&(o=Object.getOwnPropertyDescriptor(n,i),!(null==o?void 0:o.set));)n=Object.getPrototypeOf(n);(null==o?void 0:o.set)&&(delete this[i],this[i]=a)}},b=function(e){const{proxy:s,dispose:a}=U(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,o=A(this,t),n=String(i),r=null==(s=o.propMap)?void 0:s.get(n);(null==r?void 0:r.reflect)&&N(this,p,m).call(this,r,a)}this.emit("dataChange",{...e}),N(this,p,g).call(this)});j(this,i,s),j(this,o,a)},m=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},y=function(t){t.ir&&j(this,s,t.ir)},v=function(){const e=A(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;const e=Object.getOwnPropertyDescriptor(this.constructor.prototype,t.name);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},w=function(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=t.replace(/'/g,'"'),i=JSON.parse(s);return Array.isArray(i)?i:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},g=function(){A(this,c)?!A(this,r)&&A(this,e)&&(j(this,r,!0),queueMicrotask(()=>{j(this,r,!1),N(this,p,M).call(this)})):j(this,u,!0)},M=function(){if(!A(this,n)&&A(this,c)){j(this,n,!0);try{A(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),A(this,e).update(),this.updated(),A(this,h)&&(this.afterAttributesUpdate(),j(this,h,!1))}finally{j(this,n,!1)}}},$=function(){var e;const s=A(this,t);if(!s.styles)return;const i=A(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i)return void(i.adoptedStyleSheets.includes(s.sheet)||(i.adoptedStyleSheets=[...i.adoptedStyleSheets,s.sheet]));const o=i instanceof ShadowRoot?i:document.head,n=`solely-style-${s.tagName}`,r=!(null==(e=s.shadowDOM)?void 0:e.use);if(!o.querySelector(`#${n}`)){const t=document.createElement("style");t.id=n,t.textContent=s.styles,o.appendChild(t)}if(r){const t=A(q,d).get(n)||0;A(q,d).set(n,t+1)}},k=function(){A(this,l)||(j(this,l,!0),this.created())},W(q,d,new Map),(()=>{if(P&&"undefined"!=typeof customElements){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,a){if(q.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,a=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of a)t[e]!==q.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,a)}}})();let x=q;export{x as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=o=>{const s=o,l="undefined"!=typeof window&&"undefined"!=typeof customElements;return o=>{const{tagName:a}=s;if(l&&!(o.prototype instanceof HTMLElement)&&o!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${o.name||"anonymous class"}`);if(l&&customElements.get(a))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${a}" 已经被注册,跳过重复定义。`),o[n]=s,o;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const t=s.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(s.ir=t,e.IS_DEV&&console.info(`[Solely] Using precompiled IR for <${a}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${a}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${a}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=t.parseHtml(s.template);s.ir=r.buildIR(e,{source:s.template,filename:a})}catch(c){const t=c instanceof Error?c:new Error(String(c));console.error(`[Compiler Error] <${a}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${s.template.length} 字符`,e.IS_DEV?t.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${a}>: 模板为空字符串`);if(l&&s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch(c){e.IS_DEV&&console.warn(`[Style Warning] <${a}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.attributeMap){const e=new Map,t=new Map;s.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,o=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase(),s=n.name,l={...n,name:s};e.set(o,l),t.set(s,l)}),s.attributeMap=e,s.propMap=t}class i extends o{}return i[n]=s,l&&customElements.define(a,i),i}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=o=>{const s=o,l="undefined"!=typeof window&&"undefined"!=typeof customElements;return o=>{const{tagName:a}=s;if(l&&!(o.prototype instanceof HTMLElement)&&o!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${o.name||"anonymous class"}`);if(l&&customElements.get(a))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${a}" 已经被注册,跳过重复定义。`),o[n]=s,o;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const t=s.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(s.ir=t,e.IS_DEV&&console.info(`[Solely] Using precompiled IR for <${a}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${a}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${a}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=t.parseHtml(s.template);s.ir=r.buildIR(e,{source:s.template,filename:a})}catch(c){const t=c instanceof Error?c:new Error(String(c));console.error(`[Compiler Error] <${a}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${s.template.length} 字符`,e.IS_DEV?t.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${a}>: 模板为空字符串`);if(l&&s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch{e.IS_DEV&&console.warn(`[Style Warning] <${a}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.attributeMap){const e=new Map,t=new Map;s.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,o=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase(),s=n.name,l={...n,name:s};e.set(o,l),t.set(s,l)}),s.attributeMap=e,s.propMap=t}class i extends o{}return i[n]=s,l&&customElements.define(a,i),i}};
@@ -1 +1 @@
1
- import{IS_DEV as e}from"../../shared/env.js";import{parseHtml as t}from"../../compiler/parser/parser.js";import{buildIR as n}from"../../compiler/ir/buildIR.js";const o=Symbol.for("solely.manifest"),r=r=>{const s=r,l="undefined"!=typeof window&&"undefined"!=typeof customElements;return r=>{const{tagName:a}=s;if(l&&!(r.prototype instanceof HTMLElement)&&r!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${r.name||"anonymous class"}`);if(l&&customElements.get(a))return e&&console.warn(`[Solely] 标签名称 "${a}" 已经被注册,跳过重复定义。`),r[o]=s,r;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const t=s.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(s.ir=t,e&&console.info(`[Solely] Using precompiled IR for <${a}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${a}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${a}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=t(s.template);s.ir=n(e,{source:s.template,filename:a})}catch(p){const t=p instanceof Error?p:new Error(String(p));console.error(`[Compiler Error] <${a}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${s.template.length} 字符`,e?t.stack:"")}else e&&console.warn(`[Solely] <${a}>: 模板为空字符串`);if(l&&s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch(p){e&&console.warn(`[Style Warning] <${a}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.attributeMap){const e=new Map,t=new Map;s.props.forEach(n=>{const o="string"==typeof n?{name:n}:n,r=o.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase(),s=o.name,l={...o,name:s};e.set(r,l),t.set(s,l)}),s.attributeMap=e,s.propMap=t}class i extends r{}return i[o]=s,l&&customElements.define(a,i),i}};export{r as CustomElement};
1
+ import{IS_DEV as e}from"../../shared/env.js";import{parseHtml as t}from"../../compiler/parser/parser.js";import{buildIR as n}from"../../compiler/ir/buildIR.js";const o=Symbol.for("solely.manifest"),r=r=>{const s=r,l="undefined"!=typeof window&&"undefined"!=typeof customElements;return r=>{const{tagName:a}=s;if(l&&!(r.prototype instanceof HTMLElement)&&r!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${r.name||"anonymous class"}`);if(l&&customElements.get(a))return e&&console.warn(`[Solely] 标签名称 "${a}" 已经被注册,跳过重复定义。`),r[o]=s,r;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const t=s.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(s.ir=t,e&&console.info(`[Solely] Using precompiled IR for <${a}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${a}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${a}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=t(s.template);s.ir=n(e,{source:s.template,filename:a})}catch(p){const t=p instanceof Error?p:new Error(String(p));console.error(`[Compiler Error] <${a}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${s.template.length} 字符`,e?t.stack:"")}else e&&console.warn(`[Solely] <${a}>: 模板为空字符串`);if(l&&s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch{e&&console.warn(`[Style Warning] <${a}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.attributeMap){const e=new Map,t=new Map;s.props.forEach(n=>{const o="string"==typeof n?{name:n}:n,r=o.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase(),s=o.name,l={...o,name:s};e.set(r,l),t.set(s,l)}),s.attributeMap=e,s.propMap=t}class i extends r{}return i[o]=s,l&&customElements.define(a,i),i}};export{r as CustomElement};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.4.8",
4
+ "version": "0.4.10",
5
5
  "description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
6
6
  "type": "module",
7
7
  "sideEffects": false,