@piying/view-angular-core 0.6.19 → 0.6.21

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.
@@ -1 +1 @@
1
- import{effect,inject,Injector,untracked,DestroyRef,isSignal,signal,computed,linkedSignal,InjectionToken,EnvironmentInjector}from"@angular/core";import*as v from"valibot";import{deepEqual}from"fast-equals";import{BehaviorSubject,isObservable,Subject,combineLatest,startWith,skip,map}from"rxjs";import rfdc from"rfdc";import{createRawConfig,BaseSchemaHandle,convertSchema,convertCore}from"@piying/valibot-visit";export{asControl,asVirtualGroup,changeObject,condition,getDefaults,getSchemaByIssuePath,getSchemaMetadata}from"@piying/valibot-visit";import clsx from"clsx";function arrayStartsWith(list,parts){return(Array.isArray(parts)?parts:[parts]).every((item,index)=>item===list[index])}function effectListen(listen,fn,options){let first=!0,oldValue=listen();return effect(()=>{let currentValue=listen();if(first){first=!1,deepEqual(oldValue,currentValue)||fn();return}return fn()},options)}function toObservable(listen,source,options){let injector=options?.injector??inject(Injector),subject=new BehaviorSubject(source()),watcher=effectListen(listen,()=>{let value;try{value=source()}catch(err){untracked(()=>subject.error(err));return}untracked(()=>subject.next(value))},{injector,manualCleanup:!0});return injector.get(DestroyRef).onDestroy(()=>{watcher.destroy(),subject.complete()}),subject.asObservable()}let clone=rfdc({proto:!1,circles:!1});function unWrapSignal$1(value){return isSignal(value)?value():value}function toArray(input){return void 0===input||Array.isArray(input)?input:[input]}class SortedArray extends Array{#compareFn;constructor(compareFn){super(),this.#compareFn=compareFn}push(...items){let result=super.push(...items);return this.sort(this.#compareFn),result}}function isPromise(obj){return!!obj&&"function"==typeof obj.then}let ValidatorPending=Symbol("PENDING");function shortCircuitTrue(value){return value}let VALID="VALID",INVALID="INVALID",PENDING="PENDING";class AbstractControl{emptyValue$$=computed(()=>clone(this.config$().emptyValue));shouldInclude$$=computed(()=>this.valueNoError$$()&&(!this.selfDisabled$$()||this.selfDisabled$$()&&"reserve"===this.config$().disabledValue));injector;selfDisabled$$=computed(()=>this.config$?.().disabled??!1);selfEnabled$$=computed(()=>!this.selfDisabled$$());disabled$$=computed(()=>(this.parent?.disabled$$()||this.selfDisabled$$())??!1);enabled$$=computed(()=>!this.disabled$$());get disabled(){return this.disabled$$()}get enabled(){return!this.disabled$$()}enable(){this.config$.update(config=>({...config={...config,disabled:!1},disabled:!1}))}disable(){this.config$.update(config=>({...config,disabled:!0}))}selfTouched$=signal(!1);touched$$=computed(()=>this.reduceChildren(this.selfTouched$(),(child,value)=>value||child.touched$$(),shortCircuitTrue));get touched(){return untracked(this.touched$$)}get untouched(){return!untracked(this.touched$$)}selfDirty$=signal(!1);dirty$$=computed(()=>this.reduceChildren(this.selfDirty$(),(child,value)=>value||child.dirty$$(),shortCircuitTrue));get dirty(){return untracked(this.dirty$$)}get pristine(){return!untracked(this.dirty$$)}#validators$$=computed(()=>this.config$().validators??[]);#asyncValidators$$=computed(()=>this.config$().asyncValidators??[]);resetIndex$=signal(0);syncError$=linkedSignal(computed(()=>{if(this.disabled$$())return;this.resetIndex$(),this.value$$();let result=this.#validators$$().reduce((obj,item)=>{let result=untracked(()=>item(this));return result&&(obj={...obj,...result}),obj},{}),schemaResult=this.#schemaCheck$$();return schemaResult.success?Object.keys(result).length?result:void 0:{...result,valibot:schemaResult.issues}},{equal:()=>!1}));asyncErrorRes$$=computed(()=>{let result=this.#asyncValidators$$();if(0===result.length)return;this.resetIndex$(),this.value$$();let dataList=result.map(item=>untracked(()=>(function(input){let value$;if(isPromise(input)){let value$;return value$=signal(ValidatorPending),input.then(value=>{value$.set({value})}),value$}return isObservable(input)?(value$=signal(ValidatorPending),input.subscribe({next:value=>{value$.set({value})},error:error=>{value$.set({error})}}),value$):input})(item(this))));return computed(()=>{let params=dataList.map(item=>item()),pendingCount=0,errorResult=params.reduce((obj,item)=>item===ValidatorPending?(pendingCount++,obj):"value"in item?{...obj,...item.value}:{...obj,error:item.error},{});return Object.keys(errorResult).length?errorResult:pendingCount?ValidatorPending:void 0})});asyncError$$=computed(()=>{if(this.disabled$$())return;let ref=this.asyncErrorRes$$();if(ref){let result=ref();return result===ValidatorPending?PENDING:result}});rawError$$=computed(()=>{if(this.disabled$$())return;let syncError=this.syncError$(),asyncError=this.asyncError$$();return asyncError===PENDING?PENDING:syncError&&asyncError?{...syncError,...asyncError}:syncError||asyncError?syncError||asyncError:void 0});valueNoError$$=computed(()=>void 0===this.rawError$$());get errors(){let error=this.rawError$$();return error===PENDING?void 0:error}_parent;get parent(){return this._parent}get value(){return this.value$$()}required$$=computed(()=>this.config$().required);schemaParser;constructor(rawSchema,injector){this.injector=injector,this.schemaParser=v.safeParser(rawSchema)}#schemaCheck$$=computed(()=>this.schemaParser(this.value$$()));setParent(parent){this._parent=parent}get valid(){return this.status$$()===VALID}get invalid(){return this.status$$()===INVALID}get pending(){return this.status$$()===PENDING}selfUpdateOn$$=computed(()=>this.config$?.().updateOn);updateOn$$=computed(()=>(this.selfUpdateOn$$()||this.parent?.updateOn$$())??"change");markAsTouched(){this.selfTouched$.set(!0)}markAllAsDirty(){this.markAsDirty(),this._forEachChild(control=>control.markAllAsDirty())}markAllAsTouched(){this.markAsTouched(),this._forEachChild(control=>control.markAllAsTouched())}markAsUntouched(){this.selfTouched$.set(!1)}markAsDirty(){this.selfDirty$.set(!0)}markAsPristine(){this.selfDirty$.set(!1)}getRawValue(){return this.value}get(path){let currPath=path;return null==currPath||(Array.isArray(currPath)||(currPath=currPath.split(".")),0===currPath.length)?null:currPath.reduce((control,name)=>control&&control.find(name),this)}get root(){let x=this;for(;x._parent;)x=x._parent;return x}config$=signal({});initConfig(config){this.config$=config}find(name){return null}setControl(name,control){}reduceChildren(initialValue,fn,shortCircuit){let childrenMap=this.children$$?.();if(!childrenMap)return initialValue;let value=initialValue;for(let child of childrenMap){if(shortCircuit?.(value))break;value=fn(child,value)}return value}#valueChange;get valueChanges(){return this.#valueChange??(this.#valueChange=toObservable(computed(()=>({value:this.value$$(),disabled:this.disabled$$()})),this.value$$,{injector:this.injector}))}status$$=computed(()=>{if(this.disabled$$())return VALID;if(this.rawError$$())if(this.rawError$$()!==PENDING)return INVALID;else return PENDING;return this.reduceChildren(VALID,(child,value)=>value===INVALID||child.status$$()===INVALID?INVALID:value===PENDING||child.status$$()===PENDING?PENDING:VALID,v=>v===INVALID)});#statusChange;get statusChanges(){return this.#statusChange??(this.#statusChange=toObservable(this.status$$,this.status$$,{injector:this.injector}))}}class FieldArray extends AbstractControl{#deletionMode$$=computed(()=>this.config$().deletionMode??"shrink");value$$=computed(()=>{let list=[];for(let control of this.controls$())if(control&&control.shouldInclude$$())list.push(control.value$$());else{if("shrink"===this.#deletionMode$$())continue;"mark"===this.#deletionMode$$()&&list.push(void 0)}return 0===list.length?this.emptyValue$$():list});children$$=computed(()=>this.controls$());controls$=signal([]);get controls(){return this.controls$()}removeAt(index){let adjustedIndex=this._adjustIndex(index);this.controls$()[adjustedIndex]&&this.controls$.update(list=>((list=list.slice()).splice(adjustedIndex,1),list))}setControl(index,control){let adjustedIndex=this._adjustIndex(index);this.controls$.update(list=>((list=list.slice())[adjustedIndex]=control,list)),control.setParent(this)}get length(){return this.controls$().length}reset(value=[]){this._forEachChild((control,index)=>{control.reset(value[index])})}getRawValue(){return this.controls$().map(control=>control.getRawValue())}clear(){this.controls$().length<1||this.controls$.update(()=>[])}_adjustIndex(index){return index<0?Math.max(index+this.length,0):index}_forEachChild(cb){this.controls$().forEach((control,index)=>{control&&cb(control,index)})}find(name){return this.controls$()[this._adjustIndex(name)]}beforeUpdateList=[];updateValue(value=[]){deepEqual(value,this.value$$())||(this.beforeUpdateList.forEach(item=>item(value)),this.controls$().forEach((control,i)=>{control.updateValue(value[i])}))}}class FieldControl extends AbstractControl{children$$;#viewIndex=0;viewIndex$=signal(0);modelValue$=signal(void 0);modelValueToViewValueOrigin$$=computed(()=>{let viewValue=this.modelValue$(),toView=this.config$?.().transfomer?.toView;return toView?toView(viewValue,this):viewValue});modelValueToViewValue$$=computed(()=>(this.viewIndex$(),this.modelValueToViewValueOrigin$$()),{equal:()=>!1});value$$=signal(void 0);reset(formState=this.config$().defaultValue){this.updateValue(formState,!0),this.markAsPristine(),this.markAsUntouched()}_forEachChild(cb){}#initInput=!0;setViewValue(value){this.#viewIndex++;let toModel=this.config$?.().transfomer?.toModel,originValue=toModel?toModel(value,this):value,transfomered=this.schemaParser(originValue);transfomered.success?(this.value$$.set(transfomered.output),this.syncError$.set(void 0)):this.syncError$.set({valibot:transfomered.issues}),this.markAllAsDirty()}updateValue(value,force){if(force&&(this.#viewIndex++,this.viewIndex$.set(this.#viewIndex),this.resetIndex$.update(a=>a+1),this.#initInput=!0),this.#initInput){this.#initInput=!1,(void 0!==value&&!deepEqual(value,this.value$$())||force)&&(this.modelValue$.set(value),this.value$$.set(value));return}deepEqual(value,this.value$$())||(this.viewIndex$.set(this.#viewIndex),this.modelValue$.set(value),this.value$$.set(value))}initConfig(config){super.initConfig(config),"defaultValue"in this.config$()&&(this.modelValue$.set(this.config$().defaultValue),this.value$$.set(this.config$().defaultValue))}}class FieldLogicGroup extends FieldArray{activateIndex$=signal(0);type=signal("and");activateControl$=signal(void 0);value$$=computed(()=>this.getValue(!1));getActivateControls(){let list;if(this.activateControl$())list=this.activateControl$();else if("and"===this.type())list=this.controls$();else if("or"===this.type())list=[this.controls$()[this.activateIndex$()]];else throw Error("");return list}getValue(rawData){let controls=rawData?this.getActivateControls():this.getActivateControls().filter(control=>control.shouldInclude$$()),control=controls[0];if(0===controls.length)return this.emptyValue$$();if(1===controls.length)return control.value;let result=controls.reduce((obj,control)=>({...obj,...control.value$$()}),{});return Object.keys(result).length?result:this.emptyValue$$()}getRawValue(){return this.getValue(!0)}updateValue(value){deepEqual(value,this.value$$())||this.controls$().forEach((control,i)=>{control.updateValue(value)})}}function isFieldGroup(input){return input instanceof FieldGroup}function isFieldArray(input){return input instanceof FieldArray}function isFieldControl(input){return input instanceof FieldControl}function isFieldLogicGroup(input){return input instanceof FieldLogicGroup}class FieldGroup extends AbstractControl{value$$=computed(()=>{let result={...this._reduceChildren({},(acc,control,name)=>(control.shouldInclude$$()&&(acc[name]=control.value),acc)),...this.looseValue$$()};return Object.keys(result).length?result:this.emptyValue$$()});children$$=computed(()=>Object.values(this.controls$()));controls$=signal({});get controls(){return this.controls$()}registerControl(name,control){return this.controls$()[name]?this.controls$()[name]:(this.controls$.update(controls=>({...controls,[name]:control})),control.setParent(this),control)}removeControl(name){this.controls$()[name]&&this.controls$.update(controls=>(controls={...controls},delete controls[name],controls))}setControl(name,control){this.controls$.update(controls=>(controls={...controls},delete controls[name],controls)),control&&this.registerControl(name,control)}reset(value={}){this._forEachChild((control,name)=>{control.reset(value?value[name]:void 0)})}getRawValue(){return this._reduceChildren({},(acc,control,name)=>(acc[name]=control.getRawValue(),acc))}_forEachChild(cb){Object.keys(this.controls$()).forEach(key=>{let control=this.controls$()[key];control&&cb(control,key)})}_reduceChildren(initValue,fn){let res=initValue;return this._forEachChild((control,name)=>{res=fn(res,control,name)}),res}find(name){return this.controls$()[name]}looseValue$$=computed(()=>{let initValue=this.#initValue$();if(!initValue||isFieldLogicGroup(this.parent))return{};let controls=this.controls$(),looseValue={};for(let key in initValue)key in controls||(looseValue[key]=initValue[key]);return looseValue});#initValue$=signal({});setInitValue(obj){this.#initValue$.set(obj)}updateValue(value){if(!deepEqual(value,this.value$$())){for(let key in this.controls$())this.controls$()[key].updateValue(value?.[key]);if(!deepEqual(value,this.#initValue$()))return void this.setInitValue(value)}}}let PI_VIEW_CONFIG_TOKEN=new InjectionToken("PI_VIEW_CONFIG"),PI_FORM_BUILDER_OPTIONS_TOKEN=new InjectionToken("PI_FORM_BUILDER_OPTIONS"),PI_FORM_BUILDER_ALIAS_MAP=new InjectionToken("PI_FORM_BUILDER_ALIAS_MAP");function isGroup(schema){return schema.isGroup}function isArray(schema){return schema.isArray}function unWrapSignal(value){return isSignal(value)?value():value}class ParentMap extends Map{parent;constructor(parent){super(),this.parent=parent}get(key){let result=super.get(key);return void 0===result?this.parent?.get(key):result}}function fieldQuery(key,field,aliasMap,root,aliasNotFoundFn){let list,keyPath=Array.isArray(key)?key:"number"==typeof key?[key]:key.split("."),firstPath=keyPath[0];if("#"===firstPath)field=root,list=[{field:root,level:1}];else if(".."===firstPath)list=[{field:field.parent,level:1}];else if("string"==typeof firstPath&&firstPath.startsWith("@")){let queryField=aliasMap.get(firstPath.slice(1));!queryField&&aliasNotFoundFn&&(queryField=aliasNotFoundFn(firstPath.slice(1),field)),list=[{field:queryField,level:1}]}else field.fieldGroup?list=(function* groupGenerator(list){for(let item of list)!item.keyPath?.length&&item.fieldGroup?.().length?yield*groupGenerator(item.fieldGroup()):item.keyPath?.length&&(yield item)})(field.fieldGroup()).filter(field=>field.keyPath&&arrayStartsWith(keyPath,field.keyPath)).map(field=>({field:field,level:field.keyPath?.length})):field.fieldArray&&(list=field.fieldArray().filter(field=>field.keyPath&&arrayStartsWith(keyPath,field.keyPath)).map(field=>({field:field,level:field.keyPath?.length})));if(list)for(let item of list){if(keyPath.length===item.level)return item.field;let res=item.field.get(keyPath.slice(item.level),aliasNotFoundFn);if(res)return res}}class FormBuilder{#scopeMap=inject(PI_FORM_BUILDER_ALIAS_MAP,{optional:!0})??new ParentMap;#options=inject(PI_FORM_BUILDER_OPTIONS_TOKEN);#injector=inject(Injector);#envInjector=inject(EnvironmentInjector);#globalConfig=inject(PI_VIEW_CONFIG_TOKEN,{optional:!0})??void 0;#allFieldInitHookList=[];buildRoot(item){this.#buildControl({type:"root",field:{fullPath:[]},form:void 0,resolvedField$:item.resolvedField$,append:()=>{}},item.field,0),this.allFieldInitHookCall()}allFieldInitHookCall(){let list=this.#allFieldInitHookList;this.#allFieldInitHookList=[],list.forEach(fn=>fn())}#buildField(item){"group"===item.type?this.#buildGroup(item):this.#buildArray(item)}afterResolveConfig(rawConfig,config){}#buildControl(parent,field,index){var parentForm,key,injector;let viewDefaultConfig,define,control,FieldClass,control1,type=field.type;if(type){let result=this.#resolveComponent(type);viewDefaultConfig=result.defaultConfig,define=result.define}let mergeStrategy=this.#globalConfig?.defaultConfigMergeStrategy,inputs=this.configMerge([this.#globalConfig?.defaultConfig?.inputs,viewDefaultConfig?.inputs,field.inputs],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.inputs??"merge"),outputs=this.configMerge([this.#globalConfig?.defaultConfig?.outputs,viewDefaultConfig?.outputs,field.outputs],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.outputs??"merge"),attributes=this.configMerge([this.#globalConfig?.defaultConfig?.attributes,viewDefaultConfig?.attributes,field.attributes],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.attributes??"merge"),wrappers=this.configMerge([this.#globalConfig?.defaultConfig?.wrappers,viewDefaultConfig?.wrappers,field.wrappers],!0,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.wrappers??"replace"),props=this.configMerge([this.#globalConfig?.defaultConfig?.props,viewDefaultConfig?.props,field.props],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.props??"merge"),formConfig$=this.configMerge([this.#globalConfig?.defaultConfig?.formConfig,viewDefaultConfig?.formConfig,field.formConfig],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.formConfig??"merge"),renderConfig=this.configMerge([this.#globalConfig?.defaultConfig?.renderConfig,viewDefaultConfig?.renderConfig,field.renderConfig],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.renderConfig??"merge"),keyPath=field.key;isFieldLogicGroup(parent.form)?keyPath??=parent.form.controls$().length:isFieldArray(parent.form)&&(keyPath??=index);let isRoot="root"===parent.type;!field.nonFieldControl&&(void 0!==keyPath||isRoot)&&(parentForm=parent.form,key=keyPath,injector=this.#injector,FieldClass=field.isLogicAnd||field.isLogicOr?FieldLogicGroup:isGroup(field)?FieldGroup:isArray(field)||field.isTuple?FieldArray:FieldControl,isRoot?(isFieldLogicGroup(control1=new FieldClass(field.sourceSchema,injector))&&control1.type.set(field.isLogicAnd?"and":"or"),control1.initConfig(formConfig$)):(control1=parentForm.get([key]))||(isFieldLogicGroup(control1=new FieldClass(field.sourceSchema,injector))&&control1.type.set(field.isLogicAnd?"and":"or"),parentForm.setControl?.(key,control1),control1.initConfig(formConfig$)),control=control1);let rootForm=this.#options.form$$,resolvedConfig={id:field.id,keyPath:toArray(keyPath),get fullPath(){return[...resolvedConfig.parent.fullPath,...resolvedConfig.keyPath??[]]},form:{parent:parent.form,control:control??(isGroup(field)?parent.form:void 0),get root(){return rootForm()}},get:(keyPath,aliasNotFoundFn)=>untracked(()=>fieldQuery(keyPath,resolvedConfig,this.#scopeMap,this.#options.resolvedField$(),aliasNotFoundFn)),parent:parent.field,origin:field,renderConfig:renderConfig,formConfig:formConfig$,props,context:this.#options.context(),priority:field.priority,hooks:field.hooks,alias:field.alias,inputs:inputs,outputs:outputs,attributes,define:define?{...define,inputs,outputs,attributes}:void 0,wrappers,wrappers$$:computed(()=>this.#resolveWrappers(wrappers()))};return resolvedConfig=this.afterResolveConfig(field,resolvedConfig)??resolvedConfig,field.movePath?this.#moveViewField(field.movePath,resolvedConfig):parent.append(resolvedConfig),field.alias&&this.#scopeMap.set(field.alias,resolvedConfig),resolvedConfig.hooks?.fieldResolved?.(resolvedConfig),isRoot&&parent.resolvedField$.set(resolvedConfig),isGroup(field)||field.isLogicAnd||field.isLogicOr||field.isTuple?(resolvedConfig.fieldGroup=signal(new SortedArray((a,b)=>a.priority-b.priority)),this.#buildField({type:"group",fields:field.children,field:resolvedConfig,form:control||parent.form,append:field=>{resolvedConfig.fieldGroup().push(field)}})):isArray(field)&&this.#buildField({type:"array",templateField:field.arrayChild,field:resolvedConfig,form:control,append:field=>{}}),resolvedConfig.hooks?.allFieldsResolved&&this.#allFieldInitHookList.push(()=>{resolvedConfig.hooks.allFieldsResolved(resolvedConfig)}),resolvedConfig}#buildGroup(groupItem){for(let index=0;index<groupItem.fields.length;index++){let field=groupItem.fields[index];this.#buildControl(groupItem,field,index)}let field=groupItem.field;field.hooks?.afterChildrenInit?.(field)}createArrayItem(parent,field,index){let Builder=this.constructor,injector=Injector.create({providers:[Builder,{provide:PI_FORM_BUILDER_ALIAS_MAP,useValue:new ParentMap(this.#scopeMap)},{provide:EnvironmentInjector,useFactory:()=>injector}],parent:this.#envInjector});this.#envInjector.get(DestroyRef).onDestroy(()=>{result.injector?.destroy()});let instance=injector.get(Builder),result=instance.#buildControl(parent,field,index);return this.#allFieldInitHookList.push(()=>instance.allFieldInitHookCall()),result.injector=injector.get(EnvironmentInjector),result}#buildArray(arrayItem){let{templateField,form}=arrayItem;arrayItem.field.action={set:(value,index)=>{untracked(()=>{index="number"==typeof index?index:arrayItem.field.fieldArray?.().length??0;let result=this.createArrayItem(arrayItem,templateField,index),list=[...arrayItem.field.fieldArray()];list[index]=result,arrayItem.field.fieldArray.set(list),this.allFieldInitHookCall(),result.form.control.updateValue(value)})},remove:index=>{untracked(()=>{let list=[...arrayItem.field.fieldArray()],[deletedItem]=list.splice(index,1);arrayItem.field.fieldArray.set(list),form.removeAt(index),deletedItem&&(deletedItem.injector.destroy(),deletedItem.injector=void 0)})}},arrayItem.field.fieldArray=signal([]),arrayItem.field.hooks?.afterChildrenInit?.(arrayItem.field),form.beforeUpdateList.push(input=>{let controlLength=form.controls$().length;if(controlLength<input.length){let list=arrayItem.field.fieldArray().slice();for(let index=controlLength;index<input.length;index++){let result=this.createArrayItem(arrayItem,arrayItem.templateField,index);list[index]=result}arrayItem.field.fieldArray.set(list)}else if(input.length<controlLength){let list=arrayItem.field.fieldArray().slice();for(let index=arrayItem.field.fieldArray().length-1;index>=input.length;index--){let[deletedItem]=list.splice(index,1);form.removeAt(index),deletedItem&&(deletedItem.injector?.destroy(),deletedItem.injector=void 0)}arrayItem.field.fieldArray.set(list)}this.allFieldInitHookCall()})}#resolveComponent(type){let define,defaultConfig;if("string"!=typeof type)return{define:{type:type}};{let config=this.#globalConfig?.types?.[type];if(!config)throw Error(`define:未注册[${type}]`);if(defaultConfig=config,Object.keys(config).length)return define={...config},{define:{...config},defaultConfig}}return{define,defaultConfig}}configMerge(list,isArray,strategy){return signal(clone(isArray?"merge"===strategy?list.filter(Boolean).flat().map(item=>unWrapSignal(item)):list.reduce((data,item)=>unWrapSignal(item)??data,[]):"merge"===strategy?list.reduce((obj,item)=>({...obj,...unWrapSignal(item)}),{}):list.reduce((data,item)=>unWrapSignal(item)??data,{})))}#moveViewField(key,inputField){let parent=fieldQuery(key,inputField,this.#scopeMap,this.#options.resolvedField$(),(name,field)=>{let rootForm=this.#options.form$$,aliasField={alias:name,parent:field,get fullPath(){return field.fullPath},form:{parent:field.form.control??field.form.parent,control:void 0,get root(){return rootForm()}},get:(keyPath,fn)=>fieldQuery(keyPath,aliasField,this.#scopeMap,this.#options.resolvedField$(),fn),fieldGroup:signal(new SortedArray((a,b)=>a.priority-b.priority)),priority:0,renderConfig:signal({}),wrappers$$:signal([])};if(this.#scopeMap.set(name,aliasField),inputField===field)throw Error(`添加位置不可为自身`);return field.fieldGroup().push(aliasField),aliasField});if(!parent)throw Error("移动视图项失败");let index=inputField.parent.fieldGroup?.().findIndex(item=>item===inputField);"number"==typeof index&&-1!==index&&inputField.parent.fieldGroup?.().splice(index,1);let newKeyPath=inputField.fullPath.slice(parent.fullPath.length);inputField.keyPath=newKeyPath,inputField.parent=parent,parent.fieldGroup().push(inputField)}#resolveWrappers(wrappers){return(wrappers??[]).map(wrapper=>{if("string"==typeof wrapper){let config=this.#globalConfig?.wrappers?.[wrapper];if(!config)throw Error(`wrapper:未注册[${wrapper}]`);return{...config,inputs:signal(config.inputs),attributes:signal(config.attributes)}}if("string"!=typeof wrapper.type)return{...wrapper,inputs:signal(wrapper.inputs),attributes:signal(wrapper.attributes)};{let config=this.#globalConfig?.wrappers?.[wrapper.type];if(!config)throw Error(`wrapper:未注册[${wrapper.type}]`);return{inputs:signal({...config.inputs,...wrapper.inputs}),outputs:{...config.outputs,...wrapper.outputs},attributes:signal({...config.attributes,...wrapper.attributes}),type:config.type}}})}}function layout(value){return{kind:"metadata",type:"layout",reference:layout,value:value}}let rawConfig=createRawConfig("viewRawConfig");function setComponent(type){return rawConfig(field=>{field.type=type})}let setHooks=hooks=>rawConfig(field=>{field.hooks=hooks}),patchHooks=hooks=>rawConfig(field=>{field.hooks={...field.hooks,...hooks}}),DefaultOptions$1={position:"bottom"};function mergeHooksFn(hooks,options,field){for(let key in field.hooks??={},hooks){let oldFn=field.hooks[key];field.hooks[key]=(...args)=>{"top"===options.position&&hooks[key](...args),oldFn?.(...args),"bottom"===options.position&&hooks[key](...args)}}}let mergeHooks=(hooks,options=DefaultOptions$1)=>rawConfig(field=>mergeHooksFn(hooks,options,field));function removeHooks(list){return rawConfig(field=>{let oldValue=field.hooks;oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.hooks=oldValue)})}function setInputs(inputs){return rawConfig(field=>{field.inputs=inputs})}function patchInputs(inputs){return rawConfig(field=>{field.inputs={...field.inputs,...inputs}})}function removeInputs(list){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.inputs);oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.inputs=oldValue)})}function asyncInputMerge(dataObj,data$){let signalObj={};Object.keys(dataObj).forEach(key=>{let result=dataObj[key];isPromise(result)?result.then(value=>{data$.update(lastData=>((lastData={...lastData})[key]=value,lastData))}):result&&"function"==typeof result.subscribe?result.subscribe({next:value=>{data$.update(lastData=>((lastData={...lastData})[key]=value,lastData))}}):isSignal(result)?signalObj[key]=result:data$.update(lastData=>((lastData={...lastData})[key]=result,lastData))});let signalKeyList=Object.keys(signalObj);return signalKeyList.length?linkedSignal(computed(()=>({...data$(),...signalKeyList.reduce((obj,key)=>({...obj,[key]:signalObj[key]()}),{})}))):data$}function patchAsyncFn(patchKey){return(dataObj,options)=>rawConfig(rawField=>{let inputList=Object.keys(dataObj),hookName=options?.hookName??"allFieldsResolved";return rawField[patchKey]={...rawField[patchKey],...inputList.reduce((obj,item)=>(obj[item]=rawField[patchKey]?.[item]??void 0,obj),{})},mergeHooksFn({[hookName]:field=>{field[patchKey]=asyncInputMerge(Object.entries(dataObj).reduce((obj,[key,value])=>(obj[key]=value(field),obj),{}),field[patchKey])}},{position:options?.addPosition??"bottom"},rawField)})}let patchAsyncInputs=patchAsyncFn("inputs");function setAttributes(attributes){return rawConfig(field=>{field.attributes=attributes})}function patchAttributes(attributes){return rawConfig(field=>{field.attributes={...field.attributes,...attributes}})}function removeAttributes(list){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.attributes);oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.attributes=oldValue)})}let patchAsyncAttributes=patchAsyncFn("attributes");function setProps(props){return rawConfig(field=>{field.props=props})}function patchProps(props){return rawConfig(field=>{field.props={...field.props,...props}})}function removeProps(list){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.props);oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.props=oldValue)})}let patchAsyncProps=patchAsyncFn("props");function setOutputs(outputs){return rawConfig(field=>{field.outputs=outputs})}function patchOutputs(outputs){return rawConfig(field=>{let oldValue=field.outputs;field.outputs={...oldValue,...outputs}})}function removeOutputs(list){return rawConfig(field=>{let oldValue=field.outputs;oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.outputs=oldValue)})}function mergeOutputFn(field,outputs,options){field.outputs.update(originOutputs=>{for(let key in originOutputs={...originOutputs},outputs){let oldFn=originOutputs[key];originOutputs[key]=(...args)=>{"top"===options.position&&outputs[key](...args,field),oldFn?.(...args,field),"bottom"===options.position&&outputs[key](...args,field)}}return originOutputs})}let DefaultOptions={position:"bottom"},mergeOutputs=(outputs,options=DefaultOptions)=>rawConfig(field=>{mergeHooksFn({allFieldsResolved:field=>{mergeOutputFn(field,outputs,options)}},{position:"bottom"},field)});function outputChangeFn(rawField,fn){mergeHooksFn({allFieldsResolved:field=>fn(list=>{let resultList=[];for(let item of list){let emitField=item.list?field.get(item.list):field,subject=new Subject;mergeOutputFn(field,{[item.output]:(...args)=>{subject.next(args)}},{position:"bottom"}),resultList.push({subject,field:emitField})}return combineLatest(resultList.map(({subject})=>subject.pipe(startWith(void 0)))).pipe(skip(1),map(list=>({list,field,listenFields:resultList.map(item=>item.field)})))})},{position:"bottom"},rawField)}function outputChange(fn){return rawConfig(field=>outputChangeFn(field,fn))}function setWrappers(wrappers){return rawConfig(field=>{field.wrappers=wrappers})}let defaultValue={position:"tail"};function patchWrappers(wrappers,options=defaultValue){return rawConfig(field=>{let list=toArray(wrappers);field.wrappers??=[],"tail"===options.position?field.wrappers.push(...list):field.wrappers.unshift(...list)})}function removeWrappers(list){return rawConfig(field=>{if(!field.wrappers)return;let wrappers=field.wrappers;for(let i=0;i<list.length;i++){let name=list[i];for(let j=0;j<wrappers.length;j++){let config=wrappers[j];if(("string"==typeof config?config:config.type)===name){wrappers.splice(j,1);break}}}field.wrappers=wrappers})}function setAlias(alias){return rawConfig(field=>{field.alias=alias})}function renderConfig(type){return rawConfig(field=>{field.renderConfig=type})}function formConfig(config){return rawConfig(field=>{field.formConfig={...field.formConfig,...config}})}let DefaultSelfList=[void 0];function valueChangeFn(field,input={}){return combineLatest((input.list??DefaultSelfList).map(keyPath=>keyPath?field.get(keyPath).form.control:field.form.control).map(control=>input.skipInitValue?control.valueChanges.pipe(skip(1)):control.valueChanges)).pipe(map(list=>({list,field,listenFields:list})))}function valueChange(listenFn){return rawConfig(field=>{mergeHooksFn({allFieldsResolved:field=>{listenFn(options=>valueChangeFn(field,options),field)}},{position:"bottom"},field)})}function hideWhen(options){return rawConfig(field=>(mergeHooksFn({allFieldsResolved:field=>{options.listen(options=>valueChangeFn(field,options),field).subscribe(hidden=>{field.renderConfig.update(value=>!!value.hidden!==hidden?{...value,hidden:hidden}:value),void 0!==options.disabled&&field.formConfig&&field.formConfig.update(value=>((value={...value}).disabled=!!hidden&&options.disabled,value))})}},{position:"bottom"},field),field))}function disableWhen(options){return rawConfig(field=>(mergeHooksFn({allFieldsResolved:field=>{options.listen(options=>valueChangeFn(field,options),field).subscribe(disabled=>{field.formConfig().disabled!==disabled&&field.formConfig.update(value=>({...value,disabled:disabled}))})}},{position:"bottom"},field),field))}function topClass(className,merge){return rawConfig(rawField=>{mergeHooksFn({fieldResolved:field=>{let wrappers=field.wrappers();wrappers?.length?"string"==typeof wrappers[0]?wrappers[0]={type:wrappers[0],attributes:{class:clsx(className)}}:wrappers[0]={...wrappers[0],attributes:{...wrappers[0].attributes,class:merge?clsx(wrappers[0].attributes?.class,className):clsx(className)}}:field.attributes.update(attributes=>({...attributes,class:merge?clsx(attributes?.class,className):clsx(className)}))}},{position:"bottom"},rawField)})}function componentClass(className,merge){return rawConfig(field=>{field.attributes={...field.attributes,class:merge?clsx(field.attributes?.class,className):clsx(className)}})}function nonFieldControl(value=!0){return{kind:"metadata",type:"nonFieldControl",reference:nonFieldControl,value:value}}class CoreSchemaHandle extends BaseSchemaHandle{inputs;outputs;wrappers;attributes;alias;movePath;renderConfig;formConfig={};id;isLogicAnd=!1;isLogicOr=!1;isArray=!1;isTuple=!1;nonFieldControl=!1;hooks;lazySchema(schema){if(super.lazySchema(schema),this.parent){let wrappered=this.lazyWrapped;if(this.parent.isArray)this.parent.arrayChild=wrappered;else{let index=this.parent.children.findIndex(item=>item===this);this.parent.children[index]=wrappered}wrappered.parent=this.parent,wrappered.key=this.key}}arraySchema(schema){if(!this.isObjectControl){this.isArray=!0;let sh=new this.globalConfig.handle(this.globalConfig,this,schema);sh.parent=this,this.arrayChild=sh,convertSchema(schema.item,sh)}}defaultSchema(schema){this.defaultValue=schema.literal}tupleDefault(schema){super.tupleDefault(schema),this.isTuple=!0}enumSchema(schema){this.props??={},this.props.options??=schema.options}intersectBefore(schema){this.childrenAsVirtualGroup?"intersect"===this.type&&(this.type="intersect-group"):this.isLogicAnd=!0}logicItemSchema(schema,index,type){let sh=new this.globalConfig.handle(this.globalConfig,this,schema);this.childrenAsVirtualGroup||(sh.key=index),sh.setParent(this),convertSchema(schema,sh)}unionBefore(schema){this.childrenAsVirtualGroup||(this.isLogicOr=!0)}beforeSchemaType(schema){super.beforeSchemaType(schema),this.formConfig.required=!this.undefinedable&&!this.nullable}voidSchema(schema){this.nonFieldControl=!0}metadataDefaulthandle(metadata,environments){switch(metadata.type){case"viewRawConfig":metadata.value(this,this.globalConfig.context);break;case"layout":this.movePath=metadata.value.keyPath,this.priority=metadata.value.priority;break;case"nonFieldControl":this.nonFieldControl=metadata.value}}end(schema){super.end(schema),this.formConfig.defaultValue=this.defaultValue}}function convert(obj,options){let buildOptions={form$$:computed(()=>buildOptions.resolvedField$()?.form.control),resolvedField$:signal(void 0),context:computed(()=>options.context)},injector=Injector.create({providers:[{provide:PI_FORM_BUILDER_OPTIONS_TOKEN,useValue:buildOptions},{provide:PI_VIEW_CONFIG_TOKEN,useValue:options.fieldGlobalConfig},options.builder,{provide:EnvironmentInjector,useFactory:()=>injector}],parent:options.injector});return options.registerOnDestroy?.(()=>{injector.get(EnvironmentInjector).destroy()}),convertCore(obj,item=>(injector.get(options.builder).buildRoot({field:item,resolvedField$:buildOptions.resolvedField$}),buildOptions.resolvedField$()),{...options,handle:options?.handle??CoreSchemaHandle})}let NFCSchema=v.optional(v.void());export{AbstractControl,CoreSchemaHandle,FieldArray,FieldControl,FieldGroup,FieldLogicGroup,FormBuilder,INVALID,NFCSchema,PENDING,PI_FORM_BUILDER_ALIAS_MAP,PI_FORM_BUILDER_OPTIONS_TOKEN,PI_VIEW_CONFIG_TOKEN,SortedArray,VALID,arrayStartsWith,asyncInputMerge,clone,componentClass,convert,disableWhen,effectListen,formConfig,hideWhen,isArray,isFieldArray,isFieldControl,isFieldGroup,isFieldLogicGroup,isGroup,layout,mergeHooks,mergeHooksFn,mergeOutputFn,mergeOutputs,nonFieldControl,outputChange,outputChangeFn,patchAsyncAttributes,patchAsyncFn,patchAsyncInputs,patchAsyncProps,patchAttributes,patchHooks,patchInputs,patchOutputs,patchProps,patchWrappers,rawConfig,removeAttributes,removeHooks,removeInputs,removeOutputs,removeProps,removeWrappers,renderConfig,setAlias,setAttributes,setComponent,setHooks,setInputs,setOutputs,setProps,setWrappers,toArray,toObservable,topClass,unWrapSignal$1 as unWrapSignal,valueChange,valueChangeFn};
1
+ import{effect,inject,Injector,untracked,DestroyRef,isSignal,signal,computed,linkedSignal,InjectionToken,EnvironmentInjector}from"@angular/core";import*as v from"valibot";import{deepEqual}from"fast-equals";import{BehaviorSubject,isObservable,Subject,combineLatest,startWith,skip,map}from"rxjs";import rfdc from"rfdc";import{createRawConfig,BaseSchemaHandle,convertSchema,convertCore}from"@piying/valibot-visit";export{asControl,asVirtualGroup,changeObject,condition,getDefaults,getSchemaByIssuePath,getSchemaMetadata}from"@piying/valibot-visit";import clsx from"clsx";function arrayStartsWith(list,parts){return(Array.isArray(parts)?parts:[parts]).every((item,index)=>item===list[index])}function effectListen(listen,fn,options){let first=!0,oldValue=listen();return effect(()=>{let currentValue=listen();if(first){first=!1,deepEqual(oldValue,currentValue)||fn();return}return fn()},options)}function toObservable(listen,source,options){let injector=options?.injector??inject(Injector),subject=new BehaviorSubject(source()),watcher=effectListen(listen,()=>{let value;try{value=source()}catch(err){untracked(()=>subject.error(err));return}untracked(()=>subject.next(value))},{injector,manualCleanup:!0});return injector.get(DestroyRef).onDestroy(()=>{watcher.destroy(),subject.complete()}),subject.asObservable()}let clone=rfdc({proto:!1,circles:!1});function unWrapSignal$1(value){return isSignal(value)?value():value}function toArray(input){return void 0===input||Array.isArray(input)?input:[input]}class SortedArray extends Array{#compareFn;constructor(compareFn){super(),this.#compareFn=compareFn}push(...items){let result=super.push(...items);return this.sort(this.#compareFn),result}}function createViewControlLink(fieldControl,cva,injector){let pendingValue,pendingChange=!1;cva.registerOnChange(value=>{fieldControl().disabled$$()||(pendingValue=value,pendingChange=!0,"change"===fieldControl().updateOn$$()&&fieldControl().viewValueChange(value))}),cva.registerOnTouched(()=>{fieldControl().markAsTouched(),pendingChange&&"blur"===fieldControl().updateOn$$()&&(fieldControl().viewValueChange(pendingValue),pendingChange=!1)});let disposeList=[],ref=effect(()=>{let value=fieldControl().modelValueToViewValue$$();untracked(()=>{cva.writeValue(value)})},{injector:injector});if(cva.writeValue(fieldControl().modelValueToViewValue$$()),disposeList.push(()=>ref.destroy()),cva.setDisabledState){let disabledRef=effect(()=>{let value=fieldControl().disabled$$();untracked(()=>{cva.setDisabledState(value)})},{injector:injector});cva.setDisabledState(fieldControl().disabled$$()),disposeList.push(()=>disabledRef.destroy())}return disposeList}function isPromise(obj){return!!obj&&"function"==typeof obj.then}let ValidatorPending=Symbol("PENDING");function shortCircuitTrue(value){return value}let VALID="VALID",INVALID="INVALID",PENDING="PENDING";class AbstractControl{emptyValue$$=computed(()=>clone(this.config$().emptyValue));shouldInclude$$=computed(()=>this.valueNoError$$()&&(!this.selfDisabled$$()||this.selfDisabled$$()&&"reserve"===this.config$().disabledValue));injector;selfDisabled$$=computed(()=>this.config$?.().disabled??!1);selfEnabled$$=computed(()=>!this.selfDisabled$$());disabled$$=computed(()=>(this.parent?.disabled$$()||this.selfDisabled$$())??!1);enabled$$=computed(()=>!this.disabled$$());get disabled(){return this.disabled$$()}get enabled(){return!this.disabled$$()}enable(){this.config$.update(config=>({...config={...config,disabled:!1},disabled:!1}))}disable(){this.config$.update(config=>({...config,disabled:!0}))}selfTouched$=signal(!1);touched$$=computed(()=>this.reduceChildren(this.selfTouched$(),(child,value)=>value||child.touched$$(),shortCircuitTrue));get touched(){return untracked(this.touched$$)}get untouched(){return!untracked(this.touched$$)}selfDirty$=signal(!1);dirty$$=computed(()=>this.reduceChildren(this.selfDirty$(),(child,value)=>value||child.dirty$$(),shortCircuitTrue));get dirty(){return untracked(this.dirty$$)}get pristine(){return!untracked(this.dirty$$)}#validators$$=computed(()=>this.config$().validators??[]);#asyncValidators$$=computed(()=>this.config$().asyncValidators??[]);resetIndex$=signal(0);syncError$=linkedSignal(computed(()=>{if(this.disabled$$())return;this.resetIndex$(),this.value$$();let result=this.#validators$$().reduce((obj,item)=>{let result=untracked(()=>item(this));return result&&(obj={...obj,...result}),obj},{}),schemaResult=this.#schemaCheck$$();return schemaResult.success?Object.keys(result).length?result:void 0:{...result,valibot:schemaResult.issues}},{equal:()=>!1}));asyncErrorRes$$=computed(()=>{let result=this.#asyncValidators$$();if(0===result.length)return;this.resetIndex$(),this.value$$();let dataList=result.map(item=>untracked(()=>(function(input){if(isPromise(input)){let value$=signal(ValidatorPending);return input.then(value=>{value$.set({value})}),value$}if(!isObservable(input))return input;let value$=signal(ValidatorPending);return input.subscribe({next:value=>{value$.set({value})},error:error=>{value$.set({error})}}),value$})(item(this))));return computed(()=>{let params=dataList.map(item=>item()),pendingCount=0,errorResult=params.reduce((obj,item)=>item===ValidatorPending?(pendingCount++,obj):"value"in item?{...obj,...item.value}:{...obj,error:item.error},{});return Object.keys(errorResult).length?errorResult:pendingCount?ValidatorPending:void 0})});asyncError$$=computed(()=>{if(this.disabled$$())return;let ref=this.asyncErrorRes$$();if(ref){let result=ref();return result===ValidatorPending?PENDING:result}});rawError$$=computed(()=>{if(this.disabled$$())return;let syncError=this.syncError$(),asyncError=this.asyncError$$();return asyncError===PENDING?PENDING:syncError&&asyncError?{...syncError,...asyncError}:syncError||asyncError?syncError||asyncError:void 0});valueNoError$$=computed(()=>void 0===this.rawError$$());get errors(){let error=this.rawError$$();return error===PENDING?void 0:error}_parent;get parent(){return this._parent}get value(){return this.value$$()}required$$=computed(()=>this.config$().required);schemaParser;constructor(rawSchema,injector){this.injector=injector,this.schemaParser=v.safeParser(rawSchema)}#schemaCheck$$=computed(()=>this.schemaParser(this.value$$()));setParent(parent){this._parent=parent}get valid(){return this.status$$()===VALID}get invalid(){return this.status$$()===INVALID}get pending(){return this.status$$()===PENDING}selfUpdateOn$$=computed(()=>this.config$?.().updateOn);updateOn$$=computed(()=>(this.selfUpdateOn$$()||this.parent?.updateOn$$())??"change");markAsTouched(){this.selfTouched$.set(!0)}markAllAsDirty(){this.markAsDirty(),this._forEachChild(control=>control.markAllAsDirty())}markAllAsTouched(){this.markAsTouched(),this._forEachChild(control=>control.markAllAsTouched())}markAsUntouched(){this.selfTouched$.set(!1)}markAsDirty(){this.selfDirty$.set(!0)}markAsPristine(){this.selfDirty$.set(!1)}getRawValue(){return this.value}get(path){let currPath=path;return null==currPath||(Array.isArray(currPath)||(currPath=currPath.split(".")),0===currPath.length)?null:currPath.reduce((control,name)=>control&&control.find(name),this)}get root(){let x=this;for(;x._parent;)x=x._parent;return x}config$=signal({});initConfig(config){this.config$=config}find(name){return null}setControl(name,control){}reduceChildren(initialValue,fn,shortCircuit){let childrenMap=this.children$$?.();if(!childrenMap)return initialValue;let value=initialValue;for(let child of childrenMap){if(shortCircuit?.(value))break;value=fn(child,value)}return value}#valueChange;get valueChanges(){return this.#valueChange??(this.#valueChange=toObservable(computed(()=>({value:this.value$$(),disabled:this.disabled$$()})),this.value$$,{injector:this.injector}))}status$$=computed(()=>{if(this.disabled$$())return VALID;if(this.rawError$$())if(this.rawError$$()!==PENDING)return INVALID;else return PENDING;return this.reduceChildren(VALID,(child,value)=>value===INVALID||child.status$$()===INVALID?INVALID:value===PENDING||child.status$$()===PENDING?PENDING:VALID,v=>v===INVALID)});#statusChange;get statusChanges(){return this.#statusChange??(this.#statusChange=toObservable(this.status$$,this.status$$,{injector:this.injector}))}}class FieldArray extends AbstractControl{#deletionMode$$=computed(()=>this.config$().deletionMode??"shrink");value$$=computed(()=>{let list=[];for(let control of this.controls$())if(control&&control.shouldInclude$$())list.push(control.value$$());else{if("shrink"===this.#deletionMode$$())continue;"mark"===this.#deletionMode$$()&&list.push(void 0)}return 0===list.length?this.emptyValue$$():list});children$$=computed(()=>this.controls$());controls$=signal([]);get controls(){return this.controls$()}removeAt(index){let adjustedIndex=this._adjustIndex(index);this.controls$()[adjustedIndex]&&this.controls$.update(list=>((list=list.slice()).splice(adjustedIndex,1),list))}setControl(index,control){let adjustedIndex=this._adjustIndex(index);this.controls$.update(list=>((list=list.slice())[adjustedIndex]=control,list)),control.setParent(this)}get length(){return this.controls$().length}reset(value=[]){this._forEachChild((control,index)=>{control.reset(value[index])})}getRawValue(){return this.controls$().map(control=>control.getRawValue())}clear(){this.controls$().length<1||this.controls$.update(()=>[])}_adjustIndex(index){return index<0?Math.max(index+this.length,0):index}_forEachChild(cb){this.controls$().forEach((control,index)=>{control&&cb(control,index)})}find(name){return this.controls$()[this._adjustIndex(name)]}beforeUpdateList=[];updateValue(value=[]){deepEqual(value,this.value$$())||(this.beforeUpdateList.forEach(item=>item(value)),this.controls$().forEach((control,i)=>{control.updateValue(value[i])}))}}class FieldControl extends AbstractControl{children$$;#viewIndex=0;viewIndex$=signal(0);modelValue$=signal(void 0);modelValueToViewValueOrigin$$=computed(()=>{let viewValue=this.modelValue$(),toView=this.config$?.().transfomer?.toView;return toView?toView(viewValue,this):viewValue});modelValueToViewValue$$=computed(()=>(this.viewIndex$(),this.modelValueToViewValueOrigin$$()),{equal:()=>!1});value$$=signal(void 0);reset(formState=this.config$().defaultValue){this.updateValue(formState,!0),this.markAsPristine(),this.markAsUntouched()}_forEachChild(cb){}#initInput=!0;#viewSubject$$=computed(()=>{let subject=new Subject;return this.injector.get(DestroyRef).onDestroy(()=>{subject.complete()}),subject.pipe(this.config$().pipe.toModel).subscribe(value=>{untracked(()=>{this.#viewValueChange(value)})}),subject});#viewValueChange(value){this.#viewIndex++;let toModel=this.config$?.().transfomer?.toModel,originValue=toModel?toModel(value,this):value,transfomered=this.schemaParser(originValue);transfomered.success?(this.value$$.set(transfomered.output),this.syncError$.set(void 0)):this.syncError$.set({valibot:transfomered.issues}),this.markAllAsDirty()}viewValueChange(value){this.config$().pipe?.toModel?this.#viewSubject$$().next(value):this.#viewValueChange(value)}updateValue(value,force){if(force&&(this.#viewIndex++,this.viewIndex$.set(this.#viewIndex),this.resetIndex$.update(a=>a+1),this.#initInput=!0),this.#initInput){this.#initInput=!1,(void 0!==value&&!deepEqual(value,this.value$$())||force)&&(this.modelValue$.set(value),this.value$$.set(value));return}deepEqual(value,this.value$$())||(this.viewIndex$.set(this.#viewIndex),this.modelValue$.set(value),this.value$$.set(value))}initConfig(config){super.initConfig(config),"defaultValue"in this.config$()&&(this.modelValue$.set(this.config$().defaultValue),this.value$$.set(this.config$().defaultValue))}}class FieldLogicGroup extends FieldArray{activateIndex$=signal(0);type=signal("and");activateControl$=signal(void 0);value$$=computed(()=>this.getValue(!1));getActivateControls(){let list;if(this.activateControl$())list=this.activateControl$();else if("and"===this.type())list=this.controls$();else if("or"===this.type())list=[this.controls$()[this.activateIndex$()]];else throw Error("");return list}getValue(rawData){let controls=rawData?this.getActivateControls():this.getActivateControls().filter(control=>control.shouldInclude$$()),control=controls[0];if(0===controls.length)return this.emptyValue$$();if(1===controls.length)return control.value;let result=controls.reduce((obj,control)=>({...obj,...control.value$$()}),{});return Object.keys(result).length?result:this.emptyValue$$()}getRawValue(){return this.getValue(!0)}updateValue(value){deepEqual(value,this.value$$())||this.controls$().forEach((control,i)=>{control.updateValue(value)})}}function isFieldGroup(input){return input instanceof FieldGroup}function isFieldArray(input){return input instanceof FieldArray}function isFieldControl(input){return input instanceof FieldControl}function isFieldLogicGroup(input){return input instanceof FieldLogicGroup}class FieldGroup extends AbstractControl{value$$=computed(()=>{let result={...this._reduceChildren({},(acc,control,name)=>(control.shouldInclude$$()&&(acc[name]=control.value),acc)),...this.looseValue$$()};return Object.keys(result).length?result:this.emptyValue$$()});children$$=computed(()=>Object.values(this.controls$()));controls$=signal({});get controls(){return this.controls$()}registerControl(name,control){return this.controls$()[name]?this.controls$()[name]:(this.controls$.update(controls=>({...controls,[name]:control})),control.setParent(this),control)}removeControl(name){this.controls$()[name]&&this.controls$.update(controls=>(controls={...controls},delete controls[name],controls))}setControl(name,control){this.controls$.update(controls=>(controls={...controls},delete controls[name],controls)),control&&this.registerControl(name,control)}reset(value={}){this._forEachChild((control,name)=>{control.reset(value?value[name]:void 0)})}getRawValue(){return this._reduceChildren({},(acc,control,name)=>(acc[name]=control.getRawValue(),acc))}_forEachChild(cb){Object.keys(this.controls$()).forEach(key=>{let control=this.controls$()[key];control&&cb(control,key)})}_reduceChildren(initValue,fn){let res=initValue;return this._forEachChild((control,name)=>{res=fn(res,control,name)}),res}find(name){return this.controls$()[name]}looseValue$$=computed(()=>{let initValue=this.#initValue$();if(!initValue||isFieldLogicGroup(this.parent))return{};let controls=this.controls$(),looseValue={};for(let key in initValue)key in controls||(looseValue[key]=initValue[key]);return looseValue});#initValue$=signal({});setInitValue(obj){this.#initValue$.set(obj)}updateValue(value){if(!deepEqual(value,this.value$$())){for(let key in this.controls$())this.controls$()[key].updateValue(value?.[key]);if(!deepEqual(value,this.#initValue$()))return void this.setInitValue(value)}}}let PI_VIEW_CONFIG_TOKEN=new InjectionToken("PI_VIEW_CONFIG"),PI_FORM_BUILDER_OPTIONS_TOKEN=new InjectionToken("PI_FORM_BUILDER_OPTIONS"),PI_FORM_BUILDER_ALIAS_MAP=new InjectionToken("PI_FORM_BUILDER_ALIAS_MAP");function isGroup(schema){return schema.isGroup}function isArray(schema){return schema.isArray}function unWrapSignal(value){return isSignal(value)?value():value}class ParentMap extends Map{parent;constructor(parent){super(),this.parent=parent}get(key){let result=super.get(key);return void 0===result?this.parent?.get(key):result}}function fieldQuery(key,field,aliasMap,root,aliasNotFoundFn){let list,keyPath=Array.isArray(key)?key:"number"==typeof key?[key]:key.split("."),firstPath=keyPath[0];if("#"===firstPath)field=root,list=[{field:root,level:1}];else if(".."===firstPath)list=[{field:field.parent,level:1}];else if("string"==typeof firstPath&&firstPath.startsWith("@")){let queryField=aliasMap.get(firstPath.slice(1));!queryField&&aliasNotFoundFn&&(queryField=aliasNotFoundFn(firstPath.slice(1),field)),list=[{field:queryField,level:1}]}else field.fieldGroup?list=(function* groupGenerator(list){for(let item of list)!item.keyPath?.length&&item.fieldGroup?.().length?yield*groupGenerator(item.fieldGroup()):item.keyPath?.length&&(yield item)})(field.fieldGroup()).filter(field=>field.keyPath&&arrayStartsWith(keyPath,field.keyPath)).map(field=>({field:field,level:field.keyPath?.length})):field.fieldArray&&(list=field.fieldArray().filter(field=>field.keyPath&&arrayStartsWith(keyPath,field.keyPath)).map(field=>({field:field,level:field.keyPath?.length})));if(list)for(let item of list){if(keyPath.length===item.level)return item.field;let res=item.field.get(keyPath.slice(item.level),aliasNotFoundFn);if(res)return res}}class FormBuilder{#scopeMap=inject(PI_FORM_BUILDER_ALIAS_MAP,{optional:!0})??new ParentMap;#options=inject(PI_FORM_BUILDER_OPTIONS_TOKEN);#injector=inject(Injector);#envInjector=inject(EnvironmentInjector);#globalConfig=inject(PI_VIEW_CONFIG_TOKEN,{optional:!0})??void 0;#allFieldInitHookList=[];buildRoot(item){this.#buildControl({type:"root",field:{fullPath:[]},form:void 0,resolvedField$:item.resolvedField$,append:()=>{}},item.field,0),this.allFieldInitHookCall()}allFieldInitHookCall(){let list=this.#allFieldInitHookList;this.#allFieldInitHookList=[],list.forEach(fn=>fn())}#buildField(item){"group"===item.type?this.#buildGroup(item):this.#buildArray(item)}afterResolveConfig(rawConfig,config){}#buildControl(parent,field,index){var parentForm,key,injector;let viewDefaultConfig,define,control,FieldClass,control1,type=field.type;if(type){let result=this.#resolveComponent(type);viewDefaultConfig=result.defaultConfig,define=result.define}let mergeStrategy=this.#globalConfig?.defaultConfigMergeStrategy,inputs=this.configMerge([this.#globalConfig?.defaultConfig?.inputs,viewDefaultConfig?.inputs,field.inputs],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.inputs??"merge"),outputs=this.configMerge([this.#globalConfig?.defaultConfig?.outputs,viewDefaultConfig?.outputs,field.outputs],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.outputs??"merge"),attributes=this.configMerge([this.#globalConfig?.defaultConfig?.attributes,viewDefaultConfig?.attributes,field.attributes],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.attributes??"merge"),wrappers1=this.configMergeRaw([this.#globalConfig?.defaultConfig?.wrappers,viewDefaultConfig?.wrappers,field.wrappers],!0,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.wrappers??"replace"),wrappers=this.#resolveWrappers(wrappers1),props=this.configMerge([this.#globalConfig?.defaultConfig?.props,viewDefaultConfig?.props,field.props],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.props??"merge"),formConfig$=this.configMerge([this.#globalConfig?.defaultConfig?.formConfig,viewDefaultConfig?.formConfig,field.formConfig],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.formConfig??"merge"),renderConfig=this.configMerge([this.#globalConfig?.defaultConfig?.renderConfig,viewDefaultConfig?.renderConfig,field.renderConfig],!1,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.renderConfig??"merge"),keyPath=field.key;isFieldLogicGroup(parent.form)?keyPath??=parent.form.controls$().length:isFieldArray(parent.form)&&(keyPath??=index);let isRoot="root"===parent.type;!field.nonFieldControl&&(void 0!==keyPath||isRoot)&&(parentForm=parent.form,key=keyPath,injector=this.#injector,FieldClass=field.isLogicAnd||field.isLogicOr?FieldLogicGroup:isGroup(field)?FieldGroup:isArray(field)||field.isTuple?FieldArray:FieldControl,isRoot?(isFieldLogicGroup(control1=new FieldClass(field.sourceSchema,injector))&&control1.type.set(field.isLogicAnd?"and":"or"),control1.initConfig(formConfig$)):(control1=parentForm.get([key]))||(isFieldLogicGroup(control1=new FieldClass(field.sourceSchema,injector))&&control1.type.set(field.isLogicAnd?"and":"or"),parentForm.setControl?.(key,control1),control1.initConfig(formConfig$)),control=control1);let rootForm=this.#options.form$$,resolvedConfig={id:field.id,keyPath:toArray(keyPath),get fullPath(){return[...resolvedConfig.parent.fullPath,...resolvedConfig.keyPath??[]]},form:{parent:parent.form,control:control??(isGroup(field)?parent.form:void 0),get root(){return rootForm()}},get:(keyPath,aliasNotFoundFn)=>untracked(()=>fieldQuery(keyPath,resolvedConfig,this.#scopeMap,this.#options.resolvedField$(),aliasNotFoundFn)),parent:parent.field,origin:field,renderConfig:renderConfig,formConfig:formConfig$,props,context:this.#options.context(),priority:field.priority,hooks:field.hooks,alias:field.alias,inputs:inputs,outputs:outputs,attributes,define:define?{...define,inputs,outputs,attributes}:void 0,wrappers};return resolvedConfig=this.afterResolveConfig(field,resolvedConfig)??resolvedConfig,field.movePath?this.#moveViewField(field.movePath,resolvedConfig):parent.append(resolvedConfig),field.alias&&this.#scopeMap.set(field.alias,resolvedConfig),resolvedConfig.hooks?.fieldResolved?.(resolvedConfig),isRoot&&parent.resolvedField$.set(resolvedConfig),isGroup(field)||field.isLogicAnd||field.isLogicOr||field.isTuple?(resolvedConfig.fieldGroup=signal(new SortedArray((a,b)=>a.priority-b.priority)),this.#buildField({type:"group",fields:field.children,field:resolvedConfig,form:control||parent.form,append:field=>{resolvedConfig.fieldGroup().push(field)}})):isArray(field)&&this.#buildField({type:"array",templateField:field.arrayChild,field:resolvedConfig,form:control,append:field=>{}}),resolvedConfig.hooks?.allFieldsResolved&&this.#allFieldInitHookList.push(()=>{resolvedConfig.hooks.allFieldsResolved(resolvedConfig)}),resolvedConfig}#buildGroup(groupItem){for(let index=0;index<groupItem.fields.length;index++){let field=groupItem.fields[index];this.#buildControl(groupItem,field,index)}let field=groupItem.field;field.hooks?.afterChildrenInit?.(field)}createArrayItem(parent,field,index){let Builder=this.constructor,injector=Injector.create({providers:[Builder,{provide:PI_FORM_BUILDER_ALIAS_MAP,useValue:new ParentMap(this.#scopeMap)},{provide:EnvironmentInjector,useFactory:()=>injector}],parent:this.#envInjector});this.#envInjector.get(DestroyRef).onDestroy(()=>{result.injector?.destroy()});let instance=injector.get(Builder),result=instance.#buildControl(parent,field,index);return this.#allFieldInitHookList.push(()=>instance.allFieldInitHookCall()),result.injector=injector.get(EnvironmentInjector),result}#buildArray(arrayItem){let{templateField,form}=arrayItem;arrayItem.field.action={set:(value,index)=>{untracked(()=>{index="number"==typeof index?index:arrayItem.field.fieldArray?.().length??0;let result=this.createArrayItem(arrayItem,templateField,index),list=[...arrayItem.field.fieldArray()];list[index]=result,arrayItem.field.fieldArray.set(list),this.allFieldInitHookCall(),result.form.control.updateValue(value)})},remove:index=>{untracked(()=>{let list=[...arrayItem.field.fieldArray()],[deletedItem]=list.splice(index,1);arrayItem.field.fieldArray.set(list),form.removeAt(index),deletedItem&&(deletedItem.injector.destroy(),deletedItem.injector=void 0)})}},arrayItem.field.fieldArray=signal([]),arrayItem.field.hooks?.afterChildrenInit?.(arrayItem.field),form.beforeUpdateList.push(input=>{let controlLength=form.controls$().length;if(controlLength<input.length){let list=arrayItem.field.fieldArray().slice();for(let index=controlLength;index<input.length;index++){let result=this.createArrayItem(arrayItem,arrayItem.templateField,index);list[index]=result}arrayItem.field.fieldArray.set(list)}else if(input.length<controlLength){let list=arrayItem.field.fieldArray().slice();for(let index=arrayItem.field.fieldArray().length-1;index>=input.length;index--){let[deletedItem]=list.splice(index,1);form.removeAt(index),deletedItem&&(deletedItem.injector?.destroy(),deletedItem.injector=void 0)}arrayItem.field.fieldArray.set(list)}this.allFieldInitHookCall()})}#resolveComponent(type){let define,defaultConfig;if("string"!=typeof type)return{define:{type:type}};{let config=this.#globalConfig?.types?.[type];if(!config)throw Error(`define:未注册[${type}]`);if(defaultConfig=config,Object.keys(config).length)return define={...config},{define:{...config},defaultConfig}}return{define,defaultConfig}}configMergeRaw(list,isArray,strategy){return clone(isArray?"merge"===strategy?list.filter(Boolean).flat().map(item=>unWrapSignal(item)):list.reduce((data,item)=>unWrapSignal(item)??data,[]):"merge"===strategy?list.reduce((obj,item)=>({...obj,...unWrapSignal(item)}),{}):list.reduce((data,item)=>unWrapSignal(item)??data,{}))}configMerge(list,isArray,strategy){return signal(this.configMergeRaw(list,isArray,strategy))}#moveViewField(key,inputField){let parent=fieldQuery(key,inputField,this.#scopeMap,this.#options.resolvedField$(),(name,field)=>{let rootForm=this.#options.form$$,aliasField={alias:name,parent:field,get fullPath(){return field.fullPath},form:{parent:field.form.control??field.form.parent,control:void 0,get root(){return rootForm()}},get:(keyPath,fn)=>fieldQuery(keyPath,aliasField,this.#scopeMap,this.#options.resolvedField$(),fn),fieldGroup:signal(new SortedArray((a,b)=>a.priority-b.priority)),priority:0,renderConfig:signal({}),wrappers:signal([])};if(this.#scopeMap.set(name,aliasField),inputField===field)throw Error(`添加位置不可为自身`);return field.fieldGroup().push(aliasField),aliasField});if(!parent)throw Error("移动视图项失败");let index=inputField.parent.fieldGroup?.().findIndex(item=>item===inputField);"number"==typeof index&&-1!==index&&inputField.parent.fieldGroup?.().splice(index,1);let newKeyPath=inputField.fullPath.slice(parent.fullPath.length);inputField.keyPath=newKeyPath,inputField.parent=parent,parent.fieldGroup().push(inputField)}#resolveWrappers(wrappers){let result=(wrappers??[]).map(wrapper=>{if("string"==typeof wrapper){let config=this.#globalConfig?.wrappers?.[wrapper];if(!config)throw Error(`wrapper:未注册[${wrapper}]`);return{...config,inputs:signal(config.inputs),attributes:signal(config.attributes)}}if("string"!=typeof wrapper.type)return{...wrapper,inputs:signal(wrapper.inputs),attributes:signal(wrapper.attributes)};{let config=this.#globalConfig?.wrappers?.[wrapper.type];if(!config)throw Error(`wrapper:未注册[${wrapper.type}]`);return{inputs:signal({...config.inputs,...wrapper.inputs}),outputs:{...config.outputs,...wrapper.outputs},attributes:signal({...config.attributes,...wrapper.attributes}),type:config.type}}});return signal(result)}}function layout(value){return{kind:"metadata",type:"layout",reference:layout,value:value}}let rawConfig=createRawConfig("viewRawConfig");function setComponent(type){return rawConfig(field=>{field.type=type})}let setHooks=hooks=>rawConfig(field=>{field.hooks=hooks}),patchHooks=hooks=>rawConfig(field=>{field.hooks={...field.hooks,...hooks}}),DefaultOptions$1={position:"bottom"};function mergeHooksFn(hooks,options,field){for(let key in field.hooks??={},hooks){let oldFn=field.hooks[key];field.hooks[key]=(...args)=>{"top"===options.position&&hooks[key](...args),oldFn?.(...args),"bottom"===options.position&&hooks[key](...args)}}}let mergeHooks=(hooks,options=DefaultOptions$1)=>rawConfig(field=>mergeHooksFn(hooks,options,field));function removeHooks(list){return rawConfig(field=>{let oldValue=field.hooks;oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.hooks=oldValue)})}function setInputs(inputs){return rawConfig(field=>{field.inputs=inputs})}function patchInputs(inputs){return rawConfig(field=>{field.inputs={...field.inputs,...inputs}})}function removeInputs(list){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.inputs);oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.inputs=oldValue)})}function asyncInputMerge(dataObj,data$){let signalObj={};Object.keys(dataObj).forEach(key=>{let result=dataObj[key];isPromise(result)?result.then(value=>{data$.update(lastData=>((lastData={...lastData})[key]=value,lastData))}):result&&"function"==typeof result.subscribe?result.subscribe({next:value=>{data$.update(lastData=>((lastData={...lastData})[key]=value,lastData))}}):isSignal(result)?signalObj[key]=result:data$.update(lastData=>((lastData={...lastData})[key]=result,lastData))});let signalKeyList=Object.keys(signalObj);return signalKeyList.length?linkedSignal(computed(()=>({...data$(),...signalKeyList.reduce((obj,key)=>({...obj,[key]:signalObj[key]()}),{})}))):data$}function patchAsyncFn(patchKey){return(dataObj,options)=>rawConfig(rawField=>{let inputList=Object.keys(dataObj),hookName=options?.hookName??"allFieldsResolved";return rawField[patchKey]={...rawField[patchKey],...inputList.reduce((obj,item)=>(obj[item]=rawField[patchKey]?.[item]??void 0,obj),{})},mergeHooksFn({[hookName]:field=>{field[patchKey]=asyncInputMerge(Object.entries(dataObj).reduce((obj,[key,value])=>(obj[key]=value(field),obj),{}),field[patchKey])}},{position:options?.addPosition??"bottom"},rawField)})}let patchAsyncInputs=patchAsyncFn("inputs");function setAttributes(attributes){return rawConfig(field=>{field.attributes=attributes})}function patchAttributes(attributes){return rawConfig(field=>{field.attributes={...field.attributes,...attributes}})}function removeAttributes(list){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.attributes);oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.attributes=oldValue)})}let patchAsyncAttributes=patchAsyncFn("attributes");function setProps(props){return rawConfig(field=>{field.props=props})}function patchProps(props){return rawConfig(field=>{field.props={...field.props,...props}})}function removeProps(list){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.props);oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.props=oldValue)})}let patchAsyncProps=patchAsyncFn("props");function setOutputs(outputs){return rawConfig(field=>{field.outputs=outputs})}function patchOutputs(outputs){return rawConfig(field=>{let oldValue=field.outputs;field.outputs={...oldValue,...outputs}})}function removeOutputs(list){return rawConfig(field=>{let oldValue=field.outputs;oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.outputs=oldValue)})}function mergeOutputFn(field,outputs,options){field.outputs.update(originOutputs=>{for(let key in originOutputs={...originOutputs},outputs){let oldFn=originOutputs[key];originOutputs[key]=(...args)=>{"top"===options.position&&outputs[key](...args,field),oldFn?.(...args,field),"bottom"===options.position&&outputs[key](...args,field)}}return originOutputs})}let DefaultOptions={position:"bottom"},mergeOutputs=(outputs,options=DefaultOptions)=>rawConfig(field=>{mergeHooksFn({allFieldsResolved:field=>{mergeOutputFn(field,outputs,options)}},{position:"bottom"},field)});function outputChangeFn(rawField,fn){mergeHooksFn({allFieldsResolved:field=>fn(list=>{let resultList=[];for(let item of list){let emitField=item.list?field.get(item.list):field,subject=new Subject;mergeOutputFn(field,{[item.output]:(...args)=>{subject.next(args)}},{position:"bottom"}),resultList.push({subject,field:emitField})}return combineLatest(resultList.map(({subject})=>subject.pipe(startWith(void 0)))).pipe(skip(1),map(list=>({list,field,listenFields:resultList.map(item=>item.field)})))})},{position:"bottom"},rawField)}function outputChange(fn){return rawConfig(field=>outputChangeFn(field,fn))}function setWrappers(wrappers){return rawConfig(field=>{field.wrappers=wrappers})}let defaultValue={position:"tail"};function patchWrappers(wrappers,options=defaultValue){return rawConfig(field=>{let list=toArray(wrappers);field.wrappers??=[],"tail"===options.position?field.wrappers.push(...list):field.wrappers.unshift(...list)})}function removeWrappers(list){return rawConfig(field=>{if(!field.wrappers)return;let wrappers=field.wrappers;for(let i=0;i<list.length;i++){let name=list[i];for(let j=0;j<wrappers.length;j++){let config=wrappers[j];if(("string"==typeof config?config:config.type)===name){wrappers.splice(j,1);break}}}field.wrappers=wrappers})}function setAlias(alias){return rawConfig(field=>{field.alias=alias})}function renderConfig(type){return rawConfig(field=>{field.renderConfig=type})}function formConfig(config){return rawConfig(field=>{field.formConfig={...field.formConfig,...config}})}let DefaultSelfList=[void 0];function valueChangeFn(field,input={}){return combineLatest((input.list??DefaultSelfList).map(keyPath=>keyPath?field.get(keyPath).form.control:field.form.control).map(control=>input.skipInitValue?control.valueChanges.pipe(skip(1)):control.valueChanges)).pipe(map(list=>({list,field,listenFields:list})))}function valueChange(listenFn){return rawConfig(field=>{mergeHooksFn({allFieldsResolved:field=>{listenFn(options=>valueChangeFn(field,options),field)}},{position:"bottom"},field)})}function hideWhen(options){return rawConfig(field=>(mergeHooksFn({allFieldsResolved:field=>{options.listen(options=>valueChangeFn(field,options),field).subscribe(hidden=>{field.renderConfig.update(value=>!!value.hidden!==hidden?{...value,hidden:hidden}:value),void 0!==options.disabled&&field.formConfig&&field.formConfig.update(value=>((value={...value}).disabled=!!hidden&&options.disabled,value))})}},{position:"bottom"},field),field))}function disableWhen(options){return rawConfig(field=>(mergeHooksFn({allFieldsResolved:field=>{options.listen(options=>valueChangeFn(field,options),field).subscribe(disabled=>{field.formConfig().disabled!==disabled&&field.formConfig.update(value=>({...value,disabled:disabled}))})}},{position:"bottom"},field),field))}function topClass(className,merge){return rawConfig(rawField=>{mergeHooksFn({fieldResolved:field=>{let wrappers=field.wrappers();wrappers?.length?wrappers[0].attributes.update(attributes=>({...attributes,class:merge?clsx(attributes?.class,className):clsx(className)})):field.attributes.update(attributes=>({...attributes,class:merge?clsx(attributes?.class,className):clsx(className)}))}},{position:"bottom"},rawField)})}function componentClass(className,merge){return rawConfig(field=>{field.attributes={...field.attributes,class:merge?clsx(field.attributes?.class,className):clsx(className)}})}function nonFieldControl(value=!0){return{kind:"metadata",type:"nonFieldControl",reference:nonFieldControl,value:value}}class CoreSchemaHandle extends BaseSchemaHandle{inputs;outputs;wrappers;attributes;alias;movePath;renderConfig;formConfig={};id;isLogicAnd=!1;isLogicOr=!1;isArray=!1;isTuple=!1;nonFieldControl=!1;hooks;lazySchema(schema){if(super.lazySchema(schema),this.parent){let wrappered=this.lazyWrapped;if(this.parent.isArray)this.parent.arrayChild=wrappered;else{let index=this.parent.children.findIndex(item=>item===this);this.parent.children[index]=wrappered}wrappered.parent=this.parent,wrappered.key=this.key}}arraySchema(schema){if(!this.isObjectControl){this.isArray=!0;let sh=new this.globalConfig.handle(this.globalConfig,this,schema);sh.parent=this,this.arrayChild=sh,convertSchema(schema.item,sh)}}defaultSchema(schema){this.defaultValue=schema.literal}tupleDefault(schema){super.tupleDefault(schema),this.isTuple=!0}enumSchema(schema){this.props??={},this.props.options??=schema.options}intersectBefore(schema){this.childrenAsVirtualGroup?"intersect"===this.type&&(this.type="intersect-group"):this.isLogicAnd=!0}logicItemSchema(schema,index,type){let sh=new this.globalConfig.handle(this.globalConfig,this,schema);this.childrenAsVirtualGroup||(sh.key=index),sh.setParent(this),convertSchema(schema,sh)}unionBefore(schema){this.childrenAsVirtualGroup||(this.isLogicOr=!0)}beforeSchemaType(schema){super.beforeSchemaType(schema),this.formConfig.required=!this.undefinedable&&!this.nullable}voidSchema(schema){this.nonFieldControl=!0}metadataDefaulthandle(metadata,environments){switch(metadata.type){case"viewRawConfig":metadata.value(this,this.globalConfig.context);break;case"layout":this.movePath=metadata.value.keyPath,this.priority=metadata.value.priority;break;case"nonFieldControl":this.nonFieldControl=metadata.value}}end(schema){super.end(schema),this.formConfig.defaultValue=this.defaultValue}}function convert(obj,options){let buildOptions={form$$:computed(()=>buildOptions.resolvedField$()?.form.control),resolvedField$:signal(void 0),context:computed(()=>options.context)},injector=Injector.create({providers:[{provide:PI_FORM_BUILDER_OPTIONS_TOKEN,useValue:buildOptions},{provide:PI_VIEW_CONFIG_TOKEN,useValue:options.fieldGlobalConfig},options.builder,{provide:EnvironmentInjector,useFactory:()=>injector}],parent:options.injector});return options.registerOnDestroy?.(()=>{injector.get(EnvironmentInjector).destroy()}),convertCore(obj,item=>(injector.get(options.builder).buildRoot({field:item,resolvedField$:buildOptions.resolvedField$}),buildOptions.resolvedField$()),{...options,handle:options?.handle??CoreSchemaHandle})}let NFCSchema=v.optional(v.void());export{AbstractControl,CoreSchemaHandle,FieldArray,FieldControl,FieldGroup,FieldLogicGroup,FormBuilder,INVALID,NFCSchema,PENDING,PI_FORM_BUILDER_ALIAS_MAP,PI_FORM_BUILDER_OPTIONS_TOKEN,PI_VIEW_CONFIG_TOKEN,SortedArray,VALID,arrayStartsWith,asyncInputMerge,clone,componentClass,convert,createViewControlLink,disableWhen,effectListen,formConfig,hideWhen,isArray,isFieldArray,isFieldControl,isFieldGroup,isFieldLogicGroup,isGroup,layout,mergeHooks,mergeHooksFn,mergeOutputFn,mergeOutputs,nonFieldControl,outputChange,outputChangeFn,patchAsyncAttributes,patchAsyncFn,patchAsyncInputs,patchAsyncProps,patchAttributes,patchHooks,patchInputs,patchOutputs,patchProps,patchWrappers,rawConfig,removeAttributes,removeHooks,removeInputs,removeOutputs,removeProps,removeWrappers,renderConfig,setAlias,setAttributes,setComponent,setHooks,setInputs,setOutputs,setProps,setWrappers,toArray,toObservable,topClass,unWrapSignal$1 as unWrapSignal,valueChange,valueChangeFn};
package/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { WritableSignal, Signal, Injector, CreateEffectOptions, EffectRef, InjectionToken } from '@angular/core';
3
+ import * as rxjs from 'rxjs';
4
+ import { UnaryFunction, Observable } from 'rxjs';
3
5
  import * as _piying_valibot_visit from '@piying/valibot-visit';
4
6
  import { SchemaOrPipe, BaseSchemaHandle, LazySchema, DefaultSchema, TupleSchema, EnumSchema, IntersectSchema, UnionSchema, Schema, VoidSchema, MetadataAction, RawConfigActionCommon, ConvertOptions } from '@piying/valibot-visit';
5
7
  export { RawConfig, asControl, asVirtualGroup, changeObject, condition, getDefaults, getSchemaByIssuePath, getSchemaMetadata } from '@piying/valibot-visit';
6
8
  import * as v from 'valibot';
7
9
  import { BaseMetadata, ArraySchema, BaseSchema, BaseIssue, ErrorMessage, ArrayIssue } from 'valibot';
8
- import * as rxjs from 'rxjs';
9
- import { Observable } from 'rxjs';
10
10
  import * as _piying_view_angular_core from '@piying/view-angular-core';
11
11
  import { ClassValue } from 'clsx';
12
12
 
@@ -17,11 +17,14 @@ interface FieldTransformerConfig {
17
17
  }
18
18
  type LogicType = 'and' | 'or';
19
19
  type ArrayDeletionMode = 'shrink' | 'mark';
20
- interface FieldFormConfig {
20
+ interface FieldFormConfig<T = any> {
21
21
  disabled?: boolean;
22
22
  /** 删除时value应该如何处理 */
23
23
  disabledValue?: DisabledValueStrategy;
24
24
  transfomer?: FieldTransformerConfig;
25
+ pipe?: {
26
+ toModel?: UnaryFunction<Observable<any>, Observable<T>>;
27
+ };
25
28
  defaultValue?: any;
26
29
  validators?: ValidatorFn[];
27
30
  asyncValidators?: AsyncValidatorFn[];
@@ -56,6 +59,7 @@ declare const INVALID = "INVALID";
56
59
  declare const PENDING = "PENDING";
57
60
  type VALID_STATUS = typeof VALID | typeof INVALID | typeof PENDING;
58
61
  type FormHooks = 'change' | 'blur';
62
+ type AbstractControlParams = ConstructorParameters<typeof AbstractControl<any>>;
59
63
  declare abstract class AbstractControl<TValue = any> {
60
64
  #private;
61
65
  protected readonly emptyValue$$: Signal<any>;
@@ -87,11 +91,11 @@ declare abstract class AbstractControl<TValue = any> {
87
91
  get pristine(): boolean;
88
92
  protected resetIndex$: _angular_core.WritableSignal<number>;
89
93
  syncError$: _angular_core.WritableSignal<ValidationErrors | undefined>;
90
- asyncErrorRes$$: Signal<Signal<Record<string, any> | typeof ValidatorPending | undefined> | undefined>;
91
- asyncError$$: Signal<Record<string, any> | "PENDING" | undefined>;
92
- rawError$$: Signal<Record<string, any> | "PENDING" | undefined>;
94
+ asyncErrorRes$$: Signal<Signal<typeof ValidatorPending | Record<string, any> | undefined> | undefined>;
95
+ asyncError$$: Signal<"PENDING" | Record<string, any> | undefined>;
96
+ rawError$$: Signal<"PENDING" | ValidationErrors | undefined>;
93
97
  valueNoError$$: Signal<boolean>;
94
- get errors(): Record<string, any> | undefined;
98
+ get errors(): ValidationErrors | undefined;
95
99
  /** parent */
96
100
  private _parent?;
97
101
  get parent(): AbstractControl | undefined;
@@ -158,7 +162,8 @@ declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
158
162
  /** modelValue + viewValue => modelValue */
159
163
  value$$: WritableSignal<any>;
160
164
  reset(formState?: TValue): void;
161
- setViewValue(value: TValue | undefined): void;
165
+ /** view变更 */
166
+ viewValueChange(value: TValue | undefined): void;
162
167
  updateValue(value: any, force?: boolean): void;
163
168
  initConfig(config: any): void;
164
169
  }
@@ -262,6 +267,115 @@ declare class SortedArray<T> extends Array {
262
267
 
263
268
  type LazyImport<T> = () => Promise<T>;
264
269
 
270
+ interface ControlValueAccessor {
271
+ /**
272
+ * @description
273
+ * Writes a new value to the element.
274
+ *
275
+ * This method is called by the forms API to write to the view when programmatic
276
+ * changes from model to view are requested.
277
+ *
278
+ * @usageNotes
279
+ * ### Write a value to the element
280
+ *
281
+ * The following example writes a value to the native DOM element.
282
+ *
283
+ * ```ts
284
+ * writeValue(value: any): void {
285
+ * this._renderer.setProperty(this._elementRef.nativeElement, 'value', value);
286
+ * }
287
+ * ```
288
+ *
289
+ * @param obj The new value for the element
290
+ */
291
+ writeValue(obj: any): void;
292
+ /**
293
+ * @description
294
+ * Registers a callback function that is called when the control's value
295
+ * changes in the UI.
296
+ *
297
+ * This method is called by the forms API on initialization to update the form
298
+ * model when values propagate from the view to the model.
299
+ *
300
+ * When implementing the `registerOnChange` method in your own value accessor,
301
+ * save the given function so your class calls it at the appropriate time.
302
+ *
303
+ * @usageNotes
304
+ * ### Store the change function
305
+ *
306
+ * The following example stores the provided function as an internal method.
307
+ *
308
+ * ```ts
309
+ * registerOnChange(fn: (_: any) => void): void {
310
+ * this._onChange = fn;
311
+ * }
312
+ * ```
313
+ *
314
+ * When the value changes in the UI, call the registered
315
+ * function to allow the forms API to update itself:
316
+ *
317
+ * ```ts
318
+ * host: {
319
+ * '(change)': '_onChange($event.target.value)'
320
+ * }
321
+ * ```
322
+ *
323
+ * @param fn The callback function to register
324
+ */
325
+ registerOnChange(fn: any): void;
326
+ /**
327
+ * @description
328
+ * Registers a callback function that is called by the forms API on initialization
329
+ * to update the form model on blur.
330
+ *
331
+ * When implementing `registerOnTouched` in your own value accessor, save the given
332
+ * function so your class calls it when the control should be considered
333
+ * blurred or "touched".
334
+ *
335
+ * @usageNotes
336
+ * ### Store the callback function
337
+ *
338
+ * The following example stores the provided function as an internal method.
339
+ *
340
+ * ```ts
341
+ * registerOnTouched(fn: any): void {
342
+ * this._onTouched = fn;
343
+ * }
344
+ * ```
345
+ *
346
+ * On blur (or equivalent), your class should call the registered function to allow
347
+ * the forms API to update itself:
348
+ *
349
+ * ```ts
350
+ * host: {
351
+ * '(blur)': '_onTouched()'
352
+ * }
353
+ * ```
354
+ *
355
+ * @param fn The callback function to register
356
+ */
357
+ registerOnTouched(fn: any): void;
358
+ /**
359
+ * @description
360
+ * Function that is called by the forms API when the control status changes to
361
+ * or from 'DISABLED'. Depending on the status, it enables or disables the
362
+ * appropriate DOM element.
363
+ *
364
+ * @usageNotes
365
+ * The following is an example of writing the disabled property to a native DOM element:
366
+ *
367
+ * ```ts
368
+ * setDisabledState(isDisabled: boolean): void {
369
+ * this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
370
+ * }
371
+ * ```
372
+ *
373
+ * @param isDisabled The disabled status to set on the element
374
+ */
375
+ setDisabledState?(isDisabled: boolean): void;
376
+ }
377
+ declare function createViewControlLink(fieldControl: Signal<FieldControl>, cva: ControlValueAccessor, injector: Injector): (() => any)[];
378
+
265
379
  interface LayoutAction<TInput = unknown> extends BaseMetadata<TInput> {
266
380
  readonly type: 'layout';
267
381
  readonly reference: typeof layout;
@@ -367,7 +481,7 @@ declare function removeWrappers<T>(list: string[]): _piying_valibot_visit.RawCon
367
481
  declare function setAlias<T>(alias: string): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
368
482
 
369
483
  declare function renderConfig<T>(type: FieldRenderConfig): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
370
- declare function formConfig<T>(config: FieldFormConfig): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
484
+ declare function formConfig<T>(config: FieldFormConfig<T>): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
371
485
 
372
486
  type Hooks = AnyCoreSchemaHandle['hooks'];
373
487
  type HooksConfig<T> = <B>(hooks: T) => RawConfigActionCommon<B>;
@@ -448,10 +562,6 @@ declare function convert<RESULT extends Omit<PiResolvedCommonViewFieldConfig<any
448
562
  declare const NFCSchema: v.OptionalSchema<v.VoidSchema<undefined>, undefined>;
449
563
 
450
564
  interface FieldRenderConfig {
451
- /** @deprecated */
452
- ngClass?: string | string[] | Set<string> | {
453
- [klass: string]: any;
454
- };
455
565
  hidden?: boolean;
456
566
  }
457
567
  /** 全局定义使用 */
@@ -466,14 +576,14 @@ type CoreResolvedComponentDefine = SetWrapper$<CoreRawComponentDefine, 'attribut
466
576
  interface HookConfig<RESOLVED_FIELD> {
467
577
  /** 配置刚被解析 */
468
578
  fieldResolved?: (field: RESOLVED_FIELD) => void;
469
- /** 子级已经初始化 */
579
+ /** 子级已经初始化,每次array添加都会触发 */
470
580
  afterChildrenInit?: (field: RESOLVED_FIELD) => void;
471
- /** 组件创建,获取componentRef */
472
- afterCreateComponent?: (field: RESOLVED_FIELD) => void;
473
- /** 创建组件之前 */
474
- beforeCreateComponent?: (field: RESOLVED_FIELD) => void;
475
581
  /** 所有feilds初始化后执行,也就是可以进行表单监听 */
476
582
  allFieldsResolved?: (field: RESOLVED_FIELD) => void;
583
+ /** todo 此hook暂时没有使用到 创建组件之前 */
584
+ beforeCreateComponent?: (field: RESOLVED_FIELD) => void;
585
+ /** todo 此hook暂时没有使用到 组件创建,获取componentRef */
586
+ afterCreateComponent?: (field: RESOLVED_FIELD) => void;
477
587
  }
478
588
  type PiResolvedCommonViewFieldConfig<SelfResolvedFn extends () => any, Define> = {
479
589
  readonly hooks: HookConfig<ReturnType<SelfResolvedFn>>;
@@ -500,9 +610,8 @@ type PiResolvedCommonViewFieldConfig<SelfResolvedFn extends () => any, Define> =
500
610
  remove: (index: number) => void;
501
611
  };
502
612
  readonly define?: Define;
503
- /** 组件使用 */
504
- readonly wrappers$$: Signal<CoreResolvedWrapperConfig[]>;
505
- } & Readonly<Pick<AnyCoreSchemaHandle, 'priority' | 'alias'>> & Readonly<Wrapper$<Required<Pick<AnyCoreSchemaHandle, 'inputs' | 'outputs' | 'attributes' | 'formConfig' | 'renderConfig' | 'wrappers'>>>>;
613
+ wrappers: WritableSignal<CoreResolvedWrapperConfig[]>;
614
+ } & Readonly<Pick<AnyCoreSchemaHandle, 'priority' | 'alias'>> & Readonly<Wrapper$<Required<Pick<AnyCoreSchemaHandle, 'inputs' | 'outputs' | 'attributes' | 'formConfig' | 'renderConfig'>>>>;
506
615
  type _PiResolvedCommonViewFieldConfig = PiResolvedCommonViewFieldConfig<() => _PiResolvedCommonViewFieldConfig, CoreResolvedComponentDefine>;
507
616
  type ConfigMergeStrategy = 'merge' | 'replace';
508
617
  type PiCommonDefaultConfig = Partial<Pick<CoreSchemaHandle<any, any>, 'formConfig' | 'props' | 'renderConfig' | 'inputs' | 'outputs' | 'wrappers' | 'attributes'> & {
@@ -568,10 +677,11 @@ declare class FormBuilder<SchemaHandle extends CoreSchemaHandle<any, any>> {
568
677
  allFieldInitHookCall(): void;
569
678
  afterResolveConfig(rawConfig: SchemaHandle, config: _PiResolvedCommonViewFieldConfig): _PiResolvedCommonViewFieldConfig | undefined;
570
679
  createArrayItem(parent: BuildGroupItem<SchemaHandle> | BuildArrayItem<SchemaHandle>, field: AnyCoreSchemaHandle, index: number): PiResolvedCommonViewFieldConfig<any, any>;
680
+ protected configMergeRaw<T extends SignalInputValue<any>>(list: T[], isArray: boolean, strategy: ConfigMergeStrategy): UnWrapSignal<NonNullable<T>>;
571
681
  /**
572
682
  * 后面覆盖前面
573
683
  * */
574
- configMerge<T extends SignalInputValue<any>>(list: T[], isArray: boolean, strategy: ConfigMergeStrategy): WritableSignal<UnWrapSignal<NonNullable<T>>>;
684
+ protected configMerge<T extends SignalInputValue<any>>(list: T[], isArray: boolean, strategy: ConfigMergeStrategy): WritableSignal<UnWrapSignal<NonNullable<T>>>;
575
685
  }
576
686
 
577
687
  interface PiCommonConfig {
@@ -590,5 +700,5 @@ declare const PI_VIEW_CONFIG_TOKEN: InjectionToken<PiCommonConfig>;
590
700
  declare function isGroup(schema: AnyCoreSchemaHandle): boolean | undefined;
591
701
  declare function isArray(schema: AnyCoreSchemaHandle): boolean;
592
702
 
593
- export { AbstractControl, CoreSchemaHandle, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, NFCSchema, PENDING, PI_VIEW_CONFIG_TOKEN, SortedArray, VALID, arrayStartsWith, asyncInputMerge, clone, componentClass, convert, disableWhen, effectListen, formConfig, hideWhen, isArray, isFieldArray, isFieldControl, isFieldGroup, isFieldLogicGroup, isGroup, layout, mergeHooks, mergeHooksFn, mergeOutputFn, mergeOutputs, nonFieldControl, outputChange, outputChangeFn, patchAsyncAttributes, patchAsyncFn, patchAsyncInputs, patchAsyncProps, patchAttributes, patchHooks, patchInputs, patchOutputs, patchProps, patchWrappers, rawConfig, removeAttributes, removeHooks, removeInputs, removeOutputs, removeProps, removeWrappers, renderConfig, setAlias, setAttributes, setComponent, setHooks, setInputs, setOutputs, setProps, setWrappers, toArray, toObservable, topClass, unWrapSignal, valueChange, valueChangeFn };
594
- export type { AnyCoreSchemaHandle, ArraryIterable, ArrayDeletionMode, AsyncValidatorFn, BuildArrayItem, BuildGroupItem, BuildRootInputItem, BuildRootItem, ChangeWhenOption, ConfigMergeStrategy, CoreRawComponentDefine, CoreRawProps, CoreRawViewAttributes, CoreRawViewInputs, CoreRawViewOutputs, CoreRawWrapperConfig, CoreResolvedComponentDefine, CoreResolvedWrapperConfig, CoreWrapperConfig1, DefaultConfigKey, DisableWhenOption, DisabledValueStrategy, EventChangeFn, FieldArrayConfig$, FieldFormConfig, FieldFormConfig$, FieldGroupConfig$, FieldLogicGroupConfig$, FieldRenderConfig, FieldTransformerConfig, FormBuilderOptions, FormHooks, HideWhenOption, HookConfig, HooksConfig, KeyPath, LayoutAction, LazyImport, LogicType, MergeHooksConfig, NonFieldControlAction, PiCommonConfig, PiCommonDefaultConfig, PiResolvedCommonViewFieldConfig, QueryPath, RawKeyPath, SetOptional, SetReadonly, SetWrapper$, SetWrapper$$, SignalInputValue, ToObservableOptions, UnWrapSignal, VALID_STATUS, ValidationErrors, ValidatorFn, ValueChangFnOptions, ValueChangeFn, Wrapper$, Writeable, _PiResolvedCommonViewFieldConfig };
703
+ export { AbstractControl, CoreSchemaHandle, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, NFCSchema, PENDING, PI_VIEW_CONFIG_TOKEN, SortedArray, VALID, arrayStartsWith, asyncInputMerge, clone, componentClass, convert, createViewControlLink, disableWhen, effectListen, formConfig, hideWhen, isArray, isFieldArray, isFieldControl, isFieldGroup, isFieldLogicGroup, isGroup, layout, mergeHooks, mergeHooksFn, mergeOutputFn, mergeOutputs, nonFieldControl, outputChange, outputChangeFn, patchAsyncAttributes, patchAsyncFn, patchAsyncInputs, patchAsyncProps, patchAttributes, patchHooks, patchInputs, patchOutputs, patchProps, patchWrappers, rawConfig, removeAttributes, removeHooks, removeInputs, removeOutputs, removeProps, removeWrappers, renderConfig, setAlias, setAttributes, setComponent, setHooks, setInputs, setOutputs, setProps, setWrappers, toArray, toObservable, topClass, unWrapSignal, valueChange, valueChangeFn };
704
+ export type { AbstractControlParams, AnyCoreSchemaHandle, ArraryIterable, ArrayDeletionMode, AsyncValidatorFn, BuildArrayItem, BuildGroupItem, BuildRootInputItem, BuildRootItem, ChangeWhenOption, ConfigMergeStrategy, ControlValueAccessor, CoreRawComponentDefine, CoreRawProps, CoreRawViewAttributes, CoreRawViewInputs, CoreRawViewOutputs, CoreRawWrapperConfig, CoreResolvedComponentDefine, CoreResolvedWrapperConfig, CoreWrapperConfig1, DefaultConfigKey, DisableWhenOption, DisabledValueStrategy, EventChangeFn, FieldArrayConfig$, FieldFormConfig, FieldFormConfig$, FieldGroupConfig$, FieldLogicGroupConfig$, FieldRenderConfig, FieldTransformerConfig, FormBuilderOptions, FormHooks, HideWhenOption, HookConfig, HooksConfig, KeyPath, LayoutAction, LazyImport, LogicType, MergeHooksConfig, NonFieldControlAction, PiCommonConfig, PiCommonDefaultConfig, PiResolvedCommonViewFieldConfig, QueryPath, RawKeyPath, SetOptional, SetReadonly, SetWrapper$, SetWrapper$$, SignalInputValue, ToObservableOptions, UnWrapSignal, VALID_STATUS, ValidationErrors, ValidatorFn, ValueChangFnOptions, ValueChangeFn, Wrapper$, Writeable, _PiResolvedCommonViewFieldConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piying/view-angular-core",
3
- "version": "0.6.19",
3
+ "version": "0.6.21",
4
4
  "peerDependencies": {
5
5
  "valibot": "^1.1.0"
6
6
  },