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>
60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
'use strict';
|
|
|
|
var React = require('react');
|
|
var removeItemFromArray = require('reakit-utils/removeItemFromArray');
|
|
|
|
var MenuContext = /*#__PURE__*/React.createContext(null);
|
|
function useMenuContext(menuRef, role, options) {
|
|
var orphan = "unstable_orphan" in options && options.unstable_orphan;
|
|
var parent = React.useContext(MenuContext);
|
|
|
|
var _React$useState = React.useState([]),
|
|
children = _React$useState[0],
|
|
setChildren = _React$useState[1];
|
|
|
|
var _ref = parent || {},
|
|
addChildToParent = _ref.addChild,
|
|
removeChildFromParent = _ref.removeChild;
|
|
|
|
var addChild = React.useCallback(function (ref) {
|
|
return setChildren(function (refs) {
|
|
return [].concat(refs, [ref]);
|
|
});
|
|
}, []);
|
|
var removeChild = React.useCallback(function (ref) {
|
|
return setChildren(function (refs) {
|
|
return removeItemFromArray.removeItemFromArray(refs, ref);
|
|
});
|
|
}, []); // If it's a nested menu, add it to parent
|
|
|
|
React.useEffect(function () {
|
|
if (!addChildToParent || orphan) return undefined;
|
|
addChildToParent(menuRef);
|
|
return function () {
|
|
removeChildFromParent === null || removeChildFromParent === void 0 ? void 0 : removeChildFromParent(menuRef);
|
|
};
|
|
}, [menuRef, addChildToParent, removeChildFromParent, orphan]);
|
|
var providerValue = React.useMemo(function () {
|
|
return {
|
|
orientation: options.orientation,
|
|
next: options.next,
|
|
previous: options.previous,
|
|
ref: menuRef,
|
|
role: role,
|
|
parent: parent,
|
|
children: children,
|
|
addChild: addChild,
|
|
removeChild: removeChild
|
|
};
|
|
}, [options.orientation, options.next, options.previous, menuRef, role, parent, children, addChild, removeChild]);
|
|
var wrapElement = React.useCallback(function (element) {
|
|
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
value: providerValue
|
|
}, element);
|
|
}, [providerValue]);
|
|
return wrapElement;
|
|
}
|
|
|
|
exports.MenuContext = MenuContext;
|
|
exports.useMenuContext = useMenuContext;
|