@piying/view-angular-core 0.6.5

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.
@@ -0,0 +1 @@
1
+ import{rawConfig,FieldGroup,isFieldGroup,FieldArray,isFieldArray,FieldControl,isFieldControl,FieldLogicGroup,isFieldLogicGroup}from"@piying/view-angular-core";let getField=(field$,hooks="allInit")=>rawConfig(field=>{switch(field.hooks??={},hooks){case"allInit":field.hooks.allFieldsResolved=field=>{field$.resolve(field)};break;case"fieldInit":field.hooks.fieldResolved=field=>{field$.resolve(field)};break;case"chilrenInit":field.hooks.afterChildrenInit=field=>{field$.resolve(field)};break;case"afterComponent":field.hooks.afterCreateComponent=field=>{field$.resolve(field)};break;case"beforeComponent":field.hooks.beforeCreateComponent=field=>{field$.resolve(field)}}});function keyEqual(input1,input2){if(input1===input2||void 0===input1||void 0===input2)return void expect(input1).toEqual(input2);if(input1=Array.isArray(input1)?input1:void 0===input1?[]:[input1],input2=Array.isArray(input2)?input2:void 0===input2?[]:[input2],input1.length!==input2.length)throw Error(`${input1} != ${input2}`);for(let index=0;index<input1.length;index++){let i1=input1[index],i2=input2[index];expect(i1).toEqual(i2)}}function typeEqual(input1,input2){expect(input1).toEqual(input2)}function assertFieldGroup(input){if(!(input instanceof FieldGroup))throw Error("FieldGroup验证失败");expect(isFieldGroup(input)).toBeTrue()}function assertFieldArray(input){if(!(input instanceof FieldArray))throw Error("FieldArray验证失败");expect(isFieldArray(input)).toBeTrue()}function assertFieldControl(input){if(!(input instanceof FieldControl))throw Error("FieldControl验证失败");expect(isFieldControl(input)).toBeTrue()}function assertFieldLogicGroup(input){if(!(input instanceof FieldLogicGroup))throw Error("FieldLogicGroup验证失败");expect(isFieldLogicGroup(input)).toBeTrue()}export{assertFieldArray,assertFieldControl,assertFieldGroup,assertFieldLogicGroup,getField,keyEqual,typeEqual};
@@ -0,0 +1 @@
1
+ import{effect,inject,Injector,untracked,DestroyRef,isSignal,computed,signal,linkedSignal,resource,InjectionToken,EnvironmentInjector}from"@angular/core";import*as v from"valibot";import{deepEqual}from"fast-equals";import{BehaviorSubject,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 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??[]);syncError$$=linkedSignal(computed(()=>{if(this.disabled$$())return;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}}));asyncErrorRes$$=computed(()=>{let result=this.#asyncValidators$$();if(0!==result.length)return untracked(()=>resource({params:()=>this.value$$(),loader:async()=>{let errorResult=(await Promise.all(result.map(item=>untracked(()=>item(this))))).reduce((obj,item)=>(item&&(obj={...obj,...item}),obj),{});return Object.keys(errorResult).length?errorResult:void 0},injector:this.injector}))});asyncError$$=computed(()=>{if(this.disabled$$())return;let ref=this.asyncErrorRes$$();if(ref)if(ref.isLoading())return PENDING;else return ref.value()});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),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){if(this.#initInput){this.#initInput=!1,void 0===value||deepEqual(value,this.value$$())||(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,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=>{let oldValue=unWrapSignal$1(field.inputs);field.inputs=computed(()=>({...oldValue,...unWrapSignal$1(inputs)}))})}function removeInputs(list){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.inputs);oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.inputs=oldValue)})}function patchAsyncInputs(inputs,options){return rawConfig(rawField=>{let inputList=Object.keys(inputs),hookName=options?.hookName??"fieldResolved";return rawField.inputs={...rawField.inputs,...inputList.reduce((obj,item)=>(obj[item]=void 0,obj),{})},mergeHooksFn({[hookName]:field=>{inputList.forEach(key=>{let result=inputs[key](field);result&&"function"==typeof result.then?result.then(value=>{field.inputs.update(inputs=>((inputs={...inputs})[key]=value,inputs))}):result&&"function"==typeof result.subscribe?result.subscribe({next:value=>{field.inputs.update(inputs=>((inputs={...inputs})[key]=value,inputs))}}):field.inputs.update(inputs=>((inputs={...inputs})[key]=result,inputs))})}},{position:options?.addPosition??"bottom"},rawField)})}function patchInputsSignal(inputs,options){return rawConfig(rawField=>{let inputList=Object.keys(inputs);return mergeHooksFn({[options?.hookName??"fieldResolved"]:field=>{let oldInputs=field.inputs;field.inputs=linkedSignal(computed(()=>({...oldInputs(),...inputList.reduce((obj,key)=>({...obj,[key]:inputs[key]()}),{})})))}},{position:options?.addPosition??"bottom"},rawField)})}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}})}function setAttributes(attributes){return rawConfig(field=>{field.attributes=attributes})}function patchAttributes(attributes){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.attributes);field.attributes=computed(()=>({...oldValue,...unWrapSignal$1(attributes)}))})}function removeAttributes(list){return rawConfig(field=>{let oldValue=unWrapSignal$1(field.attributes);oldValue&&(list.forEach(item=>{delete oldValue[item]}),field.attributes=oldValue)})}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)).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)).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){super.lazySchema(schema),this.type=this.lazyWrapped.type}arraySchema(schema){if(!this.isObjectControl){this.isArray=!0;let sh=new this.globalConfig.handle(this.globalConfig,this,schema);sh.fullPath=[],convertSchema(schema.item,sh),this.arrayChild=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.fullPath=[...this.fullPath]:(sh.key=index,sh.fullPath=[...this.fullPath,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,clone,componentClass,convert,disableWhen,effectListen,formConfig,hideWhen,isArray,isFieldArray,isFieldControl,isFieldGroup,isFieldLogicGroup,isGroup,layout,mergeHooks,mergeHooksFn,mergeOutputFn,mergeOutputs,nonFieldControl,outputChange,outputChangeFn,patchAsyncInputs,patchAttributes,patchHooks,patchInputs,patchInputsSignal,patchOutputs,patchWrappers,rawConfig,removeAttributes,removeHooks,removeInputs,removeOutputs,removeWrappers,renderConfig,setAlias,setAttributes,setComponent,setHooks,setInputs,setOutputs,setWrappers,toArray,toObservable,topClass,unWrapSignal$1 as unWrapSignal,valueChange,valueChangeFn};
package/index.d.ts ADDED
@@ -0,0 +1,577 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { WritableSignal, Signal, Injector, CreateEffectOptions, EffectRef, InjectionToken } from '@angular/core';
3
+ import * as _piying_valibot_visit from '@piying/valibot-visit';
4
+ import { SchemaOrPipe, BaseSchemaHandle, LazySchema, DefaultSchema, TupleSchema, EnumSchema, IntersectSchema, UnionSchema, Schema, VoidSchema, MetadataAction, RawConfigActionCommon, ConvertOptions } from '@piying/valibot-visit';
5
+ export { RawConfig, asControl, asVirtualGroup, changeObject, condition, getDefaults, getSchemaByIssuePath, getSchemaMetadata } from '@piying/valibot-visit';
6
+ import * as v from 'valibot';
7
+ import { BaseMetadata, ArraySchema, BaseSchema, BaseIssue, ErrorMessage, ArrayIssue } from 'valibot';
8
+ import { Observable } from 'rxjs';
9
+ import * as _piying_view_angular_core from '@piying/view-angular-core';
10
+ import { ClassValue } from 'clsx';
11
+
12
+ type DisabledValueStrategy = 'reserve' | 'delete';
13
+ interface FieldTransformerConfig {
14
+ toView?: (value: any, control: AbstractControl) => any;
15
+ toModel?: (value: any, control: AbstractControl) => any;
16
+ }
17
+ type LogicType = 'and' | 'or';
18
+ type ArrayDeletionMode = 'shrink' | 'mark';
19
+ interface FieldFormConfig {
20
+ disabled?: boolean;
21
+ /** 删除时value应该如何处理 */
22
+ disabledValue?: DisabledValueStrategy;
23
+ transfomer?: FieldTransformerConfig;
24
+ defaultValue?: any;
25
+ validators?: ValidatorFn[];
26
+ asyncValidators?: AsyncValidatorFn[];
27
+ updateOn?: 'change' | 'blur';
28
+ activateIndex?: number;
29
+ type?: LogicType;
30
+ /** auto */
31
+ required?: boolean;
32
+ /** array/group/logic group */
33
+ emptyValue?: any;
34
+ /** array */
35
+ deletionMode?: ArrayDeletionMode;
36
+ }
37
+ type FieldFormConfig$ = WritableSignal<FieldFormConfig>;
38
+ type FieldGroupConfig$ = WritableSignal<Omit<FieldFormConfig, 'defaultValue'>>;
39
+ type FieldArrayConfig$ = WritableSignal<Omit<FieldFormConfig, 'defaultValue'>>;
40
+ type FieldLogicGroupConfig$ = WritableSignal<Omit<FieldFormConfig, 'defaultValue'>>;
41
+
42
+ type ValidationErrors = {
43
+ [key: string]: any;
44
+ };
45
+ interface ValidatorFn {
46
+ (control: AbstractControl): ValidationErrors | undefined;
47
+ }
48
+ interface AsyncValidatorFn {
49
+ (control: AbstractControl): Promise<ValidationErrors | undefined>;
50
+ }
51
+ declare const VALID = "VALID";
52
+ declare const INVALID = "INVALID";
53
+ declare const PENDING = "PENDING";
54
+ type VALID_STATUS = typeof VALID | typeof INVALID | typeof PENDING;
55
+ type FormHooks = 'change' | 'blur';
56
+ declare abstract class AbstractControl<TValue = any> {
57
+ #private;
58
+ protected readonly emptyValue$$: Signal<any>;
59
+ /** 父级取值时,当前子级是否包含在内 */
60
+ shouldInclude$$: Signal<boolean>;
61
+ readonly injector: Injector;
62
+ /** model的value */
63
+ abstract value$$: Signal<TValue | undefined>;
64
+ abstract children$$?: Signal<AbstractControl[]>;
65
+ /** disabled */
66
+ readonly selfDisabled$$: Signal<boolean>;
67
+ readonly selfEnabled$$: Signal<boolean>;
68
+ /** `self` || `parent` */
69
+ readonly disabled$$: Signal<boolean>;
70
+ readonly enabled$$: Signal<boolean>;
71
+ get disabled(): boolean;
72
+ get enabled(): boolean;
73
+ enable(): void;
74
+ disable(): void;
75
+ /** touched */
76
+ readonly selfTouched$: _angular_core.WritableSignal<boolean>;
77
+ readonly touched$$: Signal<boolean>;
78
+ get touched(): boolean;
79
+ get untouched(): boolean;
80
+ /** dirty */
81
+ private readonly selfDirty$;
82
+ readonly dirty$$: Signal<boolean>;
83
+ get dirty(): boolean;
84
+ get pristine(): boolean;
85
+ syncError$$: _angular_core.WritableSignal<ValidationErrors | undefined>;
86
+ asyncErrorRes$$: Signal<_angular_core.ResourceRef<ValidationErrors | undefined> | undefined>;
87
+ asyncError$$: Signal<ValidationErrors | "PENDING" | undefined>;
88
+ rawError$$: Signal<ValidationErrors | "PENDING" | undefined>;
89
+ valueNoError$$: Signal<boolean>;
90
+ get errors(): ValidationErrors | undefined;
91
+ /** parent */
92
+ private _parent?;
93
+ get parent(): AbstractControl | undefined;
94
+ get value(): TValue | undefined;
95
+ required$$: Signal<boolean | undefined>;
96
+ readonly schemaParser: v.SafeParser<SchemaOrPipe, undefined>;
97
+ constructor(rawSchema: SchemaOrPipe, injector: Injector);
98
+ setParent(parent: AbstractControl | undefined): void;
99
+ get valid(): boolean;
100
+ get invalid(): boolean;
101
+ get pending(): boolean;
102
+ selfUpdateOn$$: Signal<"change" | "blur" | undefined>;
103
+ updateOn$$: Signal<FormHooks>;
104
+ markAsTouched(): void;
105
+ markAllAsDirty(): void;
106
+ markAllAsTouched(): void;
107
+ markAsUntouched(): void;
108
+ markAsDirty(): void;
109
+ markAsPristine(): void;
110
+ abstract reset(value?: any): void;
111
+ getRawValue(): any;
112
+ get<P extends string | (string | number)[]>(path: P): AbstractControl | null;
113
+ get root(): AbstractControl;
114
+ abstract updateValue(value: any): void;
115
+ config$: FieldFormConfig$;
116
+ initConfig(config: any): void;
117
+ find(name: string | number): AbstractControl | null;
118
+ setControl(name: string | number, control: AbstractControl): void;
119
+ private reduceChildren;
120
+ get valueChanges(): Observable<any>;
121
+ status$$: Signal<VALID_STATUS>;
122
+ get statusChanges(): Observable<VALID_STATUS>;
123
+ }
124
+
125
+ declare class FieldGroup<TControl extends {
126
+ [K in keyof TControl]: AbstractControl<any>;
127
+ } = any> extends AbstractControl {
128
+ #private;
129
+ value$$: _angular_core.Signal<any>;
130
+ children$$: _angular_core.Signal<AbstractControl<any>[]>;
131
+ controls$: _angular_core.WritableSignal<Record<string, AbstractControl<any>>>;
132
+ get controls(): Record<string, AbstractControl<any>>;
133
+ registerControl(name: string, control: AbstractControl): AbstractControl<any>;
134
+ removeControl(name: string): void;
135
+ setControl(name: string, control: AbstractControl): void;
136
+ reset(value?: any): void;
137
+ getRawValue(): any;
138
+ find(name: string): AbstractControl | null;
139
+ looseValue$$: _angular_core.Signal<any>;
140
+ setInitValue(obj: any): void;
141
+ updateValue(value: any): void;
142
+ }
143
+
144
+ declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
145
+ #private;
146
+ children$$: undefined;
147
+ /** 视图变化时model值不变也要更新view */
148
+ private viewIndex$;
149
+ /** model输入值 */
150
+ modelValue$: WritableSignal<TValue | undefined>;
151
+ private modelValueToViewValueOrigin$$;
152
+ /** 传入到控件中的值 */
153
+ modelValueToViewValue$$: _angular_core.Signal<any>;
154
+ /** modelValue + viewValue => modelValue */
155
+ value$$: WritableSignal<any>;
156
+ reset(formState?: TValue): void;
157
+ setViewValue(value: TValue | undefined): void;
158
+ updateValue(value: any): void;
159
+ initConfig(config: any): void;
160
+ }
161
+
162
+ declare class FieldArray<TControl extends AbstractControl<any> = any> extends AbstractControl {
163
+ #private;
164
+ value$$: _angular_core.Signal<any>;
165
+ children$$: _angular_core.Signal<AbstractControl<any>[]>;
166
+ controls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
167
+ get controls(): AbstractControl<any>[];
168
+ removeAt(index: number): void;
169
+ setControl(index: number, control: TControl): void;
170
+ get length(): number;
171
+ reset(value?: any[]): void;
172
+ getRawValue(): any[];
173
+ clear(): void;
174
+ private _adjustIndex;
175
+ find(name: number): AbstractControl;
176
+ beforeUpdateList: ((value: any[]) => void)[];
177
+ updateValue(value?: any[]): void;
178
+ }
179
+
180
+ declare class FieldLogicGroup extends FieldArray {
181
+ /** 待定参数 */
182
+ activateIndex$: _angular_core.WritableSignal<number>;
183
+ type: _angular_core.WritableSignal<LogicType>;
184
+ activateControl$: _angular_core.WritableSignal<AbstractControl<any>[] | undefined>;
185
+ value$$: _angular_core.Signal<any>;
186
+ getActivateControls(): AbstractControl<any>[];
187
+ getValue(rawData: boolean): any;
188
+ getRawValue(): any;
189
+ updateValue(value: any): void;
190
+ }
191
+
192
+ declare function isFieldGroup(input: any): input is FieldGroup;
193
+ declare function isFieldArray(input: any): input is FieldArray;
194
+ declare function isFieldControl(input: any): input is FieldControl;
195
+ declare function isFieldLogicGroup(input: any): input is FieldLogicGroup;
196
+
197
+ declare function arrayStartsWith(list: any[], parts: any[] | any): boolean;
198
+
199
+ type KeyPath = (string | number)[];
200
+ type RawKeyPath = string | number;
201
+ type SetOptional<OBJ, K extends keyof OBJ> = Omit<OBJ, K> & Partial<Pick<OBJ, K>>;
202
+ type SetReadonly<OBJ, K extends keyof OBJ> = Omit<OBJ, K> & Readonly<Pick<OBJ, K>>;
203
+ type ArraryIterable<T> = T[] | Iterable<T>;
204
+ type QueryPath = string | number | KeyPath;
205
+ type Wrapper$<T> = {
206
+ [P in keyof T]: WritableSignal<T[P]>;
207
+ };
208
+ type Wrapper$$<T> = {
209
+ [P in keyof T]: Signal<T[P]>;
210
+ };
211
+ type SetWrapper$<OBJ, K extends keyof OBJ> = Omit<OBJ, K> & Wrapper$<Pick<OBJ, K>>;
212
+ type SetWrapper$$<OBJ, K extends keyof OBJ> = Omit<OBJ, K> & Wrapper$$<Pick<OBJ, K>>;
213
+ type Writeable<T> = {
214
+ -readonly [P in keyof T]: T[P];
215
+ };
216
+
217
+ /** 跳过第一个值,假如发射时和初始值不同 */
218
+ declare function effectListen(listen: () => any, fn: () => void, options?: CreateEffectOptions): EffectRef;
219
+
220
+ /**
221
+ * Options for `toObservable`.
222
+ *
223
+ * @publicApi 20.0
224
+ */
225
+ interface ToObservableOptions {
226
+ /**
227
+ * The `Injector` to use when creating the underlying `effect` which watches the signal.
228
+ *
229
+ * If this isn't specified, the current [injection context](guide/di/dependency-injection-context)
230
+ * will be used.
231
+ */
232
+ injector?: Injector;
233
+ }
234
+ /**
235
+ * Exposes the value of an Angular `Signal` as an RxJS `Observable`.
236
+ *
237
+ * The signal's value will be propagated into the `Observable`'s subscribers using an `effect`.
238
+ *
239
+ * `toObservable` must be called in an injection context unless an injector is provided via options.
240
+ *
241
+ * @publicApi 20.0
242
+ */
243
+ declare function toObservable<T>(listen: Signal<any>, source: Signal<T>, options?: ToObservableOptions): Observable<T>;
244
+
245
+ declare const clone: <T>(input: T) => T;
246
+
247
+ declare function unWrapSignal<T>(value?: T | Signal<T>): T | undefined;
248
+ type UnWrapSignal<T> = T extends Signal<infer Value> ? Value : T;
249
+ type SignalInputValue<T> = T | Signal<T> | WritableSignal<T> | undefined;
250
+
251
+ declare function toArray(input: any): any[] | undefined;
252
+
253
+ declare class SortedArray<T> extends Array {
254
+ #private;
255
+ constructor(compareFn: (a: T, b: T) => number);
256
+ push(...items: any[]): number;
257
+ }
258
+
259
+ type LazyImport<T> = () => Promise<T>;
260
+
261
+ interface LayoutAction<TInput = unknown> extends BaseMetadata<TInput> {
262
+ readonly type: 'layout';
263
+ readonly reference: typeof layout;
264
+ readonly value: {
265
+ keyPath?: KeyPath;
266
+ priority?: number;
267
+ };
268
+ }
269
+ declare function layout<TInput>(value: LayoutAction['value']): LayoutAction<TInput>;
270
+
271
+ declare class CoreSchemaHandle<Self extends CoreSchemaHandle<any, any>, RESOLVED_FN extends () => any> extends BaseSchemaHandle<Self> {
272
+ inputs?: CoreRawViewInputs;
273
+ outputs?: CoreRawViewOutputs;
274
+ wrappers?: CoreRawWrapperConfig[];
275
+ attributes?: Record<string, any>;
276
+ alias?: string;
277
+ movePath?: QueryPath;
278
+ renderConfig?: FieldRenderConfig;
279
+ /** todo 非表单应该可选 */
280
+ formConfig: FieldFormConfig;
281
+ id?: string;
282
+ isLogicAnd: boolean;
283
+ isLogicOr: boolean;
284
+ isArray: boolean;
285
+ isTuple: boolean;
286
+ nonFieldControl: boolean;
287
+ hooks?: HookConfig<ReturnType<RESOLVED_FN>>;
288
+ lazySchema(schema: LazySchema): void;
289
+ arraySchema(schema: ArraySchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<ArrayIssue> | undefined>): void;
290
+ defaultSchema(schema: DefaultSchema): void;
291
+ tupleDefault(schema: TupleSchema): void;
292
+ enumSchema(schema: EnumSchema): void;
293
+ intersectBefore(schema: IntersectSchema): void;
294
+ logicItemSchema(schema: v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>, index: number, type: 'intersect' | 'union'): void;
295
+ unionBefore(schema: UnionSchema): void;
296
+ beforeSchemaType(schema: Schema): void;
297
+ voidSchema(schema: VoidSchema): void;
298
+ metadataDefaulthandle(metadata: MetadataAction, environments: string[]): void;
299
+ end(schema: SchemaOrPipe): void;
300
+ }
301
+ type AnyCoreSchemaHandle = CoreSchemaHandle<any, () => _PiResolvedCommonViewFieldConfig>;
302
+
303
+ declare const rawConfig: <TInput>(value: (field: AnyCoreSchemaHandle, context?: any) => void, workOn?: "afterSchemaType") => _piying_valibot_visit.RawConfigAction<"viewRawConfig", TInput, AnyCoreSchemaHandle>;
304
+
305
+ declare function setComponent<T>(type: any): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
306
+
307
+ declare function setInputs<T>(inputs: CoreRawViewInputs | Signal<CoreRawViewInputs>): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
308
+ declare function patchInputs<T>(inputs: CoreRawViewInputs | Signal<CoreRawViewInputs>): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
309
+ declare function removeInputs<T>(list: string[]): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
310
+ declare function patchAsyncInputs<T>(inputs: Record<string, (field: _PiResolvedCommonViewFieldConfig) => Promise<any> | Observable<any> | (any & {})>, options?: {
311
+ addPosition: 'top' | 'bottom';
312
+ hookName: 'fieldResolved' | 'allFieldsResolved';
313
+ }): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
314
+ declare function patchInputsSignal<T>(inputs: Record<string, Signal<any>>, options?: {
315
+ addPosition: 'top' | 'bottom';
316
+ hookName: 'fieldResolved' | 'allFieldsResolved';
317
+ }): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
318
+
319
+ declare function setOutputs<T>(outputs: CoreRawViewOutputs): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, AnyCoreSchemaHandle>;
320
+ declare function patchOutputs<T>(outputs: CoreRawViewInputs): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, AnyCoreSchemaHandle>;
321
+ declare function removeOutputs<T>(list: string[]): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, AnyCoreSchemaHandle>;
322
+ declare function mergeOutputFn(field: _PiResolvedCommonViewFieldConfig, outputs: Record<string, any>, options: {
323
+ position: 'top' | 'bottom';
324
+ }): void;
325
+ declare const mergeOutputs: <T>(outputs: Record<string, (...args: any[]) => void>, options?: {
326
+ position: "top" | "bottom";
327
+ }) => _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, AnyCoreSchemaHandle>;
328
+ type EventChangeFn = (fn: (input: {
329
+ list: KeyPath | undefined;
330
+ output: string;
331
+ }[]) => Observable<{
332
+ field: _PiResolvedCommonViewFieldConfig;
333
+ list: any[];
334
+ listenFields: _PiResolvedCommonViewFieldConfig[];
335
+ }>) => void;
336
+ declare function outputChangeFn(rawField: AnyCoreSchemaHandle, fn: EventChangeFn): void;
337
+ declare function outputChange<T>(fn: EventChangeFn): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, AnyCoreSchemaHandle>;
338
+
339
+ declare function setWrappers<T>(wrappers: CoreRawWrapperConfig[]): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
340
+ type PatchWrappersOptions = {
341
+ position: 'head' | 'tail';
342
+ };
343
+ declare function patchWrappers<T>(wrappers: CoreRawWrapperConfig | CoreRawWrapperConfig[], options?: PatchWrappersOptions): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
344
+ declare function removeWrappers<T>(list: string[]): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
345
+
346
+ declare function setAlias<T>(alias: string): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
347
+
348
+ declare function renderConfig<T>(type: FieldRenderConfig): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
349
+ declare function formConfig<T>(config: FieldFormConfig): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
350
+
351
+ type Hooks = AnyCoreSchemaHandle['hooks'];
352
+ type HooksConfig<T> = <B>(hooks: T) => RawConfigActionCommon<B>;
353
+ declare const setHooks: HooksConfig<Hooks>;
354
+ declare const patchHooks: HooksConfig<Hooks>;
355
+ type HooksKey = keyof NonNullable<Hooks>;
356
+ type MergeHooksConfig<T> = <B>(hooks: T, options?: {
357
+ position: 'top' | 'bottom';
358
+ }) => RawConfigActionCommon<B>;
359
+ declare function mergeHooksFn<T extends AnyCoreSchemaHandle>(hooks: Hooks, options: {
360
+ position: 'top' | 'bottom';
361
+ }, field: T): void;
362
+ declare const mergeHooks: MergeHooksConfig<Hooks>;
363
+ declare function removeHooks<T>(list: HooksKey[]): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, AnyCoreSchemaHandle>;
364
+
365
+ declare function setAttributes<T>(attributes: CoreRawViewAttributes): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
366
+ declare function patchAttributes<T>(attributes: CoreRawViewAttributes): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
367
+ declare function removeAttributes<T>(list: string[]): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
368
+
369
+ interface ValueChangFnOptions {
370
+ list?: (KeyPath | undefined)[];
371
+ skipInitValue?: boolean;
372
+ }
373
+ interface ChangeWhenOption<T extends _PiResolvedCommonViewFieldConfig = _PiResolvedCommonViewFieldConfig> {
374
+ fn: (fn: (input: ValueChangFnOptions) => Observable<{
375
+ field: _PiResolvedCommonViewFieldConfig;
376
+ input: ValueChangFnOptions;
377
+ }>) => void;
378
+ }
379
+ type ValueChangeFn = (fn: (input?: ValueChangFnOptions) => Observable<{
380
+ field: _PiResolvedCommonViewFieldConfig;
381
+ list: any[];
382
+ }>, field: _PiResolvedCommonViewFieldConfig) => void;
383
+ declare function valueChangeFn(field: _PiResolvedCommonViewFieldConfig, input?: ValueChangFnOptions): Observable<{
384
+ list: any[];
385
+ field: _PiResolvedCommonViewFieldConfig;
386
+ listenFields: any[];
387
+ }>;
388
+ declare function valueChange<TInput>(listenFn: ValueChangeFn): _piying_valibot_visit.RawConfigAction<"viewRawConfig", TInput, _piying_view_angular_core.AnyCoreSchemaHandle>;
389
+
390
+ interface HideWhenOption<T extends _PiResolvedCommonViewFieldConfig = _PiResolvedCommonViewFieldConfig> {
391
+ disabled?: boolean;
392
+ listen: (fn: (input: ValueChangFnOptions) => Observable<{
393
+ field: _PiResolvedCommonViewFieldConfig;
394
+ list: any[];
395
+ listenFields: _PiResolvedCommonViewFieldConfig[];
396
+ }>) => Observable<boolean>;
397
+ }
398
+ declare function hideWhen<TInput>(options: HideWhenOption): _piying_valibot_visit.RawConfigAction<"viewRawConfig", TInput, _piying_view_angular_core.AnyCoreSchemaHandle>;
399
+
400
+ interface DisableWhenOption<T extends _PiResolvedCommonViewFieldConfig = _PiResolvedCommonViewFieldConfig> {
401
+ listen: (fn: (input: ValueChangFnOptions) => Observable<{
402
+ field: _PiResolvedCommonViewFieldConfig;
403
+ list: any[];
404
+ listenFields: _PiResolvedCommonViewFieldConfig[];
405
+ }>) => Observable<boolean>;
406
+ }
407
+ declare function disableWhen<TInput>(options: DisableWhenOption): _piying_valibot_visit.RawConfigAction<"viewRawConfig", TInput, _piying_view_angular_core.AnyCoreSchemaHandle>;
408
+
409
+ /** 必须防止到所有wrappers操作后面,防止设置错误
410
+ * 设置到顶层,可能是wrapper,也可能是component
411
+ *
412
+ */
413
+ declare function topClass<T>(className: ClassValue, merge?: boolean): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
414
+ /** 仅设置在组件上 */
415
+ declare function componentClass<T>(className: ClassValue, merge?: boolean): _piying_valibot_visit.RawConfigAction<"viewRawConfig", T, _piying_view_angular_core.AnyCoreSchemaHandle>;
416
+
417
+ interface NonFieldControlAction<TInput = unknown> extends BaseMetadata<TInput> {
418
+ readonly type: 'nonFieldControl';
419
+ readonly reference: typeof nonFieldControl;
420
+ readonly value: boolean;
421
+ }
422
+ declare function nonFieldControl<TInput>(value?: boolean): NonFieldControlAction<TInput>;
423
+
424
+ declare function convert<RESULT extends Omit<PiResolvedCommonViewFieldConfig<any, any>, 'define'>>(obj: SchemaOrPipe, options: SetOptional<ConvertOptions, 'handle'> & {
425
+ injector: Injector;
426
+ builder: typeof FormBuilder;
427
+ fieldGlobalConfig?: PiCommonConfig;
428
+ registerOnDestroy?: (fn: any) => void;
429
+ }): RESULT;
430
+
431
+ declare const NFCSchema: v.OptionalSchema<v.VoidSchema<undefined>, undefined>;
432
+
433
+ interface FieldRenderConfig {
434
+ /** @deprecated */
435
+ ngClass?: string | string[] | Set<string> | {
436
+ [klass: string]: any;
437
+ };
438
+ hidden?: boolean;
439
+ }
440
+ /** 全局定义使用 */
441
+ type CoreRawComponentDefine = {
442
+ type: any;
443
+ attributes?: Record<string, any>;
444
+ inputs?: CoreRawViewInputs;
445
+ outputs?: CoreRawViewOutputs;
446
+ };
447
+ /** 解析后define使用 */
448
+ type CoreResolvedComponentDefine = SetWrapper$<CoreRawComponentDefine, 'attributes' | 'inputs'>;
449
+ interface HookConfig<RESOLVED_FIELD> {
450
+ /** 配置刚被解析 */
451
+ fieldResolved?: (field: RESOLVED_FIELD) => void;
452
+ /** 子级已经初始化 */
453
+ afterChildrenInit?: (field: RESOLVED_FIELD) => void;
454
+ /** 组件创建,获取componentRef */
455
+ afterCreateComponent?: (field: RESOLVED_FIELD) => void;
456
+ /** 创建组件之前 */
457
+ beforeCreateComponent?: (field: RESOLVED_FIELD) => void;
458
+ /** 所有feilds初始化后执行,也就是可以进行表单监听 */
459
+ allFieldsResolved?: (field: RESOLVED_FIELD) => void;
460
+ }
461
+ type PiResolvedCommonViewFieldConfig<SelfResolvedFn extends () => any, Define> = {
462
+ readonly hooks: HookConfig<ReturnType<SelfResolvedFn>>;
463
+ readonly id?: string;
464
+ /** 查询时使用 */
465
+ readonly keyPath?: KeyPath | undefined;
466
+ readonly fullPath: KeyPath;
467
+ readonly props: WritableSignal<Record<string, any>>;
468
+ fieldGroup?: WritableSignal<ReturnType<SelfResolvedFn>[]>;
469
+ fieldArray?: WritableSignal<ReturnType<SelfResolvedFn>[]>;
470
+ parent: ReturnType<SelfResolvedFn>;
471
+ readonly form: {
472
+ readonly control?: FieldGroup | FieldArray | FieldControl | FieldLogicGroup;
473
+ readonly parent: FieldGroup | FieldArray | FieldLogicGroup;
474
+ readonly root: FieldGroup | FieldArray | FieldControl | FieldLogicGroup;
475
+ };
476
+ /** 仅用来开发时debug使用 */
477
+ readonly origin: any;
478
+ /** 外部传入引用 */
479
+ readonly context?: any;
480
+ get: (keyPath: KeyPath, aliasNotFoundFn?: (name: string, field: PiResolvedCommonViewFieldConfig<any, any>) => PiResolvedCommonViewFieldConfig<any, any>) => ReturnType<SelfResolvedFn> | undefined;
481
+ action: {
482
+ set: (value: any, index?: number) => void;
483
+ remove: (index: number) => void;
484
+ };
485
+ readonly define?: Define;
486
+ /** 组件使用 */
487
+ readonly wrappers$$: Signal<CoreResolvedWrapperConfig[]>;
488
+ } & Readonly<Pick<AnyCoreSchemaHandle, 'priority' | 'alias'>> & Readonly<Wrapper$<Required<Pick<AnyCoreSchemaHandle, 'inputs' | 'outputs' | 'attributes' | 'formConfig' | 'renderConfig' | 'wrappers'>>>>;
489
+ type _PiResolvedCommonViewFieldConfig = PiResolvedCommonViewFieldConfig<() => _PiResolvedCommonViewFieldConfig, CoreResolvedComponentDefine>;
490
+ type ConfigMergeStrategy = 'merge' | 'replace';
491
+ type PiCommonDefaultConfig = Partial<Pick<CoreSchemaHandle<any, any>, 'formConfig' | 'props' | 'renderConfig' | 'inputs' | 'outputs' | 'wrappers' | 'attributes'> & {
492
+ type: any;
493
+ }>;
494
+ interface FormBuilderOptions<T> {
495
+ form$$: Signal<FieldGroup>;
496
+ resolvedField$: WritableSignal<T>;
497
+ context: Signal<any>;
498
+ }
499
+ type CoreRawViewInputs = Record<string, any>;
500
+ type CoreRawViewAttributes = Record<string, any>;
501
+ interface CoreRawViewOutputs {
502
+ [name: string]: (event: any) => void;
503
+ }
504
+ type CoreWrapperConfig1 = {
505
+ type: string | any | LazyImport<any>;
506
+ attributes?: CoreRawViewAttributes;
507
+ inputs?: CoreRawViewInputs;
508
+ outputs?: CoreRawViewOutputs;
509
+ };
510
+ type CoreRawWrapperConfig = string | CoreWrapperConfig1;
511
+ type CoreResolvedWrapperConfig = {
512
+ type: any | LazyImport<any>;
513
+ attributes: WritableSignal<CoreRawViewAttributes | undefined>;
514
+ inputs: WritableSignal<CoreRawViewInputs | undefined>;
515
+ outputs?: CoreRawViewOutputs;
516
+ };
517
+
518
+ interface BuildRootInputItem<SchemaHandle extends CoreSchemaHandle<any, any>> {
519
+ field: SchemaHandle;
520
+ resolvedField$: WritableSignal<_PiResolvedCommonViewFieldConfig | undefined>;
521
+ }
522
+ interface BuildRootItem {
523
+ type: 'root';
524
+ field: {
525
+ fieldGroup?: undefined;
526
+ fullPath: [];
527
+ };
528
+ form?: undefined;
529
+ resolvedField$: WritableSignal<_PiResolvedCommonViewFieldConfig | undefined>;
530
+ append: (input: _PiResolvedCommonViewFieldConfig) => void;
531
+ }
532
+ interface BuildGroupItem<SchemaHandle extends CoreSchemaHandle<any, any>> {
533
+ type: 'group';
534
+ fields: SchemaHandle[];
535
+ form: FieldGroup;
536
+ field: _PiResolvedCommonViewFieldConfig;
537
+ append: (input: _PiResolvedCommonViewFieldConfig) => void;
538
+ }
539
+ interface BuildArrayItem<SchemaHandle extends CoreSchemaHandle<any, any>> {
540
+ type: 'array';
541
+ templateField: SchemaHandle;
542
+ form: FieldArray;
543
+ field: _PiResolvedCommonViewFieldConfig;
544
+ append: (input: _PiResolvedCommonViewFieldConfig) => void;
545
+ }
546
+
547
+ declare class FormBuilder<SchemaHandle extends CoreSchemaHandle<any, any>> {
548
+ #private;
549
+ buildRoot(item: BuildRootInputItem<SchemaHandle>): void;
550
+ allFieldInitHookCall(): void;
551
+ afterResolveConfig(rawConfig: SchemaHandle, config: _PiResolvedCommonViewFieldConfig): _PiResolvedCommonViewFieldConfig | undefined;
552
+ createArrayItem(parent: BuildGroupItem<SchemaHandle> | BuildArrayItem<SchemaHandle>, field: AnyCoreSchemaHandle, index: number): PiResolvedCommonViewFieldConfig<any, any>;
553
+ /**
554
+ * 后面覆盖前面
555
+ * */
556
+ configMerge<T extends SignalInputValue<any>>(list: T[], isArray: boolean, strategy: ConfigMergeStrategy): WritableSignal<UnWrapSignal<NonNullable<T>>>;
557
+ moveViewField(key: QueryPath, inputField: _PiResolvedCommonViewFieldConfig): void;
558
+ }
559
+
560
+ interface PiCommonConfig {
561
+ types?: Record<string, PiCommonDefaultConfig>;
562
+ defaultConfig?: PiCommonDefaultConfig;
563
+ defaultConfigMergeStrategy?: ConfigMergeStrategy | Record<DefaultConfigKey, ConfigMergeStrategy>;
564
+ wrappers?: Record<string, Omit<CoreWrapperConfig1, 'type'> & {
565
+ type: any | LazyImport<any>;
566
+ }>;
567
+ }
568
+ type DefaultConfigKey = Exclude<keyof PiCommonDefaultConfig, 'type'>;
569
+
570
+ /** 一些默认配置 */
571
+ declare const PI_VIEW_CONFIG_TOKEN: InjectionToken<PiCommonConfig>;
572
+
573
+ declare function isGroup(schema: AnyCoreSchemaHandle): boolean | undefined;
574
+ declare function isArray(schema: AnyCoreSchemaHandle): boolean;
575
+
576
+ export { AbstractControl, CoreSchemaHandle, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, NFCSchema, PENDING, PI_VIEW_CONFIG_TOKEN, SortedArray, VALID, arrayStartsWith, clone, componentClass, convert, disableWhen, effectListen, formConfig, hideWhen, isArray, isFieldArray, isFieldControl, isFieldGroup, isFieldLogicGroup, isGroup, layout, mergeHooks, mergeHooksFn, mergeOutputFn, mergeOutputs, nonFieldControl, outputChange, outputChangeFn, patchAsyncInputs, patchAttributes, patchHooks, patchInputs, patchInputsSignal, patchOutputs, patchWrappers, rawConfig, removeAttributes, removeHooks, removeInputs, removeOutputs, removeWrappers, renderConfig, setAlias, setAttributes, setComponent, setHooks, setInputs, setOutputs, setWrappers, toArray, toObservable, topClass, unWrapSignal, valueChange, valueChangeFn };
577
+ export type { AnyCoreSchemaHandle, ArraryIterable, ArrayDeletionMode, AsyncValidatorFn, BuildArrayItem, BuildGroupItem, BuildRootInputItem, BuildRootItem, ChangeWhenOption, ConfigMergeStrategy, CoreRawComponentDefine, 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 ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@piying/view-angular-core",
3
+ "version": "0.6.5",
4
+ "peerDependencies": {
5
+ "valibot": "^1.1.0"
6
+ },
7
+ "dependencies": {
8
+ "tslib": "^2.8.1",
9
+ "@piying/valibot-visit": "^1.0.1",
10
+ "rfdc": "^1.4.1",
11
+ "fast-equals": "^5.2.2",
12
+ "clsx": "^2.1.1"
13
+ },
14
+ "sideEffects": false,
15
+ "module": "fesm2022/piying-view-angular-core.mjs",
16
+ "typings": "index.d.ts",
17
+ "exports": {
18
+ "./package.json": {
19
+ "default": "./package.json"
20
+ },
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "default": "./fesm2022/piying-view-angular-core.mjs"
24
+ },
25
+ "./test": {
26
+ "types": "./test/index.d.ts",
27
+ "default": "./fesm2022/piying-view-angular-core-test.mjs"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,17 @@
1
+ import { RawConfigActionCommon } from '@piying/valibot-visit';
2
+ import { _PiResolvedCommonViewFieldConfig, FieldGroup, FieldArray, FieldControl, FieldLogicGroup } from '@piying/view-angular-core';
3
+
4
+ type GetFieldType<T> = <B>(field$: PromiseWithResolvers<T>, hooks?: 'allInit' | 'fieldInit' | 'chilrenInit' | 'beforeComponent' | 'afterComponent') => RawConfigActionCommon<B>;
5
+ declare const getField: GetFieldType<_PiResolvedCommonViewFieldConfig>;
6
+
7
+ declare function keyEqual(input1: any, input2: any): void;
8
+
9
+ declare function typeEqual(input1: any, input2: any): void;
10
+
11
+ declare function assertFieldGroup(input: any): asserts input is FieldGroup;
12
+ declare function assertFieldArray(input: any): asserts input is FieldArray;
13
+ declare function assertFieldControl(input: any): asserts input is FieldControl;
14
+ declare function assertFieldLogicGroup(input: any): asserts input is FieldLogicGroup;
15
+
16
+ export { assertFieldArray, assertFieldControl, assertFieldGroup, assertFieldLogicGroup, getField, keyEqual, typeEqual };
17
+ export type { GetFieldType };