@@ -10,10 +10,12 @@ import {
1010} from '@angular/core' ;
1111import { FormsModule , NG_VALUE_ACCESSOR } from '@angular/forms' ;
1212import {
13+ actions ,
1314 AttributesDirective ,
1415 BaseControl ,
1516 PI_INPUT_OPTIONS_TOKEN ,
1617 PI_VIEW_FIELD_TOKEN ,
18+ PiResolvedViewFieldConfig ,
1719 PiyingView ,
1820} from '@piying/view-angular' ;
1921
@@ -22,6 +24,7 @@ import { CdkConnectedOverlayConfig, CdkOverlayOrigin } from '@angular/cdk/overla
2224import * as v from 'valibot' ;
2325import { CdkConnectedOverlay , CustomMenuTrigger } from '@piying-lib/angular-core' ;
2426import { MENU_TRIGGER , PARENT_OR_NEW_MENU_STACK_PROVIDER } from '@angular/cdk/menu' ;
27+ import { PickerRefService } from './picker-ref.service' ;
2528/*
2629 * PickerRefFCC - 选择器引用组件
2730 *
@@ -57,6 +60,7 @@ import { MENU_TRIGGER, PARENT_OR_NEW_MENU_STACK_PROVIDER } from '@angular/cdk/me
5760 useExisting : CustomMenuTrigger ,
5861 } ,
5962 PARENT_OR_NEW_MENU_STACK_PROVIDER ,
63+ PickerRefService ,
6064 ] ,
6165 changeDetection : ChangeDetectionStrategy . OnPush ,
6266} )
@@ -67,10 +71,10 @@ export class PickerRefFCC extends BaseControl {
6771 templateRef = viewChild . required ( 'templateRef' ) ;
6872 readonly PiyingView = PiyingView ;
6973 /** 触发器内容 */
70- trigger = input < v . BaseSchema < any , any , any > > ( ) ;
74+ trigger = input . required < v . BaseSchema < any , any , any > > ( ) ;
7175 triggerModel = input < 'click' | 'contextmenu' > ( 'click' ) ;
7276 /** 弹窗内容 */
73- content = input < v . BaseSchema < any , any , any > > ( ) ;
77+ content = input . required < v . BaseSchema < any , any , any > > ( ) ;
7478 /** 选择后是否自动关闭 */
7579 changeClose = input < boolean > ( true ) ;
7680 isOpen$ = signal ( false ) ;
@@ -80,17 +84,27 @@ export class PickerRefFCC extends BaseControl {
8084 parentPyOptions = inject ( PI_INPUT_OPTIONS_TOKEN , { optional : true } ) ;
8185 #field$$ = inject ( PI_VIEW_FIELD_TOKEN ) ;
8286 menuTrigger = inject ( CustomMenuTrigger ) ;
83-
87+ #service = inject ( PickerRefService ) ;
8488 triggerInput$$ = computed ( ( ) => {
8589 return {
8690 model : this . value$ ,
87- schema : this . trigger ,
91+ schema : computed ( ( ) => {
92+ return v . pipe (
93+ this . trigger ( ) ,
94+ actions . hooks . merge ( {
95+ allFieldsResolved : ( field ) => {
96+ this . #service. triggerField$$ = signal ( field ) ;
97+ } ,
98+ } ) ,
99+ ) ;
100+ } ) ,
88101 options : computed ( ( ) => ( {
89102 ...this . parentPyOptions ! ( ) ,
90103 context : {
91104 ...this . parentPyOptions ! ( ) . context ,
92105 pickerValue : this . value$ ,
93106 parentProps : this . #field$$( ) . props ,
107+ rootField$$ : this . #field$$,
94108 } ,
95109 } ) ) ,
96110 selectorless : true ,
@@ -126,6 +140,10 @@ export class PickerRefFCC extends BaseControl {
126140 } ,
127141 } ;
128142 } ) ;
143+
144+ ngOnInit ( ) : void {
145+ this . #service. rootField$$ = this . #field$$;
146+ }
129147 openRef ( mode : string ) {
130148 if ( mode === this . triggerModel ( ) ) {
131149 this . isOpen$ . set ( true ) ;
0 commit comments