MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /disk001/machen/www/support/wp-content/themes/astra/inc/metabox/extend-metabox/src/ast-selector.js
import { Button } from '@wordpress/components';

const AstSelectorControl = props => {

	const {
		label,
		description,
		id,
		metavalue,
		choices,
	} = props;

	const onValueChange = (value) => {
		props.onChange( value );
	};

	if ( ! choices ) {
		return;
	}

	let labelHtml = null;
	let descriptionHtml = null;

	if ( label ) {
		labelHtml = <span className="ast-meta-sortable-title">{label}</span>;
	}

	if ( description ) {
		descriptionHtml = <span className="ast-meta-sortable-description">{description}</span>;
	}

	let optionsHtml = Object.entries( choices ).map( ( [key, data] ) => {

		let value = data.value;

		var html = (
			<div className="ast-selector-inner-wrap" key={ key }>
				<Button
					key={ key }
					onClick={ () => onValueChange( value ) }
					aria-pressed = { value === metavalue }
					isPrimary = { value === metavalue }
					label = { data.label }
				>
					{ data.label }
				</Button>
			</div>
		);

		return html;
	} );

	return <div id={id} className='ast-meta-selector-controller'>
		{ ( labelHtml || descriptionHtml ) &&
			<label>
				{labelHtml}
				{descriptionHtml}
			</label>
		}
		<div className="ast-meta-selector-wrapper">
			{optionsHtml}
		</div>
	</div>;

};

export default AstSelectorControl;