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,64 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
var Ariakit = _interopRequireWildcard(require("@ariakit/react"));
var _element = require("@wordpress/element");
var _warning = _interopRequireDefault(require("@wordpress/warning"));
var _toolbarContext = _interopRequireDefault(require("../toolbar-context"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function ToolbarItem({
children,
as: Component,
...props
}, ref) {
const accessibleToolbarStore = (0, _element.useContext)(_toolbarContext.default);
const isRenderProp = typeof children === 'function';
if (!isRenderProp && !Component) {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' + 'See https://developer.wordpress.org/block-editor/components/toolbar-item/') : void 0;
return null;
}
const allProps = {
...props,
ref,
'data-toolbar-item': true
};
if (!accessibleToolbarStore) {
if (Component) {
return (0, _react.createElement)(Component, {
...allProps
}, children);
}
if (!isRenderProp) {
return null;
}
return children(allProps);
}
const render = isRenderProp ? children : Component && (0, _react.createElement)(Component, null, children);
return (0, _react.createElement)(Ariakit.ToolbarItem, {
...allProps,
store: accessibleToolbarStore,
render: render
});
}
var _default = (0, _element.forwardRef)(ToolbarItem);
exports.default = _default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Ariakit","_interopRequireWildcard","require","_element","_warning","_interopRequireDefault","_toolbarContext","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ToolbarItem","children","as","Component","props","ref","accessibleToolbarStore","useContext","ToolbarContext","isRenderProp","SCRIPT_DEBUG","warning","allProps","_react","createElement","render","store","_default","forwardRef","exports"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarItemProps } from './types';\n\nfunction ToolbarItem(\n\t{ children, as: Component, ...props }: ToolbarItemProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarStore = useContext( ToolbarContext );\n\tconst isRenderProp = typeof children === 'function';\n\n\tif ( ! isRenderProp && ! Component ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/toolbar-item/'\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst allProps = { ...props, ref, 'data-toolbar-item': true };\n\n\tif ( ! accessibleToolbarStore ) {\n\t\tif ( Component ) {\n\t\t\treturn <Component { ...allProps }>{ children }</Component>;\n\t\t}\n\t\tif ( ! isRenderProp ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn children( allProps );\n\t}\n\n\tconst render = isRenderProp\n\t\t? children\n\t\t: Component && <Component>{ children }</Component>;\n\n\treturn (\n\t\t<Ariakit.ToolbarItem\n\t\t\t{ ...allProps }\n\t\t\tstore={ accessibleToolbarStore }\n\t\t\trender={ render }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolbarItem );\n"],"mappings":";;;;;;;;AAIA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AAKA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAAgD,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAP,wBAAAW,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC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C;IACD,OAAO,IAAI;EACZ;EAEA,MAAMC,QAAQ,GAAG;IAAE,GAAGR,KAAK;IAAEC,GAAG;IAAE,mBAAmB,EAAE;EAAK,CAAC;EAE7D,IAAK,CAAEC,sBAAsB,EAAG;IAC/B,IAAKH,SAAS,EAAG;MAChB,OAAO,IAAAU,MAAA,CAAAC,aAAA,EAACX,SAAS;QAAA,GAAMS;MAAQ,GAAKX,QAAqB,CAAC;IAC3D;IACA,IAAK,CAAEQ,YAAY,EAAG;MACrB,OAAO,IAAI;IACZ;IACA,OAAOR,QAAQ,CAAEW,QAAS,CAAC;EAC5B;EAEA,MAAMG,MAAM,GAAGN,YAAY,GACxBR,QAAQ,GACRE,SAAS,IAAI,IAAAU,MAAA,CAAAC,aAAA,EAACX,SAAS,QAAGF,QAAqB,CAAC;EAEnD,OACC,IAAAY,MAAA,CAAAC,aAAA,EAAC3C,OAAO,CAAC6B,WAAW;IAAA,GACdY,QAAQ;IACbI,KAAK,EAAGV,sBAAwB;IAChCS,MAAM,EAAGA;EAAQ,CACjB,CAAC;AAEJ;AAAC,IAAAE,QAAA,GAEc,IAAAC,mBAAU,EAAElB,WAAY,CAAC;AAAAmB,OAAA,CAAAlC,OAAA,GAAAgC,QAAA"}

View File

@@ -0,0 +1,29 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _element = require("@wordpress/element");
var _warning = _interopRequireDefault(require("@wordpress/warning"));
/**
* WordPress dependencies
*/
function ToolbarItem({
children,
...props
}, ref) {
if (typeof children !== 'function') {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('`ToolbarItem` is a generic headless component that accepts only function children props') : void 0;
return null;
}
return children({
...props,
ref
});
}
var _default = (0, _element.forwardRef)(ToolbarItem);
exports.default = _default;
//# sourceMappingURL=index.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_warning","_interopRequireDefault","ToolbarItem","children","props","ref","SCRIPT_DEBUG","warning","_default","forwardRef","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\nfunction ToolbarItem( { children, ...props }, ref ) {\n\tif ( typeof children !== 'function' ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component that accepts only function children props'\n\t\t);\n\t\treturn null;\n\t}\n\treturn children( { ...props, ref } );\n}\n\nexport default forwardRef( ToolbarItem );\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAJA;AACA;AACA;;AAIA,SAASG,WAAWA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,EAAG;EACnD,IAAK,OAAOF,QAAQ,KAAK,UAAU,EAAG;IACrC,OAAAG,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EACN,yFACD,CAAC;IACD,OAAO,IAAI;EACZ;EACA,OAAOJ,QAAQ,CAAE;IAAE,GAAGC,KAAK;IAAEC;EAAI,CAAE,CAAC;AACrC;AAAC,IAAAG,QAAA,GAEc,IAAAC,mBAAU,EAAEP,WAAY,CAAC;AAAAQ,OAAA,CAAAC,OAAA,GAAAH,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/toolbar/toolbar-item/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tReactNode,\n\tElementType,\n\tHTMLAttributes,\n\tRefAttributes,\n} from 'react';\n\nexport type ToolbarItemProps = Omit< HTMLAttributes< any >, 'children' > & {\n\t/**\n\t * Component type that will be used to render the toolbar item.\n\t */\n\tas?: ElementType;\n\t/**\n\t * A function that receives the props that should be spread onto the element\n\t * that will be rendered as a toolbar item. If the `as` prop is not provided,\n\t * this prop will accept a ReactNode instead.\n\t */\n\tchildren?:\n\t\t| ReactNode\n\t\t| ( (\n\t\t\t\tprops: HTMLAttributes< any > & RefAttributes< any >\n\t\t ) => ReactElement | null );\n};\n"],"mappings":""}