mirror of
https://github.com/zoriya/v10.git
synced 2026-08-11 16:40:27 +00:00
30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
"use client";
|
|
import { renderElement } from "../../utils/use-render.js";
|
|
import { useSliderContext } from "./context.js";
|
|
import { forwardRef } from "react";
|
|
//#region src/ui/slider/slider-value.tsx
|
|
/** Displays a formatted text representation of the slider value. Renders an `<output>` element. */
|
|
const SliderValue = forwardRef(function SliderValue(componentProps, forwardedRef) {
|
|
const { render, className, style, type = "current", format, ...elementProps } = componentProps;
|
|
const context = useSliderContext();
|
|
const { state, pointerValue, formatValue } = context;
|
|
const rawValue = type === "pointer" ? pointerValue : state.value;
|
|
const text = format ? format(rawValue) : formatValue ? formatValue(rawValue, type) : String(Math.round(rawValue));
|
|
return renderElement("output", {
|
|
render,
|
|
className,
|
|
style
|
|
}, {
|
|
state,
|
|
stateAttrMap: context.stateAttrMap,
|
|
ref: forwardedRef,
|
|
props: [{
|
|
"aria-live": "off",
|
|
children: text
|
|
}, elementProps]
|
|
});
|
|
});
|
|
//#endregion
|
|
export { SliderValue };
|
|
|
|
//# sourceMappingURL=slider-value.js.map
|