| Server IP : 104.26.5.103 / Your IP : 216.73.216.4 Web Server : nginx/1.27.1 System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : arabianexpress ( 1872) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /storage/v9321/leapdubai/public_html/wp-content/plugins/tablepress/admin/js/common/ |
Upload File : |
/**
* Common functions for loading React components in TablePress JS.
*
* @package TablePress
* @subpackage Views JavaScript
* @author Tobias Bäthge
* @since 2.2.0
*/
/**
* WordPress dependencies.
*/
import { StrictMode } from 'react';
import { createPortal, createRoot } from 'react-dom';
import domReady from '@wordpress/dom-ready';
import { addFilter } from '@wordpress/hooks';
/**
* Initializes a React component on the page.
*
* @param {string} rootId HTML ID of the root element for the component.
* @param {Component} Component JSX component.
*/
export const initializeReactComponent = ( rootId, Component ) => {
domReady( () => {
if ( process.env.DEVELOP ) {
Component = <StrictMode>{ Component }</StrictMode>;
}
const root = document.getElementById( rootId );
if ( root ) {
createRoot( root ).render( Component );
}
} );
};
/**
* Initializes a React component on the page, in a React Portal, and registers its meta box.
*
* @param {string} slug Slug of the component/feature module.
* @param {string} screen Slug/action of the screen.
* @param {Component} Component JSX component.
*/
export const initializeReactComponentInPortal = ( slug, screen, Component ) => {
addFilter(
`tablepress.${screen}ScreenFeatures`,
`tp/${slug}/${screen}-screen-feature`,
( features ) => ( [ ...features, slug ] ),
);
addFilter(
`tablepress.${screen}ScreenPortals`,
`tp/${slug}/${screen}-screen-portal`,
( Portals ) => {
return ( props ) => (
<>
<Portals { ...props } />
{
createPortal(
<Component { ...props } />,
document.getElementById( `tablepress-${slug}-section` ),
)
}
</>
);
},
);
};