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,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Surface = void 0;
var _react = require("react");
var _context = require("../context");
var _view = require("../view");
var _hook = require("./hook");
/**
* External dependencies
*/
/**
* Internal dependencies
*/
function UnconnectedSurface(props, forwardedRef) {
const surfaceProps = (0, _hook.useSurface)(props);
return (0, _react.createElement)(_view.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>
* );
* }
* ```
*/
const Surface = (0, _context.contextConnect)(UnconnectedSurface, 'Surface');
exports.Surface = Surface;
var _default = Surface;
exports.default = _default;
//# sourceMappingURL=component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_context","require","_view","_hook","UnconnectedSurface","props","forwardedRef","surfaceProps","useSurface","_react","createElement","View","ref","Surface","contextConnect","exports","_default","default"],"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":";;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAOA,SAASG,kBAAkBA,CAC1BC,KAAqD,EACrDC,YAAiC,EAChC;EACD,MAAMC,YAAY,GAAG,IAAAC,gBAAU,EAAEH,KAAM,CAAC;EAExC,OAAO,IAAAI,MAAA,CAAAC,aAAA,EAACR,KAAA,CAAAS,IAAI;IAAA,GAAMJ,YAAY;IAAGK,GAAG,EAAGN;EAAc,CAAE,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMO,OAAO,GAAG,IAAAC,uBAAc,EAAEV,kBAAkB,EAAE,SAAU,CAAC;AAACW,OAAA,CAAAF,OAAA,GAAAA,OAAA;AAAA,IAAAG,QAAA,GAExDH,OAAO;AAAAE,OAAA,CAAAE,OAAA,GAAAD,QAAA"}

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useSurface = useSurface;
var _element = require("@wordpress/element");
var _context = require("../context");
var styles = _interopRequireWildcard(require("./styles"));
var _useCx = require("../utils/hooks/use-cx");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function useSurface(props) {
const {
backgroundSize = 12,
borderBottom = false,
borderLeft = false,
borderRight = false,
borderTop = false,
className,
variant = 'primary',
...otherProps
} = (0, _context.useContextSystem)(props, 'Surface');
const cx = (0, _useCx.useCx)();
const classes = (0, _element.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":["_element","require","_context","styles","_interopRequireWildcard","_useCx","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","useSurface","props","backgroundSize","borderBottom","borderLeft","borderRight","borderTop","className","variant","otherProps","useContextSystem","cx","useCx","classes","useMemo","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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD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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,GAAG,IAAAC,yBAAgB,EAAET,KAAK,EAAE,SAAU,CAAC;EAExC,MAAMU,EAAE,GAAG,IAAAC,YAAK,EAAC,CAAC;EAElB,MAAMC,OAAO,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC9B,MAAMC,EAAE,GAAG;MACVC,OAAO,EAAEzC,MAAM,CAAC0C,UAAU,CAAE;QAC3Bd,YAAY;QACZC,UAAU;QACVC,WAAW;QACXC;MACD,CAAE;IACH,CAAC;IAED,OAAOK,EAAE,CACRpC,MAAM,CAAC2C,OAAO,EACdH,EAAE,CAACC,OAAO,EACVzC,MAAM,CAAC4C,UAAU,CAChBX,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,EACTI,EAAE,EACFH,OAAO,CACN,CAAC;EAEH,OAAO;IAAE,GAAGC,UAAU;IAAEF,SAAS,EAAEM;EAAQ,CAAC;AAC7C"}

View File

@@ -0,0 +1,29 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
Surface: true
};
Object.defineProperty(exports, "Surface", {
enumerable: true,
get: function () {
return _component.default;
}
});
var _component = _interopRequireDefault(require("./component"));
var _hook = require("./hook");
Object.keys(_hook).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _hook[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _hook[key];
}
});
});
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_component","_interopRequireDefault","require","_hook","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["@wordpress/components/src/surface/index.ts"],"sourcesContent":["export { default as Surface } from './component';\nexport * from './hook';\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA"}

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,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/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":""}