Skip to content

Commit 1dd3960

Browse files
authored
feat: Vue Vuetify improvements (#2408)
* add arrayList.title missed from the migration * add additional customizations for array renderers * fix one tab disable property
1 parent 48d3417 commit 1dd3960

14 files changed

+69
-25
lines changed

packages/vue-vuetify/src/complex/AllOfRenderer.vue

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
:schema="control.schema"
1717
combinatorKeyword="allOf"
1818
:path="path"
19+
:rootSchema="control.rootSchema"
1920
/>
2021
<dispatch-renderer
2122
v-for="(allOfRenderInfo, allOfIndex) in allOfRenderInfos"

packages/vue-vuetify/src/complex/AnyOfRenderer.vue

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:schema="control.schema"
55
combinatorKeyword="anyOf"
66
:path="path"
7+
:rootSchema="control.rootSchema"
78
/>
89

910
<v-tabs v-model="selectedIndex">

packages/vue-vuetify/src/complex/ArrayControlRenderer.vue

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
<template>
2-
<v-card v-if="control.visible" :class="styles.arrayList.root" elevation="0">
3-
<v-card-title>
4-
<v-toolbar flat :class="styles.arrayList.toolbar">
2+
<v-card
3+
v-if="control.visible"
4+
:class="styles.arrayList.root"
5+
elevation="0"
6+
v-bind="vuetifyProps('v-card')"
7+
>
8+
<v-card-title
9+
:class="styles.arrayList.title"
10+
v-bind="vuetifyProps('v-card-title')"
11+
>
12+
<v-toolbar
13+
flat
14+
:class="styles.arrayList.toolbar"
15+
v-bind="vuetifyProps('v-toolbar')"
16+
>
517
<v-toolbar-title :class="styles.arrayList.label">{{
618
computedLabel
719
}}</v-toolbar-title>
@@ -36,7 +48,7 @@
3648
</v-tooltip>
3749
</v-toolbar>
3850
</v-card-title>
39-
<v-card-text>
51+
<v-card-text v-bind="vuetifyProps('v-card-text')">
4052
<v-container justify-space-around align-content-center>
4153
<v-row justify="center">
4254
<v-table

packages/vue-vuetify/src/complex/ObjectRenderer.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
import {
2121
Generate,
2222
findUISchema,
23-
isObjectControl,
24-
rankWith,
2523
type ControlElement,
2624
type GroupLayout,
27-
type JsonFormsRendererRegistryEntry,
2825
type UISchemaElement,
2926
} from '@jsonforms/core';
3027
import {
@@ -76,7 +73,12 @@ const controlRenderer = defineComponent({
7673
},
7774
detailUiSchema(): UISchemaElement {
7875
const uiSchemaGenerator = () => {
79-
const uiSchema = Generate.uiSchema(this.control.schema, 'Group');
76+
const uiSchema = Generate.uiSchema(
77+
this.control.schema,
78+
'Group',
79+
undefined,
80+
this.control.rootSchema,
81+
);
8082
if (isEmpty(this.control.path)) {
8183
uiSchema.type = 'VerticalLayout';
8284
} else {

packages/vue-vuetify/src/complex/OneOfRenderer.vue

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:schema="control.schema"
55
combinatorKeyword="oneOf"
66
:path="path"
7+
:rootSchema="control.rootSchema"
78
/>
89

910
<v-select

packages/vue-vuetify/src/complex/OneOfTabRenderer.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
:schema="control.schema"
55
combinatorKeyword="oneOf"
66
:path="path"
7+
:rootSchema="control.rootSchema"
78
/>
89

9-
<v-tabs v-model="selectIndex" @update:model-value="handleTabChange">
10+
<v-tabs
11+
v-model="selectIndex"
12+
@update:model-value="handleTabChange"
13+
:disabled="!control.enabled"
14+
>
1015
<v-tab
1116
v-for="(oneOfRenderInfo, oneOfIndex) in oneOfRenderInfos"
1217
:key="`${control.path}-${oneOfIndex}`"

packages/vue-vuetify/src/complex/components/AdditionalProperties.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,12 @@ export default defineComponent({
227227
228228
if (propSchema) {
229229
if (propSchema.type === 'object' || propSchema.type === 'array') {
230-
propUiSchema = Generate.uiSchema(propSchema, 'Group');
230+
propUiSchema = Generate.uiSchema(
231+
propSchema,
232+
'Group',
233+
undefined,
234+
control.value.rootSchema,
235+
);
231236
(propUiSchema as GroupLayout).label =
232237
propSchema.title ?? startCase(propName);
233238
} else {

packages/vue-vuetify/src/complex/components/CombinatorProperties.vue

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface CombinatorProps {
2323
schema: JsonSchema;
2424
combinatorKeyword: 'oneOf' | 'anyOf' | 'allOf';
2525
path: string;
26+
rootSchema: JsonSchema;
2627
}
2728
2829
export default defineComponent({
@@ -43,6 +44,10 @@ export default defineComponent({
4344
type: String,
4445
required: true,
4546
},
47+
rootSchema: {
48+
type: Object as PropType<JsonSchema>,
49+
required: true,
50+
},
4651
},
4752
setup(props: CombinatorProps) {
4853
const otherProps: JsonSchema = omit(
@@ -52,6 +57,8 @@ export default defineComponent({
5257
const foundUISchema: UISchemaElement = Generate.uiSchema(
5358
otherProps,
5459
'VerticalLayout',
60+
undefined,
61+
props.rootSchema,
5562
);
5663
5764
const isLayout = (uischema: UISchemaElement): uischema is Layout =>

packages/vue-vuetify/src/layouts/ArrayLayoutRenderer.vue

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
<template>
2-
<v-card v-if="control.visible" :class="styles.arrayList.root">
3-
<v-card-title>
4-
<v-toolbar flat :class="styles.arrayList.toolbar">
2+
<v-card
3+
v-if="control.visible"
4+
:class="styles.arrayList.root"
5+
v-bind="vuetifyProps('v-card')"
6+
>
7+
<v-card-title
8+
:class="styles.arrayList.title"
9+
v-bind="vuetifyProps('v-card-title')"
10+
>
11+
<v-toolbar
12+
flat
13+
:class="styles.arrayList.toolbar"
14+
v-bind="vuetifyProps('v-toolbar')"
15+
>
516
<v-toolbar-title :class="styles.arrayList.label">{{
617
computedLabel
718
}}</v-toolbar-title>
@@ -45,7 +56,7 @@
4556
</slot>
4657
</v-toolbar>
4758
</v-card-title>
48-
<v-card-text>
59+
<v-card-text v-bind="vuetifyProps('v-card-text')">
4960
<v-container
5061
justify-space-around
5162
align-content-center
@@ -196,7 +207,11 @@
196207
{{ control.translations.noDataMessage }}
197208
</v-container>
198209
</v-card-text>
199-
<v-card-actions v-if="$slots.actions" class="pb-8">
210+
<v-card-actions
211+
v-if="$slots.actions"
212+
class="pb-8"
213+
v-bind="vuetifyProps('v-card-actions')"
214+
>
200215
<slot
201216
name="actions"
202217
:addClass="styles.arrayList.addButton"

packages/vue-vuetify/src/layouts/CategorizationRenderer.vue

+1-8
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,7 @@
7373
</template>
7474

7575
<script lang="ts">
76-
import {
77-
and,
78-
categorizationHasCategory,
79-
isCategorization,
80-
rankWith,
81-
type JsonFormsRendererRegistryEntry,
82-
type Layout,
83-
} from '@jsonforms/core';
76+
import { type Layout } from '@jsonforms/core';
8477
import {
8578
DispatchRenderer,
8679
rendererProps,

packages/vue-vuetify/src/styles/defaultStyles.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const defaultStyles: Styles = {
2323
arrayList: {
2424
root: 'array-list',
2525
toolbar: 'array-list-toolbar',
26+
title: 'array-list-title',
2627
validationIcon: 'array-list-validation',
2728
addButton: 'array-list-add',
2829
label: 'array-list-label',

packages/vue-vuetify/src/styles/styles.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface Styles {
3737
arrayList: {
3838
root?: string;
3939
toolbar?: string;
40+
title?: string;
4041
validationIcon?: string;
4142
container?: string;
4243
addButton?: string;

packages/vue-vuetify/tests/unit/complex/__snapshots__/ArrayControlRenderer.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exports[`ArrayControlRenderer.vue > should render component and match snapshot 1
2121
</div>
2222
<!---->
2323
<!---->
24-
<div data-v-4896f876="" class="v-card-title">
24+
<div data-v-4896f876="" class="v-card-title array-list-title">
2525
<header data-v-4896f876="" class="v-toolbar v-toolbar--flat v-toolbar--density-default v-theme--light v-locale--is-ltr array-list-toolbar">
2626
<!---->
2727
<div class="v-toolbar__content" style="height: 64px;">

packages/vue-vuetify/tests/unit/layout/__snapshots__/ArrayLayoutRenderer.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exports[`ArrayLayoutRenderer.vue > should render component and match snapshot 1`
2121
</div>
2222
<!---->
2323
<!---->
24-
<div data-v-5f91636e="" class="v-card-title">
24+
<div data-v-5f91636e="" class="v-card-title array-list-title">
2525
<header data-v-5f91636e="" class="v-toolbar v-toolbar--flat v-toolbar--density-default v-theme--light v-locale--is-ltr array-list-toolbar">
2626
<!---->
2727
<div class="v-toolbar__content" style="height: 64px;">

0 commit comments

Comments
 (0)