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,102 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.MenuItem = void 0;
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
var _element = require("@wordpress/element");
var _shortcut = _interopRequireDefault(require("../shortcut"));
var _button = _interopRequireDefault(require("../button"));
var _icon = _interopRequireDefault(require("../icon"));
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function UnforwardedMenuItem(props, ref) {
let {
children,
info,
className,
icon,
iconPosition = 'right',
shortcut,
isSelected,
role = 'menuitem',
suffix,
...buttonProps
} = props;
className = (0, _classnames.default)('components-menu-item__button', className);
if (info) {
children = (0, _react.createElement)("span", {
className: "components-menu-item__info-wrapper"
}, (0, _react.createElement)("span", {
className: "components-menu-item__item"
}, children), (0, _react.createElement)("span", {
className: "components-menu-item__info"
}, info));
}
if (icon && typeof icon !== 'string') {
icon = (0, _element.cloneElement)(icon, {
className: (0, _classnames.default)('components-menu-items__item-icon', {
'has-icon-right': iconPosition === 'right'
})
});
}
return (0, _react.createElement)(_button.default, {
ref: ref
// Make sure aria-checked matches spec https://www.w3.org/TR/wai-aria-1.1/#aria-checked
,
"aria-checked": role === 'menuitemcheckbox' || role === 'menuitemradio' ? isSelected : undefined,
role: role,
icon: iconPosition === 'left' ? icon : undefined,
className: className,
...buttonProps
}, (0, _react.createElement)("span", {
className: "components-menu-item__item"
}, children), !suffix && (0, _react.createElement)(_shortcut.default, {
className: "components-menu-item__shortcut",
shortcut: shortcut
}), !suffix && icon && iconPosition === 'right' && (0, _react.createElement)(_icon.default, {
icon: icon
}), suffix);
}
/**
* MenuItem is a component which renders a button intended to be used in combination with the `DropdownMenu` component.
*
* ```jsx
* import { MenuItem } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const MyMenuItem = () => {
* const [ isActive, setIsActive ] = useState( true );
*
* return (
* <MenuItem
* icon={ isActive ? 'yes' : 'no' }
* isSelected={ isActive }
* role="menuitemcheckbox"
* onClick={ () => setIsActive( ( state ) => ! state ) }
* >
* Toggle
* </MenuItem>
* );
* };
* ```
*/
const MenuItem = (0, _element.forwardRef)(UnforwardedMenuItem);
exports.MenuItem = MenuItem;
var _default = MenuItem;
exports.default = _default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/menu-item/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { ButtonAsButtonProps } from '../button/types';\n\nexport type MenuItemProps = Pick< ButtonAsButtonProps, 'isDestructive' > & {\n\t/**\n\t * A CSS `class` to give to the container element.\n\t */\n\tclassName?: string;\n\t/**\n\t * The children elements.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Text to use as description for button text.\n\t */\n\tinfo?: string;\n\t/**\n\t * The icon to render. Supported values are: Dashicons (specified as\n\t * strings), functions, Component instances and `null`.\n\t *\n\t * @default null\n\t */\n\ticon?: JSX.Element | null;\n\t/**\n\t * Determines where to display the provided `icon`.\n\t */\n\ticonPosition?: ButtonAsButtonProps[ 'iconPosition' ];\n\t/**\n\t * Whether or not the menu item is currently selected, `isSelected` is only taken into\n\t * account when the `role` prop is either `\"menuitemcheckbox\"` or `\"menuitemradio\"`.\n\t */\n\tisSelected?: boolean;\n\t/**\n\t * If shortcut is a string, it is expecting the display text. If shortcut is an object,\n\t * it will accept the properties of `display` (string) and `ariaLabel` (string).\n\t */\n\tshortcut?: string | { display: string; ariaLabel: string };\n\t/**\n\t * If you need to have selectable menu items use menuitemradio for single select,\n\t * and menuitemcheckbox for multiselect.\n\t *\n\t * @default 'menuitem'\n\t */\n\trole?: string;\n\t/**\n\t * Allows for markup other than icons or shortcuts to be added to the menu item.\n\t *\n\t */\n\tsuffix?: ReactNode;\n\t/**\n\t * Human-readable label for item.\n\t */\n\tlabel?: string;\n};\n"],"mappings":""}