From 8c1bdda8b24e27928390f3c111cabba3c3cc43ff Mon Sep 17 00:00:00 2001 From: Jelmer de Wit Date: Fri, 15 Apr 2022 11:17:13 +0200 Subject: [PATCH 1/2] (vue) add binding for one enum cell elements --- packages/vue/vue/src/jsonFormsCompositions.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/vue/vue/src/jsonFormsCompositions.ts b/packages/vue/vue/src/jsonFormsCompositions.ts index a983a7955..500aace82 100644 --- a/packages/vue/vue/src/jsonFormsCompositions.ts +++ b/packages/vue/vue/src/jsonFormsCompositions.ts @@ -395,6 +395,22 @@ export const useJsonFormsEnumCell = (props: ControlProps) => { return { cell: control, ...other }; }; +/** + * Provides bindings for 'oneOf' enum cell elements. Cells are meant to show simple inputs, + * for example without error validation, within a larger structure like tables. + * + * Access bindings via the provided reactive 'cell' object. + * Dispatch changes via the provided `handleChange` method. + */ +export const useJsonFormsOneOfEnumCell = (props: ControlProps) => { + const { control, ...other } = useControl( + props, + mapStateToOneOfEnumControlProps, + mapDispatchToControlProps + ); + return { cell: control, ...other }; +}; + /** * Provides bindings for a cell dispatcher. Cells are meant to show simple inputs, * for example without error validation, within a larger structure like tables. From 6297e42143ba3d99d03e7dda92e1d2f6433f7095 Mon Sep 17 00:00:00 2001 From: Jelmer de Wit Date: Tue, 3 May 2022 10:49:10 +0200 Subject: [PATCH 2/2] (vue) use oneOf enum mapping specific for cells --- packages/vue/vue/src/jsonFormsCompositions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vue/vue/src/jsonFormsCompositions.ts b/packages/vue/vue/src/jsonFormsCompositions.ts index 500aace82..ce7989444 100644 --- a/packages/vue/vue/src/jsonFormsCompositions.ts +++ b/packages/vue/vue/src/jsonFormsCompositions.ts @@ -27,6 +27,7 @@ import { JsonFormsCellRendererRegistryEntry, defaultMapStateToEnumCellProps, mapStateToDispatchCellProps, + mapStateToOneOfEnumCellProps, StatePropsOfJsonFormsRenderer, createId, removeId @@ -405,7 +406,7 @@ export const useJsonFormsEnumCell = (props: ControlProps) => { export const useJsonFormsOneOfEnumCell = (props: ControlProps) => { const { control, ...other } = useControl( props, - mapStateToOneOfEnumControlProps, + mapStateToOneOfEnumCellProps, mapDispatchToControlProps ); return { cell: control, ...other };