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 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Heading = void 0;
var _react = require("react");
var _context = require("../context");
var _view = require("../view");
var _hook = require("./hook");
/**
* External dependencies
*/
/**
* Internal dependencies
*/
function UnconnectedHeading(props, forwardedRef) {
const headerProps = (0, _hook.useHeading)(props);
return (0, _react.createElement)(_view.View, {
...headerProps,
ref: forwardedRef
});
}
/**
* `Heading` renders headings and titles using the library's typography system.
*
* ```jsx
* import { __experimentalHeading as Heading } from "@wordpress/components";
*
* function Example() {
* return <Heading>Code is Poetry</Heading>;
* }
* ```
*/
const Heading = (0, _context.contextConnect)(UnconnectedHeading, 'Heading');
exports.Heading = Heading;
var _default = Heading;
exports.default = _default;
//# sourceMappingURL=component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_context","require","_view","_hook","UnconnectedHeading","props","forwardedRef","headerProps","useHeading","_react","createElement","View","ref","Heading","contextConnect","exports","_default","default"],"sources":["@wordpress/components/src/heading/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../context';\nimport { contextConnect } from '../context';\nimport { View } from '../view';\nimport { useHeading } from './hook';\nimport type { HeadingProps } from './types';\n\nfunction UnconnectedHeading(\n\tprops: WordPressComponentProps< HeadingProps, 'h1' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst headerProps = useHeading( props );\n\n\treturn <View { ...headerProps } ref={ forwardedRef } />;\n}\n\n/**\n * `Heading` renders headings and titles using the library's typography system.\n *\n * ```jsx\n * import { __experimentalHeading as Heading } from \"@wordpress/components\";\n *\n * function Example() {\n * return <Heading>Code is Poetry</Heading>;\n * }\n * ```\n */\nexport const Heading = contextConnect( UnconnectedHeading, 'Heading' );\n\nexport default Heading;\n"],"mappings":";;;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAOA,SAASG,kBAAkBA,CAC1BC,KAAoD,EACpDC,YAAiC,EAChC;EACD,MAAMC,WAAW,GAAG,IAAAC,gBAAU,EAAEH,KAAM,CAAC;EAEvC,OAAO,IAAAI,MAAA,CAAAC,aAAA,EAACR,KAAA,CAAAS,IAAI;IAAA,GAAMJ,WAAW;IAAGK,GAAG,EAAGN;EAAc,CAAE,CAAC;AACxD;;AAEA;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,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useHeading = useHeading;
var _context = require("../context");
var _text = require("../text");
var _fontSize = require("../utils/font-size");
var _utils = require("../utils");
/**
* Internal dependencies
*/
function useHeading(props) {
const {
as: asProp,
level = 2,
color = _utils.COLORS.gray[900],
isBlock = true,
weight = _utils.CONFIG.fontWeightHeading,
...otherProps
} = (0, _context.useContextSystem)(props, 'Heading');
const as = asProp || `h${level}`;
const a11yProps = {};
if (typeof as === 'string' && as[0] !== 'h') {
// If not a semantic `h` element, add a11y props:
a11yProps.role = 'heading';
a11yProps['aria-level'] = typeof level === 'string' ? parseInt(level) : level;
}
const textProps = (0, _text.useText)({
color,
isBlock,
weight,
size: (0, _fontSize.getHeadingFontSize)(level),
...otherProps
});
return {
...textProps,
...a11yProps,
as
};
}
//# sourceMappingURL=hook.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_context","require","_text","_fontSize","_utils","useHeading","props","as","asProp","level","color","COLORS","gray","isBlock","weight","CONFIG","fontWeightHeading","otherProps","useContextSystem","a11yProps","role","parseInt","textProps","useText","size","getHeadingFontSize"],"sources":["@wordpress/components/src/heading/hook.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../context';\nimport { useContextSystem } from '../context';\nimport { useText } from '../text';\nimport { getHeadingFontSize } from '../utils/font-size';\nimport { CONFIG, COLORS } from '../utils';\nimport type { HeadingProps } from './types';\n\nexport function useHeading(\n\tprops: WordPressComponentProps< HeadingProps, 'h1' >\n) {\n\tconst {\n\t\tas: asProp,\n\t\tlevel = 2,\n\t\tcolor = COLORS.gray[ 900 ],\n\t\tisBlock = true,\n\t\tweight = CONFIG.fontWeightHeading as import('react').CSSProperties[ 'fontWeight' ],\n\t\t...otherProps\n\t} = useContextSystem( props, 'Heading' );\n\n\tconst as = ( asProp || `h${ level }` ) as keyof JSX.IntrinsicElements;\n\n\tconst a11yProps: {\n\t\trole?: string;\n\t\t'aria-level'?: number;\n\t} = {};\n\tif ( typeof as === 'string' && as[ 0 ] !== 'h' ) {\n\t\t// If not a semantic `h` element, add a11y props:\n\t\ta11yProps.role = 'heading';\n\t\ta11yProps[ 'aria-level' ] =\n\t\t\ttypeof level === 'string' ? parseInt( level ) : level;\n\t}\n\n\tconst textProps = useText( {\n\t\tcolor,\n\t\tisBlock,\n\t\tweight,\n\t\tsize: getHeadingFontSize( level ),\n\t\t...otherProps,\n\t} );\n\n\treturn { ...textProps, ...a11yProps, as };\n}\n"],"mappings":";;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAPA;AACA;AACA;;AAQO,SAASI,UAAUA,CACzBC,KAAoD,EACnD;EACD,MAAM;IACLC,EAAE,EAAEC,MAAM;IACVC,KAAK,GAAG,CAAC;IACTC,KAAK,GAAGC,aAAM,CAACC,IAAI,CAAE,GAAG,CAAE;IAC1BC,OAAO,GAAG,IAAI;IACdC,MAAM,GAAGC,aAAM,CAACC,iBAAkE;IAClF,GAAGC;EACJ,CAAC,GAAG,IAAAC,yBAAgB,EAAEZ,KAAK,EAAE,SAAU,CAAC;EAExC,MAAMC,EAAE,GAAKC,MAAM,IAAK,IAAIC,KAAO,EAAkC;EAErE,MAAMU,SAGL,GAAG,CAAC,CAAC;EACN,IAAK,OAAOZ,EAAE,KAAK,QAAQ,IAAIA,EAAE,CAAE,CAAC,CAAE,KAAK,GAAG,EAAG;IAChD;IACAY,SAAS,CAACC,IAAI,GAAG,SAAS;IAC1BD,SAAS,CAAE,YAAY,CAAE,GACxB,OAAOV,KAAK,KAAK,QAAQ,GAAGY,QAAQ,CAAEZ,KAAM,CAAC,GAAGA,KAAK;EACvD;EAEA,MAAMa,SAAS,GAAG,IAAAC,aAAO,EAAE;IAC1Bb,KAAK;IACLG,OAAO;IACPC,MAAM;IACNU,IAAI,EAAE,IAAAC,4BAAkB,EAAEhB,KAAM,CAAC;IACjC,GAAGQ;EACJ,CAAE,CAAC;EAEH,OAAO;IAAE,GAAGK,SAAS;IAAE,GAAGH,SAAS;IAAEZ;EAAG,CAAC;AAC1C"}

View File

@@ -0,0 +1,21 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Heading", {
enumerable: true,
get: function () {
return _component.default;
}
});
Object.defineProperty(exports, "useHeading", {
enumerable: true,
get: function () {
return _hook.useHeading;
}
});
var _component = _interopRequireDefault(require("./component"));
var _hook = require("./hook");
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_component","_interopRequireDefault","require","_hook"],"sources":["@wordpress/components/src/heading/index.ts"],"sourcesContent":["export { default as Heading } from './component';\nexport { useHeading } from './hook';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA"}

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/heading/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Props as TextProps } from '../text/types';\n\nexport type HeadingSize =\n\t| 1\n\t| 2\n\t| 3\n\t| 4\n\t| 5\n\t| 6\n\t| '1'\n\t| '2'\n\t| '3'\n\t| '4'\n\t| '5'\n\t| '6';\n\nexport type HeadingProps = Omit<\n\tTextProps,\n\t'size' | 'isBlock' | 'color' | 'weight'\n> & {\n\t/**\n\t * Passing any of the heading levels to `level` will both render the correct\n\t * typographic text size as well as the semantic element corresponding to\n\t * the level (`h1` for `1` for example).\n\t *\n\t * @default 2\n\t */\n\tlevel?: HeadingSize;\n\t/**\n\t * Sets `Heading` to have `display: block`. Note: text truncation only works\n\t * when `isBlock` is `false`.\n\t *\n\t * @default true\n\t */\n\tisBlock?: TextProps[ 'isBlock' ];\n\t/**\n\t * Adjusts the text color.\n\t *\n\t * @default '#1e1e1e'\n\t */\n\tcolor?: TextProps[ 'color' ];\n\t/**\n\t * Adjusts font-weight of the text.\n\t *\n\t * @default '600'\n\t */\n\tweight?: TextProps[ 'weight' ];\n};\n"],"mappings":""}