PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
← All changes | includes/blocks/form-builder/block.php +550 -0 2.7.6 → 2.14.0 View file →
@@ -1,0 +1,550 @@
1 +<?php
2 +
3 +namespace ABlocks\Blocks\FormBuilder;
4 +
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit;
7 +}
8 +
9 +use ABlocks\Classes\BlockBaseAbstract;
10 +use ABlocks\Classes\CssGenerator;
11 +use ABlocks\Controls\Alignment;
12 +use ABlocks\Controls\Typography;
13 +use ABlocks\Controls\Dimensions;
14 +use ABlocks\Controls\Border;
15 +use ABlocks\Controls\Range;
16 +use ABlocks\Classes\CssGeneratorV2;
17 +use ABlocks\Controls\Color;
18 +class Block extends BlockBaseAbstract {
19 +
20 + protected $block_name = 'form-builder';
21 +
22 + public function __construct() {
23 + parent::__construct();
24 + add_filter( 'ablocks/get_render_block_content', [ $this, 'render_static_block_content' ], 10, 3 );
25 + }
26 +
27 + public function render_static_block_content( $content, $attributes, $block_instance ) {
28 + if ( $block_instance->name === $this->namespace . '/' . $this->block_name ) {
29 + if ( is_user_logged_in() &&
30 + in_array( $attributes['formType'], array( 'login', 'registration', 'forget_password' ), true )
31 + ) {
32 + return '';
33 + }
34 + return $content;
35 + }
36 + return $content;
37 + }
38 +
39 + public function build_css_v1( $attributes ) {
40 + $css_generator = new CssGenerator( $attributes, $this->block_name );
41 +
42 + $css_generator->add_class_styles(
43 + '{{WRAPPER}} .ablocks-form-builder',
44 + $this->get_row_column_displayCss( $attributes ),
45 + $this->get_row_column_displayCss( $attributes, 'Tablet' ),
46 + $this->get_row_column_displayCss( $attributes, 'Mobile' ),
47 + );
48 +
49 + $css_generator->add_class_styles(
50 + '{{WRAPPER}} .ablocks-form-builder__field',
51 + $this->get_field_css( $attributes ),
52 + $this->get_field_css( $attributes, 'Tablet' ),
53 + $this->get_field_css( $attributes, 'Mobile' ),
54 + );
55 +
56 + $css_generator->add_class_styles(
57 + '{{WRAPPER}} .ablocks-form-builder__label',
58 + $this->get_label_css( $attributes ),
59 + $this->get_label_css( $attributes, 'Tablet' ),
60 + $this->get_label_css( $attributes, 'Mobile' ),
61 + );
62 + $css_generator->add_class_styles(
63 + '{{WRAPPER}} .ablocks-form-builder__helper-text',
64 + $this->get_helper_text_css( $attributes ),
65 + $this->get_helper_text_css( $attributes, 'Tablet' ),
66 + $this->get_helper_text_css( $attributes, 'Mobile' ),
67 + );
68 +
69 + $css_generator->add_class_styles(
70 + '{{WRAPPER}} input.ablocks-form-builder__input ,
71 + {{WRAPPER}} input.ablocks-form-builder__select ,
72 + {{WRAPPER}} input.ablocks-form-builder-timepicker-input ,
73 + {{WRAPPER}} input.ablocks-form-builder-datepicker-input',
74 + $this->get_input_css( $attributes ),
75 + $this->get_input_css( $attributes, 'Tablet' ),
76 + $this->get_input_css( $attributes, 'Mobile' ),
77 + );
78 + $css_generator->add_class_styles(
79 + '{{WRAPPER}} .ablocks-form-builder__input:hover',
80 + $this->get_input_hover_css( $attributes ),
81 + $this->get_input_hover_css( $attributes, 'Tablet' ),
82 + $this->get_input_hover_css( $attributes, 'Mobile' ),
83 + );
84 + $css_generator->add_class_styles(
85 + '{{WRAPPER}} .ablocks-form-builder__input:focus',
86 + $this->get_input_focus_css( $attributes ),
87 + $this->get_input_focus_css( $attributes, 'Tablet' ),
88 + $this->get_input_focus_css( $attributes, 'Mobile' ),
89 + );
90 +
91 + $css_generator->add_class_styles(
92 + '{{WRAPPER}} .ablocks-form-builder__input::placeholder',
93 + $this->get_input_placeholder_css( $attributes ),
94 + $this->get_input_placeholder_css( $attributes, 'Tablet' ),
95 + $this->get_input_placeholder_css( $attributes, 'Mobile' ),
96 + );
97 + $css_generator->add_class_styles(
98 + '{{WRAPPER}} .ablocks-form-builder__input-icon,{{WRAPPER}} .ablocks-form-builder__input-toggle-password',
99 + $this->get_input_position_css( $attributes ),
100 + $this->get_input_position_css( $attributes, 'Tablet' ),
101 + $this->get_input_position_css( $attributes, 'Mobile' ),
102 + );
103 +
104 + $css_generator->add_class_styles(
105 + '{{WRAPPER}} .ablocks-form-builder__submit-button',
106 + $this->get_alignment_button_css( $attributes ),
107 + $this->get_alignment_button_css( $attributes, 'Tablet' ),
108 + $this->get_alignment_button_css( $attributes, 'Mobile' ),
109 + );
110 +
111 + $css_generator->add_class_styles(
112 + '{{WRAPPER}} .ablocks-form-builder__submit-button',
113 + $this->get_submit_button_css( $attributes ),
114 + $this->get_submit_button_css( $attributes, 'Tablet' ),
115 + $this->get_submit_button_css( $attributes, 'Mobile' ),
116 + );
117 +
118 + $css_generator->add_class_styles(
119 + '{{WRAPPER}} .ablocks-form-builder__submit-button:hover',
120 + $this->get_submit_button_hover_css( $attributes ),
121 + $this->get_submit_button_hover_css( $attributes, 'Tablet' ),
122 + $this->get_submit_button_hover_css( $attributes, 'Mobile' ),
123 + );
124 + $css_generator->add_class_styles(
125 + '{{WRAPPER}} .ablocks-block--form-builder__navigator',
126 + $this->get_navigator_css( $attributes ),
127 + $this->get_navigator_css( $attributes, 'Tablet' ),
128 + $this->get_navigator_css( $attributes, 'Mobile' ),
129 + );
130 + $css_generator->add_class_styles(
131 + '{{WRAPPER}} .ablocks-block--form-builder__navigator-redirect-page',
132 + $this->get_navigator_spacing_css( $attributes ),
133 + $this->get_navigator_spacing_css( $attributes, 'Tablet' ),
134 + $this->get_navigator_spacing_css( $attributes, 'Mobile' ),
135 + );
136 + $css_generator->add_class_styles(
137 + '{{WRAPPER}} .ablocks-block--form-builder__success',
138 + $this->get_succsss_styles_css( $attributes ),
139 + $this->get_succsss_styles_css( $attributes, 'Tablet' ),
140 + $this->get_succsss_styles_css( $attributes, 'Mobile' ),
141 + );
142 + $css_generator->add_class_styles(
143 + '{{WRAPPER}} .ablocks-block--form-builder__error',
144 + $this->get_error_styles_css( $attributes ),
145 + $this->get_error_styles_css( $attributes, 'Tablet' ),
146 + $this->get_error_styles_css( $attributes, 'Mobile' ),
147 + );
148 + $css_generator->add_class_styles(
149 + '{{WRAPPER}} .ablocks-block--form-builder__feedback-message',
150 + $this->get_success_error_common_styles_css( $attributes ),
151 + $this->get_success_error_common_styles_css( $attributes, 'Tablet' ),
152 + $this->get_success_error_common_styles_css( $attributes, 'Mobile' ),
153 + );
154 + return $css_generator->generate_css();
155 + }
156 + public function build_css_v2( $attributes ) {
157 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
158 +
159 + $css_generator->add_class_styles(
160 + '{{WRAPPER}} .ablocks-form-builder',
161 + $this->get_row_column_displayCss( $attributes ),
162 + $this->get_row_column_displayCss( $attributes, 'Tablet' ),
163 + $this->get_row_column_displayCss( $attributes, 'Mobile' ),
164 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_row_column_displayCss( $attributes, $device ); } )
165 + );
166 +
167 + $css_generator->add_class_styles(
168 + '{{WRAPPER}} .ablocks-form-builder__field',
169 + $this->get_field_css( $attributes ),
170 + $this->get_field_css( $attributes, 'Tablet' ),
171 + $this->get_field_css( $attributes, 'Mobile' ),
172 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_field_css( $attributes, $device ); } )
173 + );
174 +
175 + $css_generator->add_class_styles(
176 + '{{WRAPPER}} .ablocks-form-builder__label',
177 + $this->get_label_css( $attributes ),
178 + $this->get_label_css( $attributes, 'Tablet' ),
179 + $this->get_label_css( $attributes, 'Mobile' ),
180 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_label_css( $attributes, $device ); } )
181 + );
182 + $css_generator->add_class_styles(
183 + '{{WRAPPER}} .ablocks-form-builder__helper-text',
184 + $this->get_helper_text_css( $attributes ),
185 + $this->get_helper_text_css( $attributes, 'Tablet' ),
186 + $this->get_helper_text_css( $attributes, 'Mobile' ),
187 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_helper_text_css( $attributes, $device ); } )
188 + );
189 +
190 + $css_generator->add_class_styles(
191 + '{{WRAPPER}} .ablocks-form-builder__input ,
192 + {{WRAPPER}} .ablocks-form-builder__select ,
193 + {{WRAPPER}} .ablocks-form-builder-timepicker-input ,
194 + {{WRAPPER}} .ablocks-form-builder-datepicker-input',
195 + $this->get_input_css( $attributes ),
196 + $this->get_input_css( $attributes, 'Tablet' ),
197 + $this->get_input_css( $attributes, 'Mobile' ),
198 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_css( $attributes, $device ); } )
199 + );
200 + $css_generator->add_class_styles(
201 + '{{WRAPPER}} .ablocks-form-builder__input:hover',
202 + $this->get_input_hover_css( $attributes ),
203 + $this->get_input_hover_css( $attributes, 'Tablet' ),
204 + $this->get_input_hover_css( $attributes, 'Mobile' ),
205 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_hover_css( $attributes, $device ); } )
206 + );
207 + $css_generator->add_class_styles(
208 + '{{WRAPPER}} .ablocks-form-builder__input:focus',
209 + $this->get_input_focus_css( $attributes ),
210 + $this->get_input_focus_css( $attributes, 'Tablet' ),
211 + $this->get_input_focus_css( $attributes, 'Mobile' ),
212 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_focus_css( $attributes, $device ); } )
213 + );
214 +
215 + $css_generator->add_class_styles(
216 + '{{WRAPPER}} .ablocks-form-builder__input::placeholder',
217 + $this->get_input_placeholder_css( $attributes ),
218 + $this->get_input_placeholder_css( $attributes, 'Tablet' ),
219 + $this->get_input_placeholder_css( $attributes, 'Mobile' ),
220 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_placeholder_css( $attributes, $device ); } )
221 + );
222 + $css_generator->add_class_styles(
223 + '{{WRAPPER}} .ablocks-form-builder__input-icon,{{WRAPPER}} .ablocks-form-builder__input-toggle-password',
224 + $this->get_input_position_css( $attributes ),
225 + $this->get_input_position_css( $attributes, 'Tablet' ),
226 + $this->get_input_position_css( $attributes, 'Mobile' ),
227 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_position_css( $attributes, $device ); } )
228 + );
229 +
230 + $css_generator->add_class_styles(
231 + '{{WRAPPER}} .ablocks-form-builder__submit-button',
232 + $this->get_alignment_button_css( $attributes ),
233 + $this->get_alignment_button_css( $attributes, 'Tablet' ),
234 + $this->get_alignment_button_css( $attributes, 'Mobile' ),
235 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_alignment_button_css( $attributes, $device ); } )
236 + );
237 +
238 + $css_generator->add_class_styles(
239 + '{{WRAPPER}} .ablocks-form-builder__submit-button',
240 + $this->get_submit_button_css( $attributes ),
241 + $this->get_submit_button_css( $attributes, 'Tablet' ),
242 + $this->get_submit_button_css( $attributes, 'Mobile' ),
243 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_submit_button_css( $attributes, $device ); } )
244 + );
245 +
246 + $css_generator->add_class_styles(
247 + '{{WRAPPER}} .ablocks-form-builder__submit-button:hover',
248 + $this->get_submit_button_hover_css( $attributes ),
249 + $this->get_submit_button_hover_css( $attributes, 'Tablet' ),
250 + $this->get_submit_button_hover_css( $attributes, 'Mobile' ),
251 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_submit_button_hover_css( $attributes, $device ); } )
252 + );
253 + $css_generator->add_class_styles(
254 + '{{WRAPPER}} .ablocks-block--form-builder__navigator',
255 + $this->get_navigator_css( $attributes ),
256 + $this->get_navigator_css( $attributes, 'Tablet' ),
257 + $this->get_navigator_css( $attributes, 'Mobile' ),
258 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_navigator_css( $attributes, $device ); } )
259 + );
260 + $css_generator->add_class_styles(
261 + '{{WRAPPER}} .ablocks-block--form-builder__navigator-redirect-page',
262 + $this->get_navigator_spacing_css( $attributes ),
263 + $this->get_navigator_spacing_css( $attributes, 'Tablet' ),
264 + $this->get_navigator_spacing_css( $attributes, 'Mobile' ),
265 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_navigator_spacing_css( $attributes, $device ); } )
266 + );
267 + $css_generator->add_class_styles(
268 + '{{WRAPPER}} .ablocks-block--form-builder__success',
269 + $this->get_succsss_styles_css( $attributes ),
270 + $this->get_succsss_styles_css( $attributes, 'Tablet' ),
271 + $this->get_succsss_styles_css( $attributes, 'Mobile' ),
272 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_succsss_styles_css( $attributes, $device ); } )
273 + );
274 + $css_generator->add_class_styles(
275 + '{{WRAPPER}} .ablocks-block--form-builder__error',
276 + $this->get_error_styles_css( $attributes ),
277 + $this->get_error_styles_css( $attributes, 'Tablet' ),
278 + $this->get_error_styles_css( $attributes, 'Mobile' ),
279 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_error_styles_css( $attributes, $device ); } )
280 + );
281 + $css_generator->add_class_styles(
282 + '{{WRAPPER}} .ablocks-block--form-builder__feedback-message',
283 + $this->get_success_error_common_styles_css( $attributes ),
284 + $this->get_success_error_common_styles_css( $attributes, 'Tablet' ),
285 + $this->get_success_error_common_styles_css( $attributes, 'Mobile' ),
286 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_success_error_common_styles_css( $attributes, $device ); } )
287 + );
288 + return $css_generator->generate_css();
289 + }
290 + public function build_css( $attributes ) {
291 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
292 + return $this->build_css_v2( $attributes );
293 + }
294 + return $this->build_css_v1( $attributes );
295 + }
296 + public function get_field_css( $attributes, $device = '' ) {
297 + $field_css = array_merge(
298 + Range::get_css([
299 + 'attributeValue' => $attributes['rowsSpacing'],
300 + 'attributeObjectKey' => 'value',
301 + 'isResponsive' => true,
302 + 'defaultValue' => 0,
303 + 'unitDefaultValue' => 'px',
304 + 'property' => 'margin-top',
305 + 'device' => $device,
306 + ]),
307 + Range::get_css([
308 + 'attributeValue' => $attributes['rowsSpacing'],
309 + 'attributeObjectKey' => 'value',
310 + 'isResponsive' => true,
311 + 'defaultValue' => 0,
312 + 'unitDefaultValue' => 'px',
313 + 'property' => 'margin-bottom',
314 + 'device' => $device,
315 + ]),
316 + );
317 + return $field_css;
318 + }
319 +
320 + public function get_label_css( $attributes, $device = '' ) {
321 + $typographyValueGlobal = ! empty( $attributes['labelTypographyGlobal'] ) ? $attributes['labelTypographyGlobal'] : array();
322 + $label_css = array_merge(
323 + [ 'color' => Color::get_css( isset( $attributes['labelColor'] ) ? $attributes['labelColor'] : '' ) ],
324 + Typography::get_css( $attributes['labelTypography'], '', $device, $typographyValueGlobal ),
325 + Alignment::get_css( $attributes['labelAlignment'], 'text-align', $device ),
326 + Range::get_css([
327 + 'attributeValue' => $attributes['labelSpacing'],
328 + 'attributeObjectKey' => 'value',
329 + 'isResponsive' => true,
330 + 'defaultValue' => 10,
331 + 'unitDefaultValue' => 'px',
332 + 'property' => 'margin-bottom',
333 + 'device' => $device,
334 + ]),
335 + );
336 + if ( ! empty( $label_css['margin-bottom'] ) ) {
337 + $label_css['margin-bottom'] = $label_css['margin-bottom'] . ' !important';
338 + }
339 + if ( ! $attributes['showLabels'] ) {
340 + $label_css['display'] = 'none';
341 + }
342 +
343 + return $label_css;
344 + }
345 + public function get_helper_text_css( $attributes, $device = '' ) {
346 + $typographyValueGlobal = ! empty( $attributes['helperTextTypographyGlobal'] ) ? $attributes['helperTextTypographyGlobal'] : array();
347 + $helper_text_css = array_merge(
348 + [ 'color' => Color::get_css( isset( $attributes['helperTextColor'] ) ? $attributes['helperTextColor'] : '' ) ],
349 + Typography::get_css( $attributes['helperTextTypography'], '', $device, $typographyValueGlobal ),
350 + Alignment::get_css( $attributes['labelAlignment'], 'text-align', $device ),
351 + Range::get_css([
352 + 'attributeValue' => $attributes['helperTextSpacing'],
353 + 'attributeObjectKey' => 'value',
354 + 'isResponsive' => true,
355 + 'defaultValue' => 10,
356 + 'unitDefaultValue' => 'px',
357 + 'property' => 'margin-bottom',
358 + 'device' => $device,
359 + ]),
360 + );
361 +
362 + if ( ! $attributes['showLabels'] ) {
363 + $helper_text_css['display'] = 'none';
364 + }
365 +
366 + if ( ! empty( $attributes['helperTextSpacing'][ 'value' . $device ] ) ) {
367 + $helper_text_css['margin-top'] = $attributes['helperTextSpacing'][ 'value' . $device ] . 'px';
368 + $helper_text_css['margin-bottom'] = $attributes['helperTextSpacing'][ 'value' . $device ] . 'px';
369 + }
370 +
371 + return $helper_text_css;
372 + }
373 +
374 + public function get_input_css( $attributes, $device = '' ) {
375 + $css = array();
376 + if ( isset( $attributes['inputBorder']['borderStyle'] ) && $attributes['inputBorder']['borderStyle'] === 'default' ) {
377 + $css['border'] = '1px solid #A7AAAD';
378 + $css['border-radius'] = '5px';
379 + }
380 + $typographyValueGlobal = ! empty( $attributes['inputTypographyGlobal'] ) ? $attributes['inputTypographyGlobal'] : array();
381 + $input_css = array_merge(
382 + [ 'background' => Color::get_css( isset( $attributes['inputBgColor'] ) ? $attributes['inputBgColor'] : '' ) ],
383 + $css,
384 + Alignment::get_css( $attributes['inputAlignment'], 'text-align', $device ),
385 + Typography::get_css( $attributes['inputTypography'], '', $device, $typographyValueGlobal ),
386 + Border::get_css( $attributes['inputBorder'], '', $device ),
387 + $this->add_important_to_css( Dimensions::get_css( $attributes['inputPadding'], 'padding', $device ) )
388 + );
389 +
390 + if ( ! empty( $attributes['inputColor'] ) ) {
391 + $input_css['color'] = Color::get_css(
392 + isset( $attributes['inputColor'] ) ? $attributes['inputColor'] : '') . '!important';
393 + }
394 + $input_css['box-sizing'] = 'border-box';
395 +
396 + return $input_css;
397 + }
398 +
399 + public function get_input_hover_css( $attributes, $device = '' ) {
400 + $css = array();
401 + if ( isset( $attributes['inputBorder']['borderStyle'] ) && $attributes['inputBorder']['borderStyle'] === 'default' ) {
402 + $css['border'] = '1px solid #A7AAAD';
403 + $css['border-radius'] = '5px';
404 + }
405 + $input_focus_css = array_merge(
406 + $css,
407 + Border::get_hover_css( $attributes['inputBorder'], '', $device )
408 + );
409 +
410 + return $input_focus_css;
411 + }
412 + public function get_input_focus_css( $attributes, $device = '' ) {
413 + $css = array();
414 + if ( isset( $attributes['inputBorder']['borderStyle'] ) && $attributes['inputBorder']['borderStyle'] === 'default' ) {
415 + $css['border'] = '1px solid #A7AAAD';
416 + $css['border-radius'] = '5px';
417 + }
418 + $input_focus_css = array_merge(
419 + $css,
420 + Border::get_hover_css( $attributes['inputBorder'], '', $device )
421 + );
422 +
423 + return $input_focus_css;
424 + }
425 + public function get_input_placeholder_css( $attributes, $device = '' ) {
426 + $typographyValueGlobal = ! empty( $attributes['inputTypographyGlobal'] ) ? $attributes['inputTypographyGlobal'] : array();
427 + $placeholder_css = array_merge(
428 + Typography::get_css( $attributes['inputTypography'], '', $device, $typographyValueGlobal ),
429 + Alignment::get_css( $attributes['inputAlignment'], 'text-align', $device )
430 + );
431 + if ( ! empty( $attributes['inputPlaceholderColor'] ) ) {
432 + $placeholder_css['color'] = Color::get_css(
433 + isset( $attributes['inputPlaceholderColor'] ) ? $attributes['inputPlaceholderColor'] : '') . '!important';
434 + }
435 + return $placeholder_css;
436 +
437 + }
438 + public function get_input_position_css( $attributes, $device = '' ) {
439 + $css = array_merge(
440 + Range::get_css([
441 + 'attributeValue' => $attributes['inputIconPosition'],
442 + 'isResponsive' => false,
443 + 'defaultValue' => 75,
444 + 'unitDefaultValue' => '%',
445 + 'property' => 'top',
446 + 'device' => $device,
447 + ]),
448 + );
449 + return $css;
450 + }
451 + public function get_alignment_button_css( $attributes, $device = '' ) {
452 + $button_alignment_css = array_merge(
453 + Alignment::get_css( $attributes['buttonTextAlignment'], 'text-align', $device ),
454 + Alignment::get_css( $attributes['buttonAlignment'], 'align-self', $device )
455 + );
456 +
457 + return $button_alignment_css;
458 + }
459 +
460 +
461 + public function get_submit_button_css( $attributes, $device = '' ) {
462 + $typographyValueGlobal = ! empty( $attributes['buttonTypographyGlobal'] ) ? $attributes['buttonTypographyGlobal'] : array();
463 + $button_css = array_merge(
464 + [ 'color' => Color::get_css( isset( $attributes['buttonColor'] ) ? $attributes['buttonColor'] : '' ) ],
465 + [ 'background' => Color::get_css( isset( $attributes['buttonBgColor'] ) ? $attributes['buttonBgColor'] : '' ) ],
466 + Border::get_css( $attributes['buttonBorder'], '', $device ),
467 + Typography::get_css( $attributes['buttonTypography'], '', $device, $typographyValueGlobal ),
468 + Dimensions::get_css( $attributes['buttonPadding'], 'padding', $device ),
469 + );
470 + return $button_css;
471 + }
472 +
473 + public function get_submit_button_hover_css( $attributes, $device = '' ) {
474 + return array_merge(
475 + [ 'color' => Color::get_css( isset( $attributes['buttonHColor'] ) ? $attributes['buttonHColor'] : '' ) ],
476 + [ 'background' => Color::get_css( isset( $attributes['buttonBgHColor'] ) ? $attributes['buttonBgHColor'] : '' ) ],
477 + Border::get_hover_css( $attributes['buttonBorder'], '', $device )
478 + );
479 + }
480 + public function get_navigator_css( $attributes, $device = '' ) {
481 + $typographyValueGlobal = ! empty( $attributes['navigatorTypographyGlobal'] ) ? $attributes['navigatorTypographyGlobal'] : array();
482 + return array_merge(
483 + [ 'color' => Color::get_css( isset( $attributes['navigatorColor'] ) ? $attributes['navigatorColor'] : '' ) ],
484 + Typography::get_css( $attributes['navigatorTypography'], '', $device, $typographyValueGlobal ),
485 + Dimensions::get_css( $attributes['navigatorPadding'], 'padding', $device ),
486 + Alignment::get_css( $attributes['navigatorAlignment'], 'text-align', $device ),
487 + );
488 + }
489 + public function get_navigator_spacing_css( $attributes, $device = '' ) {
490 + // Access the inputIconPosition attribute from the attributes array
491 + $css = array_merge(
492 + Range::get_css([
493 + 'attributeValue' => $attributes['navigatorSpacing'],
494 + 'isResponsive' => false,
495 + 'defaultValue' => 10,
496 + 'unitDefaultValue' => 'px',
497 + 'property' => 'margin-bottom',
498 + 'device' => $device,
499 + ]),
500 + );
501 + return $css;
502 +
503 + }
504 + public function get_succsss_styles_css( $attributes, $device = '' ) {
505 + return array_merge(
506 + [ 'color' => Color::get_css( isset( $attributes['successColor'] ) ? $attributes['successColor'] : '' ) ],
507 + [ 'background' => Color::get_css( isset( $attributes['successBackground'] ) ? $attributes['successBackground'] : '' ) ]
508 + );
509 + }
510 + public function get_error_styles_css( $attributes, $device = '' ) {
511 + return array_merge(
512 + [ 'color' => Color::get_css( isset( $attributes['errorColor'] ) ? $attributes['errorColor'] : '' ) ],
513 + [ 'background' => Color::get_css( isset( $attributes['errorBackground'] ) ? $attributes['errorBackground'] : '' ) ],
514 + );
515 + }
516 + public function get_success_error_common_styles_css( $attributes, $device = '' ) {
517 + $typographyValueGlobal = ! empty( $attributes['successErrorTypographyGlobal'] ) ? $attributes['successErrorTypographyGlobal'] : array();
518 + return array_merge(
519 + Typography::get_css( $attributes['successErrorTypography'], '', $device, $typographyValueGlobal ),
520 + Alignment::get_css( $attributes['successErrorAlignment'], 'text-align', $device ),
521 + Dimensions::get_css( $attributes['successErrorPadding'], 'padding', $device ),
522 + );
523 + }
524 +
525 + public function get_row_column_displayCss( $attributes, $device = '' ) {
526 + $css = [];
527 +
528 + if ( isset( $attributes['dir'][ 'value' . $device ] ) ) {
529 + $dir_value = $attributes['dir'][ 'value' . $device ];
530 + $css['flex-direction'] = $dir_value;
531 +
532 + if ( in_array( $dir_value, [ 'row', 'row-reverse' ], true ) ) {
533 + $css['align-items'] = 'center';
534 + } elseif ( in_array( $dir_value, [ 'column', 'column-reverse' ], true ) ) {
535 + $css['flex-wrap'] = 'wrap';
536 + }
537 + }
538 +
539 + return $css;
540 + }
541 +
542 + private function add_important_to_css( $css_array ) {
543 + foreach ( $css_array as $key => $value ) {
544 + $css_array[$key] = $value . ' !important';
545 + }
546 + return $css_array;
547 + }
548 +
549 +
550 +}