Files
formipay/node_modules/@wordpress/components/build/radio-control/index.js
dwindown e8fbfb14c1 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>
2026-04-18 17:02:14 +07:00

97 lines
2.6 KiB
JavaScript

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RadioControl = RadioControl;
exports.default = void 0;
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
var _compose = require("@wordpress/compose");
var _baseControl = _interopRequireDefault(require("../base-control"));
var _vStack = require("../v-stack");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Render a user interface to select the user type using radio inputs.
*
* ```jsx
* import { RadioControl } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const MyRadioControl = () => {
* const [ option, setOption ] = useState( 'a' );
*
* return (
* <RadioControl
* label="User type"
* help="The type of the current user"
* selected={ option }
* options={ [
* { label: 'Author', value: 'a' },
* { label: 'Editor', value: 'e' },
* ] }
* onChange={ ( value ) => setOption( value ) }
* />
* );
* };
* ```
*/
function RadioControl(props) {
const {
label,
className,
selected,
help,
onChange,
hideLabelFromVision,
options = [],
...additionalProps
} = props;
const instanceId = (0, _compose.useInstanceId)(RadioControl);
const id = `inspector-radio-control-${instanceId}`;
const onChangeValue = event => onChange(event.target.value);
if (!options?.length) {
return null;
}
return (0, _react.createElement)(_baseControl.default, {
__nextHasNoMarginBottom: true,
label: label,
id: id,
hideLabelFromVision: hideLabelFromVision,
help: help,
className: (0, _classnames.default)(className, 'components-radio-control')
}, (0, _react.createElement)(_vStack.VStack, {
spacing: 1
}, options.map((option, index) => (0, _react.createElement)("div", {
key: `${id}-${index}`,
className: "components-radio-control__option"
}, (0, _react.createElement)("input", {
id: `${id}-${index}`,
className: "components-radio-control__input",
type: "radio",
name: id,
value: option.value,
onChange: onChangeValue,
checked: option.value === selected,
"aria-describedby": !!help ? `${id}__help` : undefined,
...additionalProps
}), (0, _react.createElement)("label", {
className: "components-radio-control__label",
htmlFor: `${id}-${index}`
}, option.label)))));
}
var _default = RadioControl;
exports.default = _default;
//# sourceMappingURL=index.js.map