UNPKG

cc-ui-plus

Version:

13 lines (11 loc) 14.1 kB
(function(e,x){typeof exports=="object"&&typeof module<"u"?module.exports=x(require("vue")):typeof define=="function"&&define.amd?define(["vue"],x):(e=typeof globalThis<"u"?globalThis:e||self,e.index=x(e.Vue))})(this,function(e){"use strict";function x(n,t){return n.install=o=>{o.component(t,n)},n}const P={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},D=[e.createElementVNode("path",{d:"M685.4 354.8c0-4.4-3.6-8-8-8l-66 .3L512 465.6l-99.3-118.4l-66.1-.3c-4.4 0-8 3.5-8 8c0 1.9.7 3.7 1.9 5.2l130.1 155L340.5 670a8.32 8.32 0 0 0-1.9 5.2c0 4.4 3.6 8 8 8l66.1-.3L512 564.4l99.3 118.4l66 .3c4.4 0 8-3.5 8-8c0-1.9-.7-3.7-1.9-5.2L553.5 515l130.1-155c1.2-1.4 1.8-3.3 1.8-5.2z",fill:"currentColor"},null,-1),e.createElementVNode("path",{d:"M512 65C264.6 65 64 265.6 64 513s200.6 448 448 448s448-200.6 448-448S759.4 65 512 65zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"},null,-1)],W=e.defineComponent({name:"CloseCircleOutlined",render:function(t,o){return e.openBlock(),e.createElementBlock("svg",P,D)}}),Q={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},U=[e.createElementVNode("path",{d:"M942.2 486.2Q889.47 375.11 816.7 305l-50.88 50.88C807.31 395.53 843.45 447.4 874.7 512C791.5 684.2 673.4 766 512 766q-72.67 0-133.87-22.38L323 798.75Q408 838 512 838q288.3 0 430.2-300.3a60.29 60.29 0 0 0 0-51.5zm-63.57-320.64L836 122.88a8 8 0 0 0-11.32 0L715.31 232.2Q624.86 186 512 186q-288.3 0-430.2 300.3a60.3 60.3 0 0 0 0 51.5q56.69 119.4 136.5 191.41L112.48 835a8 8 0 0 0 0 11.31L155.17 889a8 8 0 0 0 11.31 0l712.15-712.12a8 8 0 0 0 0-11.32zM149.3 512C232.6 339.8 350.7 258 512 258c54.54 0 104.13 9.36 149.12 28.39l-70.3 70.3a176 176 0 0 0-238.13 238.13l-83.42 83.42C223.1 637.49 183.3 582.28 149.3 512zm246.7 0a112.11 112.11 0 0 1 146.2-106.69L401.31 546.2A112 112 0 0 1 396 512z",fill:"currentColor"},null,-1),e.createElementVNode("path",{d:"M508 624c-3.46 0-6.87-.16-10.25-.47l-52.82 52.82a176.09 176.09 0 0 0 227.42-227.42l-52.82 52.82c.31 3.38.47 6.79.47 10.25a111.94 111.94 0 0 1-112 112z",fill:"currentColor"},null,-1)],F=e.defineComponent({name:"EyeInvisibleOutlined",render:function(t,o){return e.openBlock(),e.createElementBlock("svg",Q,U)}}),K={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},Z=[e.createElementVNode("path",{d:"M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 0 0 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3c7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176s176-78.8 176-176s-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112s112 50.1 112 112s-50.1 112-112 112z",fill:"currentColor"},null,-1)],G=e.defineComponent({name:"EyeOutlined",render:function(t,o){return e.openBlock(),e.createElementBlock("svg",K,Z)}});function y(n,t,o){let l=n;return t&&(l+=`__${t}`),o&&(l+=`--${o}`),l}function H(n){const t=`cc-${n}`;return{b:()=>y(t),e:r=>r?y(t,r):"",m:r=>r?y(t,"",r):"",em:(r,s)=>r&&s?y(t,r,s):""}}function J(n){let t=0;for(let o=0;o<n.length;++o)n[o]==="&"&&++t;return t}const V=/\s*,(?![^(]*\))\s*/g,X=/\s+/g;function Y(n,t){const o=[];return t.split(V).forEach(l=>{let c=J(l);if(c){if(c===1){n.forEach(r=>{o.push(l.replace("&",r))});return}}else{n.forEach(r=>{o.push((r&&r+" ")+l)});return}let i=[l];for(;c--;){const r=[];i.forEach(s=>{n.forEach(f=>{r.push(s.replace("&",f))})}),i=r}i.forEach(r=>o.push(r))}),o}function v(n,t){const o=[];return t.split(V).forEach(l=>{n.forEach(c=>{o.push((c&&c+" ")+l)})}),o}function ee(n){let t=[""];return n.forEach(o=>{o=o&&o.trim(),o&&(o.includes("&")?t=Y(t,o):t=v(t,o))}),t.join(", ").replace(X," ")}const ne=/[A-Z]/g;function N(n){return n.replace(ne,t=>"-"+t.toLowerCase())}function te(n,t=" "){return typeof n=="object"&&n!==null?` { `+Object.entries(n).map(o=>t+` ${N(o[0])}: ${o[1]};`).join(` `)+` `+t+"}":`: ${n};`}function oe(n,t,o){return typeof n=="function"?n({context:t.context,props:o}):n}function I(n,t,o,l){if(!t)return"";const c=oe(t,o,l);if(!c)return"";if(typeof c=="string")return`${n} { ${c} }`;const i=Object.keys(c);if(i.length===0)return o.config.keepEmptyBlock?n+` { }`:"";const r=n?[n+" {"]:[];return i.forEach(s=>{const f=c[s];if(s==="raw"){r.push(` `+f+` `);return}s=N(s),f!=null&&r.push(` ${s}${te(f)}`)}),n&&r.push("}"),r.join(` `)}function k(n,t,o){!n||n.forEach(l=>{if(Array.isArray(l))k(l,t,o);else if(typeof l=="function"){const c=l(t);Array.isArray(c)?k(c,t,o):c&&o(c)}else l&&o(l)})}function A(n,t,o,l,c,i){const r=n.$;!r||typeof r=="string"?t.push(r):typeof r=="function"?t.push(r({context:l.context,props:c})):(r.before&&r.before(l.context),!r.$||typeof r.$=="string"?t.push(r.$):r.$&&t.push(r.$({context:l.context,props:c})));const s=ee(t),f=I(s,n.props,l,c);i&&f&&i.insertRule(f),!i&&f.length&&o.push(f),n.children&&k(n.children,{context:l.context,props:c},u=>{if(typeof u=="string"){const p=I(s,{raw:u},l,c);i?i.insertRule(p):o.push(p)}else A(u,t,o,l,c,i)}),t.pop(),r&&r.after&&r.after(l.context)}function S(n,t,o,l=!1){const c=[];return A(n,[],c,t,o,l?n.instance.__styleSheet:void 0),l?"":c.join(` `)}function le(n){for(var t=0,o,l=0,c=n.length;c>=4;++l,c-=4)o=n.charCodeAt(l)&255|(n.charCodeAt(++l)&255)<<8|(n.charCodeAt(++l)&255)<<16|(n.charCodeAt(++l)&255)<<24,o=(o&65535)*1540483477+((o>>>16)*59797<<16),o^=o>>>24,t=(o&65535)*1540483477+((o>>>16)*59797<<16)^(t&65535)*1540483477+((t>>>16)*59797<<16);switch(c){case 3:t^=(n.charCodeAt(l+2)&255)<<16;case 2:t^=(n.charCodeAt(l+1)&255)<<8;case 1:t^=n.charCodeAt(l)&255,t=(t&65535)*1540483477+((t>>>16)*59797<<16)}return t^=t>>>13,t=(t&65535)*1540483477+((t>>>16)*59797<<16),((t^t>>>15)>>>0).toString(36)}function b(n){if(!n)return;const t=n.parentElement;t&&t.removeChild(n)}function B(n){return document.querySelector(`style[cssr-id="${n}"]`)}function re(n){const t=document.createElement("style");return t.setAttribute("cssr-id",n),t}window&&(window.__cssrContext={});function L(n){const t=n.getAttribute("mount-count");return t===null?null:Number(t)}function E(n,t){n.setAttribute("mount-count",String(t))}function T(n,t,o,l){const{els:c}=t;if(o===void 0)c.forEach(b),t.els=[];else{const i=B(o);if(i&&c.includes(i)){const r=L(i);l?r===null?console.error(`[css-render/unmount]: The style with target='${o}' is mounted in count mode.`):r<=1?(b(i),t.els=c.filter(s=>s!==i)):E(i,r-1):r!==null?console.error(`[css-render/unmount]: The style with target='${o}' is mounted in no-count mode.`):(b(i),t.els=c.filter(s=>s!==i))}}}function ce(n,t){n.push(t)}function ie(n,t,o,l,c,i,r,s,f){if(r&&!f){if(o===void 0){console.error("[css-render/mount]: `id` is required in `boost` mode.");return}const h=window.__cssrContext;h[o]||(h[o]=!0,S(t,n,l,r));return}let u;const{els:p}=t;let d;if(o===void 0&&(d=t.render(l),o=le(d)),f){f(o,d!=null?d:t.render(l));return}const m=B(o);if(s||m===null){if(u=m===null?re(o):m,d===void 0&&(d=t.render(l)),u.textContent=d,m!==null)return;if(c){const h=document.head.getElementsByTagName("style")[0]||null;document.head.insertBefore(u,h)}else document.head.appendChild(u);i&&E(u,1),ce(p,u)}else{const h=L(m);i?h===null?console.error(`[css-render/mount]: The style with id='${o}' has been mounted in no-count mode.`):E(m,h+1):h!==null&&console.error(`[css-render/mount]: The style with id='${o}' has been mounted in count mode.`)}return m!=null?m:u}function se(n){return S(this,this.instance,n)}function ae(n={}){const{target:t,id:o,ssr:l,props:c,count:i=!1,head:r=!1,boost:s=!1,force:f=!1}=n;return ie(this.instance,this,o!=null?o:t,c,r,i,s,f,l)}function fe(n={}){const{id:t,target:o,delay:l=0,count:c=!1}=n;l===0?T(this.instance,this,t!=null?t:o,c):setTimeout(()=>T(this.instance,this,t!=null?t:o,c),l)}const g=function(n,t,o,l){return{instance:n,$:t,props:o,children:l,els:[],render:se,mount:ae,unmount:fe}},ue=function(n,t,o,l){return Array.isArray(t)?g(n,{$:null},null,t):Array.isArray(o)?g(n,t,null,o):Array.isArray(l)?g(n,t,o,l):g(n,t,o,null)};function de(n={}){let t=null;const o={c:(...l)=>ue(o,...l),use:(l,...c)=>l.install(o,...c),find:B,context:{},config:n,get __styleSheet(){if(!t){const l=document.createElement("style");return document.head.appendChild(l),t=document.styleSheets[document.styleSheets.length-1],t}return t}};return o}const{c:$}=de(),me=$(".xicon",{width:"1em",height:"1em",display:"inline-flex"},[$("svg",{width:"1em",height:"1em"}),$("svg:not([fill])",{fill:"currentColor"})]),he=()=>{me.mount({id:"xicons-icon"})},_={size:[String,Number],color:String,tag:String},j=Symbol("IconConfigInjection");e.defineComponent({name:"IconConfigProvider",props:_,setup(n,{slots:t}){return e.provide(j,n),()=>e.renderSlot(t,"default")}});const pe="span",xe=e.defineComponent({name:"Icon",props:_,setup(n,{slots:t}){const o=e.inject(j,null),l=e.computed(()=>{var r;const s=(r=n.size)!==null&&r!==void 0?r:o==null?void 0:o.size;if(s!==void 0)return typeof s=="number"||/^\d+$/.test(s)?`${s}px`:s}),c=e.computed(()=>{const{color:r}=n;return r===void 0?o?o.color:void 0:r}),i=e.computed(()=>{var r;const{tag:s}=n;return s===void 0?(r=o==null?void 0:o.tag)!==null&&r!==void 0?r:pe:s});return e.onBeforeMount(()=>{he()}),()=>e.h(i.value,{class:"xicon",style:{color:c.value,fontSize:l.value}},[e.renderSlot(t,"default")])}}),C=x(e.defineComponent({__name:"icon",props:{color:{default:"inherit"},size:{default:16},tag:{default:"span"}},setup(n){return(t,o)=>(e.openBlock(),e.createBlock(e.unref(xe),{size:n.size,color:n.color,tag:n.tag},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},8,["size","color","tag"]))}}),"cc-icon"),ye=["maxlength"],ge=["type","placeholder","readonly","disabled","maxlength"];return x(e.defineComponent({__name:"input",props:{modelValue:null,type:{default:"text"},placeholder:{default:""},maxlength:null,minlength:null,clearable:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},showPassword:{type:Boolean,default:!1},showWordLimit:{type:Boolean,default:!1},prefixIcon:null,suffixIcon:null,rows:{default:1}},emits:["update:modelValue","input","blur","focus","clear","change"],setup(n,{expose:t,emit:o}){const l=n,c=H("input"),i=e.inject("setValidateChangeFlag",void 0),r=e.inject("setValidateBlurFlag",void 0),s=e.ref(0),f=e.ref(0),u=e.ref(),p=e.ref(l.showPassword),d=e.ref(l.modelValue),m=async()=>{var a;await e.nextTick(),(a=u.value)==null||a.focus()},h=()=>{var a;return(a=u.value)==null?void 0:a.blur()},M=a=>{l.disabled||(o("update:modelValue",a.target.value),o("input",a.target.value),s.value++,i==null||i(s.value))},R=a=>{l.disabled||(o("blur",a),f.value++,r==null||r(f.value))},q=a=>{l.disabled||(i==null||i(0),r==null||r(0),o("focus",a))},O=a=>{o("change",a.target.value)},Ce=a=>{o("update:modelValue",""),o("clear",a),m()},we=()=>{p.value=!p.value,m()};return e.watch(()=>l.modelValue,a=>{d.value=a}),t({foucs:m,blur:h}),(a,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([e.unref(c).b(),{"is-disabled":n.disabled}])},[e.createElementVNode("div",{class:e.normalizeClass([e.unref(c).e("wrapper"),`${n.disabled?e.unref(c).e("wrapper-disabled"):""}`]),style:e.normalizeStyle({padding:n.type==="textarea"?"0":"0px 12px"})},[a.$slots.prefix||n.prefixIcon?(e.openBlock(),e.createElementBlock("span",{key:0,style:{color:"#a8abb2"},class:e.normalizeClass([e.unref(c).e("wrapper-content")])},[e.createElementVNode("span",null,[n.prefixIcon?(e.openBlock(),e.createBlock(e.unref(C),{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.prefixIcon)))]),_:1})):e.renderSlot(a.$slots,"prefix",{key:1})])],2)):e.createCommentVNode("",!0),n.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,"onUpdate:modelValue":w[0]||(w[0]=z=>d.value=z),class:e.normalizeClass([e.unref(c).e("textarea")]),style:e.normalizeStyle([{height:40*Number(n.rows)+"px"},{width:"100%"}]),maxlength:n.maxlength,onInput:M,onBlur:R,onFocus:q,onChange:O},null,46,ye)),[[e.vModelText,d.value]]):e.createCommentVNode("",!0),n.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,ref_key:"inputRef",ref:u,"onUpdate:modelValue":w[1]||(w[1]=z=>d.value=z),type:`${p.value?"password":n.type}`,placeholder:n.placeholder,readonly:n.readonly,disabled:n.disabled,maxlength:Number(n.maxlength),class:e.normalizeClass([e.unref(c).e("input"),`${n.disabled?e.unref(c).e("input-disabled"):""}`]),onInput:M,onBlur:R,onFocus:q,onChange:O},null,42,ge)),[[e.vModelDynamic,d.value]]):e.createCommentVNode("",!0),a.$slots.suffix||n.suffixIcon?(e.openBlock(),e.createElementBlock("span",{key:3,style:{color:"#a8abb2"},class:e.normalizeClass([e.unref(c).e("input-wrapper")])},[e.createElementVNode("span",null,[n.suffixIcon?(e.openBlock(),e.createBlock(e.unref(C),{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.suffixIcon)))]),_:1})):e.renderSlot(a.$slots,"suffix",{key:1})])],2)):e.createCommentVNode("",!0),n.clearable&&n.modelValue.length?(e.openBlock(),e.createElementBlock("span",{key:4,style:{color:"#a8abb2"},class:e.normalizeClass([e.unref(c).e("clear")]),onClick:Ce},[e.createElementVNode("span",null,[e.createVNode(e.unref(C),null,{default:e.withCtx(()=>[e.createVNode(e.unref(W))]),_:1})])],2)):e.createCommentVNode("",!0),n.showPassword&&d.value.length?(e.openBlock(),e.createElementBlock("span",{key:5,style:{color:"#a8abb2"},class:e.normalizeClass([e.unref(c).e("password")]),onClick:we},[e.createElementVNode("span",null,[e.createVNode(e.unref(C),null,{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(G),{key:0})):(e.openBlock(),e.createBlock(e.unref(F),{key:1}))]),_:1})])],2)):e.createCommentVNode("",!0),n.maxlength&&n.showWordLimit?(e.openBlock(),e.createElementBlock("div",{key:6,class:e.normalizeClass([e.unref(c).e("limit")])},e.toDisplayString(d.value.length)+" / "+e.toDisplayString(n.maxlength),3)):e.createCommentVNode("",!0)],6)],2))}}),"cc-input")});