Skip to content

Commit f9a084f

Browse files
committed
feat: allow control-wrapper to be overridden by provided component
1 parent 9acd631 commit f9a084f

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

packages/vue-vuetify/src/controls/DateControlRenderer.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<template>
2-
<control-wrapper
2+
<component
3+
:is="resolvedWrapper"
34
v-bind="controlWrapper"
5+
:control="control"
46
:styles="styles"
57
:isFocused="isFocused"
68
:appliedOptions="appliedOptions"
@@ -73,12 +75,12 @@
7375
</v-menu>
7476
</template>
7577
</v-text-field>
76-
</control-wrapper>
78+
</component>
7779
</template>
7880

7981
<script lang="ts">
8082
import { type ControlElement, type JsonSchema } from '@jsonforms/core';
81-
import { computed, defineComponent, ref, unref } from 'vue';
83+
import { computed, defineComponent, inject, ref, unref } from 'vue';
8284
8385
import {
8486
rendererProps,
@@ -140,6 +142,7 @@ const controlRenderer = defineComponent({
140142
const adaptValue = (value: any) => value || undefined;
141143
const control = useVuetifyControl(useJsonFormsControl(props), adaptValue);
142144
145+
const resolvedWrapper = inject('controlWrapperOverride', ControlWrapper);
143146
const dateFormat = computed<string>(
144147
() =>
145148
typeof control.appliedOptions.value.dateFormat == 'string'
@@ -176,6 +179,7 @@ const controlRenderer = defineComponent({
176179
options,
177180
useMask,
178181
maskCompleted,
182+
resolvedWrapper,
179183
};
180184
},
181185
computed: {

packages/vue-vuetify/src/util/composition.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ import {
3131
inject,
3232
provide,
3333
ref,
34+
type Component,
3435
type ComputedRef,
3536
type InjectionKey,
3637
} from 'vue';
3738
import type { IconOptions } from 'vuetify';
3839
import { useStyles } from '../styles';
40+
import { ControlWrapper } from '@/controls';
3941

4042
export const IconSymbol: InjectionKey<Required<IconOptions>> =
4143
Symbol.for('vuetify:icons');
@@ -481,3 +483,7 @@ export const useIcons = () => {
481483
current: iconSet,
482484
};
483485
};
486+
487+
export const useControlWrapper = () => {
488+
return inject('vuetify:control-wrapper', ControlWrapper);
489+
};

0 commit comments

Comments
 (0)