Skip to content

Commit 1dd7a03

Browse files
committed
增加 FaTextarea 组件
1 parent 95a1283 commit 1dd7a03

File tree

6 files changed

+70
-0
lines changed

6 files changed

+70
-0
lines changed

src/router/modules/component.example.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ const routes: RouteRecordRaw = {
262262
title: '标签页',
263263
},
264264
},
265+
{
266+
path: 'textarea',
267+
name: 'componentExampleBuiltInTextarea',
268+
component: () => import('@/views/component_built_in_example/textarea.vue'),
269+
meta: {
270+
title: '文本域',
271+
},
272+
},
265273
{
266274
path: 'toast',
267275
name: 'componentExampleBuiltInToast',

src/types/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ declare module 'vue' {
4747
FaSwitch: typeof import('./../ui/components/FaSwitch/index.vue')['default']
4848
FaSystemInfo: typeof import('./../ui/components/FaSystemInfo/index.vue')['default']
4949
FaTabs: typeof import('./../ui/components/FaTabs/index.vue')['default']
50+
FaTextarea: typeof import('./../ui/components/FaTextarea/index.vue')['default']
5051
FaToast: typeof import('./../ui/components/FaToast/index.vue')['default']
5152
FaTooltip: typeof import('./../ui/components/FaTooltip/index.vue')['default']
5253
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'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<route lang="yaml">
2+
meta:
3+
enabled: false
4+
</route>
5+
6+
<script setup lang="ts">
7+
const value = ref('')
8+
</script>
9+
10+
<template>
11+
<div>
12+
<FaPageHeader title="文本域" description="FaTextarea" />
13+
<FaPageMain>
14+
<FaTextarea v-model="value" placeholder="请输入内容" />
15+
</FaPageMain>
16+
</div>
17+
</template>

0 commit comments

Comments
 (0)