index.js
57 lines
| 1 | import ApplyFilters from '../apply-filters/'; |
| 2 | |
| 3 | const { |
| 4 | PanelBody, |
| 5 | } = wp.components; |
| 6 | |
| 7 | const { |
| 8 | Component, |
| 9 | } = wp.element; |
| 10 | |
| 11 | const { |
| 12 | applyFilters, |
| 13 | } = wp.hooks; |
| 14 | |
| 15 | /** |
| 16 | * Component Class |
| 17 | */ |
| 18 | export default class PanelArea extends Component { |
| 19 | render() { |
| 20 | const { |
| 21 | title = false, |
| 22 | initialOpen = false, |
| 23 | icon, |
| 24 | className, |
| 25 | id, |
| 26 | state, |
| 27 | showPanel = true, |
| 28 | children, |
| 29 | } = this.props; |
| 30 | |
| 31 | const show = applyFilters( 'generateblocks.editor.showPanel', showPanel, id, this.props ); |
| 32 | |
| 33 | if ( ! show ) { |
| 34 | return null; |
| 35 | } |
| 36 | |
| 37 | return ( |
| 38 | <ApplyFilters name={ 'generateblocks.panel.' + id } props={ this.props } state={ state }> |
| 39 | { title ? ( |
| 40 | <PanelBody |
| 41 | title={ title } |
| 42 | initialOpen={ initialOpen } |
| 43 | icon={ icon } |
| 44 | className={ className } |
| 45 | > |
| 46 | { children } |
| 47 | </PanelBody> |
| 48 | ) : ( |
| 49 | <PanelBody> |
| 50 | { children } |
| 51 | </PanelBody> |
| 52 | ) } |
| 53 | </ApplyFilters> |
| 54 | ); |
| 55 | } |
| 56 | } |
| 57 |