/**
* The WordPress components the app uses (the "wp-components" script, kept
* external in vite.config.ts), with only the props that @wordpress/components
* 19.8, the version WordPress 6.0 ships, accepts. Typing them here rather
* than installing the package keeps newer props out of the code: anything
* not listed fails the type check.
*
* `__nextHasNoMarginBottom` / `__next40pxDefaultSize` are the opt-ins newer
* versions ask for (WordPress 6.7–7.0 log a deprecation without them). Older
* ones don't know them: WordPress 6.0's TextControl passes them on to its
* , which only React's development build (SCRIPT_DEBUG) warns about.
*/
declare module '@wordpress/components' {
import type {
ChangeEvent,
ComponentPropsWithoutRef,
ComponentType,
ForwardRefExoticComponent,
ReactNode,
RefAttributes,
} from 'react';
interface NextDefaults {
__nextHasNoMarginBottom?: boolean;
__next40pxDefaultSize?: boolean;
}
interface ControlBase {
label?: ReactNode;
hideLabelFromVision?: boolean;
help?: ReactNode;
className?: string;
}
export type ButtonProps = Omit, 'type'> & {
variant?: 'primary' | 'secondary' | 'tertiary' | 'link';
isDestructive?: boolean;
isSmall?: boolean;
isBusy?: boolean;
/** Renders a link instead of a button. */
href?: string;
target?: string;
rel?: string;
type?: 'button' | 'submit' | 'reset';
} & NextDefaults;
export const Button: ForwardRefExoticComponent>;
type CardPartProps = ComponentPropsWithoutRef<'div'> & {
size?: 'xSmall' | 'small' | 'medium' | 'large';
isBorderless?: boolean;
};
export const Card: ComponentType;
export const CardHeader: ComponentType;
export const CardBody: ComponentType;
export type TextControlProps = Omit, 'onChange' | 'value' | 'className'> &
ControlBase &
NextDefaults & {
value: string | number;
onChange: ( value: string ) => void;
};
export const TextControl: ForwardRefExoticComponent>;
export const TextareaControl: ComponentType<
Omit, 'onChange' | 'value' | 'className'> &
ControlBase &
NextDefaults & {
value: string;
onChange: ( value: string ) => void;
}
>;
export const SelectControl: ComponentType<
ControlBase &
NextDefaults & {
id?: string;
value?: string;
onChange: ( value: string ) => void;
/**