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,186 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DropZoneComponent = DropZoneComponent;
exports.default = void 0;
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
var _i18n = require("@wordpress/i18n");
var _element = require("@wordpress/element");
var _icons = require("@wordpress/icons");
var _dom = require("@wordpress/dom");
var _compose = require("@wordpress/compose");
var _animation = require("../animation");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* `DropZone` is a component creating a drop zone area taking the full size of its parent element. It supports dropping files, HTML content or any other HTML drop event.
*
* ```jsx
* import { DropZone } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const MyDropZone = () => {
* const [ hasDropped, setHasDropped ] = useState( false );
*
* return (
* <div>
* { hasDropped ? 'Dropped!' : 'Drop something here' }
* <DropZone
* onFilesDrop={ () => setHasDropped( true ) }
* onHTMLDrop={ () => setHasDropped( true ) }
* onDrop={ () => setHasDropped( true ) }
* />
* </div>
* );
* }
* ```
*/
function DropZoneComponent({
className,
label,
onFilesDrop,
onHTMLDrop,
onDrop,
...restProps
}) {
const [isDraggingOverDocument, setIsDraggingOverDocument] = (0, _element.useState)();
const [isDraggingOverElement, setIsDraggingOverElement] = (0, _element.useState)();
const [type, setType] = (0, _element.useState)();
const ref = (0, _compose.__experimentalUseDropZone)({
onDrop(event) {
const files = event.dataTransfer ? (0, _dom.getFilesFromDataTransfer)(event.dataTransfer) : [];
const html = event.dataTransfer?.getData('text/html');
/**
* From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
* The order of the checks is important to recognise the HTML drop.
*/
if (html && onHTMLDrop) {
onHTMLDrop(html);
} else if (files.length && onFilesDrop) {
onFilesDrop(files);
} else if (onDrop) {
onDrop(event);
}
},
onDragStart(event) {
setIsDraggingOverDocument(true);
let _type = 'default';
/**
* From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
* The order of the checks is important to recognise the HTML drop.
*/
if (event.dataTransfer?.types.includes('text/html')) {
_type = 'html';
} else if (
// Check for the types because sometimes the files themselves
// are only available on drop.
event.dataTransfer?.types.includes('Files') || (event.dataTransfer ? (0, _dom.getFilesFromDataTransfer)(event.dataTransfer) : []).length > 0) {
_type = 'file';
}
setType(_type);
},
onDragEnd() {
setIsDraggingOverDocument(false);
setType(undefined);
},
onDragEnter() {
setIsDraggingOverElement(true);
},
onDragLeave() {
setIsDraggingOverElement(false);
}
});
const disableMotion = (0, _compose.useReducedMotion)();
let children;
const backdrop = {
hidden: {
opacity: 0
},
show: {
opacity: 1,
transition: {
type: 'tween',
duration: 0.2,
delay: 0,
delayChildren: 0.1
}
},
exit: {
opacity: 0,
transition: {
duration: 0.2,
delayChildren: 0
}
}
};
const foreground = {
hidden: {
opacity: 0,
scale: 0.9
},
show: {
opacity: 1,
scale: 1,
transition: {
duration: 0.1
}
},
exit: {
opacity: 0,
scale: 0.9
}
};
if (isDraggingOverElement) {
children = (0, _react.createElement)(_animation.__unstableMotion.div, {
variants: backdrop,
initial: disableMotion ? 'show' : 'hidden',
animate: "show",
exit: disableMotion ? 'show' : 'exit',
className: "components-drop-zone__content"
// Without this, when this div is shown,
// Safari calls a onDropZoneLeave causing a loop because of this bug
// https://bugs.webkit.org/show_bug.cgi?id=66547
,
style: {
pointerEvents: 'none'
}
}, (0, _react.createElement)(_animation.__unstableMotion.div, {
variants: foreground
}, (0, _react.createElement)(_icons.Icon, {
icon: _icons.upload,
className: "components-drop-zone__content-icon"
}), (0, _react.createElement)("span", {
className: "components-drop-zone__content-text"
}, label ? label : (0, _i18n.__)('Drop files to upload'))));
}
const classes = (0, _classnames.default)('components-drop-zone', className, {
'is-active': (isDraggingOverDocument || isDraggingOverElement) && (type === 'file' && onFilesDrop || type === 'html' && onHTMLDrop || type === 'default' && onDrop),
'is-dragging-over-document': isDraggingOverDocument,
'is-dragging-over-element': isDraggingOverElement,
[`is-dragging-${type}`]: !!type
});
return (0, _react.createElement)("div", {
...restProps,
ref: ref,
className: classes
}, disableMotion ? children : (0, _react.createElement)(_animation.__unstableAnimatePresence, null, children));
}
var _default = DropZoneComponent;
exports.default = _default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DropZoneProvider;
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
/**
* WordPress dependencies
*/
function DropZoneProvider({
children
}) {
(0, _deprecated.default)('wp.components.DropZoneProvider', {
since: '5.8',
hint: 'wp.component.DropZone no longer needs a provider. wp.components.DropZoneProvider is safe to remove from your code.'
});
return children;
}
//# sourceMappingURL=provider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_deprecated","_interopRequireDefault","require","DropZoneProvider","children","deprecated","since","hint"],"sources":["@wordpress/components/src/drop-zone/provider.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\nexport default function DropZoneProvider( {\n\tchildren,\n}: {\n\tchildren: React.ReactNode;\n} ) {\n\tdeprecated( 'wp.components.DropZoneProvider', {\n\t\tsince: '5.8',\n\t\thint: 'wp.component.DropZone no longer needs a provider. wp.components.DropZoneProvider is safe to remove from your code.',\n\t} );\n\treturn children;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGe,SAASC,gBAAgBA,CAAE;EACzCC;AAGD,CAAC,EAAG;EACH,IAAAC,mBAAU,EAAE,gCAAgC,EAAE;IAC7CC,KAAK,EAAE,KAAK;IACZC,IAAI,EAAE;EACP,CAAE,CAAC;EACH,OAAOH,QAAQ;AAChB"}

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/drop-zone/types.ts"],"sourcesContent":["export type DropType = 'file' | 'html' | 'default';\n\nexport type DropZoneProps = {\n\t/**\n\t * A CSS `class` to give to the wrapper element.\n\t */\n\tclassName?: string;\n\t/**\n\t * A string to be shown within the drop zone area.\n\t *\n\t * @default `__( 'Drop files to upload' )`\n\t */\n\tlabel?: string;\n\t/**\n\t * The function is generic drop handler called if the `onFilesDrop` or `onHTMLDrop` are not called.\n\t * It receives the drop `event` object as an argument.\n\t */\n\tonDrop?: ( event: DragEvent ) => void;\n\t/**\n\t * The function is called when dropping a file into the `DropZone`.\n\t * It receives an array of dropped files as an argument.\n\t */\n\tonFilesDrop?: ( files: File[] ) => void;\n\t/**\n\t * The function is called when dropping HTML into the `DropZone`.\n\t * It receives the HTML being dropped as an argument.\n\t */\n\tonHTMLDrop?: ( html: string ) => void;\n};\n"],"mappings":""}