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,84 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.ExternalLink = 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 _visuallyHidden = require("../visually-hidden");
var _externalLinkStyles = require("./styles/external-link-styles");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function UnforwardedExternalLink(props, ref) {
const {
href,
children,
className,
rel = '',
...additionalProps
} = props;
const optimizedRel = [...new Set([...rel.split(' '), 'external', 'noreferrer', 'noopener'].filter(Boolean))].join(' ');
const classes = (0, _classnames.default)('components-external-link', className);
/* Anchor links are perceived as external links.
This constant helps check for on page anchor links,
to prevent them from being opened in the editor. */
const isInternalAnchor = !!href?.startsWith('#');
const onClickHandler = event => {
if (isInternalAnchor) {
event.preventDefault();
}
if (props.onClick) {
props.onClick(event);
}
};
return (/* eslint-disable react/jsx-no-target-blank */
(0, _react.createElement)("a", {
...additionalProps,
className: classes,
href: href,
onClick: onClickHandler,
target: "_blank",
rel: optimizedRel,
ref: ref
}, children, (0, _react.createElement)(_visuallyHidden.VisuallyHidden, {
as: "span"
}, /* translators: accessibility text */
(0, _i18n.__)('(opens in a new tab)')), (0, _react.createElement)(_externalLinkStyles.StyledIcon, {
icon: _icons.external,
className: "components-external-link__icon"
}))
/* eslint-enable react/jsx-no-target-blank */
);
}
/**
* Link to an external resource.
*
* ```jsx
* import { ExternalLink } from '@wordpress/components';
*
* const MyExternalLink = () => (
* <ExternalLink href="https://wordpress.org">WordPress.org</ExternalLink>
* );
* ```
*/
const ExternalLink = (0, _element.forwardRef)(UnforwardedExternalLink);
exports.ExternalLink = ExternalLink;
var _default = ExternalLink;
exports.default = _default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_element","_icons","_visuallyHidden","_externalLinkStyles","UnforwardedExternalLink","props","ref","href","children","className","rel","additionalProps","optimizedRel","Set","split","filter","Boolean","join","classes","classnames","isInternalAnchor","startsWith","onClickHandler","event","preventDefault","onClick","_react","createElement","target","VisuallyHidden","as","__","StyledIcon","icon","external","ExternalLink","forwardRef","exports","_default","default"],"sources":["@wordpress/components/src/external-link/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef } from '@wordpress/element';\nimport { external } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { VisuallyHidden } from '../visually-hidden';\nimport { StyledIcon } from './styles/external-link-styles';\nimport type { ExternalLinkProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nfunction UnforwardedExternalLink(\n\tprops: Omit<\n\t\tWordPressComponentProps< ExternalLinkProps, 'a', false >,\n\t\t'target'\n\t>,\n\tref: ForwardedRef< HTMLAnchorElement >\n) {\n\tconst { href, children, className, rel = '', ...additionalProps } = props;\n\tconst optimizedRel = [\n\t\t...new Set(\n\t\t\t[\n\t\t\t\t...rel.split( ' ' ),\n\t\t\t\t'external',\n\t\t\t\t'noreferrer',\n\t\t\t\t'noopener',\n\t\t\t].filter( Boolean )\n\t\t),\n\t].join( ' ' );\n\tconst classes = classnames( 'components-external-link', className );\n\t/* Anchor links are perceived as external links.\n\tThis constant helps check for on page anchor links,\n\tto prevent them from being opened in the editor. */\n\tconst isInternalAnchor = !! href?.startsWith( '#' );\n\n\tconst onClickHandler = (\n\t\tevent: React.MouseEvent< HTMLAnchorElement, MouseEvent >\n\t) => {\n\t\tif ( isInternalAnchor ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\tif ( props.onClick ) {\n\t\t\tprops.onClick( event );\n\t\t}\n\t};\n\n\treturn (\n\t\t/* eslint-disable react/jsx-no-target-blank */\n\t\t<a\n\t\t\t{ ...additionalProps }\n\t\t\tclassName={ classes }\n\t\t\thref={ href }\n\t\t\tonClick={ onClickHandler }\n\t\t\ttarget=\"_blank\"\n\t\t\trel={ optimizedRel }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ children }\n\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t{\n\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t}\n\t\t\t</VisuallyHidden>\n\t\t\t<StyledIcon\n\t\t\t\ticon={ external }\n\t\t\t\tclassName=\"components-external-link__icon\"\n\t\t\t/>\n\t\t</a>\n\t\t/* eslint-enable react/jsx-no-target-blank */\n\t);\n}\n\n/**\n * Link to an external resource.\n *\n * ```jsx\n * import { ExternalLink } from '@wordpress/components';\n *\n * const MyExternalLink = () => (\n * <ExternalLink href=\"https://wordpress.org\">WordPress.org</ExternalLink>\n * );\n * ```\n */\nexport const ExternalLink = forwardRef( UnforwardedExternalLink );\n\nexport default ExternalLink;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAL,OAA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mBAAA,CAAA6B,UAAU;MACVC,IAAI,EAAGC,eAAU;MACjBzB,SAAS,EAAC;IAAgC,CAC1C,CACC;IACH;EAAA;AAEF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM0B,YAAY,GAAG,IAAAC,mBAAU,EAAEhC,uBAAwB,CAAC;AAACiC,OAAA,CAAAF,YAAA,GAAAA,YAAA;AAAA,IAAAG,QAAA,GAEnDH,YAAY;AAAAE,OAAA,CAAAE,OAAA,GAAAD,QAAA"}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ExternalLink = ExternalLink;
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _i18n = require("@wordpress/i18n");
var _icons = require("@wordpress/icons");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function ExternalLink({
href,
children
}) {
return (0, _react.createElement)(_reactNative.TouchableOpacity, {
onPress: () => _reactNative.Linking.openURL(href),
accessibilityLabel: (0, _i18n.__)('Open link in a browser')
}, (0, _react.createElement)(_reactNative.Text, null, children), (0, _react.createElement)(_icons.Icon, {
icon: _icons.external
}));
}
var _default = ExternalLink;
exports.default = _default;
//# sourceMappingURL=index.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_reactNative","require","_i18n","_icons","ExternalLink","href","children","_react","createElement","TouchableOpacity","onPress","Linking","openURL","accessibilityLabel","__","Text","Icon","icon","external","_default","exports","default"],"sources":["@wordpress/components/src/external-link/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\n\nimport { TouchableOpacity, Text, Linking } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { external, Icon } from '@wordpress/icons';\n\nexport function ExternalLink( { href, children } ) {\n\treturn (\n\t\t<TouchableOpacity\n\t\t\tonPress={ () => Linking.openURL( href ) }\n\t\t\taccessibilityLabel={ __( 'Open link in a browser' ) }\n\t\t>\n\t\t\t<Text>{ children }</Text>\n\t\t\t<Icon icon={ external } />\n\t\t</TouchableOpacity>\n\t);\n}\n\nexport default ExternalLink;\n"],"mappings":";;;;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIO,SAASG,YAAYA,CAAE;EAAEC,IAAI;EAAEC;AAAS,CAAC,EAAG;EAClD,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACR,YAAA,CAAAS,gBAAgB;IAChBC,OAAO,EAAGA,CAAA,KAAMC,oBAAO,CAACC,OAAO,CAAEP,IAAK,CAAG;IACzCQ,kBAAkB,EAAG,IAAAC,QAAE,EAAE,wBAAyB;EAAG,GAErD,IAAAP,MAAA,CAAAC,aAAA,EAACR,YAAA,CAAAe,IAAI,QAAGT,QAAgB,CAAC,EACzB,IAAAC,MAAA,CAAAC,aAAA,EAACL,MAAA,CAAAa,IAAI;IAACC,IAAI,EAAGC;EAAU,CAAE,CACR,CAAC;AAErB;AAAC,IAAAC,QAAA,GAEcf,YAAY;AAAAgB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}

View File

@@ -0,0 +1,26 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StyledIcon = void 0;
var _base = _interopRequireDefault(require("@emotion/styled/base"));
var _icons = require("@wordpress/icons");
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
const StyledIcon = ( /*#__PURE__*/0, _base.default)(_icons.Icon, process.env.NODE_ENV === "production" ? {
target: "esh4a730"
} : {
target: "esh4a730",
label: "StyledIcon"
})(process.env.NODE_ENV === "production" ? {
name: "rvs7bx",
styles: "width:1em;height:1em;margin:0;vertical-align:middle;fill:currentColor"
} : {
name: "rvs7bx",
styles: "width:1em;height:1em;margin:0;vertical-align:middle;fill:currentColor",
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvZXh0ZXJuYWwtbGluay9zdHlsZXMvZXh0ZXJuYWwtbGluay1zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBVXdDIiwiZmlsZSI6IkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvZXh0ZXJuYWwtbGluay9zdHlsZXMvZXh0ZXJuYWwtbGluay1zdHlsZXMudHMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEV4dGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5cbi8qKlxuICogV29yZFByZXNzIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgeyBJY29uIH0gZnJvbSAnQHdvcmRwcmVzcy9pY29ucyc7XG5cbmV4cG9ydCBjb25zdCBTdHlsZWRJY29uID0gc3R5bGVkKCBJY29uIClgXG5cdHdpZHRoOiAxZW07XG5cdGhlaWdodDogMWVtO1xuXHRtYXJnaW46IDA7XG5cdHZlcnRpY2FsLWFsaWduOiBtaWRkbGU7XG5cdGZpbGw6IGN1cnJlbnRDb2xvcjtcbmA7XG4iXX0= */",
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
});
exports.StyledIcon = StyledIcon;
//# sourceMappingURL=external-link-styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_icons","require","_EMOTION_STRINGIFIED_CSS_ERROR__","StyledIcon","_base","default","Icon","process","env","NODE_ENV","target","label","name","styles","map","toString","exports"],"sources":["@wordpress/components/src/external-link/styles/external-link-styles.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\n\n/**\n * WordPress dependencies\n */\nimport { Icon } from '@wordpress/icons';\n\nexport const StyledIcon = styled( Icon )`\n\twidth: 1em;\n\theight: 1em;\n\tmargin: 0;\n\tvertical-align: middle;\n\tfill: currentColor;\n`;\n"],"mappings":";;;;;;;;AAQA,IAAAA,MAAA,GAAAC,OAAA;AAAwC,SAAAC,iCAAA;AAEjC,MAAMC,UAAU,GAAG,kBAAAC,KAAA,CAAAC,OAAA,EAAQC,WAAI,EAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,CAAC,CAAC,CAAAJ,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAG,IAAA;EAAAC,MAAA;AAAA;EAAAD,IAAA;EAAAC,MAAA;EAAAC,GAAA;EAAAC,QAAA,EAAAb;AAAA,EAMvC;AAACc,OAAA,CAAAb,UAAA,GAAAA,UAAA"}

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/external-link/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type ExternalLinkProps = {\n\t/**\n\t * The content to be displayed within the link.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * The URL of the external resource.\n\t */\n\thref: string;\n};\n"],"mappings":""}