feat: add InputGroup and verify shared field integration
This commit is contained in:
@@ -54,6 +54,7 @@ const groups = [
|
||||
{ title: "Chip 标签", url: "/components/chip" },
|
||||
{ title: "CloseButton 关闭按钮", url: "/components/close-button" },
|
||||
{ title: "Input 输入框", url: "/components/input" },
|
||||
{ title: "InputGroup 输入框组", url: "/components/input-group" },
|
||||
{ title: "Kbd 键盘按键", url: "/components/kbd" },
|
||||
{ title: "Link 链接", url: "/components/link" },
|
||||
{ title: "Separator 分隔符", url: "/components/separator" },
|
||||
|
||||
@@ -12,6 +12,7 @@ description: 已迁移组件及文档
|
||||
- [Chip 标签](./components/chip)
|
||||
- [CloseButton 关闭按钮](./components/close-button)
|
||||
- [Input 输入框](./components/input)
|
||||
- [InputGroup 输入框组](./components/input-group)
|
||||
- [Kbd 键盘按键](./components/kbd)
|
||||
- [Link 链接](./components/link)
|
||||
- [Separator 分隔符](./components/separator)
|
||||
|
||||
@@ -0,0 +1,299 @@
|
||||
---
|
||||
title: InputGroup 输入框组
|
||||
description: 将相关输入控件与前后缀元素组合,以增强表单字段
|
||||
component: input-group
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
InputGroup,
|
||||
InputGroupInput,
|
||||
InputGroupPrefix,
|
||||
Label,
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="input-group-default" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
InputGroup,
|
||||
InputGroupInput,
|
||||
InputGroupPrefix,
|
||||
InputGroupSuffix,
|
||||
Label,
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField>
|
||||
<Label />
|
||||
<InputGroup>
|
||||
<InputGroupPrefix />
|
||||
<InputGroupInput />
|
||||
<!-- 多行请使用 InputGroupTextArea -->
|
||||
<InputGroupSuffix />
|
||||
</InputGroup>
|
||||
</TextField>
|
||||
</template>
|
||||
```
|
||||
|
||||
> **InputGroup** 使用可选的前缀与后缀包裹输入框,形成视觉上统一的组合。通常放在 **TextField** 内,用于在输入前后添加图标、文字、按钮等元素。单行输入请使用 **InputGroupInput**,多行输入请使用 **InputGroupTextArea**。
|
||||
|
||||
命名导出为 `InputGroup` / `InputGroupInput` / `InputGroupTextArea` / `InputGroupPrefix` / `InputGroupSuffix`,不使用 `InputGroup.Input` 对象式子部件。值、校验、ARIA、reset 与表单提交由既有 TextField / `useTextControl` 统一管理。
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
InputGroup 组件支持两种视觉变体:
|
||||
|
||||
- **`primary`**(默认)- 标准样式带阴影,适用于大多数场景
|
||||
- **`secondary`** - 低强调变体无阴影,适用于 Surface 组件内
|
||||
|
||||
<ComponentPreview name="input-group-variants" />
|
||||
|
||||
### 表面样式
|
||||
|
||||
在 [Surface](/components/surface) 内使用时,请使用 `variant="secondary"` 以应用适合 Surface 背景的低强调变体。
|
||||
|
||||
<ComponentPreview name="input-group-on-surface" />
|
||||
|
||||
### 后缀加载状态
|
||||
|
||||
在后缀显示加载 spinner 以表示正在处理。
|
||||
|
||||
<ComponentPreview name="input-group-with-loading-suffix" />
|
||||
|
||||
### 必填字段
|
||||
|
||||
InputGroup 会遵循父级 TextField 的必填状态。
|
||||
|
||||
<ComponentPreview name="input-group-required" />
|
||||
|
||||
### 禁用状态
|
||||
|
||||
InputGroup 会遵循父级 TextField 的禁用状态。
|
||||
|
||||
<ComponentPreview name="input-group-disabled" />
|
||||
|
||||
### 宽度充满
|
||||
|
||||
<ComponentPreview name="input-group-full-width" />
|
||||
|
||||
### 文字前缀
|
||||
|
||||
使用文字作为前缀,例如货币符号或协议前缀。
|
||||
|
||||
<ComponentPreview name="input-group-with-text-prefix" />
|
||||
|
||||
### 文字后缀
|
||||
|
||||
使用文字作为后缀,例如域名后缀或单位。
|
||||
|
||||
<ComponentPreview name="input-group-with-text-suffix" />
|
||||
|
||||
### 图标前缀与文字后缀
|
||||
|
||||
组合图标前缀与文字后缀。
|
||||
|
||||
<ComponentPreview name="input-group-with-icon-prefix-and-text-suffix" />
|
||||
|
||||
### 复制按钮后缀
|
||||
|
||||
在后缀中加入按钮,例如复制图标按钮。本例仅展示布局,复制逻辑由使用方接入。嵌入按钮使用 `type="button"`(本库 Button 默认),避免误提交表单。
|
||||
|
||||
<ComponentPreview name="input-group-with-copy-suffix" />
|
||||
|
||||
### 图标前缀与复制按钮
|
||||
|
||||
组合图标前缀与交互式后缀按钮。
|
||||
|
||||
<ComponentPreview name="input-group-with-icon-prefix-and-copy-suffix" />
|
||||
|
||||
### 密码可见性切换
|
||||
|
||||
在后缀中使用按钮切换密码可见性。
|
||||
|
||||
<ComponentPreview name="input-group-password-with-toggle" />
|
||||
|
||||
### 键盘快捷键
|
||||
|
||||
使用 [Kbd](/components/kbd) 组件展示键盘快捷键。
|
||||
|
||||
<ComponentPreview name="input-group-with-keyboard-shortcut" />
|
||||
|
||||
### 徽章后缀
|
||||
|
||||
在后缀中加入徽章或 chip,用于展示状态或标签。
|
||||
|
||||
<ComponentPreview name="input-group-with-badge-suffix" />
|
||||
|
||||
### 表单校验
|
||||
|
||||
InputGroup 会自动反映父级 TextField 的无效状态。
|
||||
|
||||
<ComponentPreview name="input-group-invalid" />
|
||||
|
||||
### 前缀图标
|
||||
|
||||
在输入框前添加图标。
|
||||
|
||||
<ComponentPreview name="input-group-with-prefix-icon" />
|
||||
|
||||
### 后缀图标
|
||||
|
||||
在输入框后添加图标。
|
||||
|
||||
<ComponentPreview name="input-group-with-suffix-icon" />
|
||||
|
||||
### 前缀与后缀
|
||||
|
||||
同时组合前缀与后缀。
|
||||
|
||||
<ComponentPreview name="input-group-with-prefix-and-suffix" />
|
||||
|
||||
### 文本域
|
||||
|
||||
多行输入请使用 **InputGroupTextArea**,并搭配前缀与后缀。当存在 textarea 时,容器高度会自动适应内容,并将前缀/后缀与顶部对齐。
|
||||
|
||||
上游示例中的 Tooltip 由原生 `title` 与 `aria-label` 适配(Tooltip 组件尚未迁移)。
|
||||
|
||||
<ComponentPreview name="input-group-with-textarea" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="input-group-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
InputGroup 使用可自定义的 CSS 类。覆盖组件类以匹配设计系统。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-input-group {
|
||||
@apply bg-field text-field-foreground shadow-field rounded-field inline-flex min-h-9 items-center overflow-hidden border text-sm outline-none;
|
||||
}
|
||||
|
||||
.hv-input-group__input {
|
||||
@apply flex-1 rounded-none border-0 bg-transparent px-3 py-2 shadow-none outline-none;
|
||||
}
|
||||
|
||||
.hv-input-group__prefix {
|
||||
@apply text-field-placeholder rounded-l-field flex h-full items-center justify-center rounded-r-none bg-transparent px-3;
|
||||
}
|
||||
|
||||
.hv-input-group__suffix {
|
||||
@apply text-field-placeholder rounded-r-field flex h-full items-center justify-center rounded-l-none bg-transparent px-3;
|
||||
}
|
||||
|
||||
/* Secondary variant */
|
||||
.hv-input-group--secondary {
|
||||
@apply shadow-none;
|
||||
background-color: var(--color-default);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
|
||||
|
||||
### CSS 类
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-input-group` – 根容器:带边框、背景与 flex 布局。默认 `min-h-9` 与 `items-center`;存在 textarea 时切换为 `items-start`
|
||||
- `.hv-input-group__input` – 透明背景、无边框的输入元素。textarea 也使用该基础类
|
||||
- `.hv-input-group__prefix` – 左侧圆角的前缀容器。与 textarea 搭配时与顶部对齐
|
||||
- `.hv-input-group__suffix` – 右侧圆角的后缀容器。与 textarea 搭配时与顶部对齐
|
||||
|
||||
#### 变体类 [!toc]
|
||||
|
||||
- `.hv-input-group--primary` – 带阴影的主变体(默认)
|
||||
- `.hv-input-group--secondary` – 无阴影的次变体,适用于 Surface 内
|
||||
|
||||
**Note:** 使用 `InputGroupTextArea` 时,容器从 `items-center` 切换为 `items-start`,并使用 `height: auto` 替代固定高度。前缀与后缀与顶部对齐,并增加内边距以匹配 textarea 的垂直内边距。textarea 使用相同的 `.hv-input-group__input` 基础类,并通过 `[data-slot="input-group-textarea"]` 选择器应用 textarea 专用样式(最小高度与纵向 resize)。
|
||||
|
||||
### 交互状态
|
||||
|
||||
InputGroup 会根据状态自动管理以下 data 属性:
|
||||
|
||||
- **Hover**:`[data-hovered]` - 悬停在组合上时应用
|
||||
- **Focus Within**:`[data-focus-within]` - 输入聚焦时应用
|
||||
- **Invalid**:`[data-invalid]` - 父级 TextField 无效时应用
|
||||
- **Disabled**:`[data-disabled]` 或 `[aria-disabled]` - 父级 TextField 禁用时应用
|
||||
|
||||
## API 参考
|
||||
|
||||
### InputGroup
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ----------- | --------------------------------------- | -------------------------------- | ----------------------------------------- |
|
||||
| 默认插槽 | `Component` | - | 子部件(Input、TextArea、Prefix、Suffix) |
|
||||
| `variant` | `'primary' \| 'secondary'` | 继承 TextField,否则 `'primary'` | 视觉变体。显式值优先于 TextField 继承 |
|
||||
| `fullWidth` | `boolean` | `false` | 输入组是否占满容器宽度 |
|
||||
| `role` | `'group' \| 'region' \| 'presentation'` | `'group'` | 分组的无障碍角色 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
点击组合空白区域会聚焦内部真实 input/textarea(按钮等可交互子元素除外)。`aria-label`、`aria-labelledby`、`aria-describedby` 等 ARIA 属性透传到根节点。
|
||||
|
||||
### InputGroupInput
|
||||
|
||||
真实 `input` 元素,复用 `useTextControl` 与 TextField 上下文。
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------------- | --------------------------- | -------- | ------------------------------------- |
|
||||
| `modelValue` | `string` | - | 当前值(受控;也可由 TextField 管理) |
|
||||
| `defaultValue` | `string` | - | 默认值(非受控) |
|
||||
| `type` | `string` | `'text'` | 输入类型(text、password、email 等) |
|
||||
| `invalid` | `boolean` | - | 标记无效状态(与父字段错误合并) |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
`name`、`id`、`disabled`、`readonly`、`required`、原生约束与 ARIA 落在真实 `input` 上;从 TextField 继承;控件可额外启用 disabled/readonly/required,不能通过 false 解除父字段状态。
|
||||
|
||||
### InputGroupTextArea
|
||||
|
||||
真实 `textarea` 元素,复用同一套值/reset/ARIA 协议。
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------------- | --------------------------- | ------ | -------------------------------- |
|
||||
| `modelValue` | `string` | - | 当前值(受控) |
|
||||
| `defaultValue` | `string` | - | 默认值(非受控) |
|
||||
| `rows` | `number` | - | 可见文本行数 |
|
||||
| `invalid` | `boolean` | - | 标记无效状态(与父字段错误合并) |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
### InputGroupPrefix
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------- | --------------------------- | ------ | ----------------------------- |
|
||||
| 默认插槽 | `Component` | - | 前缀内容(图标、文字等) |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
前后缀是展示容器,不是第二个表单字段,不会出现在 FormData 中。
|
||||
|
||||
### InputGroupSuffix
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------- | --------------------------- | ------ | ------------------------------ |
|
||||
| 默认插槽 | `Component` | - | 后缀内容(图标、按钮、徽章等) |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
`class` 遵循 Vue 的 class 绑定,可接收字符串、数组和对象并与基础类合并;不要使用 React 的 `className`。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Input 输入框](./input) · [Surface 表面](./surface) · [Button 按钮](./button)
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user