UNPKG

1.54 kBJavaScriptView Raw
1import * as React from 'react';
2import PropTypes from 'prop-types';
3import clsx from 'clsx';
4import sliderUnstyledClasses from './sliderUnstyledClasses';
5import { jsx as _jsx } from "react/jsx-runtime";
6import { jsxs as _jsxs } from "react/jsx-runtime";
7
8const useValueLabelClasses = props => {
9 const {
10 open
11 } = props;
12 const utilityClasses = {
13 offset: clsx(open && sliderUnstyledClasses.valueLabelOpen),
14 circle: sliderUnstyledClasses.valueLabelCircle,
15 label: sliderUnstyledClasses.valueLabelLabel
16 };
17 return utilityClasses;
18};
19/**
20 * @ignore - internal component.
21 */
22
23
24function SliderValueLabelUnstyled(props) {
25 const {
26 children,
27 className,
28 value,
29 theme
30 } = props;
31 const classes = useValueLabelClasses(props);
32 return /*#__PURE__*/React.cloneElement(children, {
33 className: clsx(children.props.className)
34 }, /*#__PURE__*/_jsxs(React.Fragment, {
35 children: [children.props.children, /*#__PURE__*/_jsx("span", {
36 className: clsx(classes.offset, className),
37 theme: theme,
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}
49
50process.env.NODE_ENV !== "production" ? SliderValueLabelUnstyled.propTypes = {
51 children: PropTypes.element.isRequired,
52 className: PropTypes.string,
53 theme: PropTypes.any,
54 value: PropTypes.node
55} : void 0;
56export default SliderValueLabelUnstyled;
\No newline at end of file