feat: migrate Slider with native range semantics and strict ESM declarations
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Slider,
|
||||
SliderOutput,
|
||||
SliderTrack,
|
||||
SliderFill,
|
||||
SliderThumb,
|
||||
Label,
|
||||
Button,
|
||||
Fieldset,
|
||||
type SliderValue,
|
||||
} from "@heroui-vue/components";
|
||||
const disabled = ref(false),
|
||||
accepted = ref<SliderValue>([20, 80]);
|
||||
const submit = ref(""),
|
||||
changes = ref(0),
|
||||
ends = ref(0);
|
||||
function read(event: Event) {
|
||||
submit.value = JSON.stringify([
|
||||
...new FormData(event.target as HTMLFormElement).entries(),
|
||||
]);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-12 p-4">
|
||||
<form class="flex flex-col gap-6" @submit.prevent="read">
|
||||
<Fieldset :disabled="disabled">
|
||||
<Slider
|
||||
v-model="accepted"
|
||||
class="max-w-xs"
|
||||
@change="changes++"
|
||||
@change-end="ends++"
|
||||
>
|
||||
<Label>表单区间</Label>
|
||||
<SliderOutput />
|
||||
<SliderTrack>
|
||||
<SliderFill />
|
||||
<SliderThumb name="min" aria-label="下限" />
|
||||
<SliderThumb :index="1" name="max" aria-label="上限" />
|
||||
</SliderTrack>
|
||||
</Slider>
|
||||
</Fieldset>
|
||||
<div class="flex gap-2">
|
||||
<Button type="reset">重置</Button>
|
||||
<Button type="submit">读取表单</Button>
|
||||
</div>
|
||||
</form>
|
||||
<p>提交:{{ submit }};change:{{ changes }};end:{{ ends }}</p>
|
||||
<Button @click="disabled = !disabled">切换禁用</Button>
|
||||
<Slider dir="rtl" :default-value="[20, 80]" class="max-w-xs">
|
||||
<Label>RTL 区间</Label>
|
||||
<SliderOutput />
|
||||
<SliderTrack>
|
||||
<SliderFill />
|
||||
<SliderThumb aria-label="RTL 下限" />
|
||||
<SliderThumb :index="1" aria-label="RTL 上限" is-disabled />
|
||||
</SliderTrack>
|
||||
</Slider>
|
||||
<Slider :model-value="30" class="max-w-xs">
|
||||
<Label>拒绝更新</Label>
|
||||
<SliderOutput />
|
||||
<SliderTrack>
|
||||
<SliderFill />
|
||||
<SliderThumb name="rejected" />
|
||||
</SliderTrack>
|
||||
</Slider>
|
||||
<div class="h-48">
|
||||
<Slider :default-value="30" orientation="vertical" class="h-full">
|
||||
<Label>竖向</Label>
|
||||
<SliderOutput />
|
||||
<SliderTrack>
|
||||
<SliderFill />
|
||||
<SliderThumb />
|
||||
</SliderTrack>
|
||||
</Slider>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user