@piying/view-angular 0.6.10 → 0.6.12

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
- var SelectorRegexp,SelectorFlags,SelectorRegexp1,SelectorFlags1;import*as i0 from"@angular/core";import{input,Directive,ChangeDetectionStrategy,Component,InjectionToken,reflectComponentType,ɵɵelementStart as __elementStart,ɵɵlistener as __listener,ɵɵtwoWayBindingSet as __twoWayBindingSet,ɵɵprojection as __projection,ɵɵtext as __text,ɵɵtextInterpolate as __textInterpolate,ɵɵelementEnd as __elementEnd,ɵɵproperty as __property,ɵɵtwoWayProperty as __twoWayProperty,viewChild,TemplateRef,ElementRef,ɵɵdefineComponent as __defineComponent,ɵɵviewQuerySignal as __viewQuerySignal,ɵɵqueryAdvance as __queryAdvance,ɵɵprojectionDef as __projectionDef,ɵɵtemplate as __template,inject,computed,untracked,signal,EventEmitter,Injector,createComponent,EnvironmentInjector,effect,ViewContainerRef,createNgModule,resource,Injectable,Pipe,output,createEnvironmentInjector,DestroyRef}from"@angular/core";import{NgTemplateOutlet,NgClass}from"@angular/common";import{deepEqual}from"fast-equals";import{unWrapSignal,FormBuilder,PI_VIEW_CONFIG_TOKEN,CoreSchemaHandle,convert,rawConfig as rawConfig$1}from"@piying/view-angular-core";export{asControl,asVirtualGroup,condition,layout}from"@piying/view-angular-core";import{NgControl,Validators,NG_VALUE_ACCESSOR}from"@angular/forms";class PiViewGroupBase{fields=input.required();fieldTemplateRef=input.required();static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiViewGroupBase,deps:[],target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.1.0",version:"20.0.3",type:PiViewGroupBase,isStandalone:!0,inputs:{fields:{classPropertyName:"fields",publicName:"fields",isSignal:!0,isRequired:!0,transformFunction:null},fieldTemplateRef:{classPropertyName:"fieldTemplateRef",publicName:"fieldTemplateRef",isSignal:!0,isRequired:!0,transformFunction:null}},ngImport:i0})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiViewGroupBase,decorators:[{type:Directive}]});class PiViewGroup extends PiViewGroupBase{static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiViewGroup,deps:null,target:i0.ɵɵFactoryTarget.Component});static ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"20.0.3",type:PiViewGroup,isStandalone:!0,selector:"piying-view-group",usesInheritance:!0,ngImport:i0,template:'@for (field of fields(); track field.id || $index) {\r\n <ng-container\r\n *ngTemplateOutlet="fieldTemplateRef(); context: { $implicit: field }"\r\n ></ng-container>\r\n}\r\n',dependencies:[{kind:"directive",type:NgTemplateOutlet,selector:"[ngTemplateOutlet]",inputs:["ngTemplateOutletContext","ngTemplateOutlet","ngTemplateOutletInjector"]}],changeDetection:i0.ChangeDetectionStrategy.OnPush})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiViewGroup,decorators:[{type:Component,args:[{selector:"piying-view-group",imports:[NgTemplateOutlet],standalone:!0,changeDetection:ChangeDetectionStrategy.OnPush,template:'@for (field of fields(); track field.id || $index) {\r\n <ng-container\r\n *ngTemplateOutlet="fieldTemplateRef(); context: { $implicit: field }"\r\n ></ng-container>\r\n}\r\n'}]}]});let PI_VIEW_FIELD_TOKEN=new InjectionToken("PI_VIEW_FIELD_TOKEN"),PI_COMPONENT_LIST=new InjectionToken("PI_COMPONENT_LIST"),PI_COMPONENT_INDEX=new InjectionToken("PI_COMPONENT_INDEX"),PI_COMPONENT_LIST_LISTEN=new InjectionToken("PI_COMPONENT_LIST_LISTEN"),EMPTY_ARRAY=[];function getComponentCheckConfig(a){return{...a,inputs:Object.keys(a.inputs()??{}).join(","),attributes:Object.keys(a.attributes()??{}).join(","),directives:a.directives?a.directives.map(config=>({...config,inputs:`${config.inputs?Object.keys(config.inputs()).join(","):""}`})):void 0,contents:a.contents?.map(item=>({...item,text:!!item.text}))}}let _SELECTOR_REGEXP=RegExp("(\\:not\\()|(([\\.\\#]?)[-\\w]+)|(?:\\[([-.\\w*\\\\$]+)(?:=([\"']?)([^\\]\"']*)\\5)?\\])|(\\))|(\\s*,\\s*)","g");(SelectorRegexp1=SelectorRegexp||(SelectorRegexp={}))[SelectorRegexp1.ALL=0]="ALL",SelectorRegexp1[SelectorRegexp1.NOT=1]="NOT",SelectorRegexp1[SelectorRegexp1.TAG=2]="TAG",SelectorRegexp1[SelectorRegexp1.PREFIX=3]="PREFIX",SelectorRegexp1[SelectorRegexp1.ATTRIBUTE=4]="ATTRIBUTE",SelectorRegexp1[SelectorRegexp1.ATTRIBUTE_STRING=5]="ATTRIBUTE_STRING",SelectorRegexp1[SelectorRegexp1.ATTRIBUTE_VALUE=6]="ATTRIBUTE_VALUE",SelectorRegexp1[SelectorRegexp1.NOT_END=7]="NOT_END",SelectorRegexp1[SelectorRegexp1.SEPARATOR=8]="SEPARATOR";class CssSelector{element=null;classNames=[];attrs=[];notSelectors=[];static parse(selector){let match,results=[],_addResult=(res,cssSel)=>{cssSel.notSelectors.length>0&&!cssSel.element&&0==cssSel.classNames.length&&0==cssSel.attrs.length&&(cssSel.element="*"),res.push(cssSel)},cssSelector=new CssSelector,current=cssSelector,inNot=!1;for(_SELECTOR_REGEXP.lastIndex=0;match=_SELECTOR_REGEXP.exec(selector);){if(match[SelectorRegexp.NOT]){if(inNot)throw Error("Nesting :not in a selector is not allowed");inNot=!0,current=new CssSelector,cssSelector.notSelectors.push(current)}let tag=match[SelectorRegexp.TAG];if(tag){let prefix=match[SelectorRegexp.PREFIX];"#"===prefix?current.addAttribute("id",tag.slice(1)):"."===prefix?current.addClassName(tag.slice(1)):current.setElement(tag)}let attribute=match[SelectorRegexp.ATTRIBUTE];if(attribute&&current.addAttribute(current.unescapeAttribute(attribute),match[SelectorRegexp.ATTRIBUTE_VALUE]),match[SelectorRegexp.NOT_END]&&(inNot=!1,current=cssSelector),match[SelectorRegexp.SEPARATOR]){if(inNot)throw Error("Multiple selectors in :not are not supported");_addResult(results,cssSelector),cssSelector=current=new CssSelector}}return _addResult(results,cssSelector),results}unescapeAttribute(attr){let result="",escaping=!1;for(let i=0;i<attr.length;i++){let char=attr.charAt(i);if("\\"===char){escaping=!0;continue}if("$"===char&&!escaping)throw Error(`Error in attribute selector "${attr}". Unescaped "$" is not supported. Please escape with "\\$".`);escaping=!1,result+=char}return result}escapeAttribute(attr){return attr.replace(/\\/g,"\\\\").replace(/\$/g,"\\$")}setElement(element=null){this.element=element}addAttribute(name,value=""){this.attrs.push(name,value&&value.toLowerCase()||"")}addClassName(name){this.classNames.push(name.toLowerCase())}toString(){let res=this.element||"";if(this.classNames&&this.classNames.forEach(klass=>res+=`.${klass}`),this.attrs)for(let i=0;i<this.attrs.length;i+=2){let name=this.escapeAttribute(this.attrs[i]),value=this.attrs[i+1];res+=`[${name}${value?"="+value:""}]`}return this.notSelectors.forEach(notSelector=>res+=`:not(${notSelector})`),res}}function parserSelectorToR3Selector(selector){let positive=function(selector){let classes=selector.classNames&&selector.classNames.length?[SelectorFlags.CLASS,...selector.classNames]:[];return[selector.element&&"*"!==selector.element?selector.element:"",...selector.attrs,...classes]}(selector),negative=selector.notSelectors&&selector.notSelectors.length?selector.notSelectors.map(notSelector=>(function(selector){let classes=selector.classNames&&selector.classNames.length?[SelectorFlags.CLASS,...selector.classNames]:[];return selector.element?[SelectorFlags.NOT|SelectorFlags.ELEMENT,selector.element,...selector.attrs,...classes]:selector.attrs.length?[SelectorFlags.NOT|SelectorFlags.ATTRIBUTE,...selector.attrs,...classes]:selector.classNames&&selector.classNames.length?[SelectorFlags.NOT|SelectorFlags.CLASS,...selector.classNames]:[]})(notSelector)):[];return positive.concat(...negative)}(SelectorFlags1=SelectorFlags||(SelectorFlags={}))[SelectorFlags1.NOT=1]="NOT",SelectorFlags1[SelectorFlags1.ATTRIBUTE=2]="ATTRIBUTE",SelectorFlags1[SelectorFlags1.ELEMENT=4]="ELEMENT",SelectorFlags1[SelectorFlags1.CLASS=8]="CLASS";let EL_QUERY=["el"],index=0,EmptyOBJ={};class BaseComponent{#index=inject(PI_COMPONENT_INDEX,{optional:!0});#eventEmitter;#componentConfig;#viewContainerRef;destroyComponentFn;fieldComponentInstance;fieldElementRef;fieldDirectiveRefList;#componentCheckConfig$$;#setComponentCheck(config){this.#componentCheckConfig$$=computed(()=>untracked(()=>getComponentCheckConfig(config)))}setFieldData(field,index){this.#index=index}#inputCache;#contentCache;#configUpdate$=signal(0);createComponent(list,viewContainerRef){this.destroyComponentFn?.(),this.#viewContainerRef=viewContainerRef,this.#eventEmitter=new EventEmitter;let componentConfig=list[this.#index];this.#componentConfig=componentConfig,this.#inputCache={inputs:computed(()=>(this.#configUpdate$(),this.#componentConfig.inputs()??EmptyOBJ)),directiveList:this.#componentConfig?.directives?.map((config,index)=>config.inputs?computed(()=>(this.#configUpdate$(),this.#componentConfig.directives[index].inputs())):void 0)},this.#contentCache=componentConfig.contents?.map((item,index)=>item.text?{...item,text:computed(()=>(this.#configUpdate$(),this.#componentConfig.contents[index].text()))}:item),this.#setComponentCheck(componentConfig);let SidecarComponent=function(component,directives){let contentArray,result=function(component,list){let elementTag,vars=0,consts=[],directiveList=[],propertyList=[],listenerList=[],modelList=[];if("string"==typeof component.type)elementTag=component.type;else{let componentDefine=reflectComponentType(component.type);elementTag=component.selector??componentDefine.selector,directiveList.push(component.type)}if(!elementTag)throw Error("未找到元素对应的选择器");let attributes=component.attributes?.();if(attributes)for(let key in attributes)consts.push(key,attributes[key]);let mergedList=[component,...list];for(let i=0;i<mergedList.length;i++){let item=mergedList[i];if(i>0){directiveList.push(item.type);let selectors=item.type["ɵdir"].selectors,selector=item.selector??selectors.find(selectorList=>3===selectorList.length&&""===selectorList[0]&&""===selectorList[2])[1];(!item.inputs||selector in item.inputs())&&item.inputs||(!item.model||selector in item.model)&&item.model||consts.push(selector,"")}if(item.inputs)for(let key in propertyList[i]={signal:item.inputs,keyList:[]},item.inputs())vars++,propertyList[i].keyList.push(key);for(let key in item.outputs)listenerList.push({eventName:key,listenerFn:item.outputs[key]});for(let key in item.model)vars++,modelList.push({key:key,eventName:`${key}Change`,signal:item.model[key]})}return consts.push(3),consts.push(...new Set([...listenerList.map(({eventName})=>eventName),...modelList.map(({eventName})=>eventName)])),consts.push(...new Set([...propertyList.flatMap(item=>item.keyList),...modelList.map(({key})=>key)])),{vars,consts:[["el",""],consts],directiveList,propertyList:propertyList,listenerList:listenerList,modelList,elementTag}}(component,directives);function templateFn(rf,ctx){1&rf&&(__elementStart(0,result.elementTag,1,0),result.listenerList.reduce((fn,item)=>fn(item.eventName,item.listenerFn),__listener),result.modelList.reduce((fn,item)=>fn(item.eventName,value=>{__twoWayBindingSet(item.signal,value)}),__listener),component.contents?.length&&component.contents.forEach((item,index)=>{if(item.select){var selector;__projection(index+2,index,["ngProjectAs",item.select,5,((selector=item.select)?CssSelector.parse(selector).map(parserSelectorToR3Selector):[])[0]],item.text?(rf,ctx)=>{1&rf&&__text(0),2&rf&&__textInterpolate(item.text())}:void 0,item.text?1:void 0,item.text?1:void 0)}else __projection(index+1,index)}),__elementEnd()),2&rf&&(result.propertyList.reduce((fn,{signal,keyList})=>{let value=signal();return keyList.reduce((fn,key)=>fn(key,value[key]),fn)},__property),result.modelList.reduce((fn,item)=>fn(item.key,item.signal),__twoWayProperty))}return component.contents?.length&&(contentArray=Array(component.contents.length).fill("*")),class D{templateRef=viewChild.required(TemplateRef);componentInstance=viewChild("el");elementRef=viewChild("el",{read:ElementRef});directiveRefList=directives.map(({type})=>viewChild("el",{read:type}));static ɵfac=_=>new(_||D);static ɵcmp=__defineComponent({type:D,selectors:[[`d-${index++}`]],ngContentSelectors:contentArray,decls:1,vars:0,consts:result.consts,template:(rf,ctx)=>{1&rf&&(contentArray&&__projectionDef(contentArray),__template(0,templateFn,2+(component.contents?.length??0),result.vars,"ng-template"))},viewQuery:(rf,ctx)=>{1&rf&&(__viewQuerySignal(ctx.templateRef,TemplateRef,5),__viewQuerySignal(ctx.componentInstance,EL_QUERY,5),__viewQuerySignal(ctx.elementRef,EL_QUERY,5,ElementRef),directives.forEach(({type},index)=>{__viewQuerySignal(ctx.directiveRefList[index],EL_QUERY,5,type)})),2&rf&&__queryAdvance(3+directives.length)},dependencies:result.directiveList,encapsulation:2,changeDetection:0})}}({...componentConfig,inputs:this.#inputCache.inputs,contents:this.#contentCache},componentConfig.directives?.map((config,index)=>({...config,inputs:this.#inputCache.directiveList[index]}))??[]),componentInjector=Injector.create({providers:[{provide:PI_COMPONENT_LIST,useValue:list},{provide:PI_COMPONENT_INDEX,useValue:this.#index+1},{provide:PI_COMPONENT_LIST_LISTEN,useValue:this.#eventEmitter}],parent:componentConfig.injector??viewContainerRef.injector}),componentRef=createComponent(SidecarComponent,{elementInjector:componentInjector,environmentInjector:componentInjector.get(EnvironmentInjector),projectableNodes:componentConfig.contents?.map(({nodes})=>nodes).filter(Boolean)});if(viewContainerRef.createEmbeddedView(componentRef.instance.templateRef()),this.fieldComponentInstance=componentRef.instance.componentInstance(),this.fieldElementRef=componentRef.instance.elementRef(),this.fieldDirectiveRefList=componentRef.instance.directiveRefList.map(item=>item()),this.destroyComponentFn=()=>{viewContainerRef.clear(),componentRef.destroy(),this.#eventEmitter.unsubscribe()},list.length===this.#index+1){let field=componentInjector.get(PI_VIEW_FIELD_TOKEN)();field.hooks?.afterCreateComponent?.(field)}}update(list){let item=list[this.#index];deepEqual(getComponentCheckConfig(item),this.#componentCheckConfig$$())?(this.#componentConfig=item,this.#configUpdate$.update(a=>a+1),this.#eventEmitter.next(list)):this.createComponent(list,this.#viewContainerRef)}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:BaseComponent,deps:[],target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"14.0.0",version:"20.0.3",type:BaseComponent,isStandalone:!0,ngImport:i0})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:BaseComponent,decorators:[{type:Directive}]});class InteropNgControl extends NgControl{field;constructor(field){super(),this.field=field}control=this;get value(){return this.field().value}get valid(){return this.field().valid}get invalid(){return!this.field().valid}get pending(){return!1}get disabled(){return this.field().disabled}get enabled(){return!this.field().disabled}get errors(){return this.field().errors??null}get pristine(){return!0}get dirty(){return!1}get touched(){return this.field().touched}get untouched(){return!this.field().touched}get submitted(){return!1}viewToModelUpdate(newValue){}get valueChanges(){return this.field().valueChanges}get statusChanges(){return this.field().statusChanges}hasValidator(input){return Validators.required===input&&this.field().required$$()}}let formControlBinding={provide:NgControl,useFactory:()=>inject(FieldControlDirective).ngControl};class FieldControlDirective{fieldControl=input.required();cvaArray=inject(NG_VALUE_ACCESSOR);injector=inject(Injector);get cva(){return this.cvaArray[0]}#_ngControl;get ngControl(){return this.#_ngControl??=new InteropNgControl(()=>this.fieldControl())}ngOnInit(){let _pendingValue,cva=this.cva,_pendingChange=!1;cva.registerOnChange(value=>{this.fieldControl().disabled$$()||(_pendingValue=value,_pendingChange=!0,"change"===this.fieldControl().updateOn$$()&&this.fieldControl().setViewValue(value))}),cva.registerOnTouched(()=>{this.fieldControl().markAsTouched(),_pendingChange&&"blur"===this.fieldControl().updateOn$$()&&(this.fieldControl().setViewValue(_pendingValue),_pendingChange=!1)});let ref=effect(()=>{let value=this.fieldControl().modelValueToViewValue$$();untracked(()=>{cva.writeValue(value)})},{injector:this.injector});if(this.cva.writeValue(this.fieldControl().modelValueToViewValue$$()),this.disposeList.push(()=>ref.destroy()),cva.setDisabledState){let disabledRef=effect(()=>{let value=this.fieldControl().disabled$$();untracked(()=>{cva.setDisabledState(value)})},{injector:this.injector});cva.setDisabledState(this.fieldControl().disabled$$()),this.disposeList.push(()=>disabledRef.destroy())}}disposeList=[];clear(){this.disposeList.forEach(fn=>fn()),this.disposeList=[]}ngOnDestroy(){this.clear()}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:FieldControlDirective,deps:[],target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.1.0",version:"20.0.3",type:FieldControlDirective,isStandalone:!1,selector:"[fieldControl]",inputs:{fieldControl:{classPropertyName:"fieldControl",publicName:"fieldControl",isSignal:!0,isRequired:!0,transformFunction:null}},providers:[formControlBinding],ngImport:i0})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:FieldControlDirective,decorators:[{type:Directive,args:[{selector:"[fieldControl]",providers:[formControlBinding],standalone:!1}]}]});class NgComponentOutlet extends BaseComponent{ngComponentOutlet=input();ngComponentOutletInputs=input();ngComponentOutletOutputs=input();ngComponentOutletInjector=input();ngComponentOutletContent=input();ngComponentOutletFormControl=input();ngComponentOutletWrappers=input();ngComponentOutletTopDirectives=input();ngComponentOutletDirectives=input();ngComponentOutletField=input.required();#viewContainerRef=inject(ViewContainerRef);#wrappers=computed(()=>this.ngComponentOutletWrappers()?.map(item=>({...item,type:item.type.component,module:item.type.module})));#onputEqual$$=computed(()=>this.ngComponentOutletOutputs(),{equal:deepEqual});#moduleDestroy;#moduleRef$$=computed(()=>{this.#moduleDestroy?.();let injector=this.ngComponentOutletInjector()||this.#injector,module=this.ngComponentOutlet()?.type.module;if(!module)return;let moduleRef=createNgModule(module,injector);return this.#moduleDestroy=()=>{moduleRef.destroy(),this.#moduleDestroy=void 0},moduleRef});#usedEnvInjector$$=computed(()=>{let injector=this.#moduleRef$$()?.injector??(this.ngComponentOutletInjector()||this.#injector);return Injector.create({providers:[{provide:PI_VIEW_FIELD_TOKEN,useValue:this.ngComponentOutletField},{provide:PI_COMPONENT_INDEX,useValue:0}],parent:injector}).get(Injector)});#injector=inject(Injector);#formControlDirectiveConfig$$=computed(()=>{let fieldControl=this.ngComponentOutletFormControl();return fieldControl?{type:FieldControlDirective,inputs:computed(()=>({fieldControl:fieldControl}))}:void 0});#directiveConfigList$$=computed(()=>{let directivesInputs=this.ngComponentOutletDirectives(),formConfig=this.#formControlDirectiveConfig$$();return formConfig?[...directivesInputs?.()??[],formConfig]:directivesInputs?.()});#componentConfig$$=computed(()=>{let define=this.ngComponentOutlet();if(!define)return;let directives=this.#directiveConfigList$$();return{...define,type:define.type.component,module:define.type.module,inputs:this.ngComponentOutletInputs,directives:directives?directives.map(item=>{let outputs=item.outputs;return outputs?{...item,outputs:outputs}:item}):void 0,outputs:this.#onputEqual$$(),contents:this.ngComponentOutletContent()}});#componentList$$=computed(()=>{let componentConfig=this.#componentConfig$$();if(!componentConfig)return EMPTY_ARRAY;let injector=this.#usedEnvInjector$$(),list=[...this.#wrappers()??[],componentConfig],topDirectives=this.ngComponentOutletTopDirectives();if(list[0]={...list[0],injector},topDirectives){let classIndex=list[0].directives?.findIndex(item=>item.type===topDirectives[0].type);if("number"==typeof classIndex&&-1!==classIndex){let topInputs=topDirectives.pop().inputs,compInputs=list[0].directives?.[classIndex]?.inputs;list[0].directives[classIndex].inputs=computed(()=>({ngClass:function(input1,input2){if("string"==typeof input1)input1=input1.trim().split(/\s+/);else if(!input1)return input2??[];return"string"==typeof input2&&(input2=input2.trim().split(/\s+/)),new Set([...input1,...input2??[]])}(unWrapSignal(compInputs)?.ngClass,unWrapSignal(topInputs)?.ngClass)}))}list[0]={...list[0],directives:list[0].directives?[...list[0].directives,...topDirectives]:[...topDirectives]}}return list});#lastList;ngOnChanges(){let list=this.#componentList$$();if(!list.length)return this.destroyComponentFn?.();if(this.#lastList)this.#lastList!==list&&this.update(list);else{let field=this.ngComponentOutletField();field.hooks?.beforeCreateComponent?.(field),this.setFieldData(this.ngComponentOutletField,0),this.createComponent(list,this.#viewContainerRef)}this.#lastList=list}ngOnDestroy(){this.#moduleDestroy?.(),this.destroyComponentFn?.()}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:NgComponentOutlet,deps:null,target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.1.0",version:"20.0.3",type:NgComponentOutlet,isStandalone:!0,selector:"[ngComponentOutlet]",inputs:{ngComponentOutlet:{classPropertyName:"ngComponentOutlet",publicName:"ngComponentOutlet",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletInputs:{classPropertyName:"ngComponentOutletInputs",publicName:"ngComponentOutletInputs",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletOutputs:{classPropertyName:"ngComponentOutletOutputs",publicName:"ngComponentOutletOutputs",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletInjector:{classPropertyName:"ngComponentOutletInjector",publicName:"ngComponentOutletInjector",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletContent:{classPropertyName:"ngComponentOutletContent",publicName:"ngComponentOutletContent",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletFormControl:{classPropertyName:"ngComponentOutletFormControl",publicName:"ngComponentOutletFormControl",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletWrappers:{classPropertyName:"ngComponentOutletWrappers",publicName:"ngComponentOutletWrappers",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletTopDirectives:{classPropertyName:"ngComponentOutletTopDirectives",publicName:"ngComponentOutletTopDirectives",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletDirectives:{classPropertyName:"ngComponentOutletDirectives",publicName:"ngComponentOutletDirectives",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletField:{classPropertyName:"ngComponentOutletField",publicName:"ngComponentOutletField",isSignal:!0,isRequired:!0,transformFunction:null}},exportAs:["ngComponentOutlet"],usesInheritance:!0,usesOnChanges:!0,ngImport:i0})}function createAsyncCache(one,injector){let loading=new Map,cached=new Map;return list=>untracked(()=>{if(!list)return{value:computed(()=>void 0)};let hasPromise=!1,result=(one?[list]:list).map(item=>{if(cached.has(item))return cached.get(item);if(loading.has(item))return hasPromise=!0,loading.get(item);let type=item.type;if("string"!=typeof type&&!reflectComponentType(type))if("function"!=typeof type)return item;else{hasPromise=!0;let result$$=type().then(value=>{let result={...item,type:reflectComponentType(value)?{component:value}:value};return cached.set(item,result),loading.delete(item),result});return loading.set(item,result$$),result$$}{let result={...item,type:{component:type}};return cached.set(item,result),result}});return hasPromise?resource({loader:async()=>one?result[0]:Promise.all(result),injector:injector}):{value:computed(()=>one?result[0]:result)}})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:NgComponentOutlet,decorators:[{type:Directive,args:[{selector:"[ngComponentOutlet]",exportAs:"ngComponentOutlet",standalone:!0}]}]});class AngularFormBuilder extends FormBuilder{#globalConfig=inject(PI_VIEW_CONFIG_TOKEN,{optional:!0})??void 0;afterResolveConfig(rawConfig,config){let componentDefaultConfig,type=rawConfig.type,mergeStrategy=this.#globalConfig?.defaultConfigMergeStrategy;if(type){let result=this.#resolveComponent(type);result.define,componentDefaultConfig=result.defaultConfig}let directives=this.configMerge([componentDefaultConfig?.directives,rawConfig.directives],!0,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.directives??"merge");return{...config,contents:rawConfig.contents?.sort((a,b)=>a.nodes&&b.nodes?0:a.nodes?-1:1),directives:directives}}#resolveComponent(type){let define,defaultConfig;if("string"==typeof type){let config=this.#globalConfig?.types?.[type];if(!config)throw Error(`未注册${type}`);defaultConfig=config,Object.keys(config).length&&(define={...config})}else define={type};return{define,defaultConfig}}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:AngularFormBuilder,deps:null,target:i0.ɵɵFactoryTarget.Injectable});static ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:AngularFormBuilder})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:AngularFormBuilder,decorators:[{type:Injectable}]});class NgSchemaHandle extends CoreSchemaHandle{contents;directives}class PurePipe{transform(fn,...args){return fn(...args)}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PurePipe,deps:[],target:i0.ɵɵFactoryTarget.Pipe});static ɵpipe=i0.ɵɵngDeclarePipe({minVersion:"14.0.0",version:"20.0.3",ngImport:i0,type:PurePipe,isStandalone:!0,name:"pure"})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PurePipe,decorators:[{type:Pipe,args:[{name:"pure",standalone:!0}]}]});let DefaultConvertOptions={builder:AngularFormBuilder,handle:NgSchemaHandle};class PiView{schema=input.required();model=input(void 0);modelChange=output();options=input();form$$=computed(()=>this.resolvedField$()?.form.control);#lastRF;ngOnChanges(changes){let rFields=this.#resolvedFields$$();(this.#lastRF!==rFields||"model"in changes)&&this.#modelChange$$(),this.#lastRF=rFields}#modelChange$$=computed(()=>{let model=this.model();untracked(()=>this.#updateField(model))});#resolvedFields$$=computed(()=>(this.schema(),untracked(()=>this.#updateForm())));#injector=inject(Injector);#envInjector=inject(EnvironmentInjector);#builderEnvInjector;resolvedField$=signal(void 0);#disposeList=[];#updateForm(){this.#clean();let envInjector=createEnvironmentInjector([],this.#envInjector);this.#builderEnvInjector=envInjector;let result=convert(this.schema(),{...DefaultConvertOptions,...this.options(),injector:envInjector,registerOnDestroy:fn=>{envInjector.get(DestroyRef).onDestroy(()=>{fn()})}});if(this.resolvedField$.set(result),result.form.control){var input,control,injector,fn;let init,ref=(input=this.model(),control=result.form.control,injector=this.#injector,fn=value=>{untracked(()=>{result.form.control?.valueNoError$$()&&this.modelChange.emit(value)})},init=!0,effect(()=>{let modelValue=control.value$$();init?(deepEqual(modelValue,input)||fn(modelValue),init=!1):fn(modelValue)},{injector}));this.#disposeList.push(()=>ref.destroy())}return result}#clean(isDestoryed=!1){this.#disposeList.forEach(item=>item()),this.#disposeList=[],!isDestoryed&&this.#builderEnvInjector&&(this.#builderEnvInjector.destroy(),this.#builderEnvInjector=void 0)}#updateField(model){if(!this.resolvedField$())return;let field=this.resolvedField$();field.form.control?.updateValue(model)}groupInputsValue=(inputs,fields,fieldTemplateRef)=>computed(()=>({...inputs(),fields,fieldTemplateRef}));resolvedComponent=createAsyncCache(!0,this.#injector);resolvedWrapper=createAsyncCache(!1,this.#injector);topDirectives=renderConfig=>[{type:NgClass,inputs:computed(()=>({ngClass:renderConfig().ngClass??""}))}];groupHidden=field=>computed(()=>this.#groupHidden(field));#groupHidden(field){return field.fieldGroup?!field.fieldGroup().length||field.fieldGroup().every(field=>this.#groupHidden(field)):!field.define||!!field.renderConfig().hidden}ngOnDestroy(){this.#clean(!0)}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiView,deps:[],target:i0.ɵɵFactoryTarget.Component});static ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"20.0.3",type:PiView,isStandalone:!0,selector:"piying-view",inputs:{schema:{classPropertyName:"schema",publicName:"schema",isSignal:!0,isRequired:!0,transformFunction:null},model:{classPropertyName:"model",publicName:"model",isSignal:!0,isRequired:!1,transformFunction:null},options:{classPropertyName:"options",publicName:"options",isSignal:!0,isRequired:!1,transformFunction:null}},outputs:{modelChange:"modelChange"},usesOnChanges:!0,ngImport:i0,template:'<ng-template #dynamicComponent let-field>\r\n @let renderConfig = field.renderConfig();\r\n @if (!renderConfig?.hidden) {\r\n @let typeResource = resolvedComponent | pure: field.define;\r\n @let type = typeResource.value();\r\n @let wrappersResource = resolvedWrapper | pure: field.wrappers$$();\r\n @let wrappers = wrappersResource.value();\r\n @if (type) {\r\n @if (field.fieldGroup) {\r\n @if (!(groupHidden | pure: field)()) {\r\n \x3c!-- 自定义group --\x3e\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="\r\n (\r\n groupInputsValue\r\n | pure: field.inputs : field.fieldGroup() : dynamicComponent\r\n )?.()\r\n "\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n ></ng-container>\r\n }\r\n } @else if (field.fieldArray) {\r\n \x3c!-- 自定义array --\x3e\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="\r\n (\r\n groupInputsValue\r\n | pure: field.inputs : field.fieldArray() : dynamicComponent\r\n )?.()\r\n "\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n ></ng-container>\r\n } @else {\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="field.inputs()"\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletFormControl]="$any(field.form.control)"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n [ngComponentOutletContent]="field.contents"\r\n ></ng-container>\r\n }\r\n }\r\n }\r\n</ng-template>\r\n\r\n@if (resolvedField$(); as field) {\r\n <ng-container\r\n *ngTemplateOutlet="dynamicComponent; context: { $implicit: field }"\r\n ></ng-container>\r\n}\r\n',dependencies:[{kind:"directive",type:NgComponentOutlet,selector:"[ngComponentOutlet]",inputs:["ngComponentOutlet","ngComponentOutletInputs","ngComponentOutletOutputs","ngComponentOutletInjector","ngComponentOutletContent","ngComponentOutletFormControl","ngComponentOutletWrappers","ngComponentOutletTopDirectives","ngComponentOutletDirectives","ngComponentOutletField"],exportAs:["ngComponentOutlet"]},{kind:"pipe",type:PurePipe,name:"pure"},{kind:"directive",type:NgTemplateOutlet,selector:"[ngTemplateOutlet]",inputs:["ngTemplateOutletContext","ngTemplateOutlet","ngTemplateOutletInjector"]}],changeDetection:i0.ChangeDetectionStrategy.OnPush})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiView,decorators:[{type:Component,args:[{selector:"piying-view",imports:[NgComponentOutlet,PurePipe,NgTemplateOutlet],standalone:!0,changeDetection:ChangeDetectionStrategy.OnPush,template:'<ng-template #dynamicComponent let-field>\r\n @let renderConfig = field.renderConfig();\r\n @if (!renderConfig?.hidden) {\r\n @let typeResource = resolvedComponent | pure: field.define;\r\n @let type = typeResource.value();\r\n @let wrappersResource = resolvedWrapper | pure: field.wrappers$$();\r\n @let wrappers = wrappersResource.value();\r\n @if (type) {\r\n @if (field.fieldGroup) {\r\n @if (!(groupHidden | pure: field)()) {\r\n \x3c!-- 自定义group --\x3e\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="\r\n (\r\n groupInputsValue\r\n | pure: field.inputs : field.fieldGroup() : dynamicComponent\r\n )?.()\r\n "\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n ></ng-container>\r\n }\r\n } @else if (field.fieldArray) {\r\n \x3c!-- 自定义array --\x3e\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="\r\n (\r\n groupInputsValue\r\n | pure: field.inputs : field.fieldArray() : dynamicComponent\r\n )?.()\r\n "\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n ></ng-container>\r\n } @else {\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="field.inputs()"\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletFormControl]="$any(field.form.control)"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n [ngComponentOutletContent]="field.contents"\r\n ></ng-container>\r\n }\r\n }\r\n }\r\n</ng-template>\r\n\r\n@if (resolvedField$(); as field) {\r\n <ng-container\r\n *ngTemplateOutlet="dynamicComponent; context: { $implicit: field }"\r\n ></ng-container>\r\n}\r\n'}]}]});class PiWrapperBaseComponent extends BaseComponent{fieldComponentAnchor=viewChild("fieldComponent",{read:ViewContainerRef});field$$=inject(PI_VIEW_FIELD_TOKEN);props$$=computed(()=>this.field$$().props());#listen=inject(PI_COMPONENT_LIST_LISTEN);#list=inject(PI_COMPONENT_LIST);createComponent(){let result=super.createComponent(this.#list,this.fieldComponentAnchor());return this.#listen.subscribe(list=>{this.update(list)}),result}ngOnInit(){this.createComponent()}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiWrapperBaseComponent,deps:null,target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.2.0",version:"20.0.3",type:PiWrapperBaseComponent,isStandalone:!0,viewQueries:[{propertyName:"fieldComponentAnchor",first:!0,predicate:["fieldComponent"],descendants:!0,read:ViewContainerRef,isSignal:!0}],usesInheritance:!0,ngImport:i0})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiWrapperBaseComponent,decorators:[{type:Directive}]});let rawConfig=rawConfig$1;export{AngularFormBuilder,NgSchemaHandle,PI_COMPONENT_INDEX,PI_COMPONENT_LIST,PI_COMPONENT_LIST_LISTEN,PI_VIEW_FIELD_TOKEN,PiView,PiViewGroup,PiViewGroupBase,PiWrapperBaseComponent,rawConfig};
1
+ var SelectorRegexp,SelectorFlags,SelectorRegexp1,SelectorFlags1;import*as i0 from"@angular/core";import{input,Directive,ChangeDetectionStrategy,Component,InjectionToken,reflectComponentType,ɵɵelementStart as __elementStart,ɵɵlistener as __listener,ɵɵtwoWayBindingSet as __twoWayBindingSet,ɵɵprojection as __projection,ɵɵtext as __text,ɵɵtextInterpolate as __textInterpolate,ɵɵelementEnd as __elementEnd,ɵɵproperty as __property,ɵɵtwoWayProperty as __twoWayProperty,viewChild,TemplateRef,ElementRef,ɵɵdefineComponent as __defineComponent,ɵɵviewQuerySignal as __viewQuerySignal,ɵɵqueryAdvance as __queryAdvance,ɵɵprojectionDef as __projectionDef,ɵɵtemplate as __template,inject,computed,untracked,signal,EventEmitter,Injector,createComponent,EnvironmentInjector,effect,ViewContainerRef,createNgModule,resource,Injectable,Pipe,output,createEnvironmentInjector,DestroyRef,linkedSignal}from"@angular/core";import{NgTemplateOutlet,NgClass}from"@angular/common";import{deepEqual}from"fast-equals";import{unWrapSignal,FormBuilder,PI_VIEW_CONFIG_TOKEN,CoreSchemaHandle,convert,rawConfig as rawConfig$1,mergeHooksFn,asyncInputMerge}from"@piying/view-angular-core";export{asControl,asVirtualGroup,condition,layout}from"@piying/view-angular-core";import{NgControl,Validators,NG_VALUE_ACCESSOR}from"@angular/forms";class PiViewGroupBase{fields=input.required();fieldTemplateRef=input.required();static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiViewGroupBase,deps:[],target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.1.0",version:"20.0.3",type:PiViewGroupBase,isStandalone:!0,inputs:{fields:{classPropertyName:"fields",publicName:"fields",isSignal:!0,isRequired:!0,transformFunction:null},fieldTemplateRef:{classPropertyName:"fieldTemplateRef",publicName:"fieldTemplateRef",isSignal:!0,isRequired:!0,transformFunction:null}},ngImport:i0})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiViewGroupBase,decorators:[{type:Directive}]});class PiViewGroup extends PiViewGroupBase{static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiViewGroup,deps:null,target:i0.ɵɵFactoryTarget.Component});static ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"20.0.3",type:PiViewGroup,isStandalone:!0,selector:"piying-view-group",usesInheritance:!0,ngImport:i0,template:'@for (field of fields(); track field.id || $index) {\r\n <ng-container\r\n *ngTemplateOutlet="fieldTemplateRef(); context: { $implicit: field }"\r\n ></ng-container>\r\n}\r\n',dependencies:[{kind:"directive",type:NgTemplateOutlet,selector:"[ngTemplateOutlet]",inputs:["ngTemplateOutletContext","ngTemplateOutlet","ngTemplateOutletInjector"]}],changeDetection:i0.ChangeDetectionStrategy.OnPush})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiViewGroup,decorators:[{type:Component,args:[{selector:"piying-view-group",imports:[NgTemplateOutlet],standalone:!0,changeDetection:ChangeDetectionStrategy.OnPush,template:'@for (field of fields(); track field.id || $index) {\r\n <ng-container\r\n *ngTemplateOutlet="fieldTemplateRef(); context: { $implicit: field }"\r\n ></ng-container>\r\n}\r\n'}]}]});let PI_VIEW_FIELD_TOKEN=new InjectionToken("PI_VIEW_FIELD_TOKEN"),PI_COMPONENT_LIST=new InjectionToken("PI_COMPONENT_LIST"),PI_COMPONENT_INDEX=new InjectionToken("PI_COMPONENT_INDEX"),PI_COMPONENT_LIST_LISTEN=new InjectionToken("PI_COMPONENT_LIST_LISTEN"),EMPTY_ARRAY=[];function getComponentCheckConfig(a){return{...a,inputs:Object.keys(a.inputs()??{}).join(","),attributes:Object.keys(a.attributes()??{}).join(","),directives:a.directives?a.directives.map(config=>({...config,inputs:`${config.inputs?Object.keys(config.inputs()).join(","):""}`})):void 0,contents:a.contents?.map(item=>({...item,text:!!item.text}))}}let _SELECTOR_REGEXP=RegExp("(\\:not\\()|(([\\.\\#]?)[-\\w]+)|(?:\\[([-.\\w*\\\\$]+)(?:=([\"']?)([^\\]\"']*)\\5)?\\])|(\\))|(\\s*,\\s*)","g");(SelectorRegexp1=SelectorRegexp||(SelectorRegexp={}))[SelectorRegexp1.ALL=0]="ALL",SelectorRegexp1[SelectorRegexp1.NOT=1]="NOT",SelectorRegexp1[SelectorRegexp1.TAG=2]="TAG",SelectorRegexp1[SelectorRegexp1.PREFIX=3]="PREFIX",SelectorRegexp1[SelectorRegexp1.ATTRIBUTE=4]="ATTRIBUTE",SelectorRegexp1[SelectorRegexp1.ATTRIBUTE_STRING=5]="ATTRIBUTE_STRING",SelectorRegexp1[SelectorRegexp1.ATTRIBUTE_VALUE=6]="ATTRIBUTE_VALUE",SelectorRegexp1[SelectorRegexp1.NOT_END=7]="NOT_END",SelectorRegexp1[SelectorRegexp1.SEPARATOR=8]="SEPARATOR";class CssSelector{element=null;classNames=[];attrs=[];notSelectors=[];static parse(selector){let match,results=[],_addResult=(res,cssSel)=>{cssSel.notSelectors.length>0&&!cssSel.element&&0==cssSel.classNames.length&&0==cssSel.attrs.length&&(cssSel.element="*"),res.push(cssSel)},cssSelector=new CssSelector,current=cssSelector,inNot=!1;for(_SELECTOR_REGEXP.lastIndex=0;match=_SELECTOR_REGEXP.exec(selector);){if(match[SelectorRegexp.NOT]){if(inNot)throw Error("Nesting :not in a selector is not allowed");inNot=!0,current=new CssSelector,cssSelector.notSelectors.push(current)}let tag=match[SelectorRegexp.TAG];if(tag){let prefix=match[SelectorRegexp.PREFIX];"#"===prefix?current.addAttribute("id",tag.slice(1)):"."===prefix?current.addClassName(tag.slice(1)):current.setElement(tag)}let attribute=match[SelectorRegexp.ATTRIBUTE];if(attribute&&current.addAttribute(current.unescapeAttribute(attribute),match[SelectorRegexp.ATTRIBUTE_VALUE]),match[SelectorRegexp.NOT_END]&&(inNot=!1,current=cssSelector),match[SelectorRegexp.SEPARATOR]){if(inNot)throw Error("Multiple selectors in :not are not supported");_addResult(results,cssSelector),cssSelector=current=new CssSelector}}return _addResult(results,cssSelector),results}unescapeAttribute(attr){let result="",escaping=!1;for(let i=0;i<attr.length;i++){let char=attr.charAt(i);if("\\"===char){escaping=!0;continue}if("$"===char&&!escaping)throw Error(`Error in attribute selector "${attr}". Unescaped "$" is not supported. Please escape with "\\$".`);escaping=!1,result+=char}return result}escapeAttribute(attr){return attr.replace(/\\/g,"\\\\").replace(/\$/g,"\\$")}setElement(element=null){this.element=element}addAttribute(name,value=""){this.attrs.push(name,value&&value.toLowerCase()||"")}addClassName(name){this.classNames.push(name.toLowerCase())}toString(){let res=this.element||"";if(this.classNames&&this.classNames.forEach(klass=>res+=`.${klass}`),this.attrs)for(let i=0;i<this.attrs.length;i+=2){let name=this.escapeAttribute(this.attrs[i]),value=this.attrs[i+1];res+=`[${name}${value?"="+value:""}]`}return this.notSelectors.forEach(notSelector=>res+=`:not(${notSelector})`),res}}function parserSelectorToR3Selector(selector){let positive=function(selector){let classes=selector.classNames&&selector.classNames.length?[SelectorFlags.CLASS,...selector.classNames]:[];return[selector.element&&"*"!==selector.element?selector.element:"",...selector.attrs,...classes]}(selector),negative=selector.notSelectors&&selector.notSelectors.length?selector.notSelectors.map(notSelector=>(function(selector){let classes=selector.classNames&&selector.classNames.length?[SelectorFlags.CLASS,...selector.classNames]:[];return selector.element?[SelectorFlags.NOT|SelectorFlags.ELEMENT,selector.element,...selector.attrs,...classes]:selector.attrs.length?[SelectorFlags.NOT|SelectorFlags.ATTRIBUTE,...selector.attrs,...classes]:selector.classNames&&selector.classNames.length?[SelectorFlags.NOT|SelectorFlags.CLASS,...selector.classNames]:[]})(notSelector)):[];return positive.concat(...negative)}(SelectorFlags1=SelectorFlags||(SelectorFlags={}))[SelectorFlags1.NOT=1]="NOT",SelectorFlags1[SelectorFlags1.ATTRIBUTE=2]="ATTRIBUTE",SelectorFlags1[SelectorFlags1.ELEMENT=4]="ELEMENT",SelectorFlags1[SelectorFlags1.CLASS=8]="CLASS";let EL_QUERY=["el"],index=0,EmptyOBJ={};class BaseComponent{#index=inject(PI_COMPONENT_INDEX,{optional:!0});#eventEmitter;#componentConfig;#viewContainerRef;destroyComponentFn;fieldComponentInstance;fieldElementRef;fieldDirectiveRefList;#componentCheckConfig$$;#setComponentCheck(config){this.#componentCheckConfig$$=computed(()=>untracked(()=>getComponentCheckConfig(config)))}setFieldData(field,index){this.#index=index}#inputCache;#contentCache;#configUpdate$=signal(0);createComponent(list,viewContainerRef){this.destroyComponentFn?.(),this.#viewContainerRef=viewContainerRef,this.#eventEmitter=new EventEmitter;let componentConfig=list[this.#index];this.#componentConfig=componentConfig,this.#inputCache={inputs:computed(()=>(this.#configUpdate$(),this.#componentConfig.inputs()??EmptyOBJ)),directiveList:this.#componentConfig?.directives?.map((config,index)=>config.inputs?computed(()=>(this.#configUpdate$(),this.#componentConfig.directives[index].inputs())):void 0)},this.#contentCache=componentConfig.contents?.map((item,index)=>item.text?{...item,text:computed(()=>(this.#configUpdate$(),this.#componentConfig.contents[index].text()))}:item),this.#setComponentCheck(componentConfig);let SidecarComponent=function(component,directives){let contentArray,result=function(component,list){let elementTag,vars=0,consts=[],directiveList=[],propertyList=[],listenerList=[],modelList=[];if("string"==typeof component.type)elementTag=component.type;else{let componentDefine=reflectComponentType(component.type);elementTag=component.selector??componentDefine.selector,directiveList.push(component.type)}if(!elementTag)throw Error("未找到元素对应的选择器");let attributes=component.attributes?.();if(attributes)for(let key in attributes)consts.push(key,attributes[key]);let mergedList=[component,...list];for(let i=0;i<mergedList.length;i++){let item=mergedList[i];if(i>0){directiveList.push(item.type);let selectors=item.type["ɵdir"].selectors,selector=item.selector??selectors.find(selectorList=>3===selectorList.length&&""===selectorList[0]&&""===selectorList[2])[1];(!item.inputs||selector in item.inputs())&&item.inputs||(!item.model||selector in item.model)&&item.model||consts.push(selector,"")}if(item.inputs)for(let key in propertyList[i]={signal:item.inputs,keyList:[]},item.inputs())vars++,propertyList[i].keyList.push(key);for(let key in item.outputs)listenerList.push({eventName:key,listenerFn:item.outputs[key]});for(let key in item.model)vars++,modelList.push({key:key,eventName:`${key}Change`,signal:item.model[key]})}return consts.push(3),consts.push(...new Set([...listenerList.map(({eventName})=>eventName),...modelList.map(({eventName})=>eventName)])),consts.push(...new Set([...propertyList.flatMap(item=>item.keyList),...modelList.map(({key})=>key)])),{vars,consts:[["el",""],consts],directiveList,propertyList:propertyList,listenerList:listenerList,modelList,elementTag}}(component,directives);function templateFn(rf,ctx){1&rf&&(__elementStart(0,result.elementTag,1,0),result.listenerList.reduce((fn,item)=>fn(item.eventName,item.listenerFn),__listener),result.modelList.reduce((fn,item)=>fn(item.eventName,value=>{__twoWayBindingSet(item.signal,value)}),__listener),component.contents?.length&&component.contents.forEach((item,index)=>{if(item.select){var selector;__projection(index+2,index,["ngProjectAs",item.select,5,((selector=item.select)?CssSelector.parse(selector).map(parserSelectorToR3Selector):[])[0]],item.text?(rf,ctx)=>{1&rf&&__text(0),2&rf&&__textInterpolate(item.text())}:void 0,item.text?1:void 0,item.text?1:void 0)}else __projection(index+1,index)}),__elementEnd()),2&rf&&(result.propertyList.reduce((fn,{signal,keyList})=>{let value=signal();return keyList.reduce((fn,key)=>fn(key,value[key]),fn)},__property),result.modelList.reduce((fn,item)=>fn(item.key,item.signal),__twoWayProperty))}return component.contents?.length&&(contentArray=Array(component.contents.length).fill("*")),class D{templateRef=viewChild.required(TemplateRef);componentInstance=viewChild("el");elementRef=viewChild("el",{read:ElementRef});directiveRefList=directives.map(({type})=>viewChild("el",{read:type}));static ɵfac=_=>new(_||D);static ɵcmp=__defineComponent({type:D,selectors:[[`d-${index++}`]],ngContentSelectors:contentArray,decls:1,vars:0,consts:result.consts,template:(rf,ctx)=>{1&rf&&(contentArray&&__projectionDef(contentArray),__template(0,templateFn,2+(component.contents?.length??0),result.vars,"ng-template"))},viewQuery:(rf,ctx)=>{1&rf&&(__viewQuerySignal(ctx.templateRef,TemplateRef,5),__viewQuerySignal(ctx.componentInstance,EL_QUERY,5),__viewQuerySignal(ctx.elementRef,EL_QUERY,5,ElementRef),directives.forEach(({type},index)=>{__viewQuerySignal(ctx.directiveRefList[index],EL_QUERY,5,type)})),2&rf&&__queryAdvance(3+directives.length)},dependencies:result.directiveList,encapsulation:2,changeDetection:0})}}({...componentConfig,inputs:this.#inputCache.inputs,contents:this.#contentCache},componentConfig.directives?.map((config,index)=>({...config,inputs:this.#inputCache.directiveList[index]}))??[]),componentInjector=Injector.create({providers:[{provide:PI_COMPONENT_LIST,useValue:list},{provide:PI_COMPONENT_INDEX,useValue:this.#index+1},{provide:PI_COMPONENT_LIST_LISTEN,useValue:this.#eventEmitter}],parent:componentConfig.injector??viewContainerRef.injector}),componentRef=createComponent(SidecarComponent,{elementInjector:componentInjector,environmentInjector:componentInjector.get(EnvironmentInjector),projectableNodes:componentConfig.contents?.map(({nodes})=>nodes).filter(Boolean)});if(viewContainerRef.createEmbeddedView(componentRef.instance.templateRef()),this.fieldComponentInstance=componentRef.instance.componentInstance(),this.fieldElementRef=componentRef.instance.elementRef(),this.fieldDirectiveRefList=componentRef.instance.directiveRefList.map(item=>item()),this.destroyComponentFn=()=>{viewContainerRef.clear(),componentRef.destroy(),this.#eventEmitter.unsubscribe()},list.length===this.#index+1){let field=componentInjector.get(PI_VIEW_FIELD_TOKEN)();field.hooks?.afterCreateComponent?.(field)}}update(list){let item=list[this.#index];deepEqual(getComponentCheckConfig(item),this.#componentCheckConfig$$())?(this.#componentConfig=item,this.#configUpdate$.update(a=>a+1),this.#eventEmitter.next(list)):this.createComponent(list,this.#viewContainerRef)}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:BaseComponent,deps:[],target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"14.0.0",version:"20.0.3",type:BaseComponent,isStandalone:!0,ngImport:i0})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:BaseComponent,decorators:[{type:Directive}]});class InteropNgControl extends NgControl{field;constructor(field){super(),this.field=field}control=this;get value(){return this.field().value}get valid(){return this.field().valid}get invalid(){return!this.field().valid}get pending(){return!1}get disabled(){return this.field().disabled}get enabled(){return!this.field().disabled}get errors(){return this.field().errors??null}get pristine(){return!0}get dirty(){return!1}get touched(){return this.field().touched}get untouched(){return!this.field().touched}get submitted(){return!1}viewToModelUpdate(newValue){}get valueChanges(){return this.field().valueChanges}get statusChanges(){return this.field().statusChanges}hasValidator(input){return Validators.required===input&&this.field().required$$()}}let formControlBinding={provide:NgControl,useFactory:()=>inject(FieldControlDirective).ngControl};class FieldControlDirective{fieldControl=input.required();cvaArray=inject(NG_VALUE_ACCESSOR);injector=inject(Injector);get cva(){return this.cvaArray[0]}#_ngControl;get ngControl(){return this.#_ngControl??=new InteropNgControl(()=>this.fieldControl())}ngOnInit(){let _pendingValue,cva=this.cva,_pendingChange=!1;cva.registerOnChange(value=>{this.fieldControl().disabled$$()||(_pendingValue=value,_pendingChange=!0,"change"===this.fieldControl().updateOn$$()&&this.fieldControl().setViewValue(value))}),cva.registerOnTouched(()=>{this.fieldControl().markAsTouched(),_pendingChange&&"blur"===this.fieldControl().updateOn$$()&&(this.fieldControl().setViewValue(_pendingValue),_pendingChange=!1)});let ref=effect(()=>{let value=this.fieldControl().modelValueToViewValue$$();untracked(()=>{cva.writeValue(value)})},{injector:this.injector});if(this.cva.writeValue(this.fieldControl().modelValueToViewValue$$()),this.disposeList.push(()=>ref.destroy()),cva.setDisabledState){let disabledRef=effect(()=>{let value=this.fieldControl().disabled$$();untracked(()=>{cva.setDisabledState(value)})},{injector:this.injector});cva.setDisabledState(this.fieldControl().disabled$$()),this.disposeList.push(()=>disabledRef.destroy())}}disposeList=[];clear(){this.disposeList.forEach(fn=>fn()),this.disposeList=[]}ngOnDestroy(){this.clear()}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:FieldControlDirective,deps:[],target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.1.0",version:"20.0.3",type:FieldControlDirective,isStandalone:!1,selector:"[fieldControl]",inputs:{fieldControl:{classPropertyName:"fieldControl",publicName:"fieldControl",isSignal:!0,isRequired:!0,transformFunction:null}},providers:[formControlBinding],ngImport:i0})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:FieldControlDirective,decorators:[{type:Directive,args:[{selector:"[fieldControl]",providers:[formControlBinding],standalone:!1}]}]});class NgComponentOutlet extends BaseComponent{ngComponentOutlet=input();ngComponentOutletInputs=input();ngComponentOutletOutputs=input();ngComponentOutletInjector=input();ngComponentOutletContent=input();ngComponentOutletFormControl=input();ngComponentOutletWrappers=input();ngComponentOutletTopDirectives=input();ngComponentOutletDirectives=input();ngComponentOutletField=input.required();#viewContainerRef=inject(ViewContainerRef);#wrappers=computed(()=>this.ngComponentOutletWrappers()?.map(item=>({...item,type:item.type.component,module:item.type.module})));#onputEqual$$=computed(()=>this.ngComponentOutletOutputs(),{equal:deepEqual});#moduleDestroy;#moduleRef$$=computed(()=>{this.#moduleDestroy?.();let injector=this.ngComponentOutletInjector()||this.#injector,module=this.ngComponentOutlet()?.type.module;if(!module)return;let moduleRef=createNgModule(module,injector);return this.#moduleDestroy=()=>{moduleRef.destroy(),this.#moduleDestroy=void 0},moduleRef});#usedEnvInjector$$=computed(()=>{let injector=this.#moduleRef$$()?.injector??(this.ngComponentOutletInjector()||this.#injector);return Injector.create({providers:[{provide:PI_VIEW_FIELD_TOKEN,useValue:this.ngComponentOutletField},{provide:PI_COMPONENT_INDEX,useValue:0}],parent:injector}).get(Injector)});#injector=inject(Injector);#formControlDirectiveConfig$$=computed(()=>{let fieldControl=this.ngComponentOutletFormControl();return fieldControl?{type:FieldControlDirective,inputs:computed(()=>({fieldControl:fieldControl}))}:void 0});#directiveConfigList$$=computed(()=>{let directivesInputs=this.ngComponentOutletDirectives(),formConfig=this.#formControlDirectiveConfig$$();return formConfig?[...directivesInputs?.()??[],formConfig]:directivesInputs?.()});#componentConfig$$=computed(()=>{let define=this.ngComponentOutlet();if(!define)return;let directives=this.#directiveConfigList$$();return{...define,type:define.type.component,module:define.type.module,inputs:this.ngComponentOutletInputs,directives:directives?directives.map(item=>{let outputs=item.outputs;return outputs?{...item,outputs:outputs}:item}):void 0,outputs:this.#onputEqual$$(),contents:this.ngComponentOutletContent()}});#componentList$$=computed(()=>{let componentConfig=this.#componentConfig$$();if(!componentConfig)return EMPTY_ARRAY;let injector=this.#usedEnvInjector$$(),list=[...this.#wrappers()??[],componentConfig],topDirectives=this.ngComponentOutletTopDirectives();if(list[0]={...list[0],injector},topDirectives){let classIndex=list[0].directives?.findIndex(item=>item.type===topDirectives[0].type);if("number"==typeof classIndex&&-1!==classIndex){let topInputs=topDirectives.pop().inputs,compInputs=list[0].directives?.[classIndex]?.inputs;list[0].directives[classIndex].inputs=computed(()=>({ngClass:function(input1,input2){if("string"==typeof input1)input1=input1.trim().split(/\s+/);else if(!input1)return input2??[];return"string"==typeof input2&&(input2=input2.trim().split(/\s+/)),new Set([...input1,...input2??[]])}(unWrapSignal(compInputs)?.ngClass,unWrapSignal(topInputs)?.ngClass)}))}list[0]={...list[0],directives:list[0].directives?[...list[0].directives,...topDirectives]:[...topDirectives]}}return list});#lastList;ngOnChanges(){let list=this.#componentList$$();if(!list.length)return this.destroyComponentFn?.();if(this.#lastList)this.#lastList!==list&&this.update(list);else{let field=this.ngComponentOutletField();field.hooks?.beforeCreateComponent?.(field),this.setFieldData(this.ngComponentOutletField,0),this.createComponent(list,this.#viewContainerRef)}this.#lastList=list}ngOnDestroy(){this.#moduleDestroy?.(),this.destroyComponentFn?.()}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:NgComponentOutlet,deps:null,target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.1.0",version:"20.0.3",type:NgComponentOutlet,isStandalone:!0,selector:"[ngComponentOutlet]",inputs:{ngComponentOutlet:{classPropertyName:"ngComponentOutlet",publicName:"ngComponentOutlet",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletInputs:{classPropertyName:"ngComponentOutletInputs",publicName:"ngComponentOutletInputs",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletOutputs:{classPropertyName:"ngComponentOutletOutputs",publicName:"ngComponentOutletOutputs",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletInjector:{classPropertyName:"ngComponentOutletInjector",publicName:"ngComponentOutletInjector",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletContent:{classPropertyName:"ngComponentOutletContent",publicName:"ngComponentOutletContent",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletFormControl:{classPropertyName:"ngComponentOutletFormControl",publicName:"ngComponentOutletFormControl",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletWrappers:{classPropertyName:"ngComponentOutletWrappers",publicName:"ngComponentOutletWrappers",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletTopDirectives:{classPropertyName:"ngComponentOutletTopDirectives",publicName:"ngComponentOutletTopDirectives",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletDirectives:{classPropertyName:"ngComponentOutletDirectives",publicName:"ngComponentOutletDirectives",isSignal:!0,isRequired:!1,transformFunction:null},ngComponentOutletField:{classPropertyName:"ngComponentOutletField",publicName:"ngComponentOutletField",isSignal:!0,isRequired:!0,transformFunction:null}},exportAs:["ngComponentOutlet"],usesInheritance:!0,usesOnChanges:!0,ngImport:i0})}function createAsyncCache(one,injector){let loading=new Map,cached=new Map;return list=>untracked(()=>{if(!list)return{value:computed(()=>void 0)};let hasPromise=!1,result=(one?[list]:list).map(item=>{if(cached.has(item))return cached.get(item);if(loading.has(item))return hasPromise=!0,loading.get(item);let type=item.type;if("string"!=typeof type&&!reflectComponentType(type))if("function"!=typeof type)return item;else{hasPromise=!0;let result$$=type().then(value=>{let result={...item,type:reflectComponentType(value)?{component:value}:value};return cached.set(item,result),loading.delete(item),result});return loading.set(item,result$$),result$$}{let result={...item,type:{component:type}};return cached.set(item,result),result}});return hasPromise?resource({loader:async()=>one?result[0]:Promise.all(result),injector:injector}):{value:computed(()=>one?result[0]:result)}})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:NgComponentOutlet,decorators:[{type:Directive,args:[{selector:"[ngComponentOutlet]",exportAs:"ngComponentOutlet",standalone:!0}]}]});class AngularFormBuilder extends FormBuilder{#globalConfig=inject(PI_VIEW_CONFIG_TOKEN,{optional:!0})??void 0;afterResolveConfig(rawConfig,config){let componentDefaultConfig,type=rawConfig.type,mergeStrategy=this.#globalConfig?.defaultConfigMergeStrategy;if(type){let result=this.#resolveComponent(type);result.define,componentDefaultConfig=result.defaultConfig}let directives=this.configMerge([componentDefaultConfig?.directives,rawConfig.directives],!0,"string"==typeof mergeStrategy?mergeStrategy:mergeStrategy?.directives??"merge");return{...config,contents:rawConfig.contents?.sort((a,b)=>a.nodes&&b.nodes?0:a.nodes?-1:1),directives:directives}}#resolveComponent(type){let define,defaultConfig;if("string"==typeof type){let config=this.#globalConfig?.types?.[type];if(!config)throw Error(`未注册${type}`);defaultConfig=config,Object.keys(config).length&&(define={...config})}else define={type};return{define,defaultConfig}}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:AngularFormBuilder,deps:null,target:i0.ɵɵFactoryTarget.Injectable});static ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:AngularFormBuilder})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:AngularFormBuilder,decorators:[{type:Injectable}]});class NgSchemaHandle extends CoreSchemaHandle{contents;directives}class PurePipe{transform(fn,...args){return fn(...args)}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PurePipe,deps:[],target:i0.ɵɵFactoryTarget.Pipe});static ɵpipe=i0.ɵɵngDeclarePipe({minVersion:"14.0.0",version:"20.0.3",ngImport:i0,type:PurePipe,isStandalone:!0,name:"pure"})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PurePipe,decorators:[{type:Pipe,args:[{name:"pure",standalone:!0}]}]});let DefaultConvertOptions={builder:AngularFormBuilder,handle:NgSchemaHandle};class PiView{schema=input.required();model=input(void 0);modelChange=output();options=input();form$$=computed(()=>this.resolvedField$()?.form.control);#lastRF;ngOnChanges(changes){let rFields=this.#resolvedFields$$();(this.#lastRF!==rFields||"model"in changes)&&this.#modelChange$$(),this.#lastRF=rFields}#modelChange$$=computed(()=>{let model=this.model();untracked(()=>this.#updateField(model))});#resolvedFields$$=computed(()=>(this.schema(),untracked(()=>this.#updateForm())));#injector=inject(Injector);#envInjector=inject(EnvironmentInjector);#builderEnvInjector;resolvedField$=signal(void 0);#disposeList=[];#updateForm(){this.#clean();let envInjector=createEnvironmentInjector([],this.#envInjector);this.#builderEnvInjector=envInjector;let result=convert(this.schema(),{...DefaultConvertOptions,...this.options(),injector:envInjector,registerOnDestroy:fn=>{envInjector.get(DestroyRef).onDestroy(()=>{fn()})}});if(this.resolvedField$.set(result),result.form.control){var input,control,injector,fn;let init,ref=(input=this.model(),control=result.form.control,injector=this.#injector,fn=value=>{untracked(()=>{result.form.control?.valueNoError$$()&&this.modelChange.emit(value)})},init=!0,effect(()=>{let modelValue=control.value$$();init?(deepEqual(modelValue,input)||fn(modelValue),init=!1):fn(modelValue)},{injector}));this.#disposeList.push(()=>ref.destroy())}return result}#clean(isDestoryed=!1){this.#disposeList.forEach(item=>item()),this.#disposeList=[],!isDestoryed&&this.#builderEnvInjector&&(this.#builderEnvInjector.destroy(),this.#builderEnvInjector=void 0)}#updateField(model){if(!this.resolvedField$())return;let field=this.resolvedField$();field.form.control?.updateValue(model)}groupInputsValue=(inputs,fields,fieldTemplateRef)=>computed(()=>({...inputs(),fields,fieldTemplateRef}));resolvedComponent=createAsyncCache(!0,this.#injector);resolvedWrapper=createAsyncCache(!1,this.#injector);topDirectives=renderConfig=>[{type:NgClass,inputs:computed(()=>({ngClass:renderConfig().ngClass??""}))}];groupHidden=field=>computed(()=>this.#groupHidden(field));#groupHidden(field){return field.fieldGroup?!field.fieldGroup().length||field.fieldGroup().every(field=>this.#groupHidden(field)):!field.define||!!field.renderConfig().hidden}ngOnDestroy(){this.#clean(!0)}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiView,deps:[],target:i0.ɵɵFactoryTarget.Component});static ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"20.0.3",type:PiView,isStandalone:!0,selector:"piying-view",inputs:{schema:{classPropertyName:"schema",publicName:"schema",isSignal:!0,isRequired:!0,transformFunction:null},model:{classPropertyName:"model",publicName:"model",isSignal:!0,isRequired:!1,transformFunction:null},options:{classPropertyName:"options",publicName:"options",isSignal:!0,isRequired:!1,transformFunction:null}},outputs:{modelChange:"modelChange"},usesOnChanges:!0,ngImport:i0,template:'<ng-template #dynamicComponent let-field>\r\n @let renderConfig = field.renderConfig();\r\n @if (!renderConfig?.hidden) {\r\n @let typeResource = resolvedComponent | pure: field.define;\r\n @let type = typeResource.value();\r\n @let wrappersResource = resolvedWrapper | pure: field.wrappers$$();\r\n @let wrappers = wrappersResource.value();\r\n @if (type) {\r\n @if (field.fieldGroup) {\r\n @if (!(groupHidden | pure: field)()) {\r\n \x3c!-- 自定义group --\x3e\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="\r\n (\r\n groupInputsValue\r\n | pure: field.inputs : field.fieldGroup() : dynamicComponent\r\n )?.()\r\n "\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n ></ng-container>\r\n }\r\n } @else if (field.fieldArray) {\r\n \x3c!-- 自定义array --\x3e\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="\r\n (\r\n groupInputsValue\r\n | pure: field.inputs : field.fieldArray() : dynamicComponent\r\n )?.()\r\n "\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n ></ng-container>\r\n } @else {\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="field.inputs()"\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletFormControl]="$any(field.form.control)"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n [ngComponentOutletContent]="field.contents"\r\n ></ng-container>\r\n }\r\n }\r\n }\r\n</ng-template>\r\n\r\n@if (resolvedField$(); as field) {\r\n <ng-container\r\n *ngTemplateOutlet="dynamicComponent; context: { $implicit: field }"\r\n ></ng-container>\r\n}\r\n',dependencies:[{kind:"directive",type:NgComponentOutlet,selector:"[ngComponentOutlet]",inputs:["ngComponentOutlet","ngComponentOutletInputs","ngComponentOutletOutputs","ngComponentOutletInjector","ngComponentOutletContent","ngComponentOutletFormControl","ngComponentOutletWrappers","ngComponentOutletTopDirectives","ngComponentOutletDirectives","ngComponentOutletField"],exportAs:["ngComponentOutlet"]},{kind:"pipe",type:PurePipe,name:"pure"},{kind:"directive",type:NgTemplateOutlet,selector:"[ngTemplateOutlet]",inputs:["ngTemplateOutletContext","ngTemplateOutlet","ngTemplateOutletInjector"]}],changeDetection:i0.ChangeDetectionStrategy.OnPush})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiView,decorators:[{type:Component,args:[{selector:"piying-view",imports:[NgComponentOutlet,PurePipe,NgTemplateOutlet],standalone:!0,changeDetection:ChangeDetectionStrategy.OnPush,template:'<ng-template #dynamicComponent let-field>\r\n @let renderConfig = field.renderConfig();\r\n @if (!renderConfig?.hidden) {\r\n @let typeResource = resolvedComponent | pure: field.define;\r\n @let type = typeResource.value();\r\n @let wrappersResource = resolvedWrapper | pure: field.wrappers$$();\r\n @let wrappers = wrappersResource.value();\r\n @if (type) {\r\n @if (field.fieldGroup) {\r\n @if (!(groupHidden | pure: field)()) {\r\n \x3c!-- 自定义group --\x3e\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="\r\n (\r\n groupInputsValue\r\n | pure: field.inputs : field.fieldGroup() : dynamicComponent\r\n )?.()\r\n "\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n ></ng-container>\r\n }\r\n } @else if (field.fieldArray) {\r\n \x3c!-- 自定义array --\x3e\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="\r\n (\r\n groupInputsValue\r\n | pure: field.inputs : field.fieldArray() : dynamicComponent\r\n )?.()\r\n "\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n ></ng-container>\r\n } @else {\r\n <ng-container\r\n [ngComponentOutlet]="type"\r\n [ngComponentOutletInputs]="field.inputs()"\r\n [ngComponentOutletOutputs]="field.outputs()"\r\n [ngComponentOutletFormControl]="$any(field.form.control)"\r\n [ngComponentOutletWrappers]="wrappers"\r\n [ngComponentOutletField]="field"\r\n [ngComponentOutletDirectives]="field.directives"\r\n [ngComponentOutletTopDirectives]="\r\n topDirectives | pure: field.renderConfig\r\n "\r\n [ngComponentOutletContent]="field.contents"\r\n ></ng-container>\r\n }\r\n }\r\n }\r\n</ng-template>\r\n\r\n@if (resolvedField$(); as field) {\r\n <ng-container\r\n *ngTemplateOutlet="dynamicComponent; context: { $implicit: field }"\r\n ></ng-container>\r\n}\r\n'}]}]});class PiWrapperBaseComponent extends BaseComponent{fieldComponentAnchor=viewChild("fieldComponent",{read:ViewContainerRef});field$$=inject(PI_VIEW_FIELD_TOKEN);props$$=computed(()=>this.field$$().props());#listen=inject(PI_COMPONENT_LIST_LISTEN);#list=inject(PI_COMPONENT_LIST);createComponent(){let result=super.createComponent(this.#list,this.fieldComponentAnchor());return this.#listen.subscribe(list=>{this.update(list)}),result}ngOnInit(){this.createComponent()}static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiWrapperBaseComponent,deps:null,target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.2.0",version:"20.0.3",type:PiWrapperBaseComponent,isStandalone:!0,viewQueries:[{propertyName:"fieldComponentAnchor",first:!0,predicate:["fieldComponent"],descendants:!0,read:ViewContainerRef,isSignal:!0}],usesInheritance:!0,ngImport:i0})}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiWrapperBaseComponent,decorators:[{type:Directive}]});let rawConfig=rawConfig$1;function setDirectives(items){return rawConfig(field=>{field.directives=items})}function patchDirectives(items){return rawConfig(field=>{field.directives??=[],field.directives.push(...items)})}function patchAsyncDirective(fn){return rawConfig(field=>{mergeHooksFn({fieldResolved:field=>{field.directives??=signal([]);let directive=fn(field),inputs=directive.inputs,inputs$=signal({});inputs&&(inputs$.set(Object.keys(inputs).reduce((obj,key)=>(obj[key]=void 0,obj),{})),inputs$=asyncInputMerge(inputs,inputs$));let oldDirectives=field.directives;field.directives=linkedSignal(()=>[...oldDirectives(),{...directive,inputs:inputs$}])}},{position:"bottom"},field)})}export{AngularFormBuilder,NgSchemaHandle,PI_COMPONENT_INDEX,PI_COMPONENT_LIST,PI_COMPONENT_LIST_LISTEN,PI_VIEW_FIELD_TOKEN,PiView,PiViewGroup,PiViewGroupBase,PiWrapperBaseComponent,patchAsyncDirective,patchDirectives,rawConfig,setDirectives};
package/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { Type, Signal, WritableSignal, Injector, InjectionToken, EventEmitter, TemplateRef, OnChanges, SimpleChanges, ElementRef, ViewContainerRef } from '@angular/core';
3
- import { CoreRawViewOutputs, CoreRawViewAttributes, CoreRawViewInputs, CoreRawWrapperConfig, ConfigMergeStrategy, CoreWrapperConfig1, LazyImport, CoreSchemaHandle, PiResolvedCommonViewFieldConfig, CoreResolvedComponentDefine, CoreRawComponentDefine, CoreResolvedWrapperConfig, SetOptional, FormBuilder, FieldGroup, FieldArray, FieldControl } from '@piying/view-angular-core';
3
+ import { CoreRawViewOutputs, CoreRawViewAttributes, CoreRawViewInputs, CoreRawWrapperConfig, ConfigMergeStrategy, CoreWrapperConfig1, LazyImport, CoreSchemaHandle, PiResolvedCommonViewFieldConfig, CoreResolvedComponentDefine, CoreRawComponentDefine, CoreResolvedWrapperConfig, SetOptional, FormBuilder, FieldArray, FieldGroup, FieldControl, _PiResolvedCommonViewFieldConfig } from '@piying/view-angular-core';
4
4
  export { asControl, asVirtualGroup, condition, layout } from '@piying/view-angular-core';
5
+ import * as _piying_valibot_visit from '@piying/valibot-visit';
5
6
  import { ConvertOptions, RawConfigCommon } from '@piying/valibot-visit';
6
7
  import * as v from 'valibot';
7
8
  import * as _piying_view_angular from '@piying/view-angular';
@@ -126,7 +127,7 @@ declare class PiView implements OnChanges {
126
127
  options: _angular_core.InputSignal<(Omit<SetOptional<NgConvertOptions, "handle" | "builder">, "fieldGlobalConfig"> & {
127
128
  fieldGlobalConfig?: PiViewConfig;
128
129
  }) | undefined>;
129
- form$$: _angular_core.Signal<FieldGroup<any> | FieldArray<any> | FieldControl<any> | undefined>;
130
+ form$$: _angular_core.Signal<FieldArray<any> | FieldGroup<any> | FieldControl<any> | undefined>;
130
131
  ngOnChanges(changes: SimpleChanges): void;
131
132
  resolvedField$: _angular_core.WritableSignal<PiResolvedViewFieldConfig | undefined>;
132
133
  groupInputsValue: (inputs: PiResolvedViewFieldConfig["inputs"], fields: PiResolvedViewFieldConfig[], fieldTemplateRef: TemplateRef<any>) => _angular_core.Signal<{
@@ -176,6 +177,12 @@ declare class PiWrapperBaseComponent extends BaseComponent {
176
177
 
177
178
  declare const rawConfig: RawConfigCommon<NgSchemaHandle>;
178
179
 
180
+ declare function setDirectives<T>(items: NgDirectiveConfig[]): _piying_valibot_visit.RawConfigAction<string, T, any>;
181
+ declare function patchDirectives(items: NgDirectiveConfig[]): _piying_valibot_visit.RawConfigAction<string, unknown, any>;
182
+ declare function patchAsyncDirective<T>(fn: (field: _PiResolvedCommonViewFieldConfig) => Omit<NgDirectiveConfig, 'inputs'> & {
183
+ inputs?: Record<string, any>;
184
+ }): _piying_valibot_visit.RawConfigAction<string, T, any>;
185
+
179
186
  declare class AngularFormBuilder extends FormBuilder<NgSchemaHandle> {
180
187
  #private;
181
188
  afterResolveConfig(rawConfig: NgSchemaHandle, config: PiResolvedViewFieldConfig): PiResolvedViewFieldConfig;
@@ -183,5 +190,5 @@ declare class AngularFormBuilder extends FormBuilder<NgSchemaHandle> {
183
190
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<AngularFormBuilder>;
184
191
  }
185
192
 
186
- export { AngularFormBuilder, NgSchemaHandle, PI_COMPONENT_INDEX, PI_COMPONENT_LIST_LISTEN, PI_VIEW_FIELD_TOKEN, PiView, PiViewGroup, PiViewGroupBase, PiWrapperBaseComponent, rawConfig };
193
+ export { AngularFormBuilder, NgSchemaHandle, PI_COMPONENT_INDEX, PI_COMPONENT_LIST_LISTEN, PI_VIEW_FIELD_TOKEN, PiView, PiViewGroup, PiViewGroupBase, PiWrapperBaseComponent, patchAsyncDirective, patchDirectives, rawConfig, setDirectives };
187
194
  export type { ConfigMergeStrategyObject, NgDirectiveConfig, NgRawComponentDefine, NgResolvedComponentDefine1, NgResolvedWraaperConfig, PiComponentDefaultConfig, PiDefaultRawViewFieldConfig, PiResolvedViewFieldConfig, PiViewConfig };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@piying/view-angular",
3
- "version": "0.6.10",
3
+ "version": "0.6.12",
4
4
  "peerDependencies": {
5
5
  "valibot": "^1.1.0"
6
6
  },
7
7
  "dependencies": {
8
- "@piying/view-angular-core": "0.6.10",
8
+ "@piying/view-angular-core": "0.6.12",
9
9
  "tslib": "^2.3.0"
10
10
  },
11
11
  "sideEffects": false,