lituix 0.1.2 → 0.1.3

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/dist/index.cjs CHANGED
@@ -11401,7 +11401,7 @@
11401
11401
  --lui-form-item-control-height: var(--lui-control-height-lg, 44px);
11402
11402
  --lui-form-item-gap: 6px;
11403
11403
  }
11404
- `],a([(0,Jr.property)()],ar.prototype,"label",2),a([(0,Jr.property)({type:Boolean})],ar.prototype,"required",2),a([(0,Jr.property)()],ar.prototype,"description",2),a([(0,Jr.property)()],ar.prototype,"help",2),a([(0,Jr.property)()],ar.prototype,"extra",2),a([(0,Jr.property)()],ar.prototype,"tooltip",2),a([(0,Jr.property)({attribute:!1})],ar.prototype,"errors",2),a([(0,Jr.property)({type:Boolean,reflect:!0})],ar.prototype,"invalid",2),a([(0,Jr.property)({type:Boolean,attribute:"hidden-label"})],ar.prototype,"hiddenLabel",2),a([(0,Jr.property)({type:Boolean,reflect:!0})],ar.prototype,"inline",2),a([(0,Jr.property)({reflect:!0})],ar.prototype,"size",2),a([(0,Jr.property)({reflect:!0,attribute:"label-placement"})],ar.prototype,"labelPlacement",2),a([(0,Jr.property)({attribute:"label-width"})],ar.prototype,"labelWidth",2),ar=a([(0,Jr.customElement)("lui-form-item")],ar);function md(i,o){if(!i||!o)return;let e=i;for(let[t,r]of Object.entries(o))r!=null&&(t==="style"&&typeof r=="string"?i.setAttribute("style",r):typeof r=="boolean"?r?i.setAttribute(t,""):i.removeAttribute(t):e[t]=r)}var hs=new Map;function Bp(i,o){return hs.set(i,o),()=>{hs.get(i)===o&&hs.delete(i)}}function qp(i){hs.delete(i)}function gd(i){let o={};for(let e of i)e.type==="group"&&e.fields?Object.assign(o,gd(e.fields)):e.type==="array"?o[e.name]=e.defaultValue!==void 0?e.defaultValue:[]:o[e.name]=e.defaultValue!==void 0?e.defaultValue:e.type==="switch"||e.type==="checkbox"?!1:e.type==="checkbox-group"?[]:e.type==="number"||e.type==="slider"?0:(e.type==="date"||e.type==="time"||e.type==="datetime","");return o}function vl(i,o){return o.split(/[.[\]]/).filter(Boolean).reduce((e,t)=>e?.[t],i)}function Sg(i,o){if(!i)return{visible:!0,disabled:!1,required:!1};let e=Array.isArray(i.when)?i.when:[i.when],t=!1;for(let n of e){let s=vl(o,n);if(i.is!==void 0?t=s===i.is:i.isNot!==void 0?t=s!==i.isNot:i.contains!==void 0?t=Array.isArray(s)&&s.includes(i.contains):i.pattern!==void 0?t=new RegExp(i.pattern).test(String(s??"")):t=!!s,t)break}let r=t?i.then??{visible:!0}:i.else??{visible:!1};return{visible:r.visible??!0,disabled:r.disabled??!1,required:r.required??!1}}function $g(i){let e={...i.validators??{}};i.validator&&(e.onSubmit=e.onSubmit??i.validator);let t=r=>{if(r!=null)return(0,xa.isStandardSchemaValidator)(r)?n=>xa.standardSchemaValidators.validate({value:n.value,validationSource:"field"},r)??void 0:r};return e.onChange=t(e.onChange),e.onSubmit=t(e.onSubmit),Object.keys(e).length?e:void 0}function Dn(i,o={}){if(i==null)return[];if(typeof i=="string")return i?[i]:[];if(typeof i=="number"||typeof i=="boolean")return[String(i)];if(i instanceof Error)return i.message?[i.message]:[String(i)];if(Array.isArray(i))return Array.from(new Set(i.flatMap(e=>Dn(e,o))));if(typeof i=="object"){let e=i,t=[];return typeof e.message=="string"&&e.message&&t.push(e.message),"form"in e&&t.push(...Dn(e.form,o)),o.includeFieldErrors&&"fields"in e&&t.push(...Dn(e.fields,o)),Array.from(new Set(t))}return[]}function ya(i){return i==null||i===!1?!1:typeof i=="string"?i.length>0:typeof i=="number"||typeof i=="boolean"||i instanceof Error?!0:Array.isArray(i)?i.some(ya):typeof i=="object"?Object.values(i).some(ya):!1}function Tg(i,o){let e=i.successMessage;return typeof e=="function"?e(o):e??"\u63D0\u4EA4\u6210\u529F"}var ge,Lt=class extends D.LitElement{constructor(){super(...arguments);this.schema=null;this.showActions=!0;this.size="md";this.labelPlacement="top";this.labelWidth="120px";this._currentStep=0;this._isStepPending=!1;this._submitErrorMessages=[];this._submitSuccessMessage="";Hu(this,ge);this._explicitAttrs=new Set;this._collapsedArrayItems=new Set;this._initializedSchema=null}connectedCallback(){super.connectedCallback(),this._explicitAttrs=new Set(this.getAttributeNames()),this._ensureControllerInitialized()}submit(){this._ensureControllerInitialized(),this._submitForm()}_dispatchValidate(e){ye(this,ge)&&this.dispatchEvent(new CustomEvent("validate",{detail:{valid:e,errors:ye(this,ge).api.getAllErrors(),values:this.getValues()},bubbles:!0,composed:!0}))}getValues(){return this._ensureControllerInitialized(),{...ye(this,ge)?.api.state.values??{}}}setValues(e,t={}){if(this._ensureControllerInitialized(),!!ye(this,ge)){for(let[r,n]of Object.entries(e))ye(this,ge).api.setFieldValue(r,n,{dontUpdateMeta:!t.touch});this._emitFormChange("setValues",void 0,void 0,this.getValues())}}getValue(e){return vl(this.getValues(),e)}setValue(e,t,r={}){this._ensureControllerInitialized(),ye(this,ge)&&(ye(this,ge).api.setFieldValue(e,t,{dontUpdateMeta:!r.touch}),this._emitFormChange("setValue",e,t,this.getValues()))}async validate(){if(this._ensureControllerInitialized(),!ye(this,ge)||!this.schema)return!0;this._clearSubmissionFeedback();let e=this.schema.steps?this.schema.steps.flatMap(d=>d.fields):this.schema.fields??[],t=Array.from(new Set(this._collectVisibleFieldNames(e)));this._markFieldsTouched(t);let r=await Promise.all(t.map(d=>ye(this,ge).api.validateField(d,"submit"))),n=await ye(this,ge).api.validate("submit"),s=!r.some(ya)&&!this._hasFieldErrors(t)&&!ya(n)&&this._getFormErrorMessages(ye(this,ge)).length===0;return this._dispatchValidate(s),this.requestUpdate(),s}clearValidate(e){if(this._ensureControllerInitialized(),!ye(this,ge)||!this.schema)return;this._clearSubmissionFeedback();let t=this.schema.steps?this.schema.steps.flatMap(n=>n.fields):this.schema.fields??[],r=e?.length?e:Array.from(new Set(this._collectVisibleFieldNames(t)));for(let n of r)ye(this,ge).api.setFieldMeta(n,s=>({...s,isValidating:!1,isTouched:!1,isBlurred:!1,isValid:!0,errors:[],errorMap:{},errorSourceMap:{}}));this.requestUpdate()}_clearSubmissionFeedback(){(this._submitErrorMessages.length||this._submitSuccessMessage)&&(this._submitErrorMessages=[],this._submitSuccessMessage="")}async _submitForm(){if(!ye(this,ge)||!this.schema)return;if(this._clearSubmissionFeedback(),!await this.validate()){this._scrollToFirstError(),this.requestUpdate();return}await ye(this,ge).api.handleSubmit(),this.requestUpdate()}reset(e){this._ensureControllerInitialized(),this._clearSubmissionFeedback(),ye(this,ge)?.api.reset(e),this._collapsedArrayItems.clear(),this._emitFormChange("reset",void 0,void 0,ye(this,ge)?.api.state.values??{})}_emitFormChange(e,t,r,n=this.getValues()){this.dispatchEvent(new CustomEvent("change",{detail:{reason:e,name:t,value:r,values:n},bubbles:!0,composed:!0}))}_emitFieldChange(e,t,r){let n=this.getValues();this._emitFormChange("field",e.name,t,n)}focusField(e){let r=this._fieldElement(e)?.querySelector("lui-input,lui-textarea,lui-select,lui-input-number,lui-datepicker,lui-color-picker,lui-input-opt,lui-checkbox,lui-switch,lui-radio,button,input,textarea,select");return r?.focus?.(),!!r}scrollToField(e,t={block:"center",behavior:"smooth"}){let r=this._fieldElement(e);return r?.scrollIntoView(t),!!r}_fieldElement(e){return this.renderRoot.querySelector(`[data-field-name="${CSS.escape(e)}"]`)}_findFieldDef(e){let t=e.replace(/\[\d+\]/g,""),r=this.schema?.steps?this.schema.steps.flatMap(s=>s.fields):this.schema?.fields??[],n=s=>{for(let d of s){if(d.name===e||d.name===t||t.endsWith(`.${d.name}`))return d;if(d.fields){let h=n(d.fields);if(h)return h}}};return n(r)}_firstErrorFieldName(){if(!ye(this,ge)||!this.schema)return;let e=this.schema.steps?this.schema.steps.flatMap(r=>r.fields):this.schema.fields??[];return Array.from(new Set(this._collectVisibleFieldNames(e))).find(r=>(ye(this,ge).api.getFieldMeta(r)?.errors?.length??0)>0)}_scrollToFirstError(){let e=this._firstErrorFieldName();e&&requestAnimationFrame(()=>{this.scrollToField(e),this.focusField(e)})}_effectiveSize(e){return e?.size??this.schema?.size??this.size}_effectiveLabelPlacement(e){return e?.labelPlacement??this.schema?.labelPlacement??this.labelPlacement}_normalizedLabelPlacement(e){let t=this._effectiveLabelPlacement(e);return t==="left"||t==="horizontal"?"left":"top"}_effectiveLabelWidth(e){return Ot(e?.labelWidth??this.schema?.labelWidth??this.labelWidth)||"120px"}_effectiveValidateTrigger(e){return e?.validateTrigger??this.schema?.validateTrigger??"change"}_fieldClass(e){return`field ${this._normalizedLabelPlacement(e)}`}_fieldStyle(e){return`--lui-form-label-width:${this._effectiveLabelWidth(e)}`}willUpdate(){this._ensureControllerInitialized();let e=N(this,"form");!this._explicitAttrs.has("size")&&typeof e.size=="string"&&this.size!==e.size&&(this.size=e.size),!this._explicitAttrs.has("label-placement")&&typeof e.labelPlacement=="string"&&this.labelPlacement!==e.labelPlacement&&(this.labelPlacement=e.labelPlacement),!this._explicitAttrs.has("label-width")&&(typeof e.labelWidth=="string"||typeof e.labelWidth=="number")&&this.labelWidth!==e.labelWidth&&(this.labelWidth=e.labelWidth),!this._explicitAttrs.has("show-actions")&&typeof e.showActions=="boolean"&&this.showActions!==e.showActions&&(this.showActions=e.showActions)}updated(e){super.updated(e),e.has("schema")&&this.schema&&(this._currentStep=0,this._clearSubmissionFeedback(),this._initializedSchema!==this.schema&&(this._initForm(),this.requestUpdate()))}_initForm(){if(!this.schema)return;let e=this.schema.steps?this.schema.steps.flatMap(n=>n.fields):this.schema.fields??[],t={...gd(e),...this.schema.defaultValues},r={...this.schema.validators??{}};this.schema.validator&&(r.onSubmit=r.onSubmit??this.schema.validator),Ru(this,ge,new xa.TanStackFormController(this,{defaultValues:t,validators:r,validationLogic:this.schema.validationLogic,onSubmit:async({value:n})=>{this._clearSubmissionFeedback(),this.dispatchEvent(new CustomEvent("submit",{detail:{value:n},bubbles:!0,composed:!0}));try{typeof this.schema.onSubmit=="function"&&await this.schema.onSubmit(n),this._submitSuccessMessage=Tg(this.schema,n)}catch(s){let d=Dn(s);throw this._submitErrorMessages=d.length?d:["\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"],this._submitSuccessMessage="",s}},onSubmitInvalid:()=>{this._submitSuccessMessage="",this._dispatchValidate(!1),this._scrollToFirstError()}})),this._initializedSchema=this.schema}_ensureControllerInitialized(){ye(this,ge)&&this._initializedSchema===this.schema||this.schema&&this._initForm()}_isGroupInline(e){return e.length>1&&e.every(t=>t.type!=="textarea"&&t.type!=="array"&&t.type!=="slider"&&t.type!=="date"&&t.type!=="time"&&t.type!=="datetime"&&t.type!=="file")}_getFieldCondition(e){let t=ye(this,ge)?.api?.state?.values??{},r=Sg(e.condition,t);return{visible:!e.hidden&&r.visible,disabled:(this.schema?.disabled??!1)||(e.disabled??!1)||r.disabled,readonly:(this.schema?.readonly??!1)||(e.readonly??!1),required:(e.required??!1)||r.required}}_renderField(e,t,r=!1,n=!1){if(e.type==="group"&&e.fields)return this._renderGroup(e,t,r,n);if(e.type==="array")return this._renderArrayField(e,t,r,n);if(e.type==="button")return this._renderButtonField(e,r);let s=this._getFieldCondition(e);if(!s.visible)return D.nothing;let d={name:e.name},h={...e,required:s.required},p=$g(h);return p&&(d.validators=p),t.field(d,f=>{let x=Dn(f.state.meta.errors||[],{includeFieldErrors:!0}),y=f.state.meta.isTouched||ye(this,ge).api.state.submissionAttempts>0,C=y&&x.length>0,S=ke=>{let Ve=f.state.value;this._clearSubmissionFeedback(),f.handleChange(ke),this._effectiveValidateTrigger(h)==="change"&&f.validate?.("change"),this._emitFieldChange(h,ke,Ve)},E={field:h,value:f.state.value,errors:x,disabled:s.disabled||r,readonly:s.readonly||n,required:!!h.required,touched:y,invalid:x.length>0,formValues:ye(this,ge).api.state.values,fieldApi:f,blur:()=>f.handleBlur(),clearFeedback:()=>this._clearSubmissionFeedback(),handleChange:S,submit:()=>void this._submitForm(),reset:()=>this.reset()},T=this._withProps(h,this._renderControl(h,f,s.disabled||r,s.readonly||n,E)),O=h.hiddenLabel?"":h.label??"",H=D.html`
11404
+ `],a([(0,Jr.property)()],ar.prototype,"label",2),a([(0,Jr.property)({type:Boolean})],ar.prototype,"required",2),a([(0,Jr.property)()],ar.prototype,"description",2),a([(0,Jr.property)()],ar.prototype,"help",2),a([(0,Jr.property)()],ar.prototype,"extra",2),a([(0,Jr.property)()],ar.prototype,"tooltip",2),a([(0,Jr.property)({attribute:!1})],ar.prototype,"errors",2),a([(0,Jr.property)({type:Boolean,reflect:!0})],ar.prototype,"invalid",2),a([(0,Jr.property)({type:Boolean,attribute:"hidden-label"})],ar.prototype,"hiddenLabel",2),a([(0,Jr.property)({type:Boolean,reflect:!0})],ar.prototype,"inline",2),a([(0,Jr.property)({reflect:!0})],ar.prototype,"size",2),a([(0,Jr.property)({reflect:!0,attribute:"label-placement"})],ar.prototype,"labelPlacement",2),a([(0,Jr.property)({attribute:"label-width"})],ar.prototype,"labelWidth",2),ar=a([(0,Jr.customElement)("lui-form-item")],ar);function md(i,o){if(!i||!o)return;let e=i;for(let[t,r]of Object.entries(o))r!=null&&(t==="style"&&typeof r=="string"?i.setAttribute("style",r):typeof r=="boolean"?r?i.setAttribute(t,""):i.removeAttribute(t):e[t]=r)}var hs=new Map;function Bp(i,o){return hs.set(i,o),()=>{hs.get(i)===o&&hs.delete(i)}}function qp(i){hs.delete(i)}function gd(i){let o={};for(let e of i)e.type==="group"&&e.fields?Object.assign(o,gd(e.fields)):e.type==="array"?o[e.name]=e.defaultValue!==void 0?e.defaultValue:[]:o[e.name]=e.defaultValue!==void 0?e.defaultValue:e.type==="switch"||e.type==="checkbox"?!1:e.type==="checkbox-group"?[]:e.type==="number"||e.type==="slider"?0:(e.type==="date"||e.type==="time"||e.type==="datetime","");return o}function vl(i,o){return o.split(/[.[\]]/).filter(Boolean).reduce((e,t)=>e?.[t],i)}function Sg(i,o){if(!i)return{visible:!0,disabled:!1,required:!1};let e=Array.isArray(i.when)?i.when:[i.when],t=!1;for(let n of e){let s=vl(o,n);if(i.is!==void 0?t=s===i.is:i.isNot!==void 0?t=s!==i.isNot:i.contains!==void 0?t=Array.isArray(s)&&s.includes(i.contains):i.pattern!==void 0?t=new RegExp(i.pattern).test(String(s??"")):t=!!s,t)break}let r=t?i.then??{visible:!0}:i.else??{visible:!1};return{visible:r.visible??!0,disabled:r.disabled??!1,required:r.required??!1}}function $g(i){let e={...i.validators??{}};i.validator&&(e.onSubmit=e.onSubmit??i.validator);let t=r=>{if(r!=null)return(0,xa.isStandardSchemaValidator)(r)?n=>xa.standardSchemaValidators.validate({value:n.value,validationSource:"field"},r)??void 0:r};return e.onChange=t(e.onChange),e.onSubmit=t(e.onSubmit),Object.keys(e).length?e:void 0}function Dn(i,o={}){if(i==null)return[];if(typeof i=="string")return i?[i]:[];if(typeof i=="number"||typeof i=="boolean")return[String(i)];if(i instanceof Error)return i.message?[i.message]:[String(i)];if(Array.isArray(i))return Array.from(new Set(i.flatMap(e=>Dn(e,o))));if(typeof i=="object"){let e=i,t=[];return typeof e.message=="string"&&e.message&&t.push(e.message),"form"in e&&t.push(...Dn(e.form,o)),o.includeFieldErrors&&"fields"in e&&t.push(...Dn(e.fields,o)),Array.from(new Set(t))}return[]}function ya(i){return i==null||i===!1?!1:typeof i=="string"?i.length>0:typeof i=="number"||typeof i=="boolean"||i instanceof Error?!0:Array.isArray(i)?i.some(ya):typeof i=="object"?Object.values(i).some(ya):!1}function Tg(i,o){let e=i.successMessage;return typeof e=="function"?e(o):e??"\u63D0\u4EA4\u6210\u529F"}var ge,Lt=class extends D.LitElement{constructor(){super(...arguments);this.schema=null;this.showActions=!0;this.size="md";this.labelPlacement="top";this.labelWidth="120px";this._currentStep=0;this._isStepPending=!1;this._submitErrorMessages=[];this._submitSuccessMessage="";Hu(this,ge);this._explicitAttrs=new Set;this._collapsedArrayItems=new Set;this._initializedSchema=null}connectedCallback(){super.connectedCallback(),this._explicitAttrs=new Set(this.getAttributeNames()),this._ensureControllerInitialized()}submit(){this._ensureControllerInitialized(),this._submitForm()}_dispatchValidate(e){ye(this,ge)&&this.dispatchEvent(new CustomEvent("validate",{detail:{valid:e,errors:ye(this,ge).api.getAllErrors(),values:this.getValues()},bubbles:!0,composed:!0}))}getValues(){return this._ensureControllerInitialized(),{...ye(this,ge)?.api.state.values??{}}}setValues(e,t={}){if(this._ensureControllerInitialized(),!!ye(this,ge)){for(let[r,n]of Object.entries(e))ye(this,ge).api.setFieldValue(r,n,{dontUpdateMeta:!t.touch});this._emitFormChange("setValues",void 0,void 0,this.getValues())}}getValue(e){return vl(this.getValues(),e)}setValue(e,t,r={}){this._ensureControllerInitialized(),ye(this,ge)&&(ye(this,ge).api.setFieldValue(e,t,{dontUpdateMeta:!r.touch}),this._emitFormChange("setValue",e,t,this.getValues()))}async validate(){if(this._ensureControllerInitialized(),!ye(this,ge)||!this.schema)return!0;this._clearSubmissionFeedback();let e=this.schema.steps?this.schema.steps.flatMap(d=>d.fields):this.schema.fields??[],t=Array.from(new Set(this._collectVisibleFieldNames(e)));this._markFieldsTouched(t);let r=await Promise.all(t.map(d=>ye(this,ge).api.validateField(d,"submit"))),n=await ye(this,ge).api.validate("submit"),s=!r.some(ya)&&!this._hasFieldErrors(t)&&!ya(n)&&this._getFormErrorMessages(ye(this,ge)).length===0;return this._dispatchValidate(s),this.requestUpdate(),s}clearValidate(e){if(this._ensureControllerInitialized(),!ye(this,ge)||!this.schema)return;this._clearSubmissionFeedback();let t=this.schema.steps?this.schema.steps.flatMap(n=>n.fields):this.schema.fields??[],r=e?.length?e:Array.from(new Set(this._collectVisibleFieldNames(t)));for(let n of r)ye(this,ge).api.setFieldMeta(n,s=>({...s,isValidating:!1,isTouched:!1,isBlurred:!1,isValid:!0,errors:[],errorMap:{},errorSourceMap:{}}));this.requestUpdate()}_clearSubmissionFeedback(){(this._submitErrorMessages.length||this._submitSuccessMessage)&&(this._submitErrorMessages=[],this._submitSuccessMessage="")}async _submitForm(){if(!ye(this,ge)||!this.schema)return;if(this._clearSubmissionFeedback(),!await this.validate()){this._scrollToFirstError(),this.requestUpdate();return}await ye(this,ge).api.handleSubmit(),this.requestUpdate()}reset(e){this._ensureControllerInitialized(),this._clearSubmissionFeedback(),ye(this,ge)?.api.reset(e),this._collapsedArrayItems.clear(),this._emitFormChange("reset",void 0,void 0,ye(this,ge)?.api.state.values??{})}_emitFormChange(e,t,r,n=this.getValues()){this.dispatchEvent(new CustomEvent("change",{detail:{reason:e,name:t,value:r,values:n},bubbles:!0,composed:!0}))}_emitFieldChange(e,t,r){let n=this.getValues();this._emitFormChange("field",e.name,t,n)}focusField(e){let r=this._fieldElement(e)?.querySelector("lui-input,lui-textarea,lui-select,lui-input-number,lui-datepicker,lui-color-picker,lui-input-opt,lui-checkbox,lui-switch,lui-radio,button,input,textarea,select");return r?.focus?.(),!!r}scrollToField(e,t={block:"center",behavior:"smooth"}){let r=this._fieldElement(e);return r?.scrollIntoView(t),!!r}_fieldElement(e){return this.renderRoot.querySelector(`[data-field-name="${CSS.escape(e)}"]`)}_findFieldDef(e){let t=e.replace(/\[\d+\]/g,""),r=this.schema?.steps?this.schema.steps.flatMap(s=>s.fields):this.schema?.fields??[],n=s=>{for(let d of s){if(d.name===e||d.name===t||t.endsWith(`.${d.name}`))return d;if(d.fields){let h=n(d.fields);if(h)return h}}};return n(r)}_firstErrorFieldName(){if(!ye(this,ge)||!this.schema)return;let e=this.schema.steps?this.schema.steps.flatMap(r=>r.fields):this.schema.fields??[];return Array.from(new Set(this._collectVisibleFieldNames(e))).find(r=>(ye(this,ge).api.getFieldMeta(r)?.errors?.length??0)>0)}_scrollToFirstError(){let e=this._firstErrorFieldName();e&&requestAnimationFrame(()=>{this.scrollToField(e),this.focusField(e)})}_effectiveSize(e){return e?.size??this.schema?.size??this.size}_effectiveLabelPlacement(e){return e?.labelPlacement??this.schema?.labelPlacement??this.labelPlacement}_normalizedLabelPlacement(e){let t=this._effectiveLabelPlacement(e);return t==="left"||t==="horizontal"?"left":"top"}_effectiveLabelWidth(e){return Ot(e?.labelWidth??this.schema?.labelWidth??this.labelWidth)||"120px"}_effectiveValidateTrigger(e){return e?.validateTrigger??this.schema?.validateTrigger??"change"}_fieldClass(e){return`field ${this._normalizedLabelPlacement(e)}`}_fieldStyle(e){return`--lui-form-label-width:${this._effectiveLabelWidth(e)}`}willUpdate(){this._ensureControllerInitialized();let e=N(this,"form");!this._explicitAttrs.has("size")&&typeof e.size=="string"&&this.size!==e.size&&(this.size=e.size),!this._explicitAttrs.has("label-placement")&&typeof e.labelPlacement=="string"&&this.labelPlacement!==e.labelPlacement&&(this.labelPlacement=e.labelPlacement),!this._explicitAttrs.has("label-width")&&(typeof e.labelWidth=="string"||typeof e.labelWidth=="number")&&this.labelWidth!==e.labelWidth&&(this.labelWidth=e.labelWidth),!this._explicitAttrs.has("show-actions")&&typeof e.showActions=="boolean"&&this.showActions!==e.showActions&&(this.showActions=e.showActions)}updated(e){super.updated(e),e.has("schema")&&this.schema&&(this._currentStep=0,this._clearSubmissionFeedback(),this._initializedSchema!==this.schema&&(this._initForm(),this.requestUpdate()))}_initForm(){if(!this.schema)return;let e=this.schema.steps?this.schema.steps.flatMap(n=>n.fields):this.schema.fields??[],t={...gd(e),...this.schema.defaultValues},r={...this.schema.validators??{}};this.schema.validator&&(r.onSubmit=r.onSubmit??this.schema.validator),Ru(this,ge,new xa.TanStackFormController(this,{defaultValues:t,validators:r,validationLogic:this.schema.validationLogic,onSubmit:async({value:n})=>{this._clearSubmissionFeedback(),this.dispatchEvent(new CustomEvent("submit",{detail:{value:n},bubbles:!0,composed:!0}));try{typeof this.schema.onSubmit=="function"&&await this.schema.onSubmit(n),this._submitSuccessMessage=Tg(this.schema,n)}catch(s){let d=Dn(s);throw this._submitErrorMessages=d.length?d:["\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"],this._submitSuccessMessage="",s}},onSubmitInvalid:()=>{this._submitSuccessMessage="",this._dispatchValidate(!1),this._scrollToFirstError()}})),this._initializedSchema=this.schema}_ensureControllerInitialized(){ye(this,ge)&&this._initializedSchema===this.schema||this.schema&&this._initForm()}_isGroupInline(e){return e.length>1&&e.every(t=>t.type!=="textarea"&&t.type!=="array"&&t.type!=="slider"&&t.type!=="date"&&t.type!=="time"&&t.type!=="datetime"&&t.type!=="file")}_getFieldCondition(e){let t=ye(this,ge)?.api?.state?.values??{},r=Sg(e.condition,t);return{visible:!e.hidden&&r.visible,disabled:(this.schema?.disabled??!1)||(e.disabled??!1)||r.disabled,readonly:(this.schema?.readonly??!1)||(e.readonly??!1),required:(e.required??!1)||r.required}}_isFieldRenderable(e){return e.type==="group"||e.type==="array"||e.type==="button"?!0:this._getFieldCondition(e).visible}_renderField(e,t,r=!1,n=!1){if(e.type==="group"&&e.fields)return this._renderGroup(e,t,r,n);if(e.type==="array")return this._renderArrayField(e,t,r,n);if(e.type==="button")return this._renderButtonField(e,r);let s=this._getFieldCondition(e);if(!s.visible)return D.nothing;let d={name:e.name},h={...e,required:s.required},p=$g(h);return p&&(d.validators=p),t.field(d,f=>{let x=Dn(f.state.meta.errors||[],{includeFieldErrors:!0}),y=f.state.meta.isTouched||ye(this,ge).api.state.submissionAttempts>0,C=y&&x.length>0,S=ke=>{let Ve=f.state.value;this._clearSubmissionFeedback(),f.handleChange(ke),this._effectiveValidateTrigger(h)==="change"&&f.validate?.("change"),this._emitFieldChange(h,ke,Ve)},E={field:h,value:f.state.value,errors:x,disabled:s.disabled||r,readonly:s.readonly||n,required:!!h.required,touched:y,invalid:x.length>0,formValues:ye(this,ge).api.state.values,fieldApi:f,blur:()=>f.handleBlur(),clearFeedback:()=>this._clearSubmissionFeedback(),handleChange:S,submit:()=>void this._submitForm(),reset:()=>this.reset()},T=this._withProps(h,this._renderControl(h,f,s.disabled||r,s.readonly||n,E)),O=h.hiddenLabel?"":h.label??"",H=D.html`
11405
11405
  <lui-form-item
11406
11406
  data-field-name=${h.name}
11407
11407
  .label=${O}
@@ -11649,27 +11649,27 @@
11649
11649
  type=${e.type}
11650
11650
  @input=${f}
11651
11651
  @blur=${x}
11652
- ></lui-input>`}}_renderFields(e,t){return!!this.schema?.gutter||!!this.schema?.align||!!this.schema?.justify||!!this.schema?.nowrap||e.some(n=>n.span!=null||n.xs!=null||n.sm!=null||n.md!=null||n.lg!=null||n.xl!=null||n.offset!=null||n.order!=null)?D.html`
11652
+ ></lui-input>`}}_renderFields(e,t){if(!(!!this.schema?.gutter||!!this.schema?.align||!!this.schema?.justify||!!this.schema?.nowrap||e.some(s=>s.span!=null||s.xs!=null||s.sm!=null||s.md!=null||s.lg!=null||s.xl!=null||s.offset!=null||s.order!=null)))return e.map(s=>this._renderField(s,t));let n=e.filter(s=>this._isFieldRenderable(s));return D.html`
11653
11653
  <lui-row
11654
11654
  .gutter=${this.schema?.gutter??[12,12]}
11655
11655
  .align=${this.schema?.align??"top"}
11656
11656
  .justify=${this.schema?.justify??"start"}
11657
11657
  .nowrap=${this.schema?.nowrap??!1}
11658
11658
  >
11659
- ${e.map(n=>D.html`<lui-col
11660
- .span=${n.span}
11661
- .xs=${n.xs}
11662
- .sm=${n.sm}
11663
- .md=${n.md}
11664
- .lg=${n.lg}
11665
- .xl=${n.xl}
11666
- .offset=${n.offset}
11667
- .colOrder=${n.order}
11659
+ ${n.map(s=>D.html`<lui-col
11660
+ .span=${s.span}
11661
+ .xs=${s.xs}
11662
+ .sm=${s.sm}
11663
+ .md=${s.md}
11664
+ .lg=${s.lg}
11665
+ .xl=${s.xl}
11666
+ .offset=${s.offset}
11667
+ .colOrder=${s.order}
11668
11668
  >
11669
- ${this._renderField(n,t)}
11669
+ ${this._renderField(s,t)}
11670
11670
  </lui-col>`)}
11671
11671
  </lui-row>
11672
- `:e.map(n=>this._renderField(n,t))}_renderWizard(e){let t=this.schema.steps,r=t[this._currentStep];if(!r)return D.nothing;let n=this._currentStep===0,s=this._currentStep===t.length-1,d=e.api.state.isSubmitting||this._isStepPending;return D.html`
11672
+ `}_renderWizard(e){let t=this.schema.steps,r=t[this._currentStep];if(!r)return D.nothing;let n=this._currentStep===0,s=this._currentStep===t.length-1,d=e.api.state.isSubmitting||this._isStepPending;return D.html`
11673
11673
  <div class="wizard-steps">
11674
11674
  ${t.map((h,p)=>D.html`
11675
11675
  <div