solely 0.4.0 → 0.4.2
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.
- package/dist/compiler/ir/buildIR.cjs +1 -1
- package/dist/compiler/ir/buildIR.js +1 -1
- package/dist/components/commands/drawer/index.cjs +1 -1
- package/dist/components/commands/drawer/index.js +1 -1
- package/dist/components/commands/drawer/types.d.ts +2 -2
- package/dist/components/commands/message/index.cjs +1 -1
- package/dist/components/commands/message/index.d.ts +5 -5
- package/dist/components/commands/message/index.js +1 -1
- package/dist/components/commands/message/types.d.ts +3 -3
- package/dist/components/commands/modal/index.cjs +1 -1
- package/dist/components/commands/modal/index.js +1 -1
- package/dist/components/commands/modal/types.d.ts +9 -7
- package/dist/components/commands/popconfirm/index.cjs +1 -1
- package/dist/components/commands/popconfirm/index.js +1 -1
- package/dist/components/commands/popconfirm/types.d.ts +8 -6
- package/dist/components/commands/tooltip/index.cjs +1 -1
- package/dist/components/commands/tooltip/index.js +1 -1
- package/dist/components/commands/tooltip/types.d.ts +1 -1
- package/dist/components/elements/backtop/index.cjs +1 -1
- package/dist/components/elements/backtop/index.d.ts +10 -0
- package/dist/components/elements/backtop/index.js +1 -1
- package/dist/components/elements/card/index.cjs +1 -1
- package/dist/components/elements/card/index.js +1 -1
- package/dist/components/elements/checkbox/index.cjs +1 -1
- package/dist/components/elements/checkbox/index.js +1 -1
- package/dist/components/elements/fab/style.css.cjs +1 -1
- package/dist/components/elements/fab/style.css.js +1 -1
- package/dist/components/elements/input/index.cjs +1 -1
- package/dist/components/elements/input/index.d.ts +18 -1
- package/dist/components/elements/input/index.html.cjs +1 -1
- package/dist/components/elements/input/index.html.js +1 -1
- package/dist/components/elements/input/index.js +1 -1
- package/dist/components/elements/input/style.css.cjs +1 -1
- package/dist/components/elements/input/style.css.js +1 -1
- package/dist/components/elements/pagination/index.cjs +1 -1
- package/dist/components/elements/pagination/index.js +1 -1
- package/dist/components/elements/radio/index.cjs +1 -1
- package/dist/components/elements/radio/index.js +1 -1
- package/dist/components/elements/select/index.cjs +1 -1
- package/dist/components/elements/select/index.d.ts +48 -6
- package/dist/components/elements/select/index.html.cjs +1 -1
- package/dist/components/elements/select/index.html.js +1 -1
- package/dist/components/elements/select/index.js +1 -1
- package/dist/components/elements/select/style.css.cjs +1 -1
- package/dist/components/elements/select/style.css.js +1 -1
- package/dist/components/elements/select/types.d.ts +35 -11
- package/dist/components/elements/slider/index.cjs +1 -1
- package/dist/components/elements/slider/index.js +1 -1
- package/dist/components/elements/steps/index.cjs +1 -1
- package/dist/components/elements/steps/index.d.ts +38 -1
- package/dist/components/elements/steps/index.html.cjs +1 -1
- package/dist/components/elements/steps/index.html.js +1 -1
- package/dist/components/elements/steps/index.js +1 -1
- package/dist/components/elements/steps/style.css.cjs +1 -1
- package/dist/components/elements/steps/style.css.js +1 -1
- package/dist/components/elements/switch/index.cjs +1 -1
- package/dist/components/elements/switch/index.d.ts +6 -1
- package/dist/components/elements/switch/index.js +1 -1
- package/dist/components/elements/table/index.cjs +1 -1
- package/dist/components/elements/table/index.js +1 -1
- package/dist/components/elements/tabs/index.cjs +1 -1
- package/dist/components/elements/tabs/index.js +1 -1
- package/dist/components/elements/timeline/index.cjs +1 -1
- package/dist/components/elements/timeline/index.js +1 -1
- package/dist/components/elements/tree/index.cjs +1 -1
- package/dist/components/elements/tree/index.js +1 -1
- package/dist/components/elements/upload/index.cjs +1 -1
- package/dist/components/elements/upload/index.js +1 -1
- package/dist/components/elements/utils/helpers.cjs +1 -0
- package/dist/components/elements/utils/helpers.d.ts +24 -0
- package/dist/components/elements/utils/helpers.js +1 -0
- package/dist/runtime/component/base-element.cjs +1 -1
- package/dist/runtime/component/base-element.d.ts +12 -0
- package/dist/runtime/component/base-element.js +1 -1
- package/dist/runtime/component/decorators.d.ts +11 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty;import t from"./style.css.js";import s from"./index.html.js";import n from"../../../runtime/component/base-element.js";import{CustomElement as
|
|
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],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}};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("../../../runtime/component/base-element.cjs"),
|
|
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 +1 @@
|
|
|
1
|
-
import e from"./style.css.js";import t from"./index.html.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.safeJsonParse=function(t,e){try{return JSON.parse(t||JSON.stringify(e))}catch{return e}},exports.throttle=function(t,e){let r=0;return function(...n){const o=Date.now();o-r>=e&&(r=o,t.apply(this,n))}};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用工具函数
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 安全地解析 JSON 字符串
|
|
6
|
+
* @param json - 要解析的 JSON 字符串
|
|
7
|
+
* @param defaultValue - 解析失败时的默认值
|
|
8
|
+
* @returns 解析后的值或默认值
|
|
9
|
+
*/
|
|
10
|
+
export declare function safeJsonParse<T>(json: string | undefined, defaultValue: T): T;
|
|
11
|
+
/**
|
|
12
|
+
* 创建防抖函数
|
|
13
|
+
* @param fn - 要防抖的函数
|
|
14
|
+
* @param delay - 延迟时间(毫秒)
|
|
15
|
+
* @returns 防抖后的函数
|
|
16
|
+
*/
|
|
17
|
+
export declare function debounce<T extends (...args: unknown[]) => void>(fn: T, delay: number): T;
|
|
18
|
+
/**
|
|
19
|
+
* 创建节流函数
|
|
20
|
+
* @param fn - 要节流的函数
|
|
21
|
+
* @param interval - 间隔时间(毫秒)
|
|
22
|
+
* @returns 节流后的函数
|
|
23
|
+
*/
|
|
24
|
+
export declare function throttle<T extends (...args: unknown[]) => void>(fn: T, interval: number): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t,n){try{return JSON.parse(t||JSON.stringify(n))}catch{return n}}function n(t,n){let r=0;return function(...e){const c=Date.now();c-r>=n&&(r=c,t.apply(this,e))}}export{t as safeJsonParse,n as throttle};
|
|
@@ -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,g,
|
|
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=_;
|
|
@@ -19,6 +19,18 @@ declare class BaseElement<TData extends object = Record<string, unknown>, TRefs
|
|
|
19
19
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
20
20
|
emit(eventName: string, detail?: unknown, options?: Partial<CustomEventInit>): void;
|
|
21
21
|
emitNative(eventName: string, options?: EventInit): void;
|
|
22
|
+
/**
|
|
23
|
+
* 在开发模式下输出警告信息
|
|
24
|
+
* @param condition - 是否输出警告的条件
|
|
25
|
+
* @param message - 警告信息
|
|
26
|
+
*/
|
|
27
|
+
protected warn(condition: boolean, message: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* 在开发模式下输出错误信息
|
|
30
|
+
* @param condition - 是否输出错误的条件
|
|
31
|
+
* @param message - 错误信息
|
|
32
|
+
*/
|
|
33
|
+
protected error(condition: boolean, message: string): void;
|
|
22
34
|
onInit(): void | Promise<void>;
|
|
23
35
|
created(): void;
|
|
24
36
|
mounted(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e,s,i,a,n,
|
|
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};
|
|
@@ -19,6 +19,15 @@ export interface PropDescriptor {
|
|
|
19
19
|
*/
|
|
20
20
|
reactive?: boolean;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Model 配置:定义 s-model 双向绑定的属性名和事件名
|
|
24
|
+
*/
|
|
25
|
+
export interface ModelConfig {
|
|
26
|
+
/** 要绑定的属性名,默认为 'value' */
|
|
27
|
+
prop?: string;
|
|
28
|
+
/** 监听的事件名,默认为 'change' */
|
|
29
|
+
event?: string;
|
|
30
|
+
}
|
|
22
31
|
/**
|
|
23
32
|
* Manifest:组件声明配置
|
|
24
33
|
* -------------------------------------------------------
|
|
@@ -40,6 +49,8 @@ export interface Manifest {
|
|
|
40
49
|
className?: string;
|
|
41
50
|
/** 注册的自定义元素标签名 */
|
|
42
51
|
tagName: string;
|
|
52
|
+
/** s-model 双向绑定配置 */
|
|
53
|
+
model?: ModelConfig;
|
|
43
54
|
}
|
|
44
55
|
/** 框架内部使用的运行时版本 */
|
|
45
56
|
export interface InternalManifest extends Manifest {
|
package/package.json
CHANGED