litos-ui 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/base.d.ts +6 -3
- package/lib/base.js +49 -39
- package/lib/browser.d.ts +6 -4
- package/lib/button/index.d.ts +4 -0
- package/lib/button/index.js +73 -59
- package/lib/form/form_events.d.ts +12 -4
- package/lib/form/form_events.js +19 -15
- package/lib/form/form_inner.d.ts +34 -0
- package/lib/form/form_inner.js +121 -0
- package/lib/form/form_item.d.ts +33 -0
- package/lib/form/form_item.js +124 -7
- package/lib/form/index.d.ts +22 -1
- package/lib/form/index.js +108 -19
- package/lib/form/types.js +1 -0
- package/lib/icon/arrow_down.js +8 -6
- package/lib/icon/base.js +24 -19
- package/lib/icon/caret_bottom.js +8 -6
- package/lib/icon/caret_top.js +8 -6
- package/lib/icon/font_icon.js +18 -13
- package/lib/icon/info.js +8 -6
- package/lib/icon/loading.js +8 -6
- package/lib/icon/mask_close.js +8 -6
- package/lib/icon/search.js +8 -6
- package/lib/icon/success.js +7 -5
- package/lib/icon/warn.js +8 -6
- package/lib/index-B_9rPBWp.js +4 -0
- package/lib/index-Boq1Q7q9.js +4 -0
- package/lib/index-CCcVpk6U.js +4 -0
- package/lib/index-ColsUDnt.js +4 -0
- package/lib/index-D-Ikkdx0.js +4 -0
- package/lib/index-oNjb_IVt.js +4 -0
- package/lib/index.d.ts +10 -4
- package/lib/index.js +31 -25
- package/lib/input/index.d.ts +17 -16
- package/lib/input/index.js +86 -86
- package/lib/list/index.d.ts +19 -0
- package/lib/list/index.js +62 -0
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -1
- package/lib/message/index.js +9 -9
- package/lib/radio/index.d.ts +27 -0
- package/lib/radio/index.js +113 -0
- package/lib/transition.js +27 -22
- package/lib/util.js +23 -20
- package/package.json +7 -6
- package/styles/reset.css +5 -0
- package/lib/index-CWq5_ldX.js +0 -4
- package/lib/index-CbaSCp33.js +0 -4
- package/lib/index-DZ2ZMrk1.js +0 -4
- package/lib/index-JjjljTZ2.js +0 -4
package/lib/litos-ui.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";var p;const at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",ot="0123456789";function ct(n,t=!0){return n==null?!0:(t&&typeof n=="string"?n.trim().length:n.length)===0}function y(n){if(typeof n=="object"&&n.min!=null&&n.max!=null){const t=Math.random(),e=n.hasEnd?1:0,s=t*(n.max-n.min+e)+n.min;return n.isInteger!==!1?Math.floor(s):s}else{if(typeof n=="object"&&n.length==null)throw new Error("random_length_cannot_null");let t=typeof n=="object"?n.length:n,e=at;typeof n=="object"&&n.hasLetter===!1&&(e=ot);const s=Array.from({length:t},()=>e.charAt(y({min:0,max:e.length-1,hasEnd:!0}))).join("");return typeof n=="object"&&n.firstIsZero===!1&&s.indexOf("0")===0?y(n):s}}let ut=-1,j={prefix:"l"};function h(n,t){const e=`${j.prefix}-${n.baseName}`;customElements.get(e)||customElements.define(e,n)}function dt(){return`${j.prefix}-${++ut}`}function C(n,t,e){if(n==null)return t;switch(typeof t){case"boolean":return n===""||n==="true"||n==="1"||n===e;case"number":return Number(n);default:return n}}function O(n){const t=n.attributes;for(const e of t){const{name:s,value:r}=e,l=s.split("-").map((c,d)=>d===0?c:c[0].toUpperCase()+c.slice(1)).join(""),a=C(r,n[l],s);n[l]=a}}function x(n,t){let e=" ";return t===!0?e=` ${n}`:typeof t=="string"&&!ct(t)&&(e=` ${n}="${t}"`),e}function ht(n,t){return typeof n=="string"?(t||document).querySelectorAll(n):[n]}function k(n,t){return ht(n,t)[0]}function ft(n,t){n.classList.add(t)}function mt(n,t){n.classList.remove(t)}function bt(n,t,e){const s=n.getAttribute(t);if(e==null)return s;const r=typeof e;return s==null?e:r==="bigint"||r==="number"?s===""?e:Number(s):r==="boolean"?s===""||s==="1"||s==="true"||s===t:r==="object"?s===""?e:JSON.parse(s):s}function w(n){let t="";if(Array.isArray(n))for(let e=0,s=n.length;e<s;e++){const r=n[e];r&&(t+=`${r} `)}else for(const e in n)n[e]&&(t+=`${e} `);return t.trim()}function gt(n){let t="";if(Array.isArray(n))for(let e=0,s=n.length;e<s;e++){const r=n[e];r&&(t+=`${r};`)}else for(const e in n)n[e]&&(t+=`${e}:${n[e]};`);return t}function pt(n,t,e){n.style.setProperty("display","none");const s=[];for(let r=0,i=t.length;r<i;r++){const l=t[r];n.style.setProperty(l[0],l[1]),s.push(`${l[0]} ${e}`)}queueMicrotask(()=>{n.style.removeProperty("display"),queueMicrotask(()=>{for(let r=0,i=t.length;r<i;r++){const l=t[r];n.style.removeProperty(l[0])}})})}function yt(n,t,e){for(let s=0,r=t.length;s<r;s++){const i=t[s];n.style.setProperty(i[0],i[1])}n.addEventListener("transitionend",()=>{n.style.display="none";for(let s=0,r=t.length;s<r;s++){const i=t[s];n.style.removeProperty(i[0])}e!=null&&e()},{once:!0})}const F=class F extends HTMLElement{constructor(t=!0){super(),t&&this.attachShadow({mode:"open"})}static get observedAttributes(){return[]}attributeChangedCallback(t,e,s){}get shadow(){return this.shadowRoot}createStyle(t){const e=document.createElement("style");e.textContent=t.trim(),this.shadow.appendChild(e)}createLink(t){const e=document.createElement("link");e.rel="stylesheet",e.href=t,this.shadow.appendChild(e)}loadStyle(t){{let e=document.querySelector("#litos-ui-style");e?this.createLink(e.href):queueMicrotask(()=>{e=document.querySelector("#litos-ui-style"),e&&this.createLink(e.href)})}}loadExternalStyle(t){}setProperty(t,e){this[t]=e}setProperties(t){for(const e in t)this.setProperty(e,t[e])}getAttr(t,e){return bt(this,t,e)}connectedCallback(){this.render()}disconnectedCallback(){}render(){}};F.baseName="base-component";let b=F;const q=class q extends b{constructor(){super(),this.useLink=!1,this.viewBox="0 0 1024 1024"}connectedCallback(){this.loadStyle(["icon"]),this.render()}render(){const t=this.createEl("svg"),e=this.getAttr("useLink",this.useLink),s=this.getAttr("viewBox",this.viewBox);t.classList.add("l-icon"),e||t.setAttribute("viewBox",s);const r=this.renderChildren();if(typeof r=="string")if(r===""){const i=this.children,l=[];for(let a=0,c=i.length;a<c;a++){const d=i[a];l.push(d.outerHTML),t.appendChild(d)}t.innerHTML=l.join("")}else t.innerHTML=r;else t.append(r);this.shadow.appendChild(t)}renderChildren(){return""}createEl(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}};q.baseName="base-icon";let f=q,tt=(p=class extends f{renderChildren(){return'<path d="M520.665 64.564a29.244 29.244 0 0 0-7.071-.894c-16.211 0-29.35 13.14-29.35 29.35 0 15.83 12.538 28.696 28.223 29.293v.073c.375 0 .751-.014 1.127-.014 216.493 0 389.629 173.942 389.629 390.433 0 216.496-173.136 388.827-389.63 388.827s-389.63-172.333-389.63-388.829c0-.27.01-.536.01-.804h-.01c0-16.209-13.141-29.35-29.35-29.35s-29.35 13.139-29.35 29.35c0 .055.007.11.007.164-.001.214-.007.425-.007.64 0 247.609 200.722 448.331 448.33 448.331 247.607 0 448.33-200.722 448.33-448.33-.002-245.242-196.917-444.456-441.258-448.24z" fill="currentColor"></path>'}},p.baseName="loading-icon",p);const $=2,$t=.16,At=.05,Ct=.05,xt=.15,kt=/rgba?\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d*\.?\d+))?\s*\)/,et=/^#(?:([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})|([0-9A-Fa-f]{1})([0-9A-Fa-f]{1})([0-9A-Fa-f]{1}))$/;function wt(n){return n.r!=null&&n.g!=null&&n.b!=null}function nt(n){return n.h!=null&&n.s!=null&&n.v!=null}function vt(n){let t=n.match(kt);if(t!=null){const e=parseInt(t[1].trim()),s=parseInt(t[2].trim()),r=parseInt(t[3].trim());if(isNaN(e)||isNaN(s)||isNaN(r))throw new Error("Invalid RGB color.");let i=1;return t[4]!=null&&(i=parseFloat(t[4].trim()),isNaN(i)&&(i=1)),{r:e,g:s,b:r,a:i}}}function Mt(n){const t=n.match(et);if(t!=null){const e=t[4]!==void 0,s=parseInt(e?t[4]+t[4]:t[1],16),r=parseInt(e?t[5]+t[5]:t[2],16),i=parseInt(e?t[6]+t[6]:t[3],16);return{r:s,g:r,b:i}}}function v(n){if(typeof n=="string"){let t=Mt(n);if(t==null&&(t=vt(n)),t!=null)return t;throw new Error("Invalid color string")}else{if(wt(n))return n;if(nt(n))return Nt(n);throw new Error("Invalid color")}}function St(n){if(nt(n))return n;const t=v(n),e=t.r/255,s=t.g/255,r=t.b/255;let i=Math.max(e,s,r),l=Math.min(e,s,r),a=i-l,c=i,d=i===0?0:a/i,u=0;if(i===l)u=0;else switch(i){case e:u=((s-r)/a+(s<r?6:0))/6;break;case s:u=((r-e)/a+2)/6;break;case r:u=((e-s)/a+4)/6;break}return u=u*360,{h:u,s:d,v:c}}function Nt(n){let t=n.s,e=n.v;t>1&&(t/=100),e>1&&(e/=100);const s=n.h;var r=Math.floor(s/60)%6,i=s/60-Math.floor(s/60),l=e*(1-t),a=e*(1-i*t),c=e*(1-(1-i)*t);let d=0,u=0,m=0;switch(r){case 0:d=e,u=c,m=l;break;case 1:d=a,u=e,m=l;break;case 2:d=l,u=e,m=c;break;case 3:d=l,u=a,m=e;break;case 4:d=c,u=l,m=e;break;case 5:d=e,u=l,m=a;break}return d=Math.round(d*255),u=Math.round(u*255),m=Math.round(m*255),{r:d,g:u,b:m}}function Lt(n,t,e){let s;return Math.round(n.h)>=60&&Math.round(n.h)<=240?s=e?Math.round(n.h)-$*t:Math.round(n.h)+$*t:s=e?Math.round(n.h)+$*t:Math.round(n.h)-$*t,s<0?s+=360:s>=360&&(s-=360),s}function It(n,t,e){if(n.h===0&&n.s===0)return n.s;let s;return e?s=n.s-$t*t:s=n.s+At*t,s>1&&(s=1),s<.06&&(s=.06),Number(s.toFixed(2))}function Ht(n,t,e){let s;return e?s=n.v+Ct*t:s=n.v-xt*t,s>1&&(s=1),Number(s.toFixed(2))}function st(n){const t=e=>e.toString(16).padStart(2,"0");return`#${t(n.r)}${t(n.g)}${t(n.b)}`.toUpperCase()}function Et(n){return typeof n=="string"&&et.test(n)?n:st(v(n))}function rt(n,t=1,e=!0){const s=St(n);return Et({h:Lt(s,t,e),s:It(s,t,e),v:Ht(s,t,e)})}function zt(n){let t="";if(Array.isArray(n))for(let e=0,s=n.length;e<s;e++){const r=n[e];r&&(t+=`${r};`)}else for(const e in n)n[e]&&(t+=`${e}:${n[e]};`);return t}h(tt);const B=class B extends b{constructor(){super(),this.loadExternalStyle(["animation"])}static get observedAttributes(){return["loading","color"]}attributeChangedCallback(t,e,s){const r=k(".l-btn",this.shadow);if(r){if(t==="loading"){const i=C(s,!1,t),l=k(".l-btn",this.shadow);i?(ft(l,"l-btn-loading"),l.disabled=!0,l.innerHTML=this.loadingBody()):(mt(l,"l-btn-loading"),l.disabled=this.getAttr("disabled",!1),l.innerHTML="<slot></slot>")}else if(t==="color"){const i=this.getAttr("text",!1),l=this.getAttr("ghost",!1);r.style.cssText=this.applyColor(s,i,l)}}}connectedCallback(){this.loadStyle(["button"]),this.render()}render(){const t=this.getAttr("type","normal"),e=document.createElement("button"),s=this.getAttr("loading",!1),r=this.getAttr("shape","default"),i=this.getAttr("text",!1),l=this.getAttr("ghost",!1),a=["l-btn",`l-btn-${t}`,this.getAttr("block",!1)?"l-btn-block":"",r==="round"?"l-btn-round":"",r==="circle"?"l-btn-circle":"",l?"l-btn-ghost":"",i?"l-btn-text":"",s?"l-btn-loading":""];e.className=w(a),e.disabled=this.getAttr("disabled",!1)||s,e.type=this.getAttr("html-type","button");const c=this.applyColor(this.getAttr("color"),i,l);c&&(e.style.cssText=c),s?e.innerHTML=this.loadingBody():e.innerHTML="<slot></slot>",e.setAttribute("part","default"),this.shadow.appendChild(e)}loadingBody(){const t=this.getAttr("loading-text",""),e=['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];return t===""?e.push("<slot></slot>"):e.push(`<span>${t}</span>`),e.join("")}applyColor(t,e=!1,s=!1){if(!t)return"";const r=rt(t,1,!0),i=rt(t,3,!1);return zt({"--l-btn-border-color":e?"transparent":t,"--l-btn-text-color":s||e?t:"#ffffff","--l-btn-hover-text-color":s||e?r:"#ffffff","--l-btn-background":s||e?"transparent":t,"--l-btn-active-text-color":s||e?i:"#ffffff","--l-btn-hover-border-color":e?"transparent":r,"--l-btn-hover-background":s||e?"transparent":r,"--l-btn-active-background":s||e?"transparent":i,"--l-btn-active-border-color":e?"transparent":i})}};B.baseName="button";let M=B,o;function Tt(n,t,e){o==null&&(o=new Map),o.has(n)||o.set(n,new Map([[t,new Set]])),o.get(n).has(t)||o.get(n).set(t,new Set),o.get(n).get(t).add(e)}function Rt(n,t,e){var s,r,i,l,a,c;(r=(s=o==null?void 0:o.get(n))==null?void 0:s.get(t))==null||r.delete(e),((l=(i=o==null?void 0:o.get(n))==null?void 0:i.get(t))==null?void 0:l.size)==0&&((a=o.get(n))==null||a.delete(t)),((c=o==null?void 0:o.get(n))==null?void 0:c.size)==0&&o.delete(n),(o==null?void 0:o.size)==0&&(o=void 0)}function Pt(n,t,...e){var r;const s=(r=o==null?void 0:o.get(n))==null?void 0:r.get(t);if(s!=null)for(const i of s)i(...e)}const D=class D extends b{constructor(){super(),this.type="text",this.placeholder=void 0,this.autosize=!1,this.disabled=!1,this.allowInput=void 0,this.$input=void 0,this.form=void 0,this.formAttrs={},this.formItemAttrs={},O(this),this.handleInput=this._input.bind(this)}get value(){return this.$input?this.$input.value:""}set value(t){this.$input&&(this.$input.value=t||"")}connectedCallback(){const t=this._getForm();this.formAttrs=t.formAttr,this.formItemAttrs=t.formItemAttr,this.formAttrs.formId&&(this.attributeChangedHandler=this._formAttributeChanged.bind(this),Tt(this.formAttrs.formId,"attributeChanged",this.attributeChangedHandler)),this.render(),this.loadStyle(["input"])}disconnectedCallback(){var t;this.attributeChangedHandler!=null&&Rt(this.formAttrs.formId,"attributeChanged",this.attributeChangedHandler),(t=this.$input)==null||t.removeEventListener("input",this.handleInput),this.$input=void 0}render(){const t=this.getAttr("value","");let e=x("value",t);const s=x("placeholder",this.placeholder),r=x("disabled",this._isDisabled()),i=w({"l-input":!0,"is-autosize":this.autosize});this.shadow.innerHTML=`<input${e} type="${this.type}"${s}${r} class="${i}" />`,this.$input=k("input",this.shadow),this.$input.addEventListener("input",this.handleInput)}setParser(t){this.parser=t}focus(){var t;(t=this.$input)==null||t.focus()}_input(t){const e=t.target;let s=e.value;if(this.allowInput!=null){let r=this.allowInput.indexOf("."),i=r===-1?r:parseInt(this.allowInput.substring(r+1));s=this._numberInputParse(s,{integer:this.allowInput.includes("integer"),negative:this.allowInput.startsWith("-"),precition:i}),e.value=String(s)}this.parser!=null&&(s=this.parser(s),e.value=String(s))}_isDisabled(){return this.formAttrs.disabled===!0||this.formItemAttrs.disabled===!0?!0:this.disabled}_formAttributeChanged(t,e,s){t==="form"?this.formAttrs[e]=s:this.formItemAttrs[e]=s,e==="disabled"&&this._changeDisabled()}_changeDisabled(){this.$input!=null&&(this.$input.disabled=this._isDisabled())}_getForm(){let t=this.parentElement,e={},s={};for(;t!=null;){const r=t.tagName;if(r==="L-FORM"){const i=t.sharedAttrs;for(let l=0;l<i.length;l++){const a=i[l];e[a]=t[a]}break}if(r==="BODY")break;if(r==="L-FORM-ITEM"){const i=t.sharedAttrs;for(let l=0;l<i.length;l++){const a=i[l];s[a]=t[a]}}t=t.parentElement}return t=null,{formAttr:e,formItemAttr:s}}_numberInputParse(t,e){let s=t,r=e.negative?"-?":"";if(e.integer){const l=s.match(new RegExp(`^(${r}\\d*)`));return l!=null?l[1]:s.substring(0,s.length-1)}const i=s.match(new RegExp(`(${r}\\d+\\.\\d{0,${e.precition}})|(${r}\\d*)`));return i!=null?s=i[1]||i[2]:s="",i!=null?i[1]||i[2]:""}};D.baseName="input";let S=D;const V=class V extends f{connectedCallback(){super.connectedCallback()}renderChildren(){return'<path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>'}};V.baseName="arrow-down-icon";let N=V;const U=class U extends f{renderChildren(){return'<path fill="currentColor" d="M512 320 192 704h639.936z"></path>'}};U.baseName="caret-top-icon";let L=U;const G=class G extends f{renderChildren(){return'<path fill="currentColor" d="m192 384 320 384 320-384z"></path>'}};G.baseName="caret-bottom-icon";let I=G;const J=class J extends f{constructor(){super(),this.useLink=!0,this._t=void 0,this._start=0}renderChildren(){return""}render(){super.render()}disconnectedCallback(){this._t!=null&&(cancelAnimationFrame(this._t),this._t=void 0)}connectedCallback(){super.connectedCallback();const t=this.getAttribute("name");this._start=Date.now(),t&&this._loadIcon(t)}_loadIcon(t){Date.now()-this._start>=1e4||(this._t=requestAnimationFrame(()=>{const s=document.querySelector(`#${t}`);if(s==null){this._loadIcon(t);return}this._t=void 0;let r=s.getAttribute("viewBox");r||(r="0 0 1024 1024");const i=this.shadow.querySelector("svg");i!=null&&(i.setAttribute("viewBox",r),i.innerHTML=s.innerHTML)}))}};J.baseName="font-icon";let H=J;const W=class W extends f{renderChildren(){return'<path fill="currentColor" d="m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704"></path>'}};W.baseName="search-icon";let E=W;const Y=class Y extends f{constructor(){super(),this.viewBox="0 0 24 24"}renderChildren(){return'<path fill="currentColor" d="M12 23a11 11 0 100-22 11 11 0 000 22zM8.82 7.4L12 10.6l3.18-3.19 1.42 1.42L13.4 12l3.19 3.18-1.42 1.42L12 13.4 8.82 16.6 7.4 15.18 10.6 12 7.4 8.82 8.82 7.4z"></path>'}};Y.baseName="mask-close-icon";let z=Y;const Z=class Z extends f{connectedCallback(){super.connectedCallback()}renderChildren(){return'<path fill="currentColor" d="M512 0C228.693333 0 0 228.693333 0 512s228.693333 512 512 512 512-228.693333 512-512S795.306667 0 512 0z m307.2 368.64L467.626667 730.453333c0 3.413333-3.413333 3.413333-3.413334 6.826667-13.653333 13.653333-37.546667 13.653333-51.2 0l-177.493333-177.493333c-13.653333-13.653333-13.653333-37.546667 0-51.2 13.653333-13.653333 37.546667-13.653333 51.2 0l150.186667 153.6 334.506666-341.333334c13.653333-13.653333 37.546667-13.653333 51.2 0 10.24 10.24 10.24 34.133333-3.413333 47.786667z m0 0"></path>'}};Z.baseName="success-icon";let T=Z;const K=class K extends f{connectedCallback(){super.connectedCallback()}renderChildren(){return'<path fill="currentColor" d="M512 1024C229.234 1024 0 794.766 0 512S229.234 0 512 0s512 229.234 512 512-229.234 512-512 512z m-64.853-734.52l19.484 244.906 1.309 16.156c1.251 15.93 15.018 28.644 30.72 28.644h25.571c15.56 0 29.298-12.601 30.663-28.132l1.422-16.668 21.334-244.907c3.214-36.978-24.434-66.844-61.725-66.844h-6.627c-37.462 0-65.138 29.923-62.18 66.844zM512 801.393a66.788 66.788 0 1 0 0-133.575 66.788 66.788 0 0 0 0 133.575z"></path>'}};K.baseName="warn-icon";let R=K;const Q=class Q extends f{connectedCallback(){super.connectedCallback()}renderChildren(){return'<path fill="currentColor" d="M512 64a448 448 0 110 896.064A448 448 0 01512 64zm67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344zM590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.992 12.992 0 01-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 017.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"></path>'}};Q.baseName="info-icon";let P=Q;h(z),h(T),h(R),h(P);const g=[],it=[["opacity","0"],["transform","translate3d(-50%, -100%, 0)"]];function lt(n){const t=g.findIndex(i=>i.id===n);if(t===-1)return;const e=g.splice(t,1)[0];if(e==null)return;yt(e,it,()=>{e.remove()});const s=15+e.offsetHeight,r=g.length;if(r!==0)for(let i=t;i<r;i++){const l=g[i],a=parseInt(l.style.top,10)-s;l.style.setProperty("top",`${a}px`)}}function _t(n){const t=document.createElement("div");t.id=n.id;const e=n.type||"info";let s=`l-message l-message-${e}`;n.customClass&&(s+=" "+n.customClass),t.className=s,t.style.setProperty("top",`${n.offset}px`),t.style.setProperty("z-index",`${n.zindex||1e3}`),n.width&&t.style.setProperty("width",n.width);let r=e;return r==="error"&&(r="mask-close"),t.innerHTML=['<div class="l-message-container">',`<l-${r}-icon class="l-message-icon"></l-${r}-icon>`,`<span class="l-message-content">${n.message}</span>`,"</div>"].join(""),t}const A=n=>{const t=g.reduce((l,a)=>l+a.offsetHeight+15,15),e=dt(),s=typeof n=="string"?{message:n}:n;s.id=e,s.offset=t;const r=_t(s);g.push(r),document.body.appendChild(r),pt(r,it);let i=s.duration;return i==null&&(i=3e3),i!==0&&setTimeout(()=>{lt(e)},i),e};for(const n of["info","success","error","warn","show"])A[n]=t=>{const e=typeof t=="string"?{message:t}:t;return n!=="show"?e.type=n:e.type==null&&(e.type="info"),A(e)};A.close=lt;const X=class X extends b{constructor(){super(),this.inline=!1,this.labelPosition="right",this.disabled=!1,this.sharedAttrs=["disabled","formId"],this.formId=`l-f${y(3)}-${y(6)}`,O(this)}static get observedAttributes(){return["disabled"]}attributeChangedCallback(t,e,s){if(t==="disabled"){const r=C(s,!1,t);r!==this.disabled&&(Pt(this.formId,"attributeChanged","form",t,r,this.disabled),this.disabled=r)}}connectedCallback(){this.loadStyle(["form"]),super.connectedCallback()}render(){const t=w(["l-form",this.inline?"l-form-inline":void 0,`l-form--${this.labelPosition}`]),e=gt({"--l-form-label-width":this.labelWidth?this.labelWidth:""});this.shadow.innerHTML=`<form class="${t}" style="${e}"><slot></slot></form>`}};X.baseName="form";let _=X;h(_),h(M),h(S),h(f),h(N),h(L),h(I),h(H),h(tt),h(E),globalThis.LMessage=A;function Ft(){const n=document.currentScript.src,t=n.lastIndexOf("/"),s=`${n.slice(0,t+1)}litos-ui.css`,r=document.createElement("link");r.rel="stylesheet",r.href=s,r.id="litos-ui-style",document.head.appendChild(r)}Ft()})();
|
|
1
|
+
var Ot=Object.defineProperty;var Kt=($,v,S)=>v in $?Ot($,v,{enumerable:!0,configurable:!0,writable:!0,value:S}):$[v]=S;var a=($,v,S)=>Kt($,typeof v!="symbol"?v+"":v,S);(function(){"use strict";var U;const $="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",v="0123456789";function S(s,r=!0){return s==null?!0:(r&&typeof s=="string"?s.trim().length:s.length)===0}function C(s){if(typeof s=="object"&&s.min!=null&&s.max!=null){const r=Math.random(),t=s.hasEnd?1:0,e=r*(s.max-s.min+t)+s.min;return s.isInteger!==!1?Math.floor(e):e}else{if(typeof s=="object"&&s.length==null)throw new Error("random_length_cannot_null");let r=typeof s=="object"?s.length:s,t=$;typeof s=="object"&&s.hasLetter===!1&&(t=v);const e=Array.from({length:r},()=>t.charAt(C({min:0,max:t.length-1,hasEnd:!0}))).join("");return typeof s=="object"&&s.firstIsZero===!1&&e.indexOf("0")===0?C(s):e}}let yt=-1,Y={prefix:"l"};function f(s,r){const t=`${Y.prefix}-${s.baseName}`;customElements.get(t)||customElements.define(t,s)}function $t(){return`${Y.prefix}-${++yt}`}function y(s,r,t){if(s==null)return r;switch(typeof r){case"boolean":return s===""||s==="true"||s==="1"||s===t;case"number":return Number(s);default:return s}}function w(s){const r=s.attributes;for(const t of r){const{name:e,value:i}=t;if(e.startsWith("data-")||e.startsWith("aria-")||e.startsWith("_")||e.startsWith("$"))continue;const l=e.split("-").map((h,d)=>d===0?h:h[0].toUpperCase()+h.slice(1)).join(""),o=y(i,s[l],e);s[l]=o,e==="value"&&(s._resetValue=o)}}function _(s,r){let t=" ";return r===!0?t=` ${s}`:typeof r=="string"&&!S(r)&&(t=` ${s}="${r}"`),t}function G(s,r){return typeof s=="string"?(r||document).querySelectorAll(s):[s]}function F(s,r){return G(s,r)}function m(s,r){return G(s,r)[0]}function M(s,r){s.classList.add(r)}function L(s,r){s.classList.remove(r)}function J(s,r){return s.classList.contains(r)}function P(s,r,t,e=!1){let i={eventStop:!1};typeof e=="boolean"?i.once=e:i=e,i.eventFlag!=null?(s.setAttribute(i.eventFlag,"__stop__"),s.addEventListener(r,n=>{let l=n.target,o="";do o=l.getAttribute(i.eventFlag)||"",o===""&&(l=l.parentNode);while(o==="");(o!=="__stop__"||i.eventStop)&&t(n,l,o)},i)):s.addEventListener(r,t,i)}function H(s,r,t){s.removeEventListener(r,t)}function B(s,r){for(let t=0,e=s.length;t<e&&r(s[t],t)!==!0;t++);}function q(s,r,t){const e=s.getAttribute(r);if(t==null)return e;const i=typeof t;return e==null?t:i==="bigint"||i==="number"?e===""?t:Number(e):i==="boolean"?e===""||e==="1"||e==="true"||e===r:i==="object"?e===""?t:JSON.parse(e):e}function E(s){let r="";if(Array.isArray(s))for(let t=0,e=s.length;t<e;t++){const i=s[t];i&&(r+=`${i} `)}else for(const t in s)s[t]&&(r+=`${t} `);return r.trim()}function z(s){let r="";if(Array.isArray(s))for(let t=0,e=s.length;t<e;t++){const i=s[t];i&&(r+=`${i};`)}else for(const t in s){const e=s[t];e&&(r+=`${t}:${e};`)}return r}function kt(s,r,t="0.3s"){s.style.setProperty("display","none");const e=[];for(let i=0,n=r.length;i<n;i++){const l=r[i];s.style.setProperty(l[0],l[1]),e.push(`${l[0]} ${t}`)}t&&s.style.setProperty("transition",e.join(", ")),s.style.removeProperty("display"),requestAnimationFrame(()=>{for(let i=0,n=r.length;i<n;i++){const l=r[i];s.style.removeProperty(l[0])}})}function At(s,r,t){for(let e=0,i=r.length;e<i;e++){const n=r[e];s.style.setProperty(n[0],n[1])}s.addEventListener("transitionend",()=>{s.style.display="none";for(let e=0,i=r.length;e<i;e++){const n=r[e];s.style.removeProperty(n[0])}t!=null&&t()},{once:!0})}class k extends HTMLElement{constructor(t=!0){super();a(this,"rendered",!1);t&&this.attachShadow({mode:"open"})}static get observedAttributes(){return[]}attributeChangedCallback(t,e,i){}get shadow(){return this.shadowRoot}get root(){return this.shadowRoot||this}createStyle(t){const e=document.createElement("style");e.textContent=t.trim(),this.shadow.appendChild(e)}createLink(t){const e=document.createElement("link");e.rel="stylesheet",e.href=t,this.shadow.appendChild(e)}loadStyle(t){{let e=document.querySelector("#litos-ui-style");e?this.createLink(e.href):queueMicrotask(()=>{e=document.querySelector("#litos-ui-style"),e&&this.createLink(e.href)})}}loadExternalStyle(t){}loadStyleText(t){this.createStyle(t)}setProperty(t,e){this[t]=e}setProperties(t){for(const e in t)this.setProperty(e,t[e])}getAttr(t,e){return q(this,t,e)}connectedCallback(){this.render(),this.rendered=!0}disconnectedCallback(){}render(){}}a(k,"baseName","base-component");class g extends k{constructor(){super();a(this,"useLink");a(this,"viewBox");this.useLink=!1,this.viewBox="0 0 1024 1024"}connectedCallback(){this.loadStyle(["icon"]),this.render()}render(){const t=this.createEl("svg"),e=this.getAttr("useLink",this.useLink),i=this.getAttr("viewBox",this.viewBox);t.classList.add("l-icon"),e||t.setAttribute("viewBox",i);const n=this.renderChildren();if(typeof n=="string")if(n===""){const l=this.children,o=[];for(let h=0,d=l.length;h<d;h++){const u=l[h];o.push(u.outerHTML),t.appendChild(u)}t.innerHTML=o.join("")}else t.innerHTML=n;else t.append(n);this.shadow.appendChild(t)}renderChildren(){return""}createEl(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}}a(g,"baseName","base-icon");let j=(U=class extends g{renderChildren(){return'<path d="M520.665 64.564a29.244 29.244 0 0 0-7.071-.894c-16.211 0-29.35 13.14-29.35 29.35 0 15.83 12.538 28.696 28.223 29.293v.073c.375 0 .751-.014 1.127-.014 216.493 0 389.629 173.942 389.629 390.433 0 216.496-173.136 388.827-389.63 388.827s-389.63-172.333-389.63-388.829c0-.27.01-.536.01-.804h-.01c0-16.209-13.141-29.35-29.35-29.35s-29.35 13.139-29.35 29.35c0 .055.007.11.007.164-.001.214-.007.425-.007.64 0 247.609 200.722 448.331 448.33 448.331 247.607 0 448.33-200.722 448.33-448.33-.002-245.242-196.917-444.456-441.258-448.24z" fill="currentColor"></path>'}},a(U,"baseName","loading-icon"),U);const T=2,xt=.16,St=.05,wt=.05,Et=.15,It=/rgba?\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d*\.?\d+))?\s*\)/,Z=/^#(?:([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})|([0-9A-Fa-f]{1})([0-9A-Fa-f]{1})([0-9A-Fa-f]{1}))$/;function Mt(s){return s.r!=null&&s.g!=null&&s.b!=null}function Q(s){return s.h!=null&&s.s!=null&&s.v!=null}function Nt(s){let r=s.match(It);if(r!=null){const t=parseInt(r[1].trim()),e=parseInt(r[2].trim()),i=parseInt(r[3].trim());if(isNaN(t)||isNaN(e)||isNaN(i))throw new Error("Invalid RGB color.");let n=1;return r[4]!=null&&(n=parseFloat(r[4].trim()),isNaN(n)&&(n=1)),{r:t,g:e,b:i,a:n}}}function Lt(s){const r=s.match(Z);if(r!=null){const t=r[4]!==void 0,e=parseInt(t?r[4]+r[4]:r[1],16),i=parseInt(t?r[5]+r[5]:r[2],16),n=parseInt(t?r[6]+r[6]:r[3],16);return{r:e,g:i,b:n}}}function D(s){if(typeof s=="string"){let r=Lt(s);if(r==null&&(r=Nt(s)),r!=null)return r;throw new Error("Invalid color string")}else{if(Mt(s))return s;if(Q(s))return Rt(s);throw new Error("Invalid color")}}function Tt(s){if(Q(s))return s;const r=D(s),t=r.r/255,e=r.g/255,i=r.b/255;let n=Math.max(t,e,i),l=Math.min(t,e,i),o=n-l,h=n,d=n===0?0:o/n,u=0;if(n===l)u=0;else switch(n){case t:u=((e-i)/o+(e<i?6:0))/6;break;case e:u=((i-t)/o+2)/6;break;case i:u=((t-e)/o+4)/6;break}return u=u*360,{h:u,s:d,v:h}}function Rt(s){let r=s.s,t=s.v;r>1&&(r/=100),t>1&&(t/=100);const e=s.h;var i=Math.floor(e/60)%6,n=e/60-Math.floor(e/60),l=t*(1-r),o=t*(1-n*r),h=t*(1-(1-n)*r);let d=0,u=0,p=0;switch(i){case 0:d=t,u=h,p=l;break;case 1:d=o,u=t,p=l;break;case 2:d=l,u=t,p=h;break;case 3:d=l,u=o,p=t;break;case 4:d=h,u=l,p=t;break;case 5:d=t,u=l,p=o;break}return d=Math.round(d*255),u=Math.round(u*255),p=Math.round(p*255),{r:d,g:u,b:p}}function Vt(s,r,t){let e;return Math.round(s.h)>=60&&Math.round(s.h)<=240?e=t?Math.round(s.h)-T*r:Math.round(s.h)+T*r:e=t?Math.round(s.h)+T*r:Math.round(s.h)-T*r,e<0?e+=360:e>=360&&(e-=360),e}function Ft(s,r,t){if(s.h===0&&s.s===0)return s.s;let e;return t?e=s.s-xt*r:e=s.s+St*r,e>1&&(e=1),e<.06&&(e=.06),Number(e.toFixed(2))}function Pt(s,r,t){let e;return t?e=s.v+wt*r:e=s.v-Et*r,e>1&&(e=1),Number(e.toFixed(2))}function X(s){const r=t=>t.toString(16).padStart(2,"0");return`#${r(s.r)}${r(s.g)}${r(s.b)}`.toUpperCase()}function Ht(s){return typeof s=="string"&&Z.test(s)?s:X(D(s))}function tt(s,r=1,t=!0){const e=Tt(s);return Ht({h:Vt(e,r,t),s:Ft(e,r,t),v:Pt(e,r,t)})}f(j);class et extends k{constructor(){super();a(this,"htmlType","button");a(this,"_handleClick",t=>{const e=t.target,i=q(e,"html-type");if(i==="reset"||i==="submit"){const n=this._getForm();n&&(i==="reset"?n.reset():i==="submit"&&n.submit())}});w(this)}static get observedAttributes(){return["loading","color"]}attributeChangedCallback(t,e,i){const n=m(".l-button",this.root);if(n){if(t==="loading")y(i,!1,t)?(M(n,"l-btn-loading"),n.disabled=!0,n.innerHTML=this.loadingBody()):(L(n,"l-btn-loading"),n.disabled=this.getAttr("disabled",!1),n.innerHTML="<slot></slot>");else if(t==="color"){const l=this.getAttr("text",!1),o=this.getAttr("ghost",!1);n.style.cssText=this.applyColor(i,l,o)}}}connectedCallback(){this.loadStyle(["button"]),this.loadExternalStyle(["animation"]),this.render(),(this.htmlType==="reset"||this.htmlType==="submit")&&P(this,"click",this._handleClick)}disconnectedCallback(){super.disconnectedCallback(),(this.htmlType==="reset"||this.htmlType==="submit")&&H(this,"click",this._handleClick)}render(){const t=this.getAttr("type","normal"),e=document.createElement("button"),i=this.getAttr("loading",!1),n=this.getAttr("shape","default"),l=this.getAttr("text",!1),o=this.getAttr("ghost",!1),h=["l-btn",`l-btn-${t}`,this.getAttr("block",!1)?"l-btn-block":"",n==="round"?"l-btn-round":"",n==="circle"?"l-btn-circle":"",o?"l-btn-ghost":"",l?"l-btn-text":"",i?"l-btn-loading":""];e.className=E(h),e.disabled=this.getAttr("disabled",!1)||i,e.type=this.getAttr("html-type","button");const d=this.applyColor(this.getAttr("color"),l,o);d&&(e.style.cssText=d),i?e.innerHTML=this.loadingBody():e.innerHTML="<slot></slot>",e.setAttribute("part","default"),this.root.appendChild(e)}loadingBody(){const t=this.getAttr("loading-text",""),e=['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];return t===""?e.push("<slot></slot>"):e.push(`<span>${t}</span>`),e.join("")}applyColor(t,e=!1,i=!1){if(!t)return"";const n=tt(t,1,!0),l=tt(t,3,!1);return z({"--l-btn-border-color":e?"transparent":t,"--l-btn-text-color":i||e?t:"#ffffff","--l-btn-hover-text-color":i||e?n:"#ffffff","--l-btn-background":i||e?"transparent":t,"--l-btn-active-text-color":i||e?l:"#ffffff","--l-btn-hover-border-color":e?"transparent":n,"--l-btn-hover-background":i||e?"transparent":n,"--l-btn-active-background":i||e?"transparent":l,"--l-btn-active-border-color":e?"transparent":l})}_getForm(){let t=this.parentElement,e;for(;t!=null;){const i=t.tagName;if(i==="L-FORM"){e=t;break}if(i==="BODY")break;t=t.parentElement}return t=null,e}}a(et,"baseName","button");let c;function A(s,r,t){c==null&&(c=new Map),c.has(s)||c.set(s,new Map([[r,new Set]])),c.get(s).has(r)||c.get(s).set(r,new Set),c.get(s).get(r).add(t)}function N(s,r,t){var e,i,n,l,o,h;(i=(e=c==null?void 0:c.get(s))==null?void 0:e.get(r))==null||i.delete(t),((l=(n=c==null?void 0:c.get(s))==null?void 0:n.get(r))==null?void 0:l.size)==0&&((o=c.get(s))==null||o.delete(r)),((h=c==null?void 0:c.get(s))==null?void 0:h.size)==0&&c.delete(s),(c==null?void 0:c.size)==0&&(c=void 0)}function st(s){s==null?c!=null&&(c.clear(),c=void 0):c!=null&&(c.delete(s),c.size===0&&(c=void 0))}function b(s,r,...t){var i;const e=(i=c==null?void 0:c.get(s))==null?void 0:i.get(r);if(e!=null)for(const n of e)n(...t)}class it extends k{constructor(t=!0){super();a(this,"disabled",!1);a(this,"name");a(this,"formAttrs",{});a(this,"formItemAttrs",{});a(this,"_value","");a(this,"_resetValue");a(this,"_firstPushValue",!0);a(this,"_reseting",!1);a(this,"_formAttributeChanged",(t,e,i)=>{i===this.formAttrs.formId?this.formAttrs[t]=e:this.formItemAttrs[t]=e,t==="disabled"&&this._changeDisabled()});a(this,"_resetFieldValue",()=>{this._reseting=!0,this.reset()});this._firstPushValue=t}set value(t){this.setValue(t)}get value(){return this.getValue()}setValue(t){this._value=t,this.pushValueChange()}getValue(){return this._value}static get observedAttributes(){return["disabled"]}attributeChangedCallback(t,e,i){if(t==="disabled"){const n=y(i,!1,t);n!==this.disabled&&(this._changeDisabled(),this.disabled=n)}else this.attributeChange(t,e,i)}attributeChange(t,e,i){}connectedCallback(){const t=this._getForm();this.formAttrs=t.formAttr,this.formItemAttrs=t.formItemAttr,this.formAttrs.id&&(A(this.formAttrs.id,"attributeChanged",this._formAttributeChanged),A(this.formAttrs.id,"reset",this._resetFieldValue),this._firstPushValue&&this.pushValueChange()),this.formItemAttrs.id&&A(this.formItemAttrs.id,"attributeChanged",this._formAttributeChanged),this.render()}disconnectedCallback(){this.formAttrs.id&&(N(this.formAttrs.id,"attributeChanged",this._formAttributeChanged),N(this.formAttrs.id,"reset",this._resetFieldValue)),this.formItemAttrs.id&&N(this.formItemAttrs.id,"attributeChanged",this._formAttributeChanged)}isDisabled(){return this.disabled===!0||this.formItemAttrs.disabled===!0?!0:this.formAttrs.disabled||!1}getName(){return this.name?this.name:this.formItemAttrs.name}_getForm(){let t=this.parentElement,e={},i={};for(;t!=null;){const n=t.tagName;if(n==="L-FORM"){const l=t.sharedAttrs;for(let o=0;o<l.length;o++){const h=l[o];e[h]=t[h]}break}if(n==="BODY")break;if(n==="L-FORM-ITEM"){const l=t.sharedAttrs;for(let o=0;o<l.length;o++){const h=l[o];i[h]=t[h]}}t=t.parentElement}return t=null,{formAttr:e,formItemAttr:i}}_changeDisabled(){}pushValueChange(){const t=this.getName();this.formAttrs.id&&t&&b(this.formAttrs.id,"valueChange",t,this._value,!this._reseting),this._reseting=!1}reset(){this.value=this._resetValue||""}}class rt extends it{constructor(){super();a(this,"type","text");a(this,"placeholder");a(this,"autosize",!1);a(this,"allowInput");a(this,"parser");a(this,"width");a(this,"block",!1);a(this,"error",!1);a(this,"$input");a(this,"_input",t=>{const e=t.target;let i=e.value;if(this.allowInput!=null){let n=this.allowInput.indexOf("."),l=n===-1?n:parseInt(this.allowInput.substring(n+1));i=this._numberInputParse(i,{integer:this.allowInput.includes("integer"),negative:this.allowInput.startsWith("-"),precition:l}),i=String(i),e.value=i}this.parser!=null&&(i=this.parser(i),e.value=i),this.setValue(i)});a(this,"_validateChange",(t,e)=>{const i=this.getName();if(i){const n=t===!0?!1:t[i]!=null;(e==null||e===i&&this.error!=n)&&(this.error=n,this._updateError()),Object.keys(t)[0]===i&&this.focus()}});w(this)}set value(t){this.setValue(t),this.$input!=null&&(this.$input.value=this.value)}get value(){return this.getValue()}static get observedAttributes(){return["disabled","error"]}connectedCallback(){super.connectedCallback(),this.loadStyle(["input"])}disconnectedCallback(){super.disconnectedCallback(),this.formAttrs.id&&N(this.formAttrs.id,"validateChange",this._validateChange),H(this.$input,"input",this._input),this.$input=void 0}attributeChange(t,e,i){if(t==="error"){const n=y(i,!1,t);n!==this.error&&(this.error=n,this._updateError())}}render(){let t=_("value",this.value);const e=_("placeholder",this.placeholder),i=_("disabled",this.isDisabled()),n=E({"l-input":!0,"is-autosize":this.autosize,"is-error":this.error}),l=this.getName(),o=_("name",l),h=`${t}${o}${e}${i}`;this.shadow.innerHTML=`<input part="default" type="${this.type}" class="${n}"${h}></input>`,this.$input=m("input",this.root),P(this.$input,"input",this._input),this.style.cssText=z(this._getStyleObj())+this.getAttr("style",""),l&&this.formAttrs.id&&A(this.formAttrs.id,"validateChange",this._validateChange)}setParser(t){this.parser=t}focus(){var t;(t=this.$input)==null||t.focus()}_changeDisabled(){this.$input!=null&&(this.$input.disabled=this.isDisabled())}_numberInputParse(t,e){let i=t,n=e.negative?"-?":"";if(e.integer){const o=i.match(new RegExp(`^(${n}\\d*)`));return o!=null?o[1]:i.substring(0,i.length-1)}const l=i.match(new RegExp(`(${n}\\d+\\.\\d{0,${e.precition}})|(${n}\\d*)`));return l!=null?i=l[1]||l[2]:i="",l!=null?l[1]||l[2]:""}_getStyleObj(){const t={};return this._isBlock()&&(t["--l-input-width"]="100%"),this.width&&(t["--l-input-width"]=this.width),t}_isBlock(){if(this.block===!0||this.formItemAttrs.innerBlock===!0||this.formAttrs.innerBlock===!0)return!0}_updateError(){this.$input&&(this.error?M(this.$input,"is-error"):L(this.$input,"is-error"))}}a(rt,"baseName","input");class nt extends g{connectedCallback(){super.connectedCallback()}renderChildren(){return'<path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>'}}a(nt,"baseName","arrow-down-icon");class lt extends g{renderChildren(){return'<path fill="currentColor" d="M512 320 192 704h639.936z"></path>'}}a(lt,"baseName","caret-top-icon");class at extends g{renderChildren(){return'<path fill="currentColor" d="m192 384 320 384 320-384z"></path>'}}a(at,"baseName","caret-bottom-icon");class ot extends g{constructor(){super();a(this,"_t");a(this,"_start");this.useLink=!0,this._t=void 0,this._start=0}renderChildren(){return""}render(){super.render()}disconnectedCallback(){this._t!=null&&(cancelAnimationFrame(this._t),this._t=void 0)}connectedCallback(){super.connectedCallback();const t=this.getAttribute("name");this._start=Date.now(),t&&this._loadIcon(t)}_loadIcon(t){Date.now()-this._start>=1e4||(this._t=requestAnimationFrame(()=>{const i=document.querySelector(`#${t}`);if(i==null){this._loadIcon(t);return}this._t=void 0;let n=i.getAttribute("viewBox");n||(n="0 0 1024 1024");const l=this.shadow.querySelector("svg");l!=null&&(l.setAttribute("viewBox",n),l.innerHTML=i.innerHTML)}))}}a(ot,"baseName","font-icon");class ht extends g{renderChildren(){return'<path fill="currentColor" d="m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704"></path>'}}a(ht,"baseName","search-icon");class ct extends g{constructor(){super(),this.viewBox="0 0 24 24"}renderChildren(){return'<path fill="currentColor" d="M12 23a11 11 0 100-22 11 11 0 000 22zM8.82 7.4L12 10.6l3.18-3.19 1.42 1.42L13.4 12l3.19 3.18-1.42 1.42L12 13.4 8.82 16.6 7.4 15.18 10.6 12 7.4 8.82 8.82 7.4z"></path>'}}a(ct,"baseName","mask-close-icon");class dt extends g{connectedCallback(){super.connectedCallback()}renderChildren(){return'<path fill="currentColor" d="M512 0C228.693333 0 0 228.693333 0 512s228.693333 512 512 512 512-228.693333 512-512S795.306667 0 512 0z m307.2 368.64L467.626667 730.453333c0 3.413333-3.413333 3.413333-3.413334 6.826667-13.653333 13.653333-37.546667 13.653333-51.2 0l-177.493333-177.493333c-13.653333-13.653333-13.653333-37.546667 0-51.2 13.653333-13.653333 37.546667-13.653333 51.2 0l150.186667 153.6 334.506666-341.333334c13.653333-13.653333 37.546667-13.653333 51.2 0 10.24 10.24 10.24 34.133333-3.413333 47.786667z m0 0"></path>'}}a(dt,"baseName","success-icon");class ut extends g{connectedCallback(){super.connectedCallback()}renderChildren(){return'<path fill="currentColor" d="M512 1024C229.234 1024 0 794.766 0 512S229.234 0 512 0s512 229.234 512 512-229.234 512-512 512z m-64.853-734.52l19.484 244.906 1.309 16.156c1.251 15.93 15.018 28.644 30.72 28.644h25.571c15.56 0 29.298-12.601 30.663-28.132l1.422-16.668 21.334-244.907c3.214-36.978-24.434-66.844-61.725-66.844h-6.627c-37.462 0-65.138 29.923-62.18 66.844zM512 801.393a66.788 66.788 0 1 0 0-133.575 66.788 66.788 0 0 0 0 133.575z"></path>'}}a(ut,"baseName","warn-icon");class ft extends g{connectedCallback(){super.connectedCallback()}renderChildren(){return'<path fill="currentColor" d="M512 64a448 448 0 110 896.064A448 448 0 01512 64zm67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344zM590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.992 12.992 0 01-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 017.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"></path>'}}a(ft,"baseName","info-icon"),f(ct),f(dt),f(ut),f(ft);const I=[],mt=[["opacity","0"],["transform","translate3d(-50%, -100%, 0)"]];function bt(s){const r=I.findIndex(n=>n.id===s);if(r===-1)return;const t=I.splice(r,1)[0];if(t==null)return;At(t,mt,()=>{t.remove()});const e=15+t.offsetHeight,i=I.length;if(i!==0)for(let n=r;n<i;n++){const l=I[n],o=parseInt(l.style.top,10)-e;l.style.setProperty("top",`${o}px`)}}function Bt(s){const r=document.createElement("div");r.id=s.id;const t=s.type||"info";let e=`l-message l-message-${t}`;s.customClass&&(e+=" "+s.customClass),r.className=e,r.style.setProperty("top",`${s.offset}px`),r.style.setProperty("z-index",`${s.zindex||1e3}`),s.width&&r.style.setProperty("width",s.width);let i=t;return i==="error"&&(i="mask-close"),r.innerHTML=['<div class="l-message-container">',`<l-${i}-icon class="l-message-icon"></l-${i}-icon>`,`<span class="l-message-content">${s.message}</span>`,"</div>"].join(""),r}const R=s=>{const r=I.reduce((l,o)=>l+o.offsetHeight+15,15),t=$t(),e=typeof s=="string"?{message:s}:s;e.id=t,e.offset=r;const i=Bt(e);I.push(i),document.body.appendChild(i),kt(i,mt,null);let n=e.duration;return n==null&&(n=3e3),n!==0&&setTimeout(()=>{bt(t)},n),t};for(const s of["info","success","error","warn","show"])R[s]=r=>{const t=typeof r=="string"?{message:r}:r;return s!=="show"?t.type=s:t.type==null&&(t.type="info"),R(t)};R.close=bt;const O={mobile:"请输入正确的手机号",same:"两次输入不一致",required:"%s为必填字段"},K="请输入正确的数据",x={same:/^same:(.+)$/i,mobile:/^1[345678]\d{9}$/,required:/^\S{1}.*/},W={same(s,r){return r===s},pattern(s,r){return r==null?!1:s.test(String(r))}};class gt extends Error{constructor(r,t,e){super(e),this.name="ValidateError",this.key=t,this.detail=r}}class qt{constructor(r){this.rules={},this.addSchemas(r)}addSchemas(r){for(let t of r)this.rules[t.key]=this._parseSchemaRules(t)}addSchema(r){this.rules[r.key]=this._parseSchemaRules(r)}async validate(r,t=!1){return new Promise((e,i)=>{const n={};let l,o;for(let h in this.rules){let d=this._validateRule(this.rules[h],r[h],r);if(d!==""&&(d=d.replace("%s",h),n[h]=d,l=h,o=d,t))break}l==null?e(!0):i(new gt(n,l,o))})}async validateKey(r,t,e){return new Promise((i,n)=>{let l=this.rules[r];if(l==null){i({key:r,value:t});return}let o=this._validateRule(l,t,e);o!==""?(o=o.replace("%s",r),n(new gt({[r]:o},r,o))):i({key:r,value:t})})}_validateRule(r,t,e){let i="";for(let n of r)if(n.rule==="required"?(t==null||!W.pattern(x.required,t))&&(i=n.message):typeof n.rule=="function"?n.rule(t)||(i=n.message):n.sameKey!=null?e!=null&&(W.same(t,e[n.sameKey])||(i=n.message)):W.pattern(n.rule,t)||(i=n.message),i!=="")break;return i}_parseSchemaRules(r){let t=[],e=r.rules;if(r.required===!0&&t.push(...this._parseStringRule("required",r.message)),e!=null)if(typeof e=="string")t=t.concat(this._parseStringRule(e,r.message));else if(e instanceof Array)for(let i of e)typeof i=="string"?t.push(...this._parseStringRule(i,r.message)):i instanceof RegExp||typeof i=="function"?t.push({rule:i,message:r.message||K}):typeof i.rule=="string"?t.push(...this._parseStringRule(i.rule,i.message)):t.push({rule:i.rule,message:i.message||K});else t.push({rule:e,message:K});return t}_parseStringRule(r,t){let e=[],i=r.split("|");for(let n of i){let l=t,o=null,h;if(r==="required")o="required",l=l||t||O.required;else if(x.same.test(n)){if(n.match(x.same)!=null){o=x.same;let u=n.match(x.same);u!=null&&(h=u[1]),l=l||O.same}}else Object.hasOwn(x,n)&&(o=x[n],l=l||O[n]);e.push({rule:o,message:l,sameKey:h})}return e}}class pt extends k{constructor(){super();a(this,"inline",!1);a(this,"labelPosition","right");a(this,"labelWidth");a(this,"id");a(this,"disabled",!1);a(this,"sharedAttrs",["disabled","id","innerBlock"]);a(this,"validator");a(this,"innerBlock",!1);a(this,"novalidate",!1);a(this,"_data");a(this,"emit");a(this,"ruleChange",t=>{this.validator.addSchema(t)});a(this,"_valueChange",(t,e,i=!0)=>{this._data==null&&(this._data={});const n=Object.hasOwn(this._data,t);this._data[t]=e,!this.novalidate&&n&&i&&this.validator.validateKey(t,e,this._data).then(()=>{b(this.id,"validateChange",!0,t)}).catch(l=>{b(this.id,"validateChange",l.detail,t)})});w(this),this.id==null&&(this.id=`l-f${C(3)}-${C(6)}`),this.validator=new qt([]),this.emit=new CustomEvent("submit")}static get observedAttributes(){return["disabled","label-position"]}attributeChangedCallback(t,e,i){if(t==="disabled"){const n=y(i,!1,t);n!==this.disabled&&(b(this.id,"attributeChanged",t,n,this.id),this.disabled=n)}else if(t==="label-position"){const n=m("form",this.root);n&&(n.className=E(["l-form",this.inline?"l-form-inline":void 0,`l-form--${i}`]))}}connectedCallback(){this.loadStyle(["form"]),super.connectedCallback(),A(this.id,"ruleChange",this.ruleChange),A(this.id,"valueChange",this._valueChange)}disconnectedCallback(){st(this.id),this.validator=void 0}render(){const t=E(["l-form",this.inline?"l-form-inline":void 0,`l-form--${this.labelPosition}`]),e=z({"--l-form-label-width":this.labelWidth?this.labelWidth:""});this.shadow.innerHTML=`<form class="${t}" style="${e}"><slot></slot></form>`}validateField(t){const e=[];if(this._data!=null){if(Array.isArray(t))for(let i=0,n=t.length;i<n;i++){const l=t[i];e.push(this.validator.validateKey(l,this._data[l],this._data))}else e.push(this.validator.validateKey(t,this._data[t],this._data));Promise.allSettled(e).then(i=>{for(let n=0,l=i.length;n<l;n++){const o=i[n];o.status==="rejected"?b(this.id,"validateChange",o.reason.detail,o.reason.key):b(this.id,"validateChange",!0,o.value.key)}})}}clearValidate(){b(this.id,"validateChange",!0)}reset(){this.clearValidate(),b(this.id,"reset")}submit(){this.novalidate?this.dispatchEvent(this.emit):this.validate().then(t=>{t&&this.dispatchEvent(this.emit)})}async validate(){if(this._data!=null)try{return await this.validator.validate(this._data),b(this.id,"validateChange",!0),Promise.resolve(!0)}catch(t){return b(this.id,"validateChange",t.detail),Promise.resolve(!1)}return Promise.resolve(!0)}getData(){return{...this._data}}}a(pt,"baseName","form");class vt extends k{constructor(){super();a(this,"disabled",!1);a(this,"sharedAttrs",["disabled","id","name","innerBlock"]);a(this,"required",!1);a(this,"error");a(this,"label");a(this,"id");a(this,"verify");a(this,"validity");a(this,"pattern");a(this,"name");a(this,"innerBlock",!1);a(this,"labelPosition","right");a(this,"formId");a(this,"_validateChange",(t,e)=>{const i=t===!0?void 0:t[this.name];(e==null||e===this.name&&this.error!=i)&&(this.error=i,this._updateError())});w(this),this.id==null&&(this.id=`l-fi${C(3)}-${C(6)}`)}static get observedAttributes(){return["error","label","disabled"]}attributeChangedCallback(t,e,i){if(t==="error")i!=this.error&&(this.error=i,this._updateError());else if(t==="label")this.label=i,this._updateLabel();else if(t==="disabled"){const n=y(i,!1,t);n!==this.disabled&&(b(this.id,"attributeChanged",t,n,this.id),this.disabled=n)}}connectedCallback(){var t;if(super.connectedCallback(),this.loadStyle(["form"]),this.formId=this._getFormId(),this.name&&this.formId){let e=((t=this.verify)==null?void 0:t.split("|"))||[];this.pattern&&e.push(new RegExp(this.pattern));const i={key:this.name,required:this.required,message:this.validity,rules:e};b(this.formId,"ruleChange",i),A(this.formId,"validateChange",this._validateChange)}}disconnectedCallback(){st(this.id),this.formId&&N(this.formId,"validateChange",this._validateChange)}setRules(t){const e={...t,key:this.name};e.required!=null&&this.required&&(e.required=!0),this.formId&&b(this.formId,"ruleChange",e)}setError(t){this.error=t}render(){const t=["l-form-item",this.required?"is-required":void 0,this.error?"is-error":void 0,`l-form-item--${this.labelPosition}`],e=this.label!=null?`<label class="l-form-item__label">${this.label}</label>`:"",i=this.error?`<div class="l-form-item__error">${this.error}</div>`:"";this.shadow.innerHTML=[`<div class="${E(t)}">${e}`,'<div class="l-form-item__content">',`<slot></slot>${i}</div></div>`].join("")}_updateError(){if(!this.rendered)return;let t=m(".l-form-item__error",this.root);if(t)this.error?t.textContent=this.error:t.remove();else if(this.error){t=document.createElement("div"),t.className="l-form-item__error",t.textContent=this.error;const i=m(".l-form-item__content",this.root);i&&i.appendChild(t)}const e=m(".l-form-item",this.root);e&&(this.error?M(e,"is-error"):L(e,"is-error"))}_updateLabel(){if(!this.rendered)return;let t=m(".l-form-item__label",this.root);if(t==null){if(this.label!=null){t=document.createElement("div"),t.className="l-form-item__label",t.textContent=this.label;const e=m(".l-form-item",this.root);e&&e.appendChild(t)}}else this.label!=null?t.textContent=this.label:t.remove()}_getFormId(){let t=this.parentElement,e;for(;t!=null;){const i=t.tagName;if(i==="L-FORM"){e=t.id;break}if(i==="BODY")break;t=t.parentElement}return t=null,e}}a(vt,"baseName","form-item");class _t extends it{constructor(){super(!1);a(this,"type");a(this,"label");a(this,"checked",!1);a(this,"_changeEvent");a(this,"_radioChange",t=>{const e=t.target;let i=e.parentElement;for(;i!=null&&!J(i,"l-radio");)i=i.parentElement;const n=m(".is-checked",this.root);n&&L(n,"is-checked"),this.value=e.value,i&&M(i,"is-checked"),this.dispatchEvent(this._changeEvent)});w(this),this._changeEvent=new CustomEvent("change")}setItems(t){this._removeEvents(),this.root.innerHTML=this._renderItems(t),this._initEvents()}connectedCallback(){super.connectedCallback(),this.loadStyle(["radio"]),this._initEvents()}disconnectedCallback(){super.disconnectedCallback(),this._removeEvents()}attributeChange(t,e,i){if(t==="checked"){const n=y(i,!1,t);this.checked=n,this.value=n;const l=m(".l-radio",this.root);if(l&&!J(l,"is-checked")){M(l,"is-checked");const o=m("input",l);o&&(o.checked=!0)}}}render(){this.getName()||(this.name=`la${C(3)}_${C(6)}`);const t=[],e=m('[slot="label"]',this),i=F("[radio-value]",this);e!=null||this.label?(this.value=this._isChecked(),e?t.push(this._renderItem("slot",void 0,this._isChecked(),"label")):t.push(this._renderItem(this.label,void 0,this._isChecked(),"label"))):i.length>0&&(B(i,n=>{const l=n.cloneNode(!0),o=q(n,"radio-value");t.push(this._renderItem(l.outerHTML,o,this.value===o))}),this.pushValueChange()),this.root.innerHTML=t.join("")}_renderItems(t){const e=[];for(let i=0,n=t.length;i<n;i++){const l=t[i];e.push(this._renderItem(l.label,l.value,this.value===l.value,l.labelPart))}return e.join("")}_renderItem(t,e,i=!1,n=void 0){const l=E({"l-radio":!0,"l-radio--disabled":this.isDisabled(),"l-radio--button":this.type==="button","is-checked":i}),o=_("disabled",this.isDisabled()),h=_("checked",i),d=_("value",e),p=`${_("name",this.getName())}${d}${o}${h}`,jt=_("part",n),V=[`<label class="${l}">`,`<input type="radio" class="l-radio__input"${p} />`];this.type!=="button"&&V.push('<span class="l-radio__inner"></span>');let Dt=t==="slot"?'<slot name="label"></slot>':t;return V.push(`<div class="l-radio__label"${jt}>${Dt}</div>`),V.push("</label>"),V.join("")}_isChecked(){return this.checked}_initEvents(){B(F("input",this.root),t=>{P(t,"change",this._radioChange)})}_removeEvents(){B(F("input",this.root),t=>{H(t,"change",this._radioChange)})}}a(_t,"baseName","radio"),f(j);class Ct extends k{constructor(){super();a(this,"finish",!1);a(this,"infinite",!0);a(this,"observer");a(this,"loadMoreEmit");a(this,"$more");w(this),this.loadMoreEmit=new CustomEvent("load-more")}static get observedAttributes(){return["finish"]}attributeChangedCallback(t,e,i){if(t==="finish"){const n=y(i,!1,t);this.finish!==n&&(this.finish=n,this._finishChange())}}connectedCallback(){this.loadStyle(["list"]),this.loadExternalStyle(["animation"]),super.connectedCallback(),this.infinite&&(this.observer=new IntersectionObserver(t=>{t[0].isIntersecting&&!this.finish&&this.dispatchEvent(this.loadMoreEmit)}),this.$more=m(".l-list-loadmore",this.root),!this.finish&&this.$more&&this.observer.observe(this.$more))}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.$more&&(this.observer.unobserve(this.$more),this.$more=void 0),this.observer.disconnect(),this.observer=void 0),this.loadMoreEmit=void 0}render(){const t=["<slot></slot>"];this.infinite&&(t.push('<div class="l-list-loadmore">'),this.finish||t.push('<l-loading-icon class="l-list-icon l-rotate-anim"></l-loading-icon>'),t.push(`<span class="l-list-loadmore-text">${this._loadingText()}</span></div>`)),this.root.innerHTML=t.join("")}_loadingText(){return this.finish?"已经到底啦!":"加载中……"}_finishChange(){if(this.$more){this.observer&&(this.finish?this.observer.unobserve(this.$more):this.observer.observe(this.$more));const t=m(".l-list-loadmore-text",this.$more);t&&(t.textContent=this._loadingText());let e=m(".l-list-icon",this.$more);this.finish?e&&e.remove():e==null&&(e=document.createElement("l-loading-icon"),e.className="l-list-icon l-rotate-anim",this.$more.prepend(e))}}}a(Ct,"baseName","list"),f(Ct),f(_t),f(pt),f(vt),f(et),f(rt),f(g),f(nt),f(lt),f(at),f(ot),f(j),f(ht),globalThis.LMessage=R;function zt(){const s=document.currentScript.src,r=s.lastIndexOf("/"),e=`${s.slice(0,r+1)}litos-ui.css`,i=document.createElement("link");i.rel="stylesheet",i.href=e,i.id="litos-ui-style",document.head.appendChild(i)}zt()})();
|
package/lib/message/index.js
CHANGED
|
@@ -23,8 +23,8 @@ function d(e) {
|
|
|
23
23
|
const i = 15 + s.offsetHeight, n = r.length;
|
|
24
24
|
if (n !== 0)
|
|
25
25
|
for (let o = t; o < n; o++) {
|
|
26
|
-
const c = r[o],
|
|
27
|
-
c.style.setProperty("top", `${
|
|
26
|
+
const c = r[o], l = parseInt(c.style.top, 10) - i;
|
|
27
|
+
c.style.setProperty("top", `${l}px`);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
function v(e) {
|
|
@@ -41,25 +41,25 @@ function v(e) {
|
|
|
41
41
|
"</div>"
|
|
42
42
|
].join(""), t;
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const f = (e) => {
|
|
45
45
|
const t = r.reduce(
|
|
46
|
-
(c,
|
|
46
|
+
(c, l) => c + l.offsetHeight + 15,
|
|
47
47
|
15
|
|
48
48
|
), s = u(), i = typeof e == "string" ? { message: e } : e;
|
|
49
49
|
i.id = s, i.offset = t;
|
|
50
50
|
const n = v(i);
|
|
51
|
-
r.push(n), document.body.appendChild(n), y(n, m);
|
|
51
|
+
r.push(n), document.body.appendChild(n), y(n, m, null);
|
|
52
52
|
let o = i.duration;
|
|
53
53
|
return o == null && (o = 3e3), o !== 0 && setTimeout(() => {
|
|
54
54
|
d(s);
|
|
55
55
|
}, o), s;
|
|
56
56
|
};
|
|
57
57
|
for (const e of ["info", "success", "error", "warn", "show"])
|
|
58
|
-
|
|
58
|
+
f[e] = (t) => {
|
|
59
59
|
const s = typeof t == "string" ? { message: t } : t;
|
|
60
|
-
return e !== "show" ? s.type = e : s.type == null && (s.type = "info"),
|
|
60
|
+
return e !== "show" ? s.type = e : s.type == null && (s.type = "info"), f(s);
|
|
61
61
|
};
|
|
62
|
-
|
|
62
|
+
f.close = d;
|
|
63
63
|
export {
|
|
64
|
-
|
|
64
|
+
f as default
|
|
65
65
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import FormInner from "../form/form_inner";
|
|
2
|
+
type RadioItem = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
/** 允许通过 part 修改样式 */
|
|
6
|
+
labelPart?: string;
|
|
7
|
+
};
|
|
8
|
+
export default class Radio extends FormInner {
|
|
9
|
+
static baseName: string;
|
|
10
|
+
type?: "button";
|
|
11
|
+
label?: string;
|
|
12
|
+
checked: boolean;
|
|
13
|
+
private _changeEvent;
|
|
14
|
+
setItems(items: RadioItem[]): void;
|
|
15
|
+
constructor();
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
disconnectedCallback(): void;
|
|
18
|
+
protected attributeChange(name: string, oldValue: string, newValue: string): void;
|
|
19
|
+
render(): void;
|
|
20
|
+
private _renderItems;
|
|
21
|
+
private _renderItem;
|
|
22
|
+
private _isChecked;
|
|
23
|
+
private _initEvents;
|
|
24
|
+
private _removeEvents;
|
|
25
|
+
private _radioChange;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var E = (o, n, e) => n in o ? C(o, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[n] = e;
|
|
3
|
+
var r = (o, n, e) => E(o, typeof n != "symbol" ? n + "" : n, e);
|
|
4
|
+
import { initAttr as A, tagAttr as h, parseAttrValue as I } from "../util.js";
|
|
5
|
+
import N from "../form/form_inner.js";
|
|
6
|
+
import { $one as d, hasClass as v, addClass as p, $ as u, iterate as m, getAttr as y, formatClass as S, on as j, off as D, removeClass as H } from "ph-utils/dom";
|
|
7
|
+
import { random as b } from "ph-utils";
|
|
8
|
+
class L extends N {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(!1);
|
|
11
|
+
r(this, "type");
|
|
12
|
+
r(this, "label");
|
|
13
|
+
r(this, "checked", !1);
|
|
14
|
+
r(this, "_changeEvent");
|
|
15
|
+
r(this, "_radioChange", (e) => {
|
|
16
|
+
const a = e.target;
|
|
17
|
+
let t = a.parentElement;
|
|
18
|
+
for (; t != null && !v(t, "l-radio"); )
|
|
19
|
+
t = t.parentElement;
|
|
20
|
+
const i = d(".is-checked", this.root);
|
|
21
|
+
i && H(i, "is-checked"), this.value = a.value, t && p(t, "is-checked"), this.dispatchEvent(this._changeEvent);
|
|
22
|
+
});
|
|
23
|
+
A(this), this._changeEvent = new CustomEvent("change");
|
|
24
|
+
}
|
|
25
|
+
setItems(e) {
|
|
26
|
+
this._removeEvents(), this.root.innerHTML = this._renderItems(e), this._initEvents();
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
super.connectedCallback(), this.loadStyle(["radio"]), this._initEvents();
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback(), this._removeEvents();
|
|
33
|
+
}
|
|
34
|
+
attributeChange(e, a, t) {
|
|
35
|
+
if (e === "checked") {
|
|
36
|
+
const i = I(t, !1, e);
|
|
37
|
+
this.checked = i, this.value = i;
|
|
38
|
+
const s = d(".l-radio", this.root);
|
|
39
|
+
if (s && !v(s, "is-checked")) {
|
|
40
|
+
p(s, "is-checked");
|
|
41
|
+
const l = d("input", s);
|
|
42
|
+
l && (l.checked = !0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
this.getName() || (this.name = `la${b(3)}_${b(6)}`);
|
|
48
|
+
const e = [], a = d('[slot="label"]', this), t = u("[radio-value]", this);
|
|
49
|
+
a != null || this.label ? (this.value = this._isChecked(), a ? e.push(
|
|
50
|
+
this._renderItem("slot", void 0, this._isChecked(), "label")
|
|
51
|
+
) : e.push(
|
|
52
|
+
this._renderItem(
|
|
53
|
+
this.label,
|
|
54
|
+
void 0,
|
|
55
|
+
this._isChecked(),
|
|
56
|
+
"label"
|
|
57
|
+
)
|
|
58
|
+
)) : t.length > 0 && (m(t, (i) => {
|
|
59
|
+
const s = i.cloneNode(!0), l = y(i, "radio-value");
|
|
60
|
+
e.push(
|
|
61
|
+
this._renderItem(s.outerHTML, l, this.value === l)
|
|
62
|
+
);
|
|
63
|
+
}), this.pushValueChange()), this.root.innerHTML = e.join("");
|
|
64
|
+
}
|
|
65
|
+
_renderItems(e) {
|
|
66
|
+
const a = [];
|
|
67
|
+
for (let t = 0, i = e.length; t < i; t++) {
|
|
68
|
+
const s = e[t];
|
|
69
|
+
a.push(
|
|
70
|
+
this._renderItem(
|
|
71
|
+
s.label,
|
|
72
|
+
s.value,
|
|
73
|
+
this.value === s.value,
|
|
74
|
+
s.labelPart
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return a.join("");
|
|
79
|
+
}
|
|
80
|
+
_renderItem(e, a, t = !1, i = void 0) {
|
|
81
|
+
const s = S({
|
|
82
|
+
"l-radio": !0,
|
|
83
|
+
"l-radio--disabled": this.isDisabled(),
|
|
84
|
+
"l-radio--button": this.type === "button",
|
|
85
|
+
"is-checked": t
|
|
86
|
+
}), l = h("disabled", this.isDisabled()), _ = h("checked", t), f = h("value", a), k = `${h("name", this.getName())}${f}${l}${_}`, $ = h("part", i), c = [
|
|
87
|
+
`<label class="${s}">`,
|
|
88
|
+
`<input type="radio" class="l-radio__input"${k} />`
|
|
89
|
+
];
|
|
90
|
+
this.type !== "button" && c.push('<span class="l-radio__inner"></span>');
|
|
91
|
+
let g = e === "slot" ? '<slot name="label"></slot>' : e;
|
|
92
|
+
return c.push(
|
|
93
|
+
`<div class="l-radio__label"${$}>${g}</div>`
|
|
94
|
+
), c.push("</label>"), c.join("");
|
|
95
|
+
}
|
|
96
|
+
_isChecked() {
|
|
97
|
+
return this.checked;
|
|
98
|
+
}
|
|
99
|
+
_initEvents() {
|
|
100
|
+
m(u("input", this.root), (e) => {
|
|
101
|
+
j(e, "change", this._radioChange);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
_removeEvents() {
|
|
105
|
+
m(u("input", this.root), (e) => {
|
|
106
|
+
D(e, "change", this._radioChange);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
r(L, "baseName", "radio");
|
|
111
|
+
export {
|
|
112
|
+
L as default
|
|
113
|
+
};
|
package/lib/transition.js
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var c = (r, e, t) => e in r ? l(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var o = (r, e, t) => c(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import d from "./base.js";
|
|
5
|
+
import { startTransition as u, endTransition as g } from "ph-utils/dom";
|
|
6
|
+
class p extends d {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
/** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
|
|
10
|
+
o(this, "sheetRec");
|
|
11
|
+
this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
|
|
12
|
+
}
|
|
4
13
|
static get observedAttributes() {
|
|
5
14
|
return ["sheets"];
|
|
6
15
|
}
|
|
7
|
-
constructor() {
|
|
8
|
-
super(), this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
|
|
9
|
-
}
|
|
10
16
|
connectedCallback() {
|
|
11
17
|
super.connectedCallback(), this.show();
|
|
12
18
|
}
|
|
13
19
|
render() {
|
|
14
20
|
this.shadow.innerHTML = "<slot></slot>";
|
|
15
21
|
}
|
|
16
|
-
attributeChangedCallback(t,
|
|
17
|
-
t === "sheets" && (this.sheetRec = this._parseSheets(
|
|
22
|
+
attributeChangedCallback(t, s, i) {
|
|
23
|
+
t === "sheets" && (this.sheetRec = this._parseSheets(i));
|
|
18
24
|
}
|
|
19
25
|
show() {
|
|
20
26
|
const t = this._getSlotFirstChild();
|
|
21
27
|
if (!t) return;
|
|
22
|
-
const
|
|
23
|
-
|
|
28
|
+
const s = this.getAttr("duration", "0.3s");
|
|
29
|
+
u(t, this.sheetRec, s);
|
|
24
30
|
}
|
|
25
31
|
hide(t) {
|
|
26
|
-
const
|
|
27
|
-
|
|
32
|
+
const s = this._getSlotFirstChild();
|
|
33
|
+
s && g(s, this.sheetRec, t);
|
|
28
34
|
}
|
|
29
35
|
_parseSheets(t) {
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
if (
|
|
33
|
-
const [h,
|
|
34
|
-
|
|
36
|
+
const s = t.split(";"), i = [];
|
|
37
|
+
return s.forEach((n) => {
|
|
38
|
+
if (n) {
|
|
39
|
+
const [h, a] = n.split(":");
|
|
40
|
+
i.push([h.trim(), a.trim()]);
|
|
35
41
|
}
|
|
36
|
-
}),
|
|
42
|
+
}), i;
|
|
37
43
|
}
|
|
38
44
|
_getSlotFirstChild() {
|
|
39
45
|
const t = this.shadow.querySelector("slot");
|
|
40
46
|
return t != null && t.assignedNodes().length > 0 ? t.assignedNodes()[0] : null;
|
|
41
47
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let o = r;
|
|
48
|
+
}
|
|
49
|
+
o(p, "tagName", "transition");
|
|
45
50
|
export {
|
|
46
|
-
|
|
51
|
+
p as Transition
|
|
47
52
|
};
|
package/lib/util.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { isBlank as
|
|
2
|
-
let
|
|
1
|
+
import { isBlank as u } from "ph-utils";
|
|
2
|
+
let m = -1, i = {
|
|
3
3
|
/** 注册应用的前缀 */
|
|
4
4
|
prefix: "l"
|
|
5
5
|
};
|
|
6
6
|
function g(t) {
|
|
7
|
-
|
|
7
|
+
i = { ...i, ...t };
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
const e = n || `${
|
|
9
|
+
function h(t, n) {
|
|
10
|
+
const e = n || `${i.prefix}-${t.baseName}`;
|
|
11
11
|
customElements.get(e) || customElements.define(e, t);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function l(t, n = !1) {
|
|
14
14
|
t = t || "l-transition";
|
|
15
15
|
let e = t;
|
|
16
16
|
typeof t == "string" && (e = document.querySelector(t)), e && e.hide(() => {
|
|
17
17
|
n && e.remove();
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return `${
|
|
20
|
+
function y() {
|
|
21
|
+
return `${i.prefix}-${++m}`;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function p(t, n, e) {
|
|
24
24
|
if (t == null) return n;
|
|
25
25
|
switch (typeof n) {
|
|
26
26
|
case "boolean":
|
|
@@ -31,23 +31,26 @@ function a(t, n, e) {
|
|
|
31
31
|
return t;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function b(t) {
|
|
35
35
|
const n = t.attributes;
|
|
36
36
|
for (const e of n) {
|
|
37
|
-
const { name:
|
|
38
|
-
|
|
37
|
+
const { name: r, value: c } = e;
|
|
38
|
+
if (r.startsWith("data-") || r.startsWith("aria-") || r.startsWith("_") || r.startsWith("$"))
|
|
39
|
+
continue;
|
|
40
|
+
const o = r.split("-").map((s, a) => a === 0 ? s : s[0].toUpperCase() + s.slice(1)).join(""), f = p(c, t[o], r);
|
|
41
|
+
t[o] = f, r === "value" && (t._resetValue = f);
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
|
-
function
|
|
44
|
+
function x(t, n) {
|
|
42
45
|
let e = " ";
|
|
43
|
-
return n === !0 ? e = ` ${t}` : typeof n == "string" && !
|
|
46
|
+
return n === !0 ? e = ` ${t}` : typeof n == "string" && !u(n) && (e = ` ${t}="${n}"`), e;
|
|
44
47
|
}
|
|
45
48
|
export {
|
|
46
49
|
g as config,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
l as hideTransition,
|
|
51
|
+
b as initAttr,
|
|
52
|
+
p as parseAttrValue,
|
|
53
|
+
h as regist,
|
|
54
|
+
x as tagAttr,
|
|
55
|
+
y as useId
|
|
53
56
|
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litos-ui",
|
|
3
3
|
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@eslint/js": "^9.16.0",
|
|
8
8
|
"@types/node": "^22.10.1",
|
|
9
9
|
"eslint": "^9.16.0",
|
|
10
10
|
"globals": "^15.13.0",
|
|
11
|
+
"less": "^4.2.1",
|
|
11
12
|
"lightningcss": "^1.28.2",
|
|
12
|
-
"prettier": "^3.4.
|
|
13
|
+
"prettier": "^3.4.2",
|
|
13
14
|
"typescript": "^5.7.2",
|
|
14
|
-
"typescript-eslint": "^8.
|
|
15
|
-
"vite": "^6.0.
|
|
15
|
+
"typescript-eslint": "^8.18.0",
|
|
16
|
+
"vite": "^6.0.3",
|
|
16
17
|
"vitepress": "^1.5.0"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
@@ -49,8 +50,8 @@
|
|
|
49
50
|
},
|
|
50
51
|
"license": "MIT",
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"ph-utils": "^0.
|
|
53
|
-
"shiki": "^1.24.
|
|
53
|
+
"ph-utils": "^0.11.4",
|
|
54
|
+
"shiki": "^1.24.1"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|
|
56
57
|
"docs:dev": "vitepress dev docs",
|
package/styles/reset.css
CHANGED
package/lib/index-CWq5_ldX.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const i = ".l-input{--l-input-width: auto;outline:none;box-sizing:border-box;width:var(--l-input-width);max-width:100%;height:var(--l-form-edit-height, 32px);border:1px solid var(--l-border-color, #dedede);transition:border-color .3s;text-align:inherit;padding:0 5px;border-radius:3px;vertical-align:middle}.l-input.is-autosize{width:auto}.l-input:focus{border-color:var(--l-primary-color, #722ed1)}.l-input:disabled{cursor:not-allowed;background:var(--l-disabled-color, #f5f7fa)}";
|
|
2
|
-
export {
|
|
3
|
-
i as default
|
|
4
|
-
};
|
package/lib/index-CbaSCp33.js
DELETED
package/lib/index-DZ2ZMrk1.js
DELETED
package/lib/index-JjjljTZ2.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const r = ".l-btn{--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #722ed1);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #9254de);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #531dab);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:0 15px;line-height:1;height:var(--l-form-edit-height, 32px);border-radius:3px;font-size:14px;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:5px;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var( --l-btn-active-border-color, var(--l-btn-active-background) );color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color, #722ed1);--l-btn-hover-background: var(--l-primary-color-light1, #9254de);--l-btn-active-background: var(--l-primary-color-dark1, #531dab)}.l-btn:not(.l-btn-loading):disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;height:auto;padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #722ed1);--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-edit-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-edit-height, 32px);padding:0}.l-btn-block{width:100%}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
|
|
2
|
-
export {
|
|
3
|
-
r as default
|
|
4
|
-
};
|