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,40 @@
import { createElement } from "react";
/**
* WordPress dependencies
*/
import { forwardRef, useContext } from '@wordpress/element';
/**
* External dependencies
*/
/**
* Internal dependencies
*/
import ToolbarItem from '../toolbar-item';
import ToolbarContext from '../toolbar-context';
import DropdownMenu from '../../dropdown-menu';
function ToolbarDropdownMenu(props, ref) {
const accessibleToolbarState = useContext(ToolbarContext);
if (!accessibleToolbarState) {
return createElement(DropdownMenu, {
...props
});
}
// ToolbarItem will pass all props to the render prop child, which will pass
// all props to the toggle of DropdownMenu. This means that ToolbarDropdownMenu
// has the same API as DropdownMenu.
return createElement(ToolbarItem, {
ref: ref,
...props.toggleProps
}, toolbarItemProps => createElement(DropdownMenu, {
...props,
popoverProps: {
...props.popoverProps
},
toggleProps: toolbarItemProps
}));
}
export default forwardRef(ToolbarDropdownMenu);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["forwardRef","useContext","ToolbarItem","ToolbarContext","DropdownMenu","ToolbarDropdownMenu","props","ref","accessibleToolbarState","createElement","toggleProps","toolbarItemProps","popoverProps"],"sources":["@wordpress/components/src/toolbar/toolbar-dropdown-menu/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\n\n/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport ToolbarItem from '../toolbar-item';\nimport ToolbarContext from '../toolbar-context';\nimport DropdownMenu from '../../dropdown-menu';\nimport type { DropdownMenuProps } from '../../dropdown-menu/types';\n\nfunction ToolbarDropdownMenu(\n\tprops: DropdownMenuProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ! accessibleToolbarState ) {\n\t\treturn <DropdownMenu { ...props } />;\n\t}\n\n\t// ToolbarItem will pass all props to the render prop child, which will pass\n\t// all props to the toggle of DropdownMenu. This means that ToolbarDropdownMenu\n\t// has the same API as DropdownMenu.\n\treturn (\n\t\t<ToolbarItem ref={ ref } { ...props.toggleProps }>\n\t\t\t{ ( toolbarItemProps ) => (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t...props.popoverProps,\n\t\t\t\t\t} }\n\t\t\t\t\ttoggleProps={ toolbarItemProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</ToolbarItem>\n\t);\n}\n\nexport default forwardRef( ToolbarDropdownMenu );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;;AAE3D;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,YAAY,MAAM,qBAAqB;AAG9C,SAASC,mBAAmBA,CAC3BC,KAAwB,EACxBC,GAAwB,EACvB;EACD,MAAMC,sBAAsB,GAAGP,UAAU,CAAEE,cAAe,CAAC;EAE3D,IAAK,CAAEK,sBAAsB,EAAG;IAC/B,OAAOC,aAAA,CAACL,YAAY;MAAA,GAAME;IAAK,CAAI,CAAC;EACrC;;EAEA;EACA;EACA;EACA,OACCG,aAAA,CAACP,WAAW;IAACK,GAAG,EAAGA,GAAK;IAAA,GAAMD,KAAK,CAACI;EAAW,GAC1CC,gBAAgB,IACnBF,aAAA,CAACL,YAAY;IAAA,GACPE,KAAK;IACVM,YAAY,EAAG;MACd,GAAGN,KAAK,CAACM;IACV,CAAG;IACHF,WAAW,EAAGC;EAAkB,CAChC,CAEU,CAAC;AAEhB;AAEA,eAAeX,UAAU,CAAEK,mBAAoB,CAAC"}