@@ -405,7 +405,7 @@ Make sure to test your application with a production build as repeat registratio
405405 ${this._renderRequiredOption()}
406406 </span>
407407 ${B(r==="top"&&!e.viewonly,()=>this.renderHelp())}
408- </div>`}}renderInput(){return u``}isShowError(){return this.context.validAtInit?!!this.invalidTips:this.dirty?!!this.invalidTips:false}renderError(){return this.isShowError()?u`<div class="error">${this.invalidTips}</div>`:u``}_handleSchemaChange(){let e=this.context;if(e?.store&&this.schema){let r=this.getPath().join("_$_");this._subscribers.push(e.store.schemas.store.watch(`${r}.**`,i=>{let{reply:s,type:n,value:c,flags:a}=i;if(s||e.form.seq===a)return;(n==="batch"?c:[i]).forEach(m=>{let d=m.path.slice(1);Hr(this.schema,d,m.value),this.options[d[0]]=m.value;}),this.requestUpdate();},{operates:"write"}));}}renderView(){let e=this.value;if(this.options.toView&&this.options.toView)try{e=this.options.toView.call(this,this.value);}catch(r){console.error(`Error while toView<${this.path}>: ${r.message}`);}return u`${Ot(String(e))}`}_handleStateChange(){let e=this.context;e?.store&&this.schema&&this._subscribers.push(e.store.watch(this.getPath().join("."),r=>{this.value=this.toInput(r.value);},{operates:"write"}));}getStateValue(){return this.toInput(vn(this.context.store.state,this.getPath()))}connectedCallback(){super.connectedCallback(),this.updateOptions();}updateOptions(){let e=this.context;e?.store&&this.schema&&(this.options=this.getFieldOptions(),this.value=this.getStateValue(),this._handleSchemaChange(),this._handleStateChange(),this.path=this.getPath().join("."),this.name=this.options.name||this.path,this.path in e.store.schemas.errors&&(this.invalidTips=e.store.schemas.errors[this.path]),Array.isArray(this.options.actions)&&(this.beforeActions=this.options.actions.filter(r=>r.pos==="before"),this.afterActions=this.options.actions.filter(r=>r.pos!=="before")));}getInitialOptions(){return {}}disconnectedCallback(){super.disconnectedCallback(),this._subscribers.forEach(e=>e.off());}getLabelPos(){return this.options.labelPos||this.context.labelPos}_updateFormClasss(){this.context.form&&(wo(this.context.form,"dirty",this.dirty),wo(this.context.form,"invalid",!!this.invalidTips));}_updateFieldValue(){if(!this.schema)return;let e=this.getPath(),r=this.toState(this.getInputValue()),i=this.context;i.dirty=true,this.dirty=true;try{let s=this.context.store;this.noreactive||s.update(n=>{let c=yn(r,this.schema);Hr(n,e,c),this.invalidTips=void 0;},{flags:i.form.seq}),this.dispatchEvent(new CustomEvent("field-change",{detail:{value:r,options:this.options},composed:!0,bubbles:!0}));}catch(s){this.invalidTips=s.message;}finally{this._updateFormClasss();}}renderValue(){return u`
408+ </div>`}}renderInput(){return u``}isShowError(){return this.context.validAtInit?!!this.invalidTips:this.dirty?!!this.invalidTips:false}renderError(){return this.isShowError()?u`<div class="error">${this.invalidTips}</div>`:u``}_handleSchemaChange(){let e=this.context;if(e?.store&&this.schema){let r=this.getPath().join("_$_");this._subscribers.push(e.store.schemas.store.watch(`${r}.**`,i=>{let{reply:s,type:n,value:c,flags:a}=i;if(s||e.form.seq===a)return;(n==="batch"?c:[i]).forEach(m=>{let d=m.path.slice(1);Hr(this.schema,d,m.value),this.options[d[0]]=m.value;}),this.requestUpdate();},{operates:"write"}));}}renderView(){let e=this.value;if(this.options.toView&&this.options.toView)try{e=this.options.toView.call(this,this.value);}catch(r){console.error(`Error while toView<${this.path}>: ${r.message}`);}return u`${Ot(String(e))}`}_handleStateChange(){let e=this.context;e?.store&&this.schema&&this._subscribers.push(e.store.watch(this.getPath().join("."),r=>{this.value=this.toInput(r.value);},{operates:"write"}));}getStateValue(){return this.toInput(vn(this.context.store.state,this.getPath()))}connectedCallback(){super.connectedCallback(),this.updateOptions();}updateOptions(){let e=this.context;e?.store&&this.schema&&(this.options=this.getFieldOptions(),this.value=this.getStateValue(),this._handleSchemaChange(),this._handleStateChange(),this.path=this.getPath().join("."),this.name=this.options.name||this.path,this.path in e.store.schemas.errors&&(this.invalidTips=e.store.schemas.errors[this.path]),Array.isArray(this.options.actions)&&(this.beforeActions=this.options.actions.filter(r=>r.pos==="before"),this.afterActions=this.options.actions.filter(r=>r.pos!=="before")));}getInitialOptions(){return {}}disconnectedCallback(){super.disconnectedCallback(),this._subscribers.forEach(e=>{e.off();});}getLabelPos(){return this.options.labelPos||this.context.labelPos}_updateFormClasss(){this.context.form&&(wo(this.context.form,"dirty",this.dirty),wo(this.context.form,"invalid",!!this.invalidTips));}_updateFieldValue(){if(!this.schema)return;let e=this.getPath(),r=this.toState(this.getInputValue()),i=this.context;i.dirty=true,this.dirty=true;try{let s=this.context.store;this.noreactive||s.update(n=>{let c=yn(r,this.schema);Hr(n,e,c),this.invalidTips=void 0;},{flags:i.form.seq}),this.dispatchEvent(new CustomEvent("field-change",{detail:{value:r,options:this.options},composed:!0,bubbles:!0}));}catch(s){this.invalidTips=s.message;}finally{this._updateFormClasss();}}renderValue(){return u`
409409 ${this.renderInput()} ${B(this.context.viewonly,()=>this.renderHelp())}
410410 ${this.renderError()}
411411 `}getPath(){return this.options.path&&this.options.path.length===0?this.parent?.getPath():this.options.path}updated(){this.options.styles&&Nn(this.shadow,this.options.styles);}render(){let e=this.context,r=this.options.labelPos?this.options.labelPos:e.labelPos;return this.classs.use(e.size,{[`${e.border}-border`]:true,error:this.isShowError(),"left-label":r==="left"||e.viewonly,"top-label":r==="top"&&!e.viewonly,disable:this.options.enable===false,readonly:e.readonly,viewonly:e.viewonly,compact:this.compact===void 0?e.compact:this.compact,required:this.options.required===true,hidden:!this.options.visible,[`view-${e.viewAlign}`]:true,[`${e.layout}-layout`]:true}),u`
@@ -3417,7 +3417,7 @@ Make sure to test your application with a production build as repeat registratio
34173417 }
34183418`;var xs="__AS_ASYNC_COMPUTED_VALUE__";function _i(t){return toString.call(t)==="[object Map]"}function Ie(t){return t&&typeof t=="object"&&t.hasOwnProperty(xs)}function Ss(t,o){let e=t.get(o);if(e!==void 0)return e;let r=t.get(Number(o)||o);if(r!==void 0)return r}function ye(t,o,e){if(!o||o.length===0)return t;let r=Array.isArray(o)?o:o.split("."),i,s=t;for(let n=0;n<r.length;n++){let c=r[n];if(_i(s))i=Ss(s,c);else if(c in s)i=s[c];else return e;s=i;}return i}function ks(t,o){return t.length>o.length?false:t.every((e,r)=>e===o[r])}(t=>typeof Be<"u"?Be:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof Be<"u"?Be:o)[e]}):t)(function(t){if(typeof Be<"u")return Be.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var ze=class{constructor(o,e,r){this.path=e;this.handle=r;this._loading=false;this._ready=false;this.host=o,o.addController(this);}get loading(){return this._loading}get value(){return this._value}load(){let o=this.host.schema,e=ye(o,this.path);Ie(e)?e.loading?(this._loading=true,this._value=this.handle(void 0)):(this._ready=e.value!==void 0,this._value=this.handle(e.value),this._loading=false):(this._ready=true,this._value=this.handle(e),this._loading=false);}render(o){return u`
34193419 ${B(this.loading,()=>u`<auto-loading></auto-loading>`,()=>o(this._value))}
3420- `}hostUpdate(){this._ready||this.load();}hostUpdated(){}};exports.AutoFieldSelect=class fr extends R{constructor(){super(...arguments);this.valueKey="value";this.labelKey="label";this.items=new ze(this,"select",e=>e? e.map(r=>{let i={};return typeof r=="object"?Object.assign(i,r):typeof r=="string"&&r.startsWith("-")?Object.assign(i,{type:"divider"}):Object.assign(i,{label:r}),i}):[] );}getInitialOptions(){return {valueKey:"value",labelKey:"label",select:[],multiple:false,clearable:true,maxOptionsVisible:0,placement:"top"}}_renderItem(e){let r=this.options.renderItem;return typeof r=="string"?u`${Ot(r.replace(/\{(.+?)\}/g,(i,s)=>e[s]))}`:typeof r=="function"?u`${Ot(r(e))}`:e.label||e.value}_onDropdownMenu(){}renderInput(){return u`
3420+ `}hostUpdate(){this._ready||this.load();}hostUpdated(){}};exports.AutoFieldSelect=class fr extends R{constructor(){super(...arguments);this.valueKey="value";this.labelKey="label";this.items=new ze(this,"select",e=>!e||!Array.isArray(e)?[]: e.map(r=>{let i={};return typeof r=="object"?Object.assign(i,r):typeof r=="string"&&r.startsWith("-")?Object.assign(i,{type:"divider"}):Object.assign(i,{label:r}),i}));}getInitialOptions(){return {valueKey:"value",labelKey:"label",select:[],multiple:false,clearable:true,maxOptionsVisible:0,placement:"top"}}_renderItem(e){let r=this.options.renderItem;return typeof r=="string"?u`${Ot(r.replace(/\{(.+?)\}/g,(i,s)=>e[s]))}`:typeof r=="function"?u`${Ot(r(e))}`:e.label||e.value}_onDropdownMenu(){}renderInput(){return u`
34213421 <sl-select
34223422 name="${this.name}"
34233423 data-path="${this.path}"
0 commit comments