@wordpress/block-library
Version:
Block library for the WordPress editor.
58 lines • 2.78 kB
TypeScript
import type { Order } from './order-options';
type SourceOrderControlProps = {
/** The stored query order. */
order: Order;
/** Whether the gallery's `randomOrder` attribute is set. */
isRandom: boolean;
/**
* Called with `{ orderby, order }` to update the query. Choosing an order
* also turns "Random" off; the handler owns that so both writes land in one
* undo level.
*/
onChange: (order: Order) => void;
/** Called when "Random" is chosen. */
onSelectRandom: () => void;
};
/**
* Ordering control for a dynamic gallery, shown in the Settings panel. The
* chosen order is a *setting*: it's stored in the source's query and re-applied
* every time the source resolves. "Random" is stored separately (the
* `randomOrder` attribute) and overrides the query order on the front end, so
* while it's set the control shows it instead of the query order.
*/
export declare function SourceOrderControl({ order, isRandom, onChange, onSelectRandom, }: SourceOrderControlProps): import("react").JSX.Element;
type SortImagesControlProps = {
/** The last sort applied, while it still holds, or `null` for a custom order. */
currentOrder: Order | null;
/** Whether the gallery's `randomOrder` attribute is set. */
isRandom: boolean;
/** Whether the sort orders can be applied (false while media resolves). */
canSort: boolean;
/**
* Called with `{ orderby, order }` to sort the images. Sorting also turns
* "Random" off; the handler owns that so both writes land in one undo level.
*/
onSort: (order: Order) => void;
/** Called when "Custom" is chosen, which turns "Random" off. */
onSelectCustom: () => void;
/** Called when "Random" is chosen. */
onSelectRandom: () => void;
};
/**
* Ordering control for a static gallery, shown in the Settings panel.
*
* The date and title orders are one-off *actions*: choosing one reorders the
* inner image blocks once, and the user can drag them into any other order
* afterwards. Nothing is stored for them, so the caller passes back the last
* sort it applied for as long as the images remain in that sequence, and
* `null` ("Custom") otherwise. "Custom" means the order arranged in the
* editor, and is choosable only while "Random" is on: picking it turns
* "Random" off without reordering anything.
*
* "Random" is the one stored value (the `randomOrder` attribute). It applies
* on the front end only, leaving the editor order as it is, and choosing any
* other option clears it.
*/
export declare function SortImagesControl({ currentOrder, isRandom, canSort, onSort, onSelectCustom, onSelectRandom, }: SortImagesControlProps): import("react").JSX.Element;
export {};
//# sourceMappingURL=order-controls.d.ts.map