| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\Styles; |
| 4 |
|
| 5 |
class Style_States { |
| 6 |
const HOVER = 'hover'; |
| 7 |
const ACTIVE = 'active'; |
| 8 |
const FOCUS = 'focus'; |
| 9 |
|
| 10 |
const SELECTED = 'e--selected'; |
| 11 |
|
| 12 |
public static function get_pseudo_states(): array { |
| 13 |
return [ |
| 14 |
self::HOVER, |
| 15 |
self::ACTIVE, |
| 16 |
self::FOCUS, |
| 17 |
]; |
| 18 |
} |
| 19 |
|
| 20 |
public static function get_class_states(): array { |
| 21 |
return [ |
| 22 |
self::SELECTED, |
| 23 |
]; |
| 24 |
} |
| 25 |
|
| 26 |
public static function get_valid_states(): array { |
| 27 |
return [ |
| 28 |
...self::get_pseudo_states(), |
| 29 |
...self::get_class_states(), |
| 30 |
null, |
| 31 |
]; |
| 32 |
} |
| 33 |
|
| 34 |
public static function is_pseudo_state( string $state ): bool { |
| 35 |
return in_array( $state, self::get_pseudo_states(), true ); |
| 36 |
} |
| 37 |
|
| 38 |
public static function is_class_state( string $state ): bool { |
| 39 |
return in_array( $state, self::get_class_states(), true ); |
| 40 |
} |
| 41 |
|
| 42 |
public static function is_valid_state( $state ): bool { |
| 43 |
if ( null === $state ) { |
| 44 |
return true; |
| 45 |
} |
| 46 |
|
| 47 |
return is_string( $state ) && in_array( $state, self::get_valid_states(), true ); |
| 48 |
} |
| 49 |
|
| 50 |
public static function get_class_states_map(): array { |
| 51 |
return [ |
| 52 |
'selected' => [ |
| 53 |
'name' => 'selected', |
| 54 |
'value' => self::SELECTED, |
| 55 |
], |
| 56 |
]; |
| 57 |
} |
| 58 |
} |
| 59 |
|