@wordpress/components
Version:
UI components for WordPress.
97 lines • 3.95 kB
TypeScript
/**
* Internal dependencies
*/
import type { BoxControlInputControlProps, BoxControlProps, BoxControlValue, CustomValueUnits, Preset } from './types';
export declare const CUSTOM_VALUE_SETTINGS: CustomValueUnits;
export declare const LABELS: {
all: import("@wordpress/i18n").TransformedText<"All sides">;
top: import("@wordpress/i18n").TransformedText<"Top side">;
bottom: import("@wordpress/i18n").TransformedText<"Bottom side">;
left: import("@wordpress/i18n").TransformedText<"Left side">;
right: import("@wordpress/i18n").TransformedText<"Right side">;
vertical: import("@wordpress/i18n").TransformedText<"Top and bottom sides">;
horizontal: import("@wordpress/i18n").TransformedText<"Left and right sides">;
};
export declare const DEFAULT_VALUES: {
top: undefined;
right: undefined;
bottom: undefined;
left: undefined;
};
export declare const ALL_SIDES: readonly ['top', 'right', 'bottom', 'left'];
/**
* Gets the merged input value and unit from values data.
*
* @param values Box values.
* @param availableSides Available box sides to evaluate.
*
* @return A value + unit for the 'all' input.
*/
export declare function getMergedValue(values?: BoxControlValue, availableSides?: BoxControlProps['sides']): string | undefined;
/**
* Checks if the values are mixed.
*
* @param values Box values.
* @param availableSides Available box sides to evaluate.
* @return Whether the values are mixed.
*/
export declare function isValueMixed(values?: BoxControlValue, availableSides?: BoxControlProps['sides']): boolean;
/**
* Determine the most common unit selection to use as a fallback option.
*
* @param selectedUnits Current unit selections for individual sides.
* @return Most common unit selection.
*/
export declare function getAllUnitFallback(selectedUnits?: BoxControlValue): string | undefined;
/**
* Checks to determine if values are defined.
*
* @param values Box values.
*
* @return Whether values are mixed.
*/
export declare function isValuesDefined(values?: BoxControlValue): boolean | undefined;
/**
* Normalizes provided sides configuration to an array containing only top,
* right, bottom and left. This essentially just maps `horizontal` or `vertical`
* to their appropriate sides to facilitate correctly determining value for
* all input control.
*
* @param sides Available sides for box control.
* @return Normalized sides configuration.
*/
export declare function normalizeSides(sides: BoxControlProps['sides']): (keyof BoxControlValue)[] | readonly ["top", "right", "bottom", "left"];
/**
* Return the allowed sides based on the sides configuration.
*
* @param sides Sides configuration.
* @return Allowed sides.
*/
export declare function getAllowedSides(sides: BoxControlInputControlProps['sides']): Set<keyof BoxControlValue>;
/**
* Checks if a value is a preset value.
*
* @param value The value to check.
* @param presetKey The preset key to check against.
* @return Whether the value is a preset value.
*/
export declare function isValuePreset(value: string, presetKey: string): boolean;
/**
* Returns the index of the preset value in the presets array.
*
* @param value The value to check.
* @param presetKey The preset key to check against.
* @param presets The array of presets to search.
* @return The index of the preset value in the presets array.
*/
export declare function getPresetIndexFromValue(value: string, presetKey: string, presets: Preset[]): number | undefined;
/**
* Returns the preset value from the index.
*
* @param index The index of the preset value in the presets array.
* @param presetKey The preset key to check against.
* @param presets The array of presets to search.
* @return The preset value from the index.
*/
export declare function getPresetValueFromIndex(index: number, presetKey: string, presets: Preset[]): string;
//# sourceMappingURL=utils.d.ts.map