it-tools/dist/client/assets/chunks/chunk-4515d3e7.js

106 lines
30 KiB
JavaScript
Raw Normal View History

2024-04-28 00:48:29 +08:00
import{i as ie,a0 as Ce,A as $e,a1 as Ne,c as k,r as X,d as We,C as fe,p as De,b as Be,h as S,f as He}from"./chunk-449c23a2.js";import{f as Ue}from"./chunk-2749dac9.js";import{c as Ee,w as xe}from"./chunk-a740628f.js";import{U as ge,ag as je,n as ee,c as Ye,o as N,p as de,q as T,u as Ke,y as qe,v as Me,w as D,x as Je,af as Ze}from"../entries/src_pages_Home.page.16dc467b.js";import{f as Ge}from"./chunk-6d336811.js";function Qe(n,e,t){var r;const i=ie(n,null);if(i===null)return;const s=(r=Ce())===null||r===void 0?void 0:r.proxy;$e(t,a),a(t.value),Ne(()=>{a(void 0,t.value)});function a(u,d){const m=i[e];d!==void 0&&o(m,d),u!==void 0&&f(m,u)}function o(u,d){u[d]||(u[d]=[]),u[d].splice(u[d].findIndex(m=>m===s),1)}function f(u,d){u[d]||(u[d]=[]),~u[d].findIndex(m=>m===s)||u[d].push(s)}}const ce=Ee("n-form"),Xe=Ee("n-form-item-insts");function U(){return U=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},U.apply(this,arguments)}function et(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,ne(n,e)}function pe(n){return pe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},pe(n)}function ne(n,e){return ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},ne(n,e)}function tt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ue(n,e,t){return tt()?ue=Reflect.construct.bind():ue=function(i,s,a){var o=[null];o.push.apply(o,s);var f=Function.bind.apply(i,o),u=new f;return a&&ne(u,a.prototype),u},ue.apply(null,arguments)}function rt(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function ve(n){var e=typeof Map=="function"?new Map:void 0;return ve=function(r){if(r===null||!rt(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return ue(r,arguments,pe(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),ne(i,r)},ve(n)}var nt=/%[sdj%]/g,it=function(){};typeof process<"u"&&process.env;function be(n){if(!n||!n.length)return null;var e={};return n.forEach(function(t){var r=t.field;e[r]=e[r]||[],e[r].push(t)}),e}function j(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];var i=0,s=t.length;if(typeof n=="function")return n.apply(null,t);if(typeof n=="string"){var a=n.replace(nt,function(o){if(o==="%%")return"%";if(i>=s)return o;switch(o){case"%s":return String(t[i++]);case"%d":return Number(t[i++]);case"%j":try{return JSON.stringify(t[i++])}catch{return"[Circular]"}break;default:return o}});return a}return n}function at(n){return n==="string"||n==="url"||n==="hex"||n==="email"||n==="date"||n==="pattern"}function R(n,e){return!!(n==null||e==="array"&&Array.isArray(n)&&!n.length||at(e)&&typeof n=="string"&&!n)}function st(n,e,t){var r=[],i=0,s=n.length;function a(o){r.push.apply(r,o||[]),i++,i===s&&t(r)}n.forEach(function(o){e(o,a)})}function Re(n,e,t){var r=0,i=n.length;function s(a){if(a&&a.length){t(a);return}var o=r;r=r+1,o<i?e(n[o],s):t([])}s([])}function ot(n){var e=[];return Object.keys(n).forEach(function(t){e.push.apply(e,n[t]||[])}),e}var ke=function(n){et(e,n);function e(t,r){var i;return i=n.call(this,"Async Validation Error")||this,i.errors=t,i.fields=r,i}return e}(ve(Error));function ft(n,e,t,r,i){if(e.first){var s=new Promise(function(b,c){var q=function(l){return r(l),l.length?c(new ke(l,be(l))):b(i)},g=ot(n);Re(g,t,q)});return s.catch(function(b){return b}),s}var a=e.firstFields===!0?Object.keys(n):e.firstFields||[],o=Object.keys(n),f=o.length,u=0,d=[],m=new Promise(function(b,c){var q=function(w){if(d.push.apply(d,w),u++,u===f)return r(d),d.length?c(ne
(?:
(?:`+r+":){7}(?:"+r+`|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:`+r+":){6}(?:"+t+"|:"+r+`|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
(?:`+r+":){5}(?::"+t+"|(?::"+r+`){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
(?:`+r+":){4}(?:(?::"+r+"){0,1}:"+t+"|(?::"+r+`){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
(?:`+r+":){3}(?:(?::"+r+"){0,2}:"+t+"|(?::"+r+`){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
(?:`+r+":){2}(?:(?::"+r+"){0,3}:"+t+"|(?::"+r+`){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:`+r+":){1}(?:(?::"+r+"){0,4}:"+t+"|(?::"+r+`){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::`+r+"){0,5}:"+t+"|(?::"+r+`){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
`).replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),s=new RegExp("(?:^"+t+"$)|(?:^"+i+"$)"),a=new RegExp("^"+t+"$"),o=new RegExp("^"+i+"$"),f=function(y){return y&&y.exact?s:new RegExp("(?:"+e(y)+t+e(y)+")|(?:"+e(y)+i+e(y)+")","g")};f.v4=function(p){return p&&p.exact?a:new RegExp(""+e(p)+t+e(p),"g")},f.v6=function(p){return p&&p.exact?o:new RegExp(""+e(p)+i+e(p),"g")};var u="(?:(?:[a-z]+:)?//)",d="(?:\\S+(?::\\S*)?@)?",m=f.v4().source,b=f.v6().source,c="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",q="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",g="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",w="(?::\\d{2,5})?",l='(?:[/?#][^\\s"]*)?',M="(?:"+u+"|www\\.)"+d+"(?:localhost|"+m+"|"+b+"|"+c+q+g+")"+w+l;return le=new RegExp("(?:^"+M+"$)","i"),le},Pe={email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},te={integer:function(e){return te.number(e)&&parseInt(e,10)===e},float:function(e){return te.number(e)&&!te.integer(e)},array:function(e){return Array.isArray(e)},regexp:function(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch{return!1}},date:function(e){return typeof e.getTime=="function"&&typeof e.getMonth=="function"&&typeof e.getYear=="function"&&!isNaN(e.getTime())},number:function(e){return isNaN(e)?!1:typeof e=="number"},object:function(e){return typeof e=="object"&&!te.array(e)},method:function(e){return typeof e=="function"},email:function(e){return typeof e=="string"&&e.length<=320&&!!e.match(Pe.email)},url:function(e){return typeof e=="string"&&e.length<=2048&&!!e.match(ct())},hex:function(e){return typeof e=="string"&&!!e.match(Pe.hex)}},mt=function(e,t,r,i,s){if(e.required&&t===void 0){ze(e,t,r,i,s);return}var a=["integer","float","array","regexp","object","method","email","number","date","url","hex"],o=e.type;a.indexOf(o)>-1?te[o](t)||i.push(j(s.messages.types[o],e.fullField,e.type)):o&&typeof t!==e.type&&i.push(j(s.messages.types[o],e.fullField,e.type))},gt=function(e,t,r,i,s){var a=typeof e.len=="number",o=typeof e.min=="number",f=typeof e.max=="number",u=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,d=t,m=null,b=typeof t=="number",c=typeof t=="string",q=Array.isArray(t);if(b?m="number":c?m="string":q&&(m="array"),!m)return!1;q&&(d=t.length),c&&(d=t.replace(u,"_").length),a?d!==e.len&&i.push(j(s.messages[m].len,e.fullField,e.len)):o&&!f&&d<e.min?i.push(j(s.messages[m].min,e.fullField,e.min)):f&&!o&&d>e.max?i.push(j(s.messages[m].max,e.fullField,e.max)):o&&f&&(d<e.min||d>e.max)&&i.push(j(s.messages[m].range,e.fullField,e.min,e.max))},G="enum",ht=function(e,t,r,i,s){e[G]=Array.isArray(e[G])?e[G]:[],e[G].indexOf(t)===-1&&i.push(j(s.messages[G],e.fullField,e[G].join(", ")))},pt=function(e,t,r,i,s){if(e.pattern){if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(t)||i.push(j(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if(typeof e.pattern=="string"){var a=new RegExp(e.pattern);a.test(t)||i.push(j(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}},v={required:ze,whitespace:ut,type:mt,range:gt,enum:ht,pattern:pt},vt=function(e,t,r,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(R(t,"string")&&!e.required)return r();v.required(e,t,i,a,s,"string"),R(t,"string")||(v.type(e,t,i,a,s),v.range(e,t,i,a,s),v.pattern(e,t,i,a,s),e.whitespace===!0&&v.whitespace(e,t,i,a,s))}r(a)},bt=function(e,t,r,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(R(t)&&!e.required)return r();v.required(e,t,i,a,s),t!==void 0&&v.type(e,t,i,a,s)}r(a)},yt=function(e,t,r,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(t===""&&(t=void 0),R(t)&&!e.required)return r();v.required(e,t,i,a,s),t!==void 0&&(v.type(e,t,i,a,s),v.range(e,t,i,a,s))}r(a)},wt=function(e,t,r,i,s){var a=[],o=e.required||!e.required&&i.hasOwnProperty(e.field);if(o){if(R(t)&&!e.required)return r();v.required(e,t,i,a
display: grid;
line-height: var(--n-line-height);
`,[N("form-item-label",`
grid-area: label;
align-items: center;
line-height: 1.25;
text-align: var(--n-label-text-align);
font-size: var(--n-label-font-size);
min-height: var(--n-label-height);
padding: var(--n-label-padding);
color: var(--n-label-text-color);
transition: color .3s var(--n-bezier);
box-sizing: border-box;
font-weight: var(--n-label-font-weight);
`,[de("asterisk",`
white-space: nowrap;
user-select: none;
-webkit-user-select: none;
color: var(--n-asterisk-color);
transition: color .3s var(--n-bezier);
`),de("asterisk-placeholder",`
grid-area: mark;
user-select: none;
-webkit-user-select: none;
visibility: hidden;
`)]),N("form-item-blank",`
grid-area: blank;
min-height: var(--n-blank-height);
`),T("auto-label-width",[N("form-item-label","white-space: nowrap;")]),T("left-labelled",`
grid-template-areas:
"label blank"
"label feedback";
grid-template-columns: auto minmax(0, 1fr);
grid-template-rows: auto 1fr;
align-items: start;
`,[N("form-item-label",`
display: grid;
grid-template-columns: 1fr auto;
min-height: var(--n-blank-height);
height: auto;
box-sizing: border-box;
flex-shrink: 0;
flex-grow: 0;
`,[T("reverse-columns-space",`
grid-template-columns: auto 1fr;
`),T("left-mark",`
grid-template-areas:
"mark text"
". text";
`),T("right-mark",`
grid-template-areas:
"text mark"
"text .";
`),T("right-hanging-mark",`
grid-template-areas:
"text mark"
"text .";
`),de("text",`
grid-area: text;
`),de("asterisk",`
grid-area: mark;
align-self: end;
`)])]),T("top-labelled",`
grid-template-areas:
"label"
"blank"
"feedback";
grid-template-rows: minmax(var(--n-label-height), auto) 1fr;
grid-template-columns: minmax(0, 100%);
`,[T("no-label",`
grid-template-areas:
"blank"
"feedback";
grid-template-rows: 1fr;
`),N("form-item-label",`
display: flex;
align-items: flex-start;
justify-content: var(--n-label-text-align);
`)]),N("form-item-blank",`
box-sizing: border-box;
display: flex;
align-items: center;
position: relative;
`),N("form-item-feedback-wrapper",`
grid-area: feedback;
box-sizing: border-box;
min-height: var(--n-feedback-height);
font-size: var(--n-feedback-font-size);
line-height: 1.25;
transform-origin: top left;
`,[ee("&:not(:empty)",`
padding: var(--n-feedback-padding);
`),N("form-item-feedback",{transition:"color .3s var(--n-bezier)",color:"var(--n-feedback-text-color)"},[T("warning",{color:"var(--n-feedback-text-color-warning)"}),T("error",{color:"var(--n-feedback-text-color-error)"}),zt({fromOffset:"-3px",enterDuration:".3s",leaveDuration:".2s"})])])]);var Ae=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(d){try{u(r.next(d))}catch(m){a(m)}}function f(d){try{u(r.throw(d))}catch(m){a(m)}}function u(d){d.done?s(d.value):i(d.value).then(o,f)}u((r=r.apply(n,e||[])).next())})};const Lt=Object.assign(Object.assign({},Me.props),{label:String,labelWidth:[Number,String],labelStyle:[String,Object],labelAlign:String,labelPlacement:String,path:String,first:Boolean,rulePath:String,required:Boolean,showRequireMark:{type:Boolean,default:void 0},requireMarkPlacement:String,showFeedback:{type:Boolean,default:void 0},rule:[Object,Array],size:String,ignorePathChange:Boolean,validationStatus:String,feedback:String,showLabel:{type:Boolean,default:void 0},labelProps:Object});function Se(n,e){return(...t)=>{try{const r=n(...t);return!e&&(typeof r=="boolean"||r instanceof Error||Array.isArray(r))||r?.then?r:(r===void 0||xe("form-item/validate",`You return a ${typeof r} typed value in the validator method, which is not recommended. Please use `+(e?"`Promise`":"`boolean`, `Error` or `Promise`")+" typed value instead."),!0)}catch(r){xe("form-item/validate","An error is catched in the validation, so the validation won't be done. Your callback in `validate` method of `n-form` or `n-form-item` won't be called in this validation."),console.error(r);return}}}const Bt=We({name:"FormItem",props:Lt,setup(n){Qe(Xe,"formItems",fe(n,"path"));const{mergedClsPrefixRef:e,inlineThemeDisabled:t}=Ke(n),r=ie(ce,null),i=Et(n),s=jt(n),{validationErrored:a}=s,{mergedRequired:o,mergedRules:f}=Mt(n),{mergedSize:u}=i,{mergedLabelPlacement:d,mergedLabelAlign:m,mergedRequireMarkPlacement:b}=s,c=X([]),q=X(qe()),g=r?fe(r.props,"disabled"):X(!1),w=Me("Form","-form-item",Vt,Ge,n,e);$e(fe(n,"path"),()=>{n.ignorePathChange||l()});function l(){c.value=[],a.value=!1,n.feedback&&(q.value=qe())}function M(){P("blur")}function p(){P("change")}function y(){P("focus")}function _(){P("input")}function F(h,$){return Ae(this,void 0,void 0,function*(){let E,O,B,Y;typeof h=="string"?(E=h,O=$):h!==null&&typeof h=="object"&&(E=h.trigger,O=h.callback,B=h.shouldRuleBeApplied,Y=h.options),yield new Promise((K,J)=>{P(E,B,Y).then(({valid:Z,errors:H})=>{Z?(O&&O(),K()):(O&&O(H),J(H))})})})}const P=(h=null,$=()=>!0,E={suppressWarning:!0})=>Ae(this,void 0,void 0,function*(){const{path:O}=n;E?E.first||(E.first=n.first):E={};const{value:B}=f,Y=r?je(r.props.model,O||""):void 0,K={},J={},Z=(h?B.filter(L=>Array.isArray(L.trigger)?L.trigger.includes(h):L.trigger===h):B).filter($).map((L,I)=>{const x=Object.assign({},L);if(x.validator&&(x.validator=Se(x.validator,!1)),x.asyncValidator&&(x.asyncValidator=Se(x.asyncValidator,!0)),x.renderMessage){const A=`__renderMessage__${I}`;J[A]=x.message,x.message=A,K[A]=x.renderMessage}return x});if(!Z.length)return{valid:!0};const H=O??"__n_no_path__",se=new ae({[H]:Z}),{validateMessages:oe}=r?.props||{};return oe&&se.messages(oe),yield new Promise(L=>{se.validate({[H]:Y},E,I=>{I?.length?(c.value=I.map(x=>{const A=x?.message||"";return{key:A,render:()=>A.startsWith("__renderMessage__")?K[A]():A}}),I.forEach(x=>{var A;!((A=x.message)===null||A===void 0)&&A.startsWith("__renderMessage__")&&(x.message=J[x.message])}),a.value=!0,L({valid:!1,errors:I})):(l(),L({valid:!0}))})})});De(Ue,{path:fe(n,"path"),disabled:g,mergedSize:i.mergedSize,mergedValidationStatus:s.mergedValidationStatus,restoreValidation:l,handleContentBlur:M,handleContentChange:p,handleContentFocus:y,handleContentInput:_});const z={validate:F,restoreValidation:l,internalValidate:P},W=X(null);Be(()=>{if(!s.isAutoLabelWidth.value)return;const h=W.value;if(h!==null){const $=h.style.whiteSpace;h.style.whiteSpace="nowrap",h.style.width="",r?.deriveMaxChildLa