UNPKG

@renderlesskit/react

Version:

Collection of headless components/hooks that are accessible, composable, customizable from low level to build your own UI & Design System powered by Reakit

39 lines (35 loc) 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useProgressState = useProgressState; var _utils = require("../utils"); /** * All credit goes to [Segun Adebayo](https://github.com/segunadebayo) for * creating an Awesome Library [Chakra UI](https://github.com/chakra-ui/chakra-ui/) * We improved the Progress Component [Progress](https://github.com/chakra-ui/chakra-ui/tree/develop/packages/progress) * to work with Reakit System */ function useProgressState() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var _props$value = props.value, value = _props$value === void 0 ? 0 : _props$value, _props$min = props.min, min = _props$min === void 0 ? 0 : _props$min, _props$max = props.max, max = _props$max === void 0 ? 100 : _props$max; var clampedValue = clampValue(value, min, max); var percent = (0, _utils.isNull)(clampedValue) ? null : (0, _utils.valueToPercent)(clampedValue, min, max); return { value: clampedValue, min: min, max: max, isIndeterminate: (0, _utils.isNull)(clampedValue), percent: percent }; } function clampValue(value, min, max) { if ((0, _utils.isNull)(value)) return null; return Math.min(Math.max(value, min), max); } //# sourceMappingURL=ProgressState.js.map