feat: add Fieldset and SearchField infrastructure
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
FieldGroup,
|
||||
Fieldset,
|
||||
FieldsetActions,
|
||||
FieldsetLegend,
|
||||
Form,
|
||||
Input,
|
||||
Label,
|
||||
Link,
|
||||
Switch,
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
const disabled = ref(true);
|
||||
const result = ref("");
|
||||
const buttonLabel = computed(() =>
|
||||
disabled.value ? "启用字段组" : "禁用字段组",
|
||||
);
|
||||
function submit(event: Event) {
|
||||
result.value = JSON.stringify(
|
||||
Object.fromEntries(new FormData(event.currentTarget as HTMLFormElement)),
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex w-full max-w-96 flex-col gap-4">
|
||||
<Button variant="secondary" @click="disabled = !disabled">
|
||||
{{ buttonLabel }}
|
||||
</Button>
|
||||
<Form @submit.prevent="submit">
|
||||
<Fieldset :disabled="disabled">
|
||||
<FieldsetLegend>
|
||||
禁用继承验证
|
||||
<Label for="legend-action">可用的 Legend 标签</Label>
|
||||
<Button
|
||||
id="legend-action"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
@click="result = 'Legend 操作可用'"
|
||||
>
|
||||
Legend 操作
|
||||
</Button>
|
||||
</FieldsetLegend>
|
||||
<FieldGroup>
|
||||
<TextField name="name" default-value="Jane">
|
||||
<Label>姓名</Label>
|
||||
<Input />
|
||||
</TextField>
|
||||
<Switch name="notifications" default-checked aria-label="接收通知" />
|
||||
<Link
|
||||
href="#disabled-inheritance"
|
||||
@click.prevent="result = '链接操作可用'"
|
||||
>
|
||||
链接操作
|
||||
</Link>
|
||||
<Fieldset>
|
||||
<FieldsetLegend>嵌套字段组</FieldsetLegend>
|
||||
<Input name="nested" default-value="nested" aria-label="嵌套字段" />
|
||||
</Fieldset>
|
||||
</FieldGroup>
|
||||
<FieldsetActions>
|
||||
<Button type="submit">提交字段组</Button>
|
||||
<Button type="reset" variant="secondary">重置</Button>
|
||||
</FieldsetActions>
|
||||
</Fieldset>
|
||||
<Button type="submit" variant="tertiary" class="mt-4">
|
||||
在组外查看提交值
|
||||
</Button>
|
||||
</Form>
|
||||
<p role="status" aria-label="字段组结果" class="text-sm text-muted">
|
||||
{{ result }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user