Skip to content

Commit 9bfe2fb

Browse files
committed
feat: 增加 FaTextarea 组件
1 parent c19d749 commit 9bfe2fb

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

src/types/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ declare module 'vue' {
4646
FaSwitch: typeof import('./../ui/components/FaSwitch/index.vue')['default']
4747
FaSystemInfo: typeof import('./../ui/components/FaSystemInfo/index.vue')['default']
4848
FaTabs: typeof import('./../ui/components/FaTabs/index.vue')['default']
49+
FaTextarea: typeof import('./../ui/components/FaTextarea/index.vue')['default']
4950
FaToast: typeof import('./../ui/components/FaToast/index.vue')['default']
5051
FaTooltip: typeof import('./../ui/components/FaTooltip/index.vue')['default']
5152
RouterLink: typeof import('vue-router')['RouterLink']
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script setup lang="ts" generic="T extends string | number">
2+
import type { HTMLAttributes } from 'vue'
3+
import { Textarea } from './textarea'
4+
5+
defineOptions({
6+
name: 'FaTextarea',
7+
})
8+
9+
const props = defineProps<{
10+
disabled?: boolean
11+
class?: HTMLAttributes['class']
12+
}>()
13+
14+
const value = defineModel<T>()
15+
</script>
16+
17+
<template>
18+
<Textarea v-model="value" :disabled :class="props.class" />
19+
</template>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup lang="ts">
2+
import type { HTMLAttributes } from 'vue'
3+
import { useVModel } from '@vueuse/core'
4+
import { cn } from '@/utils'
5+
6+
const props = defineProps<{
7+
class?: HTMLAttributes['class']
8+
defaultValue?: string | number
9+
modelValue?: string | number
10+
}>()
11+
12+
const emits = defineEmits<{
13+
(e: 'update:modelValue', payload: string | number): void
14+
}>()
15+
16+
const modelValue = useVModel(props, 'modelValue', emits, {
17+
passive: true,
18+
defaultValue: props.defaultValue,
19+
})
20+
</script>
21+
22+
<template>
23+
<textarea v-model="modelValue" :class="cn('flex min-h-20 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', props.class)" />
24+
</template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Textarea } from './Textarea.vue'

0 commit comments

Comments
 (0)