@@ -4,21 +4,13 @@ import arrayMutators from 'final-form-arrays';
44import PropTypes from 'prop-types' ;
55import createFocusDecorator from 'final-form-focus' ;
66
7- import miqParser from '../parsers/miq-parser/miq-parser' ;
8- import mozillaParser from '../parsers/mozilla-parser/mozilla-schema-parser' ;
97import RendererContext from './renderer-context' ;
108import FormControls from './form-controls' ;
119import renderForm from './render-form' ;
1210import defaultSchemaValidator from '../parsers/default-schema-validator' ;
1311import SchemaErrorComponent from './schema-error-component' ;
1412import { renderTitle , renderDescription } from './form-information' ;
1513
16- const schemaMapper = type => ( {
17- mozilla : ( schema , uiSchema ) => mozillaParser ( schema , uiSchema ) ,
18- miq : schema => miqParser ( schema ) ,
19- default : schema => ( { schema } ) ,
20- } ) [ type ] ;
21-
2214const isDisabled = ( disableStates , getState ) => disableStates . map ( item => getState ( ) [ item ] ) . find ( item => ! ! item ) ;
2315
2416const FormRenderer = ( {
@@ -28,12 +20,9 @@ const FormRenderer = ({
2820 onCancel,
2921 canReset,
3022 onReset,
31- schema,
32- schemaType,
3323 buttonsLabels,
3424 disableSubmit,
3525 initialValues,
36- uiSchema,
3726 showFormControls,
3827 buttonOrder,
3928 buttonClassName,
@@ -43,11 +32,11 @@ const FormRenderer = ({
4332 renderFormButtons,
4433 subscription,
4534 clearedValue,
35+ schema,
4636} ) => {
47- const inputSchema = schemaMapper ( schemaType ) ( schema , uiSchema ) ;
4837 let schemaError ;
4938 try {
50- defaultSchemaValidator ( inputSchema . schema , formFieldsMapper , layoutMapper ) ;
39+ defaultSchemaValidator ( schema , formFieldsMapper , layoutMapper ) ;
5140 } catch ( error ) {
5241 schemaError = error ;
5342 console . error ( error ) ;
@@ -58,17 +47,14 @@ const FormRenderer = ({
5847 return < SchemaErrorComponent name = { schemaError . name } message = { schemaError . message } /> ;
5948 }
6049
61- const label = inputSchema . schema . title || inputSchema . schema . label ;
50+ const label = schema . title || schema . label ;
6251
6352 return (
6453 < Form
6554 onSubmit = { onSubmit }
6655 mutators = { { ...arrayMutators } }
6756 decorators = { [ createFocusDecorator ( ) ] }
68- initialValues = { {
69- ...inputSchema . defaultValues ,
70- ...initialValues ,
71- } }
57+ initialValues = { initialValues }
7258 validate = { validate }
7359 subscription = { { pristine : true , submitting : true , valid : true , ...subscription } }
7460 render = { ( { handleSubmit, pristine, valid, form : { reset, mutators, getState, submit, ...form } , ...state } ) => (
@@ -95,8 +81,8 @@ const FormRenderer = ({
9581 { ( { layoutMapper : { FormWrapper } } ) => (
9682 < FormWrapper onSubmit = { handleSubmit } >
9783 { label && renderTitle ( label ) }
98- { inputSchema . schema . description && renderDescription ( inputSchema . schema . description ) }
99- { renderForm ( inputSchema . schema . fields ) }
84+ { schema . description && renderDescription ( schema . description ) }
85+ { renderForm ( schema . fields ) }
10086 { onStateUpdate && < FormSpy onChange = { onStateUpdate } /> }
10187 { showFormControls && (
10288 < FormControls
@@ -127,11 +113,9 @@ FormRenderer.propTypes = {
127113 onReset : PropTypes . func ,
128114 canReset : PropTypes . bool ,
129115 schema : PropTypes . object . isRequired ,
130- schemaType : PropTypes . oneOf ( [ 'mozilla' , 'miq' , 'default' ] ) ,
131116 buttonsLabels : PropTypes . object ,
132117 disableSubmit : PropTypes . arrayOf ( PropTypes . string ) ,
133118 initialValues : PropTypes . object ,
134- uiSchema : PropTypes . object ,
135119 showFormControls : PropTypes . bool ,
136120 buttonOrder : PropTypes . arrayOf ( PropTypes . string ) ,
137121 buttonClassName : PropTypes . string ,
@@ -145,11 +129,9 @@ FormRenderer.propTypes = {
145129
146130FormRenderer . defaultProps = {
147131 resetAble : false ,
148- schemaType : 'default' ,
149132 buttonsLabels : { } ,
150133 disableSubmit : [ ] ,
151134 initialValues : { } ,
152- uiSchema : { } ,
153135 showFormControls : true ,
154136 clearOnUnmount : false ,
155137 buttonClassName : '' ,
0 commit comments