@base-ui-components/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
44 lines (43 loc) • 1.62 kB
JavaScript
;
'use client';
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ProgressValue = void 0;
var React = _interopRequireWildcard(require("react"));
var _useRenderElement = require("../../utils/useRenderElement");
var _ProgressRootContext = require("../root/ProgressRootContext");
var _stateAttributesMapping = require("../root/stateAttributesMapping");
/**
* A text label displaying the current value.
* Renders a `<span>` element.
*
* Documentation: [Base UI Progress](https://base-ui.com/react/components/progress)
*/
const ProgressValue = exports.ProgressValue = /*#__PURE__*/React.forwardRef(function ProgressValue(componentProps, forwardedRef) {
const {
className,
render,
children,
...elementProps
} = componentProps;
const {
value,
formattedValue,
state
} = (0, _ProgressRootContext.useProgressRootContext)();
const formattedValueArg = value == null ? 'indeterminate' : formattedValue;
const formattedValueDisplay = value == null ? null : formattedValue;
const element = (0, _useRenderElement.useRenderElement)('span', componentProps, {
state,
ref: forwardedRef,
props: [{
'aria-hidden': true,
children: typeof children === 'function' ? children(formattedValueArg, value) : formattedValueDisplay
}, elementProps],
stateAttributesMapping: _stateAttributesMapping.progressStateAttributesMapping
});
return element;
});
if (process.env.NODE_ENV !== "production") ProgressValue.displayName = "ProgressValue";