@adaptui/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
38 lines (37 loc) • 1.43 kB
TypeScript
/**
* Handle Inequalities with received values
*
* minimum ≤ value ≤ maximum
* minimum ≤ low ≤ maximum (if low is specified)
* minimum ≤ high ≤ maximum (if high is specified)
* minimum ≤ optimum ≤ maximum (if optimum is specified)
*
* @see https://html.spec.whatwg.org/multipage/form-elements.html#the-meter-element:attr-meter-max-3:~:text=following%20inequalities%20must%20hold
*/
declare type CalculateStatusProps = {
value: number;
optimum: number;
min: number;
max: number;
low: number;
high: number;
};
export declare const calculateStatus: (props: CalculateStatusProps) => "safe" | "caution" | "danger";
export declare const isInRange: (value: number, min: number, max: number) => boolean;
export declare function clamp(value: number, min: number, max: number): number;
/**
* Convert a value to percentage based on lower and upper bound values
*
* @param value the value in number
* @param min the minimum value
* @param max the maximum value
*/
export declare function valueToPercent(value: number, min: number, max: number): number;
/**
* The candidate optimum point is the midpoint between the minimum value and
* the maximum value.
*
* @see https://html.spec.whatwg.org/multipage/form-elements.html#the-meter-element:attr-meter-high-8:~:text=boundary.-,The%20optimum%20point
*/
export declare function getOptimumValue(min: number, max: number): number;
export {};