@@ -2,7 +2,6 @@ import { ADDITIONAL_PROPERTY_FLAG } from "react-jsonschema-form/lib/utils";
22import React from "react" ;
33import {
44 TextField ,
5- FormControl ,
65 FormLabel ,
76 Typography ,
87 FormHelperText ,
@@ -11,7 +10,6 @@ import {
1110export default function DefaultTemplate ( props ) {
1211 const {
1312 id,
14- classNames,
1513 label,
1614 children,
1715 rawErrors,
@@ -21,67 +19,56 @@ export default function DefaultTemplate(props) {
2119 required,
2220 displayLabel,
2321 onKeyChange,
24- // schema,
22+ schema,
2523 uiSchema,
2624 } = props ;
2725 if ( hidden ) {
2826 return children ;
2927 }
3028
31- function suppress_label ( ) {
32- let l = uiSchema [ "ui:widget" ] ;
33- let map = {
34- textarea : true ,
35- checkboxes : true ,
36- range : true ,
37- } ;
38- console . log ( "mapped" , map [ l ] ) ;
39- return ! map [ l ] ;
40- }
41-
4229 let help_text = uiSchema [ "ui:help" ] ;
4330 let help_is_object = typeof help_text == "object" ;
4431 let actual_help = help ;
4532 //console.log('help_text', typeof help_text, help_text)
4633 if ( help_text && ! help_is_object ) {
4734 //console.log('replacing help', help_text);
48- actual_help = < Typography variant = "caption" > { help_text } </ Typography > ;
35+ actual_help = (
36+ < Typography variant = "caption" color = "textSecondary" >
37+ { help_text }
38+ </ Typography >
39+ ) ;
4940 } else if ( help_is_object ) {
5041 actual_help = "" ;
5142 }
5243
53- const additional = props . schema . hasOwnProperty ( ADDITIONAL_PROPERTY_FLAG ) ;
44+ const additional = schema . hasOwnProperty ( ADDITIONAL_PROPERTY_FLAG ) ;
5445 const keyLabel = `${ label } Key` ;
55- const forceLabelHide = suppress_label ( ) ;
5646 //console.log('schema', schema);
57- //console.log('schema', uiSchema);
58- //console.log('hiding label', forceLabelHide);
59- return (
60- < div className = { classNames } >
61- { additional && (
62- < React . Fragment >
63- < FormLabel required = { required } id = { `${ id } -key` } >
64- { keyLabel } xX
65- </ FormLabel >
66- < TextField
67- required = { required }
68- id = { `${ id } -key` }
69- onChange = { onKeyChange }
70- />
71- </ React . Fragment >
72- ) }
73- < FormControl fullWidth = { true } margin = "normal" error = { ! ! rawErrors } >
74- { ! forceLabelHide && displayLabel && (
75- < FormLabel required = { required } id = { `${ id } -key` } >
76- { label }
77- </ FormLabel >
47+ //console.log('uiSchema', uiSchema);
48+
49+ function inner ( ) {
50+ return (
51+ < React . Fragment >
52+ { additional && (
53+ < React . Fragment >
54+ < FormLabel required = { required } id = { `${ id } -key` } >
55+ { keyLabel }
56+ </ FormLabel >
57+ < TextField
58+ required = { required }
59+ id = { `${ id } -key` }
60+ onChange = { onKeyChange }
61+ />
62+ </ React . Fragment >
7863 ) }
7964 { children }
8065 { displayLabel && description ? description : null }
8166 { rawErrors &&
8267 rawErrors . map ( e => < FormHelperText error = { true } > { e } </ FormHelperText > ) }
8368 { actual_help }
84- </ FormControl >
85- </ div >
86- ) ;
69+ </ React . Fragment >
70+ ) ;
71+ }
72+
73+ return inner ( ) ;
8774}
0 commit comments