solely 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1311,6 +1311,10 @@ npm run pack:local
1311
1311
 
1312
1312
  感谢所有为这个项目做出贡献的人!
1313
1313
 
1314
+ ### 第三方资源
1315
+
1316
+ - [Bootstrap Icons](https://icons.getbootstrap.com/) - 用于文档演示的图标库(MIT License)
1317
+
1314
1318
  ---
1315
1319
 
1316
1320
  **Happy Coding with Solely! 🚀**
@@ -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,bottom:24,left:24,right:24,placement:"top"};let o,i=null;const s=new Set,a=[],r={info:"ℹ",success:"✓",warning:"⚠",error:"✕",loading:e.createElement("span",{className:"message__loading-spinner"})},c=new Map;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 p(t){var n;if(!s.has(t)){s.add(t);try{const s=a.findIndex(e=>e.id===t);if(-1===s)return;const l=a[s];l.timer&&(clearTimeout(l.timer),l.timer=void 0),await e.addClosingAnimation(l.element,e.ANIMATION_DURATION.NORMAL),l.element.remove();const p=a.findIndex(e=>e.id===t);-1!==p&&a.splice(p,1);try{null==(n=l.onClose)||n.call(l)}catch(r){console.error("[Solely Message] onClose callback error:",r)}o&&clearTimeout(o),o=window.setTimeout(()=>{0===a.length&&(c.forEach((e,t)=>{0===e.childElementCount&&(e.remove(),c.delete(t))}),0===c.size&&i&&(i.disconnect(),i=null)),o=void 0},300)}finally{s.delete(t)}}}function d(o){const s=e.generateId(),d=o.placement||n.placement,m=function(o=n.placement){const s=o;if(c.has(s))return c.get(s);const a=e.createElement("div",{className:"message-container"}),r={position:"fixed",display:"flex",flexDirection:"column",gap:`${n.gap}px`,pointerEvents:"none",zIndex:"var(--solely-z-index-toast)"};switch(o){case"top":r.top=`${n.top}px`,r.left="50%",r.transform="translateX(-50%)";break;case"topLeft":r.top=`${n.top}px`,r.left=`${n.left}px`,r.alignItems="flex-start";break;case"topRight":r.top=`${n.top}px`,r.right=`${n.right}px`,r.alignItems="flex-end";break;case"bottom":r.bottom=`${n.bottom}px`,r.left="50%",r.transform="translateX(-50%)";break;case"bottomLeft":r.bottom=`${n.bottom}px`,r.left=`${n.left}px`,r.alignItems="flex-start";break;case"bottomRight":r.bottom=`${n.bottom}px`,r.right=`${n.right}px`,r.alignItems="flex-end";break;case"left":r.top="50%",r.left=`${n.left}px`,r.transform="translateY(-50%)",r.alignItems="flex-start";break;case"right":r.top="50%",r.right=`${n.right}px`,r.transform="translateY(-50%)",r.alignItems="flex-end"}Object.assign(a.style,r);const l=document.documentElement.getAttribute("data-theme");return l&&a.setAttribute("data-theme",l),document.body.appendChild(a),e.injectStyle("solely-message-styles",t.default),function(e){i&&i.disconnect(),i=new MutationObserver(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")}),i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}(a),c.set(s,a),a}(d),u=a.filter(e=>e.placement===d);if(u.length>=n.maxCount){const e=u[0];e&&p(e.id)}const f=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(r[o],o);s.appendChild(e)}const a=e.createElement("span",{className:"message__content"}),c=e.createElement("span",{className:"message__text"});if("string"==typeof t.content?c.textContent=t.content:t.content instanceof HTMLElement&&c.appendChild(t.content.cloneNode(!0)),a.appendChild(c),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)),a.appendChild(n)}if(s.appendChild(a),t.closable){const t=e.createElement("button",{className:"message__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}});t.onclick=()=>p(n),s.appendChild(t)}return s}(o,s);m.appendChild(f);const g={id:s,element:f,onClose:o.onClose,placement:d},b=o.duration??n.duration;return b>0&&(g.timer=window.setTimeout(()=>{p(s)},b)),a.push(g),{close:()=>p(s),update:t=>{if("string"==typeof t||t instanceof HTMLElement){const e=f.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=f.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=f.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=f.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 m={open:d,info:function(e,t){return d({content:e,type:"info",..."number"==typeof t?{duration:t}:t})},success:function(e,t){return d({content:e,type:"success",..."number"==typeof t?{duration:t}:t})},warning:function(e,t){return d({content:e,type:"warning",..."number"==typeof t?{duration:t}:t})},error:function(e,t){return d({content:e,type:"error",..."number"==typeof t?{duration:t}:t})},loading:function(e,t){return d(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),c.forEach((t,n)=>{void 0!==e.top&&["top","topLeft","topRight"].includes(n)&&(t.style.top=`${e.top}px`),void 0!==e.bottom&&["bottom","bottomLeft","bottomRight"].includes(n)&&(t.style.bottom=`${e.bottom}px`),void 0!==e.left&&["topLeft","bottomLeft","left"].includes(n)&&(t.style.left=`${e.left}px`),void 0!==e.right&&["topRight","bottomRight","right"].includes(n)&&(t.style.right=`${e.right}px`),void 0!==e.gap&&(t.style.gap=`${e.gap}px`)})},destroy:async function(){o&&(clearTimeout(o),o=void 0);const e=[...a];await Promise.all(e.map(e=>p(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,bottom:24,left:24,right:24,placement:"top"};let o,i=null;const s=new Set,a=[],r={info:"ℹ",success:"✓",warning:"⚠",error:"✕",loading:e.createElement("span",{className:"message__loading-spinner"})},c=new Map;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 p(t){var n;if(!s.has(t)){s.add(t);try{const s=a.findIndex(e=>e.id===t);if(-1===s)return;const l=a[s];l.timer&&(clearTimeout(l.timer),l.timer=void 0),await e.addClosingAnimation(l.element,e.ANIMATION_DURATION.NORMAL),l.element.remove();const p=a.findIndex(e=>e.id===t);-1!==p&&a.splice(p,1);try{null==(n=l.onClose)||n.call(l)}catch(r){console.error("[Solely Message] onClose callback error:",r)}o&&clearTimeout(o),o=window.setTimeout(()=>{0===a.length&&(c.forEach((e,t)=>{0===e.childElementCount&&(e.remove(),c.delete(t))}),0===c.size&&i&&(i.disconnect(),i=null)),o=void 0},300)}finally{s.delete(t)}}}function d(o){const s=e.generateId(),d=o.placement||n.placement,m=function(o=n.placement){const s=o;if(c.has(s))return c.get(s);const a=e.createElement("div",{className:"message-container"}),r={position:"fixed",display:"flex",flexDirection:"column",gap:`${n.gap}px`,pointerEvents:"none",zIndex:String(e.Z_INDEX.TOAST)};switch(o){case"top":r.top=`${n.top}px`,r.left="50%",r.transform="translateX(-50%)";break;case"topLeft":r.top=`${n.top}px`,r.left=`${n.left}px`,r.alignItems="flex-start";break;case"topRight":r.top=`${n.top}px`,r.right=`${n.right}px`,r.alignItems="flex-end";break;case"bottom":r.bottom=`${n.bottom}px`,r.left="50%",r.transform="translateX(-50%)";break;case"bottomLeft":r.bottom=`${n.bottom}px`,r.left=`${n.left}px`,r.alignItems="flex-start";break;case"bottomRight":r.bottom=`${n.bottom}px`,r.right=`${n.right}px`,r.alignItems="flex-end";break;case"left":r.top="50%",r.left=`${n.left}px`,r.transform="translateY(-50%)",r.alignItems="flex-start";break;case"right":r.top="50%",r.right=`${n.right}px`,r.transform="translateY(-50%)",r.alignItems="flex-end"}Object.assign(a.style,r);const l=document.documentElement.getAttribute("data-theme");return l&&a.setAttribute("data-theme",l),document.body.appendChild(a),e.injectStyle("solely-message-styles",t.default),function(e){i&&i.disconnect(),i=new MutationObserver(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")}),i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}(a),c.set(s,a),a}(d),u=a.filter(e=>e.placement===d);if(u.length>=n.maxCount){const e=u[0];e&&p(e.id)}const f=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(r[o],o);s.appendChild(e)}const a=e.createElement("span",{className:"message__content"}),c=e.createElement("span",{className:"message__text"});if("string"==typeof t.content?c.textContent=t.content:t.content instanceof HTMLElement&&c.appendChild(t.content.cloneNode(!0)),a.appendChild(c),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)),a.appendChild(n)}if(s.appendChild(a),t.closable){const t=e.createElement("button",{className:"message__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}});t.onclick=()=>p(n),s.appendChild(t)}return s}(o,s);m.appendChild(f);const g={id:s,element:f,onClose:o.onClose,placement:d},b=o.duration??n.duration;return b>0&&(g.timer=window.setTimeout(()=>{p(s)},b)),a.push(g),{close:()=>p(s),update:t=>{if("string"==typeof t||t instanceof HTMLElement){const e=f.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=f.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=f.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=f.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 m={open:d,info:function(e,t){return d({content:e,type:"info",..."number"==typeof t?{duration:t}:t})},success:function(e,t){return d({content:e,type:"success",..."number"==typeof t?{duration:t}:t})},warning:function(e,t){return d({content:e,type:"warning",..."number"==typeof t?{duration:t}:t})},error:function(e,t){return d({content:e,type:"error",..."number"==typeof t?{duration:t}:t})},loading:function(e,t){return d(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),c.forEach((t,n)=>{void 0!==e.top&&["top","topLeft","topRight"].includes(n)&&(t.style.top=`${e.top}px`),void 0!==e.bottom&&["bottom","bottomLeft","bottomRight"].includes(n)&&(t.style.bottom=`${e.bottom}px`),void 0!==e.left&&["topLeft","bottomLeft","left"].includes(n)&&(t.style.left=`${e.left}px`),void 0!==e.right&&["topRight","bottomRight","right"].includes(n)&&(t.style.right=`${e.right}px`),void 0!==e.gap&&(t.style.gap=`${e.gap}px`)})},destroy:async function(){o&&(clearTimeout(o),o=void 0);const e=[...a];await Promise.all(e.map(e=>p(e.id)))}};exports.Message=m;
@@ -1 +1 @@
1
- import{createElement as t,addClosingAnimation as e,ANIMATION_DURATION as n,generateId as o,injectStyle as i}from"../utils.js";import s from"./style.css.js";const a={duration:3e3,maxCount:5,gap:8,top:24,bottom:24,left:24,right:24,placement:"top"};let r,c=null;const l=new Set,p=[],d={info:"ℹ",success:"✓",warning:"⚠",error:"✕",loading:t("span",{className:"message__loading-spinner"})},m=new Map;function f(e,n){const o=t("span",{className:`message__icon message__icon--${n}`});return"string"==typeof e?o.textContent=e:o.appendChild(e.cloneNode(!0)),o}async function u(t){var o;if(!l.has(t)){l.add(t);try{const s=p.findIndex(e=>e.id===t);if(-1===s)return;const a=p[s];a.timer&&(clearTimeout(a.timer),a.timer=void 0),await e(a.element,n.NORMAL),a.element.remove();const l=p.findIndex(e=>e.id===t);-1!==l&&p.splice(l,1);try{null==(o=a.onClose)||o.call(a)}catch(i){console.error("[Solely Message] onClose callback error:",i)}r&&clearTimeout(r),r=window.setTimeout(()=>{0===p.length&&(m.forEach((t,e)=>{0===t.childElementCount&&(t.remove(),m.delete(e))}),0===m.size&&c&&(c.disconnect(),c=null)),r=void 0},300)}finally{l.delete(t)}}}function g(e){const n=o(),r=e.placement||a.placement,l=function(e=a.placement){const n=e;if(m.has(n))return m.get(n);const o=t("div",{className:"message-container"}),r={position:"fixed",display:"flex",flexDirection:"column",gap:`${a.gap}px`,pointerEvents:"none",zIndex:"var(--solely-z-index-toast)"};switch(e){case"top":r.top=`${a.top}px`,r.left="50%",r.transform="translateX(-50%)";break;case"topLeft":r.top=`${a.top}px`,r.left=`${a.left}px`,r.alignItems="flex-start";break;case"topRight":r.top=`${a.top}px`,r.right=`${a.right}px`,r.alignItems="flex-end";break;case"bottom":r.bottom=`${a.bottom}px`,r.left="50%",r.transform="translateX(-50%)";break;case"bottomLeft":r.bottom=`${a.bottom}px`,r.left=`${a.left}px`,r.alignItems="flex-start";break;case"bottomRight":r.bottom=`${a.bottom}px`,r.right=`${a.right}px`,r.alignItems="flex-end";break;case"left":r.top="50%",r.left=`${a.left}px`,r.transform="translateY(-50%)",r.alignItems="flex-start";break;case"right":r.top="50%",r.right=`${a.right}px`,r.transform="translateY(-50%)",r.alignItems="flex-end"}Object.assign(o.style,r);const l=document.documentElement.getAttribute("data-theme");return l&&o.setAttribute("data-theme",l),document.body.appendChild(o),i("solely-message-styles",s),function(t){c&&c.disconnect(),c=new MutationObserver(()=>{const e=document.documentElement.getAttribute("data-theme");e?t.setAttribute("data-theme",e):t.removeAttribute("data-theme")}),c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}(o),m.set(n,o),o}(r),g=p.filter(t=>t.placement===r);if(g.length>=a.maxCount){const t=g[0];t&&u(t.id)}const b=function(e,n){const o=e.type||"info",i=!1!==e.showIcon,s=t("div",{className:`message message--${o}${e.className?` ${e.className}`:""}`,styles:e.style});if(s.setAttribute("role","error"===o||"warning"===o?"alert":"status"),s.setAttribute("aria-live","error"===o||"warning"===o?"assertive":"polite"),i){const t=e.icon?f(e.icon,o):f(d[o],o);s.appendChild(t)}const a=t("span",{className:"message__content"}),r=t("span",{className:"message__text"});if("string"==typeof e.content?r.textContent=e.content:e.content instanceof HTMLElement&&r.appendChild(e.content.cloneNode(!0)),a.appendChild(r),e.description){const n=t("span",{className:"message__description"});"string"==typeof e.description?n.textContent=e.description:e.description instanceof HTMLElement&&n.appendChild(e.description.cloneNode(!0)),a.appendChild(n)}if(s.appendChild(a),e.closable){const e=t("button",{className:"message__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}});e.onclick=()=>u(n),s.appendChild(e)}return s}(e,n);l.appendChild(b);const h={id:n,element:b,onClose:e.onClose,placement:r},y=e.duration??a.duration;return y>0&&(h.timer=window.setTimeout(()=>{u(n)},y)),p.push(h),{close:()=>u(n),update:e=>{if("string"==typeof e||e instanceof HTMLElement){const t=b.querySelector(".message__text");return void(t&&(t.innerHTML="","string"==typeof e?t.textContent=e:e instanceof HTMLElement&&t.appendChild(e.cloneNode(!0))))}if(void 0!==e.content){const t=b.querySelector(".message__text");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.description){let n=b.querySelector(".message__description");if(!n&&e.description){n=t("span",{className:"message__description"}),"string"==typeof e.description?n.textContent=e.description:e.description instanceof HTMLElement&&n.appendChild(e.description.cloneNode(!0));const o=b.querySelector(".message__content");null==o||o.appendChild(n)}else n&&(e.description?(n.innerHTML="","string"==typeof e.description?n.textContent=e.description:e.description instanceof HTMLElement&&n.appendChild(e.description.cloneNode(!0))):n.remove())}}}}const b={open:g,info:function(t,e){return g({content:t,type:"info",..."number"==typeof e?{duration:e}:e})},success:function(t,e){return g({content:t,type:"success",..."number"==typeof e?{duration:e}:e})},warning:function(t,e){return g({content:t,type:"warning",..."number"==typeof e?{duration:e}:e})},error:function(t,e){return g({content:t,type:"error",..."number"==typeof e?{duration:e}:e})},loading:function(t,e){return g(void 0===e?{content:t,type:"loading",duration:0,closable:!0}:"number"==typeof e?{content:t,type:"loading",duration:e,closable:!0}:{content:t,type:"loading",duration:0,closable:!0,...e})},config:function(t){Object.assign(a,t),m.forEach((e,n)=>{void 0!==t.top&&["top","topLeft","topRight"].includes(n)&&(e.style.top=`${t.top}px`),void 0!==t.bottom&&["bottom","bottomLeft","bottomRight"].includes(n)&&(e.style.bottom=`${t.bottom}px`),void 0!==t.left&&["topLeft","bottomLeft","left"].includes(n)&&(e.style.left=`${t.left}px`),void 0!==t.right&&["topRight","bottomRight","right"].includes(n)&&(e.style.right=`${t.right}px`),void 0!==t.gap&&(e.style.gap=`${t.gap}px`)})},destroy:async function(){r&&(clearTimeout(r),r=void 0);const t=[...p];await Promise.all(t.map(t=>u(t.id)))}};export{b as Message};
1
+ import{createElement as t,addClosingAnimation as e,ANIMATION_DURATION as n,Z_INDEX as o,generateId as i,injectStyle as s}from"../utils.js";import a from"./style.css.js";const r={duration:3e3,maxCount:5,gap:8,top:24,bottom:24,left:24,right:24,placement:"top"};let c,l=null;const p=new Set,d=[],m={info:"ℹ",success:"✓",warning:"⚠",error:"✕",loading:t("span",{className:"message__loading-spinner"})},f=new Map;function u(e,n){const o=t("span",{className:`message__icon message__icon--${n}`});return"string"==typeof e?o.textContent=e:o.appendChild(e.cloneNode(!0)),o}async function g(t){var o;if(!p.has(t)){p.add(t);try{const s=d.findIndex(e=>e.id===t);if(-1===s)return;const a=d[s];a.timer&&(clearTimeout(a.timer),a.timer=void 0),await e(a.element,n.NORMAL),a.element.remove();const r=d.findIndex(e=>e.id===t);-1!==r&&d.splice(r,1);try{null==(o=a.onClose)||o.call(a)}catch(i){console.error("[Solely Message] onClose callback error:",i)}c&&clearTimeout(c),c=window.setTimeout(()=>{0===d.length&&(f.forEach((t,e)=>{0===t.childElementCount&&(t.remove(),f.delete(e))}),0===f.size&&l&&(l.disconnect(),l=null)),c=void 0},300)}finally{p.delete(t)}}}function b(e){const n=i(),c=e.placement||r.placement,p=function(e=r.placement){const n=e;if(f.has(n))return f.get(n);const i=t("div",{className:"message-container"}),c={position:"fixed",display:"flex",flexDirection:"column",gap:`${r.gap}px`,pointerEvents:"none",zIndex:String(o.TOAST)};switch(e){case"top":c.top=`${r.top}px`,c.left="50%",c.transform="translateX(-50%)";break;case"topLeft":c.top=`${r.top}px`,c.left=`${r.left}px`,c.alignItems="flex-start";break;case"topRight":c.top=`${r.top}px`,c.right=`${r.right}px`,c.alignItems="flex-end";break;case"bottom":c.bottom=`${r.bottom}px`,c.left="50%",c.transform="translateX(-50%)";break;case"bottomLeft":c.bottom=`${r.bottom}px`,c.left=`${r.left}px`,c.alignItems="flex-start";break;case"bottomRight":c.bottom=`${r.bottom}px`,c.right=`${r.right}px`,c.alignItems="flex-end";break;case"left":c.top="50%",c.left=`${r.left}px`,c.transform="translateY(-50%)",c.alignItems="flex-start";break;case"right":c.top="50%",c.right=`${r.right}px`,c.transform="translateY(-50%)",c.alignItems="flex-end"}Object.assign(i.style,c);const p=document.documentElement.getAttribute("data-theme");return p&&i.setAttribute("data-theme",p),document.body.appendChild(i),s("solely-message-styles",a),function(t){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"]})}(i),f.set(n,i),i}(c),b=d.filter(t=>t.placement===c);if(b.length>=r.maxCount){const t=b[0];t&&g(t.id)}const h=function(e,n){const o=e.type||"info",i=!1!==e.showIcon,s=t("div",{className:`message message--${o}${e.className?` ${e.className}`:""}`,styles:e.style});if(s.setAttribute("role","error"===o||"warning"===o?"alert":"status"),s.setAttribute("aria-live","error"===o||"warning"===o?"assertive":"polite"),i){const t=e.icon?u(e.icon,o):u(m[o],o);s.appendChild(t)}const a=t("span",{className:"message__content"}),r=t("span",{className:"message__text"});if("string"==typeof e.content?r.textContent=e.content:e.content instanceof HTMLElement&&r.appendChild(e.content.cloneNode(!0)),a.appendChild(r),e.description){const n=t("span",{className:"message__description"});"string"==typeof e.description?n.textContent=e.description:e.description instanceof HTMLElement&&n.appendChild(e.description.cloneNode(!0)),a.appendChild(n)}if(s.appendChild(a),e.closable){const e=t("button",{className:"message__close",textContent:"×",attrs:{type:"button","aria-label":"关闭"}});e.onclick=()=>g(n),s.appendChild(e)}return s}(e,n);p.appendChild(h);const y={id:n,element:h,onClose:e.onClose,placement:c},x=e.duration??r.duration;return x>0&&(y.timer=window.setTimeout(()=>{g(n)},x)),d.push(y),{close:()=>g(n),update:e=>{if("string"==typeof e||e instanceof HTMLElement){const t=h.querySelector(".message__text");return void(t&&(t.innerHTML="","string"==typeof e?t.textContent=e:e instanceof HTMLElement&&t.appendChild(e.cloneNode(!0))))}if(void 0!==e.content){const t=h.querySelector(".message__text");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.description){let n=h.querySelector(".message__description");if(!n&&e.description){n=t("span",{className:"message__description"}),"string"==typeof e.description?n.textContent=e.description:e.description instanceof HTMLElement&&n.appendChild(e.description.cloneNode(!0));const o=h.querySelector(".message__content");null==o||o.appendChild(n)}else n&&(e.description?(n.innerHTML="","string"==typeof e.description?n.textContent=e.description:e.description instanceof HTMLElement&&n.appendChild(e.description.cloneNode(!0))):n.remove())}}}}const h={open:b,info:function(t,e){return b({content:t,type:"info",..."number"==typeof e?{duration:e}:e})},success:function(t,e){return b({content:t,type:"success",..."number"==typeof e?{duration:e}:e})},warning:function(t,e){return b({content:t,type:"warning",..."number"==typeof e?{duration:e}:e})},error:function(t,e){return b({content:t,type:"error",..."number"==typeof e?{duration:e}:e})},loading:function(t,e){return b(void 0===e?{content:t,type:"loading",duration:0,closable:!0}:"number"==typeof e?{content:t,type:"loading",duration:e,closable:!0}:{content:t,type:"loading",duration:0,closable:!0,...e})},config:function(t){Object.assign(r,t),f.forEach((e,n)=>{void 0!==t.top&&["top","topLeft","topRight"].includes(n)&&(e.style.top=`${t.top}px`),void 0!==t.bottom&&["bottom","bottomLeft","bottomRight"].includes(n)&&(e.style.bottom=`${t.bottom}px`),void 0!==t.left&&["topLeft","bottomLeft","left"].includes(n)&&(e.style.left=`${t.left}px`),void 0!==t.right&&["topRight","bottomRight","right"].includes(n)&&(e.style.right=`${t.right}px`),void 0!==t.gap&&(e.style.gap=`${t.gap}px`)})},destroy:async function(){c&&(clearTimeout(c),c=void 0);const t=[...d];await Promise.all(t.map(t=>g(t.id)))}};export{h as Message};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),a=require("../../../runtime/component/base-element.cjs"),s=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyCheckbox=class extends a.default{getCheckboxClasses(){const e={},t=this.$data.size||"medium",a=this.$data.type||"primary";return"small"===t?e["checkbox--sm"]=!0:"large"===t?e["checkbox--lg"]=!0:e["checkbox--md"]=!0,e[`checkbox--${a}`]=!0,e["is-checked"]=!!this.$data.checked,e["is-indeterminate"]=!!this.$data.indeterminate,e["is-disabled"]=!!this.$data.disabled,e["checkbox--block"]=!!this.$data.block,e}handleClick(e){this.$data.disabled||(this.toggle(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleKeyDown(e){this.$data.disabled||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick(e))}toggle(){if(this.$data.disabled)return;const e=!this.$data.checked;this.$data.checked=e,this.$data.indeterminate&&(this.$data.indeterminate=!1),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}setChecked(e){this.$data.checked=e,this.$data.indeterminate=!1}getChecked(){return this.$data.checked}get checked(){return this.$data.checked}set checked(e){this.setChecked(e)}setIndeterminate(e){this.$data.indeterminate=e}focus(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&t.focus()}blur(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&t.blur()}mounted(){this.updateAriaAttributes()}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&(t.setAttribute("aria-checked",this.$data.checked?"true":"false"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}},exports.SolelyCheckbox=((e,t)=>{for(var a,s=t,d=e.length-1;d>=0;d--)(a=e[d])&&(s=a(s)||s);return s})([s.CustomElement({tagName:"solely-checkbox",template:t.default,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"checked",type:"boolean",default:!1},{name:"indeterminate",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"content",type:"string",default:""},{name:"type",type:"string",default:"primary"},{name:"size",type:"string",default:"medium"},{name:"block",type:"boolean",default:!1},{name:"name",type:"string",default:""}],model:{prop:"checked",event:"change"}})],exports.SolelyCheckbox);
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),a=require("../../../runtime/component/base-element.cjs"),s=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyCheckbox=class extends a.default{getCheckboxClasses(){const e={},t=this.$data.size||"medium",a=this.$data.type||"primary";return"small"===t?e["checkbox--sm"]=!0:"large"===t?e["checkbox--lg"]=!0:e["checkbox--md"]=!0,e[`checkbox--${a}`]=!0,e["is-checked"]=!!this.$data.checked,e["is-indeterminate"]=!!this.$data.indeterminate,e["is-disabled"]=!!this.$data.disabled,e["checkbox--block"]=!!this.$data.block,e}handleClick(e){this.$data.disabled||this.toggle()}handleKeyDown(e){this.$data.disabled||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick(e))}toggle(){if(this.$data.disabled)return;const e=!this.$data.checked;this.$data.checked=e,this.$data.indeterminate&&(this.$data.indeterminate=!1),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}setChecked(e){this.$data.checked=e,this.$data.indeterminate=!1}getChecked(){return this.$data.checked}get checked(){return this.$data.checked}set checked(e){this.setChecked(e)}setIndeterminate(e){this.$data.indeterminate=e}focus(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&t.focus()}blur(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&t.blur()}mounted(){this.updateAriaAttributes()}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&(t.setAttribute("aria-checked",this.$data.checked?"true":"false"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}},exports.SolelyCheckbox=((e,t)=>{for(var a,s=t,d=e.length-1;d>=0;d--)(a=e[d])&&(s=a(s)||s);return s})([s.CustomElement({tagName:"solely-checkbox",template:t.default,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"checked",type:"boolean",default:!1},{name:"indeterminate",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"content",type:"string",default:""},{name:"type",type:"string",default:"primary"},{name:"size",type:"string",default:"medium"},{name:"block",type:"boolean",default:!1},{name:"name",type:"string",default:""}],model:{prop:"checked",event:"change"}})],exports.SolelyCheckbox);
@@ -1 +1 @@
1
- import e from"./style.css.js";import t from"./index.html.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as s}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let d=class extends a{getCheckboxClasses(){const e={},t=this.$data.size||"medium",a=this.$data.type||"primary";return"small"===t?e["checkbox--sm"]=!0:"large"===t?e["checkbox--lg"]=!0:e["checkbox--md"]=!0,e[`checkbox--${a}`]=!0,e["is-checked"]=!!this.$data.checked,e["is-indeterminate"]=!!this.$data.indeterminate,e["is-disabled"]=!!this.$data.disabled,e["checkbox--block"]=!!this.$data.block,e}handleClick(e){this.$data.disabled||(this.toggle(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleKeyDown(e){this.$data.disabled||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick(e))}toggle(){if(this.$data.disabled)return;const e=!this.$data.checked;this.$data.checked=e,this.$data.indeterminate&&(this.$data.indeterminate=!1),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}setChecked(e){this.$data.checked=e,this.$data.indeterminate=!1}getChecked(){return this.$data.checked}get checked(){return this.$data.checked}set checked(e){this.setChecked(e)}setIndeterminate(e){this.$data.indeterminate=e}focus(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&t.focus()}blur(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&t.blur()}mounted(){this.updateAriaAttributes()}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&(t.setAttribute("aria-checked",this.$data.checked?"true":"false"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}};d=((e,t)=>{for(var a,s=t,d=e.length-1;d>=0;d--)(a=e[d])&&(s=a(s)||s);return s})([s({tagName:"solely-checkbox",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"checked",type:"boolean",default:!1},{name:"indeterminate",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"content",type:"string",default:""},{name:"type",type:"string",default:"primary"},{name:"size",type:"string",default:"medium"},{name:"block",type:"boolean",default:!1},{name:"name",type:"string",default:""}],model:{prop:"checked",event:"change"}})],d);export{d as SolelyCheckbox};
1
+ import e from"./style.css.js";import t from"./index.html.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as d}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let s=class extends a{getCheckboxClasses(){const e={},t=this.$data.size||"medium",a=this.$data.type||"primary";return"small"===t?e["checkbox--sm"]=!0:"large"===t?e["checkbox--lg"]=!0:e["checkbox--md"]=!0,e[`checkbox--${a}`]=!0,e["is-checked"]=!!this.$data.checked,e["is-indeterminate"]=!!this.$data.indeterminate,e["is-disabled"]=!!this.$data.disabled,e["checkbox--block"]=!!this.$data.block,e}handleClick(e){this.$data.disabled||this.toggle()}handleKeyDown(e){this.$data.disabled||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick(e))}toggle(){if(this.$data.disabled)return;const e=!this.$data.checked;this.$data.checked=e,this.$data.indeterminate&&(this.$data.indeterminate=!1),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}setChecked(e){this.$data.checked=e,this.$data.indeterminate=!1}getChecked(){return this.$data.checked}get checked(){return this.$data.checked}set checked(e){this.setChecked(e)}setIndeterminate(e){this.$data.indeterminate=e}focus(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&t.focus()}blur(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&t.blur()}mounted(){this.updateAriaAttributes()}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".checkbox");t&&(t.setAttribute("aria-checked",this.$data.checked?"true":"false"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}};s=((e,t)=>{for(var a,d=t,s=e.length-1;s>=0;s--)(a=e[s])&&(d=a(d)||d);return d})([d({tagName:"solely-checkbox",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"checked",type:"boolean",default:!1},{name:"indeterminate",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"content",type:"string",default:""},{name:"type",type:"string",default:"primary"},{name:"size",type:"string",default:"medium"},{name:"block",type:"boolean",default:!1},{name:"name",type:"string",default:""}],model:{prop:"checked",event:"change"}})],s);export{s as SolelyCheckbox};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),a=require("../utils/helpers.cjs"),s=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyPagination=class extends s.default{get current(){return this.$data.current}set current(e){this.$data.current=e,this.calculateVisiblePages(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get pageSize(){return this.$data.pageSize}set pageSize(e){this.$data.pageSize=e,this.calculateVisiblePages(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getPaginationClasses(){const e={};return"small"===this.$data.size?e["pagination--sm"]=!0:"large"===this.$data.size?e["pagination--lg"]=!0:e["pagination--md"]=!0,e["is-disabled"]=!!this.$data.disabled,e}getPrevClasses(){return{"pagination__item--disabled":(this.$data.current||1)<=1}}getNextClasses(){return{"pagination__item--disabled":(this.$data.current||1)>=this.totalPages}}getItemClasses(e){return{"pagination__item--active":e===this.$data.current}}mounted(){this.$data.jumperValue="",this.parsePageSizeOptions(),this.calculateVisiblePages()}parsePageSizeOptions(){this.$data.parsedPageSizeOptions=a.safeJsonParse(this.$data.pageSizeOptions,[10,20,50,100])}get totalPages(){return Math.ceil((this.$data.total||0)/(this.$data.pageSize||10))}calculateVisiblePages(){const e=this.$data.current||1,t=this.totalPages,a=[];if(t<=7)for(let s=1;s<=t;s++)a.push(s);else e<=3?a.push(1,2,3,4,5,"...",t):e>=t-2?a.push(1,"...",t-4,t-3,t-2,t-1,t):a.push(1,"...",e-1,e,e+1,"...",t);this.$data.visiblePages=a}handlePageClick(e){this.$data.disabled||e===this.$data.current||(this.$data.current=e,this.calculateVisiblePages(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:e,pageSize:this.$data.pageSize}})))}handlePrev(){this.$data.disabled||this.$data.current<=1||this.handlePageClick(this.$data.current-1)}handleNext(){this.$data.disabled||this.$data.current>=this.totalPages||this.handlePageClick(this.$data.current+1)}handleSizeChange(e){if(this.$data.disabled)return;const t=e.target,a=parseInt(t.value,10);this.$data.pageSize=a,this.$data.current=1,this.calculateVisiblePages(),this.dispatchEvent(new CustomEvent("showSizeChange",{bubbles:!0,composed:!0,detail:{current:1,pageSize:a}}))}handleJumperKeydown(e){if("Enter"!==e.key)return;const t=e.target,a=parseInt(t.value,10);a>=1&&a<=this.totalPages&&this.handlePageClick(a),this.$data.jumperValue=""}handleJumperStep(e){if(this.$data.disabled)return;const t=this.$data.current+e;t>=1&&t<=this.totalPages&&(this.handlePageClick(t),this.$data.jumperValue=String(t))}setCurrent(e){this.$data.current=e,this.calculateVisiblePages()}getCurrent(){return this.$data.current}},exports.SolelyPagination=((e,t)=>{for(var a,s=t,i=e.length-1;i>=0;i--)(a=e[i])&&(s=a(s)||s);return s})([i.CustomElement({tagName:"solely-pagination",template:t.default,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"current",type:"number",default:1},{name:"total",type:"number",default:0},{name:"pageSize",type:"number",default:10},{name:"size",type:"string",default:"default"},{name:"simple",type:"boolean",default:!1},{name:"showQuickJumper",type:"boolean",default:!1},{name:"showSizeChanger",type:"boolean",default:!1},{name:"pageSizeOptions",type:"string",default:"[10, 20, 50, 100]"},{name:"disabled",type:"boolean",default:!1},{name:"showTotal",type:"boolean",default:!1}]})],exports.SolelyPagination);
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),a=require("../utils/helpers.cjs"),s=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyPagination=class extends s.default{get current(){return this.$data.current}set current(e){this.$data.current=e,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get pageSize(){return this.$data.pageSize}set pageSize(e){this.$data.pageSize=e,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getPaginationClasses(){const e={};return"small"===this.$data.size?e["pagination--sm"]=!0:"large"===this.$data.size?e["pagination--lg"]=!0:e["pagination--md"]=!0,e["is-disabled"]=!!this.$data.disabled,e}getPrevClasses(){return{"pagination__item--disabled":(this.$data.current||1)<=1}}getNextClasses(){return{"pagination__item--disabled":(this.$data.current||1)>=this.totalPages}}getItemClasses(e){return{"pagination__item--active":e===this.$data.current}}mounted(){this.$data.jumperValue="",this.parsePageSizeOptions()}parsePageSizeOptions(){this.$data.parsedPageSizeOptions=a.safeJsonParse(this.$data.pageSizeOptions,[10,20,50,100])}get totalPages(){return Math.ceil((this.$data.total||0)/(this.$data.pageSize||10))}calculateVisiblePages(){const e=this.$data.current||1,t=this.totalPages,a=[];if(t<=7)for(let s=1;s<=t;s++)a.push(s);else e<=3?a.push(1,2,3,4,5,"...",t):e>=t-2?a.push(1,"...",t-4,t-3,t-2,t-1,t):a.push(1,"...",e-1,e,e+1,"...",t);return a}handlePageClick(e){this.$data.disabled||e===this.$data.current||(this.$data.current=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:e,pageSize:this.$data.pageSize}})))}handlePrev(){this.$data.disabled||this.$data.current<=1||this.handlePageClick(this.$data.current-1)}handleNext(){this.$data.disabled||this.$data.current>=this.totalPages||this.handlePageClick(this.$data.current+1)}handleSizeChange(e){if(this.$data.disabled)return;const t=e.target,a=parseInt(t.value,10);this.$data.pageSize=a,this.$data.current=1,this.dispatchEvent(new CustomEvent("showSizeChange",{bubbles:!0,composed:!0,detail:{current:1,pageSize:a}}))}handleJumperKeydown(e){if("Enter"!==e.key)return;const t=e.target,a=parseInt(t.value,10);a>=1&&a<=this.totalPages&&this.handlePageClick(a),this.$data.jumperValue=""}handleJumperStep(e){if(this.$data.disabled)return;const t=this.$data.current+e;t>=1&&t<=this.totalPages&&(this.handlePageClick(t),this.$data.jumperValue=String(t))}setCurrent(e){this.$data.current=e}getCurrent(){return this.$data.current}},exports.SolelyPagination=((e,t)=>{for(var a,s=t,i=e.length-1;i>=0;i--)(a=e[i])&&(s=a(s)||s);return s})([i.CustomElement({tagName:"solely-pagination",template:t.default,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"current",type:"number",default:1},{name:"total",type:"number",default:0},{name:"pageSize",type:"number",default:10},{name:"size",type:"string",default:"default"},{name:"simple",type:"boolean",default:!1},{name:"showQuickJumper",type:"boolean",default:!1},{name:"showSizeChanger",type:"boolean",default:!1},{name:"pageSizeOptions",type:"string",default:"[10, 20, 50, 100]"},{name:"disabled",type:"boolean",default:!1},{name:"showTotal",type:"boolean",default:!1}]})],exports.SolelyPagination);
@@ -1,7 +1,6 @@
1
1
  import { BaseElement } from '../../../runtime/component';
2
2
  import { PaginationProps } from './types';
3
3
  declare class SolelyPagination extends BaseElement<PaginationProps & {
4
- visiblePages: (number | string)[];
5
4
  parsedPageSizeOptions: number[];
6
5
  }> {
7
6
  /**
@@ -42,7 +41,7 @@ declare class SolelyPagination extends BaseElement<PaginationProps & {
42
41
  /**
43
42
  * 计算可见页码
44
43
  */
45
- calculateVisiblePages(): void;
44
+ calculateVisiblePages(): (number | string)[];
46
45
  /**
47
46
  * 页码点击
48
47
  */
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div\n class="pagination"\n :class="this.getPaginationClasses()"\n>\n \x3c!-- 总数 --\x3e\n <If test="$data.showTotal">\n <span class="pagination__total">\n 共 {{$data.total}} 条\n </span>\n </If>\n\n \x3c!-- 上一页 --\x3e\n <span\n class="pagination__prev"\n :class="this.getPrevClasses()"\n @click="this.handlePrev(event)"\n >\n &lt;\n </span>\n\n \x3c!-- 页码 --\x3e\n <For each="$data.visiblePages" item="page">\n <If test="page !== \'...\'">\n <span\n class="pagination__item"\n :class="this.getItemClasses(page)"\n @click="this.handlePageClick(page, event)"\n >\n {{page}}\n </span>\n </If>\n <If test="page === \'...\'">\n <span class="pagination__ellipsis">...</span>\n </If>\n </For>\n\n \x3c!-- 下一页 --\x3e\n <span\n class="pagination__next"\n :class="this.getNextClasses()"\n @click="this.handleNext(event)"\n >\n &gt;\n </span>\n\n \x3c!-- 每页条数选择器 --\x3e\n <If test="$data.showSizeChanger">\n <span class="pagination__size-changer">\n <select @change="this.handleSizeChange(event)">\n <For each="$data.parsedPageSizeOptions" item="size">\n <option\n :value="size"\n :selected="size === $data.pageSize"\n >\n {{size}} 条/页\n </option>\n </For>\n </select>\n </span>\n </If>\n\n \x3c!-- 快速跳转 --\x3e\n <If test="$data.showQuickJumper">\n <span class="pagination__jumper">\n 跳至\n <span class="pagination__jumper-input-wrapper">\n <input\n type="number"\n min="1"\n :max="$data.totalPages"\n s-model="$data.jumperValue"\n @keydown="this.handleJumperKeydown(event)"\n />\n <span class="pagination__jumper-controls">\n <span class="pagination__jumper-up" @click="this.handleJumperStep(1)">▲</span>\n <span class="pagination__jumper-down" @click="this.handleJumperStep(-1)">▼</span>\n </span>\n </span>\n 页\n </span>\n </If>\n</div>\n';
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default='<div\n class="pagination"\n :class="this.getPaginationClasses()"\n>\n \x3c!-- 总数 --\x3e\n <If test="$data.showTotal">\n <span class="pagination__total">\n 共 {{$data.total}} 条\n </span>\n </If>\n\n \x3c!-- 上一页 --\x3e\n <span\n class="pagination__prev"\n :class="this.getPrevClasses()"\n @click="this.handlePrev(event)"\n >\n &lt;\n </span>\n\n \x3c!-- 页码 --\x3e\n <For each="this.calculateVisiblePages()" item="page">\n <If test="page !== \'...\'">\n <span\n class="pagination__item"\n :class="this.getItemClasses(page)"\n @click="this.handlePageClick(page, event)"\n >\n {{page}}\n </span>\n </If>\n <If test="page === \'...\'">\n <span class="pagination__ellipsis">...</span>\n </If>\n </For>\n\n \x3c!-- 下一页 --\x3e\n <span\n class="pagination__next"\n :class="this.getNextClasses()"\n @click="this.handleNext(event)"\n >\n &gt;\n </span>\n\n \x3c!-- 每页条数选择器 --\x3e\n <If test="$data.showSizeChanger">\n <span class="pagination__size-changer">\n <select @change="this.handleSizeChange(event)">\n <For each="$data.parsedPageSizeOptions" item="size">\n <option\n :value="size"\n :selected="size === $data.pageSize"\n >\n {{size}} 条/页\n </option>\n </For>\n </select>\n </span>\n </If>\n\n \x3c!-- 快速跳转 --\x3e\n <If test="$data.showQuickJumper">\n <span class="pagination__jumper">\n 跳至\n <span class="pagination__jumper-input-wrapper">\n <input\n type="number"\n min="1"\n :max="$data.totalPages"\n s-model="$data.jumperValue"\n @keydown="this.handleJumperKeydown(event)"\n />\n <span class="pagination__jumper-controls">\n <span class="pagination__jumper-up" @click="this.handleJumperStep(1)">▲</span>\n <span class="pagination__jumper-down" @click="this.handleJumperStep(-1)">▼</span>\n </span>\n </span>\n 页\n </span>\n </If>\n</div>\n';
@@ -1 +1 @@
1
- const n='<div\n class="pagination"\n :class="this.getPaginationClasses()"\n>\n \x3c!-- 总数 --\x3e\n <If test="$data.showTotal">\n <span class="pagination__total">\n 共 {{$data.total}} 条\n </span>\n </If>\n\n \x3c!-- 上一页 --\x3e\n <span\n class="pagination__prev"\n :class="this.getPrevClasses()"\n @click="this.handlePrev(event)"\n >\n &lt;\n </span>\n\n \x3c!-- 页码 --\x3e\n <For each="$data.visiblePages" item="page">\n <If test="page !== \'...\'">\n <span\n class="pagination__item"\n :class="this.getItemClasses(page)"\n @click="this.handlePageClick(page, event)"\n >\n {{page}}\n </span>\n </If>\n <If test="page === \'...\'">\n <span class="pagination__ellipsis">...</span>\n </If>\n </For>\n\n \x3c!-- 下一页 --\x3e\n <span\n class="pagination__next"\n :class="this.getNextClasses()"\n @click="this.handleNext(event)"\n >\n &gt;\n </span>\n\n \x3c!-- 每页条数选择器 --\x3e\n <If test="$data.showSizeChanger">\n <span class="pagination__size-changer">\n <select @change="this.handleSizeChange(event)">\n <For each="$data.parsedPageSizeOptions" item="size">\n <option\n :value="size"\n :selected="size === $data.pageSize"\n >\n {{size}} 条/页\n </option>\n </For>\n </select>\n </span>\n </If>\n\n \x3c!-- 快速跳转 --\x3e\n <If test="$data.showQuickJumper">\n <span class="pagination__jumper">\n 跳至\n <span class="pagination__jumper-input-wrapper">\n <input\n type="number"\n min="1"\n :max="$data.totalPages"\n s-model="$data.jumperValue"\n @keydown="this.handleJumperKeydown(event)"\n />\n <span class="pagination__jumper-controls">\n <span class="pagination__jumper-up" @click="this.handleJumperStep(1)">▲</span>\n <span class="pagination__jumper-down" @click="this.handleJumperStep(-1)">▼</span>\n </span>\n </span>\n 页\n </span>\n </If>\n</div>\n';export{n as default};
1
+ const n='<div\n class="pagination"\n :class="this.getPaginationClasses()"\n>\n \x3c!-- 总数 --\x3e\n <If test="$data.showTotal">\n <span class="pagination__total">\n 共 {{$data.total}} 条\n </span>\n </If>\n\n \x3c!-- 上一页 --\x3e\n <span\n class="pagination__prev"\n :class="this.getPrevClasses()"\n @click="this.handlePrev(event)"\n >\n &lt;\n </span>\n\n \x3c!-- 页码 --\x3e\n <For each="this.calculateVisiblePages()" item="page">\n <If test="page !== \'...\'">\n <span\n class="pagination__item"\n :class="this.getItemClasses(page)"\n @click="this.handlePageClick(page, event)"\n >\n {{page}}\n </span>\n </If>\n <If test="page === \'...\'">\n <span class="pagination__ellipsis">...</span>\n </If>\n </For>\n\n \x3c!-- 下一页 --\x3e\n <span\n class="pagination__next"\n :class="this.getNextClasses()"\n @click="this.handleNext(event)"\n >\n &gt;\n </span>\n\n \x3c!-- 每页条数选择器 --\x3e\n <If test="$data.showSizeChanger">\n <span class="pagination__size-changer">\n <select @change="this.handleSizeChange(event)">\n <For each="$data.parsedPageSizeOptions" item="size">\n <option\n :value="size"\n :selected="size === $data.pageSize"\n >\n {{size}} 条/页\n </option>\n </For>\n </select>\n </span>\n </If>\n\n \x3c!-- 快速跳转 --\x3e\n <If test="$data.showQuickJumper">\n <span class="pagination__jumper">\n 跳至\n <span class="pagination__jumper-input-wrapper">\n <input\n type="number"\n min="1"\n :max="$data.totalPages"\n s-model="$data.jumperValue"\n @keydown="this.handleJumperKeydown(event)"\n />\n <span class="pagination__jumper-controls">\n <span class="pagination__jumper-up" @click="this.handleJumperStep(1)">▲</span>\n <span class="pagination__jumper-down" @click="this.handleJumperStep(-1)">▼</span>\n </span>\n </span>\n 页\n </span>\n </If>\n</div>\n';export{n as default};
@@ -1 +1 @@
1
- import e from"./style.css.js";import t from"./index.html.js";import{safeJsonParse as a}from"../utils/helpers.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let n=class extends s{get current(){return this.$data.current}set current(e){this.$data.current=e,this.calculateVisiblePages(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get pageSize(){return this.$data.pageSize}set pageSize(e){this.$data.pageSize=e,this.calculateVisiblePages(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getPaginationClasses(){const e={};return"small"===this.$data.size?e["pagination--sm"]=!0:"large"===this.$data.size?e["pagination--lg"]=!0:e["pagination--md"]=!0,e["is-disabled"]=!!this.$data.disabled,e}getPrevClasses(){return{"pagination__item--disabled":(this.$data.current||1)<=1}}getNextClasses(){return{"pagination__item--disabled":(this.$data.current||1)>=this.totalPages}}getItemClasses(e){return{"pagination__item--active":e===this.$data.current}}mounted(){this.$data.jumperValue="",this.parsePageSizeOptions(),this.calculateVisiblePages()}parsePageSizeOptions(){this.$data.parsedPageSizeOptions=a(this.$data.pageSizeOptions,[10,20,50,100])}get totalPages(){return Math.ceil((this.$data.total||0)/(this.$data.pageSize||10))}calculateVisiblePages(){const e=this.$data.current||1,t=this.totalPages,a=[];if(t<=7)for(let s=1;s<=t;s++)a.push(s);else e<=3?a.push(1,2,3,4,5,"...",t):e>=t-2?a.push(1,"...",t-4,t-3,t-2,t-1,t):a.push(1,"...",e-1,e,e+1,"...",t);this.$data.visiblePages=a}handlePageClick(e){this.$data.disabled||e===this.$data.current||(this.$data.current=e,this.calculateVisiblePages(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:e,pageSize:this.$data.pageSize}})))}handlePrev(){this.$data.disabled||this.$data.current<=1||this.handlePageClick(this.$data.current-1)}handleNext(){this.$data.disabled||this.$data.current>=this.totalPages||this.handlePageClick(this.$data.current+1)}handleSizeChange(e){if(this.$data.disabled)return;const t=e.target,a=parseInt(t.value,10);this.$data.pageSize=a,this.$data.current=1,this.calculateVisiblePages(),this.dispatchEvent(new CustomEvent("showSizeChange",{bubbles:!0,composed:!0,detail:{current:1,pageSize:a}}))}handleJumperKeydown(e){if("Enter"!==e.key)return;const t=e.target,a=parseInt(t.value,10);a>=1&&a<=this.totalPages&&this.handlePageClick(a),this.$data.jumperValue=""}handleJumperStep(e){if(this.$data.disabled)return;const t=this.$data.current+e;t>=1&&t<=this.totalPages&&(this.handlePageClick(t),this.$data.jumperValue=String(t))}setCurrent(e){this.$data.current=e,this.calculateVisiblePages()}getCurrent(){return this.$data.current}};n=((e,t)=>{for(var a,s=t,i=e.length-1;i>=0;i--)(a=e[i])&&(s=a(s)||s);return s})([i({tagName:"solely-pagination",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"current",type:"number",default:1},{name:"total",type:"number",default:0},{name:"pageSize",type:"number",default:10},{name:"size",type:"string",default:"default"},{name:"simple",type:"boolean",default:!1},{name:"showQuickJumper",type:"boolean",default:!1},{name:"showSizeChanger",type:"boolean",default:!1},{name:"pageSizeOptions",type:"string",default:"[10, 20, 50, 100]"},{name:"disabled",type:"boolean",default:!1},{name:"showTotal",type:"boolean",default:!1}]})],n);export{n as SolelyPagination};
1
+ import e from"./style.css.js";import t from"./index.html.js";import{safeJsonParse as a}from"../utils/helpers.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let n=class extends s{get current(){return this.$data.current}set current(e){this.$data.current=e,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get pageSize(){return this.$data.pageSize}set pageSize(e){this.$data.pageSize=e,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getPaginationClasses(){const e={};return"small"===this.$data.size?e["pagination--sm"]=!0:"large"===this.$data.size?e["pagination--lg"]=!0:e["pagination--md"]=!0,e["is-disabled"]=!!this.$data.disabled,e}getPrevClasses(){return{"pagination__item--disabled":(this.$data.current||1)<=1}}getNextClasses(){return{"pagination__item--disabled":(this.$data.current||1)>=this.totalPages}}getItemClasses(e){return{"pagination__item--active":e===this.$data.current}}mounted(){this.$data.jumperValue="",this.parsePageSizeOptions()}parsePageSizeOptions(){this.$data.parsedPageSizeOptions=a(this.$data.pageSizeOptions,[10,20,50,100])}get totalPages(){return Math.ceil((this.$data.total||0)/(this.$data.pageSize||10))}calculateVisiblePages(){const e=this.$data.current||1,t=this.totalPages,a=[];if(t<=7)for(let s=1;s<=t;s++)a.push(s);else e<=3?a.push(1,2,3,4,5,"...",t):e>=t-2?a.push(1,"...",t-4,t-3,t-2,t-1,t):a.push(1,"...",e-1,e,e+1,"...",t);return a}handlePageClick(e){this.$data.disabled||e===this.$data.current||(this.$data.current=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:e,pageSize:this.$data.pageSize}})))}handlePrev(){this.$data.disabled||this.$data.current<=1||this.handlePageClick(this.$data.current-1)}handleNext(){this.$data.disabled||this.$data.current>=this.totalPages||this.handlePageClick(this.$data.current+1)}handleSizeChange(e){if(this.$data.disabled)return;const t=e.target,a=parseInt(t.value,10);this.$data.pageSize=a,this.$data.current=1,this.dispatchEvent(new CustomEvent("showSizeChange",{bubbles:!0,composed:!0,detail:{current:1,pageSize:a}}))}handleJumperKeydown(e){if("Enter"!==e.key)return;const t=e.target,a=parseInt(t.value,10);a>=1&&a<=this.totalPages&&this.handlePageClick(a),this.$data.jumperValue=""}handleJumperStep(e){if(this.$data.disabled)return;const t=this.$data.current+e;t>=1&&t<=this.totalPages&&(this.handlePageClick(t),this.$data.jumperValue=String(t))}setCurrent(e){this.$data.current=e}getCurrent(){return this.$data.current}};n=((e,t)=>{for(var a,s=t,i=e.length-1;i>=0;i--)(a=e[i])&&(s=a(s)||s);return s})([i({tagName:"solely-pagination",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"current",type:"number",default:1},{name:"total",type:"number",default:0},{name:"pageSize",type:"number",default:10},{name:"size",type:"string",default:"default"},{name:"simple",type:"boolean",default:!1},{name:"showQuickJumper",type:"boolean",default:!1},{name:"showSizeChanger",type:"boolean",default:!1},{name:"pageSizeOptions",type:"string",default:"[10, 20, 50, 100]"},{name:"disabled",type:"boolean",default:!1},{name:"showTotal",type:"boolean",default:!1}]})],n);export{n as SolelyPagination};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),s=require("./index.html.cjs"),n=require("../utils/helpers.cjs"),a=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyTree=class extends a.default{constructor(){var t;super(...arguments),((t,s,n)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n})(this,"symbol"!=typeof(t="treeData")?t+"":t,[])}getTreeClasses(){return{"tree--show-line":!!this.$data.showLine}}getNodeClasses(e){const t={"tree__node--filtered":!!e.isFiltered,"tree__node--last-child":!!e.isLastChild};return void 0!==e.level&&(t[`tree__node--level-${e.level}`]=!0),t}getContentClasses(e){return{"tree__content--selected":!!e.selected,"tree__content--disabled":!!e.disabled}}getSwitcherClasses(e){return{"tree__switcher--expanded":!!e.expanded,"tree__switcher--leaf":!e.children||0===e.children.length}}getCheckboxClasses(e){return{"tree__checkbox--checked":!!e.checked,"tree__checkbox--half-checked":!!e.halfChecked,"tree__checkbox--disabled":!!e.disabled}}getTitleClasses(e){return{"tree__title--highlight":!!e.highlight}}mounted(){this.parseTreeData()}parseTreeData(){this.treeData=n.safeJsonParse(this.$data.treeData,[]),this.flattenTree()}flattenTree(){const e=[],t=this.$data.searchable?(this.$data.searchValue||"").toLowerCase():"",s=(n,a)=>{for(let r=0;r<n.length;r++){const d=n[r],c=d.children&&d.children.length>0,h=this.$data.defaultExpandAll||d.expanded,i=t&&d.title.toLowerCase().includes(t),l={...d,level:a,expanded:h,isFiltered:!(!t||i||this.hasMatchingDescendant(d,t)),highlight:!!i,isLastChild:r===n.length-1};e.push(l),c&&h&&d.children&&s(d.children,a+1)}};s(this.treeData,0),this.$data.flattenedTree=e}hasMatchingDescendant(e,t){if(!e.children||0===e.children.length)return!1;for(const s of e.children){if(s.title.toLowerCase().includes(t))return!0;if(this.hasMatchingDescendant(s,t))return!0}return!1}handleToggle(e,t){if(t.stopPropagation(),this.$data.disabled)return;const s=this.findNode(this.treeData,e.key);s&&(s.expanded=!s.expanded,this.flattenTree(),this.emit("expand",{expandedKeys:this.getExpandedKeys(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleNodeClick(e){if(this.$data.disabled||e.disabled)return;this.$data.multiple||this.clearSelection();const t=this.findNode(this.treeData,e.key);t&&(t.selected=!t.selected,this.flattenTree(),this.emit("select",{selectedKeys:this.getSelectedKeys(),selectedNodes:this.getSelectedNodes(),node:t}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleCheck(e,t){if(t.stopPropagation(),this.$data.disabled||e.disabled)return;const s=this.findNode(this.treeData,e.key);if(s){const e=!s.checked;this.updateNodeCheckState(s,e),this.flattenTree(),this.emit("check",{checkedKeys:this.getCheckedKeys(),checkedNodes:this.getCheckedNodes(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}updateNodeCheckState(e,t){if(e.checked=t,e.halfChecked=!1,e.children)for(const s of e.children)this.updateNodeCheckState(s,t);this.updateParentCheckState(this.treeData,e)}updateParentCheckState(e,t){for(const s of e)if(s.children){if(s.children.includes(t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}if(this.updateParentCheckState(s.children,t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}}return!1}findNode(e,t){for(const s of e){if(s.key===t)return s;if(s.children){const e=this.findNode(s.children,t);if(e)return e}}return null}clearSelection(){const e=t=>{for(const s of t)s.selected=!1,s.children&&e(s.children)};e(this.treeData)}getCheckedKeys(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set checkedKeys(e){const t=e=>{for(const s of e)s.checked=!1,s.halfChecked=!1,s.children&&t(s.children)};t(this.treeData);const s=(e,t)=>{for(const n of e)t.includes(n.key)&&(n.checked=!0),n.children&&s(n.children,t)};s(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getExpandedKeys(){const e=[],t=s=>{for(const n of s)n.expanded&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set expandedKeys(e){const t=s=>{for(const n of s)n.expanded=e.includes(n.key),n.children&&t(n.children)};t(this.treeData),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getSelectedKeys(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}getSelectedNodes(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}getCheckedNodes(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}setTreeData(e){this.treeData=e,this.$data.treeData=JSON.stringify(e),this.flattenTree()}getTreeData(){return this.treeData}},exports.SolelyTree=((e,t)=>{for(var s,n=t,a=e.length-1;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n})([r.CustomElement({tagName:"solely-tree",template:s.default,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"treeData",type:"string"},{name:"showLine",type:"boolean",default:!1},{name:"multiple",type:"boolean",default:!1},{name:"checkable",type:"boolean",default:!1},{name:"defaultExpandAll",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"searchable",type:"boolean",default:!1},{name:"searchValue",type:"string"},{name:"block",type:"boolean",default:!1}]})],exports.SolelyTree);
1
+ "use strict";var e=Object.defineProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),s=require("./index.html.cjs"),n=require("../utils/helpers.cjs"),a=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyTree=class extends a.default{constructor(){var t;super(...arguments),((t,s,n)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n})(this,"symbol"!=typeof(t="treeData")?t+"":t,[])}getTreeClasses(){return{"tree--show-line":!!this.$data.showLine}}getNodeClasses(e){const t={"tree__node--filtered":!!e.isFiltered,"tree__node--last-child":!!e.isLastChild};return void 0!==e.level&&(t[`tree__node--level-${e.level}`]=!0),t}getContentClasses(e){return{"tree__content--selected":!!e.selected,"tree__content--disabled":!!e.disabled}}getSwitcherClasses(e){return{"tree__switcher--expanded":!!e.expanded,"tree__switcher--leaf":!e.children||0===e.children.length}}getCheckboxClasses(e){return{"tree__checkbox--checked":!!e.checked,"tree__checkbox--half-checked":!!e.halfChecked,"tree__checkbox--disabled":!!e.disabled}}getTitleClasses(e){return{"tree__title--highlight":!!e.highlight}}mounted(){this.parseTreeData()}parseTreeData(){this.treeData=n.safeJsonParse(this.$data.treeData,[]),this.flattenTree()}flattenTree(){const e=[],t=this.$data.searchable?(this.$data.searchValue||"").toLowerCase():"",s=(n,a)=>{for(let r=0;r<n.length;r++){const d=n[r],c=d.children&&d.children.length>0,h=this.$data.defaultExpandAll||d.expanded,i=t&&d.title.toLowerCase().includes(t),l={...d,level:a,expanded:h,isFiltered:!(!t||i||this.hasMatchingDescendant(d,t)),highlight:!!i,isLastChild:r===n.length-1};e.push(l),c&&h&&d.children&&s(d.children,a+1)}};s(this.treeData,0),this.$data.flattenedTree=e}hasMatchingDescendant(e,t){if(!e.children||0===e.children.length)return!1;for(const s of e.children){if(s.title.toLowerCase().includes(t))return!0;if(this.hasMatchingDescendant(s,t))return!0}return!1}handleToggle(e,t){if(t.stopPropagation(),this.$data.disabled)return;const s=this.findNode(this.treeData,e.key);s&&(s.expanded=!s.expanded,this.flattenTree(),this.emit("expand",{expandedKeys:this.getExpandedKeys(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleNodeClick(e){if(this.$data.disabled||e.disabled)return;this.$data.multiple||this.clearSelection();const t=this.findNode(this.treeData,e.key);t&&(t.selected=!t.selected,this.flattenTree(),this.emit("select",{selectedKeys:this.getSelectedKeys(),selectedNodes:this.getSelectedNodes(),node:t}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleCheck(e,t){if(t.stopPropagation(),this.$data.disabled||e.disabled)return;const s=this.findNode(this.treeData,e.key);if(s){const e=!s.checked;this.updateNodeCheckState(s,e),this.flattenTree(),this.emit("check",{checkedKeys:this.getCheckedKeys(),checkedNodes:this.getCheckedNodes(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}updateNodeCheckState(e,t){if(e.checked=t,e.halfChecked=!1,e.children)for(const s of e.children)this.updateNodeCheckState(s,t);this.updateParentCheckState(this.treeData,e)}updateParentCheckState(e,t){for(const s of e)if(s.children){if(s.children.includes(t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}if(this.updateParentCheckState(s.children,t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}}return!1}findNode(e,t){for(const s of e){if(s.key===t)return s;if(s.children){const e=this.findNode(s.children,t);if(e)return e}}return null}clearSelection(){const e=t=>{for(const s of t)s.selected=!1,s.children&&e(s.children)};e(this.treeData)}getCheckedKeys(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set checkedKeys(e){const t=e=>{for(const s of e)s.checked=!1,s.halfChecked=!1,s.children&&t(s.children)};t(this.treeData);const s=(e,t)=>{for(const n of e)t.includes(n.key)&&(n.checked=!0),n.children&&s(n.children,t)};s(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getExpandedKeys(){const e=[],t=s=>{for(const n of s)n.expanded&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set expandedKeys(e){const t=s=>{for(const n of s)n.expanded=e.includes(n.key),n.children&&t(n.children)};t(this.treeData),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getSelectedKeys(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}getSelectedNodes(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}getCheckedNodes(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}setTreeData(e){this.treeData=e,this.$data.treeData=JSON.stringify(e),this.flattenTree()}getTreeData(){return this.treeData}get value(){return this.getSelectedKeys()}set value(e){this.clearSelection();const t=(e,s)=>{for(const n of e)s.includes(n.key)&&(n.selected=!0),n.children&&t(n.children,s)};t(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get selectedKeys(){return this.getSelectedKeys()}set selectedKeys(e){this.value=e}},exports.SolelyTree=((e,t)=>{for(var s,n=t,a=e.length-1;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n})([r.CustomElement({tagName:"solely-tree",template:s.default,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"treeData",type:"string"},{name:"showLine",type:"boolean",default:!1},{name:"multiple",type:"boolean",default:!1},{name:"checkable",type:"boolean",default:!1},{name:"defaultExpandAll",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"searchable",type:"boolean",default:!1},{name:"searchValue",type:"string"},{name:"block",type:"boolean",default:!1}]})],exports.SolelyTree);
@@ -122,6 +122,16 @@ declare class SolelyTree extends BaseElement<TreeProps & {
122
122
  * 获取树形数据
123
123
  */
124
124
  getTreeData(): TreeNode[];
125
+ /**
126
+ * 暴露 value 属性,使外部可通过 event.target.value 访问选中节点 key
127
+ */
128
+ get value(): string[];
129
+ set value(keys: string[]);
130
+ /**
131
+ * selectedKeys getter/setter(与 checkedKeys/expandedKeys 对称)
132
+ */
133
+ get selectedKeys(): string[];
134
+ set selectedKeys(keys: string[]);
125
135
  }
126
136
  export default SolelyTree;
127
137
  export { SolelyTree };
@@ -1 +1 @@
1
- var e=Object.defineProperty;import t from"./style.css.js";import s from"./index.html.js";import{safeJsonParse as n}from"../utils/helpers.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as d}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends a{constructor(){var t;super(...arguments),((t,s,n)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n})(this,"symbol"!=typeof(t="treeData")?t+"":t,[])}getTreeClasses(){return{"tree--show-line":!!this.$data.showLine}}getNodeClasses(e){const t={"tree__node--filtered":!!e.isFiltered,"tree__node--last-child":!!e.isLastChild};return void 0!==e.level&&(t[`tree__node--level-${e.level}`]=!0),t}getContentClasses(e){return{"tree__content--selected":!!e.selected,"tree__content--disabled":!!e.disabled}}getSwitcherClasses(e){return{"tree__switcher--expanded":!!e.expanded,"tree__switcher--leaf":!e.children||0===e.children.length}}getCheckboxClasses(e){return{"tree__checkbox--checked":!!e.checked,"tree__checkbox--half-checked":!!e.halfChecked,"tree__checkbox--disabled":!!e.disabled}}getTitleClasses(e){return{"tree__title--highlight":!!e.highlight}}mounted(){this.parseTreeData()}parseTreeData(){this.treeData=n(this.$data.treeData,[]),this.flattenTree()}flattenTree(){const e=[],t=this.$data.searchable?(this.$data.searchValue||"").toLowerCase():"",s=(n,a)=>{for(let d=0;d<n.length;d++){const r=n[d],h=r.children&&r.children.length>0,c=this.$data.defaultExpandAll||r.expanded,i=t&&r.title.toLowerCase().includes(t),l={...r,level:a,expanded:c,isFiltered:!(!t||i||this.hasMatchingDescendant(r,t)),highlight:!!i,isLastChild:d===n.length-1};e.push(l),h&&c&&r.children&&s(r.children,a+1)}};s(this.treeData,0),this.$data.flattenedTree=e}hasMatchingDescendant(e,t){if(!e.children||0===e.children.length)return!1;for(const s of e.children){if(s.title.toLowerCase().includes(t))return!0;if(this.hasMatchingDescendant(s,t))return!0}return!1}handleToggle(e,t){if(t.stopPropagation(),this.$data.disabled)return;const s=this.findNode(this.treeData,e.key);s&&(s.expanded=!s.expanded,this.flattenTree(),this.emit("expand",{expandedKeys:this.getExpandedKeys(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleNodeClick(e){if(this.$data.disabled||e.disabled)return;this.$data.multiple||this.clearSelection();const t=this.findNode(this.treeData,e.key);t&&(t.selected=!t.selected,this.flattenTree(),this.emit("select",{selectedKeys:this.getSelectedKeys(),selectedNodes:this.getSelectedNodes(),node:t}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleCheck(e,t){if(t.stopPropagation(),this.$data.disabled||e.disabled)return;const s=this.findNode(this.treeData,e.key);if(s){const e=!s.checked;this.updateNodeCheckState(s,e),this.flattenTree(),this.emit("check",{checkedKeys:this.getCheckedKeys(),checkedNodes:this.getCheckedNodes(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}updateNodeCheckState(e,t){if(e.checked=t,e.halfChecked=!1,e.children)for(const s of e.children)this.updateNodeCheckState(s,t);this.updateParentCheckState(this.treeData,e)}updateParentCheckState(e,t){for(const s of e)if(s.children){if(s.children.includes(t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}if(this.updateParentCheckState(s.children,t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}}return!1}findNode(e,t){for(const s of e){if(s.key===t)return s;if(s.children){const e=this.findNode(s.children,t);if(e)return e}}return null}clearSelection(){const e=t=>{for(const s of t)s.selected=!1,s.children&&e(s.children)};e(this.treeData)}getCheckedKeys(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set checkedKeys(e){const t=e=>{for(const s of e)s.checked=!1,s.halfChecked=!1,s.children&&t(s.children)};t(this.treeData);const s=(e,t)=>{for(const n of e)t.includes(n.key)&&(n.checked=!0),n.children&&s(n.children,t)};s(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getExpandedKeys(){const e=[],t=s=>{for(const n of s)n.expanded&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set expandedKeys(e){const t=s=>{for(const n of s)n.expanded=e.includes(n.key),n.children&&t(n.children)};t(this.treeData),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getSelectedKeys(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}getSelectedNodes(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}getCheckedNodes(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}setTreeData(e){this.treeData=e,this.$data.treeData=JSON.stringify(e),this.flattenTree()}getTreeData(){return this.treeData}};r=((e,t)=>{for(var s,n=t,a=e.length-1;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n})([d({tagName:"solely-tree",template:s,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"treeData",type:"string"},{name:"showLine",type:"boolean",default:!1},{name:"multiple",type:"boolean",default:!1},{name:"checkable",type:"boolean",default:!1},{name:"defaultExpandAll",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"searchable",type:"boolean",default:!1},{name:"searchValue",type:"string"},{name:"block",type:"boolean",default:!1}]})],r);export{r as SolelyTree};
1
+ var e=Object.defineProperty;import t from"./style.css.js";import s from"./index.html.js";import{safeJsonParse as n}from"../utils/helpers.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as d}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends a{constructor(){var t;super(...arguments),((t,s,n)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n})(this,"symbol"!=typeof(t="treeData")?t+"":t,[])}getTreeClasses(){return{"tree--show-line":!!this.$data.showLine}}getNodeClasses(e){const t={"tree__node--filtered":!!e.isFiltered,"tree__node--last-child":!!e.isLastChild};return void 0!==e.level&&(t[`tree__node--level-${e.level}`]=!0),t}getContentClasses(e){return{"tree__content--selected":!!e.selected,"tree__content--disabled":!!e.disabled}}getSwitcherClasses(e){return{"tree__switcher--expanded":!!e.expanded,"tree__switcher--leaf":!e.children||0===e.children.length}}getCheckboxClasses(e){return{"tree__checkbox--checked":!!e.checked,"tree__checkbox--half-checked":!!e.halfChecked,"tree__checkbox--disabled":!!e.disabled}}getTitleClasses(e){return{"tree__title--highlight":!!e.highlight}}mounted(){this.parseTreeData()}parseTreeData(){this.treeData=n(this.$data.treeData,[]),this.flattenTree()}flattenTree(){const e=[],t=this.$data.searchable?(this.$data.searchValue||"").toLowerCase():"",s=(n,a)=>{for(let d=0;d<n.length;d++){const r=n[d],c=r.children&&r.children.length>0,h=this.$data.defaultExpandAll||r.expanded,i=t&&r.title.toLowerCase().includes(t),l={...r,level:a,expanded:h,isFiltered:!(!t||i||this.hasMatchingDescendant(r,t)),highlight:!!i,isLastChild:d===n.length-1};e.push(l),c&&h&&r.children&&s(r.children,a+1)}};s(this.treeData,0),this.$data.flattenedTree=e}hasMatchingDescendant(e,t){if(!e.children||0===e.children.length)return!1;for(const s of e.children){if(s.title.toLowerCase().includes(t))return!0;if(this.hasMatchingDescendant(s,t))return!0}return!1}handleToggle(e,t){if(t.stopPropagation(),this.$data.disabled)return;const s=this.findNode(this.treeData,e.key);s&&(s.expanded=!s.expanded,this.flattenTree(),this.emit("expand",{expandedKeys:this.getExpandedKeys(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleNodeClick(e){if(this.$data.disabled||e.disabled)return;this.$data.multiple||this.clearSelection();const t=this.findNode(this.treeData,e.key);t&&(t.selected=!t.selected,this.flattenTree(),this.emit("select",{selectedKeys:this.getSelectedKeys(),selectedNodes:this.getSelectedNodes(),node:t}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleCheck(e,t){if(t.stopPropagation(),this.$data.disabled||e.disabled)return;const s=this.findNode(this.treeData,e.key);if(s){const e=!s.checked;this.updateNodeCheckState(s,e),this.flattenTree(),this.emit("check",{checkedKeys:this.getCheckedKeys(),checkedNodes:this.getCheckedNodes(),node:s}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}updateNodeCheckState(e,t){if(e.checked=t,e.halfChecked=!1,e.children)for(const s of e.children)this.updateNodeCheckState(s,t);this.updateParentCheckState(this.treeData,e)}updateParentCheckState(e,t){for(const s of e)if(s.children){if(s.children.includes(t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}if(this.updateParentCheckState(s.children,t)){const e=s.children.every(e=>e.checked),t=s.children.some(e=>e.checked||e.halfChecked);return s.checked=e,s.halfChecked=!e&&t,!0}}return!1}findNode(e,t){for(const s of e){if(s.key===t)return s;if(s.children){const e=this.findNode(s.children,t);if(e)return e}}return null}clearSelection(){const e=t=>{for(const s of t)s.selected=!1,s.children&&e(s.children)};e(this.treeData)}getCheckedKeys(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set checkedKeys(e){const t=e=>{for(const s of e)s.checked=!1,s.halfChecked=!1,s.children&&t(s.children)};t(this.treeData);const s=(e,t)=>{for(const n of e)t.includes(n.key)&&(n.checked=!0),n.children&&s(n.children,t)};s(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getExpandedKeys(){const e=[],t=s=>{for(const n of s)n.expanded&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}set expandedKeys(e){const t=s=>{for(const n of s)n.expanded=e.includes(n.key),n.children&&t(n.children)};t(this.treeData),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getSelectedKeys(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n.key),n.children&&t(n.children)};return t(this.treeData),e}getSelectedNodes(){const e=[],t=s=>{for(const n of s)n.selected&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}getCheckedNodes(){const e=[],t=s=>{for(const n of s)n.checked&&e.push(n),n.children&&t(n.children)};return t(this.treeData),e}setTreeData(e){this.treeData=e,this.$data.treeData=JSON.stringify(e),this.flattenTree()}getTreeData(){return this.treeData}get value(){return this.getSelectedKeys()}set value(e){this.clearSelection();const t=(e,s)=>{for(const n of e)s.includes(n.key)&&(n.selected=!0),n.children&&t(n.children,s)};t(this.treeData,e),this.flattenTree(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}get selectedKeys(){return this.getSelectedKeys()}set selectedKeys(e){this.value=e}};r=((e,t)=>{for(var s,n=t,a=e.length-1;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n})([d({tagName:"solely-tree",template:s,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"treeData",type:"string"},{name:"showLine",type:"boolean",default:!1},{name:"multiple",type:"boolean",default:!1},{name:"checkable",type:"boolean",default:!1},{name:"defaultExpandAll",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"searchable",type:"boolean",default:!1},{name:"searchValue",type:"string"},{name:"block",type:"boolean",default:!1}]})],r);export{r as SolelyTree};
@@ -0,0 +1,14 @@
1
+ Bootstrap Icons License
2
+ =======================
3
+
4
+ The file bootstrap-icons.svg in this directory is from Bootstrap Icons:
5
+ https://github.com/twbs/icons
6
+
7
+ License: MIT License
8
+ Copyright (c) 2019-2024 The Bootstrap Authors
9
+
10
+ See the project's NOTICE file or https://github.com/twbs/icons/blob/main/LICENSE
11
+ for the full license text.
12
+
13
+ This file is used for demonstration purposes only and is not bundled with
14
+ the published npm package.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.4.5",
4
+ "version": "0.4.6",
5
5
  "description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
6
6
  "type": "module",
7
7
  "sideEffects": false,