<?php

/**
 * The file that defines the core plugin configurator class
 *
 * @link       https://wpconfiguratorbuilder.com
 * @since      1.0.0
 *
 * @package    wcb-configurator-builder
 * @subpackage wcb-configurator-builder/pro/fields/blocks
 */

if ( ! defined('ABSPATH') ) {
	die();
}

use Carbon_Fields\Block;
use Carbon_Fields\Field;

$builder_group_fields = array(
	Field::make( 'separator', 'wpcb_fieldgroup_toggler', __( 'Field Group', 'wcb-configurator-builder' ) )
		->set_classes('accordeon'),
	Field::make( 'text', 'wpcb_fieldgroup_label', __( 'Field group label', 'wcb-configurator-builder' ) ),
	Field::make( 'rich_text', 'wpcb_fieldgroup_description', __( 'Field group description', 'wcb-configurator-builder' ) ),
	Field::make( 'checkbox', 'wpcb_fieldgroup_collapsible', __( 'Make field collapsible', 'wcb-configurator-builder' ) ),
	Field::make( 'select', 'wpcb_fieldgroup_collapsible_state', __( 'Collapsible state on load', 'wcb-configurator-builder' ) )
		->set_options( array(
			'yes' => __( 'Collapsed', 'wcb-configurator-builder' ),
			'no' => __( 'Open', 'wcb-configurator-builder' ),
		))
		->set_conditional_logic( array( array(
			'field' => 'wpcb_fieldgroup_collapsible',
			'value' => true,
		))),
	Field::make( 'checkbox', 'wpcb_fieldgroup_single_value', __( 'Set single field group value', 'wcb-configurator-builder' ) )
		->set_help_text( __( 'Enable this option to configure a single value for the group', 'wcb-configurator-builder' ) ),
	Field::make( 'text', 'wpcb_fieldgroup_value', __( 'Field group value format', 'wcb-configurator-builder' ) )
		->set_help_text( __( 'Enter format of the value. Use merge tags (e.g ${day}-${month}-${year})', 'wcb-configurator-builder' ) )
		->set_conditional_logic( array( array(
			'field' => 'wpcb_fieldgroup_single_value',
			'value' => true,
		))),
);
$builder_group_fields = apply_filters( 'wpcb_builder_group_fields', $builder_group_fields );

Block::make( __( 'WCB Group', 'wcb-configurator-builder' ) )
	->add_fields( $builder_group_fields )
	->set_description( __( 'Displays a field group in the configuration form', 'wcb-configurator-builder' ) )
	->set_keywords(['wcb', 'field', 'group'])
	->set_icon( 'grid-view' )
	->set_mode( 'edit' )
	->set_category( 'wpcb-layout', __( 'Layout', 'wcb-configurator-builder' ) )
	->set_inner_blocks( true )
	->set_allowed_inner_blocks( array(
		'carbon-fields/wcb-choice',
		'carbon-fields/wcb-input',
		'carbon-fields/wcb-html',
	) )
	->set_inner_blocks_position( 'below' )
	->set_render_callback( function ( $fields, $attributes, $inner_blocks ) {
		
		// include block partial

	});