/// import { ReactElement } from "@wordpress/element"; import { BlockConfiguration, BlockInstance } from "@wordpress/blocks"; import BlockInstruction from "../../core/blocks/BlockInstruction"; import { RenderEditProps, RenderSaveProps } from "../../core/blocks/BlockDefinition"; /** * Select (a drop-down box) instruction. */ export default class Select extends BlockInstruction { options: { /** * The attribute name the value selected in the select control should be saved as. */ name: string; /** * The available options within the select control. */ options: { label: string; value: string; }[]; /** * The label that should be shown before this select control. */ label: string; /** * If it is required that a value is selected. */ required?: boolean; /** * Whether to visually hide the label. */ hideLabelFromVision: boolean; /** * An optional extra class name or class names. */ className?: string; /** * The default selected value. */ defaultValue?: string; }; /** * Renders saving the element. * * @param props The props. * * @returns {JSX.Element} The element to render. */ save(props: RenderSaveProps): ReactElement | string; /** * Returns the label of the selected option. * * @param value The render props. * * @returns The label of the selected option. */ protected label(value: string): string; /** * Renders editing the element. * * @param props The props. * * @returns {JSX.Element} The element to render. */ edit(props: RenderEditProps): ReactElement | string; /** * Adds the select to the block configuration. * * @returns The block configuration. */ configuration(): Partial; /** * Checks if the instruction block is valid. * * @param blockInstance The attributes from the block. * * @returns `true` if the instruction block is valid, `false` if the block contains errors. */ valid(blockInstance: BlockInstance): boolean; }