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,86 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
var _element = require("@wordpress/element");
var _compose = require("@wordpress/compose");
/**
* WordPress dependencies
*/
function KeyboardShortcut({
target,
callback,
shortcut,
bindGlobal,
eventName
}) {
(0, _compose.useKeyboardShortcut)(shortcut, callback, {
bindGlobal,
target,
eventName
});
return null;
}
/**
* `KeyboardShortcuts` is a component which handles keyboard sequences during the lifetime of the rendering element.
*
* When passed children, it will capture key events which occur on or within the children. If no children are passed, events are captured on the document.
*
* It uses the [Mousetrap](https://craig.is/killing/mice) library to implement keyboard sequence bindings.
*
* ```jsx
* import { KeyboardShortcuts } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const MyKeyboardShortcuts = () => {
* const [ isAllSelected, setIsAllSelected ] = useState( false );
* const selectAll = () => {
* setIsAllSelected( true );
* };
*
* return (
* <div>
* <KeyboardShortcuts
* shortcuts={ {
* 'mod+a': selectAll,
* } }
* />
* [cmd/ctrl + A] Combination pressed? { isAllSelected ? 'Yes' : 'No' }
* </div>
* );
* };
* ```
*/
function KeyboardShortcuts({
children,
shortcuts,
bindGlobal,
eventName
}) {
const target = (0, _element.useRef)(null);
const element = Object.entries(shortcuts !== null && shortcuts !== void 0 ? shortcuts : {}).map(([shortcut, callback]) => (0, _react.createElement)(KeyboardShortcut, {
key: shortcut,
shortcut: shortcut,
callback: callback,
bindGlobal: bindGlobal,
eventName: eventName,
target: target
}));
// Render as non-visual if there are no children pressed. Keyboard
// events will be bound to the document instead.
if (!_element.Children.count(children)) {
return (0, _react.createElement)(_react.Fragment, null, element);
}
return (0, _react.createElement)("div", {
ref: target
}, element, children);
}
var _default = KeyboardShortcuts;
exports.default = _default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_compose","KeyboardShortcut","target","callback","shortcut","bindGlobal","eventName","useKeyboardShortcut","KeyboardShortcuts","children","shortcuts","useRef","element","Object","entries","map","_react","createElement","key","Children","count","Fragment","ref","_default","exports","default"],"sources":["@wordpress/components/src/keyboard-shortcuts/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, Children } from '@wordpress/element';\nimport { useKeyboardShortcut } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { KeyboardShortcutProps, KeyboardShortcutsProps } from './types';\n\nfunction KeyboardShortcut( {\n\ttarget,\n\tcallback,\n\tshortcut,\n\tbindGlobal,\n\teventName,\n}: KeyboardShortcutProps ) {\n\tuseKeyboardShortcut( shortcut, callback, {\n\t\tbindGlobal,\n\t\ttarget,\n\t\teventName,\n\t} );\n\n\treturn null;\n}\n\n/**\n * `KeyboardShortcuts` is a component which handles keyboard sequences during the lifetime of the rendering element.\n *\n * When passed children, it will capture key events which occur on or within the children. If no children are passed, events are captured on the document.\n *\n * It uses the [Mousetrap](https://craig.is/killing/mice) library to implement keyboard sequence bindings.\n *\n * ```jsx\n * import { KeyboardShortcuts } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyKeyboardShortcuts = () => {\n * \tconst [ isAllSelected, setIsAllSelected ] = useState( false );\n * \tconst selectAll = () => {\n * \t\tsetIsAllSelected( true );\n * \t};\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t<KeyboardShortcuts\n * \t\t\t\tshortcuts={ {\n * \t\t\t\t\t'mod+a': selectAll,\n * \t\t\t\t} }\n * \t\t\t/>\n * \t\t\t[cmd/ctrl + A] Combination pressed? { isAllSelected ? 'Yes' : 'No' }\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nfunction KeyboardShortcuts( {\n\tchildren,\n\tshortcuts,\n\tbindGlobal,\n\teventName,\n}: KeyboardShortcutsProps ) {\n\tconst target = useRef( null );\n\n\tconst element = Object.entries( shortcuts ?? {} ).map(\n\t\t( [ shortcut, callback ] ) => (\n\t\t\t<KeyboardShortcut\n\t\t\t\tkey={ shortcut }\n\t\t\t\tshortcut={ shortcut }\n\t\t\t\tcallback={ callback }\n\t\t\t\tbindGlobal={ bindGlobal }\n\t\t\t\teventName={ eventName }\n\t\t\t\ttarget={ target }\n\t\t\t/>\n\t\t)\n\t);\n\n\t// Render as non-visual if there are no children pressed. Keyboard\n\t// events will be bound to the document instead.\n\tif ( ! Children.count( children ) ) {\n\t\treturn <>{ element }</>;\n\t}\n\n\treturn (\n\t\t<div ref={ target }>\n\t\t\t{ element }\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default KeyboardShortcuts;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AASA,SAASE,gBAAgBA,CAAE;EAC1BC,MAAM;EACNC,QAAQ;EACRC,QAAQ;EACRC,UAAU;EACVC;AACsB,CAAC,EAAG;EAC1B,IAAAC,4BAAmB,EAAEH,QAAQ,EAAED,QAAQ,EAAE;IACxCE,UAAU;IACVH,MAAM;IACNI;EACD,CAAE,CAAC;EAEH,OAAO,IAAI;AACZ;;AAEA;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,SAASE,iBAAiBA,CAAE;EAC3BC,QAAQ;EACRC,SAAS;EACTL,UAAU;EACVC;AACuB,CAAC,EAAG;EAC3B,MAAMJ,MAAM,GAAG,IAAAS,eAAM,EAAE,IAAK,CAAC;EAE7B,MAAMC,OAAO,GAAGC,MAAM,CAACC,OAAO,CAAEJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,CAAC,CAAE,CAAC,CAACK,GAAG,CACpD,CAAE,CAAEX,QAAQ,EAAED,QAAQ,CAAE,KACvB,IAAAa,MAAA,CAAAC,aAAA,EAAChB,gBAAgB;IAChBiB,GAAG,EAAGd,QAAU;IAChBA,QAAQ,EAAGA,QAAU;IACrBD,QAAQ,EAAGA,QAAU;IACrBE,UAAU,EAAGA,UAAY;IACzBC,SAAS,EAAGA,SAAW;IACvBJ,MAAM,EAAGA;EAAQ,CACjB,CAEH,CAAC;;EAED;EACA;EACA,IAAK,CAAEiB,iBAAQ,CAACC,KAAK,CAAEX,QAAS,CAAC,EAAG;IACnC,OAAO,IAAAO,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAK,QAAA,QAAIT,OAAW,CAAC;EACxB;EAEA,OACC,IAAAI,MAAA,CAAAC,aAAA;IAAKK,GAAG,EAAGpB;EAAQ,GAChBU,OAAO,EACPH,QACE,CAAC;AAER;AAAC,IAAAc,QAAA,GAEcf,iBAAiB;AAAAgB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const KeyboardShortcuts = () => null;
var _default = KeyboardShortcuts;
exports.default = _default;
//# sourceMappingURL=index.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["KeyboardShortcuts","_default","exports","default"],"sources":["@wordpress/components/src/keyboard-shortcuts/index.native.js"],"sourcesContent":["const KeyboardShortcuts = () => null;\nexport default KeyboardShortcuts;\n"],"mappings":";;;;;;AAAA,MAAMA,iBAAiB,GAAGA,CAAA,KAAM,IAAI;AAAC,IAAAC,QAAA,GACtBD,iBAAiB;AAAAE,OAAA,CAAAC,OAAA,GAAAF,QAAA"}

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/keyboard-shortcuts/types.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { useKeyboardShortcut } from '@wordpress/compose';\n\n// TODO: We wouldn't have to do this if this type was exported from `@wordpress/compose`.\ntype WPKeyboardShortcutConfig = NonNullable<\n\tParameters< typeof useKeyboardShortcut >[ 2 ]\n>;\n\nexport type KeyboardShortcutProps = {\n\tshortcut: string | string[];\n\t/**\n\t * @see {@link https://craig.is/killing/mice Mousetrap documentation}\n\t */\n\tcallback: ( event: Mousetrap.ExtendedKeyboardEvent, combo: string ) => void;\n} & Pick< WPKeyboardShortcutConfig, 'bindGlobal' | 'eventName' | 'target' >;\n\nexport type KeyboardShortcutsProps = {\n\t/**\n\t * Elements to render, upon whom key events are to be monitored.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * An object of shortcut bindings, where each key is a keyboard combination,\n\t * the value of which is the callback to be invoked when the key combination is pressed.\n\t *\n\t * The value of each shortcut should be a consistent function reference, not an anonymous function.\n\t * Otherwise, the callback will not be correctly unbound when the component unmounts.\n\t *\n\t * The `KeyboardShortcuts` component will not update to reflect a changed `shortcuts` prop.\n\t * If you need to change shortcuts, mount a separate `KeyboardShortcuts` element,\n\t * which can be achieved by assigning a unique `key` prop.\n\t *\n\t * @see {@link https://craig.is/killing/mice Mousetrap documentation}\n\t */\n\tshortcuts: Record< string, KeyboardShortcutProps[ 'callback' ] >;\n\t/**\n\t * By default, a callback will not be invoked if the key combination occurs in an editable field.\n\t * Pass `bindGlobal` as `true` if the key events should be observed globally, including within editable fields.\n\t *\n\t * Tip: If you need some but not all keyboard events to be observed globally,\n\t * simply render two distinct `KeyboardShortcuts` elements, one with and one without the `bindGlobal` prop.\n\t */\n\tbindGlobal?: KeyboardShortcutProps[ 'bindGlobal' ];\n\t/**\n\t * By default, a callback is invoked in response to the `keydown` event.\n\t * To override this, pass `eventName` with the name of a specific keyboard event.\n\t */\n\teventName?: KeyboardShortcutProps[ 'eventName' ];\n};\n"],"mappings":""}