UNPKG

@nexusui/components

Version:

These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.

116 lines (115 loc) 3.44 kB
import { Unit, UnitFormatterValue } from './types'; export declare const NUMBER_REGEX: RegExp; /** * @name getValidUnit * @description Check the unit is a valid unit or not * @param {string} unit * @param {Map<string, string>} unitsMap * @returns {boolean} */ export declare const getValidUnit: (unit: string, unitsMap: Map<string, string>) => false | string; /** * @name isNumber * @description Check the string is a Number (integer, float, fraction, improper fraction and their negative values) * @param value * @example 1.5 => true * 1/2 => true * 1 1/2 => true * 11 1/2 => true * 11.5 => true * -1.5 => true * -1 1/2 => true * 0.5 cm => false */ export declare const isNumber: (value: string) => boolean; /** * @description Checks if the value is a fraction * @param changedValue */ export declare const isFraction: (changedValue: string) => boolean; /** * @name isBinaryFraction * @description Check the value is a binary fraction, * the value would be any number (integer, decimal, fraction, improper fraction) * @param value * @returns {boolean} */ export declare const isBinaryFraction: (value: string) => boolean; /** * is Mixed Number which is a whole number and a binary fraction * @param value * @returns {boolean} * @example * 1.5 => true * 1 1/2 => true * 11 1/2 => true * 11.5 => true */ export declare const isMixedNumberBasedOnBinaryFraction: (value: string) => boolean; /** * @name decimalToFraction * @description Convert a decimal to a fraction * @param decimal * @returns {string} */ export declare const decimalToFraction: (decimal: number) => string; /** * @description Converts a fraction to a decimal, it supports a fraction and improper fraction and negative fraction * @param fraction * @returns {number} * @example * 1/2 => 0.5 * 1 1/2 => 1.5 * 11 1/2 => 11.5 * -1/2 => -0.5 * -1 1/2 => -1.5 */ export declare const fractionToDecimal: (fraction: string) => number; /** * @name decimalToMixedNumber * @description Convert a decimal to a fraction * @param decimal * @returns {string} * @example * 0.5 => 1/2 * 1.5 => 1 1/2 * 11.5 => 11 1/2 * 0.25 => 1/4 */ export declare const decimalToMixedNumber: (decimal: number) => string; /** * @name splitUnitValue * @description Split the unit value into value and unit */ export declare const splitUnitValue: (unitValue: string | undefined) => { value: string; unit: string; }; /** * @name handleUnitValue * @description Check the string is start with number if not return false, * If yes divide the string into number and string two parts, * the function should support a fraction and improper fraction. * @param unitValue */ export declare const handleUnitValue: (unitValue: string) => false | UnitFormatterValue; /** * @name unitDisplayStringMapGenerator * @description Generate a map of unit display string */ export declare const unitDisplayStringMapGenerator: <T>(units: Record<string, Unit<T>>) => Map<string, string>; /** * @alias handleUnitValue * @name stringToUnitValue */ export declare const stringToUnitValue: (unitValue: string) => false | UnitFormatterValue; /** * @alias isBinaryFraction * @name isBaseTwoFraction */ export declare const isBaseTwoFraction: (value: string) => boolean; /** * @alias isMixedNumberBasedOnBinaryFraction * @name isMixedNumberWithBaseTwoFraction */ export declare const isMixedNumberWithBaseTwoFraction: (value: string) => boolean;