@piying/view-angular 0.6.21 → 0.6.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/piying-view-angular.mjs +1 -1
- package/index.d.ts +12 -12
- package/package.json +2 -2
|
@@ -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,ViewContainerRef,createNgModule,resource,effect,Injectable,Pipe,output,createEnvironmentInjector,DestroyRef,linkedSignal}from"@angular/core";import{NgTemplateOutlet}from"@angular/common";import{deepEqual}from"fast-equals";import{NgControl,Validators,NG_VALUE_ACCESSOR}from"@angular/forms";import{createViewControlLink,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";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) {\n <ng-container\n *ngTemplateOutlet="fieldTemplateRef(); context: { $implicit: field }"\n ></ng-container>\n}\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) {\n <ng-container\n *ngTemplateOutlet="fieldTemplateRef(); context: { $implicit: field }"\n ></ng-container>\n}\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.entries(a.attributes()??{}).map((key,value)=>`${key}:${value}`).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&¤t.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)),attributes:computed(()=>(this.#configUpdate$(),this.#componentConfig.attributes()??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,attributes:this.#inputCache.attributes,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(){this.disposeList=createViewControlLink(this.fieldControl,this.cva,this.injector)}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];return list[0]={...list[0],injector},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);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>\n @let renderConfig = field.renderConfig();\n @if (!renderConfig?.hidden) {\n @let typeResource = resolvedComponent | pure: field.define;\n @let type = typeResource.value();\n @let wrappersResource = resolvedWrapper | pure: field.wrappers();\n @let wrappers = wrappersResource.value();\n @if (type) {\n @if (field.fieldGroup) {\n @if (!(groupHidden | pure: field)()) {\n \x3c!-- 自定义group --\x3e\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="\n (\n groupInputsValue\n | pure: field.inputs : field.fieldGroup() : dynamicComponent\n )?.()\n "\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n ></ng-container>\n }\n } @else if (field.fieldArray) {\n \x3c!-- 自定义array --\x3e\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="\n (\n groupInputsValue\n | pure: field.inputs : field.fieldArray() : dynamicComponent\n )?.()\n "\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n ></ng-container>\n } @else {\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="field.inputs()"\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletFormControl]="$any(field.form.control)"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n [ngComponentOutletContent]="field.contents"\n ></ng-container>\n }\n }\n }\n</ng-template>\n\n@if (resolvedField$(); as field) {\n <ng-container\n *ngTemplateOutlet="dynamicComponent; context: { $implicit: field }"\n ></ng-container>\n}\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>\n @let renderConfig = field.renderConfig();\n @if (!renderConfig?.hidden) {\n @let typeResource = resolvedComponent | pure: field.define;\n @let type = typeResource.value();\n @let wrappersResource = resolvedWrapper | pure: field.wrappers();\n @let wrappers = wrappersResource.value();\n @if (type) {\n @if (field.fieldGroup) {\n @if (!(groupHidden | pure: field)()) {\n \x3c!-- 自定义group --\x3e\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="\n (\n groupInputsValue\n | pure: field.inputs : field.fieldGroup() : dynamicComponent\n )?.()\n "\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n ></ng-container>\n }\n } @else if (field.fieldArray) {\n \x3c!-- 自定义array --\x3e\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="\n (\n groupInputsValue\n | pure: field.inputs : field.fieldArray() : dynamicComponent\n )?.()\n "\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n ></ng-container>\n } @else {\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="field.inputs()"\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletFormControl]="$any(field.form.control)"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n [ngComponentOutletContent]="field.contents"\n ></ng-container>\n }\n }\n }\n</ng-template>\n\n@if (resolvedField$(); as field) {\n <ng-container\n *ngTemplateOutlet="dynamicComponent; context: { $implicit: field }"\n ></ng-container>\n}\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};
|
|
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,ViewContainerRef,createNgModule,resource,effect,Injectable,Pipe,output,createEnvironmentInjector,DestroyRef,linkedSignal}from"@angular/core";import{NgTemplateOutlet}from"@angular/common";import{deepEqual}from"fast-equals";import{NgControl,Validators,NG_VALUE_ACCESSOR}from"@angular/forms";import{createViewControlLink,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";class PiyingViewGroupBase{fields=input.required();fieldTemplateRef=input.required();static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiyingViewGroupBase,deps:[],target:i0.ɵɵFactoryTarget.Directive});static ɵdir=i0.ɵɵngDeclareDirective({minVersion:"17.1.0",version:"20.0.3",type:PiyingViewGroupBase,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:PiyingViewGroupBase,decorators:[{type:Directive}]});class PiyingViewGroup extends PiyingViewGroupBase{static ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"20.0.3",ngImport:i0,type:PiyingViewGroup,deps:null,target:i0.ɵɵFactoryTarget.Component});static ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"20.0.3",type:PiyingViewGroup,isStandalone:!0,selector:"piying-view-group",usesInheritance:!0,ngImport:i0,template:'@for (field of fields(); track field.id || $index) {\n <ng-container\n *ngTemplateOutlet="fieldTemplateRef(); context: { $implicit: field }"\n ></ng-container>\n}\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:PiyingViewGroup,decorators:[{type:Component,args:[{selector:"piying-view-group",imports:[NgTemplateOutlet],standalone:!0,changeDetection:ChangeDetectionStrategy.OnPush,template:'@for (field of fields(); track field.id || $index) {\n <ng-container\n *ngTemplateOutlet="fieldTemplateRef(); context: { $implicit: field }"\n ></ng-container>\n}\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.entries(a.attributes()??{}).map((key,value)=>`${key}:${value}`).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&¤t.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)),attributes:computed(()=>(this.#configUpdate$(),this.#componentConfig.attributes()??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,attributes:this.#inputCache.attributes,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(){this.disposeList=createViewControlLink(this.fieldControl,this.cva,this.injector)}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];return list[0]={...list[0],injector},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 PiyingView{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);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:PiyingView,deps:[],target:i0.ɵɵFactoryTarget.Component});static ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"20.0.3",type:PiyingView,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>\n @let renderConfig = field.renderConfig();\n @if (!renderConfig?.hidden) {\n @let typeResource = resolvedComponent | pure: field.define;\n @let type = typeResource.value();\n @let wrappersResource = resolvedWrapper | pure: field.wrappers();\n @let wrappers = wrappersResource.value();\n @if (type) {\n @if (field.fieldGroup) {\n @if (!(groupHidden | pure: field)()) {\n \x3c!-- 自定义group --\x3e\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="\n (\n groupInputsValue\n | pure: field.inputs : field.fieldGroup() : dynamicComponent\n )?.()\n "\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n ></ng-container>\n }\n } @else if (field.fieldArray) {\n \x3c!-- 自定义array --\x3e\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="\n (\n groupInputsValue\n | pure: field.inputs : field.fieldArray() : dynamicComponent\n )?.()\n "\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n ></ng-container>\n } @else {\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="field.inputs()"\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletFormControl]="$any(field.form.control)"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n [ngComponentOutletContent]="field.contents"\n ></ng-container>\n }\n }\n }\n</ng-template>\n\n@if (resolvedField$(); as field) {\n <ng-container\n *ngTemplateOutlet="dynamicComponent; context: { $implicit: field }"\n ></ng-container>\n}\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:PiyingView,decorators:[{type:Component,args:[{selector:"piying-view",imports:[NgComponentOutlet,PurePipe,NgTemplateOutlet],standalone:!0,changeDetection:ChangeDetectionStrategy.OnPush,template:'<ng-template #dynamicComponent let-field>\n @let renderConfig = field.renderConfig();\n @if (!renderConfig?.hidden) {\n @let typeResource = resolvedComponent | pure: field.define;\n @let type = typeResource.value();\n @let wrappersResource = resolvedWrapper | pure: field.wrappers();\n @let wrappers = wrappersResource.value();\n @if (type) {\n @if (field.fieldGroup) {\n @if (!(groupHidden | pure: field)()) {\n \x3c!-- 自定义group --\x3e\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="\n (\n groupInputsValue\n | pure: field.inputs : field.fieldGroup() : dynamicComponent\n )?.()\n "\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n ></ng-container>\n }\n } @else if (field.fieldArray) {\n \x3c!-- 自定义array --\x3e\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="\n (\n groupInputsValue\n | pure: field.inputs : field.fieldArray() : dynamicComponent\n )?.()\n "\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n ></ng-container>\n } @else {\n <ng-container\n [ngComponentOutlet]="type"\n [ngComponentOutletInputs]="field.inputs()"\n [ngComponentOutletOutputs]="field.outputs()"\n [ngComponentOutletFormControl]="$any(field.form.control)"\n [ngComponentOutletWrappers]="wrappers"\n [ngComponentOutletField]="field"\n [ngComponentOutletDirectives]="field.directives"\n [ngComponentOutletContent]="field.contents"\n ></ng-container>\n }\n }\n }\n</ng-template>\n\n@if (resolvedField$(); as field) {\n <ng-container\n *ngTemplateOutlet="dynamicComponent; context: { $implicit: field }"\n ></ng-container>\n}\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,PiWrapperBaseComponent,PiyingView,PiyingViewGroup,PiyingViewGroupBase,patchAsyncDirective,patchDirectives,rawConfig,setDirectives};
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, FieldControl,
|
|
3
|
+
import { CoreRawViewOutputs, CoreRawViewAttributes, CoreRawViewInputs, CoreRawWrapperConfig, ConfigMergeStrategy, CoreWrapperConfig1, LazyImport, CoreSchemaHandle, PiResolvedCommonViewFieldConfig, CoreResolvedComponentDefine, CoreRawComponentDefine, CoreResolvedWrapperConfig, SetOptional, FormBuilder, FieldControl, FieldArray, FieldGroup, _PiResolvedCommonViewFieldConfig } from '@piying/view-angular-core';
|
|
4
4
|
export { asControl, asVirtualGroup, condition, layout } from '@piying/view-angular-core';
|
|
5
5
|
import * as _piying_valibot_visit from '@piying/valibot-visit';
|
|
6
6
|
import { ConvertOptions, RawConfigCommon } from '@piying/valibot-visit';
|
|
@@ -102,16 +102,16 @@ type NgResolvedWraaperConfig = Omit<CoreResolvedWrapperConfig, 'type'> & {
|
|
|
102
102
|
type: NgComponentDefine;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
declare class
|
|
105
|
+
declare class PiyingViewGroupBase {
|
|
106
106
|
fields: _angular_core.InputSignal<PiResolvedViewFieldConfig[]>;
|
|
107
107
|
fieldTemplateRef: _angular_core.InputSignal<TemplateRef<any>>;
|
|
108
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<
|
|
109
|
-
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<
|
|
108
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<PiyingViewGroupBase, never>;
|
|
109
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<PiyingViewGroupBase, never, never, { "fields": { "alias": "fields"; "required": true; "isSignal": true; }; "fieldTemplateRef": { "alias": "fieldTemplateRef"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
declare class
|
|
113
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<
|
|
114
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<
|
|
112
|
+
declare class PiyingViewGroup extends PiyingViewGroupBase {
|
|
113
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<PiyingViewGroup, never>;
|
|
114
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<PiyingViewGroup, "piying-view-group", never, {}, {}, never, never, true, never>;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
type NgConvertOptions = SetOptional<ConvertOptions, 'handle'> & {
|
|
@@ -119,7 +119,7 @@ type NgConvertOptions = SetOptional<ConvertOptions, 'handle'> & {
|
|
|
119
119
|
fieldGlobalConfig?: PiViewConfig;
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
declare class
|
|
122
|
+
declare class PiyingView implements OnChanges {
|
|
123
123
|
#private;
|
|
124
124
|
schema: _angular_core.InputSignal<v.BaseSchema<any, any, any> | v.SchemaWithPipe<any>>;
|
|
125
125
|
model: _angular_core.InputSignal<any>;
|
|
@@ -127,7 +127,7 @@ declare class PiView implements OnChanges {
|
|
|
127
127
|
options: _angular_core.InputSignal<(Omit<SetOptional<NgConvertOptions, "handle" | "builder">, "fieldGlobalConfig"> & {
|
|
128
128
|
fieldGlobalConfig?: PiViewConfig;
|
|
129
129
|
}) | undefined>;
|
|
130
|
-
form$$: _angular_core.Signal<FieldControl<any> |
|
|
130
|
+
form$$: _angular_core.Signal<FieldControl<any> | FieldArray<any> | FieldGroup<any> | undefined>;
|
|
131
131
|
ngOnChanges(changes: SimpleChanges): void;
|
|
132
132
|
resolvedField$: _angular_core.WritableSignal<PiResolvedViewFieldConfig | undefined>;
|
|
133
133
|
groupInputsValue: (inputs: PiResolvedViewFieldConfig["inputs"], fields: PiResolvedViewFieldConfig[], fieldTemplateRef: TemplateRef<any>) => _angular_core.Signal<{
|
|
@@ -146,8 +146,8 @@ declare class PiView implements OnChanges {
|
|
|
146
146
|
};
|
|
147
147
|
groupHidden: (field: PiResolvedViewFieldConfig) => _angular_core.Signal<boolean>;
|
|
148
148
|
ngOnDestroy(): void;
|
|
149
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<
|
|
150
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<
|
|
149
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<PiyingView, never>;
|
|
150
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<PiyingView, "piying-view", never, { "schema": { "alias": "schema"; "required": true; "isSignal": true; }; "model": { "alias": "model"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; }, { "modelChange": "modelChange"; }, never, never, true, never>;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
declare class BaseComponent {
|
|
@@ -189,5 +189,5 @@ declare class AngularFormBuilder extends FormBuilder<NgSchemaHandle> {
|
|
|
189
189
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<AngularFormBuilder>;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
export { AngularFormBuilder, NgSchemaHandle, PI_COMPONENT_INDEX, PI_COMPONENT_LIST_LISTEN, PI_VIEW_FIELD_TOKEN,
|
|
192
|
+
export { AngularFormBuilder, NgSchemaHandle, PI_COMPONENT_INDEX, PI_COMPONENT_LIST_LISTEN, PI_VIEW_FIELD_TOKEN, PiWrapperBaseComponent, PiyingView, PiyingViewGroup, PiyingViewGroupBase, patchAsyncDirective, patchDirectives, rawConfig, setDirectives };
|
|
193
193
|
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.
|
|
3
|
+
"version": "0.6.23",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"valibot": "^1.1.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@piying/view-angular-core": "0.6.
|
|
8
|
+
"@piying/view-angular-core": "0.6.23",
|
|
9
9
|
"tslib": "^2.3.0"
|
|
10
10
|
},
|
|
11
11
|
"sideEffects": false,
|