-
Notifications
You must be signed in to change notification settings - Fork 26
/
MultiStringControlRenderer.vue
89 lines (85 loc) · 2.23 KB
/
MultiStringControlRenderer.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
<control-wrapper
v-bind="controlWrapper"
:styles="styles"
:isFocused="isFocused"
:appliedOptions="appliedOptions"
>
<v-hover v-slot="{ hover }">
<v-textarea
v-disabled-icon-focus
:id="control.id + '-input'"
:class="styles.control.input"
:disabled="!control.enabled"
:autofocus="appliedOptions.focus"
:placeholder="appliedOptions.placeholder"
:label="computedLabel"
:hint="control.description"
:persistent-hint="persistentHint()"
:required="control.required"
:error-messages="control.errors"
:value="control.data"
:maxlength="
appliedOptions.restrict ? control.schema.maxLength : undefined
"
:size="
appliedOptions.trim && control.schema.maxLength !== undefined
? control.schema.maxLength
: undefined
"
:clearable="hover"
multi-line
v-bind="vuetifyProps('v-textarea')"
@input="onChange"
@focus="isFocused = true"
@blur="isFocused = false"
/>
</v-hover>
</control-wrapper>
</template>
<script lang="ts">
import {
ControlElement,
JsonFormsRendererRegistryEntry,
rankWith,
isStringControl,
isMultiLineControl,
and,
} from '@jsonforms/core';
import { defineComponent } from 'vue';
import {
rendererProps,
useJsonFormsControl,
RendererProps,
} from '@jsonforms/vue2';
import { default as ControlWrapper } from './ControlWrapper.vue';
import { useVuetifyControl } from '../util';
import { VHover, VTextarea } from 'vuetify/lib';
import { DisabledIconFocus } from './directives';
const controlRenderer = defineComponent({
name: 'multi-string-control-renderer',
components: {
ControlWrapper,
VHover,
VTextarea,
},
directives: {
DisabledIconFocus,
},
props: {
...rendererProps<ControlElement>(),
},
setup(props: RendererProps<ControlElement>) {
return useVuetifyControl(
useJsonFormsControl(props),
(value) => value || undefined,
300
);
},
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(2, and(isStringControl, isMultiLineControl)),
};
</script>