solely 0.4.13 → 0.4.15

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 (60) hide show
  1. package/dist/components/commands/modal/index.cjs +1 -1
  2. package/dist/components/commands/modal/index.js +1 -1
  3. package/dist/components/commands/modal/types.d.ts +4 -2
  4. package/dist/components/elements/alert/index.cjs +1 -1
  5. package/dist/components/elements/alert/index.d.ts +2 -0
  6. package/dist/components/elements/alert/index.js +1 -1
  7. package/dist/components/elements/breadcrumb/index.cjs +1 -1
  8. package/dist/components/elements/breadcrumb/index.js +1 -1
  9. package/dist/components/elements/coordinate-input/index.cjs +1 -1
  10. package/dist/components/elements/coordinate-input/index.d.ts +2 -2
  11. package/dist/components/elements/coordinate-input/index.js +1 -1
  12. package/dist/components/elements/input/index.cjs +1 -1
  13. package/dist/components/elements/input/index.d.ts +1 -1
  14. package/dist/components/elements/input/index.js +1 -1
  15. package/dist/components/elements/pagination/index.cjs +1 -1
  16. package/dist/components/elements/pagination/index.js +1 -1
  17. package/dist/components/elements/radio/index.cjs +1 -1
  18. package/dist/components/elements/radio/index.d.ts +3 -0
  19. package/dist/components/elements/radio/index.js +1 -1
  20. package/dist/components/elements/rate/index.cjs +1 -1
  21. package/dist/components/elements/rate/index.d.ts +4 -0
  22. package/dist/components/elements/rate/index.js +1 -1
  23. package/dist/components/elements/select/index.cjs +1 -1
  24. package/dist/components/elements/select/index.d.ts +2 -0
  25. package/dist/components/elements/select/index.js +1 -1
  26. package/dist/components/elements/slider/index.cjs +1 -1
  27. package/dist/components/elements/slider/index.d.ts +8 -1
  28. package/dist/components/elements/slider/index.js +1 -1
  29. package/dist/components/elements/steps/index.cjs +1 -1
  30. package/dist/components/elements/steps/index.d.ts +1 -0
  31. package/dist/components/elements/steps/index.js +1 -1
  32. package/dist/components/elements/tabs/index.cjs +1 -1
  33. package/dist/components/elements/tabs/index.js +1 -1
  34. package/dist/components/elements/tooltip/index.d.ts +4 -0
  35. package/dist/components/elements/upload/index.cjs +1 -1
  36. package/dist/components/elements/upload/index.d.ts +3 -0
  37. package/dist/components/elements/upload/index.js +1 -1
  38. package/dist/index.cjs +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/runtime/component/base-element.cjs +1 -1
  41. package/dist/runtime/component/base-element.js +1 -1
  42. package/dist/runtime/component/decorators.cjs +1 -1
  43. package/dist/runtime/component/decorators.js +1 -1
  44. package/dist/runtime/reactivity/observe.cjs +1 -1
  45. package/dist/runtime/reactivity/observe.js +1 -1
  46. package/dist/runtime/renderer/html-decode.cjs +1 -1
  47. package/dist/runtime/renderer/html-decode.d.ts +1 -2
  48. package/dist/runtime/renderer/html-decode.js +1 -1
  49. package/dist/runtime/renderer/renderIR.cjs +1 -1
  50. package/dist/runtime/renderer/renderIR.js +1 -1
  51. package/dist/shared/case-convert.cjs +1 -0
  52. package/dist/shared/case-convert.d.ts +1 -0
  53. package/dist/shared/case-convert.js +1 -0
  54. package/dist/shared/index.cjs +1 -1
  55. package/dist/shared/index.d.ts +1 -0
  56. package/dist/shared/index.js +1 -1
  57. package/dist/shared/is-object.cjs +1 -1
  58. package/dist/shared/is-object.d.ts +0 -5
  59. package/dist/shared/is-object.js +1 -1
  60. package/package.json +1 -1
@@ -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:"取消"},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",part:"wrap"}}),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":"关闭",part:"close"}}),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"}),w=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]});w.appendChild(t)}const N=e.createElement("div");"string"==typeof a.content?N.textContent=a.content||"":a.content instanceof HTMLElement&&N.appendChild(a.content.cloneNode(!0)),w.appendChild(N),g.appendChild(w),C.appendChild(g);const _=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),_.appendChild(n)});else{if(u){const e=d(a.cancelText||n.cancelText,"default",()=>{var e;s(i),null==(e=a.onCancel)||e.call(a)});_.appendChild(e)}const t=d(a.okText||n.okText,a.okType||"primary",async()=>{a.onOk&&!1===await e.safeAsyncCallback(()=>a.onOk())||s(i)});_.appendChild(t)}C.appendChild(_),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
+ "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=[],o=new Set;let a=null;const c={info:"ℹ",success:"✓",warning:"⚠",error:"✕",confirm:"?"};async function s(t){var n;if(!o.has(t)){o.add(t);try{const o=l.findIndex(e=>e.id===t);if(-1===o)return;const a=l[o],c=a.element.querySelector(".modal-mask"),s=a.element.querySelector(".modal");c&&c.classList.add("is-closing"),s&&s.classList.add("is-closing"),await e.addClosingAnimation(a.element,e.ANIMATION_DURATION.NORMAL),null==(n=a.cleanup)||n.call(a);const i=l.findIndex(e=>e.id===t);-1!==i&&(l[i].element.remove(),l.splice(i,1))}finally{o.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,o=!1){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(o?t.cloneNode(!0):t),a.onclick=()=>e.safeAsyncCallback(l),a}function r(o){const i=e.generateId();e.injectStyle("solely-modal-styles",t.default);const r=o.type||"info",m=o.width??n.width,u=o.showCancel??"confirm"===r,p=o.maskClosable??n.maskClosable,f=e.createElement("div",{className:"modal-wrap",attrs:{tabIndex:"-1",part:"wrap"}}),y=function(e){return(()=>{const t=document.documentElement.getAttribute("data-theme");t?e.setAttribute("data-theme",t):e.removeAttribute("data-theme")})(),a||(a=new MutationObserver(()=>{l.forEach(e=>{const t=document.documentElement.getAttribute("data-theme");t?e.element.setAttribute("data-theme",t):e.element.removeAttribute("data-theme")})}),a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})),()=>{a&&0===l.length&&(a.disconnect(),a=null)}}(f),h=[];if(!1!==o.mask){const t=e.createElement("div",{className:"modal-mask"});if(p){const e=()=>{var e;s(i),null==(e=o.onCancel)||e.call(o)};t.onclick=e,h.push({element:t,type:"click",handler:e})}f.appendChild(t)}const C=e.createElement("div",{className:"modal"+(o.className?` ${o.className}`:""),styles:{...o.style,width:"number"==typeof m?`${m}px`:m}}),b=e.createElement("div",{className:"modal__header"}),E=e.createElement("h3",{className:"modal__title"});if("string"==typeof o.title)E.textContent=o.title||"";else if(o.title instanceof HTMLElement){const e=o.cloneElement??!1;E.appendChild(e?o.title.cloneNode(!0):o.title)}if(b.appendChild(E),!1!==o.closable){const t=e.createElement("button",{className:"modal__close",textContent:"×",attrs:{type:"button","aria-label":"关闭",part:"close"}}),n=()=>{var e;s(i),null==(e=o.onClose)||e.call(o)};t.onclick=n,h.push({element:t,type:"click",handler:n}),b.appendChild(t)}C.appendChild(b);const _=e.createElement("div",{className:"modal__body"}),v=e.createElement("div",{className:"modal__content-wrapper"});if(!1!==o.showIcon){const t=e.createElement("span",{className:`modal__icon modal__icon--${r}`,textContent:c[r]});v.appendChild(t)}const N=e.createElement("div",{className:"modal__content"});if("string"==typeof o.content)N.textContent=o.content||"";else if(o.content instanceof HTMLElement){const e=o.cloneElement??!1;N.appendChild(e?o.content.cloneNode(!0):o.content)}v.appendChild(N),_.appendChild(v),C.appendChild(_);const g=e.createElement("div",{className:"modal__footer"});if(o.buttons&&o.buttons.length>0)o.buttons.forEach(t=>{const n=d(t.text,t.type||"default",async()=>{await e.safeAsyncCallback(()=>t.onClick())},o.cloneElement);t.style&&Object.assign(n.style,t.style),g.appendChild(n)});else{if(u){const e=d(o.cancelText||n.cancelText,"default",()=>{var e;s(i),null==(e=o.onCancel)||e.call(o)},o.cloneElement);g.appendChild(e)}const t=d(o.okText||n.okText,o.okType||"primary",async()=>{o.onOk&&!1===await e.safeAsyncCallback(()=>o.onOk())||s(i)},o.cloneElement);g.appendChild(t)}C.appendChild(g),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 w={close:()=>{var e;s(i),null==(e=o.onClose)||e.call(o)},update:e=>{if(void 0!==e.title){const t=f.querySelector(".modal__title");if(t)if(t.innerHTML="","string"==typeof e.title)t.textContent=e.title;else if(e.title instanceof HTMLElement){const n=e.cloneElement??!1;t.appendChild(n?e.title.cloneNode(!0):e.title)}}if(void 0!==e.content){const t=f.querySelector(".modal__content");if(t)if(t.innerHTML="","string"==typeof e.content)t.textContent=e.content;else if(e.content instanceof HTMLElement){const n=e.cloneElement??!1;t.appendChild(n?e.content.cloneNode(!0):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)}}},k=l.find(e=>e.id===i);return k&&(k.instance=w),w}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 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",part:"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(()=>{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":"关闭",part:"close"}}),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};
1
+ import{createElement as e,safeAsyncCallback as t,injectStyle as n,addClosingAnimation as l,ANIMATION_DURATION as o,generateId as a}from"../utils.js";import c from"./style.css.js";const s={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 a=i[n],c=a.element.querySelector(".modal-mask"),s=a.element.querySelector(".modal");c&&c.classList.add("is-closing"),s&&s.classList.add("is-closing"),await l(a.element,o.NORMAL),null==(t=a.cleanup)||t.call(a);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(n,l,o,a=!1){const c=e("button",{className:`modal__btn modal__btn--${"default"===l?"default":l}`,attrs:{type:"button"}});return"string"==typeof n?c.textContent=n:n instanceof HTMLElement&&c.appendChild(a?n.cloneNode(!0):n),c.onclick=()=>t(o),c}function h(l){const o=a();n("solely-modal-styles",c);const d=l.type||"info",u=l.width??s.width,h=l.showCancel??"confirm"===d,y=l.maskClosable??s.maskClosable,C=e("div",{className:"modal-wrap",attrs:{tabIndex:"-1",part:"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(()=>{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),_=[];if(!1!==l.mask){const t=e("div",{className:"modal-mask"});if(y){const e=()=>{var e;p(o),null==(e=l.onCancel)||e.call(l)};t.onclick=e,_.push({element:t,type:"click",handler:e})}C.appendChild(t)}const v=e("div",{className:"modal"+(l.className?` ${l.className}`:""),styles:{...l.style,width:"number"==typeof u?`${u}px`:u}}),w=e("div",{className:"modal__header"}),N=e("h3",{className:"modal__title"});if("string"==typeof l.title)N.textContent=l.title||"";else if(l.title instanceof HTMLElement){const e=l.cloneElement??!1;N.appendChild(e?l.title.cloneNode(!0):l.title)}if(w.appendChild(N),!1!==l.closable){const t=e("button",{className:"modal__close",textContent:"×",attrs:{type:"button","aria-label":"关闭",part:"close"}}),n=()=>{var e;p(o),null==(e=l.onClose)||e.call(l)};t.onclick=n,_.push({element:t,type:"click",handler:n}),w.appendChild(t)}v.appendChild(w);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",{className:"modal__content"});if("string"==typeof l.content)k.textContent=l.content||"";else if(l.content instanceof HTMLElement){const e=l.cloneElement??!1;k.appendChild(e?l.content.cloneNode(!0):l.content)}x.appendChild(k),g.appendChild(x),v.appendChild(g);const E=e("div",{className:"modal__footer"});if(l.buttons&&l.buttons.length>0)l.buttons.forEach(e=>{const n=f(e.text,e.type||"default",async()=>{await t(()=>e.onClick())},l.cloneElement);e.style&&Object.assign(n.style,e.style),E.appendChild(n)});else{if(h){const e=f(l.cancelText||s.cancelText,"default",()=>{var e;p(o),null==(e=l.onCancel)||e.call(l)},l.cloneElement);E.appendChild(e)}const e=f(l.okText||s.okText,l.okType||"primary",async()=>{l.onOk&&!1===await t(()=>l.onOk())||p(o)},l.cloneElement);E.appendChild(e)}v.appendChild(E),C.appendChild(v),document.body.appendChild(C),i.push({id:o,element:C,instance:null,cleanup:()=>{_.forEach(({element:e,type:t,handler:n})=>{e.removeEventListener(t,n)}),b()}});const T={close:()=>{var e;p(o),null==(e=l.onClose)||e.call(l)},update:e=>{if(void 0!==e.title){const t=C.querySelector(".modal__title");if(t)if(t.innerHTML="","string"==typeof e.title)t.textContent=e.title;else if(e.title instanceof HTMLElement){const n=e.cloneElement??!1;t.appendChild(n?e.title.cloneNode(!0):e.title)}}if(void 0!==e.content){const t=C.querySelector(".modal__content");if(t)if(t.innerHTML="","string"==typeof e.content)t.textContent=e.content;else if(e.content instanceof HTMLElement){const n=e.cloneElement??!1;t.appendChild(n?e.content.cloneNode(!0):e.content)}}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===o);return L&&(L.instance=T),T}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(s,e)},destroy:async function(){for(;i.length>0;)await u()}};export{y as Modal};
@@ -39,8 +39,8 @@ export interface ModalOptions {
39
39
  showCancel?: boolean;
40
40
  /** 自定义按钮数组(如果提供,将忽略 okText/cancelText/showCancel) */
41
41
  buttons?: ModalButton[];
42
- /** 确定按钮回调 */
43
- onOk?: () => void | Promise<void>;
42
+ /** 确定按钮回调 - 返回 false 阻止关闭,返回 HTMLElement 或数据作为结果 */
43
+ onOk?: () => void | false | HTMLElement | Record<string, unknown> | Promise<void | false | HTMLElement | Record<string, unknown>>;
44
44
  /** 取消按钮回调 */
45
45
  onCancel?: () => void;
46
46
  /** 关闭后回调 */
@@ -49,6 +49,8 @@ export interface ModalOptions {
49
49
  className?: string;
50
50
  /** 自定义样式 */
51
51
  style?: Partial<CSSStyleDeclaration>;
52
+ /** 是否克隆传入的 HTMLElement,默认 false(不克隆) */
53
+ cloneElement?: boolean;
52
54
  }
53
55
  export interface ModalInstance {
54
56
  /** 关闭弹窗 */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),s=require("../../../runtime/component/base-element.cjs"),o=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyAlert=class extends s.default{getAlertClasses(){return{[`alert--${this.$data.type}`]:!!this.$data.type,"is-closing":this.$data.closing,"alert--block":!!this.$data.block}}getIcon(e){const t={info:"ℹ",success:"✓",warning:"⚠",error:"✕"};return t[e]||t.info}mounted(){this.refresh()}handleClose(){this.$data.closing=!0,this.emit("close"),setTimeout(()=>{this.remove()},300)}setMessage(e){this.$data.message=e}setType(e){this.$data.type=e}},exports.SolelyAlert=((e,t)=>{for(var s,o=t,a=e.length-1;a>=0;a--)(s=e[a])&&(o=s(o)||o);return o})([o.CustomElement({tagName:"solely-alert",template:t.__SOLELY_IR__,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"info"},{name:"message",type:"string",default:""},{name:"description",type:"string",default:""},{name:"closable",type:"boolean",default:!1},{name:"showIcon",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelyAlert);
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"),o=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyAlert=class extends o.default{constructor(){var t,s;super(...arguments),((t,s,o)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[s]=o})(this,"symbol"!=typeof(t="closeTimer")?t+"":t,s)}getAlertClasses(){return{[`alert--${this.$data.type}`]:!!this.$data.type,"is-closing":this.$data.closing,"alert--block":!!this.$data.block}}getIcon(e){const t={info:"ℹ",success:"✓",warning:"⚠",error:"✕"};return t[e]||t.info}mounted(){this.refresh()}unmounted(){this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=void 0)}handleClose(){this.$data.closing=!0,this.emit("close"),this.closeTimer=setTimeout(()=>{this.remove()},300)}setMessage(e){this.$data.message=e}setType(e){this.$data.type=e}},exports.SolelyAlert=((e,t)=>{for(var s,o=t,r=e.length-1;r>=0;r--)(s=e[r])&&(o=s(o)||o);return o})([r.CustomElement({tagName:"solely-alert",template:s.__SOLELY_IR__,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"info"},{name:"message",type:"string",default:""},{name:"description",type:"string",default:""},{name:"closable",type:"boolean",default:!1},{name:"showIcon",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelyAlert);
@@ -3,6 +3,7 @@ import { AlertProps } from './types';
3
3
  declare class SolelyAlert extends BaseElement<AlertProps & {
4
4
  closing: boolean;
5
5
  }> {
6
+ private closeTimer?;
6
7
  /**
7
8
  * 获取 alert class 对象
8
9
  */
@@ -15,6 +16,7 @@ declare class SolelyAlert extends BaseElement<AlertProps & {
15
16
  * 组件挂载后
16
17
  */
17
18
  mounted(): void;
19
+ unmounted(): void;
18
20
  /**
19
21
  * 关闭事件处理
20
22
  */
@@ -1 +1 @@
1
- import e from"./style.css.js";import{__SOLELY_IR__ as t}from"./index.html.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as o}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let a=class extends s{getAlertClasses(){return{[`alert--${this.$data.type}`]:!!this.$data.type,"is-closing":this.$data.closing,"alert--block":!!this.$data.block}}getIcon(e){const t={info:"ℹ",success:"✓",warning:"⚠",error:"✕"};return t[e]||t.info}mounted(){this.refresh()}handleClose(){this.$data.closing=!0,this.emit("close"),setTimeout(()=>{this.remove()},300)}setMessage(e){this.$data.message=e}setType(e){this.$data.type=e}};a=((e,t)=>{for(var s,o=t,a=e.length-1;a>=0;a--)(s=e[a])&&(o=s(o)||o);return o})([o({tagName:"solely-alert",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"info"},{name:"message",type:"string",default:""},{name:"description",type:"string",default:""},{name:"closable",type:"boolean",default:!1},{name:"showIcon",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],a);export{a as SolelyAlert};
1
+ var e=Object.defineProperty;import t from"./style.css.js";import{__SOLELY_IR__ as s}from"./index.html.js";import o from"../../../runtime/component/base-element.js";import{CustomElement as r}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let a=class extends o{constructor(){var t,s;super(...arguments),((t,s,o)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[s]=o})(this,"symbol"!=typeof(t="closeTimer")?t+"":t,s)}getAlertClasses(){return{[`alert--${this.$data.type}`]:!!this.$data.type,"is-closing":this.$data.closing,"alert--block":!!this.$data.block}}getIcon(e){const t={info:"ℹ",success:"✓",warning:"⚠",error:"✕"};return t[e]||t.info}mounted(){this.refresh()}unmounted(){this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=void 0)}handleClose(){this.$data.closing=!0,this.emit("close"),this.closeTimer=setTimeout(()=>{this.remove()},300)}setMessage(e){this.$data.message=e}setType(e){this.$data.type=e}};a=((e,t)=>{for(var s,o=t,r=e.length-1;r>=0;r--)(s=e[r])&&(o=s(o)||o);return o})([r({tagName:"solely-alert",template:s,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"info"},{name:"message",type:"string",default:""},{name:"description",type:"string",default:""},{name:"closable",type:"boolean",default:!1},{name:"showIcon",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],a);export{a as SolelyAlert};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),r=require("./index.html.cjs"),s=require("../../../runtime/component/base-element.cjs"),a=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyBreadcrumb=class extends s.default{constructor(){var t;super(...arguments),((t,r,s)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s})(this,"symbol"!=typeof(t="clickedItem")?t+"":t,null)}handleClick(e,t){e.href||(t.preventDefault(),this.clickedItem=e,this.dispatchEvent(new Event("click",{bubbles:!0,composed:!0})))}get items(){return this.$data.items}set items(e){this.$data.items=e}},exports.SolelyBreadcrumb=((e,t)=>{for(var r,s=t,a=e.length-1;a>=0;a--)(r=e[a])&&(s=r(s)||s);return s})([a.CustomElement({tagName:"solely-breadcrumb",template:r.__SOLELY_IR__,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"items",type:"array",default:[]},{name:"separator",type:"string",default:"/"}]})],exports.SolelyBreadcrumb);
1
+ "use strict";var e=Object.defineProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),r=require("./index.html.cjs"),s=require("../../../runtime/component/base-element.cjs"),a=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyBreadcrumb=class extends s.default{constructor(){var t;super(...arguments),((t,r,s)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s})(this,"symbol"!=typeof(t="clickedItem")?t+"":t,null)}handleClick(e,t){e.href||(t.preventDefault(),this.clickedItem=e,this.dispatchEvent(new CustomEvent("click",{bubbles:!0,composed:!0,detail:{item:e}})))}get items(){return this.$data.items}set items(e){this.$data.items=e}},exports.SolelyBreadcrumb=((e,t)=>{for(var r,s=t,a=e.length-1;a>=0;a--)(r=e[a])&&(s=r(s)||s);return s})([a.CustomElement({tagName:"solely-breadcrumb",template:r.__SOLELY_IR__,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"items",type:"array",default:[]},{name:"separator",type:"string",default:"/"}]})],exports.SolelyBreadcrumb);
@@ -1 +1 @@
1
- var e=Object.defineProperty;import t from"./style.css.js";import{__SOLELY_IR__ as r}from"./index.html.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as o}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let a=class extends s{constructor(){var t;super(...arguments),((t,r,s)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s})(this,"symbol"!=typeof(t="clickedItem")?t+"":t,null)}handleClick(e,t){e.href||(t.preventDefault(),this.clickedItem=e,this.dispatchEvent(new Event("click",{bubbles:!0,composed:!0})))}get items(){return this.$data.items}set items(e){this.$data.items=e}};a=((e,t)=>{for(var r,s=t,o=e.length-1;o>=0;o--)(r=e[o])&&(s=r(s)||s);return s})([o({tagName:"solely-breadcrumb",template:r,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"items",type:"array",default:[]},{name:"separator",type:"string",default:"/"}]})],a);export{a as SolelyBreadcrumb};
1
+ var e=Object.defineProperty;import t from"./style.css.js";import{__SOLELY_IR__ as r}from"./index.html.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as o}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let m=class extends s{constructor(){var t;super(...arguments),((t,r,s)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s})(this,"symbol"!=typeof(t="clickedItem")?t+"":t,null)}handleClick(e,t){e.href||(t.preventDefault(),this.clickedItem=e,this.dispatchEvent(new CustomEvent("click",{bubbles:!0,composed:!0,detail:{item:e}})))}get items(){return this.$data.items}set items(e){this.$data.items=e}};m=((e,t)=>{for(var r,s=t,o=e.length-1;o>=0;o--)(r=e[o])&&(s=r(s)||s);return s})([o({tagName:"solely-breadcrumb",template:r,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"items",type:"array",default:[]},{name:"separator",type:"string",default:"/"}]})],m);export{m as SolelyBreadcrumb};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),e=require("./index.html.cjs"),i=require("../../../runtime/component/base-element.cjs"),s=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;var n,a,o,d,r=t=>{throw TypeError(t)},l=(t,e,i)=>e.has(t)||r("Cannot "+i),u=(t,e,i)=>(l(t,e,"read from private field"),i?i.call(t):e.get(t)),h=(t,e,i)=>e.has(t)?r("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),c=(t,e,i,s)=>(l(t,e,"write to private field"),e.set(t,i),i);exports.SolelyCoordinateInput=class extends i.default{constructor(){super(...arguments),h(this,n,{degrees:0,minutes:0,seconds:0,direction:"N"}),h(this,a,{degrees:0,minutes:0,seconds:0,direction:"E"}),h(this,o,{latitude:!1,longitude:!1}),h(this,d,null)}mounted(){this.refresh(),this.initializeValues()}beforeUnmount(){u(this,d)&&(document.removeEventListener("click",u(this,d)),c(this,d,null))}registerCloseHandler(){u(this,d)&&document.removeEventListener("click",u(this,d)),c(this,d,t=>{const e=t.target;this.contains(e)&&e.closest(".dms-input__direction")||((this.$data.latitudeDirectionOpen||this.$data.longitudeDirectionOpen)&&(this.$data.latitudeDirectionOpen=!1,this.$data.longitudeDirectionOpen=!1,this.refresh()),u(this,d)&&(document.removeEventListener("click",u(this,d)),c(this,d,null)))}),setTimeout(()=>{u(this,d)&&document.addEventListener("click",u(this,d))},0)}onPropChange(t,e){"latitude"===t&&"number"==typeof e?(c(this,n,this.decimalToDms(e,"latitude")),this.refresh(),this.updateSecondsInputs()):"longitude"===t&&"number"==typeof e&&(c(this,a,this.decimalToDms(e,"longitude")),this.refresh(),this.updateSecondsInputs())}initializeValues(){void 0===this.$data.latitude||isNaN(this.$data.latitude)||c(this,n,this.decimalToDms(this.$data.latitude,"latitude")),void 0===this.$data.longitude||isNaN(this.$data.longitude)||c(this,a,this.decimalToDms(this.$data.longitude,"longitude")),this.refresh(),this.updateSecondsInputs()}updateSecondsInputs(){const t=this.$refs.latitudeSecondsInput,e=this.$refs.longitudeSecondsInput;if(t){const e=u(this,n).seconds;if(e>0){const i=this.$data.precision??3;e===Math.floor(e)?t.value=String(Math.floor(e)):t.value=e.toFixed(i)}else t.value=""}if(e){const t=u(this,a).seconds;if(t>0){const i=this.$data.precision??3;t===Math.floor(t)?e.value=String(Math.floor(t)):e.value=t.toFixed(i)}else e.value=""}}getContainerClasses(){const t=[],e=this.$data.size||"medium",i=this.$data.type||"both";return"small"===e?t.push("coordinate-input--sm"):"large"===e?t.push("coordinate-input--lg"):t.push("coordinate-input--md"),"both"===i&&t.push("coordinate-input--horizontal"),t.join(" ")}getDmsInputClasses(t){const e=[],i=u(this,o)[t],s=this.$data.disabled,n=this.$data.readonly;return i&&e.push("dms-input--focused"),s&&e.push("dms-input--disabled"),n&&e.push("dms-input--readonly"),e.join(" ")}getDirectionClasses(t){const e=["dms-input__direction"];return("latitude"===t?this.$data.latitudeDirectionOpen:this.$data.longitudeDirectionOpen)&&e.push("dms-input__direction--open"),e.join(" ")}getDirectionOptionClasses(t,e){const i=["dms-input__direction-option"];return("latitude"===t?u(this,n).direction:u(this,a).direction)===e&&i.push("dms-input__direction-option--selected"),i.join(" ")}getSecondsPlaceholder(){const t=this.$data.precision??3;return 0===t?"00":"00."+"0".repeat(t)}getSecondsStep(){const t=this.$data.precision??3;return 0===t?"1":"0."+"0".repeat(t-1)+"1"}getDmsDisplayValue(t,e){const i=u(this,"latitude"===t?n:a)[e];if("seconds"===e){const t=this.$data.precision??3;return"number"==typeof i&&!isNaN(i)&&i>0?i===Math.floor(i)?String(Math.floor(i)):i.toFixed(t):""}return"direction"===e?i:null!=i&&!isNaN(Number(i))&&Number(i)>0?String(i):""}getDecimalDisplayValue(t){const e="latitude"===t?this.$data.latitude:this.$data.longitude;return void 0===e||isNaN(e)?"-":e.toFixed(6)}handleDmsInput(t,e,i){if(this.$data.disabled||this.$data.readonly)return;const s=i.target;let o=parseFloat(s.value);const d=this.getFieldLimits(t,e);isNaN(o)?o=0:o<d.min?o=d.min:o>d.max&&(o=d.max),u(this,"latitude"===t?n:a)[e]=o,this.updateDecimalValue(t),!1!==this.$data.autoTab&&this.shouldAutoTab(e,o,d.max)&&this.focusNextInput(t,e)}handleDmsChange(t,e,i){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleSecondsChange(t,e){const i=e.target;let s=parseFloat(i.value);const o=this.getFieldLimits(t,"seconds");isNaN(s)?s=0:s<o.min?s=o.min:s>o.max&&(s=o.max);const d=this.$data.precision??3;s=parseFloat(s.toFixed(d)),u(this,"latitude"===t?n:a).seconds=s,this.updateDecimalValue(t),this.refresh(),this.updateSecondsInputs(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}shouldAutoTab(t,e,i){if("seconds"!==t){const t=String(Math.floor(e)),s=String(Math.floor(i));return t.length>=s.length}const s=this.$data.precision??3,n=String(e),a=n.indexOf(".");if(-1===a){const t=Math.floor(e),s=String(t),n=String(Math.floor(i));return s.length>=n.length}return n.length-a-1>=s}focusNextInput(t,e){const i={degrees:"Minutes",minutes:"Seconds",seconds:"Direction"}[e];if(!i)return;const s=`${t}${i}Input`,n=this.$refs[s];n&&(n.focus(),n instanceof HTMLInputElement&&n.select())}toggleDirection(t){if(this.$data.disabled||this.$data.readonly)return;const e="latitude"===t?"latitudeDirectionOpen":"longitudeDirectionOpen",i=this.$data[e]||!1;this.$data.latitudeDirectionOpen=!1,this.$data.longitudeDirectionOpen=!1,this.$data[e]=!i,this.refresh(),this.$data[e]&&this.registerCloseHandler()}handleDropdownClick(t){t.stopPropagation()}selectDirection(t,e){if(this.$data.disabled||this.$data.readonly)return;u(this,"latitude"===t?n:a).direction=e;const i="latitude"===t?"latitudeDirectionOpen":"longitudeDirectionOpen";this.$data[i]=!1,this.updateDecimalValue(t),this.refresh()}handleFocus(t,e){u(this,o)[t]=!0,this.refresh()}handleBlur(t,e){u(this,o)[t]=!1,this.refresh()}handleSecondsBlur(t,e){u(this,o)[t]=!1;const i=e.target;let s=parseFloat(i.value);const d=this.getFieldLimits(t,"seconds");isNaN(s)?s=0:s<d.min?s=d.min:s>d.max&&(s=d.max);const r=this.$data.precision??3;s=parseFloat(s.toFixed(r)),u(this,"latitude"===t?n:a).seconds=s,this.updateDecimalValue(t),this.refresh(),this.updateSecondsInputs()}handleSecondsKeyDown(t,e){const i=e.target,s=this.$data.precision??3,n=e.key;if(["Backspace","Delete","ArrowLeft","ArrowRight","Tab","Enter","Escape"].includes(n))return;if((e.ctrlKey||e.metaKey)&&["a","c","v","x"].includes(n.toLowerCase()))return;if(!/[0-9.]/.test(n))return void e.preventDefault();if("."===n)return i.value.includes(".")||0===s?void e.preventDefault():void 0;const a=i.value,o=i.selectionStart??0,d=i.selectionEnd??0,r=a.slice(0,o)+n+a.slice(d),l=parseFloat(r);if(!isNaN(l)&&l>59)return void e.preventDefault();const u=a.indexOf(".");-1!==u&&o>u&&a.length-u-1>=s&&e.preventDefault()}getFieldLimits(t,e){const i="latitude"===t;switch(e){case"degrees":return{min:0,max:i?90:180};case"minutes":case"seconds":return{min:0,max:59};default:return{min:0,max:0}}}updateDecimalValue(t){const e=u(this,"latitude"===t?n:a),i=this.dmsToDecimal(e);"latitude"===t?this.$data.latitude=i:this.$data.longitude=i,this.refresh()}dmsToDecimal(t){let e=t.degrees+t.minutes/60+t.seconds/3600;return"S"!==t.direction&&"W"!==t.direction||(e=-e),e}decimalToDms(t,e){const i="latitude"===e;let s=i?"N":"E";t<0&&(t=-t,s=i?"S":"W");const n=Math.floor(t),a=60*(t-n),o=Math.floor(a);return{degrees:n,minutes:o,seconds:parseFloat((60*(a-o)).toFixed(3)),direction:s}}getValue(){return{latitude:this.$data.latitude||0,longitude:this.$data.longitude||0}}getDmsCoordinateValue(){return{latitude:{...u(this,n)},longitude:{...u(this,a)}}}setValue(t,e){this.$data.latitude=t,this.$data.longitude=e,c(this,n,this.decimalToDms(t,"latitude")),c(this,a,this.decimalToDms(e,"longitude")),this.refresh()}clear(){this.$data.latitude=0,this.$data.longitude=0,c(this,n,{degrees:0,minutes:0,seconds:0,direction:"N"}),c(this,a,{degrees:0,minutes:0,seconds:0,direction:"E"}),this.refresh(),this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0}))}get value(){return this.getValue()}set value(t){Array.isArray(t)?this.setValue(t[0],t[1]):this.setValue(t.latitude,t.longitude)}},n=new WeakMap,a=new WeakMap,o=new WeakMap,d=new WeakMap,exports.SolelyCoordinateInput=((t,e)=>{for(var i,s=e,n=t.length-1;n>=0;n--)(i=t[n])&&(s=i(s)||s);return s})([s.CustomElement({tagName:"solely-coordinate-input",template:e.__SOLELY_IR__,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"both"},{name:"latitude",type:"number"},{name:"longitude",type:"number"},{name:"disabled",type:"boolean",default:!1},{name:"readonly",type:"boolean",default:!1},{name:"placeholder",type:"string",default:""},{name:"size",type:"string",default:"medium"},{name:"showDirection",type:"boolean",default:!1},{name:"precision",type:"number",default:3},{name:"showDecimal",type:"boolean",default:!1},{name:"autoTab",type:"boolean",default:!1},{name:"latitudeDirectionOpen",type:"boolean",default:!1},{name:"longitudeDirectionOpen",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelyCoordinateInput);
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),e=require("./index.html.cjs"),i=require("../../../runtime/component/base-element.cjs"),s=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;var a,n,o,d,r=t=>{throw TypeError(t)},l=(t,e,i)=>e.has(t)||r("Cannot "+i),u=(t,e,i)=>(l(t,e,"read from private field"),i?i.call(t):e.get(t)),h=(t,e,i)=>e.has(t)?r("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),c=(t,e,i,s)=>(l(t,e,"write to private field"),e.set(t,i),i);exports.SolelyCoordinateInput=class extends i.default{constructor(){super(...arguments),h(this,a,{degrees:0,minutes:0,seconds:0,direction:"N"}),h(this,n,{degrees:0,minutes:0,seconds:0,direction:"E"}),h(this,o,{latitude:!1,longitude:!1}),h(this,d,null)}mounted(){this.refresh(),this.initializeValues()}unmounted(){u(this,d)&&(document.removeEventListener("click",u(this,d)),c(this,d,null))}registerCloseHandler(){u(this,d)&&document.removeEventListener("click",u(this,d)),c(this,d,t=>{const e=t.target;this.contains(e)&&e.closest(".dms-input__direction")||((this.$data.latitudeDirectionOpen||this.$data.longitudeDirectionOpen)&&(this.$data.latitudeDirectionOpen=!1,this.$data.longitudeDirectionOpen=!1,this.refresh()),u(this,d)&&(document.removeEventListener("click",u(this,d)),c(this,d,null)))}),setTimeout(()=>{u(this,d)&&document.addEventListener("click",u(this,d))},0)}attributeChanged(t,e,i){"latitude"===t&&"number"==typeof i?(c(this,a,this.decimalToDms(i,"latitude")),this.refresh(),this.updateSecondsInputs()):"longitude"===t&&"number"==typeof i&&(c(this,n,this.decimalToDms(i,"longitude")),this.refresh(),this.updateSecondsInputs())}initializeValues(){void 0===this.$data.latitude||isNaN(this.$data.latitude)||c(this,a,this.decimalToDms(this.$data.latitude,"latitude")),void 0===this.$data.longitude||isNaN(this.$data.longitude)||c(this,n,this.decimalToDms(this.$data.longitude,"longitude")),this.refresh(),this.updateSecondsInputs()}updateSecondsInputs(){const t=this.$refs.latitudeSecondsInput,e=this.$refs.longitudeSecondsInput;if(t){const e=u(this,a).seconds;if(e>0){const i=this.$data.precision??3;e===Math.floor(e)?t.value=String(Math.floor(e)):t.value=e.toFixed(i)}else t.value=""}if(e){const t=u(this,n).seconds;if(t>0){const i=this.$data.precision??3;t===Math.floor(t)?e.value=String(Math.floor(t)):e.value=t.toFixed(i)}else e.value=""}}getContainerClasses(){const t=[],e=this.$data.size||"medium",i=this.$data.type||"both";return"small"===e?t.push("coordinate-input--sm"):"large"===e?t.push("coordinate-input--lg"):t.push("coordinate-input--md"),"both"===i&&t.push("coordinate-input--horizontal"),t.join(" ")}getDmsInputClasses(t){const e=[],i=u(this,o)[t],s=this.$data.disabled,a=this.$data.readonly;return i&&e.push("dms-input--focused"),s&&e.push("dms-input--disabled"),a&&e.push("dms-input--readonly"),e.join(" ")}getDirectionClasses(t){const e=["dms-input__direction"];return("latitude"===t?this.$data.latitudeDirectionOpen:this.$data.longitudeDirectionOpen)&&e.push("dms-input__direction--open"),e.join(" ")}getDirectionOptionClasses(t,e){const i=["dms-input__direction-option"];return("latitude"===t?u(this,a).direction:u(this,n).direction)===e&&i.push("dms-input__direction-option--selected"),i.join(" ")}getSecondsPlaceholder(){const t=this.$data.precision??3;return 0===t?"00":"00."+"0".repeat(t)}getSecondsStep(){const t=this.$data.precision??3;return 0===t?"1":"0."+"0".repeat(t-1)+"1"}getDmsDisplayValue(t,e){const i=u(this,"latitude"===t?a:n)[e];if("seconds"===e){const t=this.$data.precision??3;return"number"==typeof i&&!isNaN(i)&&i>0?i===Math.floor(i)?String(Math.floor(i)):i.toFixed(t):""}return"direction"===e?i:null!=i&&!isNaN(Number(i))&&Number(i)>0?String(i):""}getDecimalDisplayValue(t){const e="latitude"===t?this.$data.latitude:this.$data.longitude;return void 0===e||isNaN(e)?"-":e.toFixed(6)}handleDmsInput(t,e,i){if(this.$data.disabled||this.$data.readonly)return;const s=i.target;let o=parseFloat(s.value);const d=this.getFieldLimits(t,e);isNaN(o)?o=0:o<d.min?o=d.min:o>d.max&&(o=d.max),u(this,"latitude"===t?a:n)[e]=o,this.updateDecimalValue(t),!1!==this.$data.autoTab&&this.shouldAutoTab(e,o,d.max)&&this.focusNextInput(t,e)}handleDmsChange(t,e,i){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleSecondsChange(t,e){const i=e.target;let s=parseFloat(i.value);const o=this.getFieldLimits(t,"seconds");isNaN(s)?s=0:s<o.min?s=o.min:s>o.max&&(s=o.max);const d=this.$data.precision??3;s=parseFloat(s.toFixed(d)),u(this,"latitude"===t?a:n).seconds=s,this.updateDecimalValue(t),this.refresh(),this.updateSecondsInputs(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}shouldAutoTab(t,e,i){if("seconds"!==t){const t=String(Math.floor(e)),s=String(Math.floor(i));return t.length>=s.length}const s=this.$data.precision??3,a=String(e),n=a.indexOf(".");if(-1===n){const t=Math.floor(e),s=String(t),a=String(Math.floor(i));return s.length>=a.length}return a.length-n-1>=s}focusNextInput(t,e){const i={degrees:"Minutes",minutes:"Seconds",seconds:"Direction"}[e];if(!i)return;const s=`${t}${i}Input`,a=this.$refs[s];a&&(a.focus(),a instanceof HTMLInputElement&&a.select())}toggleDirection(t){if(this.$data.disabled||this.$data.readonly)return;const e="latitude"===t?"latitudeDirectionOpen":"longitudeDirectionOpen",i=this.$data[e]||!1;this.$data.latitudeDirectionOpen=!1,this.$data.longitudeDirectionOpen=!1,this.$data[e]=!i,this.refresh(),this.$data[e]&&this.registerCloseHandler()}handleDropdownClick(t){t.stopPropagation()}selectDirection(t,e){if(this.$data.disabled||this.$data.readonly)return;u(this,"latitude"===t?a:n).direction=e;const i="latitude"===t?"latitudeDirectionOpen":"longitudeDirectionOpen";this.$data[i]=!1,this.updateDecimalValue(t),this.refresh()}handleFocus(t,e){u(this,o)[t]=!0,this.refresh()}handleBlur(t,e){u(this,o)[t]=!1,this.refresh()}handleSecondsBlur(t,e){u(this,o)[t]=!1;const i=e.target;let s=parseFloat(i.value);const d=this.getFieldLimits(t,"seconds");isNaN(s)?s=0:s<d.min?s=d.min:s>d.max&&(s=d.max);const r=this.$data.precision??3;s=parseFloat(s.toFixed(r)),u(this,"latitude"===t?a:n).seconds=s,this.updateDecimalValue(t),this.refresh(),this.updateSecondsInputs()}handleSecondsKeyDown(t,e){const i=e.target,s=this.$data.precision??3,a=e.key;if(["Backspace","Delete","ArrowLeft","ArrowRight","Tab","Enter","Escape"].includes(a))return;if((e.ctrlKey||e.metaKey)&&["a","c","v","x"].includes(a.toLowerCase()))return;if(!/[0-9.]/.test(a))return void e.preventDefault();if("."===a)return i.value.includes(".")||0===s?void e.preventDefault():void 0;const n=i.value,o=i.selectionStart??0,d=i.selectionEnd??0,r=n.slice(0,o)+a+n.slice(d),l=parseFloat(r);if(!isNaN(l)&&l>59)return void e.preventDefault();const u=n.indexOf(".");-1!==u&&o>u&&n.length-u-1>=s&&e.preventDefault()}getFieldLimits(t,e){const i="latitude"===t;switch(e){case"degrees":return{min:0,max:i?90:180};case"minutes":case"seconds":return{min:0,max:59};default:return{min:0,max:0}}}updateDecimalValue(t){const e=u(this,"latitude"===t?a:n),i=this.dmsToDecimal(e);"latitude"===t?this.$data.latitude=i:this.$data.longitude=i,this.refresh()}dmsToDecimal(t){let e=t.degrees+t.minutes/60+t.seconds/3600;return"S"!==t.direction&&"W"!==t.direction||(e=-e),e}decimalToDms(t,e){const i="latitude"===e;let s=i?"N":"E";t<0&&(t=-t,s=i?"S":"W");const a=Math.floor(t),n=60*(t-a),o=Math.floor(n);return{degrees:a,minutes:o,seconds:parseFloat((60*(n-o)).toFixed(3)),direction:s}}getValue(){return{latitude:this.$data.latitude||0,longitude:this.$data.longitude||0}}getDmsCoordinateValue(){return{latitude:{...u(this,a)},longitude:{...u(this,n)}}}setValue(t,e){this.$data.latitude=t,this.$data.longitude=e,c(this,a,this.decimalToDms(t,"latitude")),c(this,n,this.decimalToDms(e,"longitude")),this.refresh()}clear(){this.$data.latitude=0,this.$data.longitude=0,c(this,a,{degrees:0,minutes:0,seconds:0,direction:"N"}),c(this,n,{degrees:0,minutes:0,seconds:0,direction:"E"}),this.refresh(),this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0}))}get value(){return this.getValue()}set value(t){Array.isArray(t)?this.setValue(t[0],t[1]):this.setValue(t.latitude,t.longitude)}},a=new WeakMap,n=new WeakMap,o=new WeakMap,d=new WeakMap,exports.SolelyCoordinateInput=((t,e)=>{for(var i,s=e,a=t.length-1;a>=0;a--)(i=t[a])&&(s=i(s)||s);return s})([s.CustomElement({tagName:"solely-coordinate-input",template:e.__SOLELY_IR__,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"both"},{name:"latitude",type:"number"},{name:"longitude",type:"number"},{name:"disabled",type:"boolean",default:!1},{name:"readonly",type:"boolean",default:!1},{name:"placeholder",type:"string",default:""},{name:"size",type:"string",default:"medium"},{name:"showDirection",type:"boolean",default:!1},{name:"precision",type:"number",default:3},{name:"showDecimal",type:"boolean",default:!1},{name:"autoTab",type:"boolean",default:!1},{name:"latitudeDirectionOpen",type:"boolean",default:!1},{name:"longitudeDirectionOpen",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelyCoordinateInput);
@@ -9,7 +9,7 @@ declare class SolelyCoordinateInput extends BaseElement<CoordinateInputProps, Co
9
9
  /**
10
10
  * 组件卸载前
11
11
  */
12
- beforeUnmount(): void;
12
+ unmounted(): void;
13
13
  /**
14
14
  * 注册外部点击关闭事件
15
15
  */
@@ -17,7 +17,7 @@ declare class SolelyCoordinateInput extends BaseElement<CoordinateInputProps, Co
17
17
  /**
18
18
  * 属性变化时
19
19
  */
20
- onPropChange(prop: string, value: unknown): void;
20
+ attributeChanged(name: string, _oldValue: unknown, newValue: unknown): void;
21
21
  /**
22
22
  * 初始化值
23
23
  */
@@ -1 +1 @@
1
- import t from"./style.css.js";import{__SOLELY_IR__ as e}from"./index.html.js";import i from"../../../runtime/component/base-element.js";import{CustomElement as s}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;var a,n,o,d,r=t=>{throw TypeError(t)},l=(t,e,i)=>e.has(t)||r("Cannot "+i),u=(t,e,i)=>(l(t,e,"read from private field"),i?i.call(t):e.get(t)),h=(t,e,i)=>e.has(t)?r("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),c=(t,e,i,s)=>(l(t,e,"write to private field"),e.set(t,i),i);let p=class extends i{constructor(){super(...arguments),h(this,a,{degrees:0,minutes:0,seconds:0,direction:"N"}),h(this,n,{degrees:0,minutes:0,seconds:0,direction:"E"}),h(this,o,{latitude:!1,longitude:!1}),h(this,d,null)}mounted(){this.refresh(),this.initializeValues()}beforeUnmount(){u(this,d)&&(document.removeEventListener("click",u(this,d)),c(this,d,null))}registerCloseHandler(){u(this,d)&&document.removeEventListener("click",u(this,d)),c(this,d,t=>{const e=t.target;this.contains(e)&&e.closest(".dms-input__direction")||((this.$data.latitudeDirectionOpen||this.$data.longitudeDirectionOpen)&&(this.$data.latitudeDirectionOpen=!1,this.$data.longitudeDirectionOpen=!1,this.refresh()),u(this,d)&&(document.removeEventListener("click",u(this,d)),c(this,d,null)))}),setTimeout(()=>{u(this,d)&&document.addEventListener("click",u(this,d))},0)}onPropChange(t,e){"latitude"===t&&"number"==typeof e?(c(this,a,this.decimalToDms(e,"latitude")),this.refresh(),this.updateSecondsInputs()):"longitude"===t&&"number"==typeof e&&(c(this,n,this.decimalToDms(e,"longitude")),this.refresh(),this.updateSecondsInputs())}initializeValues(){void 0===this.$data.latitude||isNaN(this.$data.latitude)||c(this,a,this.decimalToDms(this.$data.latitude,"latitude")),void 0===this.$data.longitude||isNaN(this.$data.longitude)||c(this,n,this.decimalToDms(this.$data.longitude,"longitude")),this.refresh(),this.updateSecondsInputs()}updateSecondsInputs(){const t=this.$refs.latitudeSecondsInput,e=this.$refs.longitudeSecondsInput;if(t){const e=u(this,a).seconds;if(e>0){const i=this.$data.precision??3;e===Math.floor(e)?t.value=String(Math.floor(e)):t.value=e.toFixed(i)}else t.value=""}if(e){const t=u(this,n).seconds;if(t>0){const i=this.$data.precision??3;t===Math.floor(t)?e.value=String(Math.floor(t)):e.value=t.toFixed(i)}else e.value=""}}getContainerClasses(){const t=[],e=this.$data.size||"medium",i=this.$data.type||"both";return"small"===e?t.push("coordinate-input--sm"):"large"===e?t.push("coordinate-input--lg"):t.push("coordinate-input--md"),"both"===i&&t.push("coordinate-input--horizontal"),t.join(" ")}getDmsInputClasses(t){const e=[],i=u(this,o)[t],s=this.$data.disabled,a=this.$data.readonly;return i&&e.push("dms-input--focused"),s&&e.push("dms-input--disabled"),a&&e.push("dms-input--readonly"),e.join(" ")}getDirectionClasses(t){const e=["dms-input__direction"];return("latitude"===t?this.$data.latitudeDirectionOpen:this.$data.longitudeDirectionOpen)&&e.push("dms-input__direction--open"),e.join(" ")}getDirectionOptionClasses(t,e){const i=["dms-input__direction-option"];return("latitude"===t?u(this,a).direction:u(this,n).direction)===e&&i.push("dms-input__direction-option--selected"),i.join(" ")}getSecondsPlaceholder(){const t=this.$data.precision??3;return 0===t?"00":"00."+"0".repeat(t)}getSecondsStep(){const t=this.$data.precision??3;return 0===t?"1":"0."+"0".repeat(t-1)+"1"}getDmsDisplayValue(t,e){const i=u(this,"latitude"===t?a:n)[e];if("seconds"===e){const t=this.$data.precision??3;return"number"==typeof i&&!isNaN(i)&&i>0?i===Math.floor(i)?String(Math.floor(i)):i.toFixed(t):""}return"direction"===e?i:null!=i&&!isNaN(Number(i))&&Number(i)>0?String(i):""}getDecimalDisplayValue(t){const e="latitude"===t?this.$data.latitude:this.$data.longitude;return void 0===e||isNaN(e)?"-":e.toFixed(6)}handleDmsInput(t,e,i){if(this.$data.disabled||this.$data.readonly)return;const s=i.target;let o=parseFloat(s.value);const d=this.getFieldLimits(t,e);isNaN(o)?o=0:o<d.min?o=d.min:o>d.max&&(o=d.max),u(this,"latitude"===t?a:n)[e]=o,this.updateDecimalValue(t),!1!==this.$data.autoTab&&this.shouldAutoTab(e,o,d.max)&&this.focusNextInput(t,e)}handleDmsChange(t,e,i){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleSecondsChange(t,e){const i=e.target;let s=parseFloat(i.value);const o=this.getFieldLimits(t,"seconds");isNaN(s)?s=0:s<o.min?s=o.min:s>o.max&&(s=o.max);const d=this.$data.precision??3;s=parseFloat(s.toFixed(d)),u(this,"latitude"===t?a:n).seconds=s,this.updateDecimalValue(t),this.refresh(),this.updateSecondsInputs(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}shouldAutoTab(t,e,i){if("seconds"!==t){const t=String(Math.floor(e)),s=String(Math.floor(i));return t.length>=s.length}const s=this.$data.precision??3,a=String(e),n=a.indexOf(".");if(-1===n){const t=Math.floor(e),s=String(t),a=String(Math.floor(i));return s.length>=a.length}return a.length-n-1>=s}focusNextInput(t,e){const i={degrees:"Minutes",minutes:"Seconds",seconds:"Direction"}[e];if(!i)return;const s=`${t}${i}Input`,a=this.$refs[s];a&&(a.focus(),a instanceof HTMLInputElement&&a.select())}toggleDirection(t){if(this.$data.disabled||this.$data.readonly)return;const e="latitude"===t?"latitudeDirectionOpen":"longitudeDirectionOpen",i=this.$data[e]||!1;this.$data.latitudeDirectionOpen=!1,this.$data.longitudeDirectionOpen=!1,this.$data[e]=!i,this.refresh(),this.$data[e]&&this.registerCloseHandler()}handleDropdownClick(t){t.stopPropagation()}selectDirection(t,e){if(this.$data.disabled||this.$data.readonly)return;u(this,"latitude"===t?a:n).direction=e;const i="latitude"===t?"latitudeDirectionOpen":"longitudeDirectionOpen";this.$data[i]=!1,this.updateDecimalValue(t),this.refresh()}handleFocus(t,e){u(this,o)[t]=!0,this.refresh()}handleBlur(t,e){u(this,o)[t]=!1,this.refresh()}handleSecondsBlur(t,e){u(this,o)[t]=!1;const i=e.target;let s=parseFloat(i.value);const d=this.getFieldLimits(t,"seconds");isNaN(s)?s=0:s<d.min?s=d.min:s>d.max&&(s=d.max);const r=this.$data.precision??3;s=parseFloat(s.toFixed(r)),u(this,"latitude"===t?a:n).seconds=s,this.updateDecimalValue(t),this.refresh(),this.updateSecondsInputs()}handleSecondsKeyDown(t,e){const i=e.target,s=this.$data.precision??3,a=e.key;if(["Backspace","Delete","ArrowLeft","ArrowRight","Tab","Enter","Escape"].includes(a))return;if((e.ctrlKey||e.metaKey)&&["a","c","v","x"].includes(a.toLowerCase()))return;if(!/[0-9.]/.test(a))return void e.preventDefault();if("."===a)return i.value.includes(".")||0===s?void e.preventDefault():void 0;const n=i.value,o=i.selectionStart??0,d=i.selectionEnd??0,r=n.slice(0,o)+a+n.slice(d),l=parseFloat(r);if(!isNaN(l)&&l>59)return void e.preventDefault();const u=n.indexOf(".");-1!==u&&o>u&&n.length-u-1>=s&&e.preventDefault()}getFieldLimits(t,e){const i="latitude"===t;switch(e){case"degrees":return{min:0,max:i?90:180};case"minutes":case"seconds":return{min:0,max:59};default:return{min:0,max:0}}}updateDecimalValue(t){const e=u(this,"latitude"===t?a:n),i=this.dmsToDecimal(e);"latitude"===t?this.$data.latitude=i:this.$data.longitude=i,this.refresh()}dmsToDecimal(t){let e=t.degrees+t.minutes/60+t.seconds/3600;return"S"!==t.direction&&"W"!==t.direction||(e=-e),e}decimalToDms(t,e){const i="latitude"===e;let s=i?"N":"E";t<0&&(t=-t,s=i?"S":"W");const a=Math.floor(t),n=60*(t-a),o=Math.floor(n);return{degrees:a,minutes:o,seconds:parseFloat((60*(n-o)).toFixed(3)),direction:s}}getValue(){return{latitude:this.$data.latitude||0,longitude:this.$data.longitude||0}}getDmsCoordinateValue(){return{latitude:{...u(this,a)},longitude:{...u(this,n)}}}setValue(t,e){this.$data.latitude=t,this.$data.longitude=e,c(this,a,this.decimalToDms(t,"latitude")),c(this,n,this.decimalToDms(e,"longitude")),this.refresh()}clear(){this.$data.latitude=0,this.$data.longitude=0,c(this,a,{degrees:0,minutes:0,seconds:0,direction:"N"}),c(this,n,{degrees:0,minutes:0,seconds:0,direction:"E"}),this.refresh(),this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0}))}get value(){return this.getValue()}set value(t){Array.isArray(t)?this.setValue(t[0],t[1]):this.setValue(t.latitude,t.longitude)}};a=new WeakMap,n=new WeakMap,o=new WeakMap,d=new WeakMap,p=((t,e)=>{for(var i,s=e,a=t.length-1;a>=0;a--)(i=t[a])&&(s=i(s)||s);return s})([s({tagName:"solely-coordinate-input",template:e,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"both"},{name:"latitude",type:"number"},{name:"longitude",type:"number"},{name:"disabled",type:"boolean",default:!1},{name:"readonly",type:"boolean",default:!1},{name:"placeholder",type:"string",default:""},{name:"size",type:"string",default:"medium"},{name:"showDirection",type:"boolean",default:!1},{name:"precision",type:"number",default:3},{name:"showDecimal",type:"boolean",default:!1},{name:"autoTab",type:"boolean",default:!1},{name:"latitudeDirectionOpen",type:"boolean",default:!1},{name:"longitudeDirectionOpen",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],p);export{p as SolelyCoordinateInput};
1
+ import t from"./style.css.js";import{__SOLELY_IR__ as e}from"./index.html.js";import i from"../../../runtime/component/base-element.js";import{CustomElement as s}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;var a,n,o,d,r=t=>{throw TypeError(t)},l=(t,e,i)=>e.has(t)||r("Cannot "+i),u=(t,e,i)=>(l(t,e,"read from private field"),i?i.call(t):e.get(t)),h=(t,e,i)=>e.has(t)?r("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),c=(t,e,i,s)=>(l(t,e,"write to private field"),e.set(t,i),i);let p=class extends i{constructor(){super(...arguments),h(this,a,{degrees:0,minutes:0,seconds:0,direction:"N"}),h(this,n,{degrees:0,minutes:0,seconds:0,direction:"E"}),h(this,o,{latitude:!1,longitude:!1}),h(this,d,null)}mounted(){this.refresh(),this.initializeValues()}unmounted(){u(this,d)&&(document.removeEventListener("click",u(this,d)),c(this,d,null))}registerCloseHandler(){u(this,d)&&document.removeEventListener("click",u(this,d)),c(this,d,t=>{const e=t.target;this.contains(e)&&e.closest(".dms-input__direction")||((this.$data.latitudeDirectionOpen||this.$data.longitudeDirectionOpen)&&(this.$data.latitudeDirectionOpen=!1,this.$data.longitudeDirectionOpen=!1,this.refresh()),u(this,d)&&(document.removeEventListener("click",u(this,d)),c(this,d,null)))}),setTimeout(()=>{u(this,d)&&document.addEventListener("click",u(this,d))},0)}attributeChanged(t,e,i){"latitude"===t&&"number"==typeof i?(c(this,a,this.decimalToDms(i,"latitude")),this.refresh(),this.updateSecondsInputs()):"longitude"===t&&"number"==typeof i&&(c(this,n,this.decimalToDms(i,"longitude")),this.refresh(),this.updateSecondsInputs())}initializeValues(){void 0===this.$data.latitude||isNaN(this.$data.latitude)||c(this,a,this.decimalToDms(this.$data.latitude,"latitude")),void 0===this.$data.longitude||isNaN(this.$data.longitude)||c(this,n,this.decimalToDms(this.$data.longitude,"longitude")),this.refresh(),this.updateSecondsInputs()}updateSecondsInputs(){const t=this.$refs.latitudeSecondsInput,e=this.$refs.longitudeSecondsInput;if(t){const e=u(this,a).seconds;if(e>0){const i=this.$data.precision??3;e===Math.floor(e)?t.value=String(Math.floor(e)):t.value=e.toFixed(i)}else t.value=""}if(e){const t=u(this,n).seconds;if(t>0){const i=this.$data.precision??3;t===Math.floor(t)?e.value=String(Math.floor(t)):e.value=t.toFixed(i)}else e.value=""}}getContainerClasses(){const t=[],e=this.$data.size||"medium",i=this.$data.type||"both";return"small"===e?t.push("coordinate-input--sm"):"large"===e?t.push("coordinate-input--lg"):t.push("coordinate-input--md"),"both"===i&&t.push("coordinate-input--horizontal"),t.join(" ")}getDmsInputClasses(t){const e=[],i=u(this,o)[t],s=this.$data.disabled,a=this.$data.readonly;return i&&e.push("dms-input--focused"),s&&e.push("dms-input--disabled"),a&&e.push("dms-input--readonly"),e.join(" ")}getDirectionClasses(t){const e=["dms-input__direction"];return("latitude"===t?this.$data.latitudeDirectionOpen:this.$data.longitudeDirectionOpen)&&e.push("dms-input__direction--open"),e.join(" ")}getDirectionOptionClasses(t,e){const i=["dms-input__direction-option"];return("latitude"===t?u(this,a).direction:u(this,n).direction)===e&&i.push("dms-input__direction-option--selected"),i.join(" ")}getSecondsPlaceholder(){const t=this.$data.precision??3;return 0===t?"00":"00."+"0".repeat(t)}getSecondsStep(){const t=this.$data.precision??3;return 0===t?"1":"0."+"0".repeat(t-1)+"1"}getDmsDisplayValue(t,e){const i=u(this,"latitude"===t?a:n)[e];if("seconds"===e){const t=this.$data.precision??3;return"number"==typeof i&&!isNaN(i)&&i>0?i===Math.floor(i)?String(Math.floor(i)):i.toFixed(t):""}return"direction"===e?i:null!=i&&!isNaN(Number(i))&&Number(i)>0?String(i):""}getDecimalDisplayValue(t){const e="latitude"===t?this.$data.latitude:this.$data.longitude;return void 0===e||isNaN(e)?"-":e.toFixed(6)}handleDmsInput(t,e,i){if(this.$data.disabled||this.$data.readonly)return;const s=i.target;let o=parseFloat(s.value);const d=this.getFieldLimits(t,e);isNaN(o)?o=0:o<d.min?o=d.min:o>d.max&&(o=d.max),u(this,"latitude"===t?a:n)[e]=o,this.updateDecimalValue(t),!1!==this.$data.autoTab&&this.shouldAutoTab(e,o,d.max)&&this.focusNextInput(t,e)}handleDmsChange(t,e,i){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleSecondsChange(t,e){const i=e.target;let s=parseFloat(i.value);const o=this.getFieldLimits(t,"seconds");isNaN(s)?s=0:s<o.min?s=o.min:s>o.max&&(s=o.max);const d=this.$data.precision??3;s=parseFloat(s.toFixed(d)),u(this,"latitude"===t?a:n).seconds=s,this.updateDecimalValue(t),this.refresh(),this.updateSecondsInputs(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}shouldAutoTab(t,e,i){if("seconds"!==t){const t=String(Math.floor(e)),s=String(Math.floor(i));return t.length>=s.length}const s=this.$data.precision??3,a=String(e),n=a.indexOf(".");if(-1===n){const t=Math.floor(e),s=String(t),a=String(Math.floor(i));return s.length>=a.length}return a.length-n-1>=s}focusNextInput(t,e){const i={degrees:"Minutes",minutes:"Seconds",seconds:"Direction"}[e];if(!i)return;const s=`${t}${i}Input`,a=this.$refs[s];a&&(a.focus(),a instanceof HTMLInputElement&&a.select())}toggleDirection(t){if(this.$data.disabled||this.$data.readonly)return;const e="latitude"===t?"latitudeDirectionOpen":"longitudeDirectionOpen",i=this.$data[e]||!1;this.$data.latitudeDirectionOpen=!1,this.$data.longitudeDirectionOpen=!1,this.$data[e]=!i,this.refresh(),this.$data[e]&&this.registerCloseHandler()}handleDropdownClick(t){t.stopPropagation()}selectDirection(t,e){if(this.$data.disabled||this.$data.readonly)return;u(this,"latitude"===t?a:n).direction=e;const i="latitude"===t?"latitudeDirectionOpen":"longitudeDirectionOpen";this.$data[i]=!1,this.updateDecimalValue(t),this.refresh()}handleFocus(t,e){u(this,o)[t]=!0,this.refresh()}handleBlur(t,e){u(this,o)[t]=!1,this.refresh()}handleSecondsBlur(t,e){u(this,o)[t]=!1;const i=e.target;let s=parseFloat(i.value);const d=this.getFieldLimits(t,"seconds");isNaN(s)?s=0:s<d.min?s=d.min:s>d.max&&(s=d.max);const r=this.$data.precision??3;s=parseFloat(s.toFixed(r)),u(this,"latitude"===t?a:n).seconds=s,this.updateDecimalValue(t),this.refresh(),this.updateSecondsInputs()}handleSecondsKeyDown(t,e){const i=e.target,s=this.$data.precision??3,a=e.key;if(["Backspace","Delete","ArrowLeft","ArrowRight","Tab","Enter","Escape"].includes(a))return;if((e.ctrlKey||e.metaKey)&&["a","c","v","x"].includes(a.toLowerCase()))return;if(!/[0-9.]/.test(a))return void e.preventDefault();if("."===a)return i.value.includes(".")||0===s?void e.preventDefault():void 0;const n=i.value,o=i.selectionStart??0,d=i.selectionEnd??0,r=n.slice(0,o)+a+n.slice(d),l=parseFloat(r);if(!isNaN(l)&&l>59)return void e.preventDefault();const u=n.indexOf(".");-1!==u&&o>u&&n.length-u-1>=s&&e.preventDefault()}getFieldLimits(t,e){const i="latitude"===t;switch(e){case"degrees":return{min:0,max:i?90:180};case"minutes":case"seconds":return{min:0,max:59};default:return{min:0,max:0}}}updateDecimalValue(t){const e=u(this,"latitude"===t?a:n),i=this.dmsToDecimal(e);"latitude"===t?this.$data.latitude=i:this.$data.longitude=i,this.refresh()}dmsToDecimal(t){let e=t.degrees+t.minutes/60+t.seconds/3600;return"S"!==t.direction&&"W"!==t.direction||(e=-e),e}decimalToDms(t,e){const i="latitude"===e;let s=i?"N":"E";t<0&&(t=-t,s=i?"S":"W");const a=Math.floor(t),n=60*(t-a),o=Math.floor(n);return{degrees:a,minutes:o,seconds:parseFloat((60*(n-o)).toFixed(3)),direction:s}}getValue(){return{latitude:this.$data.latitude||0,longitude:this.$data.longitude||0}}getDmsCoordinateValue(){return{latitude:{...u(this,a)},longitude:{...u(this,n)}}}setValue(t,e){this.$data.latitude=t,this.$data.longitude=e,c(this,a,this.decimalToDms(t,"latitude")),c(this,n,this.decimalToDms(e,"longitude")),this.refresh()}clear(){this.$data.latitude=0,this.$data.longitude=0,c(this,a,{degrees:0,minutes:0,seconds:0,direction:"N"}),c(this,n,{degrees:0,minutes:0,seconds:0,direction:"E"}),this.refresh(),this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0}))}get value(){return this.getValue()}set value(t){Array.isArray(t)?this.setValue(t[0],t[1]):this.setValue(t.latitude,t.longitude)}};a=new WeakMap,n=new WeakMap,o=new WeakMap,d=new WeakMap,p=((t,e)=>{for(var i,s=e,a=t.length-1;a>=0;a--)(i=t[a])&&(s=i(s)||s);return s})([s({tagName:"solely-coordinate-input",template:e,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"both"},{name:"latitude",type:"number"},{name:"longitude",type:"number"},{name:"disabled",type:"boolean",default:!1},{name:"readonly",type:"boolean",default:!1},{name:"placeholder",type:"string",default:""},{name:"size",type:"string",default:"medium"},{name:"showDirection",type:"boolean",default:!1},{name:"precision",type:"number",default:3},{name:"showDecimal",type:"boolean",default:!1},{name:"autoTab",type:"boolean",default:!1},{name:"latitudeDirectionOpen",type:"boolean",default:!1},{name:"longitudeDirectionOpen",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],p);export{p as SolelyCoordinateInput};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,t=(t,a,s)=>((t,a,s)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s)(t,"symbol"!=typeof a?a+"":a,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./style.css.cjs"),s=require("./index.html.cjs"),r=require("../../../runtime/component/base-element.cjs"),l=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyInput=class extends r.default{constructor(){super(...arguments),t(this,"_filteredSuggestions",[]),t(this,"inputElement"),t(this,"searchDebounceTimer")}get filteredSuggestions(){return this._filteredSuggestions}mounted(){this.refresh(),this.$data.autofocus&&this.focus()}hasPrefixSlot(){return null!==this.querySelector('[slot="prefix"]')}hasSuffixSlot(){return null!==this.querySelector('[slot="suffix"]')}afterMount(){var e;this.inputElement=null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea")}getWrapperClasses(){const e={};return"small"===this.$data.size?e["form-control--sm"]=!0:"large"===this.$data.size&&(e["form-control--lg"]=!0),"error"===this.$data.status?e["is-error"]=!0:"warning"===this.$data.status?e["is-warning"]=!0:"success"===this.$data.status&&(e["is-success"]=!0),"textarea"===this.$data.type&&(e["form-control--textarea"]=!0),e["is-focused"]=!!this.$data.focused,e["is-disabled"]=!!this.$data.disabled,e["is-readonly"]=!!this.$data.readonly,e["form-control--block"]=!!this.$data.block,e}getCharCount(){var e;return(null==(e=this.$data.value)?void 0:e.length)||0}formatValue(e){if(!e)return"";switch(this.$data.format){case"phone":return e.replace(/(\d{3})(\d{4})(\d{4})/,"$1 $2 $3").trim();case"bankcard":return e.replace(/(\d{4})(?=\d)/g,"$1 ").trim();case"idcard":return e.replace(/(\d{6})(\d{4})(\d{4})(\d{4})(\d{0,4})/,"$1 $2 $3 $4 $5").trim();default:return e}}unformatValue(e){return e?e.replace(/\s/g,""):""}handleInput(e){const t=e.target;let a=t.value;if("none"!==this.$data.format&&"textarea"!==this.$data.type){const e=this.unformatValue(a),s=this.formatValue(e);s!==a&&(t.value=s,a=s)}this.$data.value=a,this.$data.suggestions&&this.$data.suggestions.length>0&&this.updateSuggestions(a)}handleFocus(e){this.$data.focused=!0,this.$data.selectall&&this.$data.value&&this.select()}handleBlur(e){this.$data.focused=!1}handleChange(e){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleKeydown(e){"Enter"===e.key&&"search"===this.$data.type&&this.emit("search",{value:this.$data.value})}handleClear(){this.$data.value="",this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.focus()}togglePassword(){this.$data.passwordVisible=!this.$data.passwordVisible}async handleCopy(){try{const e=this.unformatValue(this.$data.value);await navigator.clipboard.writeText(e),this.emit("copy",{value:e})}catch(e){this.emit("copy-error",{error:e})}}updateSuggestions(e){this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=setTimeout(()=>{this._updateSuggestionsImpl(e),this.searchDebounceTimer=void 0},300)}_updateSuggestionsImpl(e){if(!e||!this.$data.suggestions)return this._filteredSuggestions=[],void this.refresh();this._filteredSuggestions=this.$data.suggestions.filter(t=>t.toLowerCase().includes(e.toLowerCase())),this.refresh()}selectSuggestion(e){this.$data.value=e,this._filteredSuggestions=[],this.refresh(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}focus(){var e;null==(e=this.inputElement)||e.focus(),this.$data.focused=!0}blur(){var e;null==(e=this.inputElement)||e.blur(),this.$data.focused=!1}setValue(e){this.$data.value=e}getValue(){return this.unformatValue(this.$data.value)}get value(){return this.getValue()}set value(e){this.setValue(e)}select(){var e;null==(e=this.inputElement)||e.select()}},exports.SolelyInput=((e,t)=>{for(var a,s=t,r=e.length-1;r>=0;r--)(a=e[r])&&(s=a(s)||s);return s})([l.CustomElement({tagName:"solely-input",template:s.__SOLELY_IR__,styles:a.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"text"},{name:"size",type:"string",default:""},{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:""},{name:"disabled",type:"boolean",default:!1},{name:"readonly",type:"boolean",default:!1},{name:"required",type:"boolean",default:!1},{name:"maxlength",type:"number"},{name:"minlength",type:"number"},{name:"clearable",type:"boolean",default:!1},{name:"showpassword",type:"boolean",default:!1},{name:"passwordVisible",type:"boolean",default:!1},{name:"focused",type:"boolean",default:!1},{name:"prefix",type:"string",default:""},{name:"suffix",type:"string",default:""},{name:"status",type:"string",default:""},{name:"message",type:"string",default:""},{name:"showcount",type:"boolean",default:!1},{name:"rows",type:"number",default:3},{name:"autofocus",type:"boolean",default:!1},{name:"selectall",type:"boolean",default:!1},{name:"copyable",type:"boolean",default:!1},{name:"format",type:"string",default:"none"},{name:"suggestions",type:"array",default:[]},{name:"block",type:"boolean",default:!1}]})],exports.SolelyInput);
1
+ "use strict";var e=Object.defineProperty,t=(t,a,s)=>((t,a,s)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s)(t,"symbol"!=typeof a?a+"":a,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./style.css.cjs"),s=require("./index.html.cjs"),r=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyInput=class extends r.default{constructor(){super(...arguments),t(this,"_filteredSuggestions",[]),t(this,"inputElement"),t(this,"searchDebounceTimer")}get filteredSuggestions(){return this._filteredSuggestions}mounted(){var e;this.refresh(),this.inputElement=null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea"),this.$data.autofocus&&this.focus()}unmounted(){this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=void 0)}hasPrefixSlot(){return null!==this.querySelector('[slot="prefix"]')}hasSuffixSlot(){return null!==this.querySelector('[slot="suffix"]')}getWrapperClasses(){const e={};return"small"===this.$data.size?e["form-control--sm"]=!0:"large"===this.$data.size&&(e["form-control--lg"]=!0),"error"===this.$data.status?e["is-error"]=!0:"warning"===this.$data.status?e["is-warning"]=!0:"success"===this.$data.status&&(e["is-success"]=!0),"textarea"===this.$data.type&&(e["form-control--textarea"]=!0),e["is-focused"]=!!this.$data.focused,e["is-disabled"]=!!this.$data.disabled,e["is-readonly"]=!!this.$data.readonly,e["form-control--block"]=!!this.$data.block,e}getCharCount(){var e;return(null==(e=this.$data.value)?void 0:e.length)||0}formatValue(e){if(!e)return"";switch(this.$data.format){case"phone":return e.replace(/(\d{3})(\d{4})(\d{4})/,"$1 $2 $3").trim();case"bankcard":return e.replace(/(\d{4})(?=\d)/g,"$1 ").trim();case"idcard":return e.replace(/(\d{6})(\d{4})(\d{4})(\d{4})(\d{0,4})/,"$1 $2 $3 $4 $5").trim();default:return e}}unformatValue(e){return e?e.replace(/\s/g,""):""}handleInput(e){const t=e.target;let a=t.value;if("none"!==this.$data.format&&"textarea"!==this.$data.type){const e=this.unformatValue(a),s=this.formatValue(e);s!==a&&(t.value=s,a=s)}this.$data.value=a,this.$data.suggestions&&this.$data.suggestions.length>0&&this.updateSuggestions(a)}handleFocus(e){this.$data.focused=!0,this.$data.selectall&&this.$data.value&&this.select()}handleBlur(e){this.$data.focused=!1}handleChange(e){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleKeydown(e){"Enter"===e.key&&"search"===this.$data.type&&this.emit("search",{value:this.$data.value})}handleClear(){this.$data.value="",this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.focus()}togglePassword(){this.$data.passwordVisible=!this.$data.passwordVisible}async handleCopy(){try{const e=this.unformatValue(this.$data.value);await navigator.clipboard.writeText(e),this.emit("copy",{value:e})}catch(e){this.emit("copy-error",{error:e})}}updateSuggestions(e){this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=setTimeout(()=>{this._updateSuggestionsImpl(e),this.searchDebounceTimer=void 0},300)}_updateSuggestionsImpl(e){if(!e||!this.$data.suggestions)return this._filteredSuggestions=[],void this.refresh();this._filteredSuggestions=this.$data.suggestions.filter(t=>t.toLowerCase().includes(e.toLowerCase())),this.refresh()}selectSuggestion(e){this.$data.value=e,this._filteredSuggestions=[],this.refresh(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}focus(){var e;const t=this.inputElement||(null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea"));null==t||t.focus(),this.$data.focused=!0}blur(){var e;const t=this.inputElement||(null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea"));null==t||t.blur(),this.$data.focused=!1}setValue(e){this.$data.value=e}getValue(){return this.unformatValue(this.$data.value)}get value(){return this.getValue()}set value(e){this.setValue(e)}select(){var e;const t=this.inputElement||(null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea"));null==t||t.select()}},exports.SolelyInput=((e,t)=>{for(var a,s=t,r=e.length-1;r>=0;r--)(a=e[r])&&(s=a(s)||s);return s})([i.CustomElement({tagName:"solely-input",template:s.__SOLELY_IR__,styles:a.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"text"},{name:"size",type:"string",default:""},{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:""},{name:"disabled",type:"boolean",default:!1},{name:"readonly",type:"boolean",default:!1},{name:"required",type:"boolean",default:!1},{name:"maxlength",type:"number"},{name:"minlength",type:"number"},{name:"clearable",type:"boolean",default:!1},{name:"showpassword",type:"boolean",default:!1},{name:"passwordVisible",type:"boolean",default:!1},{name:"focused",type:"boolean",default:!1},{name:"prefix",type:"string",default:""},{name:"suffix",type:"string",default:""},{name:"status",type:"string",default:""},{name:"message",type:"string",default:""},{name:"showcount",type:"boolean",default:!1},{name:"rows",type:"number",default:3},{name:"autofocus",type:"boolean",default:!1},{name:"selectall",type:"boolean",default:!1},{name:"copyable",type:"boolean",default:!1},{name:"format",type:"string",default:"none"},{name:"suggestions",type:"array",default:[]},{name:"block",type:"boolean",default:!1}]})],exports.SolelyInput);
@@ -15,6 +15,7 @@ declare class SolelyInput extends BaseElement<InputProps, InputRefs> {
15
15
  * 组件挂载后
16
16
  */
17
17
  mounted(): void;
18
+ unmounted(): void;
18
19
  /**
19
20
  * 检查是否有 prefix 插槽
20
21
  */
@@ -23,7 +24,6 @@ declare class SolelyInput extends BaseElement<InputProps, InputRefs> {
23
24
  * 检查是否有 suffix 插槽
24
25
  */
25
26
  hasSuffixSlot(): boolean;
26
- protected afterMount(): void;
27
27
  /**
28
28
  * 获取 wrapper class 对象
29
29
  */
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,a,s)=>((t,a,s)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s)(t,"symbol"!=typeof a?a+"":a,s);import a from"./style.css.js";import{__SOLELY_IR__ as s}from"./index.html.js";import r from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let n=class extends r{constructor(){super(...arguments),t(this,"_filteredSuggestions",[]),t(this,"inputElement"),t(this,"searchDebounceTimer")}get filteredSuggestions(){return this._filteredSuggestions}mounted(){this.refresh(),this.$data.autofocus&&this.focus()}hasPrefixSlot(){return null!==this.querySelector('[slot="prefix"]')}hasSuffixSlot(){return null!==this.querySelector('[slot="suffix"]')}afterMount(){var e;this.inputElement=null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea")}getWrapperClasses(){const e={};return"small"===this.$data.size?e["form-control--sm"]=!0:"large"===this.$data.size&&(e["form-control--lg"]=!0),"error"===this.$data.status?e["is-error"]=!0:"warning"===this.$data.status?e["is-warning"]=!0:"success"===this.$data.status&&(e["is-success"]=!0),"textarea"===this.$data.type&&(e["form-control--textarea"]=!0),e["is-focused"]=!!this.$data.focused,e["is-disabled"]=!!this.$data.disabled,e["is-readonly"]=!!this.$data.readonly,e["form-control--block"]=!!this.$data.block,e}getCharCount(){var e;return(null==(e=this.$data.value)?void 0:e.length)||0}formatValue(e){if(!e)return"";switch(this.$data.format){case"phone":return e.replace(/(\d{3})(\d{4})(\d{4})/,"$1 $2 $3").trim();case"bankcard":return e.replace(/(\d{4})(?=\d)/g,"$1 ").trim();case"idcard":return e.replace(/(\d{6})(\d{4})(\d{4})(\d{4})(\d{0,4})/,"$1 $2 $3 $4 $5").trim();default:return e}}unformatValue(e){return e?e.replace(/\s/g,""):""}handleInput(e){const t=e.target;let a=t.value;if("none"!==this.$data.format&&"textarea"!==this.$data.type){const e=this.unformatValue(a),s=this.formatValue(e);s!==a&&(t.value=s,a=s)}this.$data.value=a,this.$data.suggestions&&this.$data.suggestions.length>0&&this.updateSuggestions(a)}handleFocus(e){this.$data.focused=!0,this.$data.selectall&&this.$data.value&&this.select()}handleBlur(e){this.$data.focused=!1}handleChange(e){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleKeydown(e){"Enter"===e.key&&"search"===this.$data.type&&this.emit("search",{value:this.$data.value})}handleClear(){this.$data.value="",this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.focus()}togglePassword(){this.$data.passwordVisible=!this.$data.passwordVisible}async handleCopy(){try{const e=this.unformatValue(this.$data.value);await navigator.clipboard.writeText(e),this.emit("copy",{value:e})}catch(e){this.emit("copy-error",{error:e})}}updateSuggestions(e){this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=setTimeout(()=>{this._updateSuggestionsImpl(e),this.searchDebounceTimer=void 0},300)}_updateSuggestionsImpl(e){if(!e||!this.$data.suggestions)return this._filteredSuggestions=[],void this.refresh();this._filteredSuggestions=this.$data.suggestions.filter(t=>t.toLowerCase().includes(e.toLowerCase())),this.refresh()}selectSuggestion(e){this.$data.value=e,this._filteredSuggestions=[],this.refresh(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}focus(){var e;null==(e=this.inputElement)||e.focus(),this.$data.focused=!0}blur(){var e;null==(e=this.inputElement)||e.blur(),this.$data.focused=!1}setValue(e){this.$data.value=e}getValue(){return this.unformatValue(this.$data.value)}get value(){return this.getValue()}set value(e){this.setValue(e)}select(){var e;null==(e=this.inputElement)||e.select()}};n=((e,t)=>{for(var a,s=t,r=e.length-1;r>=0;r--)(a=e[r])&&(s=a(s)||s);return s})([i({tagName:"solely-input",template:s,styles:a,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"text"},{name:"size",type:"string",default:""},{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:""},{name:"disabled",type:"boolean",default:!1},{name:"readonly",type:"boolean",default:!1},{name:"required",type:"boolean",default:!1},{name:"maxlength",type:"number"},{name:"minlength",type:"number"},{name:"clearable",type:"boolean",default:!1},{name:"showpassword",type:"boolean",default:!1},{name:"passwordVisible",type:"boolean",default:!1},{name:"focused",type:"boolean",default:!1},{name:"prefix",type:"string",default:""},{name:"suffix",type:"string",default:""},{name:"status",type:"string",default:""},{name:"message",type:"string",default:""},{name:"showcount",type:"boolean",default:!1},{name:"rows",type:"number",default:3},{name:"autofocus",type:"boolean",default:!1},{name:"selectall",type:"boolean",default:!1},{name:"copyable",type:"boolean",default:!1},{name:"format",type:"string",default:"none"},{name:"suggestions",type:"array",default:[]},{name:"block",type:"boolean",default:!1}]})],n);export{n as SolelyInput};
1
+ var e=Object.defineProperty,t=(t,a,s)=>((t,a,s)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s)(t,"symbol"!=typeof a?a+"":a,s);import a from"./style.css.js";import{__SOLELY_IR__ as s}from"./index.html.js";import r from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let o=class extends r{constructor(){super(...arguments),t(this,"_filteredSuggestions",[]),t(this,"inputElement"),t(this,"searchDebounceTimer")}get filteredSuggestions(){return this._filteredSuggestions}mounted(){var e;this.refresh(),this.inputElement=null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea"),this.$data.autofocus&&this.focus()}unmounted(){this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=void 0)}hasPrefixSlot(){return null!==this.querySelector('[slot="prefix"]')}hasSuffixSlot(){return null!==this.querySelector('[slot="suffix"]')}getWrapperClasses(){const e={};return"small"===this.$data.size?e["form-control--sm"]=!0:"large"===this.$data.size&&(e["form-control--lg"]=!0),"error"===this.$data.status?e["is-error"]=!0:"warning"===this.$data.status?e["is-warning"]=!0:"success"===this.$data.status&&(e["is-success"]=!0),"textarea"===this.$data.type&&(e["form-control--textarea"]=!0),e["is-focused"]=!!this.$data.focused,e["is-disabled"]=!!this.$data.disabled,e["is-readonly"]=!!this.$data.readonly,e["form-control--block"]=!!this.$data.block,e}getCharCount(){var e;return(null==(e=this.$data.value)?void 0:e.length)||0}formatValue(e){if(!e)return"";switch(this.$data.format){case"phone":return e.replace(/(\d{3})(\d{4})(\d{4})/,"$1 $2 $3").trim();case"bankcard":return e.replace(/(\d{4})(?=\d)/g,"$1 ").trim();case"idcard":return e.replace(/(\d{6})(\d{4})(\d{4})(\d{4})(\d{0,4})/,"$1 $2 $3 $4 $5").trim();default:return e}}unformatValue(e){return e?e.replace(/\s/g,""):""}handleInput(e){const t=e.target;let a=t.value;if("none"!==this.$data.format&&"textarea"!==this.$data.type){const e=this.unformatValue(a),s=this.formatValue(e);s!==a&&(t.value=s,a=s)}this.$data.value=a,this.$data.suggestions&&this.$data.suggestions.length>0&&this.updateSuggestions(a)}handleFocus(e){this.$data.focused=!0,this.$data.selectall&&this.$data.value&&this.select()}handleBlur(e){this.$data.focused=!1}handleChange(e){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleKeydown(e){"Enter"===e.key&&"search"===this.$data.type&&this.emit("search",{value:this.$data.value})}handleClear(){this.$data.value="",this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.focus()}togglePassword(){this.$data.passwordVisible=!this.$data.passwordVisible}async handleCopy(){try{const e=this.unformatValue(this.$data.value);await navigator.clipboard.writeText(e),this.emit("copy",{value:e})}catch(e){this.emit("copy-error",{error:e})}}updateSuggestions(e){this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=setTimeout(()=>{this._updateSuggestionsImpl(e),this.searchDebounceTimer=void 0},300)}_updateSuggestionsImpl(e){if(!e||!this.$data.suggestions)return this._filteredSuggestions=[],void this.refresh();this._filteredSuggestions=this.$data.suggestions.filter(t=>t.toLowerCase().includes(e.toLowerCase())),this.refresh()}selectSuggestion(e){this.$data.value=e,this._filteredSuggestions=[],this.refresh(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}focus(){var e;const t=this.inputElement||(null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea"));null==t||t.focus(),this.$data.focused=!0}blur(){var e;const t=this.inputElement||(null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea"));null==t||t.blur(),this.$data.focused=!1}setValue(e){this.$data.value=e}getValue(){return this.unformatValue(this.$data.value)}get value(){return this.getValue()}set value(e){this.setValue(e)}select(){var e;const t=this.inputElement||(null==(e=this.shadowRoot)?void 0:e.querySelector("input, textarea"));null==t||t.select()}};o=((e,t)=>{for(var a,s=t,r=e.length-1;r>=0;r--)(a=e[r])&&(s=a(s)||s);return s})([i({tagName:"solely-input",template:s,styles:a,shadowDOM:{use:!0,mode:"open"},props:[{name:"type",type:"string",default:"text"},{name:"size",type:"string",default:""},{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:""},{name:"disabled",type:"boolean",default:!1},{name:"readonly",type:"boolean",default:!1},{name:"required",type:"boolean",default:!1},{name:"maxlength",type:"number"},{name:"minlength",type:"number"},{name:"clearable",type:"boolean",default:!1},{name:"showpassword",type:"boolean",default:!1},{name:"passwordVisible",type:"boolean",default:!1},{name:"focused",type:"boolean",default:!1},{name:"prefix",type:"string",default:""},{name:"suffix",type:"string",default:""},{name:"status",type:"string",default:""},{name:"message",type:"string",default:""},{name:"showcount",type:"boolean",default:!1},{name:"rows",type:"number",default:3},{name:"autofocus",type:"boolean",default:!1},{name:"selectall",type:"boolean",default:!1},{name:"copyable",type:"boolean",default:!1},{name:"format",type:"string",default:"none"},{name:"suggestions",type:"array",default:[]},{name:"block",type:"boolean",default:!1}]})],o);export{o as SolelyInput};
@@ -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.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.refresh(),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;const s={current:1,pageSize:a};this.emit("sizeChange",s),this.emit("showSizeChange",s)}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.__SOLELY_IR__,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 CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:e,pageSize:this.$data.pageSize}}))}get pageSize(){return this.$data.pageSize}set pageSize(e){this.$data.pageSize=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:this.$data.current,pageSize:e}}))}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.refresh(),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;const s={current:1,pageSize:a};this.emit("sizeChange",s),this.emit("showSizeChange",s)}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.__SOLELY_IR__,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 +1 @@
1
- import e from"./style.css.js";import{__SOLELY_IR__ as 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.refresh(),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;const s={current:1,pageSize:a};this.emit("sizeChange",s),this.emit("showSizeChange",s)}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
+ import e from"./style.css.js";import{__SOLELY_IR__ as 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 CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:e,pageSize:this.$data.pageSize}}))}get pageSize(){return this.$data.pageSize}set pageSize(e){this.$data.pageSize=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:this.$data.current,pageSize:e}}))}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.refresh(),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;const s={current:1,pageSize:a};this.emit("sizeChange",s),this.emit("showSizeChange",s)}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";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.SolelyRadio=class extends a.default{get checked(){return this.$data.checked}set checked(e){this.setChecked(e)}get value(){return this.$data.value}set value(e){this.$data.value=e}getRadioClasses(){return{"is-checked":!!this.$data.checked,"is-disabled":!!this.$data.disabled,[`radio--${this.$data.type}`]:!!this.$data.type,"radio--block":!!this.$data.block}}mounted(){this.refresh()}handleClick(e){this.$data.disabled||this.$data.checked||(this.$data.name&&this.uncheckSameNameRadios(),this.$data.checked=!0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}uncheckSameNameRadios(){const e=this.$data.name;e&&this.getRootNode().querySelectorAll("solely-radio").forEach(t=>{if(t!==this&&t.getAttribute("name")===e){const e=t;"function"==typeof(null==e?void 0:e.setChecked)&&e.setChecked(!1)}})}setChecked(e){this.$data.checked=e}getChecked(){return this.$data.checked}},exports.SolelyRadio=((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-radio",template:t.__SOLELY_IR__,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"checked",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"content",type:"string",default:""},{name:"value",type:"string",default:""},{name:"type",type:"string",default:"primary"},{name:"name",type:"string",default:""},{name:"block",type:"boolean",default:!1}],model:{prop:"checked",event:"change"}})],exports.SolelyRadio);
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.SolelyRadio=class extends a.default{get checked(){return this.$data.checked}set checked(e){this.setChecked(e)}get value(){return this.$data.value}set value(e){this.$data.value=e}getRadioClasses(){return{"is-checked":!!this.$data.checked,"is-disabled":!!this.$data.disabled,[`radio--${this.$data.type}`]:!!this.$data.type,"radio--block":!!this.$data.block}}mounted(){this.refresh(),this.updateAriaAttributes()}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".radio");t&&(t.setAttribute("aria-checked",this.$data.checked?"true":"false"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}handleClick(e){this.$data.disabled||this.$data.checked||(this.$data.name&&this.uncheckSameNameRadios(),this.$data.checked=!0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleKeyDown(e){this.$data.disabled||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick(e))}uncheckSameNameRadios(){const e=this.$data.name;e&&this.getRootNode().querySelectorAll("solely-radio").forEach(t=>{if(t!==this&&t.getAttribute("name")===e){const e=t;"function"==typeof(null==e?void 0:e.setChecked)&&e.setChecked(!1)}})}setChecked(e){this.$data.checked=e}getChecked(){return this.$data.checked}},exports.SolelyRadio=((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-radio",template:t.__SOLELY_IR__,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"checked",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"content",type:"string",default:""},{name:"value",type:"string",default:""},{name:"type",type:"string",default:"primary"},{name:"name",type:"string",default:""},{name:"block",type:"boolean",default:!1}],model:{prop:"checked",event:"change"}})],exports.SolelyRadio);
@@ -25,10 +25,13 @@ declare class SolelyRadio extends BaseElement<RadioProps> {
25
25
  * 组件挂载后
26
26
  */
27
27
  mounted(): void;
28
+ updated(): void;
29
+ private updateAriaAttributes;
28
30
  /**
29
31
  * 点击事件处理
30
32
  */
31
33
  handleClick(_event: Event): void;
34
+ handleKeyDown(event: KeyboardEvent): void;
32
35
  /**
33
36
  * 取消同组其他单选框的选中状态
34
37
  */
@@ -1 +1 @@
1
- import e from"./style.css.js";import{__SOLELY_IR__ as 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{get checked(){return this.$data.checked}set checked(e){this.setChecked(e)}get value(){return this.$data.value}set value(e){this.$data.value=e}getRadioClasses(){return{"is-checked":!!this.$data.checked,"is-disabled":!!this.$data.disabled,[`radio--${this.$data.type}`]:!!this.$data.type,"radio--block":!!this.$data.block}}mounted(){this.refresh()}handleClick(e){this.$data.disabled||this.$data.checked||(this.$data.name&&this.uncheckSameNameRadios(),this.$data.checked=!0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}uncheckSameNameRadios(){const e=this.$data.name;e&&this.getRootNode().querySelectorAll("solely-radio").forEach(t=>{if(t!==this&&t.getAttribute("name")===e){const e=t;"function"==typeof(null==e?void 0:e.setChecked)&&e.setChecked(!1)}})}setChecked(e){this.$data.checked=e}getChecked(){return this.$data.checked}};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-radio",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"checked",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"content",type:"string",default:""},{name:"value",type:"string",default:""},{name:"type",type:"string",default:"primary"},{name:"name",type:"string",default:""},{name:"block",type:"boolean",default:!1}],model:{prop:"checked",event:"change"}})],d);export{d as SolelyRadio};
1
+ import e from"./style.css.js";import{__SOLELY_IR__ as 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{get checked(){return this.$data.checked}set checked(e){this.setChecked(e)}get value(){return this.$data.value}set value(e){this.$data.value=e}getRadioClasses(){return{"is-checked":!!this.$data.checked,"is-disabled":!!this.$data.disabled,[`radio--${this.$data.type}`]:!!this.$data.type,"radio--block":!!this.$data.block}}mounted(){this.refresh(),this.updateAriaAttributes()}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".radio");t&&(t.setAttribute("aria-checked",this.$data.checked?"true":"false"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}handleClick(e){this.$data.disabled||this.$data.checked||(this.$data.name&&this.uncheckSameNameRadios(),this.$data.checked=!0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleKeyDown(e){this.$data.disabled||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick(e))}uncheckSameNameRadios(){const e=this.$data.name;e&&this.getRootNode().querySelectorAll("solely-radio").forEach(t=>{if(t!==this&&t.getAttribute("name")===e){const e=t;"function"==typeof(null==e?void 0:e.setChecked)&&e.setChecked(!1)}})}setChecked(e){this.$data.checked=e}getChecked(){return this.$data.checked}};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-radio",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"checked",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"content",type:"string",default:""},{name:"value",type:"string",default:""},{name:"type",type:"string",default:"primary"},{name:"name",type:"string",default:""},{name:"block",type:"boolean",default:!1}],model:{prop:"checked",event:"change"}})],d);export{d as SolelyRadio};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),a=require("./index.html.cjs"),t=require("../../../runtime/component/base-element.cjs"),s=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyRate=class extends t.default{getRateClasses(){return{"is-disabled":!!this.$data.disabled,"is-readonly":!!this.$data.readonly}}get value(){return this.$data.value||0}set value(e){this.$data.disabled||this.$data.readonly||this.setValue(e)}getStarClasses(e){const a=this.$data.hoverValue,t=this.$data.value||0,s=void 0!==a?a:t;return{"rate__star--full":e<=s,"rate__star--half":!!this.$data.allowHalf&&e-.5===s,"rate__star--zero":e>s}}mounted(){this.refresh(),this.$data.hoverValue=void 0,this.generateStarCount()}generateStarCount(){const e=this.$data.count||5;this.$data.starCount=Array.from({length:e},(e,a)=>a+1)}handleClick(e){if(this.$data.disabled||this.$data.readonly)return;const a=this.$data.allowHalf&&this.$data.hoverValue||e;this.$data.allowClear&&a===this.$data.value?this.$data.value=0:this.$data.value=a,this.$data.hoverValue=void 0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleMouseEnter(e){this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=e)}handleMouseLeave(){this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=void 0)}setValue(e){this.$data.value=e}getValue(){return this.$data.value}},exports.SolelyRate=((e,a)=>{for(var t,s=a,l=e.length-1;l>=0;l--)(t=e[l])&&(s=t(s)||s);return s})([s.CustomElement({tagName:"solely-rate",template:a.__SOLELY_IR__,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"number",default:0},{name:"count",type:"number"},{name:"allowHalf",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"allowClear",type:"boolean",default:!1},{name:"character",type:"string"},{name:"readonly",type:"boolean",default:!1}]})],exports.SolelyRate);
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),a=require("./index.html.cjs"),e=require("../../../runtime/component/base-element.cjs"),s=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyRate=class extends e.default{getRateClasses(){return{"is-disabled":!!this.$data.disabled,"is-readonly":!!this.$data.readonly}}get value(){return this.$data.value||0}set value(t){this.$data.disabled||this.$data.readonly||this.setValue(t)}getStarClasses(t){const a=this.$data.hoverValue,e=this.$data.value||0,s=void 0!==a?a:e;return{"rate__star--full":t<=s,"rate__star--half":!!this.$data.allowHalf&&t-.5===s,"rate__star--zero":t>s}}mounted(){this.refresh(),this.$data.hoverValue=void 0,this.generateStarCount()}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var t;const a=null==(t=this.shadowRoot)?void 0:t.querySelector(".rate");a&&(a.setAttribute("aria-valuenow",String(this.$data.value||0)),a.setAttribute("aria-valuemin","0"),a.setAttribute("aria-valuemax",String(this.$data.count||5)),a.setAttribute("aria-disabled",this.$data.disabled?"true":"false"),a.setAttribute("aria-readonly",this.$data.readonly?"true":"false"))}generateStarCount(){const t=this.$data.count||5;this.$data.starCount=Array.from({length:t},(t,a)=>a+1)}handleClick(t){if(this.$data.disabled||this.$data.readonly)return;const a=this.$data.allowHalf&&this.$data.hoverValue||t;this.$data.allowClear&&a===this.$data.value?this.$data.value=0:this.$data.value=a,this.$data.hoverValue=void 0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleMouseEnter(t){this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=t)}handleMouseLeave(){this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=void 0)}handleKeyDown(t){if(this.$data.disabled||this.$data.readonly)return;const a=this.$data.count||5,e=this.$data.value||0;if("ArrowRight"===t.key||"ArrowUp"===t.key){t.preventDefault();const s=this.$data.allowHalf?.5:1,l=Math.min(a,e+s);this.$data.value=l,this.dispatchChangeEvent()}else if("ArrowLeft"===t.key||"ArrowDown"===t.key){t.preventDefault();const a=this.$data.allowHalf?.5:1,s=Math.max(0,e-a);this.$data.value=s,this.dispatchChangeEvent()}}dispatchChangeEvent(){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}setValue(t){this.$data.value=t}getValue(){return this.$data.value}},exports.SolelyRate=((t,a)=>{for(var e,s=a,l=t.length-1;l>=0;l--)(e=t[l])&&(s=e(s)||s);return s})([s.CustomElement({tagName:"solely-rate",template:a.__SOLELY_IR__,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"number",default:0},{name:"count",type:"number"},{name:"allowHalf",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"allowClear",type:"boolean",default:!1},{name:"character",type:"string"},{name:"readonly",type:"boolean",default:!1}]})],exports.SolelyRate);
@@ -18,6 +18,8 @@ declare class SolelyRate extends BaseElement<RateProps & {
18
18
  */
19
19
  getStarClasses(i: number): Record<string, boolean>;
20
20
  mounted(): void;
21
+ updated(): void;
22
+ private updateAriaAttributes;
21
23
  /**
22
24
  * 生成星星数量数组
23
25
  */
@@ -34,6 +36,8 @@ declare class SolelyRate extends BaseElement<RateProps & {
34
36
  * 鼠标离开
35
37
  */
36
38
  handleMouseLeave(): void;
39
+ handleKeyDown(event: KeyboardEvent): void;
40
+ private dispatchChangeEvent;
37
41
  /**
38
42
  * 设置评分值
39
43
  */
@@ -1 +1 @@
1
- import a from"./style.css.js";import{__SOLELY_IR__ as e}from"./index.html.js";import t from"../../../runtime/component/base-element.js";import{CustomElement as s}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let l=class extends t{getRateClasses(){return{"is-disabled":!!this.$data.disabled,"is-readonly":!!this.$data.readonly}}get value(){return this.$data.value||0}set value(a){this.$data.disabled||this.$data.readonly||this.setValue(a)}getStarClasses(a){const e=this.$data.hoverValue,t=this.$data.value||0,s=void 0!==e?e:t;return{"rate__star--full":a<=s,"rate__star--half":!!this.$data.allowHalf&&a-.5===s,"rate__star--zero":a>s}}mounted(){this.refresh(),this.$data.hoverValue=void 0,this.generateStarCount()}generateStarCount(){const a=this.$data.count||5;this.$data.starCount=Array.from({length:a},(a,e)=>e+1)}handleClick(a){if(this.$data.disabled||this.$data.readonly)return;const e=this.$data.allowHalf&&this.$data.hoverValue||a;this.$data.allowClear&&e===this.$data.value?this.$data.value=0:this.$data.value=e,this.$data.hoverValue=void 0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleMouseEnter(a){this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=a)}handleMouseLeave(){this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=void 0)}setValue(a){this.$data.value=a}getValue(){return this.$data.value}};l=((a,e)=>{for(var t,s=e,l=a.length-1;l>=0;l--)(t=a[l])&&(s=t(s)||s);return s})([s({tagName:"solely-rate",template:e,styles:a,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"number",default:0},{name:"count",type:"number"},{name:"allowHalf",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"allowClear",type:"boolean",default:!1},{name:"character",type:"string"},{name:"readonly",type:"boolean",default:!1}]})],l);export{l as SolelyRate};
1
+ import t from"./style.css.js";import{__SOLELY_IR__ as a}from"./index.html.js";import e from"../../../runtime/component/base-element.js";import{CustomElement as s}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends e{getRateClasses(){return{"is-disabled":!!this.$data.disabled,"is-readonly":!!this.$data.readonly}}get value(){return this.$data.value||0}set value(t){this.$data.disabled||this.$data.readonly||this.setValue(t)}getStarClasses(t){const a=this.$data.hoverValue,e=this.$data.value||0,s=void 0!==a?a:e;return{"rate__star--full":t<=s,"rate__star--half":!!this.$data.allowHalf&&t-.5===s,"rate__star--zero":t>s}}mounted(){this.refresh(),this.$data.hoverValue=void 0,this.generateStarCount()}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var t;const a=null==(t=this.shadowRoot)?void 0:t.querySelector(".rate");a&&(a.setAttribute("aria-valuenow",String(this.$data.value||0)),a.setAttribute("aria-valuemin","0"),a.setAttribute("aria-valuemax",String(this.$data.count||5)),a.setAttribute("aria-disabled",this.$data.disabled?"true":"false"),a.setAttribute("aria-readonly",this.$data.readonly?"true":"false"))}generateStarCount(){const t=this.$data.count||5;this.$data.starCount=Array.from({length:t},(t,a)=>a+1)}handleClick(t){if(this.$data.disabled||this.$data.readonly)return;const a=this.$data.allowHalf&&this.$data.hoverValue||t;this.$data.allowClear&&a===this.$data.value?this.$data.value=0:this.$data.value=a,this.$data.hoverValue=void 0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}handleMouseEnter(t){this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=t)}handleMouseLeave(){this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=void 0)}handleKeyDown(t){if(this.$data.disabled||this.$data.readonly)return;const a=this.$data.count||5,e=this.$data.value||0;if("ArrowRight"===t.key||"ArrowUp"===t.key){t.preventDefault();const s=this.$data.allowHalf?.5:1,r=Math.min(a,e+s);this.$data.value=r,this.dispatchChangeEvent()}else if("ArrowLeft"===t.key||"ArrowDown"===t.key){t.preventDefault();const a=this.$data.allowHalf?.5:1,s=Math.max(0,e-a);this.$data.value=s,this.dispatchChangeEvent()}}dispatchChangeEvent(){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}setValue(t){this.$data.value=t}getValue(){return this.$data.value}};r=((t,a)=>{for(var e,s=a,r=t.length-1;r>=0;r--)(e=t[r])&&(s=e(s)||s);return s})([s({tagName:"solely-rate",template:a,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"number",default:0},{name:"count",type:"number"},{name:"allowHalf",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"allowClear",type:"boolean",default:!1},{name:"character",type:"string"},{name:"readonly",type:"boolean",default:!1}]})],r);export{r as SolelyRate};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,e=(e,a,s)=>((e,a,s)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s)(e,"symbol"!=typeof a?a+"":a,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./style.css.cjs"),s=require("./index.html.cjs"),l=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelySelect=class extends l.default{constructor(){super(...arguments),e(this,"clickOutsideHandler"),e(this,"slotObserver")}get value(){return this.$data.value||""}set value(t){this.$data.disabled||this.setValue(t)}getSelectClasses(){const t={};return"small"===this.$data.size?t["select--sm"]=!0:"large"===this.$data.size?t["select--lg"]=!0:t["select--md"]=!0,t["is-disabled"]=!!this.$data.disabled,t["is-focused"]=!!this.$data.focused,t["is-open"]=!!this.$data.isOpen,t["use-slot"]=this.$data.useSlot,t}getDropdownClasses(){return{"select__dropdown--closing":!!this.$data.closing,"select__dropdown--top":"top"===this.$data.dropdownPlacement,"select__dropdown--bottom":"bottom"===this.$data.dropdownPlacement}}getOptionClasses(t){return{"select__option--selected":t.value===this.$data.value,"select__option--disabled":!!t.disabled}}calculateDropdownPlacement(){const t=this.getBoundingClientRect(),e=window.innerHeight-t.bottom,a=t.top;this.$data.dropdownPlacement=e<256&&a>e?"top":"bottom"}collectSlotOptions(){const t=Array.from(this.children);this.$data.hasHeaderSlot=t.some(t=>"header"===t.getAttribute("slot")),this.$data.hasFooterSlot=t.some(t=>"footer"===t.getAttribute("slot"));const e=t.filter(t=>!t.getAttribute("slot")&&t.hasAttribute("data-value"));0!==e.length?(this.$data.useSlot=!0,this.$data.slotOptions=e.map(t=>{var e;const a=t;return{value:a.getAttribute("data-value")||"",label:a.getAttribute("data-label")||(null==(e=a.textContent)?void 0:e.trim())||"",disabled:a.hasAttribute("disabled"),element:t}}),this.updateSelectedLabelFromSlot()):this.$data.useSlot=!1}updateSelectedLabelFromSlot(){if(!this.$data.slotOptions.length)return;const t=this.$data.slotOptions.find(t=>t.value===this.$data.value);this.$data.selectedLabel=(null==t?void 0:t.label)||""}mounted(){this.refresh(),this.parseOptions(),this.setupSlotObserver(),this.clickOutsideHandler=t=>{t.composedPath().some(t=>t===this)||this.closeDropdown()},document.addEventListener("click",this.clickOutsideHandler)}setupSlotObserver(){setTimeout(()=>{this.collectSlotOptions()},0),this.slotObserver=new MutationObserver(()=>{this.collectSlotOptions()}),this.slotObserver.observe(this,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["data-value","data-label","disabled"]})}unmounted(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.slotObserver&&this.slotObserver.disconnect()}updated(){const t=this.$data.selectedLabel,e=this.getCurrentLabel();t!==e&&(this.$data.selectedLabel=e)}getCurrentLabel(){if(this.$data.useSlot){const t=this.$data.slotOptions.find(t=>t.value===this.$data.value);return(null==t?void 0:t.label)||""}{const t=this.$data.parsedOptions.find(t=>t.value===this.$data.value);return(null==t?void 0:t.label)||""}}parseOptions(){this.$data.parsedOptions=Array.isArray(this.$data.options)?this.$data.options:[],this.$data.useSlot||this.updateSelectedLabel()}updateSelectedLabel(){if(!this.$data.parsedOptions.length)return;const t=this.$data.parsedOptions.find(t=>t.value===this.$data.value);this.$data.selectedLabel=(null==t?void 0:t.label)||""}handleClick(){if(this.$data.disabled)return;const t=!this.$data.isOpen;this.$data.isOpen=t,this.$data.focused=t,t&&this.calculateDropdownPlacement()}handleSelect(t,e){t.disabled||(this.$data.value=t.value,this.updateSelectedLabel(),this.closeDropdown(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleSlotClick(t){var e;const a=t.target.closest("[data-value]");if(!a)return;if(a.hasAttribute("data-group"))return void t.stopPropagation();const s=a.getAttribute("data-value")||"",l=a.getAttribute("data-label")||(null==(e=a.textContent)?void 0:e.trim())||"";a.hasAttribute("disabled")||(this.$data.value=s,this.$data.selectedLabel=l,this.closeDropdown(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleHeaderFooterClick(t){t.stopPropagation()}handleClear(t){t.stopPropagation(),this.$data.value="",this.$data.selectedLabel="",this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}closeDropdown(){this.$data.isOpen&&(this.$data.closing=!0,setTimeout(()=>{this.$data.isOpen=!1,this.$data.closing=!1,this.$data.focused=!1},200))}setValue(t,e=!1){this.$data.value=t,this.$data.useSlot?this.updateSelectedLabelFromSlot():this.updateSelectedLabel(),e||this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getValue(){return this.$data.value||""}setOptions(t){this.$data.options=t,this.$data.useSlot=!1,this.parseOptions()}},exports.SolelySelect=((t,e)=>{for(var a,s=e,l=t.length-1;l>=0;l--)(a=t[l])&&(s=a(s)||s);return s})([i.CustomElement({tagName:"solely-select",template:s.__SOLELY_IR__,styles:a.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:"请选择"},{name:"disabled",type:"boolean",default:!1},{name:"size",type:"string",default:"medium"},{name:"clearable",type:"boolean",default:!1},{name:"options",type:"array",default:[]},{name:"multiple",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelySelect);
1
+ "use strict";var t=Object.defineProperty,e=(e,s,a)=>((e,s,a)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[s]=a)(e,"symbol"!=typeof s?s+"":s,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./style.css.cjs"),a=require("./index.html.cjs"),l=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelySelect=class extends l.default{constructor(){super(...arguments),e(this,"clickOutsideHandler"),e(this,"slotObserver"),e(this,"closeTimer")}get value(){return this.$data.value||""}set value(t){this.$data.disabled||this.setValue(t)}getSelectClasses(){const t={};return"small"===this.$data.size?t["select--sm"]=!0:"large"===this.$data.size?t["select--lg"]=!0:t["select--md"]=!0,t["is-disabled"]=!!this.$data.disabled,t["is-focused"]=!!this.$data.focused,t["is-open"]=!!this.$data.isOpen,t["use-slot"]=this.$data.useSlot,t}getDropdownClasses(){return{"select__dropdown--closing":!!this.$data.closing,"select__dropdown--top":"top"===this.$data.dropdownPlacement,"select__dropdown--bottom":"bottom"===this.$data.dropdownPlacement}}getOptionClasses(t){return{"select__option--selected":t.value===this.$data.value,"select__option--disabled":!!t.disabled}}calculateDropdownPlacement(){const t=this.getBoundingClientRect(),e=window.innerHeight-t.bottom,s=t.top;this.$data.dropdownPlacement=e<256&&s>e?"top":"bottom"}collectSlotOptions(){const t=Array.from(this.children);this.$data.hasHeaderSlot=t.some(t=>"header"===t.getAttribute("slot")),this.$data.hasFooterSlot=t.some(t=>"footer"===t.getAttribute("slot"));const e=t.filter(t=>!t.getAttribute("slot")&&t.hasAttribute("data-value"));0!==e.length?(this.$data.useSlot=!0,this.$data.slotOptions=e.map(t=>{var e;const s=t;return{value:s.getAttribute("data-value")||"",label:s.getAttribute("data-label")||(null==(e=s.textContent)?void 0:e.trim())||"",disabled:s.hasAttribute("disabled"),element:t}}),this.updateSelectedLabelFromSlot()):this.$data.useSlot=!1}updateSelectedLabelFromSlot(){if(!this.$data.slotOptions.length)return;const t=this.$data.slotOptions.find(t=>t.value===this.$data.value);this.$data.selectedLabel=(null==t?void 0:t.label)||""}mounted(){this.refresh(),this.parseOptions(),this.setupSlotObserver(),this.clickOutsideHandler=t=>{t.composedPath().some(t=>t===this)||this.closeDropdown()},document.addEventListener("click",this.clickOutsideHandler)}setupSlotObserver(){setTimeout(()=>{this.collectSlotOptions()},0),this.slotObserver=new MutationObserver(()=>{this.collectSlotOptions()}),this.slotObserver.observe(this,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["data-value","data-label","disabled"]})}unmounted(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.slotObserver&&this.slotObserver.disconnect(),this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=void 0)}updated(){const t=this.$data.selectedLabel,e=this.getCurrentLabel();t!==e&&(this.$data.selectedLabel=e),this.updateAriaAttributes()}updateAriaAttributes(){var t;const e=null==(t=this.shadowRoot)?void 0:t.querySelector(".select__trigger");e&&(e.setAttribute("aria-expanded",this.$data.isOpen?"true":"false"),e.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}getCurrentLabel(){if(this.$data.useSlot){const t=this.$data.slotOptions.find(t=>t.value===this.$data.value);return(null==t?void 0:t.label)||""}{const t=this.$data.parsedOptions.find(t=>t.value===this.$data.value);return(null==t?void 0:t.label)||""}}parseOptions(){this.$data.parsedOptions=Array.isArray(this.$data.options)?this.$data.options:[],this.$data.useSlot||this.updateSelectedLabel()}updateSelectedLabel(){if(!this.$data.parsedOptions.length)return;const t=this.$data.parsedOptions.find(t=>t.value===this.$data.value);this.$data.selectedLabel=(null==t?void 0:t.label)||""}handleClick(){if(this.$data.disabled)return;const t=!this.$data.isOpen;this.$data.isOpen=t,this.$data.focused=t,t&&this.calculateDropdownPlacement()}handleSelect(t,e){t.disabled||(this.$data.value=t.value,this.updateSelectedLabel(),this.closeDropdown(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleSlotClick(t){var e;const s=t.target.closest("[data-value]");if(!s)return;if(s.hasAttribute("data-group"))return void t.stopPropagation();const a=s.getAttribute("data-value")||"",l=s.getAttribute("data-label")||(null==(e=s.textContent)?void 0:e.trim())||"";s.hasAttribute("disabled")||(this.$data.value=a,this.$data.selectedLabel=l,this.closeDropdown(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleHeaderFooterClick(t){t.stopPropagation()}handleClear(t){t.stopPropagation(),this.$data.value="",this.$data.selectedLabel="",this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}closeDropdown(){this.$data.isOpen&&(this.$data.closing=!0,this.closeTimer=setTimeout(()=>{this.$data.isOpen=!1,this.$data.closing=!1,this.$data.focused=!1,this.closeTimer=void 0},200))}setValue(t,e=!1){this.$data.value=t,this.$data.useSlot?this.updateSelectedLabelFromSlot():this.updateSelectedLabel(),e||this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getValue(){return this.$data.value||""}setOptions(t){this.$data.options=t,this.$data.useSlot=!1,this.parseOptions()}},exports.SolelySelect=((t,e)=>{for(var s,a=e,l=t.length-1;l>=0;l--)(s=t[l])&&(a=s(a)||a);return a})([i.CustomElement({tagName:"solely-select",template:a.__SOLELY_IR__,styles:s.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:"请选择"},{name:"disabled",type:"boolean",default:!1},{name:"size",type:"string",default:"medium"},{name:"clearable",type:"boolean",default:!1},{name:"options",type:"array",default:[]},{name:"multiple",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelySelect);
@@ -19,6 +19,7 @@ declare class SolelySelect extends BaseElement<SelectProps & {
19
19
  }> {
20
20
  clickOutsideHandler?: (event: MouseEvent) => void;
21
21
  slotObserver?: MutationObserver;
22
+ private closeTimer?;
22
23
  /**
23
24
  * 暴露 value 属性,使外部可通过 event.target.value 访问
24
25
  */
@@ -63,6 +64,7 @@ declare class SolelySelect extends BaseElement<SelectProps & {
63
64
  * 当 s-model 等外部方式修改 value 时,需要更新 selectedLabel
64
65
  */
65
66
  updated(): void;
67
+ private updateAriaAttributes;
66
68
  /**
67
69
  * 获取当前选中值对应的标签
68
70
  */