@@ -9,13 +9,28 @@ import {
99 FieldObjectValue ,
1010 FieldValue ,
1111 ObjectIndependentInput ,
12+ ObjectIndependentInputProps ,
1213 ObjectValue ,
13- Spec ,
1414 ValidateError ,
1515 transformArrIn ,
1616} from '../../../../core' ;
17+ import { block , filterPropertiesForObjectInline } from '../../../utils' ;
1718
18- export const ObjectBase : ObjectIndependentInput = ( { spec, name, Layout, ...restProps } ) => {
19+ import './ObjectBase.scss' ;
20+
21+ const b = block ( 'object-base' ) ;
22+
23+ export interface ObjectBaseProps extends ObjectIndependentInputProps {
24+ inline ?: boolean ;
25+ }
26+
27+ export const ObjectBase : React . FC < ObjectBaseProps > = ( {
28+ inline,
29+ spec,
30+ name,
31+ Layout,
32+ ...restProps
33+ } ) => {
1934 const addBtn = React . useMemo (
2035 ( ) => (
2136 < Button
@@ -49,18 +64,24 @@ export const ObjectBase: ObjectIndependentInput = ({spec, name, Layout, ...restP
4964 ) ;
5065
5166 const content = React . useMemo ( ( ) => {
52- if ( ! _ . isObjectLike ( spec . properties ) || ! Object . keys ( spec . properties || { } ) . length ) {
67+ if (
68+ ! spec . properties ||
69+ ! _ . isObjectLike ( spec . properties ) ||
70+ ! Object . keys ( spec . properties || { } ) . length
71+ ) {
5372 return null ;
5473 }
5574
56- if ( ! restProps . input . value ) {
75+ if ( ! inline && ! restProps . input . value ) {
5776 return addBtn ;
5877 }
5978
60- const specProperties = { ...spec . properties } as Record < string , Spec > ;
79+ const specProperties = inline
80+ ? filterPropertiesForObjectInline ( spec . properties )
81+ : spec . properties ;
6182
6283 return (
63- < React . Fragment >
84+ < div className = { b ( 'content' , { inline } ) } >
6485 { ( spec . viewSpec . order || Object . keys ( specProperties ) ) . map ( ( property : string ) =>
6586 specProperties [ property ] ? (
6687 < Controller
@@ -73,16 +94,17 @@ export const ObjectBase: ObjectIndependentInput = ({spec, name, Layout, ...restP
7394 />
7495 ) : null ,
7596 ) }
76- </ React . Fragment >
97+ </ div >
7798 ) ;
7899 } , [
79100 spec . properties ,
80101 spec . viewSpec . order ,
81- name ,
82102 restProps . input . value ,
103+ restProps . input . parentOnUnmount ,
104+ inline ,
83105 addBtn ,
106+ name ,
84107 parentOnChange ,
85- restProps . input . parentOnUnmount ,
86108 ] ) ;
87109
88110 if ( ! Layout || ! content ) {
@@ -95,3 +117,7 @@ export const ObjectBase: ObjectIndependentInput = ({spec, name, Layout, ...restP
95117 </ Layout >
96118 ) ;
97119} ;
120+
121+ export const ObjectInline : ObjectIndependentInput = ( props ) => {
122+ return < ObjectBase { ...props } inline /> ;
123+ } ;
0 commit comments