@gf-ui/components
Version:
1 lines • 11.8 kB
JavaScript
import{r as t,h as s,H as i,c as e}from"./p-d3a3a91e.js";import{I as n}from"./p-be7b88a7.js";const o={name:"svg",type:"element",value:"",attributes:{class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},children:[{name:"path",type:"element",value:"",attributes:{fill:"currentColor",d:"M553.936 504l79.2 79.2a16 16 0 0 1 0 22.624l-11.312 11.312a16 16 0 0 1-22.624 0l-79.2-79.2-79.2 79.2a16 16 0 0 1-22.624 0l-11.312-11.312a16 16 0 0 1 0-22.624l79.2-79.2-79.2-79.2a16 16 0 0 1 0-22.624l11.312-11.312a16 16 0 0 1 22.624 0l79.2 79.2 79.2-79.2a16 16 0 0 1 22.624 0l11.312 11.312a16 16 0 0 1 0 22.624l-79.2 79.2zM512 800c159.056 0 288-128.944 288-288s-128.944-288-288-288-288 128.944-288 288 128.944 288 288 288z m0 48c-185.568 0-336-150.432-336-336s150.432-336 336-336 336 150.432 336 336-150.432 336-336 336z"},children:[]}],_name:"clear",_isColor:!1},h={name:"svg",type:"element",value:"",attributes:{class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},children:[{name:"path",type:"element",value:"",attributes:{fill:"currentColor",d:"M509.92 795.84c157.904 0 285.92-128.016 285.92-285.92C795.84 352 667.808 224 509.92 224 352 224 224 352 224 509.92c0 157.904 128 285.92 285.92 285.92z m0 48C325.504 843.84 176 694.32 176 509.92 176 325.504 325.504 176 509.92 176c184.416 0 333.92 149.504 333.92 333.92 0 184.416-149.504 333.92-333.92 333.92z m-2.448-400.704h16a16 16 0 0 1 16 16v201.728a16 16 0 0 1-16 16h-16a16 16 0 0 1-16-16V459.136a16 16 0 0 1 16-16z m0-100.176h16a16 16 0 0 1 16 16v23.648a16 16 0 0 1-16 16h-16a16 16 0 0 1-16-16v-23.648a16 16 0 0 1 16-16z"},children:[]}],_name:"info",_isColor:!1},l={name:"svg",type:"element",value:"",attributes:{class:"icon",width:"32px",height:"32.00px",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},children:[{name:"path",type:"element",value:"",attributes:{d:"M102.4 102.4m307.2 0l204.8 0q307.2 0 307.2 307.2l0 204.8q0 307.2-307.2 307.2l-204.8 0q-307.2 0-307.2-307.2l0-204.8q0-307.2 307.2-307.2Z",fill:"#867EFC","fill-opacity":".2"},children:[]},{name:"path",type:"element",value:"",attributes:{d:"M286.72 460.8m40.96 0l61.44 0q40.96 0 40.96 40.96l0 122.88q0 40.96-40.96 40.96l-61.44 0q-40.96 0-40.96-40.96l0-122.88q0-40.96 40.96-40.96Z",fill:"#867EFC"},children:[]},{name:"path",type:"element",value:"",attributes:{d:"M440.32 307.2m40.96 0l61.44 0q40.96 0 40.96 40.96l0 276.48q0 40.96-40.96 40.96l-61.44 0q-40.96 0-40.96-40.96l0-276.48q0-40.96 40.96-40.96Z",fill:"#867EFC"},children:[]},{name:"path",type:"element",value:"",attributes:{d:"M737.28 686.08m0 30.72l0 20.48q0 30.72-30.72 30.72l-389.12 0q-30.72 0-30.72-30.72l0-20.48q0-30.72 30.72-30.72l389.12 0q30.72 0 30.72 30.72Z",fill:"#867EFC","fill-opacity":".6"},children:[]},{name:"path",type:"element",value:"",attributes:{d:"M593.92 399.36m40.96 0l61.44 0q40.96 0 40.96 40.96l0 184.32q0 40.96-40.96 40.96l-61.44 0q-40.96 0-40.96-40.96l0-184.32q0-40.96 40.96-40.96Z",fill:"#867EFC"},children:[]}],_name:"paihangbang-c",_isColor:!0},a={name:"svg",type:"element",value:"",attributes:{class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},children:[{name:"path",type:"element",value:"",attributes:{fill:"currentColor",d:"M512 149.333333c200.298667 0 362.666667 162.368 362.666667 362.666667s-162.368 362.666667-362.666667 362.666667S149.333333 712.298667 149.333333 512 311.701333 149.333333 512 149.333333z m169.045333 191.04L455.317333 572.650667l-90.944-94.336-46.08 44.416 136.832 141.952 271.829334-279.722667-45.909334-44.586667z"},children:[]}],_name:"success-fill",_isColor:!1},r={name:"svg",type:"element",value:"",attributes:{class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},children:[{name:"path",type:"element",value:"",attributes:{fill:"currentColor",d:"M512 243.712c164.949333 0 298.666667 133.717333 298.666667 298.666667s-133.717333 298.666667-298.666667 298.666666-298.666667-133.717333-298.666667-298.666666 133.717333-298.666667 298.666667-298.666667z m0 64c-129.6 0-234.666667 105.066667-234.666667 234.666667s105.066667 234.666667 234.666667 234.666666 234.666667-105.066667 234.666667-234.666666-105.066667-234.666667-234.666667-234.666667z m27.477333 59.157333v126.378667l69.824-69.824 45.226667 45.269333-124.416 124.437334c-20.16 20.16-54.634667 5.888-54.634667-22.613334v-203.648h64zM620.586667 139.306667v67.882666H394.346667V139.306667H620.586667z"},children:[]}],_name:"task-management",_isColor:!1},c=class{constructor(s){t(this,s),this.size=30,this.styles={},this.color="#606266",this.rotate=0,this.spin=!1,this.opacity=1}render(){const{size:t,styles:e,color:h,rotate:l,spin:a,opacity:r}=this;return s(i,{style:{width:t+"px",height:t+"px"}},s(n,Object.assign({},{svgData:o,size:t,styles:e,color:h,rotate:l,spin:a,opacity:r})))}},p=class{constructor(s){t(this,s),this.size=30,this.styles={},this.color="#606266",this.rotate=0,this.spin=!1,this.opacity=1}render(){const{size:t,styles:e,color:o,rotate:l,spin:a,opacity:r}=this;return s(i,{style:{width:t+"px",height:t+"px"}},s(n,Object.assign({},{svgData:h,size:t,styles:e,color:o,rotate:l,spin:a,opacity:r})))}},d=class{constructor(s){t(this,s),this.size=30,this.styles={},this.color="#606266",this.rotate=0,this.spin=!1,this.opacity=1}render(){const{size:t,styles:e,color:o,rotate:h,spin:a,opacity:r}=this;return s(i,{style:{width:t+"px",height:t+"px"}},s(n,Object.assign({},{svgData:l,size:t,styles:e,color:o,rotate:h,spin:a,opacity:r})))}},u=class{constructor(s){t(this,s),this.size=30,this.styles={},this.color="#606266",this.rotate=0,this.spin=!1,this.opacity=1}render(){const{size:t,styles:e,color:o,rotate:h,spin:l,opacity:r}=this;return s(i,{style:{width:t+"px",height:t+"px"}},s(n,Object.assign({},{svgData:a,size:t,styles:e,color:o,rotate:h,spin:l,opacity:r})))}},m=class{constructor(s){t(this,s),this.size=30,this.styles={},this.color="#606266",this.rotate=0,this.spin=!1,this.opacity=1}render(){const{size:t,styles:e,color:o,rotate:h,spin:l,opacity:a}=this;return s(i,{style:{width:t+"px",height:t+"px"}},s(n,Object.assign({},{svgData:r,size:t,styles:e,color:o,rotate:h,spin:l,opacity:a})))}};let g;const f=["position: absolute !important;","top: 0 !important;","right: 0 !important;","height: 0 !important;","visibility: hidden !important;","overflow: hidden !important;","z-index: -1000 !important;"],v=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing"];!function(t){console.log(t);for(const s in t){const i=t[s],e=s.replace(/([A-Z])/g,"-$1").toLowerCase().substring(1);customElements.define(e,i)}}({GfIconclear:c,GfIconinfo:p,GfIconsuccessFill:u});const b={success:{color:"#67C23A"},info:{color:"#346FC2"},warning:{color:"#ffc82c"},error:{color:"#ff4949"}},x=class{constructor(i){t(this,i),this.eventFocus=e(this,"eventFocus",7),this.eventBlur=e(this,"eventBlur",7),this.eventInput=e(this,"eventInput",7),this.eventChange=e(this,"eventChange",7),this.eventClear=e(this,"eventClear",7),this.disabled=!1,this.clearable=!1,this.value="",this.type="text",this.status="",this.iconFontSize=20,this.iconColor="#ccc",this.autofocus=!1,this.resize="vertical",this.rows=2,this.autosize=!1,this.curentValue="",this.calculateStyle={resize:this.resize},this.isComposing=!1,this.handleFocus=t=>{this.eventFocus.emit(t)},this.handleBlur=t=>{this.eventBlur.emit(t)},this.handleInput=t=>{if(this.isComposing)return;const s=t.target.value;this.eventInput.emit(s),this.setCurrentValue(s),this.resizeTextarea()},this.handleChange=t=>{this.eventChange.emit(t.target.value)},this.handClearClick=()=>{this.setCurrentValue(""),this.eventClear.emit(""),this.eventInput.emit(""),this.eventChange.emit("")},this.setCurrentValue=t=>{this.curentValue=t},this.handleCompositionStart=()=>{this.isComposing=!0},this.handleCompositionEnd=t=>{this.isComposing&&(this.isComposing=!1,this.handleInput(t))},this.onKeydown=t=>{"Enter"===t.key&&console.log("enter")},this.getClearInstance=()=>s("div",{class:"gf-input__clear"},s("gf-icon-clear",{size:this.iconFontSize,color:this.iconColor,onClick:this.handClearClick.bind(this)})),this.getStatusInstance=()=>s("div",{class:"gf-input__status_icon"},"success"===this.status&&s("gf-icon-success-fill",{size:this.iconFontSize,color:b[this.status].color}),["info","warning"].includes(this.status)&&s("gf-icon-info",{size:this.iconFontSize,color:b[this.status].color}),"error"===this.status&&s("gf-icon-clear",{size:this.iconFontSize,color:b[this.status].color})),this.getMaxLengthInstance=()=>s("div",{class:"gf-input__maxlength"},s("span",null,this.curentValue.length),"/",this.maxlength),this.getInputInstance=()=>"textarea"!==this.type?s("input",{type:this.type,disabled:this.disabled,class:"gf-input__inner",value:this.curentValue,minLength:this.maxlength,maxLength:this.maxlength,placeholder:this.placeholder,onFocus:this.handleFocus,onBlur:this.handleBlur,onInput:this.handleInput,onChange:this.handleChange,ref:t=>this.nativeInput=t,onKeyDown:this.onKeydown}):s("textarea",{class:"gf-textarea__inner",style:this.calculateStyle,disabled:this.disabled,value:this.curentValue,autofocus:this.autofocus,minLength:this.maxlength,maxLength:this.maxlength,placeholder:this.placeholder,rows:+this.rows,onFocus:this.handleFocus,onBlur:this.handleBlur,onInput:this.handleInput,onChange:this.handleChange,ref:t=>this.nativeInput=t})}watchPropHandler(t){t!==this.curentValue&&this.setCurrentValue(t)}componentWillLoad(){this.setCurrentValue(this.value),Promise.resolve().then((()=>{this.resizeTextarea()}))}componentDidLoad(){const t=this.nativeInput;t&&(t.addEventListener("compositionstart",this.handleCompositionStart),t.addEventListener("compositionend",this.handleCompositionEnd))}disconnectedCallback(){const t=this.nativeInput;t&&(t.removeEventListener("compositionstart",this.handleCompositionStart),t.removeEventListener("compositionEnd",this.handleCompositionEnd))}resizeTextarea(){(this.autosize||this.minRows||this.maxRows)&&(this.calculateStyle=Object.assign(Object.assign({},function(t,s=1,i=null){g||(g=document.createElement("textarea"),document.body.appendChild(g));const{boxSizing:e,paddingSize:n,borderSize:o,contextStyle:h}=function(t){const s=window.getComputedStyle(t);return{boxSizing:s.getPropertyValue("box-sizing"),paddingSize:parseFloat(s.getPropertyValue("padding-bottom"))+parseFloat(s.getPropertyValue("padding-top")),borderSize:parseFloat(s.getPropertyValue("border-bottom-width"))+parseFloat(s.getPropertyValue("border-top-width")),contextStyle:v.map((t=>`${t}:${s.getPropertyValue(t)}`)).join(";")}}(t);g.setAttribute("style",`${h};${f.join("")}`),g.value=t.value||t.placeholder||"";const l={};let a=g.scrollHeight;"border-box"===e?a+=o:"content-box"===e&&(a-=n),g.value="";const r=g.scrollHeight-n;if(null!==s){let t=r*s;"border-box"===e&&(t=t+n+o),a=Math.max(t,a),l.minHeight=`${t}px`}if(null!==i){let t=r*i;"border-box"===e&&(t=t+n+o),a=Math.min(t,a)}return l.height=`${a}px`,g.parentNode&&g.parentNode.removeChild(g),g=null,l}(this.nativeInput,this.minRows,this.maxRows)),{resize:this.resize}))}render(){return s(i,null,s("div",{class:`\n ${"textarea"!==this.type?"gf-input":"gf-textarea"}\n ${this.disabled?"is-disabled":""}\n ${this.status?"is-input-"+this.status:""}`},s("slot",{name:"before"}),this.getInputInstance(),this.clearable&&this.curentValue?this.getClearInstance():"",Number(this.maxlength)>0?this.getMaxLengthInstance():"",this.status?this.getStatusInstance():"",s("slot",{name:"after"})))}static get watchers(){return{value:["watchPropHandler"]}}};export{c as gf_icon_clear,p as gf_icon_info,d as gf_icon_paihangbang_c,u as gf_icon_success_fill,m as gf_icon_task_management,x as gf_input}