UNPKG

@wordpress/edit-post

Version:
106 lines (92 loc) 2.92 kB
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/esm/inherits"; import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; 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'; var MetaBoxesArea = /*#__PURE__*/ function (_Component) { _inherits(MetaBoxesArea, _Component); /** * @inheritdoc */ function MetaBoxesArea() { var _this; _classCallCheck(this, MetaBoxesArea); _this = _possibleConstructorReturn(this, _getPrototypeOf(MetaBoxesArea).apply(this, arguments)); _this.bindContainerNode = _this.bindContainerNode.bind(_assertThisInitialized(_assertThisInitialized(_this))); return _this; } /** * @inheritdoc */ _createClass(MetaBoxesArea, [{ key: "componentDidMount", value: function 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. */ }, { key: "componentWillUnmount", value: function componentWillUnmount() { if (this.form) { document.querySelector('#metaboxes').appendChild(this.form); } } /** * Binds the metabox area container node. * * @param {Element} node DOM Node. */ }, { key: "bindContainerNode", value: function bindContainerNode(node) { this.container = node; } /** * @inheritdoc */ }, { key: "render", value: function render() { var _this$props = this.props, location = _this$props.location, isSaving = _this$props.isSaving; var classes = classnames('edit-post-meta-boxes-area', "is-".concat(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" })); } }]); return MetaBoxesArea; }(Component); export default withSelect(function (select) { return { isSaving: select('core/edit-post').isSavingMetaBoxes() }; })(MetaBoxesArea); //# sourceMappingURL=index.js.map