UNPKG

@wordpress/edit-post

Version:
90 lines (75 loc) 1.86 kB
import { createElement } from "@wordpress/element"; /** * External dependencies */ import classnames from 'classnames'; /** * WordPress dependencies */ import { Component } from '@wordpress/element'; import { Spinner } from '@wordpress/components'; import { withSelect } from '@wordpress/data'; /** * Internal dependencies */ import { store as editPostStore } from '../../../store'; class MetaBoxesArea extends Component { /** * @inheritdoc */ constructor() { super(...arguments); this.bindContainerNode = this.bindContainerNode.bind(this); } /** * @inheritdoc */ componentDidMount() { this.form = document.querySelector('.metabox-location-' + this.props.location); if (this.form) { this.container.appendChild(this.form); } } /** * Get the meta box location form from the original location. */ componentWillUnmount() { if (this.form) { document.querySelector('#metaboxes').appendChild(this.form); } } /** * Binds the metabox area container node. * * @param {Element} node DOM Node. */ bindContainerNode(node) { this.container = node; } /** * @inheritdoc */ render() { const { location, isSaving } = this.props; const classes = classnames('edit-post-meta-boxes-area', `is-${location}`, { 'is-loading': isSaving }); return createElement("div", { className: classes }, isSaving && createElement(Spinner, null), createElement("div", { className: "edit-post-meta-boxes-area__container", ref: this.bindContainerNode }), createElement("div", { className: "edit-post-meta-boxes-area__clear" })); } } export default withSelect(select => { return { isSaving: select(editPostStore).isSavingMetaBoxes() }; })(MetaBoxesArea); //# sourceMappingURL=index.js.map