11import type {
2+ ControlProps ,
23 EnumCellProps ,
34 OwnPropsOfEnum ,
45 RankedTester ,
56} from "@jsonforms/core" ;
67import { isEnumControl , rankWith } from "@jsonforms/core" ;
7- import { withJsonFormsEnumProps } from "@jsonforms/react" ;
88import {
9- Input ,
10- Label ,
11- Select ,
12- SelectButton ,
13- TextField ,
14- } from "@stacklok/ui-kit" ;
9+ withJsonFormsControlProps ,
10+ withJsonFormsEnumProps ,
11+ } from "@jsonforms/react" ;
12+ import { Label , Select , SelectButton } from "@stacklok/ui-kit" ;
1513
16- import { JsonFormsDescription } from "../utils" ;
14+ import { getRACPropsFromJSONForms } from "../utils" ;
1715
18- const EnumFieldControl = ( props : EnumCellProps & OwnPropsOfEnum ) => {
16+ // eslint-disable-next-line react-refresh/only-export-components
17+ const EnumFieldControl = (
18+ props : EnumCellProps & OwnPropsOfEnum & ControlProps ,
19+ ) => {
1920 const items = ( props . options ?? [ ] ) . map ( ( { label, value } ) => ( {
2021 textValue : label ,
2122 id : value ,
2223 } ) ) ;
24+ const mappedProps = getRACPropsFromJSONForms ( props ) ;
2325
24- console . log ( { items } ) ;
26+ console . log ( mappedProps ) ;
2527
2628 return (
2729 < Select
@@ -31,25 +33,17 @@ const EnumFieldControl = (props: EnumCellProps & OwnPropsOfEnum) => {
3133 className = "w-full"
3234 items = { items }
3335 >
34- < Label />
35-
36- < SelectButton />
37- </ Select >
38- ) ;
39-
40- return (
41- < TextField { ...mappedProps } >
42- < Label className = "text-primary text-base mb-2 " >
36+ < Label className = "text-primary text-base mb-2" >
4337 < div className = "flex items-center" >
44- { label } { " " }
38+ { props . label } { " " }
4539 { mappedProps . isRequired === true ? (
4640 < span className = "text-red-600" > *</ span >
4741 ) : null }
4842 </ div >
4943 </ Label >
50- < Input />
51- < JsonFormsDescription { ... props } />
52- </ TextField >
44+ hello
45+ < SelectButton />
46+ </ Select >
5347 ) ;
5448} ;
5549
@@ -59,7 +53,9 @@ const tester: RankedTester = (...args) => {
5953 return x ;
6054} ;
6155
62- const renderer = withJsonFormsEnumProps ( EnumFieldControl , false ) ;
56+ const renderer = withJsonFormsControlProps (
57+ withJsonFormsEnumProps ( EnumFieldControl , false ) ,
58+ ) ;
6359
6460const config = { tester, renderer } ;
6561
0 commit comments