@@ -111,6 +111,7 @@ export const Field = {
111111 percent : ( config : FieldInput = { } ) => ( { type : 'percent' , ...config } as const ) ,
112112 url : ( config : FieldInput = { } ) => ( { type : 'url' , ...config } as const ) ,
113113 email : ( config : FieldInput = { } ) => ( { type : 'email' , ...config } as const ) ,
114+ phone : ( config : FieldInput = { } ) => ( { type : 'phone' , ...config } as const ) ,
114115 image : ( config : FieldInput = { } ) => ( { type : 'image' , ...config } as const ) ,
115116 file : ( config : FieldInput = { } ) => ( { type : 'file' , ...config } as const ) ,
116117 avatar : ( config : FieldInput = { } ) => ( { type : 'avatar' , ...config } as const ) ,
@@ -121,17 +122,43 @@ export const Field = {
121122 html : ( config : FieldInput = { } ) => ( { type : 'html' , ...config } as const ) ,
122123 password : ( config : FieldInput = { } ) => ( { type : 'password' , ...config } as const ) ,
123124
124- select : ( options : string [ ] , config : FieldInput = { } ) => ( {
125- type : 'select' ,
126- options : options . map ( o => ( { label : o , value : o } ) ) ,
127- ...config
128- } as const ) ,
125+ select : ( optionsOrConfig : SelectOption [ ] | string [ ] | FieldInput & { options : SelectOption [ ] | string [ ] } , config ?: FieldInput ) => {
126+ // Support both old and new signatures:
127+ // Old: Field.select(['a', 'b'], { label: 'X' })
128+ // New: Field.select({ options: [{label: 'A', value: 'a'}], label: 'X' })
129+ let options : SelectOption [ ] ;
130+ let finalConfig : FieldInput ;
131+
132+ if ( Array . isArray ( optionsOrConfig ) ) {
133+ // Old signature: array as first param
134+ options = optionsOrConfig . map ( o => typeof o === 'string' ? { label : o , value : o } : o ) ;
135+ finalConfig = config || { } ;
136+ } else {
137+ // New signature: config object with options
138+ options = ( optionsOrConfig . options || [ ] ) . map ( o => typeof o === 'string' ? { label : o , value : o } : o ) ;
139+ finalConfig = optionsOrConfig ;
140+ }
141+
142+ return { type : 'select' , ...finalConfig , options } as const ;
143+ } ,
129144
130- multiselect : ( options : string [ ] , config : FieldInput = { } ) => ( {
131- type : 'multiselect' ,
132- options : options . map ( o => ( { label : o , value : o } ) ) ,
133- ...config
134- } as const ) ,
145+ multiselect : ( optionsOrConfig : SelectOption [ ] | string [ ] | FieldInput & { options : SelectOption [ ] | string [ ] } , config ?: FieldInput ) => {
146+ // Support both old and new signatures
147+ let options : SelectOption [ ] ;
148+ let finalConfig : FieldInput ;
149+
150+ if ( Array . isArray ( optionsOrConfig ) ) {
151+ // Old signature: array as first param
152+ options = optionsOrConfig . map ( o => typeof o === 'string' ? { label : o , value : o } : o ) ;
153+ finalConfig = config || { } ;
154+ } else {
155+ // New signature: config object with options
156+ options = ( optionsOrConfig . options || [ ] ) . map ( o => typeof o === 'string' ? { label : o , value : o } : o ) ;
157+ finalConfig = optionsOrConfig ;
158+ }
159+
160+ return { type : 'multiselect' , ...finalConfig , options } as const ;
161+ } ,
135162
136163 lookup : ( reference : string , config : FieldInput = { } ) => ( {
137164 type : 'lookup' ,
0 commit comments