99 <v-row
1010 v-for =" (element, index) in (layout.uischema as Layout).elements"
1111 :key =" `${layout.path}-${(layout.uischema as Layout).elements.length}-${index}`"
12- no-gutters
1312 v-bind =" vuetifyProps(`v-row[${index}]`)"
1413 >
1514 <v-col
1615 cols =" 12"
16+ v-if =" isVisible(element, layout.path)"
1717 :class =" styles.verticalLayout.item"
1818 v-bind =" vuetifyProps('v-col')"
1919 >
3131</template >
3232
3333<script lang="ts">
34- import { type Layout } from ' @jsonforms/core' ;
34+ import {
35+ getAjv ,
36+ getConfig ,
37+ getData ,
38+ hasShowRule ,
39+ isVisible ,
40+ type Layout ,
41+ type UISchemaElement ,
42+ } from ' @jsonforms/core' ;
3543import {
3644 DispatchRenderer ,
3745 rendererProps ,
@@ -40,7 +48,7 @@ import {
4048} from ' @jsonforms/vue' ;
4149import { defineComponent } from ' vue' ;
4250import { VCol , VContainer , VRow } from ' vuetify/components' ;
43- import { useVuetifyLayout } from ' ../util' ;
51+ import { useJsonForms , useVuetifyLayout } from ' ../util' ;
4452
4553const layoutRenderer = defineComponent ({
4654 name: ' vertical-layout-renderer' ,
@@ -54,7 +62,26 @@ const layoutRenderer = defineComponent({
5462 ... rendererProps <Layout >(),
5563 },
5664 setup(props : RendererProps <Layout >) {
57- return useVuetifyLayout (useJsonFormsLayout (props ));
65+ const jsonforms = useJsonForms ();
66+ return { ... useVuetifyLayout (useJsonFormsLayout (props )), jsonforms };
67+ },
68+ methods: {
69+ // helper method to check visibility and if not visible to remove the v-col since otherwise it will add extra padding
70+ isVisible(uischema : UISchemaElement , path : string ): boolean {
71+ if (hasShowRule (uischema )) {
72+ const state = { jsonforms: this .jsonforms };
73+ const rootData = getData (state );
74+
75+ return isVisible (
76+ uischema ,
77+ rootData ,
78+ path ,
79+ getAjv (state ),
80+ getConfig (state ),
81+ );
82+ }
83+ return true ;
84+ },
5885 },
5986});
6087
0 commit comments