-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
149 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Textarea | ||
|
||
## 基础用法 | ||
|
||
```vue demo | ||
<script setup> | ||
import { ref } from 'vue' | ||
</script> | ||
<template> | ||
<Textarea placeholder="请输入内容" /> | ||
</template> | ||
``` | ||
|
||
## 工具条 | ||
|
||
```vue demo | ||
<script setup> | ||
import { | ||
PaperAirplaneIcon, | ||
CodeBracketIcon, | ||
TrashIcon, | ||
ArchiveBoxIcon, | ||
CircleStackIcon, | ||
} from '@heroicons/vue/24/outline' | ||
import { ref } from 'vue' | ||
</script> | ||
<template> | ||
<Textarea placeholder="请输入内容"> | ||
<template #toolbar> | ||
<div class="flex items-center justify-between"> | ||
<div> | ||
<Button variant="ghost"> | ||
<template #icon> | ||
<CodeBracketIcon /> | ||
</template> | ||
</Button> | ||
<Button variant="ghost"> | ||
<template #icon> | ||
<PaperAirplaneIcon /> | ||
</template> | ||
</Button> | ||
</div> | ||
<Button color="primary"> | ||
<template #icon> | ||
<PaperAirplaneIcon /> | ||
</template> | ||
</Button> | ||
</div> | ||
</template> | ||
</Textarea> | ||
</template> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script setup lang="ts"> | ||
import { ref, computed } from 'vue' | ||
import { useModelValue } from '../use/useModelValue' | ||
import { BaseInput } from '@/Base' | ||
import { scrollbarClass } from '@/utils/tw' | ||
defineOptions({ name: 'Textarea' }) | ||
const emit = defineEmits<{ | ||
'update:value': [string] | ||
change: [string] | ||
input: [Event] | ||
focus: [FocusEvent] | ||
blur: [FocusEvent] | ||
}>() | ||
const slots = defineSlots<{ toolbar?(props: { content: string }): any }>() | ||
const props = defineProps({ | ||
value: String, | ||
placeholder: String, | ||
readonly: Boolean, | ||
disabled: Boolean, | ||
}) | ||
const [modelValue, setModelValue] = useModelValue(props, { | ||
onChange: (v: string) => { | ||
emit('change', v) | ||
}, | ||
}) | ||
const onInput = (e: Event) => { | ||
const el = e.currentTarget as HTMLInputElement | ||
setModelValue(el.value) | ||
emit('input', e) | ||
} | ||
const inputRef = ref<HTMLTextAreaElement>() | ||
</script> | ||
<template> | ||
<BaseInput class="z-textarea relative flex-col"> | ||
<textarea | ||
class="block w-full flex-1 cursor-[inherit] border-none bg-transparent px-3 py-1.5 text-sm placeholder:text-slate-400" | ||
:class="scrollbarClass" | ||
style="box-shadow: none" | ||
rows="3" | ||
ref="inputRef" | ||
type="text" | ||
:value="modelValue" | ||
:readonly="readonly" | ||
:disabled="disabled" | ||
:placeholder="placeholder" | ||
autocomplete="off" | ||
@input="onInput" | ||
@focus="emit('focus', $event)" | ||
@blur="emit('blur', $event)" | ||
/> | ||
<div v-if="slots.toolbar" class="inset-x-px bottom-px block rounded-b-md bg-white p-2 dark:bg-slate-900"> | ||
<slot name="toolbar" :content="modelValue"></slot> | ||
</div> | ||
</BaseInput> | ||
</template> | ||
<style></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Textarea } from './Textarea.vue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters