@wordpress/components
Version:
UI components for WordPress.
119 lines • 4.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").TranslatableText<"All sides">;
top: import("@wordpress/i18n").TranslatableText<"Top side">;
bottom: import("@wordpress/i18n").TranslatableText<"Bottom side">;
left: import("@wordpress/i18n").TranslatableText<"Left side">;
right: import("@wordpress/i18n").TranslatableText<"Right side">;
vertical: import("@wordpress/i18n").TranslatableText<"Top and bottom sides">;
horizontal: import("@wordpress/i18n").TranslatableText<"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;
/**
* Get initial selected side, factoring in whether the sides are linked,
* and whether the vertical / horizontal directions are grouped via splitOnAxis.
*
* @param isLinked Whether the box control's fields are linked.
* @param splitOnAxis Whether splitting by horizontal or vertical axis.
* @return The initial side.
*/
export declare function getInitialSide(isLinked: boolean, splitOnAxis: boolean): "top" | "all" | "vertical";
/**
* 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']): readonly ["top", "right", "bottom", "left"] | (keyof BoxControlValue)[];
/**
* Applies a value to an object representing top, right, bottom and left sides
* while taking into account any custom side configuration.
*
* @deprecated
*
* @param currentValues The current values for each side.
* @param newValue The value to apply to the sides object.
* @param sides Array defining valid sides.
*
* @return Object containing the updated values for each side.
*/
export declare function applyValueToSides(currentValues: BoxControlValue, newValue?: string, sides?: BoxControlProps['sides']): BoxControlValue;
/**
* 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