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,41 @@
import { createElement, Fragment } from "react";
/**
* WordPress dependencies
*/
import { createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
import { escapeRegExp } from '../utils/strings';
/**
* Highlights occurrences of a given string within another string of text. Wraps
* each match with a `<mark>` tag which provides browser default styling.
*
* ```jsx
* import { TextHighlight } from '@wordpress/components';
*
* const MyTextHighlight = () => (
* <TextHighlight
* text="Why do we like Gutenberg? Because Gutenberg is the best!"
* highlight="Gutenberg"
* />
* );
* ```
*/
export const TextHighlight = props => {
const {
text = '',
highlight = ''
} = props;
const trimmedHighlightText = highlight.trim();
if (!trimmedHighlightText) {
return createElement(Fragment, null, text);
}
const regex = new RegExp(`(${escapeRegExp(trimmedHighlightText)})`, 'gi');
return createInterpolateElement(text.replace(regex, '<mark>$&</mark>'), {
mark: createElement("mark", null)
});
};
export default TextHighlight;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createInterpolateElement","escapeRegExp","TextHighlight","props","text","highlight","trimmedHighlightText","trim","createElement","Fragment","regex","RegExp","replace","mark"],"sources":["@wordpress/components/src/text-highlight/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { escapeRegExp } from '../utils/strings';\nimport type { TextHighlightProps } from './types';\n\n/**\n * Highlights occurrences of a given string within another string of text. Wraps\n * each match with a `<mark>` tag which provides browser default styling.\n *\n * ```jsx\n * import { TextHighlight } from '@wordpress/components';\n *\n * const MyTextHighlight = () => (\n * <TextHighlight\n * text=\"Why do we like Gutenberg? Because Gutenberg is the best!\"\n * highlight=\"Gutenberg\"\n * />\n * );\n * ```\n */\nexport const TextHighlight = ( props: TextHighlightProps ) => {\n\tconst { text = '', highlight = '' } = props;\n\tconst trimmedHighlightText = highlight.trim();\n\n\tif ( ! trimmedHighlightText ) {\n\t\treturn <>{ text }</>;\n\t}\n\n\tconst regex = new RegExp(\n\t\t`(${ escapeRegExp( trimmedHighlightText ) })`,\n\t\t'gi'\n\t);\n\n\treturn createInterpolateElement( text.replace( regex, '<mark>$&</mark>' ), {\n\t\tmark: <mark />,\n\t} );\n};\n\nexport default TextHighlight;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,wBAAwB,QAAQ,oBAAoB;;AAE7D;AACA;AACA;AACA,SAASC,YAAY,QAAQ,kBAAkB;AAG/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAKC,KAAyB,IAAM;EAC7D,MAAM;IAAEC,IAAI,GAAG,EAAE;IAAEC,SAAS,GAAG;EAAG,CAAC,GAAGF,KAAK;EAC3C,MAAMG,oBAAoB,GAAGD,SAAS,CAACE,IAAI,CAAC,CAAC;EAE7C,IAAK,CAAED,oBAAoB,EAAG;IAC7B,OAAOE,aAAA,CAAAC,QAAA,QAAIL,IAAQ,CAAC;EACrB;EAEA,MAAMM,KAAK,GAAG,IAAIC,MAAM,CACtB,IAAIV,YAAY,CAAEK,oBAAqB,CAAG,GAAE,EAC7C,IACD,CAAC;EAED,OAAON,wBAAwB,CAAEI,IAAI,CAACQ,OAAO,CAAEF,KAAK,EAAE,iBAAkB,CAAC,EAAE;IAC1EG,IAAI,EAAEL,aAAA,aAAO;EACd,CAAE,CAAC;AACJ,CAAC;AAED,eAAeN,aAAa"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/text-highlight/types.ts"],"sourcesContent":["export type TextHighlightProps = {\n\t/**\n\t * The string to search for and highlight within the `text`. Case\n\t * insensitive. Multiple matches.\n\t *\n\t * @default ''\n\t */\n\thighlight: string;\n\t/**\n\t * The string of text to be tested for occurrences of then given\n\t * `highlight`.\n\t *\n\t * @default ''\n\t */\n\ttext: string;\n};\n"],"mappings":""}