feat: migrate Slider with native range semantics and strict ESM declarations

This commit is contained in:
maoyingjie
2026-10-23 13:12:26 +08:00
parent b1cb00deba
commit 4da45b109e
40 changed files with 2239 additions and 3 deletions
@@ -0,0 +1,34 @@
<script lang="ts">
import type { SlotsType, VNode as SlotVNode } from "vue";
import { defineComponent, h } from "vue";
import { useSlider } from "./context";
export default defineComponent({
name: "SliderOutput",
inheritAttrs: false,
slots: Object as SlotsType<{
default?: (state: {
values: number[];
getThumbValueLabel: (index: number) => string;
}) => SlotVNode[];
}>,
props: { as: { type: String, default: "output" } },
setup(props, { attrs, slots }) {
const slider = useSlider();
return () =>
h(
props.as,
{
...attrs,
class: [slider.styles.output(), attrs.class],
"data-slot": "slider-output",
"aria-live": attrs["aria-live"] ?? "off",
},
slots.default?.({
values: [...slider.values.value],
getThumbValueLabel: (index: number) =>
slider.format(slider.values.value[index]),
}) ?? slider.values.value.map(slider.format).join(" – "),
);
},
});
</script>