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

30 lines (29 loc) 969 B
/** * 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 */ import { isNull, valueToPercent } from "../utils"; export function useProgressState() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var { value = 0, min = 0, max = 100 } = props; var clampedValue = clampValue(value, min, max); var percent = isNull(clampedValue) ? null : valueToPercent(clampedValue, min, max); return { value: clampedValue, min, max, isIndeterminate: isNull(clampedValue), percent }; } function clampValue(value, min, max) { if (isNull(value)) return null; return Math.min(Math.max(value, min), max); } //# sourceMappingURL=ProgressState.js.map