feat: align public Root aliases and rework progress-bar custom-value demo
- 包根补齐固定上游 82 对 Xxx/XxxRoot 同对象别名(55 个缺失 Root 别名 + Dropdown 反向别名)与 59 个 RootProps/Menu/Dropdown 类型别名;不杜撰上游没有的名称(如 CheckboxGroupRoot、ToastRootProps) - tests/package 新增 api-root-aliases 契约:完整别名清单、82 对身份等价断言与 strict NodeNext/bundler 类型正反例 - progress-bar custom-value 演示回填公共 NumberField/Select,保持固定源文案/布局/范围/四格式与边界处理 - 修复 NumberFieldInput keydown 无条件 restore 还原同任务键入字符的缺陷,并入 number-field 回归 - 文档导航 dropdown 归位固定 meta.json 顺序并补顺序断言;修正“原生临时控件”陈述
This commit is contained in:
@@ -2,10 +2,23 @@
|
||||
import { computed, ref } from "vue";
|
||||
import {
|
||||
Label,
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
NumberField,
|
||||
NumberFieldDecrementButton,
|
||||
NumberFieldGroup,
|
||||
NumberFieldIncrementButton,
|
||||
NumberFieldInput,
|
||||
ProgressBar,
|
||||
ProgressBarFill,
|
||||
ProgressBarOutput,
|
||||
ProgressBarTrack,
|
||||
Select,
|
||||
SelectIndicator,
|
||||
SelectPopover,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
Separator,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
@@ -30,22 +43,27 @@ const formatOptionsMap: Record<string, Intl.NumberFormatOptions> = {
|
||||
|
||||
const formatOptions = computed(() => formatOptionsMap[format.value]);
|
||||
|
||||
function onValueChange(event: Event) {
|
||||
const next = Number((event.target as HTMLInputElement).value);
|
||||
function onValueChange(next: number | null) {
|
||||
// 清空或无效草稿不接受,受控字段恢复上一个接受值。
|
||||
if (next == null || !Number.isFinite(next)) return;
|
||||
value.value = Math.min(Math.max(next, minValue.value), maxValue.value);
|
||||
}
|
||||
|
||||
function onMinChange(event: Event) {
|
||||
const next = Number((event.target as HTMLInputElement).value);
|
||||
function onMinChange(next: number | null) {
|
||||
if (next == null || !Number.isFinite(next)) return;
|
||||
minValue.value = Math.min(next, maxValue.value - 1);
|
||||
if (value.value < minValue.value) value.value = minValue.value;
|
||||
}
|
||||
|
||||
function onMaxChange(event: Event) {
|
||||
const next = Number((event.target as HTMLInputElement).value);
|
||||
function onMaxChange(next: number | null) {
|
||||
if (next == null || !Number.isFinite(next)) return;
|
||||
maxValue.value = Math.max(next, minValue.value + 1);
|
||||
if (value.value > maxValue.value) value.value = maxValue.value;
|
||||
}
|
||||
|
||||
function onFormatChange(next: string | number | (string | number)[] | null) {
|
||||
if (typeof next === "string" && next in formatOptionsMap) format.value = next;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -73,53 +91,75 @@ function onMaxChange(event: Event) {
|
||||
<div class="flex max-w-52 flex-col gap-3">
|
||||
<Label class="text-xs font-medium text-muted">选项</Label>
|
||||
|
||||
<Label for="pb-cv-value">值</Label>
|
||||
<input
|
||||
id="pb-cv-value"
|
||||
class="hv-input hv-input--secondary hv-input--full-width"
|
||||
type="number"
|
||||
:min="minValue"
|
||||
:max="maxValue"
|
||||
:value="value"
|
||||
@change="onValueChange"
|
||||
/>
|
||||
|
||||
<Label for="pb-cv-min">最小值</Label>
|
||||
<input
|
||||
id="pb-cv-min"
|
||||
class="hv-input hv-input--secondary hv-input--full-width"
|
||||
type="number"
|
||||
min="0"
|
||||
:max="maxValue - 1"
|
||||
:value="minValue"
|
||||
@change="onMinChange"
|
||||
/>
|
||||
|
||||
<Label for="pb-cv-max">最大值</Label>
|
||||
<input
|
||||
id="pb-cv-max"
|
||||
class="hv-input hv-input--secondary hv-input--full-width"
|
||||
type="number"
|
||||
:min="minValue + 1"
|
||||
max="2000"
|
||||
:value="maxValue"
|
||||
@change="onMaxChange"
|
||||
/>
|
||||
|
||||
<Label for="pb-cv-format">格式</Label>
|
||||
<select
|
||||
id="pb-cv-format"
|
||||
v-model="format"
|
||||
class="hv-input hv-input--secondary hv-input--full-width"
|
||||
<NumberField
|
||||
:max-value="maxValue"
|
||||
:min-value="minValue"
|
||||
:model-value="value"
|
||||
variant="secondary"
|
||||
@update:model-value="onValueChange"
|
||||
>
|
||||
<option
|
||||
v-for="option in formatStyleOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</option>
|
||||
</select>
|
||||
<Label>值</Label>
|
||||
<NumberFieldGroup>
|
||||
<NumberFieldDecrementButton />
|
||||
<NumberFieldInput />
|
||||
<NumberFieldIncrementButton />
|
||||
</NumberFieldGroup>
|
||||
</NumberField>
|
||||
|
||||
<NumberField
|
||||
:max-value="maxValue - 1"
|
||||
:min-value="0"
|
||||
:model-value="minValue"
|
||||
variant="secondary"
|
||||
@update:model-value="onMinChange"
|
||||
>
|
||||
<Label>最小值</Label>
|
||||
<NumberFieldGroup>
|
||||
<NumberFieldDecrementButton />
|
||||
<NumberFieldInput />
|
||||
<NumberFieldIncrementButton />
|
||||
</NumberFieldGroup>
|
||||
</NumberField>
|
||||
|
||||
<NumberField
|
||||
:max-value="2000"
|
||||
:min-value="minValue + 1"
|
||||
:model-value="maxValue"
|
||||
variant="secondary"
|
||||
@update:model-value="onMaxChange"
|
||||
>
|
||||
<Label>最大值</Label>
|
||||
<NumberFieldGroup>
|
||||
<NumberFieldDecrementButton />
|
||||
<NumberFieldInput />
|
||||
<NumberFieldIncrementButton />
|
||||
</NumberFieldGroup>
|
||||
</NumberField>
|
||||
|
||||
<Select
|
||||
:model-value="format"
|
||||
variant="secondary"
|
||||
@update:model-value="onFormatChange"
|
||||
>
|
||||
<Label>格式</Label>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
<SelectIndicator />
|
||||
</SelectTrigger>
|
||||
<SelectPopover>
|
||||
<ListBox>
|
||||
<ListBoxItem
|
||||
v-for="option in formatStyleOptions"
|
||||
:id="option.value"
|
||||
:key="option.value"
|
||||
:text-value="option.label"
|
||||
>
|
||||
{{ option.label }}
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</SelectPopover>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user