fix(demos): restore form, overlay and toast demos to the pinned cn baseline
HD-02 scope, all against heroui ce90ea3 cn sources:
- card: add the text-primary class to the coin icons (source parity);
card-with-form drops the added required validation and inline business
note, restores the plain href="#" forgot-password link and the baseline
alert("表单提交成功!") submit feedback (autocomplete kept: no visible
impact, allowed by the task card)
- input-group-with-textarea: restore the four Tooltips and the Enter Kbd
hint; drop the stale "Tooltip 组件尚未迁移" note from input-group.md
- alert-dialog: restore the h-px top light line in custom-styles and the
truncated/missing description text in sizes/custom-portal/
custom-animations (+ controlled); align the fluid-slide icon with the
modal mapping (IconArrowBarUp for gravity-ui:arrow-up-from-line)
- toast: restore the upstream demo layout shells (variants/simple/
custom-indicator/custom-queue) and the action button default variant:
ToastActionButton now falls back to the Button defaults (primary/md)
like upstream ToastActionButton, so variants' actions render primary,
danger stays danger and default stays tertiary; toast.md defaults fixed
- submit demos: restore baseline feedback and structure — alert() for
card/fieldset/form/checkbox/checkbox-group/switch/select/combo-box/
autocomplete and console.log for search/number/time field form examples;
modal-with-form returns to the close-only footer (no submit/result row);
drop the added inline status/result rows and the max-w-full/
max-sm:min-w-0 width guards from the restored demos
- radio-group-validation: add the missing text-muted to the result line;
label.md invalid example gives the real control its invalid state and
matches the baseline input shape
Tests re-pinned to the baseline contracts (alert/console/close behavior,
four tooltips + Kbd, positional modal footer); full suite 110 files /
1617 tests, typecheck, build:docs and the m35-m36 tarball contract pass.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { IconArrowUp, IconSparkles } from "@tabler/icons-vue";
|
||||
import {
|
||||
IconArrowBarUp as ArrowUpFromLine,
|
||||
IconSparkles,
|
||||
} from "@tabler/icons-vue";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogBackdrop,
|
||||
@@ -28,9 +31,9 @@ const animations = [
|
||||
},
|
||||
{
|
||||
name: "流体滑入",
|
||||
icon: IconArrowUp,
|
||||
icon: ArrowUpFromLine,
|
||||
description:
|
||||
"模拟在介质中运动并受流体阻力影响,避免机械式线性,更自然、更贴地。",
|
||||
"模拟在介质中运动并受流体阻力影响,避免机械式线性,更自然、更贴地,适合底部抽屉或 Toast。",
|
||||
backdropClass:
|
||||
"data-[entering]:duration-500 data-[entering]:ease-[cubic-bezier(0.25,1,0.5,1)] data-[exiting]:duration-200 data-[exiting]:ease-[cubic-bezier(0.5,0,0.75,0)]",
|
||||
containerClass:
|
||||
|
||||
@@ -50,10 +50,17 @@ const portalEl = ref<HTMLElement | null>(null);
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogBody>
|
||||
<p class="text-sm text-muted">
|
||||
此段为示例占位文案,用于演示在自定义容器内渲染对话框时的滚动与排版效果。
|
||||
此段为示例占位文案,用于演示在自定义容器内渲染对话框时的滚动与排版效果。实际项目中请替换为真实说明内容。
|
||||
</p>
|
||||
<p class="text-sm text-muted">
|
||||
通过将浮层挂载到局部容器,可以配合裁剪、缩放或卡片布局,避免遮挡整个页面。
|
||||
通过将浮层挂载到局部容器,可以配合裁剪、缩放或卡片布局,避免遮挡整个页面,同时仍保持焦点管理与无障碍行为。
|
||||
</p>
|
||||
<p class="text-sm text-muted">
|
||||
若容器存在
|
||||
<code>transform</code>
|
||||
或
|
||||
<code>filter</code>
|
||||
等属性,请注意浏览器会为其创建新的包含块,从而影响定位与层级关系。
|
||||
</p>
|
||||
</AlertDialogBody>
|
||||
<AlertDialogFooter>
|
||||
|
||||
@@ -29,6 +29,10 @@ import {
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute inset-x-0 top-0 h-24 bg-linear-to-b from-accent/6 to-transparent dark:from-accent/10"
|
||||
/>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute inset-x-8 top-0 h-px bg-linear-to-r from-transparent via-accent/35 to-transparent dark:via-accent/45"
|
||||
/>
|
||||
<AlertDialogHeader class="relative">
|
||||
<AlertDialogIcon status="accent" />
|
||||
<AlertDialogHeading>确定要退出账户吗?</AlertDialogHeading>
|
||||
|
||||
@@ -45,12 +45,13 @@ const sizes = ["xs", "sm", "md", "lg", "cover"] as const;
|
||||
<p v-if="size === 'cover'">
|
||||
此警告框使用
|
||||
<code>cover</code>
|
||||
尺寸:在移动端与桌面端保留边距铺满可视区域,仍保持圆角与标准内边距。
|
||||
尺寸:在移动端与桌面端保留边距(移动端约 16px、桌面端约
|
||||
40px)铺满可视区域,仍保持圆角与标准内边距,适合需要最大宽度又保留对话框气质的关键确认。
|
||||
</p>
|
||||
<p v-else>
|
||||
此警告框使用
|
||||
<code>{{ size }}</code>
|
||||
尺寸。在移动端各尺寸都会接近全宽以便阅读;在桌面端则对应不同的最大宽度。
|
||||
尺寸。在移动端各尺寸都会接近全宽以便阅读;在桌面端则对应不同的最大宽度,以适配不同信息量。
|
||||
</p>
|
||||
</AlertDialogBody>
|
||||
<AlertDialogFooter>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Autocomplete,
|
||||
AutocompleteClearButton,
|
||||
@@ -41,13 +40,10 @@ const countries = [
|
||||
{ id: "germany", name: "Germany" },
|
||||
];
|
||||
|
||||
const message = ref<string | null>(null);
|
||||
|
||||
function onSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(event.currentTarget as HTMLFormElement);
|
||||
void formData;
|
||||
message.value = "表单提交成功!";
|
||||
// The Form guard already blocks invalid submits, so a reached handler is valid.
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -144,8 +140,5 @@ function onSubmit(event: Event) {
|
||||
<FieldError />
|
||||
</Autocomplete>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="message" role="status" class="text-sm text-muted">
|
||||
{{ message }}
|
||||
</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
</script>
|
||||
<template>
|
||||
<Card class="w-[400px]">
|
||||
<IconCoin role="img" aria-label="美元图标" class="size-6" />
|
||||
<IconCoin role="img" aria-label="美元图标" class="text-primary size-6" />
|
||||
<CardHeader>
|
||||
<CardTitle>成为 Acme 创作者!</CardTitle>
|
||||
<CardDescription>
|
||||
|
||||
@@ -10,10 +10,12 @@ import {
|
||||
Link,
|
||||
} from "@heroui-vue/components";
|
||||
import { Input, Label } from "@heroui-vue/components";
|
||||
import { ref, useId } from "vue";
|
||||
import { useId } from "vue";
|
||||
const id = useId();
|
||||
const submitted = ref(false);
|
||||
const message = ref("");
|
||||
function onSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Card class="w-full max-w-md">
|
||||
@@ -21,7 +23,7 @@ const message = ref("");
|
||||
<CardTitle>登录</CardTitle>
|
||||
<CardDescription>输入账号信息以访问您的账户</CardDescription>
|
||||
</CardHeader>
|
||||
<form class="flex flex-col" @submit.prevent="submitted = true">
|
||||
<form class="flex flex-col" @submit="onSubmit">
|
||||
<CardContent>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-col gap-1">
|
||||
@@ -33,7 +35,6 @@ const message = ref("");
|
||||
autocomplete="email"
|
||||
placeholder="email@example.com"
|
||||
variant="secondary"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
@@ -45,28 +46,14 @@ const message = ref("");
|
||||
autocomplete="current-password"
|
||||
placeholder="••••••••"
|
||||
variant="secondary"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
<CardFooter class="mt-4 flex flex-col gap-2">
|
||||
<Button class="w-full" type="submit">登录</Button>
|
||||
<Link
|
||||
class="text-center text-sm"
|
||||
href="#"
|
||||
@click.prevent="message = '请联系账户管理员重置密码。'"
|
||||
>
|
||||
忘记密码?
|
||||
</Link>
|
||||
<Link class="text-center text-sm" href="#">忘记密码?</Link>
|
||||
</CardFooter>
|
||||
<p
|
||||
v-if="submitted || message"
|
||||
role="status"
|
||||
class="mt-2 text-sm text-muted"
|
||||
>
|
||||
{{ message || "表单提交成功!此示例不会发送账号信息。" }}
|
||||
</p>
|
||||
</form>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
@@ -62,7 +62,7 @@ import {
|
||||
<IconCoin
|
||||
role="img"
|
||||
aria-label="美元图标"
|
||||
class="size-8 shrink-0"
|
||||
class="text-primary size-8 shrink-0"
|
||||
/>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-xs font-medium text-muted uppercase">
|
||||
|
||||
@@ -6,15 +6,13 @@ import {
|
||||
Checkbox,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const data = new FormData(event.currentTarget as HTMLFormElement);
|
||||
result.value =
|
||||
"表单提交数据:\n" +
|
||||
Array.from(data)
|
||||
alert(
|
||||
`表单提交数据:\n${Array.from(data)
|
||||
.map(([key, value]) => `${key}: ${value}`)
|
||||
.join("\n");
|
||||
.join("\n")}`,
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@@ -46,8 +44,5 @@ function submit(event: Event) {
|
||||
</Checkbox>
|
||||
</div>
|
||||
<Button class="mt-4" size="sm" type="submit" variant="primary">提交</Button>
|
||||
<pre v-if="result" role="status" class="whitespace-pre-wrap text-sm">{{
|
||||
result
|
||||
}}</pre>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
@@ -10,11 +10,10 @@ import {
|
||||
Button,
|
||||
Form,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const data = new FormData(event.currentTarget as HTMLFormElement);
|
||||
result.value = "已选偏好:" + data.getAll("preferences").join(", ");
|
||||
const values = data.getAll("preferences");
|
||||
alert(`已选偏好:${values.join(", ")}`);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@@ -48,6 +47,5 @@ function submit(event: Event) {
|
||||
<FieldError>请至少选择一种通知方式。</FieldError>
|
||||
</CheckboxGroup>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="result" role="status" class="text-sm">{{ result }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
ComboBox,
|
||||
@@ -36,10 +35,8 @@ function validate(value: string | number | (string | number)[] | null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const message = ref("");
|
||||
|
||||
function onSubmit() {
|
||||
message.value = "表单提交成功!";
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -67,6 +64,5 @@ function onSubmit() {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button class="w-fit" type="submit">提交</Button>
|
||||
<p v-if="message" class="text-sm text-muted" role="status">{{ message }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
ComboBox,
|
||||
@@ -16,11 +15,9 @@ import {
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const message = ref("");
|
||||
|
||||
function onSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
message.value = "表单提交成功!";
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -64,9 +61,6 @@ function onSubmit(event: Event) {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="message" class="text-sm text-muted" role="status">
|
||||
{{ message }}
|
||||
</p>
|
||||
</Form>
|
||||
</Surface>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
ComboBox,
|
||||
@@ -15,12 +14,9 @@ import {
|
||||
ListBoxItemIndicator,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const submitted = ref(false);
|
||||
|
||||
function submit(event: Event) {
|
||||
function submit() {
|
||||
// The Form guard already blocks invalid submits, so a reached handler is valid.
|
||||
void new FormData(event.currentTarget as HTMLFormElement);
|
||||
submitted.value = true;
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -63,8 +59,5 @@ function submit(event: Event) {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="submitted" role="status" class="text-sm text-muted">
|
||||
表单提交成功!
|
||||
</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -14,19 +14,14 @@ import {
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconDeviceFloppy } from "@tabler/icons-vue";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function validateName(value: string) {
|
||||
return value.length < 3 ? "姓名至少需要 3 个字符" : null;
|
||||
}
|
||||
function validateBio(value: string) {
|
||||
return value.length < 10 ? "简介至少需要 10 个字符" : null;
|
||||
}
|
||||
function submit(event: Event) {
|
||||
const data = Object.fromEntries(
|
||||
new FormData(event.currentTarget as HTMLFormElement),
|
||||
);
|
||||
result.value = `表单提交成功!${JSON.stringify(data)}`;
|
||||
function submit() {
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@@ -57,11 +52,8 @@ function submit(event: Event) {
|
||||
<IconDeviceFloppy aria-hidden="true" />
|
||||
保存更改
|
||||
</Button>
|
||||
<Button type="reset" variant="secondary" @click="result = ''">
|
||||
取消
|
||||
</Button>
|
||||
<Button type="reset" variant="secondary">取消</Button>
|
||||
</FieldsetActions>
|
||||
</Fieldset>
|
||||
<p v-if="result" class="text-sm text-muted" role="status">{{ result }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -14,19 +14,14 @@ import {
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconDeviceFloppy } from "@tabler/icons-vue";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function validateName(value: string) {
|
||||
return value.length < 3 ? "姓名至少需要 3 个字符" : null;
|
||||
}
|
||||
function validateBio(value: string) {
|
||||
return value.length < 10 ? "简介至少需要 10 个字符" : null;
|
||||
}
|
||||
function submit(event: Event) {
|
||||
const data = Object.fromEntries(
|
||||
new FormData(event.currentTarget as HTMLFormElement),
|
||||
);
|
||||
result.value = `表单提交成功!${JSON.stringify(data)}`;
|
||||
function submit() {
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
const shell =
|
||||
"rounded-xl border border-border/70 bg-linear-to-b from-neutral-50/90 to-white p-4 ring-1 ring-black/5 dark:from-neutral-900/80 dark:to-neutral-900 dark:ring-white/10";
|
||||
@@ -67,11 +62,8 @@ const fieldClass =
|
||||
<IconDeviceFloppy aria-hidden="true" />
|
||||
保存更改
|
||||
</Button>
|
||||
<Button type="reset" variant="secondary" @click="result = ''">
|
||||
取消
|
||||
</Button>
|
||||
<Button type="reset" variant="secondary">取消</Button>
|
||||
</FieldsetActions>
|
||||
</Fieldset>
|
||||
<p v-if="result" class="text-sm text-muted" role="status">{{ result }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -15,24 +15,19 @@ import {
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconDeviceFloppy } from "@tabler/icons-vue";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function validateName(value: string) {
|
||||
return value.length < 3 ? "姓名至少需要 3 个字符" : null;
|
||||
}
|
||||
function validateBio(value: string) {
|
||||
return value.length < 10 ? "简介至少需要 10 个字符" : null;
|
||||
}
|
||||
function submit(event: Event) {
|
||||
const data = Object.fromEntries(
|
||||
new FormData(event.currentTarget as HTMLFormElement),
|
||||
);
|
||||
result.value = `表单提交成功!${JSON.stringify(data)}`;
|
||||
function submit() {
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center justify-center rounded-3xl bg-surface p-6">
|
||||
<Surface class="w-full min-w-[380px] max-sm:min-w-0">
|
||||
<Surface class="w-full min-w-[380px]">
|
||||
<Form @submit.prevent="submit">
|
||||
<Fieldset class="w-full">
|
||||
<FieldsetLegend>个人资料设置</FieldsetLegend>
|
||||
@@ -60,14 +55,9 @@ function submit(event: Event) {
|
||||
<IconDeviceFloppy aria-hidden="true" />
|
||||
保存更改
|
||||
</Button>
|
||||
<Button type="reset" variant="tertiary" @click="result = ''">
|
||||
取消
|
||||
</Button>
|
||||
<Button type="reset" variant="tertiary">取消</Button>
|
||||
</FieldsetActions>
|
||||
</Fieldset>
|
||||
<p v-if="result" class="text-sm text-muted" role="status">
|
||||
{{ result }}
|
||||
</p>
|
||||
</Form>
|
||||
</Surface>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { IconCheck } from "@tabler/icons-vue";
|
||||
import {
|
||||
Button,
|
||||
@@ -11,7 +10,6 @@ import {
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const result = ref("");
|
||||
function onSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(event.currentTarget as HTMLFormElement);
|
||||
@@ -19,7 +17,7 @@ function onSubmit(event: Event) {
|
||||
formData.forEach((value, key) => {
|
||||
data[key] = value.toString();
|
||||
});
|
||||
result.value = `表单提交数据:${JSON.stringify(data, null, 2)}`;
|
||||
alert(`表单提交数据:${JSON.stringify(data, null, 2)}`);
|
||||
}
|
||||
function validateEmail(value: string) {
|
||||
return /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(value)
|
||||
@@ -35,11 +33,7 @@ function validatePassword(value: string) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Form
|
||||
class="flex w-96 max-w-full flex-col gap-4"
|
||||
@submit="onSubmit"
|
||||
@reset="result = ''"
|
||||
>
|
||||
<Form class="flex w-96 flex-col gap-4" @submit="onSubmit">
|
||||
<TextField is-required name="email" type="email" :validate="validateEmail">
|
||||
<Label>邮箱</Label>
|
||||
<Input placeholder="john@example.com" />
|
||||
@@ -64,11 +58,5 @@ function validatePassword(value: string) {
|
||||
</Button>
|
||||
<Button type="reset" variant="secondary">重置</Button>
|
||||
</div>
|
||||
<pre
|
||||
v-if="result"
|
||||
role="status"
|
||||
aria-label="提交结果"
|
||||
class="whitespace-pre-wrap break-all text-xs"
|
||||
>{{ result }}</pre>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Button, Form, Input, Label, TextField } from "@heroui-vue/components";
|
||||
|
||||
<template>
|
||||
<Form
|
||||
class="flex w-80 max-w-full flex-col gap-3 rounded-xl border border-border/80 bg-surface p-4 shadow-sm"
|
||||
class="flex w-80 flex-col gap-3 rounded-xl border border-border/80 bg-surface p-4 shadow-sm"
|
||||
@submit.prevent
|
||||
>
|
||||
<TextField is-required name="email" type="email">
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { IconCheck } from "@tabler/icons-vue";
|
||||
import {
|
||||
Button,
|
||||
@@ -11,7 +10,6 @@ import {
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const result = ref("");
|
||||
function onSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(event.currentTarget as HTMLFormElement);
|
||||
@@ -19,7 +17,7 @@ function onSubmit(event: Event) {
|
||||
formData.forEach((value, key) => {
|
||||
data[key] = value.toString();
|
||||
});
|
||||
result.value = `表单提交数据:${JSON.stringify(data, null, 2)}`;
|
||||
alert(`表单提交数据:${JSON.stringify(data, null, 2)}`);
|
||||
}
|
||||
function validateEmail(value: string) {
|
||||
return /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(value)
|
||||
@@ -35,12 +33,7 @@ function validatePassword(value: string) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Form
|
||||
class="flex w-96 max-w-full flex-col gap-4"
|
||||
data-custom="foo"
|
||||
@submit="onSubmit"
|
||||
@reset="result = ''"
|
||||
>
|
||||
<Form class="flex w-96 flex-col gap-4" data-custom="foo" @submit="onSubmit">
|
||||
<TextField is-required name="email" type="email" :validate="validateEmail">
|
||||
<Label>邮箱</Label>
|
||||
<Input placeholder="john@example.com" />
|
||||
@@ -65,11 +58,5 @@ function validatePassword(value: string) {
|
||||
</Button>
|
||||
<Button type="reset" variant="secondary">重置</Button>
|
||||
</div>
|
||||
<pre
|
||||
v-if="result"
|
||||
role="status"
|
||||
aria-label="提交结果"
|
||||
class="whitespace-pre-wrap break-all text-xs"
|
||||
>{{ result }}</pre>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -6,8 +6,12 @@ import {
|
||||
InputGroupPrefix,
|
||||
InputGroupSuffix,
|
||||
InputGroupTextArea,
|
||||
Kbd,
|
||||
KbdAbbr,
|
||||
Spinner,
|
||||
TextField,
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconArrowUp,
|
||||
@@ -53,45 +57,64 @@ function handleSubmit() {
|
||||
: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">
|
||||
<Tooltip :delay="0">
|
||||
<Button
|
||||
is-icon-only
|
||||
aria-label="语音输入"
|
||||
aria-label="附加文件"
|
||||
size="sm"
|
||||
title="语音输入"
|
||||
variant="ghost"
|
||||
variant="tertiary"
|
||||
>
|
||||
<IconMicrophone aria-hidden="true" />
|
||||
<IconPlus aria-hidden="true" />
|
||||
</Button>
|
||||
<TooltipContent>
|
||||
<p class="text-xs">添加文件等</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Tooltip :delay="0">
|
||||
<Button
|
||||
is-icon-only
|
||||
aria-label="发送提示"
|
||||
:is-disabled="!value.trim()"
|
||||
:is-pending="isSubmitting"
|
||||
title="发送"
|
||||
@click="handleSubmit"
|
||||
aria-label="连接应用"
|
||||
size="sm"
|
||||
variant="tertiary"
|
||||
>
|
||||
<Spinner v-if="isSubmitting" color="current" size="sm" />
|
||||
<IconArrowUp v-else aria-hidden="true" />
|
||||
<IconPlugConnected aria-hidden="true" />
|
||||
</Button>
|
||||
<TooltipContent>
|
||||
<p class="text-xs">连接应用</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<div class="ms-auto flex items-center gap-1.5">
|
||||
<Tooltip :delay="0">
|
||||
<Button
|
||||
is-icon-only
|
||||
aria-label="语音输入"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
>
|
||||
<IconMicrophone aria-hidden="true" />
|
||||
</Button>
|
||||
<TooltipContent>
|
||||
<p class="text-xs">语音输入</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Tooltip :delay="0">
|
||||
<Button
|
||||
is-icon-only
|
||||
aria-label="发送提示"
|
||||
:is-disabled="!value.trim()"
|
||||
:is-pending="isSubmitting"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
<Spinner v-if="isSubmitting" color="current" size="sm" />
|
||||
<IconArrowUp v-else aria-hidden="true" />
|
||||
</Button>
|
||||
<TooltipContent class="flex items-center gap-1">
|
||||
<p class="text-xs">发送</p>
|
||||
<Kbd class="h-4 rounded-sm px-1">
|
||||
<KbdAbbr key-value="enter" />
|
||||
</Kbd>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</InputGroupSuffix>
|
||||
</InputGroup>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { IconPencil, IconSquarePlus, IconTrash } from "@tabler/icons-vue";
|
||||
import {
|
||||
Description,
|
||||
@@ -14,7 +13,9 @@ import {
|
||||
Separator,
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
const message = ref("");
|
||||
function onAction(key: string | number) {
|
||||
alert(`已选项目:${key}`);
|
||||
}
|
||||
const actions = [
|
||||
{
|
||||
id: "new-file",
|
||||
@@ -33,56 +34,53 @@ const actions = [
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<div class="space-y-3">
|
||||
<Surface class="w-[256px] rounded-3xl shadow-surface">
|
||||
<ListBox
|
||||
aria-label="文件操作"
|
||||
class="w-full p-2"
|
||||
selection-mode="none"
|
||||
@action="message = `已选项目:${$event}`"
|
||||
:disabled-keys="['delete-file']"
|
||||
>
|
||||
<ListBoxSection>
|
||||
<Header>操作</Header>
|
||||
<ListBoxItem
|
||||
v-for="action in actions"
|
||||
:key="action.id"
|
||||
:id="action.id"
|
||||
:text-value="action.title"
|
||||
>
|
||||
<div class="flex h-8 items-start justify-center pt-px">
|
||||
<component :is="action.icon" class="size-4 shrink-0 text-muted" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<Label>{{ action.title }}</Label>
|
||||
<Description>{{ action.description }}</Description>
|
||||
</div>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>{{ action.shortcut }}</KbdContent>
|
||||
</Kbd>
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
<Separator />
|
||||
<ListBoxSection>
|
||||
<Header>危险区域</Header>
|
||||
<ListBoxItem id="delete-file" text-value="删除文件" variant="danger">
|
||||
<div class="flex h-8 items-start justify-center pt-px">
|
||||
<IconTrash class="size-4 shrink-0 text-danger" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<Label>删除文件</Label>
|
||||
<Description>移至废纸篓</Description>
|
||||
</div>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdAbbr key-value="shift" />
|
||||
<KbdContent>D</KbdContent>
|
||||
</Kbd>
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
</ListBox>
|
||||
</Surface>
|
||||
<p v-if="message" role="status" class="text-sm text-muted">{{ message }}</p>
|
||||
</div>
|
||||
<Surface class="w-[256px] rounded-3xl shadow-surface">
|
||||
<ListBox
|
||||
aria-label="文件操作"
|
||||
class="w-full p-2"
|
||||
selection-mode="none"
|
||||
@action="onAction"
|
||||
:disabled-keys="['delete-file']"
|
||||
>
|
||||
<ListBoxSection>
|
||||
<Header>操作</Header>
|
||||
<ListBoxItem
|
||||
v-for="action in actions"
|
||||
:key="action.id"
|
||||
:id="action.id"
|
||||
:text-value="action.title"
|
||||
>
|
||||
<div class="flex h-8 items-start justify-center pt-px">
|
||||
<component :is="action.icon" class="size-4 shrink-0 text-muted" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<Label>{{ action.title }}</Label>
|
||||
<Description>{{ action.description }}</Description>
|
||||
</div>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>{{ action.shortcut }}</KbdContent>
|
||||
</Kbd>
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
<Separator />
|
||||
<ListBoxSection>
|
||||
<Header>危险区域</Header>
|
||||
<ListBoxItem id="delete-file" text-value="删除文件" variant="danger">
|
||||
<div class="flex h-8 items-start justify-center pt-px">
|
||||
<IconTrash class="size-4 shrink-0 text-danger" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<Label>删除文件</Label>
|
||||
<Description>移至废纸篓</Description>
|
||||
</div>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdAbbr key-value="shift" />
|
||||
<KbdContent>D</KbdContent>
|
||||
</Kbd>
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
</ListBox>
|
||||
</Surface>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { IconPencil, IconSquarePlus, IconTrash } from "@tabler/icons-vue";
|
||||
import {
|
||||
Description,
|
||||
@@ -14,7 +13,9 @@ import {
|
||||
Separator,
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
const message = ref("");
|
||||
function onAction(key: string | number) {
|
||||
alert(`已选项目:${key}`);
|
||||
}
|
||||
const actions = [
|
||||
{
|
||||
id: "new-file",
|
||||
@@ -33,55 +34,52 @@ const actions = [
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<div class="space-y-3">
|
||||
<Surface class="w-[256px] rounded-3xl shadow-surface">
|
||||
<ListBox
|
||||
aria-label="文件操作"
|
||||
class="w-full p-2"
|
||||
selection-mode="none"
|
||||
@action="message = `已选项目:${$event}`"
|
||||
>
|
||||
<ListBoxSection>
|
||||
<Header>操作</Header>
|
||||
<ListBoxItem
|
||||
v-for="action in actions"
|
||||
:key="action.id"
|
||||
:id="action.id"
|
||||
:text-value="action.title"
|
||||
>
|
||||
<div class="flex h-8 items-start justify-center pt-px">
|
||||
<component :is="action.icon" class="size-4 shrink-0 text-muted" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<Label>{{ action.title }}</Label>
|
||||
<Description>{{ action.description }}</Description>
|
||||
</div>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>{{ action.shortcut }}</KbdContent>
|
||||
</Kbd>
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
<Separator />
|
||||
<ListBoxSection>
|
||||
<Header>危险区域</Header>
|
||||
<ListBoxItem id="delete-file" text-value="删除文件" variant="danger">
|
||||
<div class="flex h-8 items-start justify-center pt-px">
|
||||
<IconTrash class="size-4 shrink-0 text-danger" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<Label>删除文件</Label>
|
||||
<Description>移至废纸篓</Description>
|
||||
</div>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdAbbr key-value="shift" />
|
||||
<KbdContent>D</KbdContent>
|
||||
</Kbd>
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
</ListBox>
|
||||
</Surface>
|
||||
<p v-if="message" role="status" class="text-sm text-muted">{{ message }}</p>
|
||||
</div>
|
||||
<Surface class="w-[256px] rounded-3xl shadow-surface">
|
||||
<ListBox
|
||||
aria-label="文件操作"
|
||||
class="w-full p-2"
|
||||
selection-mode="none"
|
||||
@action="onAction"
|
||||
>
|
||||
<ListBoxSection>
|
||||
<Header>操作</Header>
|
||||
<ListBoxItem
|
||||
v-for="action in actions"
|
||||
:key="action.id"
|
||||
:id="action.id"
|
||||
:text-value="action.title"
|
||||
>
|
||||
<div class="flex h-8 items-start justify-center pt-px">
|
||||
<component :is="action.icon" class="size-4 shrink-0 text-muted" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<Label>{{ action.title }}</Label>
|
||||
<Description>{{ action.description }}</Description>
|
||||
</div>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>{{ action.shortcut }}</KbdContent>
|
||||
</Kbd>
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
<Separator />
|
||||
<ListBoxSection>
|
||||
<Header>危险区域</Header>
|
||||
<ListBoxItem id="delete-file" text-value="删除文件" variant="danger">
|
||||
<div class="flex h-8 items-start justify-center pt-px">
|
||||
<IconTrash class="size-4 shrink-0 text-danger" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<Label>删除文件</Label>
|
||||
<Description>移至废纸篓</Description>
|
||||
</div>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdAbbr key-value="shift" />
|
||||
<KbdContent>D</KbdContent>
|
||||
</Kbd>
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
</ListBox>
|
||||
</Surface>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, useId } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
@@ -17,78 +16,61 @@ import {
|
||||
ModalIcon,
|
||||
Surface,
|
||||
TextField,
|
||||
useOverlayState,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconMail as Envelope } from "@tabler/icons-vue";
|
||||
const state = useOverlayState();
|
||||
const formId = useId();
|
||||
const result = ref<Record<string, FormDataEntryValue>>();
|
||||
function submit(event: SubmitEvent) {
|
||||
result.value = Object.fromEntries(
|
||||
new FormData(event.currentTarget as HTMLFormElement),
|
||||
);
|
||||
state.close();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<Modal :state="state">
|
||||
<Button variant="secondary">打开联系表单</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer placement="auto">
|
||||
<ModalDialog class="sm:max-w-md">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
|
||||
<Envelope aria-hidden="true" class="size-5"></Envelope>
|
||||
</ModalIcon>
|
||||
<ModalHeading>联系我们</ModalHeading>
|
||||
<p class="mt-1.5 text-sm leading-5 text-muted">
|
||||
填写下方表单,我们会尽快回复。在移动端弹出键盘时,模态框会自动适配。
|
||||
</p>
|
||||
</ModalHeader>
|
||||
<ModalBody class="p-6">
|
||||
<Surface variant="default">
|
||||
<form
|
||||
:id="formId"
|
||||
class="flex flex-col gap-4"
|
||||
@submit.prevent="submit"
|
||||
>
|
||||
<TextField class="w-full" name="name" type="text">
|
||||
<Label>姓名</Label>
|
||||
<Input placeholder="输入你的姓名"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="email" type="email">
|
||||
<Label>邮箱</Label>
|
||||
<Input placeholder="输入你的邮箱"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="phone" type="tel">
|
||||
<Label>电话</Label>
|
||||
<Input placeholder="输入你的电话号码"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="company">
|
||||
<Label>公司</Label>
|
||||
<Input placeholder="输入公司名称"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="message">
|
||||
<Label>留言</Label>
|
||||
<Input placeholder="输入留言内容"></Input>
|
||||
</TextField>
|
||||
</form>
|
||||
</Surface>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<Button type="submit" :form="formId">发送消息</Button>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
<p v-if="result" role="status" class="mt-3 text-sm text-muted">
|
||||
已记录表单:{{ result }}
|
||||
</p>
|
||||
</div>
|
||||
<Modal>
|
||||
<Button variant="secondary">打开联系表单</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer placement="auto">
|
||||
<ModalDialog class="sm:max-w-md">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
|
||||
<Envelope aria-hidden="true" class="size-5"></Envelope>
|
||||
</ModalIcon>
|
||||
<ModalHeading>联系我们</ModalHeading>
|
||||
<p class="mt-1.5 text-sm leading-5 text-muted">
|
||||
填写下方表单,我们会尽快回复。在移动端弹出键盘时,模态框会自动适配。
|
||||
</p>
|
||||
</ModalHeader>
|
||||
<ModalBody class="p-6">
|
||||
<Surface variant="default">
|
||||
<form class="flex flex-col gap-4">
|
||||
<TextField class="w-full" name="name" type="text">
|
||||
<Label>姓名</Label>
|
||||
<Input placeholder="输入你的姓名"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="email" type="email">
|
||||
<Label>邮箱</Label>
|
||||
<Input placeholder="输入你的邮箱"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="phone" type="tel">
|
||||
<Label>电话</Label>
|
||||
<Input placeholder="输入你的电话号码"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="company">
|
||||
<Label>公司</Label>
|
||||
<Input placeholder="输入公司名称"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="message">
|
||||
<Label>留言</Label>
|
||||
<Input placeholder="输入留言内容"></Input>
|
||||
</TextField>
|
||||
</form>
|
||||
</Surface>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child>
|
||||
<Button>发送消息</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -14,8 +14,7 @@ import {
|
||||
Spinner,
|
||||
} from "@heroui-vue/components";
|
||||
const value = ref<number | null>(null),
|
||||
isSubmitting = ref(false),
|
||||
feedback = ref("");
|
||||
isSubmitting = ref(false);
|
||||
const STOCK_AVAILABLE = 3;
|
||||
const isOutOfStock = computed(
|
||||
() => value.value !== null && value.value > STOCK_AVAILABLE,
|
||||
@@ -30,12 +29,11 @@ function submit() {
|
||||
)
|
||||
return;
|
||||
isSubmitting.value = true;
|
||||
feedback.value = "";
|
||||
// Local demonstration only; no order or network request is created.
|
||||
// Simulate API call
|
||||
timer = setTimeout(() => {
|
||||
console.log("Order submitted:", { quantity: value.value });
|
||||
value.value = null;
|
||||
isSubmitting.value = false;
|
||||
feedback.value = "模拟提交成功";
|
||||
}, 1500);
|
||||
}
|
||||
onBeforeUnmount(() => {
|
||||
@@ -43,10 +41,7 @@ onBeforeUnmount(() => {
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Form
|
||||
class="flex w-[280px] max-w-full flex-col gap-4"
|
||||
@submit.prevent="submit"
|
||||
>
|
||||
<Form class="flex w-[280px] flex-col gap-4" @submit.prevent="submit">
|
||||
<NumberField
|
||||
v-model="value"
|
||||
is-required
|
||||
@@ -79,6 +74,5 @@ onBeforeUnmount(() => {
|
||||
</template>
|
||||
<template v-else>下单</template>
|
||||
</Button>
|
||||
<p v-if="feedback" role="status">{{ feedback }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="w-[400px] max-w-full space-y-4">
|
||||
<div class="w-[400px] space-y-4">
|
||||
<NumberField fullWidth :defaultValue="1024" :minValue="0" name="width">
|
||||
<Label>宽度</Label>
|
||||
<NumberFieldGroup>
|
||||
|
||||
@@ -52,6 +52,6 @@ function submit(event: Event) {
|
||||
<FieldError>请先选择订阅套餐再继续。</FieldError>
|
||||
</RadioGroup>
|
||||
<Button class="mt-2 w-fit" type="submit">Submit</Button>
|
||||
<p v-if="result" role="status" class="text-sm">{{ result }}</p>
|
||||
<p v-if="result" role="status" class="text-sm text-muted">{{ result }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -15,20 +15,17 @@ import { Form } from "@heroui-vue/components";
|
||||
import { computed, onBeforeUnmount, ref } from "vue";
|
||||
const value = ref("");
|
||||
const isSubmitting = ref(false);
|
||||
const result = ref("");
|
||||
const isInvalid = computed(
|
||||
() => value.value.length > 0 && value.value.length < 3,
|
||||
);
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
function submit(event: Event) {
|
||||
function submit() {
|
||||
if (value.value.length < 3 || isSubmitting.value) return;
|
||||
const query = new FormData(event.currentTarget as HTMLFormElement).get(
|
||||
"search",
|
||||
);
|
||||
isSubmitting.value = true;
|
||||
// Simulate API call
|
||||
timer = setTimeout(() => {
|
||||
result.value = `已模拟提交搜索:${query}`;
|
||||
console.log("Search submitted:", { query: value.value });
|
||||
value.value = "";
|
||||
isSubmitting.value = false;
|
||||
}, 1500);
|
||||
@@ -65,6 +62,5 @@ function submit(event: Event) {
|
||||
</template>
|
||||
<template v-else>搜索</template>
|
||||
</Button>
|
||||
<p v-if="result" role="status" class="text-sm text-muted">{{ result }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -14,12 +14,13 @@ import {
|
||||
Button,
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const submitted = ref(false);
|
||||
function submit() {
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Surface class="w-[320px] rounded-3xl p-6">
|
||||
<Form class="flex w-full flex-col gap-4" @submit.prevent="submitted = true">
|
||||
<Form class="flex w-full flex-col gap-4" @submit.prevent="submit">
|
||||
<Select
|
||||
is-required
|
||||
class="w-full"
|
||||
@@ -105,9 +106,6 @@ const submitted = ref(false);
|
||||
<FieldError />
|
||||
</Select>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="submitted" role="status" class="text-sm text-success">
|
||||
表单提交成功!
|
||||
</p>
|
||||
</Form>
|
||||
</Surface>
|
||||
</template>
|
||||
|
||||
@@ -13,14 +13,12 @@ import {
|
||||
FieldError,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const submitted = ref(false);
|
||||
function submit() {
|
||||
alert("表单提交成功!");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Form
|
||||
class="flex w-[256px] flex-col gap-4"
|
||||
@submit.prevent="submitted = true"
|
||||
>
|
||||
<Form class="flex w-[256px] flex-col gap-4" @submit.prevent="submit">
|
||||
<Select is-required class="w-full" name="state" placeholder="请选择">
|
||||
<Label>州</Label>
|
||||
<SelectTrigger>
|
||||
@@ -94,8 +92,5 @@ const submitted = ref(false);
|
||||
<FieldError />
|
||||
</Select>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="submitted" role="status" class="text-sm text-success">
|
||||
表单提交成功!
|
||||
</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -7,13 +7,13 @@ import {
|
||||
SwitchGroup,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const values = [...new FormData(event.target as HTMLFormElement).entries()];
|
||||
result.value = values.length
|
||||
? "表单提交内容:" + values.map(([k, v]) => `${k}: ${v}`).join(",")
|
||||
: "未选择任何选项";
|
||||
const data = new FormData(event.currentTarget as HTMLFormElement);
|
||||
alert(
|
||||
`表单提交内容:\n${Array.from(data)
|
||||
.map(([key, value]) => `${key}: ${value}`)
|
||||
.join("\n")}`,
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@@ -38,20 +38,8 @@ function submit(event: Event) {
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</SwitchGroup>
|
||||
<div class="flex gap-2">
|
||||
<Button class="mt-4" size="sm" type="submit">Submit</Button>
|
||||
<Button
|
||||
class="mt-4"
|
||||
size="sm"
|
||||
type="reset"
|
||||
variant="secondary"
|
||||
@click="result = ''"
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</div>
|
||||
<output v-if="result" class="text-sm text-muted" aria-live="polite">
|
||||
{{ result }}
|
||||
</output>
|
||||
<Button class="mt-4" size="sm" type="submit" variant="primary">
|
||||
Submit
|
||||
</Button>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
@@ -30,14 +30,13 @@ const isInvalid = computed(() => {
|
||||
});
|
||||
import { onBeforeUnmount } from "vue";
|
||||
const isSubmitting = shallowRef(false);
|
||||
const submitted = shallowRef("");
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
function submit() {
|
||||
if (!value.value || isInvalid.value || isSubmitting.value) return;
|
||||
const payload = value.value.toString();
|
||||
isSubmitting.value = true;
|
||||
// Simulate API call
|
||||
timer = setTimeout(() => {
|
||||
submitted.value = payload;
|
||||
console.log("Time submitted:", { time: value.value });
|
||||
value.value = null;
|
||||
isSubmitting.value = false;
|
||||
}, 1500);
|
||||
@@ -78,8 +77,5 @@ onBeforeUnmount(() => clearTimeout(timer));
|
||||
>
|
||||
{{ isSubmitting ? "提交中…" : "提交" }}
|
||||
</Button>
|
||||
<output v-if="submitted" class="text-sm text-muted">
|
||||
已提交:{{ submitted }}
|
||||
</output>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -21,7 +21,7 @@ function show() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex h-full max-w-xl flex-col items-center justify-center">
|
||||
<Button size="sm" variant="secondary" @click="show">自定义指示器</Button>
|
||||
<ToastProvider :queue="queue" to="body" />
|
||||
</div>
|
||||
|
||||
@@ -11,51 +11,55 @@ onBeforeUnmount(() =>
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="flex h-full max-w-4xl flex-wrap items-center justify-center gap-4"
|
||||
>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="
|
||||
notificationQueue.add({
|
||||
title: '新通知',
|
||||
description: '您有一条新消息',
|
||||
variant: 'default',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加通知(最多 2 条)
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="danger-soft"
|
||||
@click="
|
||||
errorQueue.add({
|
||||
title: '发生错误',
|
||||
description: '保存更改失败',
|
||||
variant: 'danger',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加错误(最多 3 条)
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
class="text-success"
|
||||
@click="
|
||||
successQueue.add({
|
||||
title: '成功!',
|
||||
description: `操作 ${Date.now()}`,
|
||||
variant: 'success',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加成功(最多 1 条)
|
||||
</Button>
|
||||
<div class="flex h-full max-w-4xl items-center justify-center gap-4">
|
||||
<ToastProvider :queue="notificationQueue" to="body" placement="bottom" />
|
||||
<div class="flex justify-center gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="
|
||||
notificationQueue.add({
|
||||
title: '新通知',
|
||||
description: '您有一条新消息',
|
||||
variant: 'default',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加通知(最多 2 条)
|
||||
</Button>
|
||||
</div>
|
||||
<ToastProvider :queue="errorQueue" to="body" placement="bottom start" />
|
||||
<div class="flex justify-center gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="danger-soft"
|
||||
@click="
|
||||
errorQueue.add({
|
||||
title: '发生错误',
|
||||
description: '保存更改失败',
|
||||
variant: 'danger',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加错误(最多 3 条)
|
||||
</Button>
|
||||
</div>
|
||||
<ToastProvider :queue="successQueue" to="body" placement="bottom end" />
|
||||
<div class="flex justify-center gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
class="text-success"
|
||||
@click="
|
||||
successQueue.add({
|
||||
title: '成功!',
|
||||
description: `操作 ${Date.now()}`,
|
||||
variant: 'success',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加成功(最多 1 条)
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -11,26 +11,32 @@ const toast = createToastFunction(queue);
|
||||
onBeforeUnmount(() => queue.destroy());
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex h-full max-w-xl flex-wrap items-center justify-center gap-4">
|
||||
<Button size="sm" variant="secondary" @click="toast('简单消息')">
|
||||
默认
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" @click="toast.success('操作已完成')">
|
||||
成功
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" @click="toast.info('有新更新可用')">
|
||||
信息
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="toast.warning('请检查您的设置')"
|
||||
>
|
||||
警告
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" @click="toast.danger('出了点问题')">
|
||||
错误
|
||||
</Button>
|
||||
<ToastProvider :queue="queue" to="body" />
|
||||
<div class="flex h-full max-w-xl flex-col items-center justify-center">
|
||||
<div class="flex w-full flex-wrap items-center justify-center gap-4">
|
||||
<Button size="sm" variant="secondary" @click="toast('简单消息')">
|
||||
默认
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="toast.success('操作已完成')"
|
||||
>
|
||||
成功
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" @click="toast.info('有新更新可用')">
|
||||
信息
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="toast.warning('请检查您的设置')"
|
||||
>
|
||||
警告
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" @click="toast.danger('出了点问题')">
|
||||
错误
|
||||
</Button>
|
||||
<ToastProvider :queue="queue" to="body" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -62,7 +62,7 @@ function show(v: (typeof variants)[number]["key"]) {
|
||||
actionProps: {
|
||||
label: item.action,
|
||||
variant:
|
||||
v === "danger" ? "danger" : v === "default" ? "tertiary" : "secondary",
|
||||
v === "danger" ? "danger" : v === "default" ? "tertiary" : undefined,
|
||||
class:
|
||||
v === "success"
|
||||
? "bg-success text-success-foreground"
|
||||
@@ -75,29 +75,31 @@ function show(v: (typeof variants)[number]["key"]) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<Button
|
||||
v-for="v in variants"
|
||||
:key="v.key"
|
||||
size="sm"
|
||||
:variant="
|
||||
v.key === 'danger'
|
||||
? 'danger-soft'
|
||||
: v.key === 'accent'
|
||||
? 'secondary'
|
||||
: 'tertiary'
|
||||
"
|
||||
:class="
|
||||
v.key === 'success'
|
||||
? 'text-success'
|
||||
: v.key === 'warning'
|
||||
? 'text-warning'
|
||||
: undefined
|
||||
"
|
||||
@click="show(v.key)"
|
||||
>
|
||||
{{ v.label }}
|
||||
</Button>
|
||||
<ToastProvider :queue="queue" to="body" />
|
||||
<div class="flex h-full max-w-xl flex-col items-center justify-center">
|
||||
<div class="flex w-full flex-wrap items-center justify-center gap-4">
|
||||
<Button
|
||||
v-for="v in variants"
|
||||
:key="v.key"
|
||||
size="sm"
|
||||
:variant="
|
||||
v.key === 'danger'
|
||||
? 'danger-soft'
|
||||
: v.key === 'accent'
|
||||
? 'secondary'
|
||||
: 'tertiary'
|
||||
"
|
||||
:class="
|
||||
v.key === 'success'
|
||||
? 'text-success'
|
||||
: v.key === 'warning'
|
||||
? 'text-warning'
|
||||
: undefined
|
||||
"
|
||||
@click="show(v.key)"
|
||||
>
|
||||
{{ v.label }}
|
||||
</Button>
|
||||
<ToastProvider :queue="queue" to="body" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user