-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create useJsonFormsCategorization function to simplify renderers and …
…use existing mapStateToLayoutProps to create props for category
- Loading branch information
Showing
4 changed files
with
58 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
import { Categorization, Category } from '@jsonforms/core'; | ||
import { type Categorization, mapStateToLayoutProps } from '@jsonforms/core'; | ||
import { type LayoutProps, useControl } from '@jsonforms/vue'; | ||
|
||
export type CategoryItem = { | ||
element: Category | Categorization; | ||
isEnabled: boolean; | ||
label?: string; | ||
export const useJsonFormsCategorization = (props: LayoutProps) => { | ||
const { control, ...other } = useControl(props, mapStateToLayoutProps); | ||
|
||
const categories = (control.value.uischema as Categorization).elements.map( | ||
(category) => { | ||
const categoryProps: LayoutProps = { | ||
...props, | ||
uischema: category, | ||
}; | ||
|
||
return useControl(categoryProps, mapStateToLayoutProps).control; | ||
} | ||
); | ||
|
||
return { layout: control, categories, ...other }; | ||
}; |
Oops, something went wrong.