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,98 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DimensionControl = DimensionControl;
exports.default = void 0;
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
var _i18n = require("@wordpress/i18n");
var _icon = _interopRequireDefault(require("../icon"));
var _selectControl = _interopRequireDefault(require("../select-control"));
var _sizes = _interopRequireWildcard(require("./sizes"));
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; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* `DimensionControl` is a component designed to provide a UI to control spacing and/or dimensions.
*
* This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
*
* ```jsx
* import { __experimentalDimensionControl as DimensionControl } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* export default function MyCustomDimensionControl() {
* const [ paddingSize, setPaddingSize ] = useState( '' );
*
* return (
* <DimensionControl
* label={ 'Padding' }
* icon={ 'desktop' }
* onChange={ ( value ) => setPaddingSize( value ) }
* value={ paddingSize }
* />
* );
* }
* ```
*/
function DimensionControl(props) {
const {
__next40pxDefaultSize = false,
label,
value,
sizes = _sizes.default,
icon,
onChange,
className = ''
} = props;
const onChangeSpacingSize = val => {
const theSize = (0, _sizes.findSizeBySlug)(sizes, val);
if (!theSize || value === theSize.slug) {
onChange?.(undefined);
} else if (typeof onChange === 'function') {
onChange(theSize.slug);
}
};
const formatSizesAsOptions = theSizes => {
const options = theSizes.map(({
name,
slug
}) => ({
label: name,
value: slug
}));
return [{
label: (0, _i18n.__)('Default'),
value: ''
}, ...options];
};
const selectLabel = (0, _react.createElement)(_react.Fragment, null, icon && (0, _react.createElement)(_icon.default, {
icon: icon
}), label);
return (0, _react.createElement)(_selectControl.default, {
__next40pxDefaultSize: __next40pxDefaultSize,
className: (0, _classnames.default)(className, 'block-editor-dimension-control'),
label: selectLabel,
hideLabelFromVision: false,
value: value,
onChange: onChangeSpacingSize,
options: formatSizesAsOptions(sizes)
});
}
var _default = DimensionControl;
exports.default = _default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findSizeBySlug = exports.default = void 0;
var _i18n = require("@wordpress/i18n");
/**
* Sizes
*
* defines the sizes used in dimension controls
* all hardcoded `size` values are based on the value of
* the Sass variable `$block-padding` from
* `packages/block-editor/src/components/dimension-control/sizes.js`.
*/
/**
* WordPress dependencies
*/
/**
* Finds the correct size object from the provided sizes
* table by size slug (eg: `medium`)
*
* @param sizes containing objects for each size definition.
* @param slug a string representation of the size (eg: `medium`).
*/
const findSizeBySlug = (sizes, slug) => sizes.find(size => slug === size.slug);
exports.findSizeBySlug = findSizeBySlug;
var _default = [{
name: (0, _i18n._x)('None', 'Size of a UI element'),
slug: 'none'
}, {
name: (0, _i18n._x)('Small', 'Size of a UI element'),
slug: 'small'
}, {
name: (0, _i18n._x)('Medium', 'Size of a UI element'),
slug: 'medium'
}, {
name: (0, _i18n._x)('Large', 'Size of a UI element'),
slug: 'large'
}, {
name: (0, _i18n._x)('Extra Large', 'Size of a UI element'),
slug: 'xlarge'
}];
exports.default = _default;
//# sourceMappingURL=sizes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_i18n","require","findSizeBySlug","sizes","slug","find","size","exports","_default","name","_x","default"],"sources":["@wordpress/components/src/dimension-control/sizes.ts"],"sourcesContent":["/**\n * Sizes\n *\n * defines the sizes used in dimension controls\n * all hardcoded `size` values are based on the value of\n * the Sass variable `$block-padding` from\n * `packages/block-editor/src/components/dimension-control/sizes.js`.\n */\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { Size } from './types';\n\n/**\n * Finds the correct size object from the provided sizes\n * table by size slug (eg: `medium`)\n *\n * @param sizes containing objects for each size definition.\n * @param slug a string representation of the size (eg: `medium`).\n */\nexport const findSizeBySlug = ( sizes: Size[], slug: string ) =>\n\tsizes.find( ( size ) => slug === size.slug );\n\nexport default [\n\t{\n\t\tname: _x( 'None', 'Size of a UI element' ),\n\t\tslug: 'none',\n\t},\n\t{\n\t\tname: _x( 'Small', 'Size of a UI element' ),\n\t\tslug: 'small',\n\t},\n\t{\n\t\tname: _x( 'Medium', 'Size of a UI element' ),\n\t\tslug: 'medium',\n\t},\n\t{\n\t\tname: _x( 'Large', 'Size of a UI element' ),\n\t\tslug: 'large',\n\t},\n\t{\n\t\tname: _x( 'Extra Large', 'Size of a UI element' ),\n\t\tslug: 'xlarge',\n\t},\n];\n"],"mappings":";;;;;;AAYA,IAAAA,KAAA,GAAAC,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAGA,CAAEC,KAAa,EAAEC,IAAY,KAC1DD,KAAK,CAACE,IAAI,CAAIC,IAAI,IAAMF,IAAI,KAAKE,IAAI,CAACF,IAAK,CAAC;AAACG,OAAA,CAAAL,cAAA,GAAAA,cAAA;AAAA,IAAAM,QAAA,GAE/B,CACd;EACCC,IAAI,EAAE,IAAAC,QAAE,EAAE,MAAM,EAAE,sBAAuB,CAAC;EAC1CN,IAAI,EAAE;AACP,CAAC,EACD;EACCK,IAAI,EAAE,IAAAC,QAAE,EAAE,OAAO,EAAE,sBAAuB,CAAC;EAC3CN,IAAI,EAAE;AACP,CAAC,EACD;EACCK,IAAI,EAAE,IAAAC,QAAE,EAAE,QAAQ,EAAE,sBAAuB,CAAC;EAC5CN,IAAI,EAAE;AACP,CAAC,EACD;EACCK,IAAI,EAAE,IAAAC,QAAE,EAAE,OAAO,EAAE,sBAAuB,CAAC;EAC3CN,IAAI,EAAE;AACP,CAAC,EACD;EACCK,IAAI,EAAE,IAAAC,QAAE,EAAE,aAAa,EAAE,sBAAuB,CAAC;EACjDN,IAAI,EAAE;AACP,CAAC,CACD;AAAAG,OAAA,CAAAI,OAAA,GAAAH,QAAA"}

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/dimension-control/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { IconType } from '../icon';\n\nexport type Size = {\n\t/**\n\t * Human-readable name of the size.\n\t */\n\tname: string;\n\t/**\n\t * Short unique identifying name of the size.\n\t */\n\tslug: string;\n};\n\nexport type DimensionControlProps = {\n\t/**\n\t * Label for the control.\n\t */\n\tlabel: string;\n\t/**\n\t * An array of sizes to choose from.\n\t *\n\t * @default DEFAULT_SIZES\n\t *\n\t * @see packages/components/src/dimension-control/sizes.ts\n\t */\n\tsizes?: Size[];\n\t/**\n\t * Optional icon rendered in front on the label.\n\t */\n\ticon?: IconType;\n\t/**\n\t * Used to externally control the current value of the control.\n\t */\n\tvalue?: string;\n\t/**\n\t * Function called with the control's internal state changes. The `value` property is equal to a given size slug.\n\t */\n\tonChange?: ( value?: string ) => void;\n\t/**\n\t * CSS class applied to `SelectControl`.\n\t *\n\t * @default ''\n\t */\n\tclassName?: string;\n\t/**\n\t * Start opting into the larger default height that will become the default size in a future version.\n\t *\n\t * @default false\n\t */\n\t__next40pxDefaultSize?: boolean;\n};\n"],"mappings":""}