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,72 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FormFileUpload = FormFileUpload;
exports.default = void 0;
var _react = require("react");
var _element = require("@wordpress/element");
var _button = _interopRequireDefault(require("../button"));
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* FormFileUpload is a component that allows users to select files from their local device.
*
* ```jsx
* import { FormFileUpload } from '@wordpress/components';
*
* const MyFormFileUpload = () => (
* <FormFileUpload
* accept="image/*"
* onChange={ ( event ) => console.log( event.currentTarget.files ) }
* >
* Upload
* </FormFileUpload>
* );
* ```
*/
function FormFileUpload({
accept,
children,
multiple = false,
onChange,
onClick,
render,
...props
}) {
const ref = (0, _element.useRef)(null);
const openFileDialog = () => {
ref.current?.click();
};
const ui = render ? render({
openFileDialog
}) : (0, _react.createElement)(_button.default, {
onClick: openFileDialog,
...props
}, children);
return (0, _react.createElement)("div", {
className: "components-form-file-upload"
}, ui, (0, _react.createElement)("input", {
type: "file",
ref: ref,
multiple: multiple,
style: {
display: 'none'
},
accept: accept,
onChange: onChange,
onClick: onClick,
"data-testid": "form-file-upload-input"
}));
}
var _default = FormFileUpload;
exports.default = _default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_button","_interopRequireDefault","FormFileUpload","accept","children","multiple","onChange","onClick","render","props","ref","useRef","openFileDialog","current","click","ui","_react","createElement","default","className","type","style","display","_default","exports"],"sources":["@wordpress/components/src/form-file-upload/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport type { WordPressComponentProps } from '../context';\nimport type { FormFileUploadProps } from './types';\n\n/**\n * FormFileUpload is a component that allows users to select files from their local device.\n *\n * ```jsx\n * import { FormFileUpload } from '@wordpress/components';\n *\n * const MyFormFileUpload = () => (\n * <FormFileUpload\n * accept=\"image/*\"\n * onChange={ ( event ) => console.log( event.currentTarget.files ) }\n * >\n * Upload\n * </FormFileUpload>\n * );\n * ```\n */\nexport function FormFileUpload( {\n\taccept,\n\tchildren,\n\tmultiple = false,\n\tonChange,\n\tonClick,\n\trender,\n\t...props\n}: WordPressComponentProps< FormFileUploadProps, 'button', false > ) {\n\tconst ref = useRef< HTMLInputElement >( null );\n\tconst openFileDialog = () => {\n\t\tref.current?.click();\n\t};\n\n\tconst ui = render ? (\n\t\trender( { openFileDialog } )\n\t) : (\n\t\t<Button onClick={ openFileDialog } { ...props }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n\n\treturn (\n\t\t<div className=\"components-form-file-upload\">\n\t\t\t{ ui }\n\t\t\t<input\n\t\t\t\ttype=\"file\"\n\t\t\t\tref={ ref }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\taccept={ accept }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tdata-testid=\"form-file-upload-input\"\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default FormFileUpload;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,cAAcA,CAAE;EAC/BC,MAAM;EACNC,QAAQ;EACRC,QAAQ,GAAG,KAAK;EAChBC,QAAQ;EACRC,OAAO;EACPC,MAAM;EACN,GAAGC;AAC6D,CAAC,EAAG;EACpE,MAAMC,GAAG,GAAG,IAAAC,eAAM,EAAsB,IAAK,CAAC;EAC9C,MAAMC,cAAc,GAAGA,CAAA,KAAM;IAC5BF,GAAG,CAACG,OAAO,EAAEC,KAAK,CAAC,CAAC;EACrB,CAAC;EAED,MAAMC,EAAE,GAAGP,MAAM,GAChBA,MAAM,CAAE;IAAEI;EAAe,CAAE,CAAC,GAE5B,IAAAI,MAAA,CAAAC,aAAA,EAACjB,OAAA,CAAAkB,OAAM;IAACX,OAAO,EAAGK,cAAgB;IAAA,GAAMH;EAAK,GAC1CL,QACK,CACR;EAED,OACC,IAAAY,MAAA,CAAAC,aAAA;IAAKE,SAAS,EAAC;EAA6B,GACzCJ,EAAE,EACJ,IAAAC,MAAA,CAAAC,aAAA;IACCG,IAAI,EAAC,MAAM;IACXV,GAAG,EAAGA,GAAK;IACXL,QAAQ,EAAGA,QAAU;IACrBgB,KAAK,EAAG;MAAEC,OAAO,EAAE;IAAO,CAAG;IAC7BnB,MAAM,EAAGA,MAAQ;IACjBG,QAAQ,EAAGA,QAAU;IACrBC,OAAO,EAAGA,OAAS;IACnB,eAAY;EAAwB,CACpC,CACG,CAAC;AAER;AAAC,IAAAgB,QAAA,GAEcrB,cAAc;AAAAsB,OAAA,CAAAN,OAAA,GAAAK,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/form-file-upload/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentProps, InputHTMLAttributes, ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type Icon from '../icon';\n\n// TODO: Replace `children` and `icon` types with props from Button once Button is typed.\nexport type FormFileUploadProps = {\n\t/**\n\t * A string passed to `input` element that tells the browser which file types can be\n\t * upload to the upload by the user use. e.g: `image/*,video/*`.\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers.\n\t */\n\taccept?: InputHTMLAttributes< HTMLInputElement >[ 'accept' ];\n\t/**\n\t * Children are passed as children of `Button`.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * The icon to render in the `Button`.\n\t */\n\ticon?: ComponentProps< typeof Icon >[ 'icon' ];\n\t/**\n\t * Whether to allow multiple selection of files or not.\n\t */\n\tmultiple?: InputHTMLAttributes< HTMLInputElement >[ 'multiple' ];\n\t/**\n\t * Callback function passed directly to the `input` file element.\n\t *\n\t * Select files will be available in `event.currentTarget.files`.\n\t */\n\tonChange: InputHTMLAttributes< HTMLInputElement >[ 'onChange' ];\n\t/**\n\t * Callback function passed directly to the `input` file element.\n\t *\n\t * This can be useful when you want to force a `change` event to fire when\n\t * the user chooses the same file again. To do this, set the target value to\n\t * an empty string in the `onClick` function.\n\t *\n\t * ```jsx\n\t * <FormFileUpload\n\t * \tonClick={ ( event ) => ( event.target.value = '' ) }\n\t * \tonChange={ onChange }\n\t * >\n\t * \tUpload\n\t * </FormFileUpload>\n\t * ```\n\t */\n\tonClick?: InputHTMLAttributes< HTMLInputElement >[ 'onClick' ];\n\t/**\n\t * Optional callback function used to render the UI.\n\t *\n\t * If passed, the component does not render the default UI (a button) and\n\t * calls this function to render it. The function receives an object with\n\t * property `openFileDialog`, a function that, when called, opens the browser\n\t * native file upload modal window.\n\t */\n\trender?: ( arg: { openFileDialog: () => void } ) => ReactNode;\n};\n"],"mappings":""}