2424*/
2525import * as React from 'react' ;
2626import * as _ from 'lodash' ;
27- import { ExampleDescription , nestedArray as NestedArrayExample } from '@jsonforms/examples' ;
27+ import {
28+ ExampleDescription ,
29+ issue_1220 as Issue1220Example ,
30+ nestedArray as NestedArrayExample
31+ } from '@jsonforms/examples' ;
2832import ConnectedRatingControl , { ratingControlTester } from './RatingControl' ;
2933import {
3034 Actions ,
@@ -43,7 +47,9 @@ const registerRatingControl = (dispatch: Dispatch<AnyAction>) => {
4347 dispatch ( Actions . registerField ( ratingControlTester , ConnectedRatingControl ) ) ;
4448} ;
4549const unregisterRatingControl = ( dispatch : Dispatch < AnyAction > ) => {
46- dispatch ( Actions . unregisterField ( ratingControlTester , ConnectedRatingControl ) ) ;
50+ dispatch (
51+ Actions . unregisterField ( ratingControlTester , ConnectedRatingControl )
52+ ) ;
4753} ;
4854
4955export interface I18nExampleProps {
@@ -52,11 +58,13 @@ export interface I18nExampleProps {
5258 dispatch : Dispatch < AnyAction > ;
5359}
5460
55- class I18nExample extends React . Component < I18nExampleProps , {
56- localizedSchemas : Map < string , JsonSchema > ,
57- localizedUISchemas : Map < string , UISchemaElement >
58- } > {
59-
61+ class I18nExample extends React . Component <
62+ I18nExampleProps ,
63+ {
64+ localizedSchemas : Map < string , JsonSchema > ;
65+ localizedUISchemas : Map < string , UISchemaElement > ;
66+ }
67+ > {
6068 constructor ( props : I18nExampleProps ) {
6169 super ( props ) ;
6270 const { schema, uischema } = props ;
@@ -81,44 +89,37 @@ class I18nExample extends React.Component<I18nExampleProps, {
8189 } ;
8290 }
8391
84-
8592 changeLocale = ( locale : string ) => {
8693 const { dispatch } = this . props ;
8794 const { localizedSchemas, localizedUISchemas } = this . state ;
8895 dispatch ( setLocale ( locale ) ) ;
8996 dispatch ( setSchema ( localizedSchemas . get ( locale ) ) ) ;
9097 dispatch ( setUISchema ( localizedUISchemas . get ( locale ) ) ) ;
91- }
98+ } ;
9299
93100 render ( ) {
94101 return (
95102 < div >
96- < button onClick = { ( ) => this . changeLocale ( 'en-US' ) } >
97- en-US
98- </ button >
99- < button onClick = { ( ) => this . changeLocale ( 'de-DE' ) } >
100- de-DE
101- </ button >
103+ < button onClick = { ( ) => this . changeLocale ( 'en-US' ) } > en-US</ button >
104+ < button onClick = { ( ) => this . changeLocale ( 'de-DE' ) } > de-DE</ button >
102105 </ div >
103106 ) ;
104107 }
105108}
106109
107- export const enhanceExample : ( examples : ExampleDescription [ ] ) => ReactExampleDescription [ ] =
108- examples => examples . map ( e => {
110+ export const enhanceExample : (
111+ examples : ExampleDescription [ ]
112+ ) => ReactExampleDescription [ ] = examples =>
113+ examples . map ( e => {
109114 switch ( e . name ) {
110115 case 'day6' :
111116 const day6 = Object . assign ( { } , e , {
112117 customReactExtension : ( dispatch : Dispatch < AnyAction > ) => (
113118 < div >
114- < button
115- onClick = { ( ) => registerRatingControl ( dispatch ) }
116- >
119+ < button onClick = { ( ) => registerRatingControl ( dispatch ) } >
117120 Register Custom Field
118121 </ button >
119- < button
120- onClick = { ( ) => unregisterRatingControl ( dispatch ) }
121- >
122+ < button onClick = { ( ) => unregisterRatingControl ( dispatch ) } >
122123 Unregister Custom Field
123124 </ button >
124125 </ div >
@@ -130,12 +131,16 @@ export const enhanceExample: (examples: ExampleDescription[]) => ReactExampleDes
130131 customReactExtension : ( dispatch : Dispatch < AnyAction > ) => (
131132 < div >
132133 < button
133- onClick = { ( ) => NestedArrayExample . registerNestedArrayUISchema ( dispatch ) }
134+ onClick = { ( ) =>
135+ NestedArrayExample . registerNestedArrayUISchema ( dispatch )
136+ }
134137 >
135138 Register NestedArray UISchema
136139 </ button >
137140 < button
138- onClick = { ( ) => NestedArrayExample . unregisterNestedArrayUISchema ( dispatch ) }
141+ onClick = { ( ) =>
142+ NestedArrayExample . unregisterNestedArrayUISchema ( dispatch )
143+ }
139144 >
140145 Unregister NestedArray UISchema
141146 </ button >
@@ -148,7 +153,9 @@ export const enhanceExample: (examples: ExampleDescription[]) => ReactExampleDes
148153 customReactExtension : ( dispatch : Dispatch < AnyAction > ) => (
149154 < div >
150155 < button
151- onClick = { ( ) => dispatch ( Actions . init ( { id : 'aaa' } , e . schema , e . uischema ) ) }
156+ onClick = { ( ) =>
157+ dispatch ( Actions . init ( { id : 'aaa' } , e . schema , e . uischema ) )
158+ }
152159 >
153160 Change data
154161 </ button >
@@ -159,9 +166,36 @@ export const enhanceExample: (examples: ExampleDescription[]) => ReactExampleDes
159166 case 'i18n' :
160167 return Object . assign ( { } , e , {
161168 customReactExtension : ( dispatch : Dispatch < AnyAction > ) => (
162- < I18nExample schema = { e . schema } uischema = { e . uischema } dispatch = { dispatch } />
169+ < I18nExample
170+ schema = { e . schema }
171+ uischema = { e . uischema }
172+ dispatch = { dispatch }
173+ />
174+ )
175+ } ) ;
176+ case '1220' :
177+ const issue_1220 = Object . assign ( { } , e , {
178+ customReactExtension : ( dispatch : Dispatch < AnyAction > ) => (
179+ < div >
180+ < button
181+ onClick = { ( ) =>
182+ Issue1220Example . registerIssue1220UISchema ( dispatch )
183+ }
184+ >
185+ Register Issue 1220 UISchema
186+ </ button >
187+ < button
188+ onClick = { ( ) =>
189+ Issue1220Example . unregisterIssue1220UISchema ( dispatch )
190+ }
191+ >
192+ Unregister Issue 1220 UISchema
193+ </ button >
194+ </ div >
163195 )
164196 } ) ;
165- default : return e ;
197+ return issue_1220 ;
198+ default :
199+ return e ;
166200 }
167201 } ) ;
0 commit comments