fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

View File

@@ -0,0 +1,93 @@
import { createElement } from "react";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { useContext, forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import Button from '../../button';
import ToolbarItem from '../toolbar-item';
import ToolbarContext from '../toolbar-context';
import ToolbarButtonContainer from './toolbar-button-container';
function UnforwardedToolbarButton({
children,
className,
containerClassName,
extraProps,
isActive,
isDisabled,
title,
...props
}, ref) {
const accessibleToolbarState = useContext(ToolbarContext);
if (!accessibleToolbarState) {
return createElement(ToolbarButtonContainer, {
className: containerClassName
}, createElement(Button, {
ref: ref,
icon: props.icon,
label: title,
shortcut: props.shortcut,
"data-subscript": props.subscript,
onClick: event => {
event.stopPropagation();
// TODO: Possible bug; maybe use onClick instead of props.onClick.
if (props.onClick) {
props.onClick(event);
}
},
className: classnames('components-toolbar__control', className),
isPressed: isActive,
disabled: isDisabled,
"data-toolbar-item": true,
...extraProps,
...props
}, children));
}
// ToobarItem will pass all props to the render prop child, which will pass
// all props to Button. This means that ToolbarButton has the same API as
// Button.
return createElement(ToolbarItem, {
className: classnames('components-toolbar-button', className),
...extraProps,
...props,
ref: ref
}, toolbarItemProps => createElement(Button, {
label: title,
isPressed: isActive,
disabled: isDisabled,
...toolbarItemProps
}, children));
}
/**
* ToolbarButton can be used to add actions to a toolbar, usually inside a Toolbar
* or ToolbarGroup when used to create general interfaces.
*
* ```jsx
* import { Toolbar, ToolbarButton } from '@wordpress/components';
* import { edit } from '@wordpress/icons';
*
* function MyToolbar() {
* return (
* <Toolbar label="Options">
* <ToolbarButton
* icon={ edit }
* label="Edit"
* onClick={ () => alert( 'Editing' ) }
* />
* </Toolbar>
* );
* }
* ```
*/
export const ToolbarButton = forwardRef(UnforwardedToolbarButton);
export default ToolbarButton;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
import { createElement } from "react";
/**
* Internal dependencies
*/
const ToolbarButtonContainer = ({
children,
className
}) => createElement("div", {
className: className
}, children);
export default ToolbarButtonContainer;
//# sourceMappingURL=toolbar-button-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["ToolbarButtonContainer","children","className","createElement"],"sources":["@wordpress/components/src/toolbar/toolbar-button/toolbar-button-container.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { ToolbarButtonContainerProps } from './types';\n\nconst ToolbarButtonContainer = ( {\n\tchildren,\n\tclassName,\n}: ToolbarButtonContainerProps ) => (\n\t<div className={ className }>{ children }</div>\n);\n\nexport default ToolbarButtonContainer;\n"],"mappings":";AAAA;AACA;AACA;;AAGA,MAAMA,sBAAsB,GAAGA,CAAE;EAChCC,QAAQ;EACRC;AAC4B,CAAC,KAC7BC,aAAA;EAAKD,SAAS,EAAGA;AAAW,GAAGD,QAAe,CAC9C;AAED,eAAeD,sBAAsB"}

View File

@@ -0,0 +1,7 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { View } from 'react-native';
export default (props => createElement(View, null, props.children));
//# sourceMappingURL=toolbar-button-container.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["View","props","createElement","children"],"sources":["@wordpress/components/src/toolbar/toolbar-button/toolbar-button-container.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\nexport default ( props ) => <View>{ props.children }</View>;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,cAAc;AAEnC,gBAAiBC,KAAK,IAAMC,aAAA,CAACF,IAAI,QAAGC,KAAK,CAACE,QAAgB,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/toolbar/toolbar-button/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type ToolbarButtonProps = {\n\t/**\n\t * Children to be rendered inside the button.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * An optional class name for the button container.\n\t */\n\tcontainerClassName?: string;\n\t/**\n\t * Additional props to be passed alongside props.\n\t */\n\textraProps?: any;\n\t/**\n\t * Indicates if the button is active.\n\t */\n\tisActive?: boolean;\n\t/**\n\t * Indicates if the button is disabled.\n\t */\n\tisDisabled?: boolean;\n\t/**\n\t * An optional subscript for the button.\n\t */\n\tsubscript?: string;\n\t/**\n\t * An optional title/label for the button.\n\t */\n\ttitle?: string;\n};\n\nexport type ToolbarButtonContainerProps = {\n\t/**\n\t * Children to be rendered inside the button container.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * An optional class name for the button container.\n\t */\n\tclassName?: string;\n};\n"],"mappings":""}