<?php
/**
 * WeCodeArt Framework.
 *
 * WARNING: This file is part of the core WeCodeArt Framework. DO NOT edit this file under any circumstances.
 * Please do all modifications in the form of a child theme.
 *
 * @package		WeCodeArt Framework
 * @subpackage  OffCanvas
 * @since		5.0.0
 * @version    	6.6.8
 */

defined( 'ABSPATH' ) || exit;

use function WeCodeArt\Functions\toJSON;

\wecodeart( 'styles' )->Components->load( [ 'offcanvas' ] );

\wp_enqueue_script( 'wecodeart-support-assets-backdrop' );
\wp_enqueue_script( 'wecodeart-support-assets-focustrap' );

\wp_enqueue_script_module( '@wecodeart/offcanvas' );

\wp_interactivity_state( 'wecodeart/offcanvas', apply_filters( 'wecodeart/filter/interactive/state/offcanvas', [
	'backdrop'	=> true,
	'keyboard'	=> true,
	'scroll'	=> false,
	'classes'	=> [
		'show'		=> 'show',
		'showing'	=> 'showing',
		'hiding'	=> 'hiding'
	]
] ) );
	
\wp_interactivity_config( 'wecodeart/offcanvas', [
	'backdrop'	=> '(boolean|string)',
	'keyboard'	=> 'boolean',
	'scroll'	=> 'boolean',
	'classes'	=> '(object|array)'
] );

/**
 * @param   string	$id			ID
 * @param   array	$class		Class
 * @param   boolean	$close		Close
 * @param   string	$title		Title
 * @param   string	$content	Content
 */

$title 		= $title ?? '';
$close 		= $close ?? true;
$class 		= $class ?? [];
$content	= $content ?? '';
$classnames = [ 'wp-offcanvas' ];
$classnames = array_merge( $classnames, (array) $class );

?>
<div class="<?php echo esc_attr( join( ' ', $classnames ) ); ?>" id="<?php echo esc_attr( $id ); ?>-offcanvas" tabindex="-1"
	<?php if( ! empty( $title ) ) : ?>
	aria-labelledby="<?php echo esc_attr( $id ); ?>-offcanvas-title"
	<?php endif; ?>
	>
	<?php if( ! empty( $title ) || $close ) : ?>
	<div class="wp-offcanvas__header">
		<?php if( ! empty( $title ) ) : ?>
		<h5 class="wp-offcanvas__title" id="<?php echo esc_attr( $id ); ?>-offcanvas-title"><?php echo esc_html( $title ); ?></h5>
		<?php endif; ?>
		<?php if( $close ) wecodeart_template( 'general/close', [ 'close' => 'offcanvas' ] ); ?>
	</div>
	<?php endif; ?>
	<div class="wp-offcanvas__body"><?php

		// Content markup should be escaped before passing to this view.
		echo $content;

	?></div>
</div>