Skip to content

Commit 90469ea

Browse files
authored
Merge pull request #322 from devforth/AdminForth/782
feat: add text area to the afcl
2 parents 77e1d44 + 35c6871 commit 90469ea

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template>
2+
3+
<textarea
4+
ref="input"
5+
class="bg-lightInputBackground border border-lightInputBorder text-lightInputText placeholder-lightInputPlaceholderText text-sm rounded-lg block w-full p-2.5 dark:bg-darkInputBackground dark:border-darkInputBorder dark:placeholder-darkInputPlaceholderText dark:text-darkInputText dark:border-darkInputBorder focus:ring-lightInputFocusRing focus:border-lightInputFocusBorder dark:focus:ring-darkInputFocusRing dark:focus:border-darkInputFocusBorder"
6+
:placeholder="placeholder"
7+
:value="modelValue"
8+
@input="$emit('update:modelValue', ($event.target as HTMLInputElement).value)"
9+
:readonly="readonly"
10+
/>
11+
12+
</template>
13+
14+
<script setup lang="ts">
15+
16+
import { ref } from 'vue';
17+
18+
const props = defineProps<{
19+
modelValue: string,
20+
readonly?: boolean,
21+
placeholder?: string,
22+
}>()
23+
24+
const input = ref<HTMLInputElement | null>(null)
25+
26+
defineExpose({
27+
focus: () => input.value?.focus(),
28+
});
29+
30+
</script>
31+

adminforth/spa/src/afcl/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ export { default as CountryFlag } from './CountryFlag.vue';
2222
export { default as JsonViewer } from './JsonViewer.vue';
2323
export { default as Toggle } from './Toggle.vue';
2424
export { default as DatePicker } from './DatePicker.vue';
25-
25+
export { default as Textarea } from './Textarea.vue';

adminforth/spa/src/components/ColumnValueInput.vue

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,18 @@
100100
@update:modelValue="$emit('update:modelValue', $event)"
101101
:readonly="(column.editReadonly && source === 'edit') || readonly"
102102
/>
103-
<textarea
103+
<Textarea
104104
v-else-if="['text', 'richtext'].includes(type || column.type)"
105-
ref="input"
106-
class="bg-lightInputBackground border border-lightInputBorder text-lightInputText placeholder-lightInputPlaceholderText text-sm rounded-lg block w-full p-2.5 dark:bg-darkInputBackground dark:border-darkInputBorder dark:placeholder-darkInputPlaceholderText dark:text-darkInputText dark:border-darkInputBorder focus:ring-lightInputFocusRing focus:border-lightInputFocusBorder dark:focus:ring-darkInputFocusRing dark:focus:border-darkInputFocusBorder"
107105
:placeholder="$t('Text')"
108-
:value="value"
109-
@input="$emit('update:modelValue', ($event.target as HTMLInputElement).value)"
106+
:modelValue="value"
107+
@update:modelValue="$emit('update:modelValue', $event)"
110108
:readonly="(column.editReadonly && source === 'edit') || readonly"
111109
/>
112-
<textarea
110+
<Textarea
113111
v-else-if="['json'].includes(type || column.type)"
114-
ref="input"
115-
class="bg-lightInputBackground border border-lightInputBorder text-lightInputText placeholder-lightInputPlaceholderText text-sm rounded-lg block w-full p-2.5 dark:bg-darkInputBackground dark:border-darkInputBorder dark:placeholder-darkInputPlaceholderText dark:text-darkInputText dark:border-darkInputBorder focus:ring-lightInputFocusRing focus:border-lightInputFocusBorder dark:focus:ring-darkInputFocusRing dark:focus:border-darkInputFocusBorder"
116112
:placeholder="$t('Text')"
117-
:value="value"
118-
@input="$emit('update:modelValue', ($event.target as HTMLInputElement).value)"
113+
:modelValue="value"
114+
@update:modelValue="$emit('update:modelValue', $event)"
119115
/>
120116
<Input
121117
v-else
@@ -160,6 +156,7 @@
160156
import Select from '@/afcl/Select.vue';
161157
import Input from '@/afcl/Input.vue';
162158
import Spinner from '@/afcl/Spinner.vue';
159+
import Textarea from '@/afcl/Textarea.vue';
163160
import { ref, inject } from 'vue';
164161
import { getCustomComponent } from '@/utils';
165162
import { useI18n } from 'vue-i18n';

0 commit comments

Comments
 (0)