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,42 @@
import { createElement } from "react";
/**
* External dependencies
*/
/**
* Internal dependencies
*/
import { contextConnect } from '../context';
import { View } from '../view';
import { useSurface } from './hook';
function UnconnectedSurface(props, forwardedRef) {
const surfaceProps = useSurface(props);
return createElement(View, {
...surfaceProps,
ref: forwardedRef
});
}
/**
* `Surface` is a core component that renders a primary background color.
*
* In the example below, notice how the `Surface` renders in white (or dark gray if in dark mode).
*
* ```jsx
* import {
* __experimentalSurface as Surface,
* __experimentalText as Text,
* } from '@wordpress/components';
*
* function Example() {
* return (
* <Surface>
* <Text>Code is Poetry</Text>
* </Surface>
* );
* }
* ```
*/
export const Surface = contextConnect(UnconnectedSurface, 'Surface');
export default Surface;
//# sourceMappingURL=component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["contextConnect","View","useSurface","UnconnectedSurface","props","forwardedRef","surfaceProps","createElement","ref","Surface"],"sources":["@wordpress/components/src/surface/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { contextConnect } from '../context';\nimport { View } from '../view';\nimport { useSurface } from './hook';\nimport type { SurfaceProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nfunction UnconnectedSurface(\n\tprops: WordPressComponentProps< SurfaceProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst surfaceProps = useSurface( props );\n\n\treturn <View { ...surfaceProps } ref={ forwardedRef } />;\n}\n\n/**\n * `Surface` is a core component that renders a primary background color.\n *\n * In the example below, notice how the `Surface` renders in white (or dark gray if in dark mode).\n *\n * ```jsx\n * import {\n *\t__experimentalSurface as Surface,\n *\t__experimentalText as Text,\n * } from '@wordpress/components';\n *\n * function Example() {\n * \treturn (\n * \t\t<Surface>\n * \t\t\t<Text>Code is Poetry</Text>\n * \t\t</Surface>\n * \t);\n * }\n * ```\n */\nexport const Surface = contextConnect( UnconnectedSurface, 'Surface' );\n\nexport default Surface;\n"],"mappings":";AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,YAAY;AAC3C,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,UAAU,QAAQ,QAAQ;AAInC,SAASC,kBAAkBA,CAC1BC,KAAqD,EACrDC,YAAiC,EAChC;EACD,MAAMC,YAAY,GAAGJ,UAAU,CAAEE,KAAM,CAAC;EAExC,OAAOG,aAAA,CAACN,IAAI;IAAA,GAAMK,YAAY;IAAGE,GAAG,EAAGH;EAAc,CAAE,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,OAAO,GAAGT,cAAc,CAAEG,kBAAkB,EAAE,SAAU,CAAC;AAEtE,eAAeM,OAAO"}

View File

@@ -0,0 +1,40 @@
/**
* WordPress dependencies
*/
import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useContextSystem } from '../context';
import * as styles from './styles';
import { useCx } from '../utils/hooks/use-cx';
export function useSurface(props) {
const {
backgroundSize = 12,
borderBottom = false,
borderLeft = false,
borderRight = false,
borderTop = false,
className,
variant = 'primary',
...otherProps
} = useContextSystem(props, 'Surface');
const cx = useCx();
const classes = useMemo(() => {
const sx = {
borders: styles.getBorders({
borderBottom,
borderLeft,
borderRight,
borderTop
})
};
return cx(styles.Surface, sx.borders, styles.getVariant(variant, `${backgroundSize}px`, `${backgroundSize - 1}px`), className);
}, [backgroundSize, borderBottom, borderLeft, borderRight, borderTop, className, cx, variant]);
return {
...otherProps,
className: classes
};
}
//# sourceMappingURL=hook.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useMemo","useContextSystem","styles","useCx","useSurface","props","backgroundSize","borderBottom","borderLeft","borderRight","borderTop","className","variant","otherProps","cx","classes","sx","borders","getBorders","Surface","getVariant"],"sources":["@wordpress/components/src/surface/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useContextSystem } from '../context';\nimport * as styles from './styles';\nimport { useCx } from '../utils/hooks/use-cx';\nimport type { SurfaceProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nexport function useSurface(\n\tprops: WordPressComponentProps< SurfaceProps, 'div' >\n) {\n\tconst {\n\t\tbackgroundSize = 12,\n\t\tborderBottom = false,\n\t\tborderLeft = false,\n\t\tborderRight = false,\n\t\tborderTop = false,\n\t\tclassName,\n\t\tvariant = 'primary',\n\t\t...otherProps\n\t} = useContextSystem( props, 'Surface' );\n\n\tconst cx = useCx();\n\n\tconst classes = useMemo( () => {\n\t\tconst sx = {\n\t\t\tborders: styles.getBorders( {\n\t\t\t\tborderBottom,\n\t\t\t\tborderLeft,\n\t\t\t\tborderRight,\n\t\t\t\tborderTop,\n\t\t\t} ),\n\t\t};\n\n\t\treturn cx(\n\t\t\tstyles.Surface,\n\t\t\tsx.borders,\n\t\t\tstyles.getVariant(\n\t\t\t\tvariant,\n\t\t\t\t`${ backgroundSize }px`,\n\t\t\t\t`${ backgroundSize - 1 }px`\n\t\t\t),\n\t\t\tclassName\n\t\t);\n\t}, [\n\t\tbackgroundSize,\n\t\tborderBottom,\n\t\tborderLeft,\n\t\tborderRight,\n\t\tborderTop,\n\t\tclassName,\n\t\tcx,\n\t\tvariant,\n\t] );\n\n\treturn { ...otherProps, className: classes };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,OAAO,KAAKC,MAAM,MAAM,UAAU;AAClC,SAASC,KAAK,QAAQ,uBAAuB;AAI7C,OAAO,SAASC,UAAUA,CACzBC,KAAqD,EACpD;EACD,MAAM;IACLC,cAAc,GAAG,EAAE;IACnBC,YAAY,GAAG,KAAK;IACpBC,UAAU,GAAG,KAAK;IAClBC,WAAW,GAAG,KAAK;IACnBC,SAAS,GAAG,KAAK;IACjBC,SAAS;IACTC,OAAO,GAAG,SAAS;IACnB,GAAGC;EACJ,CAAC,GAAGZ,gBAAgB,CAAEI,KAAK,EAAE,SAAU,CAAC;EAExC,MAAMS,EAAE,GAAGX,KAAK,CAAC,CAAC;EAElB,MAAMY,OAAO,GAAGf,OAAO,CAAE,MAAM;IAC9B,MAAMgB,EAAE,GAAG;MACVC,OAAO,EAAEf,MAAM,CAACgB,UAAU,CAAE;QAC3BX,YAAY;QACZC,UAAU;QACVC,WAAW;QACXC;MACD,CAAE;IACH,CAAC;IAED,OAAOI,EAAE,CACRZ,MAAM,CAACiB,OAAO,EACdH,EAAE,CAACC,OAAO,EACVf,MAAM,CAACkB,UAAU,CAChBR,OAAO,EACN,GAAGN,cAAgB,IAAG,EACtB,GAAGA,cAAc,GAAG,CAAG,IACzB,CAAC,EACDK,SACD,CAAC;EACF,CAAC,EAAE,CACFL,cAAc,EACdC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,SAAS,EACTG,EAAE,EACFF,OAAO,CACN,CAAC;EAEH,OAAO;IAAE,GAAGC,UAAU;IAAEF,SAAS,EAAEI;EAAQ,CAAC;AAC7C"}

View File

@@ -0,0 +1,3 @@
export { default as Surface } from './component';
export * from './hook';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["default","Surface"],"sources":["@wordpress/components/src/surface/index.ts"],"sourcesContent":["export { default as Surface } from './component';\nexport * from './hook';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,OAAO,QAAQ,aAAa;AAChD,cAAc,QAAQ"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/surface/types.ts"],"sourcesContent":["export type SurfaceVariant =\n\t| 'primary'\n\t| 'secondary'\n\t| 'tertiary'\n\t| 'dotted'\n\t| 'grid';\n\nexport type SurfaceProps = {\n\t/**\n\t * Determines the grid size for \"dotted\" and \"grid\" variants.\n\t *\n\t * @default 12\n\t */\n\tbackgroundSize?: number;\n\t/**\n\t * Renders a bottom border.\n\t *\n\t * @default false\n\t */\n\tborderBottom?: boolean;\n\t/**\n\t * Renders a left border.\n\t *\n\t * @default false\n\t */\n\tborderLeft?: boolean;\n\t/**\n\t * Renders a right border.\n\t *\n\t * @default false\n\t */\n\tborderRight?: boolean;\n\t/**\n\t * Renders a top border.\n\t *\n\t * @default false\n\t */\n\tborderTop?: boolean;\n\t/**\n\t * Modifies the background color of `Surface`.\n\t *\n\t * * `primary`: Used for almost all cases.\n\t * * `secondary`: Used as a secondary background for inner `Surface` components.\n\t * * `tertiary`: Used as the app/site wide background. Visible in **dark mode** only. Use case is rare.\n\t * * `grid`: Used to show a grid.\n\t * * `dotted`: Used to show a dots grid.\n\t *\n\t * @default 'primary'\n\t */\n\tvariant?: SurfaceVariant;\n\t/**\n\t * The children elements.\n\t */\n\tchildren: React.ReactNode;\n};\n"],"mappings":""}