feat: add InputGroup and verify shared field integration

This commit is contained in:
maoyingjie
2026-10-21 22:56:18 +08:00
parent 7f11afeaa6
commit 37e11e6330
48 changed files with 2374 additions and 6 deletions
@@ -0,0 +1,22 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupPrefix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<TextField class="w-full max-w-xs" name="email">
<Label>工作邮箱</Label>
<InputGroup class="rounded-xl border border-border/80 bg-default shadow-sm">
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput placeholder="you@company.com" />
</InputGroup>
</TextField>
</template>
+25
View File
@@ -0,0 +1,25 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupPrefix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<TextField class="w-full max-w-[280px]" name="email">
<Label>邮箱地址</Label>
<InputGroup>
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput
class="w-full max-w-[280px]"
placeholder="name@email.com"
/>
</InputGroup>
</TextField>
</template>
+43
View File
@@ -0,0 +1,43 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupPrefix,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<div class="flex flex-col gap-4">
<TextField
class="w-full max-w-[280px]"
default-value="name@email.com"
is-disabled
name="email"
>
<Label>邮箱地址</Label>
<InputGroup>
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput class="w-full max-w-[280px]" />
</InputGroup>
</TextField>
<TextField
class="w-full max-w-[280px]"
default-value="10"
is-disabled
name="price"
>
<Label>设置价格</Label>
<InputGroup>
<InputGroupPrefix>$</InputGroupPrefix>
<InputGroupInput class="w-full max-w-[200px]" type="number" />
<InputGroupSuffix>USD</InputGroupSuffix>
</InputGroup>
</TextField>
</div>
</template>
@@ -0,0 +1,34 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupPrefix,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconEye, IconMail } from "@tabler/icons-vue";
</script>
<template>
<div class="w-[400px] space-y-4">
<TextField full-width name="email">
<Label>邮箱地址</Label>
<InputGroup full-width>
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput placeholder="name@email.com" />
</InputGroup>
</TextField>
<TextField full-width name="password">
<Label>密码</Label>
<InputGroup full-width>
<InputGroupInput placeholder="输入密码" type="password" />
<InputGroupSuffix>
<IconEye class="size-4 text-muted" aria-hidden="true" />
</InputGroupSuffix>
</InputGroup>
</TextField>
</div>
</template>
+43
View File
@@ -0,0 +1,43 @@
<script setup lang="ts">
import {
FieldError,
InputGroup,
InputGroupInput,
InputGroupPrefix,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<div class="flex flex-col gap-4">
<TextField class="w-full max-w-[280px]" is-invalid is-required name="email">
<Label>邮箱地址</Label>
<InputGroup>
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput
class="w-full max-w-[280px]"
placeholder="name@email.com"
/>
</InputGroup>
<FieldError>请输入有效的邮箱地址</FieldError>
</TextField>
<TextField class="w-full max-w-[280px]" is-invalid is-required name="price">
<Label>设置价格</Label>
<InputGroup>
<InputGroupPrefix>$</InputGroupPrefix>
<InputGroupInput
class="w-full max-w-[200px]"
placeholder="0"
type="number"
/>
<InputGroupSuffix>USD</InputGroupSuffix>
</InputGroup>
<FieldError>价格必须大于 0</FieldError>
</TextField>
</div>
</template>
@@ -0,0 +1,30 @@
<script setup lang="ts">
import {
Description,
InputGroup,
InputGroupInput,
InputGroupPrefix,
Label,
Surface,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<Surface class="rounded-2xl p-6">
<TextField class="w-full max-w-[280px]" name="email">
<Label>邮箱地址</Label>
<InputGroup variant="secondary">
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput
class="w-full max-w-[280px]"
placeholder="name@email.com"
/>
</InputGroup>
<Description>我们不会将此邮箱分享给任何人</Description>
</TextField>
</Surface>
</template>
@@ -0,0 +1,39 @@
<script setup lang="ts">
import { ref } from "vue";
import {
Button,
InputGroup,
InputGroupInput,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconEye, IconEyeOff } from "@tabler/icons-vue";
const isVisible = ref(false);
</script>
<template>
<TextField class="w-full max-w-[280px]" name="password">
<Label>密码</Label>
<InputGroup>
<InputGroupInput
class="w-full max-w-[280px]"
:model-value="isVisible ? '87$2h.3diua' : '••••••••'"
:type="isVisible ? 'text' : 'password'"
/>
<InputGroupSuffix class="pe-0">
<Button
is-icon-only
:aria-label="isVisible ? '隐藏密码' : '显示密码'"
size="sm"
variant="ghost"
@click="isVisible = !isVisible"
>
<IconEyeOff v-if="isVisible" class="size-4" aria-hidden="true" />
<IconEye v-else class="size-4" aria-hidden="true" />
</Button>
</InputGroupSuffix>
</InputGroup>
</TextField>
</template>
+42
View File
@@ -0,0 +1,42 @@
<script setup lang="ts">
import {
Description,
InputGroup,
InputGroupInput,
InputGroupPrefix,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<div class="flex flex-col gap-4">
<TextField class="w-full max-w-[280px]" is-required name="email">
<Label>邮箱地址</Label>
<InputGroup>
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput
class="w-full max-w-[280px]"
placeholder="name@email.com"
/>
</InputGroup>
</TextField>
<TextField class="w-full max-w-[280px]" is-required name="price">
<Label>设置价格</Label>
<InputGroup>
<InputGroupPrefix>$</InputGroupPrefix>
<InputGroupInput
class="w-full max-w-[200px]"
placeholder="0"
type="number"
/>
<InputGroupSuffix>USD</InputGroupSuffix>
</InputGroup>
<Description>客户将支付的价格</Description>
</TextField>
</div>
</template>
+33
View File
@@ -0,0 +1,33 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupPrefix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<div class="flex flex-col gap-4">
<TextField class="w-[280px]" name="primary">
<Label>主要变体</Label>
<InputGroup variant="primary">
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput placeholder="name@email.com" />
</InputGroup>
</TextField>
<TextField class="w-[280px]" name="secondary">
<Label>次要变体</Label>
<InputGroup variant="secondary">
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput placeholder="name@email.com" />
</InputGroup>
</TextField>
</div>
</template>
@@ -0,0 +1,20 @@
<script setup lang="ts">
import {
Chip,
InputGroup,
InputGroupInput,
InputGroupSuffix,
TextField,
} from "@heroui-vue/components";
</script>
<template>
<TextField aria-label="邮箱地址" class="w-full max-w-[280px]" name="email">
<InputGroup>
<InputGroupInput class="w-full max-w-[280px]" placeholder="邮箱地址" />
<InputGroupSuffix class="pe-2">
<Chip color="accent" size="md" variant="soft">Pro</Chip>
</InputGroupSuffix>
</InputGroup>
</TextField>
</template>
@@ -0,0 +1,29 @@
<script setup lang="ts">
import {
Button,
InputGroup,
InputGroupInput,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconCopy } from "@tabler/icons-vue";
</script>
<template>
<TextField
class="w-full max-w-[280px]"
default-value="heroui.com"
name="website"
>
<Label>网站</Label>
<InputGroup>
<InputGroupInput class="w-full max-w-[280px]" />
<InputGroupSuffix class="pe-0">
<Button is-icon-only aria-label="复制" size="sm" variant="ghost">
<IconCopy class="size-4" aria-hidden="true" />
</Button>
</InputGroupSuffix>
</InputGroup>
</TextField>
</template>
@@ -0,0 +1,33 @@
<script setup lang="ts">
import {
Button,
InputGroup,
InputGroupInput,
InputGroupPrefix,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconCopy, IconWorld } from "@tabler/icons-vue";
</script>
<template>
<TextField
class="w-full max-w-[280px]"
default-value="heroui.com"
name="website"
>
<Label>网站</Label>
<InputGroup>
<InputGroupPrefix>
<IconWorld class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput class="w-full max-w-[280px]" />
<InputGroupSuffix class="pe-0">
<Button is-icon-only aria-label="复制" size="sm" variant="ghost">
<IconCopy class="size-4" aria-hidden="true" />
</Button>
</InputGroupSuffix>
</InputGroup>
</TextField>
</template>
@@ -0,0 +1,24 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupPrefix,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconWorld } from "@tabler/icons-vue";
</script>
<template>
<TextField class="w-full max-w-[280px]" default-value="heroui" name="website">
<Label>网站</Label>
<InputGroup>
<InputGroupPrefix>
<IconWorld class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput class="w-full max-w-[280px]" />
<InputGroupSuffix>.com</InputGroupSuffix>
</InputGroup>
</TextField>
</template>
@@ -0,0 +1,25 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupSuffix,
Kbd,
KbdAbbr,
KbdContent,
TextField,
} from "@heroui-vue/components";
</script>
<template>
<TextField aria-label="命令" class="w-full max-w-[280px]" name="command">
<InputGroup>
<InputGroupInput class="w-full max-w-[280px]" placeholder="命令" />
<InputGroupSuffix class="pe-2">
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>K</KbdContent>
</Kbd>
</InputGroupSuffix>
</InputGroup>
</TextField>
</template>
@@ -0,0 +1,20 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupSuffix,
Spinner,
TextField,
} from "@heroui-vue/components";
</script>
<template>
<TextField class="w-full max-w-[280px]" default-value="发送中…" name="status">
<InputGroup>
<InputGroupInput class="w-full max-w-[280px]" />
<InputGroupSuffix>
<Spinner class="size-4" />
</InputGroupSuffix>
</InputGroup>
</TextField>
</template>
@@ -0,0 +1,23 @@
<script setup lang="ts">
import {
Description,
InputGroup,
InputGroupInput,
InputGroupPrefix,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
</script>
<template>
<TextField class="w-full max-w-[280px]" default-value="10" name="price">
<Label>设置价格</Label>
<InputGroup>
<InputGroupPrefix>$</InputGroupPrefix>
<InputGroupInput class="w-full max-w-[200px]" type="number" />
<InputGroupSuffix>USD</InputGroupSuffix>
</InputGroup>
<Description>客户将支付的价格</Description>
</TextField>
</template>
@@ -0,0 +1,27 @@
<script setup lang="ts">
import {
Description,
InputGroup,
InputGroupInput,
InputGroupPrefix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<TextField class="w-full max-w-[280px]" name="email">
<Label>邮箱地址</Label>
<InputGroup>
<InputGroupPrefix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupPrefix>
<InputGroupInput
class="w-full max-w-[280px]"
placeholder="name@email.com"
/>
</InputGroup>
<Description>我们不会将此邮箱分享给任何人</Description>
</TextField>
</template>
@@ -0,0 +1,27 @@
<script setup lang="ts">
import {
Description,
InputGroup,
InputGroupInput,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
import { IconMail } from "@tabler/icons-vue";
</script>
<template>
<TextField class="w-full max-w-[280px]" name="email">
<Label>邮箱地址</Label>
<InputGroup>
<InputGroupInput
class="w-full max-w-[280px]"
placeholder="name@email.com"
/>
<InputGroupSuffix>
<IconMail class="size-4 text-muted" aria-hidden="true" />
</InputGroupSuffix>
</InputGroup>
<Description>我们不会发送垃圾邮件</Description>
</TextField>
</template>
@@ -0,0 +1,23 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupPrefix,
Label,
TextField,
} from "@heroui-vue/components";
</script>
<template>
<TextField
class="w-full max-w-[280px]"
default-value="heroui.com"
name="website"
>
<Label>网站</Label>
<InputGroup>
<InputGroupPrefix>https://</InputGroupPrefix>
<InputGroupInput class="w-full max-w-[280px]" />
</InputGroup>
</TextField>
</template>
@@ -0,0 +1,19 @@
<script setup lang="ts">
import {
InputGroup,
InputGroupInput,
InputGroupSuffix,
Label,
TextField,
} from "@heroui-vue/components";
</script>
<template>
<TextField class="w-full max-w-[280px]" default-value="heroui" name="website">
<Label>网站</Label>
<InputGroup>
<InputGroupInput class="w-full max-w-[280px]" />
<InputGroupSuffix>.com</InputGroupSuffix>
</InputGroup>
</TextField>
</template>
@@ -0,0 +1,99 @@
<script setup lang="ts">
import { onBeforeUnmount, ref } from "vue";
import {
Button,
InputGroup,
InputGroupPrefix,
InputGroupSuffix,
InputGroupTextArea,
Spinner,
TextField,
} from "@heroui-vue/components";
import {
IconArrowUp,
IconAt,
IconMicrophone,
IconPlugConnected,
IconPlus,
} from "@tabler/icons-vue";
const value = ref("");
const isSubmitting = ref(false);
let submitTimer: ReturnType<typeof setTimeout> | undefined;
onBeforeUnmount(() => clearTimeout(submitTimer));
function handleSubmit() {
if (!value.value.trim() || isSubmitting.value) return;
isSubmitting.value = true;
submitTimer = setTimeout(() => {
isSubmitting.value = false;
value.value = "";
}, 1000);
}
</script>
<template>
<TextField
aria-label="提示输入"
class="flex w-sm flex-col sm:w-lg"
full-width
name="prompt"
>
<InputGroup class="flex flex-col gap-2 rounded-3xl py-2" full-width>
<InputGroupPrefix class="px-3 py-0">
<Button aria-label="添加上下文" size="sm" variant="outline">
<IconAt aria-hidden="true" />
添加上下文
</Button>
</InputGroupPrefix>
<InputGroupTextArea
v-model="value"
class="w-full resize-none px-3.5 py-0"
placeholder="分配任务或提问…"
:rows="5"
/>
<InputGroupSuffix class="flex w-full items-center gap-1.5 px-3 py-0">
<Button
is-icon-only
aria-label="附加文件"
size="sm"
title="添加文件等"
variant="tertiary"
>
<IconPlus aria-hidden="true" />
</Button>
<Button
is-icon-only
aria-label="连接应用"
size="sm"
title="连接应用"
variant="tertiary"
>
<IconPlugConnected aria-hidden="true" />
</Button>
<div class="ms-auto flex items-center gap-1.5">
<Button
is-icon-only
aria-label="语音输入"
size="sm"
title="语音输入"
variant="ghost"
>
<IconMicrophone aria-hidden="true" />
</Button>
<Button
is-icon-only
aria-label="发送提示"
:is-disabled="!value.trim()"
:is-pending="isSubmitting"
title="发送"
@click="handleSubmit"
>
<Spinner v-if="isSubmitting" color="current" size="sm" />
<IconArrowUp v-else aria-hidden="true" />
</Button>
</div>
</InputGroupSuffix>
</InputGroup>
</TextField>
</template>