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,75 @@
import { createElement, Fragment } from "react";
/**
* WordPress dependencies
*/
import { check } from '@wordpress/icons';
/**
* Internal dependencies
*/
import MenuItem from '../menu-item';
const noop = () => {};
/**
* `MenuItemsChoice` functions similarly to a set of `MenuItem`s, but allows the user to select one option from a set of multiple choices.
*
*
* ```jsx
* import { MenuGroup, MenuItemsChoice } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const MyMenuItemsChoice = () => {
* const [ mode, setMode ] = useState( 'visual' );
* const choices = [
* {
* value: 'visual',
* label: 'Visual editor',
* },
* {
* value: 'text',
* label: 'Code editor',
* },
* ];
*
* return (
* <MenuGroup label="Editor">
* <MenuItemsChoice
* choices={ choices }
* value={ mode }
* onSelect={ ( newMode ) => setMode( newMode ) }
* />
* </MenuGroup>
* );
* };
* ```
*/
function MenuItemsChoice({
choices = [],
onHover = noop,
onSelect,
value
}) {
return createElement(Fragment, null, choices.map(item => {
const isSelected = value === item.value;
return createElement(MenuItem, {
key: item.value,
role: "menuitemradio",
disabled: item.disabled,
icon: isSelected ? check : null,
info: item.info,
isSelected: isSelected,
shortcut: item.shortcut,
className: "components-menu-items-choice",
onClick: () => {
if (!isSelected) {
onSelect(item.value);
}
},
onMouseEnter: () => onHover(item.value),
onMouseLeave: () => onHover(null),
"aria-label": item['aria-label']
}, item.label);
}));
}
export default MenuItemsChoice;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["check","MenuItem","noop","MenuItemsChoice","choices","onHover","onSelect","value","createElement","Fragment","map","item","isSelected","key","role","disabled","icon","info","shortcut","className","onClick","onMouseEnter","onMouseLeave","label"],"sources":["@wordpress/components/src/menu-items-choice/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MenuItem from '../menu-item';\nimport type { MenuItemsChoiceProps } from './types';\n\nconst noop = () => {};\n\n/**\n * `MenuItemsChoice` functions similarly to a set of `MenuItem`s, but allows the user to select one option from a set of multiple choices.\n *\n *\n * ```jsx\n * import { MenuGroup, MenuItemsChoice } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyMenuItemsChoice = () => {\n * \tconst [ mode, setMode ] = useState( 'visual' );\n * \tconst choices = [\n * \t\t{\n * \t\t\tvalue: 'visual',\n * \t\t\tlabel: 'Visual editor',\n * \t\t},\n * \t\t{\n * \t\t\tvalue: 'text',\n * \t\t\tlabel: 'Code editor',\n * \t\t},\n * \t];\n *\n * \treturn (\n * \t\t<MenuGroup label=\"Editor\">\n * \t\t\t<MenuItemsChoice\n * \t\t\t\tchoices={ choices }\n * \t\t\t\tvalue={ mode }\n * \t\t\t\tonSelect={ ( newMode ) => setMode( newMode ) }\n * \t\t\t/>\n * \t\t</MenuGroup>\n * \t);\n * };\n * ```\n */\nfunction MenuItemsChoice( {\n\tchoices = [],\n\tonHover = noop,\n\tonSelect,\n\tvalue,\n}: MenuItemsChoiceProps ) {\n\treturn (\n\t\t<>\n\t\t\t{ choices.map( ( item ) => {\n\t\t\t\tconst isSelected = value === item.value;\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ item.value }\n\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\tdisabled={ item.disabled }\n\t\t\t\t\t\ticon={ isSelected ? check : null }\n\t\t\t\t\t\tinfo={ item.info }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tshortcut={ item.shortcut }\n\t\t\t\t\t\tclassName=\"components-menu-items-choice\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( ! isSelected ) {\n\t\t\t\t\t\t\t\tonSelect( item.value );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseEnter={ () => onHover( item.value ) }\n\t\t\t\t\t\tonMouseLeave={ () => onHover( null ) }\n\t\t\t\t\t\taria-label={ item[ 'aria-label' ] }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport default MenuItemsChoice;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,kBAAkB;;AAExC;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,cAAc;AAGnC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAE;EACzBC,OAAO,GAAG,EAAE;EACZC,OAAO,GAAGH,IAAI;EACdI,QAAQ;EACRC;AACqB,CAAC,EAAG;EACzB,OACCC,aAAA,CAAAC,QAAA,QACGL,OAAO,CAACM,GAAG,CAAIC,IAAI,IAAM;IAC1B,MAAMC,UAAU,GAAGL,KAAK,KAAKI,IAAI,CAACJ,KAAK;IACvC,OACCC,aAAA,CAACP,QAAQ;MACRY,GAAG,EAAGF,IAAI,CAACJ,KAAO;MAClBO,IAAI,EAAC,eAAe;MACpBC,QAAQ,EAAGJ,IAAI,CAACI,QAAU;MAC1BC,IAAI,EAAGJ,UAAU,GAAGZ,KAAK,GAAG,IAAM;MAClCiB,IAAI,EAAGN,IAAI,CAACM,IAAM;MAClBL,UAAU,EAAGA,UAAY;MACzBM,QAAQ,EAAGP,IAAI,CAACO,QAAU;MAC1BC,SAAS,EAAC,8BAA8B;MACxCC,OAAO,EAAGA,CAAA,KAAM;QACf,IAAK,CAAER,UAAU,EAAG;UACnBN,QAAQ,CAAEK,IAAI,CAACJ,KAAM,CAAC;QACvB;MACD,CAAG;MACHc,YAAY,EAAGA,CAAA,KAAMhB,OAAO,CAAEM,IAAI,CAACJ,KAAM,CAAG;MAC5Ce,YAAY,EAAGA,CAAA,KAAMjB,OAAO,CAAE,IAAK,CAAG;MACtC,cAAaM,IAAI,CAAE,YAAY;IAAI,GAEjCA,IAAI,CAACY,KACE,CAAC;EAEb,CAAE,CACD,CAAC;AAEL;AAEA,eAAepB,eAAe"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/menu-items-choice/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { ShortcutProps } from '../shortcut/types';\nimport type { ButtonAsButtonProps } from '../button/types';\n\nexport type MenuItemsChoiceProps = {\n\t/**\n\t * Array of choices.\n\t *\n\t * @default []\n\t */\n\tchoices: readonly MenuItemChoice[];\n\t/**\n\t * Value of currently selected choice (should match a `value` property\n\t * from a choice in `choices`).\n\t */\n\tvalue: string;\n\t/**\n\t * Callback function to be called with the selected choice when user\n\t * selects a new choice.\n\t */\n\tonSelect( value: string ): void;\n\t/**\n\t * Callback function to be called with a choice when user\n\t * hovers over a new choice (will be empty on mouse leave).\n\t *\n\t * @default noop\n\t */\n\tonHover: ( value: string | null ) => void;\n};\n\nexport type MenuItemChoice = {\n\t/**\n\t * Human-readable label for choice.\n\t */\n\tlabel: string;\n\t/**\n\t * Unique value for choice.\n\t */\n\tvalue: string;\n\t/**\n\t * Whether the menu item is disabled.\n\t */\n\tdisabled?: ButtonAsButtonProps[ 'disabled' ];\n\t/**\n\t * Additional information which will be rendered below the given label.\n\t */\n\tinfo?: string;\n\t/**\n\t * Optional keyboard sequence to trigger choice with keyboard shortcut\n\t * (e.g. `ctrl+s`).\n\t */\n\tshortcut?: ShortcutProps[ 'shortcut' ];\n\t/**\n\t * Aria compliant label.\n\t */\n\t[ 'aria-label' ]?: string;\n};\n"],"mappings":""}