Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/vue-vuetify/dev/views/ExampleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ const reloadMonacoSchema = () => {
const saveMonacoSchema = () => {
saveMonacoModel(
schemaModel,
(modelValue) => (state.schema = JSON.parse(modelValue)),
(modelValue) =>
(state.schema = modelValue ? JSON.parse(modelValue) : undefined),
'New schema applied',
);

Expand Down Expand Up @@ -277,6 +278,10 @@ const handleAction = (action: Action) => {
if (action) {
const newState = action.apply(state);
if (newState) {
if (newState.renderers) {
newState.renderers = markRaw(newState.renderers);
}

Object.assign(state, newState);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ const controlRenderer = defineComponent({
},
setup(props: RendererProps<ControlElement>) {
const clearValue = determineClearValue('');
return useVuetifyControl(useJsonFormsControl(props), (value) =>
value === null ? clearValue : value,
return useVuetifyControl(
useJsonFormsControl(props),
(value) => value || clearValue,
);
},
computed: {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-vuetify/src/controls/DateControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const controlRenderer = defineComponent({

const showMenu = ref(false);

const adaptValue = (value: any) => (value === null ? clearValue : value);
const adaptValue = (value: any) => value || clearValue;
const control = useVuetifyControl(useJsonFormsControl(props), adaptValue);

const dateFormat = computed<string>(
Expand Down
6 changes: 3 additions & 3 deletions packages/vue-vuetify/src/controls/DateTimeControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ import {
VWindowItem,
} from 'vuetify/components';

import { vMaska, type MaskOptions, type MaskaDetail } from 'maska';
import { vMaska, type MaskOptions } from 'maska';
import { useDisplay, useLocale } from 'vuetify';
import type { IconValue } from '../icons';
import {
Expand Down Expand Up @@ -289,7 +289,7 @@ const controlRenderer = defineComponent({
const t = useTranslator();
const showMenu = ref(false);
const activeTab = ref<'date' | 'time'>('date');
const adaptValue = (value: any) => (value === null ? clearValue : value);
const adaptValue = (value: any) => value || clearValue;

const control = useVuetifyControl(useJsonFormsControl(props), adaptValue);
const { mobile } = useDisplay();
Expand All @@ -299,7 +299,7 @@ const controlRenderer = defineComponent({
typeof control.appliedOptions.value.dateTimeFormat == 'string'
? (expandLocaleFormat(control.appliedOptions.value.dateTimeFormat) ??
control.appliedOptions.value.dateTimeFormat)
: (expandLocaleFormat('L LT') ?? 'YYYY-MM-DD H:mm'),
: (expandLocaleFormat('L LT') ?? 'YYYY-MM-DD HH:mm'),
);

const useMask = control.appliedOptions.value.mask !== false;
Expand Down
5 changes: 3 additions & 2 deletions packages/vue-vuetify/src/controls/EnumControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:items="control.options"
item-title="label"
item-value="value"
:return-object="true"
v-bind="vuetifyProps('v-select')"
@update:model-value="onChange"
@focus="handleFocus"
Expand Down Expand Up @@ -57,8 +58,8 @@ const controlRenderer = defineComponent({
},
setup(props: RendererProps<ControlElement>) {
const clearValue = determineClearValue('');
return useVuetifyControl(useJsonFormsEnumControl(props), (value) =>
value === null ? clearValue : value,
return useVuetifyControl(useJsonFormsEnumControl(props), (item) =>
item === null ? clearValue : item.value,
);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const controlRenderer = defineComponent({
const clearValue = determineClearValue('');
return useVuetifyControl(
useJsonFormsControl(props),
(value) => (value === null ? clearValue : value),
(value) => value || clearValue,
300,
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:items="control.options"
item-title="label"
item-value="value"
:return-object="true"
v-bind="vuetifyProps('v-select')"
@update:model-value="onChange"
@focus="handleFocus"
Expand All @@ -39,7 +40,7 @@ import {
} from '@jsonforms/vue';
import { defineComponent } from 'vue';
import { VSelect } from 'vuetify/components';
import { useVuetifyControl } from '../util';
import { determineClearValue, useVuetifyControl } from '../util';
import { default as ControlWrapper } from './ControlWrapper.vue';
import { DisabledIconFocus } from './directives';

Expand All @@ -56,8 +57,10 @@ const controlRenderer = defineComponent({
...rendererProps<ControlElement>(),
},
setup(props: RendererProps<ControlElement>) {
return useVuetifyControl(useJsonFormsOneOfEnumControl(props), (value) =>
value !== null ? value : undefined,
const clearValue = determineClearValue('');

return useVuetifyControl(useJsonFormsOneOfEnumControl(props), (item) =>
item === null ? clearValue : item.value,
);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const controlRenderer = defineComponent({
const clearValue = determineClearValue('');
return useVuetifyControl(
useJsonFormsControl(props),
(value) => (value === null ? clearValue : value),
(value) => value || clearValue,
300,
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const controlRenderer = defineComponent({
},
setup(props: RendererProps<ControlElement>) {
const clearValue = determineClearValue('');
const adaptValue = (value: any) => (value === null ? clearValue : value);
const adaptValue = (value: any) => value || clearValue;
const control = useVuetifyControl(useJsonFormsControl(props), adaptValue);

const toTokens = (tokenParams: Record<string, any>): MaskTokens => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-vuetify/src/controls/TimeControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const controlRenderer = defineComponent({

const showMenu = ref(false);

const adaptValue = (value: any) => (value === null ? clearValue : value);
const adaptValue = (value: any) => value || clearValue;
const control = useVuetifyControl(useJsonFormsControl(props), adaptValue);

const icons = useIcons();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
:items="control.options"
item-title="label"
item-value="value"
:return-object="true"
v-bind="vuetifyProps('v-select')"
@update:model-value="onChange"
@focus="handleFocus"
Expand All @@ -46,6 +47,7 @@
:items="control.options"
item-title="label"
item-value="value"
:return-object="true"
v-bind="vuetifyProps('v-autocomplete')"
@update:model-value="onChange"
@focus="handleFocus"
Expand Down Expand Up @@ -84,7 +86,7 @@ const controlRenderer = defineComponent({
const clearValue = determineClearValue('');
return useVuetifyControl(
useJsonFormsEnumControl(props),
(value) => (value === null ? clearValue : value),
(item) => (item === null ? clearValue : item.value),
300,
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
:items="control.options"
item-title="label"
item-value="value"
:return-object="true"
v-bind="vuetifyProps('v-select')"
@update:model-value="onChange"
@focus="handleFocus"
Expand All @@ -46,6 +47,7 @@
:items="control.options"
item-title="label"
item-value="value"
:return-object="true"
v-bind="vuetifyProps('v-autocomplete')"
@update:model-value="onChange"
@focus="handleFocus"
Expand Down Expand Up @@ -84,7 +86,7 @@ const controlRenderer = defineComponent({
const clearValue = determineClearValue('');
return useVuetifyControl(
useJsonFormsOneOfEnumControl(props),
(value) => (value === null ? clearValue : value),
(item) => (item === null ? clearValue : item.value),
300,
);
},
Expand Down
7 changes: 1 addition & 6 deletions packages/vue-vuetify/src/util/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,7 @@ export const useIcons = () => {
};

export const determineClearValue = (defaultValue: any) => {
const jsonforms = useJsonForms();

const useDefaultValue = inject<boolean>(
IsDynamicPropertyContext,
jsonforms.core?.schema.type !== 'object',
);
const useDefaultValue = inject<boolean>(IsDynamicPropertyContext, false);

// undefined will clear the property from the object
return useDefaultValue ? defaultValue : undefined;
Expand Down