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.
Files changed (76) hide show
  1. package/dist/compiler/ir/buildIR.cjs +1 -1
  2. package/dist/compiler/ir/buildIR.js +1 -1
  3. package/dist/components/commands/drawer/index.cjs +1 -1
  4. package/dist/components/commands/drawer/index.js +1 -1
  5. package/dist/components/commands/drawer/types.d.ts +2 -2
  6. package/dist/components/commands/message/index.cjs +1 -1
  7. package/dist/components/commands/message/index.d.ts +5 -5
  8. package/dist/components/commands/message/index.js +1 -1
  9. package/dist/components/commands/message/types.d.ts +3 -3
  10. package/dist/components/commands/modal/index.cjs +1 -1
  11. package/dist/components/commands/modal/index.js +1 -1
  12. package/dist/components/commands/modal/types.d.ts +9 -7
  13. package/dist/components/commands/popconfirm/index.cjs +1 -1
  14. package/dist/components/commands/popconfirm/index.js +1 -1
  15. package/dist/components/commands/popconfirm/types.d.ts +8 -6
  16. package/dist/components/commands/tooltip/index.cjs +1 -1
  17. package/dist/components/commands/tooltip/index.js +1 -1
  18. package/dist/components/commands/tooltip/types.d.ts +1 -1
  19. package/dist/components/elements/backtop/index.cjs +1 -1
  20. package/dist/components/elements/backtop/index.d.ts +10 -0
  21. package/dist/components/elements/backtop/index.js +1 -1
  22. package/dist/components/elements/card/index.cjs +1 -1
  23. package/dist/components/elements/card/index.js +1 -1
  24. package/dist/components/elements/checkbox/index.cjs +1 -1
  25. package/dist/components/elements/checkbox/index.js +1 -1
  26. package/dist/components/elements/fab/style.css.cjs +1 -1
  27. package/dist/components/elements/fab/style.css.js +1 -1
  28. package/dist/components/elements/input/index.cjs +1 -1
  29. package/dist/components/elements/input/index.d.ts +18 -1
  30. package/dist/components/elements/input/index.html.cjs +1 -1
  31. package/dist/components/elements/input/index.html.js +1 -1
  32. package/dist/components/elements/input/index.js +1 -1
  33. package/dist/components/elements/input/style.css.cjs +1 -1
  34. package/dist/components/elements/input/style.css.js +1 -1
  35. package/dist/components/elements/pagination/index.cjs +1 -1
  36. package/dist/components/elements/pagination/index.js +1 -1
  37. package/dist/components/elements/radio/index.cjs +1 -1
  38. package/dist/components/elements/radio/index.js +1 -1
  39. package/dist/components/elements/select/index.cjs +1 -1
  40. package/dist/components/elements/select/index.d.ts +48 -6
  41. package/dist/components/elements/select/index.html.cjs +1 -1
  42. package/dist/components/elements/select/index.html.js +1 -1
  43. package/dist/components/elements/select/index.js +1 -1
  44. package/dist/components/elements/select/style.css.cjs +1 -1
  45. package/dist/components/elements/select/style.css.js +1 -1
  46. package/dist/components/elements/select/types.d.ts +35 -11
  47. package/dist/components/elements/slider/index.cjs +1 -1
  48. package/dist/components/elements/slider/index.js +1 -1
  49. package/dist/components/elements/steps/index.cjs +1 -1
  50. package/dist/components/elements/steps/index.d.ts +38 -1
  51. package/dist/components/elements/steps/index.html.cjs +1 -1
  52. package/dist/components/elements/steps/index.html.js +1 -1
  53. package/dist/components/elements/steps/index.js +1 -1
  54. package/dist/components/elements/steps/style.css.cjs +1 -1
  55. package/dist/components/elements/steps/style.css.js +1 -1
  56. package/dist/components/elements/switch/index.cjs +1 -1
  57. package/dist/components/elements/switch/index.d.ts +6 -1
  58. package/dist/components/elements/switch/index.js +1 -1
  59. package/dist/components/elements/table/index.cjs +1 -1
  60. package/dist/components/elements/table/index.js +1 -1
  61. package/dist/components/elements/tabs/index.cjs +1 -1
  62. package/dist/components/elements/tabs/index.js +1 -1
  63. package/dist/components/elements/timeline/index.cjs +1 -1
  64. package/dist/components/elements/timeline/index.js +1 -1
  65. package/dist/components/elements/tree/index.cjs +1 -1
  66. package/dist/components/elements/tree/index.js +1 -1
  67. package/dist/components/elements/upload/index.cjs +1 -1
  68. package/dist/components/elements/upload/index.js +1 -1
  69. package/dist/components/elements/utils/helpers.cjs +1 -0
  70. package/dist/components/elements/utils/helpers.d.ts +24 -0
  71. package/dist/components/elements/utils/helpers.js +1 -0
  72. package/dist/runtime/component/base-element.cjs +1 -1
  73. package/dist/runtime/component/base-element.d.ts +12 -0
  74. package/dist/runtime/component/base-element.js +1 -1
  75. package/dist/runtime/component/decorators.d.ts +11 -0
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,t=(t,n,o)=>((t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o)(t,"symbol"!=typeof n?n+"":n,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../shared/gen-function.cjs"),o=require("../../shared/env.cjs"),c=require("../../types/ast.cjs"),i=require("../../types/lifecycle.cjs"),s=/\{\{[\s\S]*?\}\}/,l=new class{constructor(){t(this,"compilers",new Map)}get(e="anonymous"){let t=this.compilers.get(e);return t||(t=new r,this.compilers.set(e,t)),t}clear(e){var t;if(e)null==(t=this.compilers.get(e))||t.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class r{constructor(){t(this,"cache",new Map),t(this,"functions",[])}makeCacheKey(e,t,n){return 0===n.length?`${e}:${t}`:`${e}:${t}:${n.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,t,c){const i=null==t?void 0:t.trim();if(!i)return 0;const s=this.makeCacheKey(e,i,c),l=this.cache.get(s);if(void 0!==l)return l;let r;try{r=n.genFunction(i,e,c)}catch(u){o.IS_DEV&&console.error(`[IR Compile Error] Type: ${e}, Expr: "${i}"`,u),r=()=>""}const a=this.functions.push(r);return this.cache.set(s,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function a(e){const t=e[0];return":"===t?{isDynamic:!0,type:"expression"}:"@"===t?{isDynamic:!0,type:"handler"}:i.isLifecycleKind(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function u(e,t,n){e.__m={expr:t??"",loc:n??void 0}}function f(e){if(!e.attrs)return;const t=e.attrs.find(e=>"s-model"===e.key);if(!t)return;const n="$data."+t.value.replace("this.","").replace("$data.",""),o=t.loc,c=(e.tag||"").toLowerCase(),i=e.attrs.find(e=>"type"===e.key),s=(null==i?void 0:i.value)??"text";e.attrs=e.attrs.filter(e=>e!==t);const l=(t,n,c)=>{var i;null==(i=e.attrs)||i.push({key:t,value:n,role:c,loc:o})};if("input"===c){if("checkbox"===s){const t=e.attrs.find(e=>"value"===e.key),o=t?JSON.stringify(t.value):'"on"';return l(":checked",`Array.isArray(${n}) ? ${n}.includes(${o}) : ${n}`),void l("@change",`\n const _v = ${o};\n if(Array.isArray(${n})) {\n const _i = ${n}.indexOf(_v);\n if(checked && _i === -1) ${n}.push(_v);\n else if(!checked && _i > -1) ${n}.splice(_i,1);\n } else {\n ${n} = checked;\n }`,"model")}if("radio"===s){const t=e.attrs.find(e=>"value"===e.key),o=(null==t?void 0:t.value)??"null";return l(":checked",`${n} == ${JSON.stringify(o)}`),void l("@change",`if (checked) ${n} = ${JSON.stringify(o)}`,"model")}return l(":value",n),void l("@input",`${n} = value`,"model")}if("textarea"===c)return l(":value",n),void l("@input",`${n} = value`,"model");"select"!==c?(l(":value",n),l("@input",`${n} = $event`,"model")):e.attrs.some(e=>"multiple"===e.key)?(l("updated",`\n const values = Array.isArray(${n}) ? ${n} : ${n} != null ? [${n}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),l("@change",`${n} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(l(":value",n),l("@change",`${n} = value`,"model"))}function d(e,t,n,o=null){if(!e.attrs||0===e.attrs.length)return[];const c=[];for(const i of e.attrs){if(o&&o.has(i.key))continue;const{key:s,value:l,role:r}=i,{isDynamic:f,type:d}=a(s);if(f&&d){const o={k:s,f:n.compile(d,l??"",t),d:1,r:r};u(o,l,i.loc??e.loc),c.push(o)}else c.push({k:s,v:l,d:0,r:r})}return c}function p(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const t of e.c)if(!p(t))return!1;if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)if(!p(e))return!1;return!0}function h(e){if(e.c&&e.c.length>0)for(const t of e.c)h(t);if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)h(e);e.t!==c.ASTType.Element&&e.t!==c.ASTType.Text||0===e.d&&p(e)&&(e.s=1)}function y(e,t,n){var i,l,r,p,h,y;const m={t:e.type,d:0};let T=!1;var g;switch(e.type===c.ASTType.Text?(g=e.content)&&s.test(g)&&(T=!0):((null==(i=e.attrs)?void 0:i.some(e=>"s-model"===e.key||a(e.key).isDynamic))&&(T=!0),e.type===c.ASTType.For&&(T=!0)),m.d=T?1:0,e.type){case c.ASTType.Text:{const o=e.content??"";T?(m.f=n.compile("template",o,t),u(m,o,e.loc)):m.x=o;break}case c.ASTType.Element:m.g=e.tag,f(e),m.a=d(e,t,n),e.children&&(m.c=v(e.children,t,n));break;case c.ASTType.For:{const o=null==(l=e.attrs)?void 0:l.find(e=>"each"===e.key),c=(null==o?void 0:o.value)??"";m.f=n.compile("expression",c,t),m.i=(null==(p=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:p.value)??"item",m.n=(null==(y=null==(h=e.attrs)?void 0:h.find(e=>"index"===e.key))?void 0:y.value)??"index",u(m,c,(null==o?void 0:o.loc)??e.loc);const i=new Set(["each","item","index"]);m.a=d(e,t,n,i);const s=[...t,{i:m.i,x:m.n}];e.children&&(m.c=v(e.children,s,n));break}case c.ASTType.If:case c.ASTType.ElseIf:case c.ASTType.Else:o.IS_DEV&&console.warn(`[IR] Orphaned conditional node found: ${c.ASTType[e.type]}`),m.a=d(e,t,n),e.children&&(m.c=v(e.children,t,n));break;case c.ASTType.Comment:m.x=e.content??""}return m}function v(e,t,n){var o;const i=[];let s=0;for(;s<e.length;){const l=e[s];if(l.type===c.ASTType.If){const r=[];let a=s;for(;a<e.length;){const i=e[a],s=i.type;if(s!==c.ASTType.If&&s!==c.ASTType.ElseIf&&s!==c.ASTType.Else)break;if(s===c.ASTType.If&&r.length>0)break;let l,u=null,f="";if(s!==c.ASTType.Else){const e=null==(o=i.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);f=(null==e?void 0:e.value)??"false",u=n.compile("expression",f,t),l=(null==e?void 0:e.loc)??i.loc}const p=i.children?v(i.children,t,n):[],h=d(i,t,n,new Set(["test","condition"]));if(r.push({f:u,c:p,a:h.length>0?h:void 0,__m:{expr:f,loc:l}}),a++,s===c.ASTType.Else)break}i.push({t:c.ASTType.Conditional,d:1,b:r,__m:{loc:l.loc}}),s=a}else i.push(y(l,t,n)),s++}return i}exports.buildIR=function(e,t={}){const{filename:n="anonymous",source:c}=t,i=l.get(n);i.clear();const s=performance.now(),r=v(e,[],i);for(const o of r)h(o);const a=performance.now(),u=i.getStats(),f=r.filter(e=>1===e.d).length,d=r.filter(e=>1===e.s).length,p={t:"root",v:"1.2.0",fns:i.getFunctions(),n:r,s:{tf:u.total,cf:u.cached,dn:f,tn:r.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:n,...c&&{src:c}}};return o.IS_DEV&&console.info(`[Solely] Compiled <${n}> in ${(a-s).toFixed(2)}ms | Nodes: ${r.length} | Fns: ${u.total} | StaticSubtrees: ${d}`),p},exports.clearIRCache=function(e){l.clear(e)},exports.transformModel=f;
1
+ "use strict";var e=Object.defineProperty,t=(t,n,o)=>((t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o)(t,"symbol"!=typeof n?n+"":n,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../shared/gen-function.cjs"),o=require("../../shared/env.cjs"),c=require("../../types/ast.cjs"),l=require("../../types/lifecycle.cjs"),i=/\{\{[\s\S]*?\}\}/,s={"solely-checkbox":{prop:"checked",event:"change"},"solely-switch":{prop:"checked",event:"change"},"solely-radio":{prop:"checked",event:"change"}},r=new class{constructor(){t(this,"compilers",new Map)}get(e="anonymous"){let t=this.compilers.get(e);return t||(t=new a,this.compilers.set(e,t)),t}clear(e){var t;if(e)null==(t=this.compilers.get(e))||t.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class a{constructor(){t(this,"cache",new Map),t(this,"functions",[])}makeCacheKey(e,t,n){return 0===n.length?`${e}:${t}`:`${e}:${t}:${n.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,t,c){const l=null==t?void 0:t.trim();if(!l)return 0;const i=this.makeCacheKey(e,l,c),s=this.cache.get(i);if(void 0!==s)return s;let r;try{r=n.genFunction(l,e,c)}catch(u){o.IS_DEV&&console.error(`[IR Compile Error] Type: ${e}, Expr: "${l}"`,u),r=()=>""}const a=this.functions.push(r);return this.cache.set(i,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const t=e[0];return":"===t?{isDynamic:!0,type:"expression"}:"@"===t?{isDynamic:!0,type:"handler"}:l.isLifecycleKind(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function f(e,t,n){e.__m={expr:t??"",loc:n??void 0}}function d(e){if(!e.attrs)return;const t=e.attrs.find(e=>"s-model"===e.key);if(!t)return;const n="$data."+t.value.replace("this.","").replace("$data.",""),o=t.loc,c=(e.tag||"").toLowerCase(),l=e.attrs.find(e=>"type"===e.key),i=(null==l?void 0:l.value)??"text";e.attrs=e.attrs.filter(e=>e!==t);const r=(t,n,c)=>{var l;null==(l=e.attrs)||l.push({key:t,value:n,role:c,loc:o})};if("input"===c){if("checkbox"===i){const t=e.attrs.find(e=>"value"===e.key),o=t?JSON.stringify(t.value):'"on"';return r(":checked",`Array.isArray(${n}) ? ${n}.includes(${o}) : ${n}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${n})) {\n const _i = ${n}.indexOf(_v);\n if(checked && _i === -1) ${n}.push(_v);\n else if(!checked && _i > -1) ${n}.splice(_i,1);\n } else {\n ${n} = checked;\n }`,"model")}if("radio"===i){const t=e.attrs.find(e=>"value"===e.key),o=(null==t?void 0:t.value)??"null";return r(":checked",`${n} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${n} = ${JSON.stringify(o)}`,"model")}return r(":value",n),void r("@input",`${n} = value`,"model")}if("textarea"===c)return r(":value",n),void r("@input",`${n} = value`,"model");if("select"===c)return void(e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${n}) ? ${n} : ${n} != null ? [${n}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${n} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",n),r("@change",`${n} = value`,"model")));const a=s[c],u=(null==a?void 0:a.prop)??"value",f=(null==a?void 0:a.event)??"change";r(`:${u}`,n),r(`@${f}`,`${n} = ${"checked"===u?"checked":"value"===u?"value":`event.target.${u}`}`,"model")}function p(e,t,n,o=null){if(!e.attrs||0===e.attrs.length)return[];const c=[];for(const l of e.attrs){if(o&&o.has(l.key))continue;const{key:i,value:s,role:r}=l,{isDynamic:a,type:d}=u(i);if(a&&d){const o={k:i,f:n.compile(d,s??"",t),d:1,r:r};f(o,s,l.loc??e.loc),c.push(o)}else c.push({k:i,v:s,d:0,r:r})}return c}function h(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const t of e.c)if(!h(t))return!1;if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)if(!h(e))return!1;return!0}function y(e){if(e.c&&e.c.length>0)for(const t of e.c)y(t);if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)y(e);e.t!==c.ASTType.Element&&e.t!==c.ASTType.Text||0===e.d&&h(e)&&(e.s=1)}function v(e,t,n){var l,s,r,a,h,y;const v={t:e.type,d:0};let g=!1;var T;switch(e.type===c.ASTType.Text?(T=e.content)&&i.test(T)&&(g=!0):((null==(l=e.attrs)?void 0:l.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&(g=!0),e.type===c.ASTType.For&&(g=!0)),v.d=g?1:0,e.type){case c.ASTType.Text:{const o=e.content??"";g?(v.f=n.compile("template",o,t),f(v,o,e.loc)):v.x=o;break}case c.ASTType.Element:v.g=e.tag,d(e),v.a=p(e,t,n),e.children&&(v.c=m(e.children,t,n));break;case c.ASTType.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),c=(null==o?void 0:o.value)??"";v.f=n.compile("expression",c,t),v.i=(null==(a=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:a.value)??"item",v.n=(null==(y=null==(h=e.attrs)?void 0:h.find(e=>"index"===e.key))?void 0:y.value)??"index",f(v,c,(null==o?void 0:o.loc)??e.loc);const l=new Set(["each","item","index"]);v.a=p(e,t,n,l);const i=[...t,{i:v.i,x:v.n}];e.children&&(v.c=m(e.children,i,n));break}case c.ASTType.If:case c.ASTType.ElseIf:case c.ASTType.Else:o.IS_DEV&&console.warn(`[IR] Orphaned conditional node found: ${c.ASTType[e.type]}`),v.a=p(e,t,n),e.children&&(v.c=m(e.children,t,n));break;case c.ASTType.Comment:v.x=e.content??""}return v}function m(e,t,n){var o;const l=[];let i=0;for(;i<e.length;){const s=e[i];if(s.type===c.ASTType.If){const r=[];let a=i;for(;a<e.length;){const l=e[a],i=l.type;if(i!==c.ASTType.If&&i!==c.ASTType.ElseIf&&i!==c.ASTType.Else)break;if(i===c.ASTType.If&&r.length>0)break;let s,u=null,f="";if(i!==c.ASTType.Else){const e=null==(o=l.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);f=(null==e?void 0:e.value)??"false",u=n.compile("expression",f,t),s=(null==e?void 0:e.loc)??l.loc}const d=l.children?m(l.children,t,n):[],h=p(l,t,n,new Set(["test","condition"]));if(r.push({f:u,c:d,a:h.length>0?h:void 0,__m:{expr:f,loc:s}}),a++,i===c.ASTType.Else)break}l.push({t:c.ASTType.Conditional,d:1,b:r,__m:{loc:s.loc}}),i=a}else l.push(v(s,t,n)),i++}return l}exports.buildIR=function(e,t={}){const{filename:n="anonymous",source:c}=t,l=r.get(n);l.clear();const i=performance.now(),s=m(e,[],l);for(const o of s)y(o);const a=performance.now(),u=l.getStats(),f=s.filter(e=>1===e.d).length,d=s.filter(e=>1===e.s).length,p={t:"root",v:"1.2.0",fns:l.getFunctions(),n:s,s:{tf:u.total,cf:u.cached,dn:f,tn:s.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:n,...c&&{src:c}}};return o.IS_DEV&&console.info(`[Solely] Compiled <${n}> in ${(a-i).toFixed(2)}ms | Nodes: ${s.length} | Fns: ${u.total} | StaticSubtrees: ${d}`),p},exports.clearIRCache=function(e){r.clear(e)},exports.transformModel=d;
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,n,o)=>((t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o)(t,"symbol"!=typeof n?n+"":n,o);import{genFunction as n}from"../../shared/gen-function.js";import{IS_DEV as o}from"../../shared/env.js";import{ASTType as c}from"../../types/ast.js";import{isLifecycleKind as i}from"../../types/lifecycle.js";const l=/\{\{[\s\S]*?\}\}/,s=new class{constructor(){t(this,"compilers",new Map)}get(e="anonymous"){let t=this.compilers.get(e);return t||(t=new r,this.compilers.set(e,t)),t}clear(e){var t;if(e)null==(t=this.compilers.get(e))||t.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class r{constructor(){t(this,"cache",new Map),t(this,"functions",[])}makeCacheKey(e,t,n){return 0===n.length?`${e}:${t}`:`${e}:${t}:${n.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,t,c){const i=null==t?void 0:t.trim();if(!i)return 0;const l=this.makeCacheKey(e,i,c),s=this.cache.get(l);if(void 0!==s)return s;let r;try{r=n(i,e,c)}catch(f){o&&console.error(`[IR Compile Error] Type: ${e}, Expr: "${i}"`,f),r=()=>""}const a=this.functions.push(r);return this.cache.set(l,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function a(e){const t=e[0];return":"===t?{isDynamic:!0,type:"expression"}:"@"===t?{isDynamic:!0,type:"handler"}:i(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function f(e,t,n){e.__m={expr:t??"",loc:n??void 0}}function u(e){if(!e.attrs)return;const t=e.attrs.find(e=>"s-model"===e.key);if(!t)return;const n="$data."+t.value.replace("this.","").replace("$data.",""),o=t.loc,c=(e.tag||"").toLowerCase(),i=e.attrs.find(e=>"type"===e.key),l=(null==i?void 0:i.value)??"text";e.attrs=e.attrs.filter(e=>e!==t);const s=(t,n,c)=>{var i;null==(i=e.attrs)||i.push({key:t,value:n,role:c,loc:o})};if("input"===c){if("checkbox"===l){const t=e.attrs.find(e=>"value"===e.key),o=t?JSON.stringify(t.value):'"on"';return s(":checked",`Array.isArray(${n}) ? ${n}.includes(${o}) : ${n}`),void s("@change",`\n const _v = ${o};\n if(Array.isArray(${n})) {\n const _i = ${n}.indexOf(_v);\n if(checked && _i === -1) ${n}.push(_v);\n else if(!checked && _i > -1) ${n}.splice(_i,1);\n } else {\n ${n} = checked;\n }`,"model")}if("radio"===l){const t=e.attrs.find(e=>"value"===e.key),o=(null==t?void 0:t.value)??"null";return s(":checked",`${n} == ${JSON.stringify(o)}`),void s("@change",`if (checked) ${n} = ${JSON.stringify(o)}`,"model")}return s(":value",n),void s("@input",`${n} = value`,"model")}if("textarea"===c)return s(":value",n),void s("@input",`${n} = value`,"model");"select"!==c?(s(":value",n),s("@input",`${n} = $event`,"model")):e.attrs.some(e=>"multiple"===e.key)?(s("updated",`\n const values = Array.isArray(${n}) ? ${n} : ${n} != null ? [${n}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),s("@change",`${n} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(s(":value",n),s("@change",`${n} = value`,"model"))}function d(e,t,n,o=null){if(!e.attrs||0===e.attrs.length)return[];const c=[];for(const i of e.attrs){if(o&&o.has(i.key))continue;const{key:l,value:s,role:r}=i,{isDynamic:u,type:d}=a(l);if(u&&d){const o={k:l,f:n.compile(d,s??"",t),d:1,r:r};f(o,s,i.loc??e.loc),c.push(o)}else c.push({k:l,v:s,d:0,r:r})}return c}function h(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const t of e.c)if(!h(t))return!1;if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)if(!h(e))return!1;return!0}function p(e){if(e.c&&e.c.length>0)for(const t of e.c)p(t);if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)p(e);e.t!==c.Element&&e.t!==c.Text||0===e.d&&h(e)&&(e.s=1)}function m(e,t,n){var i,s,r,h,p,m;const y={t:e.type,d:0};let g=!1;var $;switch(e.type===c.Text?($=e.content)&&l.test($)&&(g=!0):((null==(i=e.attrs)?void 0:i.some(e=>"s-model"===e.key||a(e.key).isDynamic))&&(g=!0),e.type===c.For&&(g=!0)),y.d=g?1:0,e.type){case c.Text:{const o=e.content??"";g?(y.f=n.compile("template",o,t),f(y,o,e.loc)):y.x=o;break}case c.Element:y.g=e.tag,u(e),y.a=d(e,t,n),e.children&&(y.c=v(e.children,t,n));break;case c.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),c=(null==o?void 0:o.value)??"";y.f=n.compile("expression",c,t),y.i=(null==(h=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:h.value)??"item",y.n=(null==(m=null==(p=e.attrs)?void 0:p.find(e=>"index"===e.key))?void 0:m.value)??"index",f(y,c,(null==o?void 0:o.loc)??e.loc);const i=new Set(["each","item","index"]);y.a=d(e,t,n,i);const l=[...t,{i:y.i,x:y.n}];e.children&&(y.c=v(e.children,l,n));break}case c.If:case c.ElseIf:case c.Else:o&&console.warn(`[IR] Orphaned conditional node found: ${c[e.type]}`),y.a=d(e,t,n),e.children&&(y.c=v(e.children,t,n));break;case c.Comment:y.x=e.content??""}return y}function v(e,t,n){var o;const i=[];let l=0;for(;l<e.length;){const s=e[l];if(s.type===c.If){const r=[];let a=l;for(;a<e.length;){const i=e[a],l=i.type;if(l!==c.If&&l!==c.ElseIf&&l!==c.Else)break;if(l===c.If&&r.length>0)break;let s,f=null,u="";if(l!==c.Else){const e=null==(o=i.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);u=(null==e?void 0:e.value)??"false",f=n.compile("expression",u,t),s=(null==e?void 0:e.loc)??i.loc}const h=i.children?v(i.children,t,n):[],p=d(i,t,n,new Set(["test","condition"]));if(r.push({f:f,c:h,a:p.length>0?p:void 0,__m:{expr:u,loc:s}}),a++,l===c.Else)break}i.push({t:c.Conditional,d:1,b:r,__m:{loc:s.loc}}),l=a}else i.push(m(s,t,n)),l++}return i}function y(e,t={}){const{filename:n="anonymous",source:c}=t,i=s.get(n);i.clear();const l=performance.now(),r=v(e,[],i);for(const o of r)p(o);const a=performance.now(),f=i.getStats(),u=r.filter(e=>1===e.d).length,d=r.filter(e=>1===e.s).length,h={t:"root",v:"1.2.0",fns:i.getFunctions(),n:r,s:{tf:f.total,cf:f.cached,dn:u,tn:r.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:n,...c&&{src:c}}};return o&&console.info(`[Solely] Compiled <${n}> in ${(a-l).toFixed(2)}ms | Nodes: ${r.length} | Fns: ${f.total} | StaticSubtrees: ${d}`),h}function g(e){s.clear(e)}export{y as buildIR,g as clearIRCache,u as transformModel};
1
+ var e=Object.defineProperty,t=(t,n,o)=>((t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o)(t,"symbol"!=typeof n?n+"":n,o);import{genFunction as n}from"../../shared/gen-function.js";import{IS_DEV as o}from"../../shared/env.js";import{ASTType as c}from"../../types/ast.js";import{isLifecycleKind as l}from"../../types/lifecycle.js";const i=/\{\{[\s\S]*?\}\}/,s={"solely-checkbox":{prop:"checked",event:"change"},"solely-switch":{prop:"checked",event:"change"},"solely-radio":{prop:"checked",event:"change"}},r=new class{constructor(){t(this,"compilers",new Map)}get(e="anonymous"){let t=this.compilers.get(e);return t||(t=new a,this.compilers.set(e,t)),t}clear(e){var t;if(e)null==(t=this.compilers.get(e))||t.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class a{constructor(){t(this,"cache",new Map),t(this,"functions",[])}makeCacheKey(e,t,n){return 0===n.length?`${e}:${t}`:`${e}:${t}:${n.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,t,c){const l=null==t?void 0:t.trim();if(!l)return 0;const i=this.makeCacheKey(e,l,c),s=this.cache.get(i);if(void 0!==s)return s;let r;try{r=n(l,e,c)}catch(u){o&&console.error(`[IR Compile Error] Type: ${e}, Expr: "${l}"`,u),r=()=>""}const a=this.functions.push(r);return this.cache.set(i,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const t=e[0];return":"===t?{isDynamic:!0,type:"expression"}:"@"===t?{isDynamic:!0,type:"handler"}:l(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function f(e,t,n){e.__m={expr:t??"",loc:n??void 0}}function d(e){if(!e.attrs)return;const t=e.attrs.find(e=>"s-model"===e.key);if(!t)return;const n="$data."+t.value.replace("this.","").replace("$data.",""),o=t.loc,c=(e.tag||"").toLowerCase(),l=e.attrs.find(e=>"type"===e.key),i=(null==l?void 0:l.value)??"text";e.attrs=e.attrs.filter(e=>e!==t);const r=(t,n,c)=>{var l;null==(l=e.attrs)||l.push({key:t,value:n,role:c,loc:o})};if("input"===c){if("checkbox"===i){const t=e.attrs.find(e=>"value"===e.key),o=t?JSON.stringify(t.value):'"on"';return r(":checked",`Array.isArray(${n}) ? ${n}.includes(${o}) : ${n}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${n})) {\n const _i = ${n}.indexOf(_v);\n if(checked && _i === -1) ${n}.push(_v);\n else if(!checked && _i > -1) ${n}.splice(_i,1);\n } else {\n ${n} = checked;\n }`,"model")}if("radio"===i){const t=e.attrs.find(e=>"value"===e.key),o=(null==t?void 0:t.value)??"null";return r(":checked",`${n} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${n} = ${JSON.stringify(o)}`,"model")}return r(":value",n),void r("@input",`${n} = value`,"model")}if("textarea"===c)return r(":value",n),void r("@input",`${n} = value`,"model");if("select"===c)return void(e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${n}) ? ${n} : ${n} != null ? [${n}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${n} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",n),r("@change",`${n} = value`,"model")));const a=s[c],u=(null==a?void 0:a.prop)??"value",f=(null==a?void 0:a.event)??"change";r(`:${u}`,n),r(`@${f}`,`${n} = ${"checked"===u?"checked":"value"===u?"value":`event.target.${u}`}`,"model")}function h(e,t,n,o=null){if(!e.attrs||0===e.attrs.length)return[];const c=[];for(const l of e.attrs){if(o&&o.has(l.key))continue;const{key:i,value:s,role:r}=l,{isDynamic:a,type:d}=u(i);if(a&&d){const o={k:i,f:n.compile(d,s??"",t),d:1,r:r};f(o,s,l.loc??e.loc),c.push(o)}else c.push({k:i,v:s,d:0,r:r})}return c}function p(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const t of e.c)if(!p(t))return!1;if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)if(!p(e))return!1;return!0}function v(e){if(e.c&&e.c.length>0)for(const t of e.c)v(t);if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)v(e);e.t!==c.Element&&e.t!==c.Text||0===e.d&&p(e)&&(e.s=1)}function m(e,t,n){var l,s,r,a,p,v;const m={t:e.type,d:0};let g=!1;var $;switch(e.type===c.Text?($=e.content)&&i.test($)&&(g=!0):((null==(l=e.attrs)?void 0:l.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&(g=!0),e.type===c.For&&(g=!0)),m.d=g?1:0,e.type){case c.Text:{const o=e.content??"";g?(m.f=n.compile("template",o,t),f(m,o,e.loc)):m.x=o;break}case c.Element:m.g=e.tag,d(e),m.a=h(e,t,n),e.children&&(m.c=y(e.children,t,n));break;case c.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),c=(null==o?void 0:o.value)??"";m.f=n.compile("expression",c,t),m.i=(null==(a=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:a.value)??"item",m.n=(null==(v=null==(p=e.attrs)?void 0:p.find(e=>"index"===e.key))?void 0:v.value)??"index",f(m,c,(null==o?void 0:o.loc)??e.loc);const l=new Set(["each","item","index"]);m.a=h(e,t,n,l);const i=[...t,{i:m.i,x:m.n}];e.children&&(m.c=y(e.children,i,n));break}case c.If:case c.ElseIf:case c.Else:o&&console.warn(`[IR] Orphaned conditional node found: ${c[e.type]}`),m.a=h(e,t,n),e.children&&(m.c=y(e.children,t,n));break;case c.Comment:m.x=e.content??""}return m}function y(e,t,n){var o;const l=[];let i=0;for(;i<e.length;){const s=e[i];if(s.type===c.If){const r=[];let a=i;for(;a<e.length;){const l=e[a],i=l.type;if(i!==c.If&&i!==c.ElseIf&&i!==c.Else)break;if(i===c.If&&r.length>0)break;let s,u=null,f="";if(i!==c.Else){const e=null==(o=l.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);f=(null==e?void 0:e.value)??"false",u=n.compile("expression",f,t),s=(null==e?void 0:e.loc)??l.loc}const d=l.children?y(l.children,t,n):[],p=h(l,t,n,new Set(["test","condition"]));if(r.push({f:u,c:d,a:p.length>0?p:void 0,__m:{expr:f,loc:s}}),a++,i===c.Else)break}l.push({t:c.Conditional,d:1,b:r,__m:{loc:s.loc}}),i=a}else l.push(m(s,t,n)),i++}return l}function g(e,t={}){const{filename:n="anonymous",source:c}=t,l=r.get(n);l.clear();const i=performance.now(),s=y(e,[],l);for(const o of s)v(o);const a=performance.now(),u=l.getStats(),f=s.filter(e=>1===e.d).length,d=s.filter(e=>1===e.s).length,h={t:"root",v:"1.2.0",fns:l.getFunctions(),n:s,s:{tf:u.total,cf:u.cached,dn:f,tn:s.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:n,...c&&{src:c}}};return o&&console.info(`[Solely] Compiled <${n}> in ${(a-i).toFixed(2)}ms | Nodes: ${s.length} | Fns: ${u.total} | StaticSubtrees: ${d}`),h}function $(e){r.clear(e)}export{g as buildIR,$ as clearIRCache,d as transformModel};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),l={width:378,height:378,mask:!0,maskClosable:!0,closable:!0},n=[],a=new Set;let s=null;async function r(t){var l;if(!a.has(t)){a.add(t);try{const a=n.findIndex(e=>e.id===t);if(-1===a)return;const s=n[a],r=s.element.querySelector(".drawer-mask"),i=s.element.querySelector(".drawer");r&&r.classList.add("is-closing"),i&&i.classList.add("is-closing"),await e.addClosingAnimation(s.element,e.ANIMATION_DURATION.NORMAL),null==(l=s.cleanup)||l.call(s);const o=n.findIndex(e=>e.id===t);-1!==o&&(n[o].element.remove(),n.splice(o,1)),0===n.length&&document.body.classList.remove("solely-drawer-open")}finally{a.delete(t)}}}const i={open:function(a){const i=e.generateId();e.injectStyle("solely-drawer-styles",t.default);const o=a.placement||"right",d=a.width??l.width,c=a.height??l.height,m=a.mask??l.mask,h=a.maskClosable??l.maskClosable,u=a.closable??l.closable,y=e.createElement("div",{className:"drawer-wrap"}),p=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),s||(s=new MutationObserver(()=>{n.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{s&&0===n.length&&(s.disconnect(),s=null)}}(y),b=[];if(!1!==m){const t=e.createElement("div",{className:"drawer-mask"});if(h){const e=()=>{var e;r(i),null==(e=a.onClose)||e.call(a)};t.addEventListener("click",e),b.push({element:t,type:"click",handler:e})}y.appendChild(t)}const f=e.createElement("div",{className:`drawer drawer--${o}${a.className?` ${a.className}`:""}`,styles:a.style});if("left"===o||"right"===o?f.style.width="number"==typeof d?`${d}px`:d:f.style.height="number"==typeof c?`${c}px`:c,a.title||!1!==u){const t=e.createElement("div",{className:"drawer__header"});if(a.title){const l=e.createElement("h3",{className:"drawer__title",textContent:a.title});t.appendChild(l)}if(!1!==u){const l=e.createElement("button",{className:"drawer__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),n=()=>{var e;r(i),null==(e=a.onClose)||e.call(a)};l.addEventListener("click",n),b.push({element:l,type:"click",handler:n}),t.appendChild(l)}f.appendChild(t)}const w=e.createElement("div",{className:"drawer__body",styles:a.bodyStyle,textContent:a.content||""});return f.appendChild(w),y.appendChild(f),document.body.appendChild(y),document.body.classList.add("solely-drawer-open"),n.push({id:i,element:y,options:a,cleanup:()=>{b.forEach(({element:e,type:t,handler:l})=>{e.removeEventListener(t,l)}),p()}}),{close:()=>{var e;r(i),null==(e=a.onClose)||e.call(a)},update:t=>{if(void 0!==t.title){const l=y.querySelector(".drawer__title");if(l)l.textContent=t.title;else if(t.title){const l=e.createElement("div",{className:"drawer__header"}),n=e.createElement("h3",{className:"drawer__title",textContent:t.title});l.appendChild(n);const a=y.querySelector(".drawer");null==a||a.insertBefore(l,a.firstChild)}}if(void 0!==t.content){const e=y.querySelector(".drawer__body");e&&(e.textContent=t.content)}const l=y.querySelector(".drawer");if(l){const e=t.placement||a.placement||"right";void 0===t.width||"left"!==e&&"right"!==e||(l.style.width="number"==typeof t.width?`${t.width}px`:t.width),void 0===t.height||"top"!==e&&"bottom"!==e||(l.style.height="number"==typeof t.height?`${t.height}px`:t.height)}if(void 0!==t.className&&l){const e=a.placement||"right";l.className=`drawer drawer--${e} ${t.className}`.trim()}if(void 0!==t.style&&l&&Object.assign(l.style,t.style),void 0!==t.bodyStyle){const e=y.querySelector(".drawer__body");e&&Object.assign(e.style,t.bodyStyle)}}}},config:function(e){Object.assign(l,e)},destroy:async function(){const e=[...n].reverse();for(const t of e)await r(t.id)}};exports.Drawer=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={width:378,height:378,mask:!0,maskClosable:!0,closable:!0},l=[],a=new Set;let s=null;async function i(t){var n;if(!a.has(t)){a.add(t);try{const a=l.findIndex(e=>e.id===t);if(-1===a)return;const s=l[a],i=s.element.querySelector(".drawer-mask"),o=s.element.querySelector(".drawer");i&&i.classList.add("is-closing"),o&&o.classList.add("is-closing"),await e.addClosingAnimation(s.element,e.ANIMATION_DURATION.NORMAL),null==(n=s.cleanup)||n.call(s);const r=l.findIndex(e=>e.id===t);-1!==r&&(l[r].element.remove(),l.splice(r,1)),0===l.length&&document.body.classList.remove("solely-drawer-open")}finally{a.delete(t)}}}const o={open:function(a){const o=e.generateId();e.injectStyle("solely-drawer-styles",t.default);const r=a.placement||"right",d=a.width??n.width,c=a.height??n.height,m=a.mask??n.mask,h=a.maskClosable??n.maskClosable,p=a.closable??n.closable,u=e.createElement("div",{className:"drawer-wrap"}),y=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),s||(s=new MutationObserver(()=>{l.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{s&&0===l.length&&(s.disconnect(),s=null)}}(u),f=[];if(!1!==m){const t=e.createElement("div",{className:"drawer-mask"});if(h){const e=()=>{var e;i(o),null==(e=a.onClose)||e.call(a)};t.addEventListener("click",e),f.push({element:t,type:"click",handler:e})}u.appendChild(t)}const b=e.createElement("div",{className:`drawer drawer--${r}${a.className?` ${a.className}`:""}`,styles:a.style});if("left"===r||"right"===r?b.style.width="number"==typeof d?`${d}px`:d:b.style.height="number"==typeof c?`${c}px`:c,a.title||!1!==p){const t=e.createElement("div",{className:"drawer__header"});if(a.title){const n=e.createElement("h3",{className:"drawer__title"});"string"==typeof a.title?n.textContent=a.title:a.title instanceof HTMLElement&&n.appendChild(a.title.cloneNode(!0)),t.appendChild(n)}if(!1!==p){const n=e.createElement("button",{className:"drawer__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),l=()=>{var e;i(o),null==(e=a.onClose)||e.call(a)};n.addEventListener("click",l),f.push({element:n,type:"click",handler:l}),t.appendChild(n)}b.appendChild(t)}const w=e.createElement("div",{className:"drawer__body",styles:a.bodyStyle});return"string"==typeof a.content?w.textContent=a.content||"":a.content instanceof HTMLElement&&w.appendChild(a.content.cloneNode(!0)),b.appendChild(w),u.appendChild(b),document.body.appendChild(u),document.body.classList.add("solely-drawer-open"),l.push({id:o,element:u,options:a,cleanup:()=>{f.forEach(({element:e,type:t,handler:n})=>{e.removeEventListener(t,n)}),y()}}),{close:()=>{var e;i(o),null==(e=a.onClose)||e.call(a)},update:t=>{if(void 0!==t.title){const n=u.querySelector(".drawer__title");if(n)n.innerHTML="","string"==typeof t.title?n.textContent=t.title:t.title instanceof HTMLElement&&n.appendChild(t.title.cloneNode(!0));else if(t.title){const n=e.createElement("div",{className:"drawer__header"}),l=e.createElement("h3",{className:"drawer__title"});"string"==typeof t.title?l.textContent=t.title:t.title instanceof HTMLElement&&l.appendChild(t.title.cloneNode(!0)),n.appendChild(l);const a=u.querySelector(".drawer");null==a||a.insertBefore(n,a.firstChild)}}if(void 0!==t.content){const e=u.querySelector(".drawer__body");e&&(e.innerHTML="","string"==typeof t.content?e.textContent=t.content:t.content instanceof HTMLElement&&e.appendChild(t.content.cloneNode(!0)))}const n=u.querySelector(".drawer");if(n){const e=t.placement||a.placement||"right";void 0===t.width||"left"!==e&&"right"!==e||(n.style.width="number"==typeof t.width?`${t.width}px`:t.width),void 0===t.height||"top"!==e&&"bottom"!==e||(n.style.height="number"==typeof t.height?`${t.height}px`:t.height)}if(void 0!==t.className&&n){const e=a.placement||"right";n.className=`drawer drawer--${e} ${t.className}`.trim()}if(void 0!==t.style&&n&&Object.assign(n.style,t.style),void 0!==t.bodyStyle){const e=u.querySelector(".drawer__body");e&&Object.assign(e.style,t.bodyStyle)}}}},config:function(e){Object.assign(n,e)},destroy:async function(){const e=[...l].reverse();for(const t of e)await i(t.id)}};exports.Drawer=o;
@@ -1 +1 @@
1
- import{createElement as e,addClosingAnimation as t,ANIMATION_DURATION as l,injectStyle as n,generateId as s}from"../utils.js";import a from"./style.css.js";const o={width:378,height:378,mask:!0,maskClosable:!0,closable:!0},i=[],r=new Set;let d=null;async function c(e){var n;if(!r.has(e)){r.add(e);try{const s=i.findIndex(t=>t.id===e);if(-1===s)return;const a=i[s],o=a.element.querySelector(".drawer-mask"),r=a.element.querySelector(".drawer");o&&o.classList.add("is-closing"),r&&r.classList.add("is-closing"),await t(a.element,l.NORMAL),null==(n=a.cleanup)||n.call(a);const d=i.findIndex(t=>t.id===e);-1!==d&&(i[d].element.remove(),i.splice(d,1)),0===i.length&&document.body.classList.remove("solely-drawer-open")}finally{r.delete(e)}}}const m={open:function(t){const l=s();n("solely-drawer-styles",a);const r=t.placement||"right",m=t.width??o.width,h=t.height??o.height,u=t.mask??o.mask,p=t.maskClosable??o.maskClosable,y=t.closable??o.closable,f=e("div",{className:"drawer-wrap"}),b=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),d||(d=new MutationObserver(()=>{i.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),d.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{d&&0===i.length&&(d.disconnect(),d=null)}}(f),w=[];if(!1!==u){const n=e("div",{className:"drawer-mask"});if(p){const e=()=>{var e;c(l),null==(e=t.onClose)||e.call(t)};n.addEventListener("click",e),w.push({element:n,type:"click",handler:e})}f.appendChild(n)}const v=e("div",{className:`drawer drawer--${r}${t.className?` ${t.className}`:""}`,styles:t.style});if("left"===r||"right"===r?v.style.width="number"==typeof m?`${m}px`:m:v.style.height="number"==typeof h?`${h}px`:h,t.title||!1!==y){const n=e("div",{className:"drawer__header"});if(t.title){const l=e("h3",{className:"drawer__title",textContent:t.title});n.appendChild(l)}if(!1!==y){const s=e("button",{className:"drawer__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),a=()=>{var e;c(l),null==(e=t.onClose)||e.call(t)};s.addEventListener("click",a),w.push({element:s,type:"click",handler:a}),n.appendChild(s)}v.appendChild(n)}const g=e("div",{className:"drawer__body",styles:t.bodyStyle,textContent:t.content||""});return v.appendChild(g),f.appendChild(v),document.body.appendChild(f),document.body.classList.add("solely-drawer-open"),i.push({id:l,element:f,options:t,cleanup:()=>{w.forEach(({element:e,type:t,handler:l})=>{e.removeEventListener(t,l)}),b()}}),{close:()=>{var e;c(l),null==(e=t.onClose)||e.call(t)},update:l=>{if(void 0!==l.title){const t=f.querySelector(".drawer__title");if(t)t.textContent=l.title;else if(l.title){const t=e("div",{className:"drawer__header"}),n=e("h3",{className:"drawer__title",textContent:l.title});t.appendChild(n);const s=f.querySelector(".drawer");null==s||s.insertBefore(t,s.firstChild)}}if(void 0!==l.content){const e=f.querySelector(".drawer__body");e&&(e.textContent=l.content)}const n=f.querySelector(".drawer");if(n){const e=l.placement||t.placement||"right";void 0===l.width||"left"!==e&&"right"!==e||(n.style.width="number"==typeof l.width?`${l.width}px`:l.width),void 0===l.height||"top"!==e&&"bottom"!==e||(n.style.height="number"==typeof l.height?`${l.height}px`:l.height)}if(void 0!==l.className&&n){const e=t.placement||"right";n.className=`drawer drawer--${e} ${l.className}`.trim()}if(void 0!==l.style&&n&&Object.assign(n.style,l.style),void 0!==l.bodyStyle){const e=f.querySelector(".drawer__body");e&&Object.assign(e.style,l.bodyStyle)}}}},config:function(e){Object.assign(o,e)},destroy:async function(){const e=[...i].reverse();for(const t of e)await c(t.id)}};export{m as Drawer};
1
+ import{createElement as e,addClosingAnimation as t,ANIMATION_DURATION as n,injectStyle as l,generateId as s}from"../utils.js";import o from"./style.css.js";const i={width:378,height:378,mask:!0,maskClosable:!0,closable:!0},a=[],d=new Set;let r=null;async function c(e){var l;if(!d.has(e)){d.add(e);try{const s=a.findIndex(t=>t.id===e);if(-1===s)return;const o=a[s],i=o.element.querySelector(".drawer-mask"),d=o.element.querySelector(".drawer");i&&i.classList.add("is-closing"),d&&d.classList.add("is-closing"),await t(o.element,n.NORMAL),null==(l=o.cleanup)||l.call(o);const r=a.findIndex(t=>t.id===e);-1!==r&&(a[r].element.remove(),a.splice(r,1)),0===a.length&&document.body.classList.remove("solely-drawer-open")}finally{d.delete(e)}}}const m={open:function(t){const n=s();l("solely-drawer-styles",o);const d=t.placement||"right",m=t.width??i.width,h=t.height??i.height,p=t.mask??i.mask,u=t.maskClosable??i.maskClosable,y=t.closable??i.closable,f=e("div",{className:"drawer-wrap"}),b=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),r||(r=new MutationObserver(()=>{a.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{r&&0===a.length&&(r.disconnect(),r=null)}}(f),w=[];if(!1!==p){const l=e("div",{className:"drawer-mask"});if(u){const e=()=>{var e;c(n),null==(e=t.onClose)||e.call(t)};l.addEventListener("click",e),w.push({element:l,type:"click",handler:e})}f.appendChild(l)}const g=e("div",{className:`drawer drawer--${d}${t.className?` ${t.className}`:""}`,styles:t.style});if("left"===d||"right"===d?g.style.width="number"==typeof m?`${m}px`:m:g.style.height="number"==typeof h?`${h}px`:h,t.title||!1!==y){const l=e("div",{className:"drawer__header"});if(t.title){const n=e("h3",{className:"drawer__title"});"string"==typeof t.title?n.textContent=t.title:t.title instanceof HTMLElement&&n.appendChild(t.title.cloneNode(!0)),l.appendChild(n)}if(!1!==y){const s=e("button",{className:"drawer__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),o=()=>{var e;c(n),null==(e=t.onClose)||e.call(t)};s.addEventListener("click",o),w.push({element:s,type:"click",handler:o}),l.appendChild(s)}g.appendChild(l)}const v=e("div",{className:"drawer__body",styles:t.bodyStyle});return"string"==typeof t.content?v.textContent=t.content||"":t.content instanceof HTMLElement&&v.appendChild(t.content.cloneNode(!0)),g.appendChild(v),f.appendChild(g),document.body.appendChild(f),document.body.classList.add("solely-drawer-open"),a.push({id:n,element:f,options:t,cleanup:()=>{w.forEach(({element:e,type:t,handler:n})=>{e.removeEventListener(t,n)}),b()}}),{close:()=>{var e;c(n),null==(e=t.onClose)||e.call(t)},update:n=>{if(void 0!==n.title){const t=f.querySelector(".drawer__title");if(t)t.innerHTML="","string"==typeof n.title?t.textContent=n.title:n.title instanceof HTMLElement&&t.appendChild(n.title.cloneNode(!0));else if(n.title){const t=e("div",{className:"drawer__header"}),l=e("h3",{className:"drawer__title"});"string"==typeof n.title?l.textContent=n.title:n.title instanceof HTMLElement&&l.appendChild(n.title.cloneNode(!0)),t.appendChild(l);const s=f.querySelector(".drawer");null==s||s.insertBefore(t,s.firstChild)}}if(void 0!==n.content){const e=f.querySelector(".drawer__body");e&&(e.innerHTML="","string"==typeof n.content?e.textContent=n.content:n.content instanceof HTMLElement&&e.appendChild(n.content.cloneNode(!0)))}const l=f.querySelector(".drawer");if(l){const e=n.placement||t.placement||"right";void 0===n.width||"left"!==e&&"right"!==e||(l.style.width="number"==typeof n.width?`${n.width}px`:n.width),void 0===n.height||"top"!==e&&"bottom"!==e||(l.style.height="number"==typeof n.height?`${n.height}px`:n.height)}if(void 0!==n.className&&l){const e=t.placement||"right";l.className=`drawer drawer--${e} ${n.className}`.trim()}if(void 0!==n.style&&l&&Object.assign(l.style,n.style),void 0!==n.bodyStyle){const e=f.querySelector(".drawer__body");e&&Object.assign(e.style,n.bodyStyle)}}}},config:function(e){Object.assign(i,e)},destroy:async function(){const e=[...a].reverse();for(const t of e)await c(t.id)}};export{m as Drawer};
@@ -4,9 +4,9 @@
4
4
  export type DrawerPlacement = 'left' | 'right' | 'top' | 'bottom';
5
5
  export interface DrawerOptions {
6
6
  /** 标题 */
7
- title?: string;
7
+ title?: string | HTMLElement;
8
8
  /** 内容 */
9
- content?: string;
9
+ content?: string | HTMLElement;
10
10
  /** 抽屉方向 */
11
11
  placement?: DrawerPlacement;
12
12
  /** 宽度(placement为left或right时有效) */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={duration:3e3,maxCount:5,gap:8,top:24};let o,s=null,i=null;const a=new Set,r=[],c={info:"ℹ",success:"✓",warning:"⚠",error:"✕",loading:e.createElement("span",{className:"message__loading-spinner"})};function l(t,n){const o=e.createElement("span",{className:`message__icon message__icon--${n}`});return"string"==typeof t?o.textContent=t:o.appendChild(t.cloneNode(!0)),o}async function d(t){var n;if(!a.has(t)){a.add(t);try{const a=r.findIndex(e=>e.id===t);if(-1===a)return;const l=r[a];l.timer&&(clearTimeout(l.timer),l.timer=void 0),await e.addClosingAnimation(l.element,e.ANIMATION_DURATION.NORMAL),l.element.remove();const d=r.findIndex(e=>e.id===t);-1!==d&&r.splice(d,1);try{null==(n=l.onClose)||n.call(l)}catch(c){console.error("[Solely Message] onClose callback error:",c)}o&&clearTimeout(o),o=window.setTimeout(()=>{0===r.length&&s&&(i&&(i.disconnect(),i=null),s.remove(),s=null),o=void 0},300)}finally{a.delete(t)}}}function u(o){const a=e.generateId(),u=function(){if(!s){s=e.createElement("div",{className:"message-container",styles:{top:`${n.top}px`}});const a=document.documentElement.getAttribute("data-theme");a&&s.setAttribute("data-theme",a),document.body.appendChild(s),e.injectStyle("solely-message-styles",t.default),o=s,i&&i.disconnect(),i=new MutationObserver(()=>{const e=document.documentElement.getAttribute("data-theme");e?o.setAttribute("data-theme",e):o.removeAttribute("data-theme")}),i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}var o;return s}();r.length>=n.maxCount&&d(r[0].id);const m=function(t,n){const o=t.type||"info",s=!1!==t.showIcon,i=e.createElement("div",{className:`message message--${o}${t.className?` ${t.className}`:""}`,styles:t.style});if(i.setAttribute("role","error"===o||"warning"===o?"alert":"status"),i.setAttribute("aria-live","error"===o||"warning"===o?"assertive":"polite"),s){const e=t.icon?l(t.icon,o):l(c[o],o);i.appendChild(e)}const a=e.createElement("span",{className:"message__content"}),r=e.createElement("span",{className:"message__text",textContent:t.content});if(a.appendChild(r),t.description){const n=e.createElement("span",{className:"message__description",textContent:t.description});a.appendChild(n)}if(i.appendChild(a),t.closable){const t=e.createElement("button",{className:"message__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}});t.onclick=()=>d(n),i.appendChild(t)}return i}(o,a);u.appendChild(m);const p={id:a,element:m,onClose:o.onClose},g=o.duration??n.duration;return g>0&&(p.timer=window.setTimeout(()=>{d(a)},g)),r.push(p),{close:()=>d(a),update:t=>{if("string"==typeof t){const e=m.querySelector(".message__text");return void(e&&(e.textContent=t))}if(void 0!==t.content){const e=m.querySelector(".message__text");e&&(e.textContent=t.content)}if(void 0!==t.description){let n=m.querySelector(".message__description");if(!n&&t.description){n=e.createElement("span",{className:"message__description",textContent:t.description});const o=m.querySelector(".message__content");null==o||o.appendChild(n)}else n&&(t.description?n.textContent=t.description:n.remove())}}}}const m={open:u,info:function(e,t){return u({content:e,type:"info",..."number"==typeof t?{duration:t}:t})},success:function(e,t){return u({content:e,type:"success",..."number"==typeof t?{duration:t}:t})},warning:function(e,t){return u({content:e,type:"warning",..."number"==typeof t?{duration:t}:t})},error:function(e,t){return u({content:e,type:"error",..."number"==typeof t?{duration:t}:t})},loading:function(e,t){return u(void 0===t?{content:e,type:"loading",duration:0,closable:!0}:"number"==typeof t?{content:e,type:"loading",duration:t,closable:!0}:{content:e,type:"loading",duration:0,closable:!0,...t})},config:function(e){Object.assign(n,e),void 0!==e.top&&s&&(s.style.top=`${e.top}px`)},destroy:async function(){o&&(clearTimeout(o),o=void 0);const e=[...r];await Promise.all(e.map(e=>d(e.id)))}};exports.Message=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={duration:3e3,maxCount:5,gap:8,top:24};let o,i=null,s=null;const c=new Set,r=[],a={info:"ℹ",success:"✓",warning:"⚠",error:"✕",loading:e.createElement("span",{className:"message__loading-spinner"})};function l(t,n){const o=e.createElement("span",{className:`message__icon message__icon--${n}`});return"string"==typeof t?o.textContent=t:o.appendChild(t.cloneNode(!0)),o}async function d(t){var n;if(!c.has(t)){c.add(t);try{const c=r.findIndex(e=>e.id===t);if(-1===c)return;const l=r[c];l.timer&&(clearTimeout(l.timer),l.timer=void 0),await e.addClosingAnimation(l.element,e.ANIMATION_DURATION.NORMAL),l.element.remove();const d=r.findIndex(e=>e.id===t);-1!==d&&r.splice(d,1);try{null==(n=l.onClose)||n.call(l)}catch(a){console.error("[Solely Message] onClose callback error:",a)}o&&clearTimeout(o),o=window.setTimeout(()=>{0===r.length&&i&&(s&&(s.disconnect(),s=null),i.remove(),i=null),o=void 0},300)}finally{c.delete(t)}}}function p(o){const c=e.generateId(),p=function(){if(!i){i=e.createElement("div",{className:"message-container",styles:{top:`${n.top}px`}});const c=document.documentElement.getAttribute("data-theme");c&&i.setAttribute("data-theme",c),document.body.appendChild(i),e.injectStyle("solely-message-styles",t.default),o=i,s&&s.disconnect(),s=new MutationObserver(()=>{const e=document.documentElement.getAttribute("data-theme");e?o.setAttribute("data-theme",e):o.removeAttribute("data-theme")}),s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}var o;return i}();r.length>=n.maxCount&&d(r[0].id);const u=function(t,n){const o=t.type||"info",i=!1!==t.showIcon,s=e.createElement("div",{className:`message message--${o}${t.className?` ${t.className}`:""}`,styles:t.style});if(s.setAttribute("role","error"===o||"warning"===o?"alert":"status"),s.setAttribute("aria-live","error"===o||"warning"===o?"assertive":"polite"),i){const e=t.icon?l(t.icon,o):l(a[o],o);s.appendChild(e)}const c=e.createElement("span",{className:"message__content"}),r=e.createElement("span",{className:"message__text"});if("string"==typeof t.content?r.textContent=t.content:t.content instanceof HTMLElement&&r.appendChild(t.content.cloneNode(!0)),c.appendChild(r),t.description){const n=e.createElement("span",{className:"message__description"});"string"==typeof t.description?n.textContent=t.description:t.description instanceof HTMLElement&&n.appendChild(t.description.cloneNode(!0)),c.appendChild(n)}if(s.appendChild(c),t.closable){const t=e.createElement("button",{className:"message__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}});t.onclick=()=>d(n),s.appendChild(t)}return s}(o,c);p.appendChild(u);const m={id:c,element:u,onClose:o.onClose},f=o.duration??n.duration;return f>0&&(m.timer=window.setTimeout(()=>{d(c)},f)),r.push(m),{close:()=>d(c),update:t=>{if("string"==typeof t||t instanceof HTMLElement){const e=u.querySelector(".message__text");return void(e&&(e.innerHTML="","string"==typeof t?e.textContent=t:t instanceof HTMLElement&&e.appendChild(t.cloneNode(!0))))}if(void 0!==t.content){const e=u.querySelector(".message__text");e&&(e.innerHTML="","string"==typeof t.content?e.textContent=t.content:t.content instanceof HTMLElement&&e.appendChild(t.content.cloneNode(!0)))}if(void 0!==t.description){let n=u.querySelector(".message__description");if(!n&&t.description){n=e.createElement("span",{className:"message__description"}),"string"==typeof t.description?n.textContent=t.description:t.description instanceof HTMLElement&&n.appendChild(t.description.cloneNode(!0));const o=u.querySelector(".message__content");null==o||o.appendChild(n)}else n&&(t.description?(n.innerHTML="","string"==typeof t.description?n.textContent=t.description:t.description instanceof HTMLElement&&n.appendChild(t.description.cloneNode(!0))):n.remove())}}}}const u={open:p,info:function(e,t){return p({content:e,type:"info",..."number"==typeof t?{duration:t}:t})},success:function(e,t){return p({content:e,type:"success",..."number"==typeof t?{duration:t}:t})},warning:function(e,t){return p({content:e,type:"warning",..."number"==typeof t?{duration:t}:t})},error:function(e,t){return p({content:e,type:"error",..."number"==typeof t?{duration:t}:t})},loading:function(e,t){return p(void 0===t?{content:e,type:"loading",duration:0,closable:!0}:"number"==typeof t?{content:e,type:"loading",duration:t,closable:!0}:{content:e,type:"loading",duration:0,closable:!0,...t})},config:function(e){Object.assign(n,e),void 0!==e.top&&i&&(i.style.top=`${e.top}px`)},destroy:async function(){o&&(clearTimeout(o),o=void 0);const e=[...r];await Promise.all(e.map(e=>d(e.id)))}};exports.Message=u;
@@ -1,10 +1,10 @@
1
1
  import { MessageOptions, MessageInstance, MessageConfig } from './types';
2
2
  declare function open(options: MessageOptions): MessageInstance;
3
- declare function info(content: string, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
4
- declare function success(content: string, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
5
- declare function warning(content: string, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
6
- declare function error(content: string, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
7
- declare function loading(content: string, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
3
+ declare function info(content: string | HTMLElement, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
4
+ declare function success(content: string | HTMLElement, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
5
+ declare function warning(content: string | HTMLElement, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
6
+ declare function error(content: string | HTMLElement, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
7
+ declare function loading(content: string | HTMLElement, options?: number | Partial<Omit<MessageOptions, 'content' | 'type'>>): MessageInstance;
8
8
  declare function config(options: Partial<MessageConfig>): void;
9
9
  declare function destroy(): Promise<void>;
10
10
  export declare const Message: {
@@ -1 +1 @@
1
- import{createElement as e,addClosingAnimation as t,ANIMATION_DURATION as n,generateId as o,injectStyle as s}from"../utils.js";import i from"./style.css.js";const a={duration:3e3,maxCount:5,gap:8,top:24};let r,c=null,l=null;const d=new Set,u=[],m={info:"ℹ",success:"✓",warning:"⚠",error:"✕",loading:e("span",{className:"message__loading-spinner"})};function p(t,n){const o=e("span",{className:`message__icon message__icon--${n}`});return"string"==typeof t?o.textContent=t:o.appendChild(t.cloneNode(!0)),o}async function f(e){var o;if(!d.has(e)){d.add(e);try{const i=u.findIndex(t=>t.id===e);if(-1===i)return;const a=u[i];a.timer&&(clearTimeout(a.timer),a.timer=void 0),await t(a.element,n.NORMAL),a.element.remove();const d=u.findIndex(t=>t.id===e);-1!==d&&u.splice(d,1);try{null==(o=a.onClose)||o.call(a)}catch(s){console.error("[Solely Message] onClose callback error:",s)}r&&clearTimeout(r),r=window.setTimeout(()=>{0===u.length&&c&&(l&&(l.disconnect(),l=null),c.remove(),c=null),r=void 0},300)}finally{d.delete(e)}}}function g(t){const n=o(),r=function(){if(!c){c=e("div",{className:"message-container",styles:{top:`${a.top}px`}});const n=document.documentElement.getAttribute("data-theme");n&&c.setAttribute("data-theme",n),document.body.appendChild(c),s("solely-message-styles",i),t=c,l&&l.disconnect(),l=new MutationObserver(()=>{const e=document.documentElement.getAttribute("data-theme");e?t.setAttribute("data-theme",e):t.removeAttribute("data-theme")}),l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}var t;return c}();u.length>=a.maxCount&&f(u[0].id);const d=function(t,n){const o=t.type||"info",s=!1!==t.showIcon,i=e("div",{className:`message message--${o}${t.className?` ${t.className}`:""}`,styles:t.style});if(i.setAttribute("role","error"===o||"warning"===o?"alert":"status"),i.setAttribute("aria-live","error"===o||"warning"===o?"assertive":"polite"),s){const e=t.icon?p(t.icon,o):p(m[o],o);i.appendChild(e)}const a=e("span",{className:"message__content"}),r=e("span",{className:"message__text",textContent:t.content});if(a.appendChild(r),t.description){const n=e("span",{className:"message__description",textContent:t.description});a.appendChild(n)}if(i.appendChild(a),t.closable){const t=e("button",{className:"message__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}});t.onclick=()=>f(n),i.appendChild(t)}return i}(t,n);r.appendChild(d);const g={id:n,element:d,onClose:t.onClose},y=t.duration??a.duration;return y>0&&(g.timer=window.setTimeout(()=>{f(n)},y)),u.push(g),{close:()=>f(n),update:t=>{if("string"==typeof t){const e=d.querySelector(".message__text");return void(e&&(e.textContent=t))}if(void 0!==t.content){const e=d.querySelector(".message__text");e&&(e.textContent=t.content)}if(void 0!==t.description){let n=d.querySelector(".message__description");if(!n&&t.description){n=e("span",{className:"message__description",textContent:t.description});const o=d.querySelector(".message__content");null==o||o.appendChild(n)}else n&&(t.description?n.textContent=t.description:n.remove())}}}}const y={open:g,info:function(e,t){return g({content:e,type:"info",..."number"==typeof t?{duration:t}:t})},success:function(e,t){return g({content:e,type:"success",..."number"==typeof t?{duration:t}:t})},warning:function(e,t){return g({content:e,type:"warning",..."number"==typeof t?{duration:t}:t})},error:function(e,t){return g({content:e,type:"error",..."number"==typeof t?{duration:t}:t})},loading:function(e,t){return g(void 0===t?{content:e,type:"loading",duration:0,closable:!0}:"number"==typeof t?{content:e,type:"loading",duration:t,closable:!0}:{content:e,type:"loading",duration:0,closable:!0,...t})},config:function(e){Object.assign(a,e),void 0!==e.top&&c&&(c.style.top=`${e.top}px`)},destroy:async function(){r&&(clearTimeout(r),r=void 0);const e=[...u];await Promise.all(e.map(e=>f(e.id)))}};export{y as Message};
1
+ import{createElement as e,addClosingAnimation as t,ANIMATION_DURATION as n,generateId as o,injectStyle as i}from"../utils.js";import s from"./style.css.js";const c={duration:3e3,maxCount:5,gap:8,top:24};let r,a=null,l=null;const d=new Set,p=[],u={info:"ℹ",success:"✓",warning:"⚠",error:"✕",loading:e("span",{className:"message__loading-spinner"})};function m(t,n){const o=e("span",{className:`message__icon message__icon--${n}`});return"string"==typeof t?o.textContent=t:o.appendChild(t.cloneNode(!0)),o}async function f(e){var o;if(!d.has(e)){d.add(e);try{const s=p.findIndex(t=>t.id===e);if(-1===s)return;const c=p[s];c.timer&&(clearTimeout(c.timer),c.timer=void 0),await t(c.element,n.NORMAL),c.element.remove();const d=p.findIndex(t=>t.id===e);-1!==d&&p.splice(d,1);try{null==(o=c.onClose)||o.call(c)}catch(i){console.error("[Solely Message] onClose callback error:",i)}r&&clearTimeout(r),r=window.setTimeout(()=>{0===p.length&&a&&(l&&(l.disconnect(),l=null),a.remove(),a=null),r=void 0},300)}finally{d.delete(e)}}}function g(t){const n=o(),r=function(){if(!a){a=e("div",{className:"message-container",styles:{top:`${c.top}px`}});const n=document.documentElement.getAttribute("data-theme");n&&a.setAttribute("data-theme",n),document.body.appendChild(a),i("solely-message-styles",s),t=a,l&&l.disconnect(),l=new MutationObserver(()=>{const e=document.documentElement.getAttribute("data-theme");e?t.setAttribute("data-theme",e):t.removeAttribute("data-theme")}),l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}var t;return a}();p.length>=c.maxCount&&f(p[0].id);const d=function(t,n){const o=t.type||"info",i=!1!==t.showIcon,s=e("div",{className:`message message--${o}${t.className?` ${t.className}`:""}`,styles:t.style});if(s.setAttribute("role","error"===o||"warning"===o?"alert":"status"),s.setAttribute("aria-live","error"===o||"warning"===o?"assertive":"polite"),i){const e=t.icon?m(t.icon,o):m(u[o],o);s.appendChild(e)}const c=e("span",{className:"message__content"}),r=e("span",{className:"message__text"});if("string"==typeof t.content?r.textContent=t.content:t.content instanceof HTMLElement&&r.appendChild(t.content.cloneNode(!0)),c.appendChild(r),t.description){const n=e("span",{className:"message__description"});"string"==typeof t.description?n.textContent=t.description:t.description instanceof HTMLElement&&n.appendChild(t.description.cloneNode(!0)),c.appendChild(n)}if(s.appendChild(c),t.closable){const t=e("button",{className:"message__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}});t.onclick=()=>f(n),s.appendChild(t)}return s}(t,n);r.appendChild(d);const g={id:n,element:d,onClose:t.onClose},y=t.duration??c.duration;return y>0&&(g.timer=window.setTimeout(()=>{f(n)},y)),p.push(g),{close:()=>f(n),update:t=>{if("string"==typeof t||t instanceof HTMLElement){const e=d.querySelector(".message__text");return void(e&&(e.innerHTML="","string"==typeof t?e.textContent=t:t instanceof HTMLElement&&e.appendChild(t.cloneNode(!0))))}if(void 0!==t.content){const e=d.querySelector(".message__text");e&&(e.innerHTML="","string"==typeof t.content?e.textContent=t.content:t.content instanceof HTMLElement&&e.appendChild(t.content.cloneNode(!0)))}if(void 0!==t.description){let n=d.querySelector(".message__description");if(!n&&t.description){n=e("span",{className:"message__description"}),"string"==typeof t.description?n.textContent=t.description:t.description instanceof HTMLElement&&n.appendChild(t.description.cloneNode(!0));const o=d.querySelector(".message__content");null==o||o.appendChild(n)}else n&&(t.description?(n.innerHTML="","string"==typeof t.description?n.textContent=t.description:t.description instanceof HTMLElement&&n.appendChild(t.description.cloneNode(!0))):n.remove())}}}}const y={open:g,info:function(e,t){return g({content:e,type:"info",..."number"==typeof t?{duration:t}:t})},success:function(e,t){return g({content:e,type:"success",..."number"==typeof t?{duration:t}:t})},warning:function(e,t){return g({content:e,type:"warning",..."number"==typeof t?{duration:t}:t})},error:function(e,t){return g({content:e,type:"error",..."number"==typeof t?{duration:t}:t})},loading:function(e,t){return g(void 0===t?{content:e,type:"loading",duration:0,closable:!0}:"number"==typeof t?{content:e,type:"loading",duration:t,closable:!0}:{content:e,type:"loading",duration:0,closable:!0,...t})},config:function(e){Object.assign(c,e),void 0!==e.top&&a&&(a.style.top=`${e.top}px`)},destroy:async function(){r&&(clearTimeout(r),r=void 0);const e=[...p];await Promise.all(e.map(e=>f(e.id)))}};export{y as Message};
@@ -1,7 +1,7 @@
1
1
  export type MessageType = 'info' | 'success' | 'warning' | 'error' | 'loading';
2
2
  export interface MessageOptions {
3
3
  /** 消息内容 */
4
- content: string;
4
+ content?: string | HTMLElement;
5
5
  /** 消息类型,默认 'info' */
6
6
  type?: MessageType;
7
7
  /** 自动关闭延时(毫秒),设为 0 则不自动关闭,默认 3000 */
@@ -13,7 +13,7 @@ export interface MessageOptions {
13
13
  /** 自定义图标(字符串或 DOM 元素) */
14
14
  icon?: string | HTMLElement;
15
15
  /** 辅助描述文本 */
16
- description?: string;
16
+ description?: string | HTMLElement;
17
17
  /** 自定义类名 */
18
18
  className?: string;
19
19
  /** 自定义样式 */
@@ -25,7 +25,7 @@ export interface MessageInstance {
25
25
  /** 手动关闭当前消息 */
26
26
  close: () => void;
27
27
  /** 更新消息内容或描述 */
28
- update: (content: string | Partial<Pick<MessageOptions, 'content' | 'description'>>) => void;
28
+ update: (content: string | HTMLElement | Partial<Pick<MessageOptions, 'content' | 'description'>>) => void;
29
29
  }
30
30
  export interface MessageConfig {
31
31
  /** 默认自动关闭延时 */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={width:520,mask:!0,maskClosable:!1,okText:"确定",cancelText:"取消"},a=[],l=new Set;let o=null;const c={info:"ℹ",success:"✓",warning:"⚠",error:"✕",confirm:"?"};async function s(t){var n;if(!l.has(t)){l.add(t);try{const l=a.findIndex(e=>e.id===t);if(-1===l)return;const o=a[l],c=o.element.querySelector(".modal-mask"),s=o.element.querySelector(".modal");c&&c.classList.add("is-closing"),s&&s.classList.add("is-closing"),await e.addClosingAnimation(o.element,e.ANIMATION_DURATION.NORMAL),null==(n=o.cleanup)||n.call(o);const i=a.findIndex(e=>e.id===t);-1!==i&&(a[i].element.remove(),a.splice(i,1))}finally{l.delete(t)}}}async function i(){if(0===a.length)return;const e=a[a.length-1];await s(e.id)}function d(t,n,a){const l=e.createElement("button",{className:`modal__btn modal__btn--${"default"===n?"default":n}`,textContent:t,attrs:{type:"button"}});return l.onclick=()=>e.safeAsyncCallback(a),l}function r(l){const i=e.generateId();e.injectStyle("solely-modal-styles",t.default);const r=l.type||"info",m=l.width??n.width,u=l.showCancel??"confirm"===r,p=l.maskClosable??n.maskClosable,f=e.createElement("div",{className:"modal-wrap",attrs:{tabIndex:"-1"}}),y=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),o||(o=new MutationObserver(()=>{a.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{o&&0===a.length&&(o.disconnect(),o=null)}}(f),h=[];if(!1!==l.mask){const t=e.createElement("div",{className:"modal-mask"});if(p){const e=()=>{var e;s(i),null==(e=l.onCancel)||e.call(l)};t.onclick=e,h.push({element:t,type:"click",handler:e})}f.appendChild(t)}const b=e.createElement("div",{className:"modal"+(l.className?` ${l.className}`:""),styles:{...l.style,width:"number"==typeof m?`${m}px`:m}}),C=e.createElement("div",{className:"modal__header"}),v=e.createElement("h3",{className:"modal__title",textContent:l.title||""});if(C.appendChild(v),!1!==l.closable){const t=e.createElement("button",{className:"modal__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),n=()=>{var e;s(i),null==(e=l.onClose)||e.call(l)};t.onclick=n,h.push({element:t,type:"click",handler:n}),C.appendChild(t)}b.appendChild(C);const _=e.createElement("div",{className:"modal__body"}),w=e.createElement("div",{className:"modal__content-wrapper"}),k=e.createElement("span",{className:`modal__icon modal__icon--${r}`,textContent:c[r]});w.appendChild(k);const x=e.createElement("div",{textContent:l.content||""});w.appendChild(x),_.appendChild(w),b.appendChild(_);const g=e.createElement("div",{className:"modal__footer"});if(l.buttons&&l.buttons.length>0)l.buttons.forEach(t=>{const n=d(t.text,t.type||"default",async()=>{await e.safeAsyncCallback(()=>t.onClick())});t.style&&Object.assign(n.style,t.style),g.appendChild(n)});else{if(u){const e=d(l.cancelText||n.cancelText,"default",()=>{var e;s(i),null==(e=l.onCancel)||e.call(l)});g.appendChild(e)}const t=d(l.okText||n.okText,l.okType||"primary",async()=>{l.onOk&&!1===await e.safeAsyncCallback(()=>l.onOk())||s(i)});g.appendChild(t)}b.appendChild(g),f.appendChild(b),document.body.appendChild(f),a.push({id:i,element:f,instance:null,cleanup:()=>{h.forEach(({element:e,type:t,handler:n})=>{e.removeEventListener(t,n)}),y()}});const N={close:()=>{var e;s(i),null==(e=l.onClose)||e.call(l)},update:e=>{if(void 0!==e.title){const t=f.querySelector(".modal__title");t&&(t.textContent=e.title)}if(void 0!==e.content){const t=f.querySelector(".modal__content");t&&(t.textContent=e.content)}if(void 0!==e.width){const t=f.querySelector(".modal");t&&(t.style.width="number"==typeof e.width?`${e.width}px`:e.width)}if(void 0!==e.className){const t=f.querySelector(".modal");t&&(t.className=`modal ${e.className}`.trim())}if(void 0!==e.style){const t=f.querySelector(".modal");t&&Object.assign(t.style,e.style)}}},E=a.find(e=>e.id===i);return E&&(E.instance=N),N}const m={open:r,confirm:function(e){return r({...e,type:"confirm",showCancel:!0})},info:function(e){return r({...e,type:"info"})},success:function(e){return r({...e,type:"success"})},error:function(e){return r({...e,type:"error"})},warning:function(e){return r({...e,type:"warning"})},config:function(e){Object.assign(n,e)},destroy:async function(){for(;a.length>0;)await i()}};exports.Modal=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={width:520,mask:!0,maskClosable:!1,okText:"确定",cancelText:"取消"},l=[],a=new Set;let o=null;const c={info:"ℹ",success:"✓",warning:"⚠",error:"✕",confirm:"?"};async function s(t){var n;if(!a.has(t)){a.add(t);try{const a=l.findIndex(e=>e.id===t);if(-1===a)return;const o=l[a],c=o.element.querySelector(".modal-mask"),s=o.element.querySelector(".modal");c&&c.classList.add("is-closing"),s&&s.classList.add("is-closing"),await e.addClosingAnimation(o.element,e.ANIMATION_DURATION.NORMAL),null==(n=o.cleanup)||n.call(o);const i=l.findIndex(e=>e.id===t);-1!==i&&(l[i].element.remove(),l.splice(i,1))}finally{a.delete(t)}}}async function i(){if(0===l.length)return;const e=l[l.length-1];await s(e.id)}function d(t,n,l){const a=e.createElement("button",{className:`modal__btn modal__btn--${"default"===n?"default":n}`,attrs:{type:"button"}});return"string"==typeof t?a.textContent=t:t instanceof HTMLElement&&a.appendChild(t.cloneNode(!0)),a.onclick=()=>e.safeAsyncCallback(l),a}function r(a){const i=e.generateId();e.injectStyle("solely-modal-styles",t.default);const r=a.type||"info",m=a.width??n.width,u=a.showCancel??"confirm"===r,p=a.maskClosable??n.maskClosable,f=e.createElement("div",{className:"modal-wrap",attrs:{tabIndex:"-1"}}),y=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),o||(o=new MutationObserver(()=>{l.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{o&&0===l.length&&(o.disconnect(),o=null)}}(f),h=[];if(!1!==a.mask){const t=e.createElement("div",{className:"modal-mask"});if(p){const e=()=>{var e;s(i),null==(e=a.onCancel)||e.call(a)};t.onclick=e,h.push({element:t,type:"click",handler:e})}f.appendChild(t)}const C=e.createElement("div",{className:"modal"+(a.className?` ${a.className}`:""),styles:{...a.style,width:"number"==typeof m?`${m}px`:m}}),b=e.createElement("div",{className:"modal__header"}),v=e.createElement("h3",{className:"modal__title"});if("string"==typeof a.title?v.textContent=a.title||"":a.title instanceof HTMLElement&&v.appendChild(a.title.cloneNode(!0)),b.appendChild(v),!1!==a.closable){const t=e.createElement("button",{className:"modal__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),n=()=>{var e;s(i),null==(e=a.onClose)||e.call(a)};t.onclick=n,h.push({element:t,type:"click",handler:n}),b.appendChild(t)}C.appendChild(b);const g=e.createElement("div",{className:"modal__body"}),N=e.createElement("div",{className:"modal__content-wrapper"});if(!1!==a.showIcon){const t=e.createElement("span",{className:`modal__icon modal__icon--${r}`,textContent:c[r]});N.appendChild(t)}const _=e.createElement("div");"string"==typeof a.content?_.textContent=a.content||"":a.content instanceof HTMLElement&&_.appendChild(a.content.cloneNode(!0)),N.appendChild(_),g.appendChild(N),C.appendChild(g);const w=e.createElement("div",{className:"modal__footer"});if(a.buttons&&a.buttons.length>0)a.buttons.forEach(t=>{const n=d(t.text,t.type||"default",async()=>{await e.safeAsyncCallback(()=>t.onClick())});t.style&&Object.assign(n.style,t.style),w.appendChild(n)});else{if(u){const e=d(a.cancelText||n.cancelText,"default",()=>{var e;s(i),null==(e=a.onCancel)||e.call(a)});w.appendChild(e)}const t=d(a.okText||n.okText,a.okType||"primary",async()=>{a.onOk&&!1===await e.safeAsyncCallback(()=>a.onOk())||s(i)});w.appendChild(t)}C.appendChild(w),f.appendChild(C),document.body.appendChild(f),l.push({id:i,element:f,instance:null,cleanup:()=>{h.forEach(({element:e,type:t,handler:n})=>{e.removeEventListener(t,n)}),y()}});const E={close:()=>{var e;s(i),null==(e=a.onClose)||e.call(a)},update:e=>{if(void 0!==e.title){const t=f.querySelector(".modal__title");t&&(t.innerHTML="","string"==typeof e.title?t.textContent=e.title:e.title instanceof HTMLElement&&t.appendChild(e.title.cloneNode(!0)))}if(void 0!==e.content){const t=f.querySelector(".modal__content");t&&(t.innerHTML="","string"==typeof e.content?t.textContent=e.content:e.content instanceof HTMLElement&&t.appendChild(e.content.cloneNode(!0)))}if(void 0!==e.width){const t=f.querySelector(".modal");t&&(t.style.width="number"==typeof e.width?`${e.width}px`:e.width)}if(void 0!==e.className){const t=f.querySelector(".modal");t&&(t.className=`modal ${e.className}`.trim())}if(void 0!==e.style){const t=f.querySelector(".modal");t&&Object.assign(t.style,e.style)}}},k=l.find(e=>e.id===i);return k&&(k.instance=E),E}const m={open:r,confirm:function(e){return r({...e,type:"confirm",showCancel:!0})},info:function(e){return r({...e,type:"info"})},success:function(e){return r({...e,type:"success"})},error:function(e){return r({...e,type:"error"})},warning:function(e){return r({...e,type:"warning"})},config:function(e){Object.assign(n,e)},destroy:async function(){for(;l.length>0;)await i()}};exports.Modal=m;
@@ -1 +1 @@
1
- import{createElement as t,injectStyle as e,safeAsyncCallback as n,generateId as l,addClosingAnimation as a,ANIMATION_DURATION as o}from"../utils.js";import s from"./style.css.js";const c={width:520,mask:!0,maskClosable:!1,okText:"确定",cancelText:"取消"},i=[],d=new Set;let r=null;const m={info:"ℹ",success:"✓",warning:"⚠",error:"✕",confirm:"?"};async function u(t){var e;if(!d.has(t)){d.add(t);try{const n=i.findIndex(e=>e.id===t);if(-1===n)return;const l=i[n],s=l.element.querySelector(".modal-mask"),c=l.element.querySelector(".modal");s&&s.classList.add("is-closing"),c&&c.classList.add("is-closing"),await a(l.element,o.NORMAL),null==(e=l.cleanup)||e.call(l);const d=i.findIndex(e=>e.id===t);-1!==d&&(i[d].element.remove(),i.splice(d,1))}finally{d.delete(t)}}}async function p(){if(0===i.length)return;const t=i[i.length-1];await u(t.id)}function f(e,l,a){const o=t("button",{className:`modal__btn modal__btn--${"default"===l?"default":l}`,textContent:e,attrs:{type:"button"}});return o.onclick=()=>n(a),o}function h(a){const o=l();e("solely-modal-styles",s);const d=a.type||"info",p=a.width??c.width,h=a.showCancel??"confirm"===d,y=a.maskClosable??c.maskClosable,b=t("div",{className:"modal-wrap",attrs:{tabIndex:"-1"}}),C=function(t){return(()=>{const e=document.documentElement.getAttribute("data-theme");e?t.setAttribute("data-theme",e):t.removeAttribute("data-theme")})(),r||(r=new MutationObserver(()=>{i.forEach(t=>{const e=document.documentElement.getAttribute("data-theme");e?t.element.setAttribute("data-theme",e):t.element.removeAttribute("data-theme")})}),r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{r&&0===i.length&&(r.disconnect(),r=null)}}(b),v=[];if(!1!==a.mask){const e=t("div",{className:"modal-mask"});if(y){const t=()=>{var t;u(o),null==(t=a.onCancel)||t.call(a)};e.onclick=t,v.push({element:e,type:"click",handler:t})}b.appendChild(e)}const _=t("div",{className:"modal"+(a.className?` ${a.className}`:""),styles:{...a.style,width:"number"==typeof p?`${p}px`:p}}),w=t("div",{className:"modal__header"}),x=t("h3",{className:"modal__title",textContent:a.title||""});if(w.appendChild(x),!1!==a.closable){const e=t("button",{className:"modal__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),n=()=>{var t;u(o),null==(t=a.onClose)||t.call(a)};e.onclick=n,v.push({element:e,type:"click",handler:n}),w.appendChild(e)}_.appendChild(w);const k=t("div",{className:"modal__body"}),N=t("div",{className:"modal__content-wrapper"}),g=t("span",{className:`modal__icon modal__icon--${d}`,textContent:m[d]});N.appendChild(g);const S=t("div",{textContent:a.content||""});N.appendChild(S),k.appendChild(N),_.appendChild(k);const q=t("div",{className:"modal__footer"});if(a.buttons&&a.buttons.length>0)a.buttons.forEach(t=>{const e=f(t.text,t.type||"default",async()=>{await n(()=>t.onClick())});t.style&&Object.assign(e.style,t.style),q.appendChild(e)});else{if(h){const t=f(a.cancelText||c.cancelText,"default",()=>{var t;u(o),null==(t=a.onCancel)||t.call(a)});q.appendChild(t)}const t=f(a.okText||c.okText,a.okType||"primary",async()=>{a.onOk&&!1===await n(()=>a.onOk())||u(o)});q.appendChild(t)}_.appendChild(q),b.appendChild(_),document.body.appendChild(b),i.push({id:o,element:b,instance:null,cleanup:()=>{v.forEach(({element:t,type:e,handler:n})=>{t.removeEventListener(e,n)}),C()}});const A={close:()=>{var t;u(o),null==(t=a.onClose)||t.call(a)},update:t=>{if(void 0!==t.title){const e=b.querySelector(".modal__title");e&&(e.textContent=t.title)}if(void 0!==t.content){const e=b.querySelector(".modal__content");e&&(e.textContent=t.content)}if(void 0!==t.width){const e=b.querySelector(".modal");e&&(e.style.width="number"==typeof t.width?`${t.width}px`:t.width)}if(void 0!==t.className){const e=b.querySelector(".modal");e&&(e.className=`modal ${t.className}`.trim())}if(void 0!==t.style){const e=b.querySelector(".modal");e&&Object.assign(e.style,t.style)}}},E=i.find(t=>t.id===o);return E&&(E.instance=A),A}const y={open:h,confirm:function(t){return h({...t,type:"confirm",showCancel:!0})},info:function(t){return h({...t,type:"info"})},success:function(t){return h({...t,type:"success"})},error:function(t){return h({...t,type:"error"})},warning:function(t){return h({...t,type:"warning"})},config:function(t){Object.assign(c,t)},destroy:async function(){for(;i.length>0;)await p()}};export{y as Modal};
1
+ import{createElement as e,injectStyle as t,safeAsyncCallback as n,generateId as o,addClosingAnimation as l,ANIMATION_DURATION as a}from"../utils.js";import s from"./style.css.js";const c={width:520,mask:!0,maskClosable:!1,okText:"确定",cancelText:"取消"},i=[],d=new Set;let r=null;const m={info:"ℹ",success:"✓",warning:"⚠",error:"✕",confirm:"?"};async function p(e){var t;if(!d.has(e)){d.add(e);try{const n=i.findIndex(t=>t.id===e);if(-1===n)return;const o=i[n],s=o.element.querySelector(".modal-mask"),c=o.element.querySelector(".modal");s&&s.classList.add("is-closing"),c&&c.classList.add("is-closing"),await l(o.element,a.NORMAL),null==(t=o.cleanup)||t.call(o);const d=i.findIndex(t=>t.id===e);-1!==d&&(i[d].element.remove(),i.splice(d,1))}finally{d.delete(e)}}}async function u(){if(0===i.length)return;const e=i[i.length-1];await p(e.id)}function f(t,o,l){const a=e("button",{className:`modal__btn modal__btn--${"default"===o?"default":o}`,attrs:{type:"button"}});return"string"==typeof t?a.textContent=t:t instanceof HTMLElement&&a.appendChild(t.cloneNode(!0)),a.onclick=()=>n(l),a}function h(l){const a=o();t("solely-modal-styles",s);const d=l.type||"info",u=l.width??c.width,h=l.showCancel??"confirm"===d,y=l.maskClosable??c.maskClosable,C=e("div",{className:"modal-wrap",attrs:{tabIndex:"-1"}}),b=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),r||(r=new MutationObserver(()=>{i.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{r&&0===i.length&&(r.disconnect(),r=null)}}(C),v=[];if(!1!==l.mask){const t=e("div",{className:"modal-mask"});if(y){const e=()=>{var e;p(a),null==(e=l.onCancel)||e.call(l)};t.onclick=e,v.push({element:t,type:"click",handler:e})}C.appendChild(t)}const w=e("div",{className:"modal"+(l.className?` ${l.className}`:""),styles:{...l.style,width:"number"==typeof u?`${u}px`:u}}),_=e("div",{className:"modal__header"}),N=e("h3",{className:"modal__title"});if("string"==typeof l.title?N.textContent=l.title||"":l.title instanceof HTMLElement&&N.appendChild(l.title.cloneNode(!0)),_.appendChild(N),!1!==l.closable){const t=e("button",{className:"modal__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}}),n=()=>{var e;p(a),null==(e=l.onClose)||e.call(l)};t.onclick=n,v.push({element:t,type:"click",handler:n}),_.appendChild(t)}w.appendChild(_);const g=e("div",{className:"modal__body"}),x=e("div",{className:"modal__content-wrapper"});if(!1!==l.showIcon){const t=e("span",{className:`modal__icon modal__icon--${d}`,textContent:m[d]});x.appendChild(t)}const k=e("div");"string"==typeof l.content?k.textContent=l.content||"":l.content instanceof HTMLElement&&k.appendChild(l.content.cloneNode(!0)),x.appendChild(k),g.appendChild(x),w.appendChild(g);const T=e("div",{className:"modal__footer"});if(l.buttons&&l.buttons.length>0)l.buttons.forEach(e=>{const t=f(e.text,e.type||"default",async()=>{await n(()=>e.onClick())});e.style&&Object.assign(t.style,e.style),T.appendChild(t)});else{if(h){const e=f(l.cancelText||c.cancelText,"default",()=>{var e;p(a),null==(e=l.onCancel)||e.call(l)});T.appendChild(e)}const e=f(l.okText||c.okText,l.okType||"primary",async()=>{l.onOk&&!1===await n(()=>l.onOk())||p(a)});T.appendChild(e)}w.appendChild(T),C.appendChild(w),document.body.appendChild(C),i.push({id:a,element:C,instance:null,cleanup:()=>{v.forEach(({element:e,type:t,handler:n})=>{e.removeEventListener(t,n)}),b()}});const E={close:()=>{var e;p(a),null==(e=l.onClose)||e.call(l)},update:e=>{if(void 0!==e.title){const t=C.querySelector(".modal__title");t&&(t.innerHTML="","string"==typeof e.title?t.textContent=e.title:e.title instanceof HTMLElement&&t.appendChild(e.title.cloneNode(!0)))}if(void 0!==e.content){const t=C.querySelector(".modal__content");t&&(t.innerHTML="","string"==typeof e.content?t.textContent=e.content:e.content instanceof HTMLElement&&t.appendChild(e.content.cloneNode(!0)))}if(void 0!==e.width){const t=C.querySelector(".modal");t&&(t.style.width="number"==typeof e.width?`${e.width}px`:e.width)}if(void 0!==e.className){const t=C.querySelector(".modal");t&&(t.className=`modal ${e.className}`.trim())}if(void 0!==e.style){const t=C.querySelector(".modal");t&&Object.assign(t.style,e.style)}}},L=i.find(e=>e.id===a);return L&&(L.instance=E),E}const y={open:h,confirm:function(e){return h({...e,type:"confirm",showCancel:!0})},info:function(e){return h({...e,type:"info"})},success:function(e){return h({...e,type:"success"})},error:function(e){return h({...e,type:"error"})},warning:function(e){return h({...e,type:"warning"})},config:function(e){Object.assign(c,e)},destroy:async function(){for(;i.length>0;)await u()}};export{y as Modal};
@@ -4,7 +4,7 @@
4
4
  export type ModalType = 'info' | 'success' | 'warning' | 'error' | 'confirm';
5
5
  export interface ModalButton {
6
6
  /** 按钮文字 */
7
- text: string;
7
+ text: string | HTMLElement;
8
8
  /** 按钮类型 */
9
9
  type?: 'primary' | 'default' | 'danger';
10
10
  /** 按钮样式 */
@@ -14,9 +14,9 @@ export interface ModalButton {
14
14
  }
15
15
  export interface ModalOptions {
16
16
  /** 标题 */
17
- title?: string;
17
+ title?: string | HTMLElement;
18
18
  /** 内容 */
19
- content?: string;
19
+ content?: string | HTMLElement;
20
20
  /** 类型 */
21
21
  type?: ModalType;
22
22
  /** 宽度 */
@@ -27,10 +27,12 @@ export interface ModalOptions {
27
27
  maskClosable?: boolean;
28
28
  /** 是否显示关闭按钮 */
29
29
  closable?: boolean;
30
+ /** 是否显示图标,默认 true */
31
+ showIcon?: boolean;
30
32
  /** 确定按钮文字 */
31
- okText?: string;
33
+ okText?: string | HTMLElement;
32
34
  /** 取消按钮文字 */
33
- cancelText?: string;
35
+ cancelText?: string | HTMLElement;
34
36
  /** 确定按钮类型 */
35
37
  okType?: 'primary' | 'default' | 'danger';
36
38
  /** 是否显示取消按钮 */
@@ -62,7 +64,7 @@ export interface ModalConfig {
62
64
  /** 默认是否可点击遮罩关闭 */
63
65
  maskClosable: boolean;
64
66
  /** 默认确定按钮文字 */
65
- okText: string;
67
+ okText: string | HTMLElement;
66
68
  /** 默认取消按钮文字 */
67
- cancelText: string;
69
+ cancelText: string | HTMLElement;
68
70
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={okText:"确定",cancelText:"取消",okType:"primary",showCancel:!0,placement:"top"};let o=null,a=null;const c=new WeakSet;async function s(){if(!o)return;const{element:t}=o,n=t.querySelector(".popconfirm");n&&n.classList.add("is-closing"),await e.addClosingAnimation(t,e.ANIMATION_DURATION.FAST),t.remove(),o=null}async function r(c,r){if(o&&o.target===c)return await s(),{destroy:()=>{}};await s();const l=e.generateId();e.injectStyle("solely-popconfirm-styles",t.default);const i=r.placement??n.placement,d=r.okType??n.okType,m=r.showCancel??n.showCancel,p=e.createElement("div",{className:"popconfirm-overlay"}),u=(f=p,(()=>{const e=document.documentElement.getAttribute("data-theme");e?f.setAttribute("data-theme",e):f.removeAttribute("data-theme")})(),a||(a=new MutationObserver(()=>{if(o){const e=document.documentElement.getAttribute("data-theme");e?o.element.setAttribute("data-theme",e):o.element.removeAttribute("data-theme")}}),a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{a&&!o&&(a.disconnect(),a=null)});var f;const y=e.createElement("div",{className:`popconfirm popconfirm--${i}${r.className?` ${r.className}`:""}`,styles:r.style}),v=e.createElement("div",{className:"popconfirm__content"}),b=e.createElement("span",{className:"popconfirm__icon",textContent:"⚠"});v.appendChild(b);const _=e.createElement("div",{className:"popconfirm__text"}),w=e.createElement("div",{className:"popconfirm__title",textContent:r.title});if(_.appendChild(w),r.description){const t=e.createElement("div",{className:"popconfirm__description",textContent:r.description});_.appendChild(t)}v.appendChild(_);const E=e.createElement("div",{className:"popconfirm__buttons"}),h=async()=>{var e;await s(),null==(e=r.onCancel)||e.call(r)};if(m){const t=e.createElement("button",{className:"popconfirm__btn popconfirm__btn--cancel",textContent:r.cancelText??n.cancelText,attrs:{type:"button"}});t.onclick=h,E.appendChild(t)}const C=e.createElement("button",{className:"popconfirm__btn popconfirm__btn--ok"+("danger"===d?" popconfirm__btn--danger":""),textContent:r.okText??n.okText,attrs:{type:"button"}});C.onclick=async()=>{var e;await s(),null==(e=r.onConfirm)||e.call(r)},E.appendChild(C);const k=e.createElement("div",{className:"popconfirm__arrow"});y.appendChild(k),y.appendChild(v),y.appendChild(E),p.appendChild(y),document.body.appendChild(p);const x=e.calculatePosition(c,y,i);y.style.top=`${x.top}px`,y.style.left=`${x.left}px`,void 0!==x.arrowLeft&&(k.style.left=`${x.arrowLeft}px`),void 0!==x.arrowTop&&(k.style.top=`${x.arrowTop}px`);const g=e=>{e.target===p&&h()},N=e=>{"Escape"===e.key&&(h(),document.removeEventListener("keydown",N))};p.addEventListener("click",g),document.addEventListener("keydown",N);const T=()=>{document.removeEventListener("keydown",N),p.removeEventListener("click",g),u(),s()};return o={id:l,target:c,element:p,destroy:T},{destroy:T}}const l={show:r,bind:function(e,t){if(c.has(e))return{destroy:()=>{}};c.add(e);let n=null;const a=async a=>{a.stopPropagation(),o?(await s(),n=null):n=await r(e,t)},l=async t=>{if(!o)return;const a=t.target;o.element.contains(a)||e.contains(a)||(await s(),n=null)};return e.addEventListener("click",a),document.addEventListener("mousedown",l),{destroy:()=>{c.delete(e),e.removeEventListener("click",a),document.removeEventListener("mousedown",l),null==n||n.destroy(),n=null}}},config:function(e){Object.assign(n,e)},destroy:s};exports.Popconfirm=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={okText:"确定",cancelText:"取消",okType:"primary",showCancel:!0,placement:"top"};let o=null,a=null;const c=new WeakSet;async function i(){if(!o)return;const{element:t}=o,n=t.querySelector(".popconfirm");n&&n.classList.add("is-closing"),await e.addClosingAnimation(t,e.ANIMATION_DURATION.FAST),t.remove(),o=null}async function s(c,s){if(o&&o.target===c)return await i(),{destroy:()=>{}};await i();const l=e.generateId();e.injectStyle("solely-popconfirm-styles",t.default);const r=s.placement??n.placement,d=s.okType??n.okType,p=s.showCancel??n.showCancel,m=e.createElement("div",{className:"popconfirm-overlay"}),u=(f=m,(()=>{const e=document.documentElement.getAttribute("data-theme");e?f.setAttribute("data-theme",e):f.removeAttribute("data-theme")})(),a||(a=new MutationObserver(()=>{if(o){const e=document.documentElement.getAttribute("data-theme");e?o.element.setAttribute("data-theme",e):o.element.removeAttribute("data-theme")}}),a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{a&&!o&&(a.disconnect(),a=null)});var f;const y=e.createElement("div",{className:`popconfirm popconfirm--${r}${s.className?` ${s.className}`:""}`,styles:s.style}),v=e.createElement("div",{className:"popconfirm__content"});if(!1!==s.showIcon){const t=e.createElement("span",{className:"popconfirm__icon",textContent:"⚠"});v.appendChild(t)}const h=e.createElement("div",{className:"popconfirm__text"}),E=e.createElement("div",{className:"popconfirm__title"});if("string"==typeof s.title?E.textContent=s.title:s.title instanceof HTMLElement&&E.appendChild(s.title.cloneNode(!0)),h.appendChild(E),s.description){const t=e.createElement("div",{className:"popconfirm__description"});"string"==typeof s.description?t.textContent=s.description:s.description instanceof HTMLElement&&t.appendChild(s.description.cloneNode(!0)),h.appendChild(t)}v.appendChild(h);const C=e.createElement("div",{className:"popconfirm__buttons"}),b=async()=>{var e;await i(),null==(e=s.onCancel)||e.call(s)};if(p){const t=e.createElement("button",{className:"popconfirm__btn popconfirm__btn--cancel",attrs:{type:"button"}}),o=s.cancelText??n.cancelText;"string"==typeof o?t.textContent=o:o instanceof HTMLElement&&t.appendChild(o.cloneNode(!0)),t.onclick=b,C.appendChild(t)}const w=e.createElement("button",{className:"popconfirm__btn popconfirm__btn--ok"+("danger"===d?" popconfirm__btn--danger":""),attrs:{type:"button"}}),_=s.okText??n.okText;"string"==typeof _?w.textContent=_:_ instanceof HTMLElement&&w.appendChild(_.cloneNode(!0)),w.onclick=async()=>{var e;await i(),null==(e=s.onConfirm)||e.call(s)},C.appendChild(w);const g=e.createElement("div",{className:"popconfirm__arrow"});y.appendChild(g),y.appendChild(v),y.appendChild(C),m.appendChild(y),document.body.appendChild(m);const N=e.calculatePosition(c,y,r);y.style.top=`${N.top}px`,y.style.left=`${N.left}px`,void 0!==N.arrowLeft&&(g.style.left=`${N.arrowLeft}px`),void 0!==N.arrowTop&&(g.style.top=`${N.arrowTop}px`);const T=e=>{e.target===m&&b()},k=e=>{"Escape"===e.key&&(b(),document.removeEventListener("keydown",k))};m.addEventListener("click",T),document.addEventListener("keydown",k);const x=()=>{document.removeEventListener("keydown",k),m.removeEventListener("click",T),u(),i()};return o={id:l,target:c,element:m,destroy:x},{destroy:x}}const l={show:s,bind:function(e,t){if(c.has(e))return{destroy:()=>{}};c.add(e);let n=null;const a=async a=>{a.stopPropagation(),o?(await i(),n=null):n=await s(e,t)},l=async t=>{if(!o)return;const a=t.target;o.element.contains(a)||e.contains(a)||(await i(),n=null)};return e.addEventListener("click",a),document.addEventListener("mousedown",l),{destroy:()=>{c.delete(e),e.removeEventListener("click",a),document.removeEventListener("mousedown",l),null==n||n.destroy(),n=null}}},config:function(e){Object.assign(n,e)},destroy:i};exports.Popconfirm=l;
@@ -1 +1 @@
1
- import{createElement as t,calculatePosition as e,injectStyle as n,addClosingAnimation as o,ANIMATION_DURATION as a,generateId as c}from"../utils.js";import s from"./style.css.js";const i={okText:"确定",cancelText:"取消",okType:"primary",showCancel:!0,placement:"top"};let r=null,l=null;const d=new WeakSet;async function p(){if(!r)return;const{element:t}=r,e=t.querySelector(".popconfirm");e&&e.classList.add("is-closing"),await o(t,a.FAST),t.remove(),r=null}async function m(o,a){if(r&&r.target===o)return await p(),{destroy:()=>{}};await p();const d=c();n("solely-popconfirm-styles",s);const m=a.placement??i.placement,u=a.okType??i.okType,f=a.showCancel??i.showCancel,y=t("div",{className:"popconfirm-overlay"}),v=(w=y,(()=>{const t=document.documentElement.getAttribute("data-theme");t?w.setAttribute("data-theme",t):w.removeAttribute("data-theme")})(),l||(l=new MutationObserver(()=>{if(r){const t=document.documentElement.getAttribute("data-theme");t?r.element.setAttribute("data-theme",t):r.element.removeAttribute("data-theme")}}),l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{l&&!r&&(l.disconnect(),l=null)});var w;const _=t("div",{className:`popconfirm popconfirm--${m}${a.className?` ${a.className}`:""}`,styles:a.style}),b=t("div",{className:"popconfirm__content"}),h=t("span",{className:"popconfirm__icon",textContent:"⚠"});b.appendChild(h);const C=t("div",{className:"popconfirm__text"}),k=t("div",{className:"popconfirm__title",textContent:a.title});if(C.appendChild(k),a.description){const e=t("div",{className:"popconfirm__description",textContent:a.description});C.appendChild(e)}b.appendChild(C);const x=t("div",{className:"popconfirm__buttons"}),E=async()=>{var t;await p(),null==(t=a.onCancel)||t.call(a)};if(f){const e=t("button",{className:"popconfirm__btn popconfirm__btn--cancel",textContent:a.cancelText??i.cancelText,attrs:{type:"button"}});e.onclick=E,x.appendChild(e)}const N=t("button",{className:"popconfirm__btn popconfirm__btn--ok"+("danger"===u?" popconfirm__btn--danger":""),textContent:a.okText??i.okText,attrs:{type:"button"}});N.onclick=async()=>{var t;await p(),null==(t=a.onConfirm)||t.call(a)},x.appendChild(N);const g=t("div",{className:"popconfirm__arrow"});_.appendChild(g),_.appendChild(b),_.appendChild(x),y.appendChild(_),document.body.appendChild(y);const L=e(o,_,m);_.style.top=`${L.top}px`,_.style.left=`${L.left}px`,void 0!==L.arrowLeft&&(g.style.left=`${L.arrowLeft}px`),void 0!==L.arrowTop&&(g.style.top=`${L.arrowTop}px`);const T=t=>{t.target===y&&E()},A=t=>{"Escape"===t.key&&(E(),document.removeEventListener("keydown",A))};y.addEventListener("click",T),document.addEventListener("keydown",A);const $=()=>{document.removeEventListener("keydown",A),y.removeEventListener("click",T),v(),p()};return r={id:d,target:o,element:y,destroy:$},{destroy:$}}const u={show:m,bind:function(t,e){if(d.has(t))return{destroy:()=>{}};d.add(t);let n=null;const o=async o=>{o.stopPropagation(),r?(await p(),n=null):n=await m(t,e)},a=async e=>{if(!r)return;const o=e.target;r.element.contains(o)||t.contains(o)||(await p(),n=null)};return t.addEventListener("click",o),document.addEventListener("mousedown",a),{destroy:()=>{d.delete(t),t.removeEventListener("click",o),document.removeEventListener("mousedown",a),null==n||n.destroy(),n=null}}},config:function(t){Object.assign(i,t)},destroy:p};export{u as Popconfirm};
1
+ import{createElement as e,calculatePosition as t,injectStyle as n,addClosingAnimation as o,ANIMATION_DURATION as a,generateId as c}from"../utils.js";import i from"./style.css.js";const s={okText:"确定",cancelText:"取消",okType:"primary",showCancel:!0,placement:"top"};let l=null,r=null;const d=new WeakSet;async function p(){if(!l)return;const{element:e}=l,t=e.querySelector(".popconfirm");t&&t.classList.add("is-closing"),await o(e,a.FAST),e.remove(),l=null}async function m(o,a){if(l&&l.target===o)return await p(),{destroy:()=>{}};await p();const d=c();n("solely-popconfirm-styles",i);const m=a.placement??s.placement,u=a.okType??s.okType,f=a.showCancel??s.showCancel,y=e("div",{className:"popconfirm-overlay"}),v=(h=y,(()=>{const e=document.documentElement.getAttribute("data-theme");e?h.setAttribute("data-theme",e):h.removeAttribute("data-theme")})(),r||(r=new MutationObserver(()=>{if(l){const e=document.documentElement.getAttribute("data-theme");e?l.element.setAttribute("data-theme",e):l.element.removeAttribute("data-theme")}}),r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{r&&!l&&(r.disconnect(),r=null)});var h;const w=e("div",{className:`popconfirm popconfirm--${m}${a.className?` ${a.className}`:""}`,styles:a.style}),C=e("div",{className:"popconfirm__content"});if(!1!==a.showIcon){const t=e("span",{className:"popconfirm__icon",textContent:"⚠"});C.appendChild(t)}const _=e("div",{className:"popconfirm__text"}),b=e("div",{className:"popconfirm__title"});if("string"==typeof a.title?b.textContent=a.title:a.title instanceof HTMLElement&&b.appendChild(a.title.cloneNode(!0)),_.appendChild(b),a.description){const t=e("div",{className:"popconfirm__description"});"string"==typeof a.description?t.textContent=a.description:a.description instanceof HTMLElement&&t.appendChild(a.description.cloneNode(!0)),_.appendChild(t)}C.appendChild(_);const k=e("div",{className:"popconfirm__buttons"}),x=async()=>{var e;await p(),null==(e=a.onCancel)||e.call(a)};if(f){const t=e("button",{className:"popconfirm__btn popconfirm__btn--cancel",attrs:{type:"button"}}),n=a.cancelText??s.cancelText;"string"==typeof n?t.textContent=n:n instanceof HTMLElement&&t.appendChild(n.cloneNode(!0)),t.onclick=x,k.appendChild(t)}const E=e("button",{className:"popconfirm__btn popconfirm__btn--ok"+("danger"===u?" popconfirm__btn--danger":""),attrs:{type:"button"}}),N=a.okText??s.okText;"string"==typeof N?E.textContent=N:N instanceof HTMLElement&&E.appendChild(N.cloneNode(!0)),E.onclick=async()=>{var e;await p(),null==(e=a.onConfirm)||e.call(a)},k.appendChild(E);const g=e("div",{className:"popconfirm__arrow"});w.appendChild(g),w.appendChild(C),w.appendChild(k),y.appendChild(w),document.body.appendChild(y);const L=t(o,w,m);w.style.top=`${L.top}px`,w.style.left=`${L.left}px`,void 0!==L.arrowLeft&&(g.style.left=`${L.arrowLeft}px`),void 0!==L.arrowTop&&(g.style.top=`${L.arrowTop}px`);const T=e=>{e.target===y&&x()},A=e=>{"Escape"===e.key&&(x(),document.removeEventListener("keydown",A))};y.addEventListener("click",T),document.addEventListener("keydown",A);const $=()=>{document.removeEventListener("keydown",A),y.removeEventListener("click",T),v(),p()};return l={id:d,target:o,element:y,destroy:$},{destroy:$}}const u={show:m,bind:function(e,t){if(d.has(e))return{destroy:()=>{}};d.add(e);let n=null;const o=async o=>{o.stopPropagation(),l?(await p(),n=null):n=await m(e,t)},a=async t=>{if(!l)return;const o=t.target;l.element.contains(o)||e.contains(o)||(await p(),n=null)};return e.addEventListener("click",o),document.addEventListener("mousedown",a),{destroy:()=>{d.delete(e),e.removeEventListener("click",o),document.removeEventListener("mousedown",a),null==n||n.destroy(),n=null}}},config:function(e){Object.assign(s,e)},destroy:p};export{u as Popconfirm};
@@ -4,19 +4,21 @@
4
4
  export type PopconfirmPlacement = 'top' | 'bottom' | 'left' | 'right' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
5
5
  export interface PopconfirmOptions {
6
6
  /** 确认框标题 */
7
- title: string;
7
+ title?: string | HTMLElement;
8
8
  /** 确认框描述 */
9
- description?: string;
9
+ description?: string | HTMLElement;
10
10
  /** 气泡框位置 */
11
11
  placement?: PopconfirmPlacement;
12
12
  /** 确认按钮文字 */
13
- okText?: string;
13
+ okText?: string | HTMLElement;
14
14
  /** 确认按钮类型 */
15
15
  okType?: 'primary' | 'danger' | 'default';
16
16
  /** 取消按钮文字 */
17
- cancelText?: string;
17
+ cancelText?: string | HTMLElement;
18
18
  /** 是否显示取消按钮 */
19
19
  showCancel?: boolean;
20
+ /** 是否显示图标,默认 true */
21
+ showIcon?: boolean;
20
22
  /** 确认回调 */
21
23
  onConfirm?: () => void;
22
24
  /** 取消回调 */
@@ -32,9 +34,9 @@ export interface PopconfirmInstance {
32
34
  }
33
35
  export interface PopconfirmConfig {
34
36
  /** 默认确认按钮文字 */
35
- okText: string;
37
+ okText: string | HTMLElement;
36
38
  /** 默认取消按钮文字 */
37
- cancelText: string;
39
+ cancelText: string | HTMLElement;
38
40
  /** 默认确认按钮类型 */
39
41
  okType: 'primary' | 'danger' | 'default';
40
42
  /** 默认是否显示取消按钮 */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={placement:"top",trigger:"hover",duration:3e3},o=[],l=new WeakSet;let s=null;async function i(t,n){const l=o.findIndex(e=>e.id===t);if(-1===l)return;const s=o[l],i=s.element.querySelector(".tooltip");i&&i.classList.add("is-closing"),await e.addClosingAnimation(s.element,e.ANIMATION_DURATION.FAST),s.element.remove(),o.splice(l,1),null==n||n()}function r(l,r){var a;const c=e.generateId();e.injectStyle("solely-tooltip-styles",t.default);const d=r.placement??n.placement,u=e.createElement("div",{className:"tooltip-overlay"}),m=(v=u,(()=>{const e=document.documentElement.getAttribute("data-theme");e?v.setAttribute("data-theme",e):v.removeAttribute("data-theme")})(),s||(s=new MutationObserver(()=>{o.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{s&&0===o.length&&(s.disconnect(),s=null)});var v;const p=e.createElement("div",{className:`tooltip tooltip--${d}${r.className?` ${r.className}`:""}`,styles:{...r.style,...r.color?{backgroundColor:r.color}:{}}}),h=e.createElement("div",{className:"tooltip__content",textContent:r.content||""});p.appendChild(h);const g=e.createElement("div",{className:"tooltip__arrow"});r.color&&(g.style.backgroundColor=r.color),p.appendChild(g),u.appendChild(p),document.body.appendChild(u);const f=e.calculatePosition(l,p,d);return p.style.top=`${f.top}px`,p.style.left=`${f.left}px`,void 0!==f.arrowLeft&&(g.style.left=`${f.arrowLeft}px`),void 0!==f.arrowTop&&(g.style.top=`${f.arrowTop}px`),o.push({id:c,element:u,target:l,destroy:()=>{m(),i(c)}}),null==(a=r.onVisibleChange)||a.call(r,!0),c}const a={bind:function(e,t){if(l.has(e))return{show:()=>{},hide:()=>{},destroy:()=>{}};l.add(e);const o=t.trigger??n.trigger;let s=t.visible??t.defaultVisible??!1,a=null;const c=()=>{s||(s=!0,a=r(e,t))},d=()=>{if(!s||null===a)return;s=!1;const e=a;a=null,i(e,()=>{var e;null==(e=t.onVisibleChange)||e.call(t,!1)})},u=e=>{e.stopPropagation(),s?d():c()},m=t=>{s&&(e.contains(t.target)||d())};return"hover"===o?(e.addEventListener("mouseenter",c),e.addEventListener("mouseleave",d)):"click"===o?(e.addEventListener("click",u),document.addEventListener("click",m)):"focus"===o&&(e.addEventListener("focus",c),e.addEventListener("blur",d)),s&&(a=r(e,t)),{show:c,hide:d,destroy:()=>{d(),l.delete(e),"hover"===o?(e.removeEventListener("mouseenter",c),e.removeEventListener("mouseleave",d)):"click"===o?(e.removeEventListener("click",u),document.removeEventListener("click",m)):"focus"===o&&(e.removeEventListener("focus",c),e.removeEventListener("blur",d))}}},show:function(e,t){const o=r(e,t),l=t.duration??n.duration;l>0&&setTimeout(()=>{i(o)},l)},hide:async function(t){0!==o.length?(await Promise.all(o.map(async t=>{const n=t.element.querySelector(".tooltip");n&&n.classList.add("is-closing"),await e.addClosingAnimation(t.element,e.ANIMATION_DURATION.FAST),t.element.remove()})),o.length=0,null==t||t()):null==t||t()},config:function(e){Object.assign(n,e)}};exports.Tooltip=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../utils.cjs"),t=require("./style.css.cjs"),n={placement:"top",trigger:"hover",duration:3e3},o=[],l=new WeakSet;let i=null;async function s(t,n){const l=o.findIndex(e=>e.id===t);if(-1===l)return;const i=o[l],s=i.element.querySelector(".tooltip");s&&s.classList.add("is-closing"),await e.addClosingAnimation(i.element,e.ANIMATION_DURATION.FAST),i.element.remove(),o.splice(l,1),null==n||n()}function r(l,r){var a;const c=e.generateId();e.injectStyle("solely-tooltip-styles",t.default);const d=r.placement??n.placement,u=e.createElement("div",{className:"tooltip-overlay"}),m=(p=u,(()=>{const e=document.documentElement.getAttribute("data-theme");e?p.setAttribute("data-theme",e):p.removeAttribute("data-theme")})(),i||(i=new MutationObserver(()=>{o.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{i&&0===o.length&&(i.disconnect(),i=null)});var p;const v=e.createElement("div",{className:`tooltip tooltip--${d}${r.className?` ${r.className}`:""}`,styles:{...r.style,...r.color?{backgroundColor:r.color}:{}}}),h=e.createElement("div",{className:"tooltip__content"});r.content&&("string"==typeof r.content?h.textContent=r.content:r.content instanceof HTMLElement&&h.appendChild(r.content.cloneNode(!0))),v.appendChild(h);const g=e.createElement("div",{className:"tooltip__arrow"});r.color&&(g.style.backgroundColor=r.color),v.appendChild(g),u.appendChild(v),document.body.appendChild(u);const f=e.calculatePosition(l,v,d);return v.style.top=`${f.top}px`,v.style.left=`${f.left}px`,void 0!==f.arrowLeft&&(g.style.left=`${f.arrowLeft}px`),void 0!==f.arrowTop&&(g.style.top=`${f.arrowTop}px`),o.push({id:c,element:u,target:l,destroy:()=>{m(),s(c)}}),null==(a=r.onVisibleChange)||a.call(r,!0),c}const a={bind:function(e,t){if(l.has(e))return{show:()=>{},hide:()=>{},destroy:()=>{}};l.add(e);const o=t.trigger??n.trigger;let i=t.visible??t.defaultVisible??!1,a=null;const c=()=>{i||(i=!0,a=r(e,t))},d=()=>{if(!i||null===a)return;i=!1;const e=a;a=null,s(e,()=>{var e;null==(e=t.onVisibleChange)||e.call(t,!1)})},u=e=>{e.stopPropagation(),i?d():c()},m=t=>{i&&(e.contains(t.target)||d())};return"hover"===o?(e.addEventListener("mouseenter",c),e.addEventListener("mouseleave",d)):"click"===o?(e.addEventListener("click",u),document.addEventListener("click",m)):"focus"===o&&(e.addEventListener("focus",c),e.addEventListener("blur",d)),i&&(a=r(e,t)),{show:c,hide:d,destroy:()=>{d(),l.delete(e),"hover"===o?(e.removeEventListener("mouseenter",c),e.removeEventListener("mouseleave",d)):"click"===o?(e.removeEventListener("click",u),document.removeEventListener("click",m)):"focus"===o&&(e.removeEventListener("focus",c),e.removeEventListener("blur",d))}}},show:function(e,t){const o=r(e,t),l=t.duration??n.duration;l>0&&setTimeout(()=>{s(o)},l)},hide:async function(t){0!==o.length?(await Promise.all(o.map(async t=>{const n=t.element.querySelector(".tooltip");n&&n.classList.add("is-closing"),await e.addClosingAnimation(t.element,e.ANIMATION_DURATION.FAST),t.element.remove()})),o.length=0,null==t||t()):null==t||t()},config:function(e){Object.assign(n,e)}};exports.Tooltip=a;
@@ -1 +1 @@
1
- import{addClosingAnimation as e,ANIMATION_DURATION as t,generateId as n,createElement as o,calculatePosition as l,injectStyle as s}from"../utils.js";import r from"./style.css.js";const i={placement:"top",trigger:"hover",duration:3e3},a=[],c=new WeakSet;let d=null;async function u(n,o){const l=a.findIndex(e=>e.id===n);if(-1===l)return;const s=a[l],r=s.element.querySelector(".tooltip");r&&r.classList.add("is-closing"),await e(s.element,t.FAST),s.element.remove(),a.splice(l,1),null==o||o()}function m(e,t){var c;const m=n();s("solely-tooltip-styles",r);const v=t.placement??i.placement,p=o("div",{className:"tooltip-overlay"}),h=(f=p,(()=>{const e=document.documentElement.getAttribute("data-theme");e?f.setAttribute("data-theme",e):f.removeAttribute("data-theme")})(),d||(d=new MutationObserver(()=>{a.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),d.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{d&&0===a.length&&(d.disconnect(),d=null)});var f;const g=o("div",{className:`tooltip tooltip--${v}${t.className?` ${t.className}`:""}`,styles:{...t.style,...t.color?{backgroundColor:t.color}:{}}}),b=o("div",{className:"tooltip__content",textContent:t.content||""});g.appendChild(b);const y=o("div",{className:"tooltip__arrow"});t.color&&(y.style.backgroundColor=t.color),g.appendChild(y),p.appendChild(g),document.body.appendChild(p);const E=l(e,g,v);return g.style.top=`${E.top}px`,g.style.left=`${E.left}px`,void 0!==E.arrowLeft&&(y.style.left=`${E.arrowLeft}px`),void 0!==E.arrowTop&&(y.style.top=`${E.arrowTop}px`),a.push({id:m,element:p,target:e,destroy:()=>{h(),u(m)}}),null==(c=t.onVisibleChange)||c.call(t,!0),m}const v={bind:function(e,t){if(c.has(e))return{show:()=>{},hide:()=>{},destroy:()=>{}};c.add(e);const n=t.trigger??i.trigger;let o=t.visible??t.defaultVisible??!1,l=null;const s=()=>{o||(o=!0,l=m(e,t))},r=()=>{if(!o||null===l)return;o=!1;const e=l;l=null,u(e,()=>{var e;null==(e=t.onVisibleChange)||e.call(t,!1)})},a=e=>{e.stopPropagation(),o?r():s()},d=t=>{o&&(e.contains(t.target)||r())};return"hover"===n?(e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",r)):"click"===n?(e.addEventListener("click",a),document.addEventListener("click",d)):"focus"===n&&(e.addEventListener("focus",s),e.addEventListener("blur",r)),o&&(l=m(e,t)),{show:s,hide:r,destroy:()=>{r(),c.delete(e),"hover"===n?(e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",r)):"click"===n?(e.removeEventListener("click",a),document.removeEventListener("click",d)):"focus"===n&&(e.removeEventListener("focus",s),e.removeEventListener("blur",r))}}},show:function(e,t){const n=m(e,t),o=t.duration??i.duration;o>0&&setTimeout(()=>{u(n)},o)},hide:async function(n){0!==a.length?(await Promise.all(a.map(async n=>{const o=n.element.querySelector(".tooltip");o&&o.classList.add("is-closing"),await e(n.element,t.FAST),n.element.remove()})),a.length=0,null==n||n()):null==n||n()},config:function(e){Object.assign(i,e)}};export{v as Tooltip};
1
+ import{addClosingAnimation as e,ANIMATION_DURATION as t,generateId as n,createElement as o,calculatePosition as l,injectStyle as s}from"../utils.js";import r from"./style.css.js";const i={placement:"top",trigger:"hover",duration:3e3},a=[],c=new WeakSet;let d=null;async function u(n,o){const l=a.findIndex(e=>e.id===n);if(-1===l)return;const s=a[l],r=s.element.querySelector(".tooltip");r&&r.classList.add("is-closing"),await e(s.element,t.FAST),s.element.remove(),a.splice(l,1),null==o||o()}function m(e,t){var c;const m=n();s("solely-tooltip-styles",r);const p=t.placement??i.placement,v=o("div",{className:"tooltip-overlay"}),h=(f=v,(()=>{const e=document.documentElement.getAttribute("data-theme");e?f.setAttribute("data-theme",e):f.removeAttribute("data-theme")})(),d||(d=new MutationObserver(()=>{a.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),d.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{d&&0===a.length&&(d.disconnect(),d=null)});var f;const g=o("div",{className:`tooltip tooltip--${p}${t.className?` ${t.className}`:""}`,styles:{...t.style,...t.color?{backgroundColor:t.color}:{}}}),b=o("div",{className:"tooltip__content"});t.content&&("string"==typeof t.content?b.textContent=t.content:t.content instanceof HTMLElement&&b.appendChild(t.content.cloneNode(!0))),g.appendChild(b);const y=o("div",{className:"tooltip__arrow"});t.color&&(y.style.backgroundColor=t.color),g.appendChild(y),v.appendChild(g),document.body.appendChild(v);const E=l(e,g,p);return g.style.top=`${E.top}px`,g.style.left=`${E.left}px`,void 0!==E.arrowLeft&&(y.style.left=`${E.arrowLeft}px`),void 0!==E.arrowTop&&(y.style.top=`${E.arrowTop}px`),a.push({id:m,element:v,target:e,destroy:()=>{h(),u(m)}}),null==(c=t.onVisibleChange)||c.call(t,!0),m}const p={bind:function(e,t){if(c.has(e))return{show:()=>{},hide:()=>{},destroy:()=>{}};c.add(e);const n=t.trigger??i.trigger;let o=t.visible??t.defaultVisible??!1,l=null;const s=()=>{o||(o=!0,l=m(e,t))},r=()=>{if(!o||null===l)return;o=!1;const e=l;l=null,u(e,()=>{var e;null==(e=t.onVisibleChange)||e.call(t,!1)})},a=e=>{e.stopPropagation(),o?r():s()},d=t=>{o&&(e.contains(t.target)||r())};return"hover"===n?(e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",r)):"click"===n?(e.addEventListener("click",a),document.addEventListener("click",d)):"focus"===n&&(e.addEventListener("focus",s),e.addEventListener("blur",r)),o&&(l=m(e,t)),{show:s,hide:r,destroy:()=>{r(),c.delete(e),"hover"===n?(e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",r)):"click"===n?(e.removeEventListener("click",a),document.removeEventListener("click",d)):"focus"===n&&(e.removeEventListener("focus",s),e.removeEventListener("blur",r))}}},show:function(e,t){const n=m(e,t),o=t.duration??i.duration;o>0&&setTimeout(()=>{u(n)},o)},hide:async function(n){0!==a.length?(await Promise.all(a.map(async n=>{const o=n.element.querySelector(".tooltip");o&&o.classList.add("is-closing"),await e(n.element,t.FAST),n.element.remove()})),a.length=0,null==n||n()):null==n||n()},config:function(e){Object.assign(i,e)}};export{p as Tooltip};
@@ -5,7 +5,7 @@ export type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right' | 'topLeft' |
5
5
  export type TooltipTrigger = 'hover' | 'click' | 'focus' | 'manual';
6
6
  export interface TooltipOptions {
7
7
  /** 提示内容 */
8
- content?: string;
8
+ content?: string | HTMLElement;
9
9
  /** 气泡框位置 */
10
10
  placement?: TooltipPlacement;
11
11
  /** 触发方式 */
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,t=(t,i,s)=>((t,i,s)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s)(t,"symbol"!=typeof i?i+"":i,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./style.css.cjs"),s=require("./index.html.cjs"),n=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyBackTop=class extends n.default{constructor(){super(...arguments),t(this,"scrollHandler"),t(this,"resizeHandler"),t(this,"container",null)}updateVisibleClass(){this.$data.visible?this.classList.add("backtop--visible"):this.classList.remove("backtop--visible")}getContainer(){let e=this.parentElement;for(;e;){const t=window.getComputedStyle(e);if("auto"===t.overflowY||"scroll"===t.overflowY)return e;e=e.parentElement}return null}mounted(){setTimeout(()=>{this.container=this.getContainer(),this.container?(this.scrollHandler=()=>{this.handleScroll()},this.container.addEventListener("scroll",this.scrollHandler),this.resizeHandler=()=>{requestAnimationFrame(()=>{this.updatePosition()})},window.addEventListener("resize",this.resizeHandler),window.addEventListener("scroll",this.resizeHandler,{passive:!0}),this.handleScroll(),this.updatePosition()):console.warn("BackTop: 未找到可滚动的父容器")},100)}unmounted(){this.scrollHandler&&this.container&&this.container.removeEventListener("scroll",this.scrollHandler),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("scroll",this.resizeHandler))}updatePosition(){if(!this.container)return;const e=this.container.getBoundingClientRect(),t=window.innerWidth-e.right+20,i=window.innerHeight-e.bottom+20;this.style.position="fixed",this.style.right=`${t}px`,this.style.bottom=`${i}px`}handleScroll(){if(!this.container)return;const e=this.container.scrollTop>=this.$data.visibilityHeight;this.$data.visible!==e&&(this.$data.visible=e,this.updateVisibleClass())}handleClick(){if(!this.container)return;const e=this.$data.duration||450,t=Date.now(),i=this.container.scrollTop,s=()=>{const n=Date.now()-t,r=Math.min(n/e,1),o=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,l=i*(1-o);this.container.scrollTop=l,r<1?requestAnimationFrame(s):this.dispatchEvent(new Event("click",{bubbles:!0,composed:!0}))};requestAnimationFrame(s)}},exports.SolelyBackTop=((e,t)=>{for(var i,s=t,n=e.length-1;n>=0;n--)(i=e[n])&&(s=i(s)||s);return s})([r.CustomElement({tagName:"solely-backtop",template:s.default,styles:i.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"visibilityHeight",type:"number",default:400},{name:"duration",type:"number",default:450}]})],exports.SolelyBackTop);
1
+ "use strict";var e=Object.defineProperty,t=(t,i,s)=>((t,i,s)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s)(t,"symbol"!=typeof i?i+"":i,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./style.css.cjs"),s=require("./index.html.cjs"),n=require("../utils/helpers.cjs"),r=require("../../../runtime/component/base-element.cjs"),o=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyBackTop=class extends r.default{constructor(){super(...arguments),t(this,"scrollHandler"),t(this,"resizeHandler"),t(this,"container",null),t(this,"mountTimeout"),t(this,"initialized",!1)}updateVisibleClass(){this.$data.visible?this.classList.add("backtop--visible"):this.classList.remove("backtop--visible")}getContainer(){let e=this.parentElement;for(;e;){const t=window.getComputedStyle(e);if("auto"===t.overflowY||"scroll"===t.overflowY)return e;e=e.parentElement}return null}mounted(){this.mountTimeout=setTimeout(()=>{this.initializeContainer()},100)}unmounted(){this.mountTimeout&&(clearTimeout(this.mountTimeout),this.mountTimeout=void 0),this.cleanupEventListeners()}initializeContainer(){this.initialized||(this.initialized=!0,this.container=this.getContainer(),this.container?(this.scrollHandler=n.throttle(()=>{this.handleScroll()},16),this.container.addEventListener("scroll",this.scrollHandler),this.resizeHandler=()=>{requestAnimationFrame(()=>{this.updatePosition()})},window.addEventListener("resize",this.resizeHandler),window.addEventListener("scroll",n.throttle(()=>{this.resizeHandler&&this.resizeHandler()},16),{passive:!0}),this.handleScroll(),this.updatePosition()):this.warn(!0,"未找到可滚动的父容器"))}cleanupEventListeners(){this.scrollHandler&&this.container&&this.container.removeEventListener("scroll",this.scrollHandler),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("scroll",this.resizeHandler))}updatePosition(){if(!this.container)return;const e=this.container.getBoundingClientRect(),t=window.innerWidth-e.right+20,i=window.innerHeight-e.bottom+20;this.style.position="fixed",this.style.right=`${t}px`,this.style.bottom=`${i}px`}handleScroll(){if(!this.container)return;const e=this.container.scrollTop>=this.$data.visibilityHeight;this.$data.visible!==e&&(this.$data.visible=e,this.updateVisibleClass())}handleClick(){if(!this.container)return;const e=this.$data.duration||450,t=Date.now(),i=this.container.scrollTop,s=()=>{const n=Date.now()-t,r=Math.min(n/e,1),o=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,l=i*(1-o);this.container.scrollTop=l,r<1?requestAnimationFrame(s):this.dispatchEvent(new Event("click",{bubbles:!0,composed:!0}))};requestAnimationFrame(s)}},exports.SolelyBackTop=((e,t)=>{for(var i,s=t,n=e.length-1;n>=0;n--)(i=e[n])&&(s=i(s)||s);return s})([o.CustomElement({tagName:"solely-backtop",template:s.default,styles:i.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"visibilityHeight",type:"number",default:400},{name:"duration",type:"number",default:450}]})],exports.SolelyBackTop);
@@ -6,6 +6,8 @@ declare class SolelyBackTop extends BaseElement<BackTopProps & {
6
6
  scrollHandler?: () => void;
7
7
  resizeHandler?: () => void;
8
8
  container: HTMLElement | null;
9
+ private mountTimeout?;
10
+ private initialized;
9
11
  /**
10
12
  * 更新显示状态
11
13
  */
@@ -16,6 +18,14 @@ declare class SolelyBackTop extends BaseElement<BackTopProps & {
16
18
  getContainer(): HTMLElement | null;
17
19
  mounted(): void;
18
20
  unmounted(): void;
21
+ /**
22
+ * 初始化容器
23
+ */
24
+ private initializeContainer;
25
+ /**
26
+ * 清理事件监听器
27
+ */
28
+ private cleanupEventListeners;
19
29
  /**
20
30
  * 更新按钮位置
21
31
  */