feat: establish shared color channel and text input protocols

This commit is contained in:
maoyingjie
2026-10-25 14:20:12 +08:00
parent 6b8501456d
commit a042f5c44c
19 changed files with 1389 additions and 3 deletions
@@ -0,0 +1,144 @@
<script setup lang="ts">
import { shallowRef } from "vue";
import Picker from "../../../packages/vue/tests/fixtures/ColorPickerFoundation.vue";
import Area from "../../../packages/vue/tests/fixtures/ColorAreaFoundation.vue";
import Input from "../../../packages/vue/tests/fixtures/ColorInputFoundation.vue";
import { Button } from "@heroui-vue/components";
const changes = shallowRef(0),
ends = shallowRef(0),
rejected = shallowRef(0);
</script>
<template>
<main class="color-input-lab">
<h1>颜色输入协议 · 私有基建</h1>
<p>
原生滑条用于验证事务和接受值;正式 ColorSlider 的轨道、Thumb
和视觉仍待接入。
</p>
<div class="color-input-grid">
<section id="shared-input">
<h2>共享颜色 / 保留灰色色相</h2>
<form>
<Picker
default-value="hsb(270,0%,50%,.125)"
v-slot="{ value }"
@change="changes++"
@change-end="ends++"
>
<Area aria-label="Shared area" />
<label>
色相
<Input mode="range" channel="hue" aria-label="Hue" />
</label>
<label>
透明度(de-DE)
<Input
channel="alpha"
name="alpha"
locale="de-DE"
aria-label="Alpha"
/>
</label>
<label>
Hex
<Input name="hex" aria-label="Hex" />
</label>
<output>{{ value?.toString("hsba") }}</output>
</Picker>
<output>change {{ changes }} / changeEnd {{ ends }}</output>
<Button type="reset" variant="secondary">重置</Button>
</form>
</section>
<section id="rejected-input">
<h2>受控拒绝 / 相同提案可重试</h2>
<Picker
model-value="hsb(270,0%,50%,.125)"
v-slot="{ value }"
@change="rejected++"
>
<label>
色相
<Input mode="range" channel="hue" aria-label="Rejected hue" />
</label>
<label>
透明度
<Input channel="alpha" aria-label="Rejected alpha" />
</label>
<label>
Hex
<Input aria-label="Rejected hex" />
</label>
<output>{{ value?.toString("hsba") }}</output>
</Picker>
<output>提案 {{ rejected }}</output>
</section>
<section id="validated-input">
<h2>原生表单 / 必填 / 重置</h2>
<form @submit.prevent>
<Input name="color" aria-label="Required color" is-required />
<div class="color-input-actions">
<Button type="submit">校验</Button>
<Button type="reset" variant="secondary">重置</Button>
</div>
</form>
</section>
</div>
</main>
</template>
<style>
.color-input-lab {
padding: 32px;
min-height: 100vh;
background: var(--background);
color: var(--foreground);
font-family: Inter, sans-serif;
}
.color-input-lab h1 {
font-size: 24px;
font-weight: 600;
margin-bottom: 8px;
}
.color-input-lab p {
color: var(--muted);
margin-bottom: 24px;
}
.color-input-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 24px;
}
.color-input-grid section {
padding: 24px;
border: 1px solid var(--border);
border-radius: 20px;
}
.color-input-grid h2 {
font-size: 16px;
font-weight: 600;
margin-bottom: 16px;
}
.color-input-grid label,
.color-input-grid output {
display: block;
margin: 12px 0;
}
.color-input-grid input[type="text"] {
width: 100%;
padding: 8px 12px;
background: var(--field-background);
border: 1px solid var(--border);
border-radius: 12px;
}
.color-input-grid input[type="range"] {
width: 100%;
accent-color: var(--accent);
}
.color-input-grid [data-field-error] {
color: var(--danger);
}
.color-input-actions {
display: flex;
gap: 12px;
margin-top: 16px;
}
</style>