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,43 @@
import { createElement } from "react";
/**
* @typedef OwnProps
*
* @property {import('./types').IconKey} icon Icon name
* @property {string} [className] Class name
* @property {number} [size] Size of the icon
*/
/**
* Internal dependencies
*/
function Dashicon({
icon,
className,
size = 20,
style = {},
...extraProps
}) {
const iconClass = ['dashicon', 'dashicons', 'dashicons-' + icon, className].filter(Boolean).join(' ');
// For retro-compatibility reasons (for example if people are overriding icon size with CSS), we add inline styles just if the size is different to the default
const sizeStyles =
// using `!=` to catch both 20 and "20"
// eslint-disable-next-line eqeqeq
20 != size ? {
fontSize: `${size}px`,
width: `${size}px`,
height: `${size}px`
} : {};
const styles = {
...sizeStyles,
...style
};
return createElement("span", {
className: iconClass,
style: styles,
...extraProps
});
}
export default Dashicon;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Dashicon","icon","className","size","style","extraProps","iconClass","filter","Boolean","join","sizeStyles","fontSize","width","height","styles","createElement"],"sources":["@wordpress/components/src/dashicon/index.tsx"],"sourcesContent":["/**\n * @typedef OwnProps\n *\n * @property {import('./types').IconKey} icon Icon name\n * @property {string} [className] Class name\n * @property {number} [size] Size of the icon\n */\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../context';\nimport type { DashiconProps } from './types';\n\nfunction Dashicon( {\n\ticon,\n\tclassName,\n\tsize = 20,\n\tstyle = {},\n\t...extraProps\n}: WordPressComponentProps< DashiconProps, 'span', false > ) {\n\tconst iconClass = [\n\t\t'dashicon',\n\t\t'dashicons',\n\t\t'dashicons-' + icon,\n\t\tclassName,\n\t]\n\t\t.filter( Boolean )\n\t\t.join( ' ' );\n\n\t// For retro-compatibility reasons (for example if people are overriding icon size with CSS), we add inline styles just if the size is different to the default\n\tconst sizeStyles =\n\t\t// using `!=` to catch both 20 and \"20\"\n\t\t// eslint-disable-next-line eqeqeq\n\t\t20 != size\n\t\t\t? {\n\t\t\t\t\tfontSize: `${ size }px`,\n\t\t\t\t\twidth: `${ size }px`,\n\t\t\t\t\theight: `${ size }px`,\n\t\t\t }\n\t\t\t: {};\n\n\tconst styles = {\n\t\t...sizeStyles,\n\t\t...style,\n\t};\n\n\treturn <span className={ iconClass } style={ styles } { ...extraProps } />;\n}\n\nexport default Dashicon;\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAIA,SAASA,QAAQA,CAAE;EAClBC,IAAI;EACJC,SAAS;EACTC,IAAI,GAAG,EAAE;EACTC,KAAK,GAAG,CAAC,CAAC;EACV,GAAGC;AACqD,CAAC,EAAG;EAC5D,MAAMC,SAAS,GAAG,CACjB,UAAU,EACV,WAAW,EACX,YAAY,GAAGL,IAAI,EACnBC,SAAS,CACT,CACCK,MAAM,CAAEC,OAAQ,CAAC,CACjBC,IAAI,CAAE,GAAI,CAAC;;EAEb;EACA,MAAMC,UAAU;EACf;EACA;EACA,EAAE,IAAIP,IAAI,GACP;IACAQ,QAAQ,EAAG,GAAGR,IAAM,IAAG;IACvBS,KAAK,EAAG,GAAGT,IAAM,IAAG;IACpBU,MAAM,EAAG,GAAGV,IAAM;EAClB,CAAC,GACD,CAAC,CAAC;EAEN,MAAMW,MAAM,GAAG;IACd,GAAGJ,UAAU;IACb,GAAGN;EACJ,CAAC;EAED,OAAOW,aAAA;IAAMb,SAAS,EAAGI,SAAW;IAACF,KAAK,EAAGU,MAAQ;IAAA,GAAMT;EAAU,CAAI,CAAC;AAC3E;AAEA,eAAeL,QAAQ"}

View File

@@ -0,0 +1,23 @@
import { createElement } from "react";
/**
* WordPress dependencies
*/
import { Icon } from '@wordpress/components';
/**
* Internal dependencies
*/
import * as dashicons from '../mobile/dashicons';
// A predefined SVG icon is rendered instead of Dashicon because it's not supported in the native version.
function Dashicon({
icon,
...extraProps
}) {
return createElement(Icon, {
icon: dashicons[icon] || dashicons.empty,
...extraProps
});
}
export default Dashicon;
//# sourceMappingURL=index.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Icon","dashicons","Dashicon","icon","extraProps","createElement","empty"],"sources":["@wordpress/components/src/dashicon/index.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport * as dashicons from '../mobile/dashicons';\n\n// A predefined SVG icon is rendered instead of Dashicon because it's not supported in the native version.\nfunction Dashicon( { icon, ...extraProps } ) {\n\treturn (\n\t\t<Icon icon={ dashicons[ icon ] || dashicons.empty } { ...extraProps } />\n\t);\n}\n\nexport default Dashicon;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,uBAAuB;;AAE5C;AACA;AACA;AACA,OAAO,KAAKC,SAAS,MAAM,qBAAqB;;AAEhD;AACA,SAASC,QAAQA,CAAE;EAAEC,IAAI;EAAE,GAAGC;AAAW,CAAC,EAAG;EAC5C,OACCC,aAAA,CAACL,IAAI;IAACG,IAAI,EAAGF,SAAS,CAAEE,IAAI,CAAE,IAAIF,SAAS,CAACK,KAAO;IAAA,GAAMF;EAAU,CAAI,CAAC;AAE1E;AAEA,eAAeF,QAAQ"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

File diff suppressed because one or more lines are too long