UNPKG

1.42 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import sliderClasses from "./sliderClasses.js";
7import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8const useValueLabelClasses = props => {
9 const {
10 open
11 } = props;
12 const utilityClasses = {
13 offset: clsx(open && sliderClasses.valueLabelOpen),
14 circle: sliderClasses.valueLabelCircle,
15 label: sliderClasses.valueLabelLabel
16 };
17 return utilityClasses;
18};
19
20/**
21 * @ignore - internal component.
22 */
23export default function SliderValueLabel(props) {
24 const {
25 children,
26 className,
27 value
28 } = props;
29 const classes = useValueLabelClasses(props);
30 if (!children) {
31 return null;
32 }
33 return /*#__PURE__*/React.cloneElement(children, {
34 className: clsx(children.props.className)
35 }, /*#__PURE__*/_jsxs(React.Fragment, {
36 children: [children.props.children, /*#__PURE__*/_jsx("span", {
37 className: clsx(classes.offset, className),
38 "aria-hidden": true,
39 children: /*#__PURE__*/_jsx("span", {
40 className: classes.circle,
41 children: /*#__PURE__*/_jsx("span", {
42 className: classes.label,
43 children: value
44 })
45 })
46 })]
47 }));
48}
49process.env.NODE_ENV !== "production" ? SliderValueLabel.propTypes = {
50 children: PropTypes.element.isRequired,
51 className: PropTypes.string,
52 value: PropTypes.node
53} : void 0;
\No newline at end of file