UNPKG

@wordpress/global-styles-ui

Version:
101 lines • 4.39 kB
import type { GlobalStylesConfig, GlobalStylesSettings } from '@wordpress/global-styles-engine'; /** * State definition with value and label. */ export interface StateDefinition { value: string; label: string; } /** * Valid states for elements with their labels. * This mirrors the PHP constant in lib/class-wp-theme-json-gutenberg.php */ export declare const VALID_ELEMENT_STATES: Record<string, StateDefinition[]>; /** * Valid states for blocks with their labels. * This mirrors the PHP constant in lib/class-wp-theme-json-gutenberg.php */ export declare const VALID_BLOCK_STATES: Record<string, StateDefinition[]>; /** * Responsive breakpoint states available for all blocks. * These map to CSS media queries wrapping the block's styles. */ export declare const RESPONSIVE_STATES: StateDefinition[]; /** * Get the valid pseudo states for a given block or element. * * @param name The block name (e.g., 'core/button') or element name (e.g., 'button') * @return Array of valid pseudo state definitions, or empty array if none */ export declare function getValidPseudoStates(name: string): StateDefinition[]; /** * Get the valid viewport state definitions. * * @param viewportSettings * @return Array of valid viewport state definitions. */ export declare function getValidViewportStates(viewportSettings?: GlobalStylesSettings['viewport']): StateDefinition[]; /** * Removes all instances of properties from an object. * * @param object The object to remove the properties from. * @param properties The properties to remove. * @return The modified object. */ export declare function removePropertiesFromObject(object: any, properties: string[]): any; /** * Returns a new object, with properties specified in `properties` array., * maintain the original object tree structure. * The function is recursive, so it will perform a deep search for the given properties. * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the properties are `[ 'test' ]`. * * @param object The object to filter * @param properties The properties to filter by * @return The merged object. */ export declare const filterObjectByProperties: (object: any, properties: string[]) => any; /** * Compares a style variation to the same variation filtered by the specified properties. * Returns true if the variation contains only the properties specified. * * @param variation The variation to compare. * @param properties The properties to compare. * @return Whether the variation contains only the specified properties. */ export declare function isVariationWithProperties(variation: GlobalStylesConfig, properties: string[]): boolean; /** * Extracts font families from a theme JSON configuration. * * @param themeJson The theme JSON configuration * @return Array containing [bodyFontFamily, headingFontFamily] */ export declare function getFontFamilies(themeJson: any): [any, any]; /** * Iterates through the presets array and searches for slugs that start with the specified * slugPrefix followed by a numerical suffix. It identifies the highest numerical suffix found * and returns one greater than the highest found suffix, ensuring that the new index is unique. * * @param presets The array of preset objects, each potentially containing a slug property. * @param slugPrefix The prefix to look for in the preset slugs. * * @return The next available index for a preset with the specified slug prefix, or 1 if no matching slugs are found. */ /** * Gets the variation class name for a block style variation. * * @param variation The variation name. * @return The variation class name. */ export declare function getVariationClassName(variation: string): string; export declare function getNewIndexFromPresets(presets: any[], slugPrefix: string): number; /** * The block types an element paints whose own Global Styles beat the element * for at least one property it sets. Block style variations are not counted. * * @param config Merged Global Styles config. * @param element Element key, e.g. `heading`, `h2` or `button`. * @param blockNames Block types that paint the element. * @return Block names, in the given order. */ export declare function getOverridingBlockTypes(config: GlobalStylesConfig | undefined, element: string, blockNames: string[]): string[]; //# sourceMappingURL=utils.d.ts.map