@cimpress/react-components
Version:
React components to support the MCP styleguide
58 lines • 2.17 kB
TypeScript
import React from 'react';
import { PublicComponentProps } from './types';
/**
* Determines the number of digits after the decimal place. Returns 0 if there are none.
* @param {number} num any real number
* @returns {number} - an integer denoting the number of decimal digits
*/
export declare function countDecimals(num: number): number;
/**
* Rounds the given number to the closest increment. The increment can be any real number.
* @param {number} num any real number
* @param {number} inc any real number
* @returns {number} - num rounded to the closest increment.
*/
export declare function roundToIncrement(num: number, inc: number): number;
/**
* Set the number a string, truncate to the given decimal point, and cut off any extraneous decimal zeroes.
* @param {number} num any real number
* @param {number} decimals any integer
* @returns {string} - num truncated to the decimals, plus any extra zeroes removed.
*/
export declare function truncate(num: number, decimals: number): string;
export interface SliderProps extends PublicComponentProps {
/**
* Any real number denoting the increment that the slider will select.
*/
increment?: number;
/**
* Setting this to true disables the slider, and greys it out.
*/
disabled?: boolean;
/**
* The label displayed above the slider.
*/
label: string;
/**
* The minimum value that the slider can select (on the left).
*/
min?: number;
/**
* The maximum value that the slider can select (on the right).
*/
max?: number;
/**
* Once a value is selected, this callback function will receive the selected number as an argument.
*/
onSelect: (roundedNumber: number) => void;
/**
* Setting this to true calls onSelect while dragging the slider, instead of only when it is dropped.
*/
selectOnDrag?: boolean;
/**
* The current value of the slider.
*/
value: number | string;
}
export declare const Slider: ({ value, label, min, max, disabled, increment, selectOnDrag, onSelect, className, ...rest }: SliderProps) => React.JSX.Element;
//# sourceMappingURL=Slider.d.ts.map