@@ -18,7 +18,8 @@ const { uuid = { v4: randomUuid } } = window as any;
1818const initialToken = uuid . v4 ( ) ;
1919
2020const getItems = ( { initialValue, field } : PrimeFieldProps ) => {
21- if ( ! field . options . repeated ) {
21+ const options = { ...field . defaultOptions , ...field . options } ;
22+ if ( ! options . repeated ) {
2223 return [ [ initialToken , 0 ] ] ;
2324 }
2425
@@ -39,6 +40,11 @@ export class InputComponent extends React.PureComponent<PrimeFieldProps, any> {
3940 index : getIndex ( this . props ) ,
4041 } ;
4142
43+ get options ( ) {
44+ const { field } = this . props ;
45+ return { ...field . defaultOptions , ...field . options } ;
46+ }
47+
4248 public componentWillReceiveProps ( nextProps : PrimeFieldProps ) {
4349 if ( ! this . props . document && nextProps . document ) {
4450 this . setState ( {
@@ -77,7 +83,7 @@ export class InputComponent extends React.PureComponent<PrimeFieldProps, any> {
7783 } ;
7884
7985 public renderField = ( field : any , key : string , index : number ) => {
80- const repeated = get ( this . props . field , ' options.repeated' , false ) ;
86+ const repeated = this . options . repeated ;
8187 const prefix = repeated ? `${ index } .` : '' ;
8288 const path = `${ this . props . path } .${ prefix } ${ field . name } ` ;
8389 const initialValue = get ( this . props . initialValue , `${ prefix } ${ field . name } ` ) ;
@@ -93,7 +99,7 @@ export class InputComponent extends React.PureComponent<PrimeFieldProps, any> {
9399 public renderGroupItem = ( [ key , index ] : any ) => {
94100 const { field } = this . props ;
95101 const { fields = [ ] } = field ;
96- const repeated = get ( field , ' options.repeated' , false ) ;
102+ const repeated = this . options . repeated ;
97103
98104 if ( ! key ) {
99105 return null ;
@@ -119,7 +125,7 @@ export class InputComponent extends React.PureComponent<PrimeFieldProps, any> {
119125 public render ( ) {
120126 const { items } = this . state ;
121127 const { field } = this . props ;
122- const repeated = get ( field , ' options.repeated' , false ) ;
128+ const repeated = this . options . repeated ;
123129
124130 if ( field . fields . length === 0 ) {
125131 return null ;
0 commit comments