<?php

defined( 'ABSPATH' ) || exit;

/**
 * Grid Container Shortcode.
 */
if ( ! class_exists( 'Vcex_Grid_Container_Shortcode' ) ) {

	class Vcex_Grid_Container_Shortcode extends TotalThemeCore\Vcex\Shortcode_Abstract {

		/**
		 * Shortcode tag.
		 */
		public const TAG = 'vcex_grid_container';

		/**
		 * Main constructor.
		 */
		public function __construct() {

			// Call parent class constructor.
			parent::__construct();
		}

		/**
		 * Shortcode title.
		 */
		public static function get_title(): string {
			return esc_html__( 'Grid Container', 'total-theme-core' );
		}

		/**
		 * Shortcode description.
		 */
		public static function get_description(): string {
			return esc_html__( 'Place certain elements in a grid', 'total-theme-core' );
		}

		/**
		 * Returns custom vc map settings.
		 */
		public static function get_vc_lean_map_settings(): array {
			return [
				'allowed_container_element' => false,
				'is_container'				=> true,
				'content_element'			=> true,
				'js_view'					=> 'VcColumnView',
				'as_parent'					=> [
					'only' => apply_filters(
						'vcex_grid_container_allowed_elements',
						'vcex_heading,vcex_icon_box,vcex_milestone,vcex_bullets,vcex_list_item,vcex_teaser,vc_column_text,vcex_image,vcex_image_swap,vcex_pricing,vcex_custom_field,vcex_image_banner,vcex_icon,vcex_feature_box,vcex_post_next_prev,vcex_shortcode,vc_raw_html,vcex_callout'
					)
				],
			];
		}

		/**
		 * Array of shortcode parameters.
		 */
		public static function get_params_list(): array {
			$column_options = [];

			$alt_col_options = [
				esc_html__( 'Previous', 'total-theme-core' ) => '',
			];

			$columns_count = 12;

			for ( $i = 1; $i <= 12; $i++ ) {
				$column_options[ $i ] = $i;
				$alt_col_options[ $i ] = $i;
			}

			$params = [
				[
					'type' => 'vcex_notice',
					'param_name' => 'editor_notice',
					'text' => esc_html__( 'Because of how the frontend editor works, there could be some design inconsistencies when using this element, so it\'s best used via the backend.', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Align Items', 'total-theme-core' ),
					'param_name' => 'align_items',
					'description' => esc_html__( 'Set the align-items CSS property.', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Justify Items', 'total-theme-core' ),
					'param_name' => 'justify_items',
					'description' => esc_html__( 'Set the justify-items CSS property.', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_text',
					'heading' => esc_html__( 'Gap', 'total-theme-core' ),
					'param_name' => 'gap',
					'css' => true,
					'description' => esc_html__( 'Spacing between elements. Default is 20px.', 'total-theme-core' ),
				],
				[
					'type' => 'dropdown',
					'heading' => esc_html__( 'Columns', 'total-theme-core' ),
					'param_name' => 'columns',
					'value' => $column_options,
					'std' => '1',
					'description' => esc_html__( 'This element uses a mobile-first design. To change the layout on larger screens, adjust the settings below.', 'total-theme-core' ),
				],
				[
					'type' => 'dropdown',
					'heading' => esc_html__( 'Columns sm', 'total-theme-core' ),
					'param_name' => 'columns_sm',
					'std' => '',
					'edit_field_class' => 'vc_col-sm-3 vc_column',
					'value' => $alt_col_options,
					'description' => esc_html__( 'For screens 640px and greater.', 'total-theme-core' ),
				],
				[
					'type' => 'dropdown',
					'heading' => esc_html__( 'Columns md', 'total-theme-core' ),
					'param_name' => 'columns_md',
					'std' => '',
					'edit_field_class' => 'vc_col-sm-3 vc_column',
					'value' => $alt_col_options,
					'description' => esc_html__( 'For screens 768px and greater.', 'total-theme-core' ),
				],
				[
					'type' => 'dropdown',
					'heading' => esc_html__( 'Columns lg', 'total-theme-core' ),
					'param_name' => 'columns_lg',
					'std' => '3',
					'edit_field_class' => 'vc_col-sm-3 vc_column',
					'value' => $alt_col_options,
					'description' => esc_html__( 'For screens 1024px and greater.', 'total-theme-core' ),
				],
				[
					'type' => 'dropdown',
					'heading' => esc_html__( 'Columns xl', 'total-theme-core' ),
					'param_name' => 'columns_xl',
					'std' => '',
					'edit_field_class' => 'vc_col-sm-3 vc_column',
					'value' => $alt_col_options,
					'description' => esc_html__( 'For screens 1280px and greater.', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Visibility', 'total-theme-core' ),
					'param_name' => 'visibility',
				],
				[
					'type' => 'textfield',
					'heading' => esc_html__( 'Element ID', 'total-theme-core' ),
					'param_name' => 'unique_id',
					'admin_label' => true,
					'description' => self::param_description( 'unique_id' ),
				],
				[
					'type' => 'textfield',
					'heading' => esc_html__( 'Extra class name', 'total-theme-core' ),
					'param_name' => 'el_class',
					'description' => self::param_description( 'el_class' ),
				],
				// Design
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Bottom Margin', 'total-theme-core' ),
					'param_name' => 'bottom_margin',
					'admin_label' => true,
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'textfield',
					'heading' => esc_html__( 'Max Width', 'total-theme-core' ),
					'param_name' => 'width',
					'css' => [ 'property' => 'max-width' ],
					'description' => self::param_description( 'width' ),
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_text_align',
					'heading' => esc_html__( 'Align', 'total-theme-core' ),
					'param_name' => 'align',
					'std' => 'center',
					'dependency' => [ 'element' => 'width', 'not_empty' => true ],
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'textfield',
					'heading' => esc_html__( 'Min Height', 'total-theme-core' ),
					'param_name' => 'min_height',
					'css' => [ 'property' => 'min-height', 'important_in_editor' => true ],
					'description' => self::param_description( 'height' ),
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Shadow', 'total-theme-core' ),
					'param_name' => 'shadow',
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_colorpicker',
					'allow_gradient' => true,
					'heading' => esc_html__( 'Background', 'total-theme-core' ),
					'param_name' => 'background_color',
					'css' => true,
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Vertical Padding', 'total-theme-core' ),
					'param_name' => 'padding_y',
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Horizontal Padding', 'total-theme-core' ),
					'param_name' => 'padding_x',
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Border Radius', 'total-theme-core' ),
					'param_name' => 'border_radius',
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Border Width', 'total-theme-core' ),
					'param_name' => 'border_width',
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Border Style', 'total-theme-core' ),
					'param_name' => 'border_style',
					'dependency' => [ 'element' => 'border_width', 'not_empty' => true ],
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_colorpicker',
					'heading' => esc_html__( 'Border Color', 'total-theme-core' ),
					'param_name' => 'border_color',
					'css' => true,
					'dependency' => [ 'element' => 'border_width', 'not_empty' => true ],
					'group' => esc_html__( 'Style', 'total-theme-core' ),
				],
				// CSS.
				[
					'type' => 'css_editor',
					'heading' => esc_html__( 'CSS box', 'total-theme-core' ),
					'param_name' => 'css',
					'group' => esc_html__( 'CSS', 'total-theme-core' ),
				],
			];

			return $params;
		}

	}

}

new Vcex_Grid_Container_Shortcode;

if ( class_exists( 'WPBakeryShortCodesContainer' ) && ! class_exists( 'WPBakeryShortCode_Vcex_Grid_Container' ) ) {
	class WPBakeryShortCode_Vcex_Grid_Container extends WPBakeryShortCodesContainer {}
}
