jetformbuilder
/
modules
/
framework
/
blocks-style-manager
/
assets
/
src
/
helpers
/
conditions-checker.js
jetformbuilder
/
modules
/
framework
/
blocks-style-manager
/
assets
/
src
/
helpers
Last commit date
breakpoints.js
3 months ago
color-palette.js
3 months ago
conditions-checker.js
3 months ago
utils.js
3 months ago
conditions-checker.js
37 lines
| 1 | export function isVisible( conditions, context ) { |
| 2 | |
| 3 | if ( ! conditions || ! context ) { |
| 4 | return true; |
| 5 | } |
| 6 | |
| 7 | for ( const [ key, value ] of Object.entries( conditions ) ) { |
| 8 | |
| 9 | if ( Array.isArray( value ) ) { |
| 10 | |
| 11 | if ( ! value.includes( context[ key ] ) ) { |
| 12 | return false; |
| 13 | } |
| 14 | |
| 15 | continue; |
| 16 | } |
| 17 | |
| 18 | if ( context[ key ] !== value ) { |
| 19 | return false; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | return true; |
| 24 | } |
| 25 | |
| 26 | export function getContextFromProps( props ) { |
| 27 | |
| 28 | const attrs = props?.attributes || {}; |
| 29 | const supportName = window.crocoStyleEditorData.support_name; |
| 30 | const stylesContext = attrs?.[ supportName ] || {}; |
| 31 | |
| 32 | return { |
| 33 | ...attrs, |
| 34 | ...stylesContext |
| 35 | }; |
| 36 | } |
| 37 |