@wordpress/global-styles-ui
Version:
Global Styles UI components for WordPress.
127 lines • 7.34 kB
TypeScript
import type { GlobalStylesConfig, StyleVariation } from '@wordpress/global-styles-engine';
/**
* Hook to get and set style values with memoization.
*
* @param path The path to the style value.
* @param blockName The name of the block, if applicable.
* @param readFrom Which source to read from: "base" (theme), "user" (customizations), or "merged" (final result). Defaults to "merged".
* @param shouldDecodeEncode Whether to decode and encode the style value.
* @param state Optional style state path. Supports viewport states (e.g. `@mobile`),
* pseudo-selector states (e.g. `:hover`) or both (e.g. `@mobile.:hover`).
* Pseudo selectors are always read/written as nested keys.
* @return An array containing the style value and a function to set the style
* value.
*
* @example
* const [ color, setColor ] = useStyle<string>( 'color.text', 'core/button', 'merged' );
* const [ hoverColor, setHoverColor ] = useStyle<string>( 'color.text', 'core/button', 'user', true, ':hover' );
*/
export declare function useStyle<T = any>(path: string, blockName?: string, readFrom?: 'base' | 'user' | 'merged', shouldDecodeEncode?: boolean, state?: string): readonly [T | undefined, (newValue: T | undefined) => void];
/**
* Hook to get and set setting values with memoization.
*
* @param path The path to the setting value.
* @param blockName The name of the block, if applicable.
* @param readFrom Which source to read from: "base" (theme), "user" (customizations), or "merged" (final result). Defaults to "merged".
* @return An array containing the setting value and a function to set the
* setting value.
*
* @example
* const [ fontSize, setFontSize ] = useSetting<string>( 'fontSize', 'core/button', 'merged' );
*/
export declare function useSetting<T = any>(path: string, blockName?: string, readFrom?: 'base' | 'user' | 'merged'): readonly [T, (newValue: T | undefined) => void];
/**
* Fetches the current theme style variations that contain only the specified properties
* and merges them with the user config.
* @param properties
*/
export declare function useCurrentMergeThemeStyleVariationsWithUserConfig(properties?: string[]): StyleVariation[];
/**
* Hook to get color variations using the full Gutenberg implementation.
*/
export declare function useColorVariations(): StyleVariation[];
/**
* Resolves `ref` pointers and theme-relative (`file:./…`) URLs in a style
* object's `background` sub-tree, for display. The Global Styles screens
* render inside the package's own public `BlockEditorProvider`, which strips
* the Symbol-keyed settings the background panel would otherwise resolve
* these against, so the screens resolve them before passing styles down.
*
* @param style A style object whose `background` values may contain `ref`
* pointers or theme-relative URLs.
* @return The style object with its `background` values resolved.
*/
export declare function useStyleWithResolvedBackground(style: GlobalStylesConfig['styles']): import("@wordpress/global-styles-engine").GlobalStylesStyles | {
color?: {
background?: import("@wordpress/global-styles-engine").UnresolvedValue;
text?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
typography?: {
fontFamily?: import("@wordpress/global-styles-engine").UnresolvedValue;
fontSize?: import("@wordpress/global-styles-engine").UnresolvedValue;
fontWeight?: import("@wordpress/global-styles-engine").UnresolvedValue;
lineHeight?: import("@wordpress/global-styles-engine").UnresolvedValue;
letterSpacing?: import("@wordpress/global-styles-engine").UnresolvedValue;
textTransform?: import("@wordpress/global-styles-engine").UnresolvedValue;
textIndent?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
spacing?: {
padding?: import("@wordpress/global-styles-engine").UnresolvedValue | Record<string, import("@wordpress/global-styles-engine").UnresolvedValue>;
margin?: import("@wordpress/global-styles-engine").UnresolvedValue | Record<string, import("@wordpress/global-styles-engine").UnresolvedValue>;
blockGap?: string | {
top: string;
left: string;
};
};
border?: {
color?: import("@wordpress/global-styles-engine").UnresolvedValue;
width?: import("@wordpress/global-styles-engine").UnresolvedValue;
style?: import("@wordpress/global-styles-engine").UnresolvedValue;
radius?: import("@wordpress/global-styles-engine").UnresolvedValue | {
topLeft?: import("@wordpress/global-styles-engine").UnresolvedValue;
topRight?: import("@wordpress/global-styles-engine").UnresolvedValue;
bottomRight?: import("@wordpress/global-styles-engine").UnresolvedValue;
bottomLeft?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
top?: {
color?: import("@wordpress/global-styles-engine").UnresolvedValue;
width?: import("@wordpress/global-styles-engine").UnresolvedValue;
style?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
right?: {
color?: import("@wordpress/global-styles-engine").UnresolvedValue;
width?: import("@wordpress/global-styles-engine").UnresolvedValue;
style?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
bottom?: {
color?: import("@wordpress/global-styles-engine").UnresolvedValue;
width?: import("@wordpress/global-styles-engine").UnresolvedValue;
style?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
left?: {
color?: import("@wordpress/global-styles-engine").UnresolvedValue;
width?: import("@wordpress/global-styles-engine").UnresolvedValue;
style?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
};
filter?: {
duotone?: import("@wordpress/global-styles-engine").UnresolvedValue;
opacity?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
dimensions?: {
width?: import("@wordpress/global-styles-engine").UnresolvedValue;
height?: import("@wordpress/global-styles-engine").UnresolvedValue;
minWidth?: import("@wordpress/global-styles-engine").UnresolvedValue;
minHeight?: import("@wordpress/global-styles-engine").UnresolvedValue;
maxWidth?: import("@wordpress/global-styles-engine").UnresolvedValue;
maxHeight?: import("@wordpress/global-styles-engine").UnresolvedValue;
};
elements?: Record<string, Omit<import("@wordpress/global-styles-engine").GlobalStylesStyles, 'blocks' | 'elements' | 'variations'> & {
':hover'?: Omit<import("@wordpress/global-styles-engine").GlobalStylesStyles, 'blocks' | 'elements' | 'variations'>;
}>;
blocks?: Record<string, Omit<import("@wordpress/global-styles-engine").GlobalStylesStyles, 'blocks'>>;
variations?: Record<string, Omit<import("@wordpress/global-styles-engine").GlobalStylesStyles, 'blocks'>>;
css?: string;
background: Record<string, any>;
} | undefined;
//# sourceMappingURL=hooks.d.ts.map