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,112 @@
/**
* External dependencies
*/
import clsx from 'clsx';
/**
* WordPress dependencies
*/
import { createElement, forwardRef } from '@wordpress/element';
/** @typedef {{isPressed?: boolean} & import('react').ComponentPropsWithoutRef<'svg'>} SVGProps */
/**
* @param {import('react').ComponentPropsWithoutRef<'circle'>} props
*
* @return {JSX.Element} Circle component
*/
export const Circle = props => createElement('circle', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'g'>} props
*
* @return {JSX.Element} G component
*/
export const G = props => createElement('g', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'line'>} props
*
* @return {JSX.Element} Path component
*/
export const Line = props => createElement('line', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'path'>} props
*
* @return {JSX.Element} Path component
*/
export const Path = props => createElement('path', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'polygon'>} props
*
* @return {JSX.Element} Polygon component
*/
export const Polygon = props => createElement('polygon', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'rect'>} props
*
* @return {JSX.Element} Rect component
*/
export const Rect = props => createElement('rect', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'defs'>} props
*
* @return {JSX.Element} Defs component
*/
export const Defs = props => createElement('defs', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'radialGradient'>} props
*
* @return {JSX.Element} RadialGradient component
*/
export const RadialGradient = props => createElement('radialGradient', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'linearGradient'>} props
*
* @return {JSX.Element} LinearGradient component
*/
export const LinearGradient = props => createElement('linearGradient', props);
/**
* @param {import('react').ComponentPropsWithoutRef<'stop'>} props
*
* @return {JSX.Element} Stop component
*/
export const Stop = props => createElement('stop', props);
export const SVG = forwardRef(
/**
* @param {SVGProps} props isPressed indicates whether the SVG should appear as pressed.
* Other props will be passed through to svg component.
* @param {import('react').ForwardedRef<SVGSVGElement>} ref The forwarded ref to the SVG element.
*
* @return {JSX.Element} Stop component
*/
({
className,
isPressed,
...props
}, ref) => {
const appliedProps = {
...props,
className: clsx(className, {
'is-pressed': isPressed
}) || undefined,
'aria-hidden': true,
focusable: false
};
// Disable reason: We need to have a way to render HTML tag for web.
// eslint-disable-next-line react/forbid-elements
return createElement("svg", {
...appliedProps,
ref: ref
});
});
SVG.displayName = 'SVG';
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,53 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { Svg } from 'react-native-svg';
import { Animated } from 'react-native';
/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';
import { usePreferredColorScheme } from '@wordpress/compose';
/**
* Internal dependencies
*/
import styles from './style.scss';
export { Circle, G, Path, Polygon, Rect, Defs, RadialGradient, LinearGradient, Stop, Line, SvgXml } from 'react-native-svg';
const AnimatedSvg = Animated.createAnimatedComponent(forwardRef((props, ref) => createElement(Svg, {
ref: ref,
...props
})));
export const SVG = ({
className = '',
isPressed,
animated = false,
...props
}) => {
const colorScheme = usePreferredColorScheme();
const stylesFromClasses = className.split(' ').map(element => styles[element]).filter(Boolean);
const defaultStyle = isPressed ? styles[`is-pressed--${colorScheme}`] : styles['components-toolbar__control-' + colorScheme];
const propStyle = Array.isArray(props.style) ? props.style.reduce((acc, el) => {
return {
...acc,
...el
};
}, {}) : props.style;
const styleValues = Object.assign({}, defaultStyle, propStyle, ...stylesFromClasses);
const appliedProps = {
...props,
style: styleValues
};
const SvgWrapper = animated ? AnimatedSvg : Svg;
return createElement(SvgWrapper
// We want to re-render when style color is changed.
, {
key: appliedProps.style.color,
height: "100%",
width: "100%",
...appliedProps
});
};
//# sourceMappingURL=index.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Svg","Animated","forwardRef","usePreferredColorScheme","styles","Circle","G","Path","Polygon","Rect","Defs","RadialGradient","LinearGradient","Stop","Line","SvgXml","AnimatedSvg","createAnimatedComponent","props","ref","createElement","SVG","className","isPressed","animated","colorScheme","stylesFromClasses","split","map","element","filter","Boolean","defaultStyle","propStyle","Array","isArray","style","reduce","acc","el","styleValues","Object","assign","appliedProps","SvgWrapper","key","color","height","width"],"sources":["@wordpress/primitives/src/svg/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Svg } from 'react-native-svg';\nimport { Animated } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { usePreferredColorScheme } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport {\n\tCircle,\n\tG,\n\tPath,\n\tPolygon,\n\tRect,\n\tDefs,\n\tRadialGradient,\n\tLinearGradient,\n\tStop,\n\tLine,\n\tSvgXml,\n} from 'react-native-svg';\n\nconst AnimatedSvg = Animated.createAnimatedComponent(\n\tforwardRef( ( props, ref ) => <Svg ref={ ref } { ...props } /> )\n);\n\nexport const SVG = ( {\n\tclassName = '',\n\tisPressed,\n\tanimated = false,\n\t...props\n} ) => {\n\tconst colorScheme = usePreferredColorScheme();\n\tconst stylesFromClasses = className\n\t\t.split( ' ' )\n\t\t.map( ( element ) => styles[ element ] )\n\t\t.filter( Boolean );\n\tconst defaultStyle = isPressed\n\t\t? styles[ `is-pressed--${ colorScheme }` ]\n\t\t: styles[ 'components-toolbar__control-' + colorScheme ];\n\tconst propStyle = Array.isArray( props.style )\n\t\t? props.style.reduce( ( acc, el ) => {\n\t\t\t\treturn { ...acc, ...el };\n\t\t }, {} )\n\t\t: props.style;\n\tconst styleValues = Object.assign(\n\t\t{},\n\t\tdefaultStyle,\n\t\tpropStyle,\n\t\t...stylesFromClasses\n\t);\n\n\tconst appliedProps = { ...props, style: styleValues };\n\n\tconst SvgWrapper = animated ? AnimatedSvg : Svg;\n\n\treturn (\n\t\t<SvgWrapper\n\t\t\t// We want to re-render when style color is changed.\n\t\t\tkey={ appliedProps.style.color }\n\t\t\theight=\"100%\"\n\t\t\twidth=\"100%\"\n\t\t\t{ ...appliedProps }\n\t\t/>\n\t);\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,GAAG,QAAQ,kBAAkB;AACtC,SAASC,QAAQ,QAAQ,cAAc;;AAEvC;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,uBAAuB,QAAQ,oBAAoB;;AAE5D;AACA;AACA;AACA,OAAOC,MAAM,MAAM,cAAc;AAEjC,SACCC,MAAM,EACNC,CAAC,EACDC,IAAI,EACJC,OAAO,EACPC,IAAI,EACJC,IAAI,EACJC,cAAc,EACdC,cAAc,EACdC,IAAI,EACJC,IAAI,EACJC,MAAM,QACA,kBAAkB;AAEzB,MAAMC,WAAW,GAAGf,QAAQ,CAACgB,uBAAuB,CACnDf,UAAU,CAAE,CAAEgB,KAAK,EAAEC,GAAG,KAAMC,aAAA,CAACpB,GAAG;EAACmB,GAAG,EAAGA,GAAK;EAAA,GAAMD;AAAK,CAAI,CAAE,CAChE,CAAC;AAED,OAAO,MAAMG,GAAG,GAAGA,CAAE;EACpBC,SAAS,GAAG,EAAE;EACdC,SAAS;EACTC,QAAQ,GAAG,KAAK;EAChB,GAAGN;AACJ,CAAC,KAAM;EACN,MAAMO,WAAW,GAAGtB,uBAAuB,CAAC,CAAC;EAC7C,MAAMuB,iBAAiB,GAAGJ,SAAS,CACjCK,KAAK,CAAE,GAAI,CAAC,CACZC,GAAG,CAAIC,OAAO,IAAMzB,MAAM,CAAEyB,OAAO,CAAG,CAAC,CACvCC,MAAM,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