| 1 |
import type { ChartArea, FontSpec, Point } from '../types/index.js'; |
| 2 |
import type { TRBL, TRBLCorners } from '../types/geometric.js'; |
| 3 |
/** |
| 4 |
* @alias Chart.helpers.options |
| 5 |
* @namespace |
| 6 |
*/ |
| 7 |
/** |
| 8 |
* Converts the given line height `value` in pixels for a specific font `size`. |
| 9 |
* @param value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em'). |
| 10 |
* @param size - The font size (in pixels) used to resolve relative `value`. |
| 11 |
* @returns The effective line height in pixels (size * 1.2 if value is invalid). |
| 12 |
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height |
| 13 |
* @since 2.7.0 |
| 14 |
*/ |
| 15 |
export declare function toLineHeight(value: number | string, size: number): number; |
| 16 |
/** |
| 17 |
* @param value |
| 18 |
* @param props |
| 19 |
*/ |
| 20 |
export declare function _readValueToProps<K extends string>(value: number | Record<K, number>, props: K[]): Record<K, number>; |
| 21 |
export declare function _readValueToProps<K extends string, T extends string>(value: number | Record<K & T, number>, props: Record<T, K>): Record<T, number>; |
| 22 |
/** |
| 23 |
* Converts the given value into a TRBL object. |
| 24 |
* @param value - If a number, set the value to all TRBL component, |
| 25 |
* else, if an object, use defined properties and sets undefined ones to 0. |
| 26 |
* x / y are shorthands for same value for left/right and top/bottom. |
| 27 |
* @returns The padding values (top, right, bottom, left) |
| 28 |
* @since 3.0.0 |
| 29 |
*/ |
| 30 |
export declare function toTRBL(value: number | TRBL | Point): Record<"left" | "top" | "bottom" | "right", number>; |
| 31 |
/** |
| 32 |
* Converts the given value into a TRBL corners object (similar with css border-radius). |
| 33 |
* @param value - If a number, set the value to all TRBL corner components, |
| 34 |
* else, if an object, use defined properties and sets undefined ones to 0. |
| 35 |
* @returns The TRBL corner values (topLeft, topRight, bottomLeft, bottomRight) |
| 36 |
* @since 3.0.0 |
| 37 |
*/ |
| 38 |
export declare function toTRBLCorners(value: number | TRBLCorners): Record<"topLeft" | "topRight" | "bottomLeft" | "bottomRight", number>; |
| 39 |
/** |
| 40 |
* Converts the given value into a padding object with pre-computed width/height. |
| 41 |
* @param value - If a number, set the value to all TRBL component, |
| 42 |
* else, if an object, use defined properties and sets undefined ones to 0. |
| 43 |
* x / y are shorthands for same value for left/right and top/bottom. |
| 44 |
* @returns The padding values (top, right, bottom, left, width, height) |
| 45 |
* @since 2.7.0 |
| 46 |
*/ |
| 47 |
export declare function toPadding(value?: number | TRBL): ChartArea; |
| 48 |
/** |
| 49 |
* Parses font options and returns the font object. |
| 50 |
* @param options - A object that contains font options to be parsed. |
| 51 |
* @param fallback - A object that contains fallback font options. |
| 52 |
* @return The font object. |
| 53 |
* @private |
| 54 |
*/ |
| 55 |
export declare function toFont(options: Partial<FontSpec>, fallback?: Partial<FontSpec>): { |
| 56 |
family: string; |
| 57 |
lineHeight: number; |
| 58 |
size: number; |
| 59 |
style: "normal" | "inherit" | "italic" | "oblique" | "initial"; |
| 60 |
weight: number | "bold" | "normal" | "lighter" | "bolder"; |
| 61 |
string: string; |
| 62 |
}; |
| 63 |
/** |
| 64 |
* Evaluates the given `inputs` sequentially and returns the first defined value. |
| 65 |
* @param inputs - An array of values, falling back to the last value. |
| 66 |
* @param context - If defined and the current value is a function, the value |
| 67 |
* is called with `context` as first argument and the result becomes the new input. |
| 68 |
* @param index - If defined and the current value is an array, the value |
| 69 |
* at `index` become the new input. |
| 70 |
* @param info - object to return information about resolution in |
| 71 |
* @param info.cacheable - Will be set to `false` if option is not cacheable. |
| 72 |
* @since 2.7.0 |
| 73 |
*/ |
| 74 |
export declare function resolve(inputs: Array<unknown>, context?: object, index?: number, info?: { |
| 75 |
cacheable: boolean; |
| 76 |
}): unknown; |
| 77 |
/** |
| 78 |
* @param minmax |
| 79 |
* @param grace |
| 80 |
* @param beginAtZero |
| 81 |
* @private |
| 82 |
*/ |
| 83 |
export declare function _addGrace(minmax: { |
| 84 |
min: number; |
| 85 |
max: number; |
| 86 |
}, grace: number | string, beginAtZero: boolean): { |
| 87 |
min: number; |
| 88 |
max: number; |
| 89 |
}; |
| 90 |
/** |
| 91 |
* Create a context inheriting parentContext |
| 92 |
* @param parentContext |
| 93 |
* @param context |
| 94 |
* @returns |
| 95 |
*/ |
| 96 |
export declare function createContext<T extends object>(parentContext: null, context: T): T; |
| 97 |
export declare function createContext<T extends object, P extends T>(parentContext: P, context: T): P & T; |