/** * The building blocks of the Wishlist section: a titled group card, and the * picture choices inside it (heart position, button style) — each drawn as a * small preview of what it produces rather than a word in a pill bar, since * "Top left" vs "Button with label" is a question about how the page looks. */ import type { ReactNode } from 'react'; import { __ } from '@wordpress/i18n'; import { ToggleControl } from '@wordpress/components'; import { Heart } from 'lucide-react'; export interface Option { value: string; label: string; } export interface WishlistSchema { /** Whether WooCommerce's own `product_wishlist` feature is switched on. */ wishlist_enabled?: boolean; wishlist_positions?: Option[]; wishlist_styles?: Option[]; } interface GroupProps { title: string; description: string; children: ReactNode; } // A heading and description over a white card holding the group's fields. export function WishlistGroup( { title, description, children }: GroupProps ) { return (

{ title }

{ description }

{ children }
); } interface SwitchCardProps { label: string; help: string; checked: boolean; onChange: ( checked: boolean ) => void; /** The choice the switch reveals, under a divider. */ children?: ReactNode; } // A card led by a surface's on/off switch, with its options below. export function SwitchCard( { label, help, checked, onChange, children, }: SwitchCardProps ) { return (
{ checked && children && (
{ children }
) }
); } interface PictureChoiceProps { label: string; value: string; /** Choices in display order; anything the schema lacks is dropped. */ order: string[]; options?: Option[]; onChange: ( value: string ) => void; renderPreview: ( value: string ) => ReactNode; } // A labelled radio group of preview cards. export function PictureChoice( { label, value, order, options, onChange, renderPreview, }: PictureChoiceProps ) { const choices = order .map( ( key ) => ( options ?? [] ).find( ( option ) => option.value === key ) ) .filter( ( option ): option is Option => !! option ); return (
{ label }
{ choices.map( ( option ) => { const checked = option.value === value; return ( ); } ) }
); } // A product-image placeholder with the heart pinned to one top corner. export function PositionPreview( { position }: { position: string } ) { return ( ); } // The single-product button, as the chosen style renders it. export function StylePreview( { style }: { style: string } ) { if ( 'labelled' === style ) { return ( { __( 'Wishlist', 'aureon' ) } ); } return ( ); }