PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.4.0
GenerateBlocks v1.4.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / components / panel-area / index.js
generateblocks / src / components / panel-area Last commit date
index.js 5 years ago
index.js
76 lines
1 import ApplyFilters from '../apply-filters/';
2
3 import {
4 PanelBody,
5 } from '@wordpress/components';
6
7 import {
8 Component,
9 } from '@wordpress/element';
10
11 import {
12 applyFilters,
13 } from '@wordpress/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 let hasChildren = true;
38
39 if ( '' === children ) {
40 hasChildren = false;
41 }
42
43 // If we have items in the panel, make sure they're not empty.
44 if ( 'object' === typeof children ) {
45 hasChildren = Object.values( children ).some( ( x ) => ( x !== null && x !== false && x !== '' ) );
46 }
47
48 if ( ! hasChildren ) {
49 return null;
50 }
51
52 return (
53 <ApplyFilters name={ 'generateblocks.panel.' + id } props={ this.props } state={ state }>
54 { title ? (
55 <PanelBody
56 title={ title }
57 initialOpen={ initialOpen }
58 icon={ icon }
59 className={ className }
60 >
61 {
62 applyFilters( 'generateblocks.editor.panelContents', children, id, this.props )
63 }
64 </PanelBody>
65 ) : (
66 <PanelBody>
67 {
68 applyFilters( 'generateblocks.editor.panelContents', children, id, this.props )
69 }
70 </PanelBody>
71 ) }
72 </ApplyFilters>
73 );
74 }
75 }
76