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>
71 lines
1.9 KiB
JavaScript
71 lines
1.9 KiB
JavaScript
import { createElement } from "react";
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import { StyledUnitControl, ControlWrapper } from './styles/focal-point-picker-style';
|
|
import { fractionToPercentage } from './utils';
|
|
const TEXTCONTROL_MIN = 0;
|
|
const TEXTCONTROL_MAX = 100;
|
|
const noop = () => {};
|
|
export default function FocalPointPickerControls({
|
|
__nextHasNoMarginBottom,
|
|
__next40pxDefaultSize,
|
|
hasHelpText,
|
|
onChange = noop,
|
|
point = {
|
|
x: 0.5,
|
|
y: 0.5
|
|
}
|
|
}) {
|
|
const valueX = fractionToPercentage(point.x);
|
|
const valueY = fractionToPercentage(point.y);
|
|
const handleChange = (value, axis) => {
|
|
if (value === undefined) return;
|
|
const num = parseInt(value, 10);
|
|
if (!isNaN(num)) {
|
|
onChange({
|
|
...point,
|
|
[axis]: num / 100
|
|
});
|
|
}
|
|
};
|
|
return createElement(ControlWrapper, {
|
|
className: "focal-point-picker__controls",
|
|
__nextHasNoMarginBottom: __nextHasNoMarginBottom,
|
|
hasHelpText: hasHelpText,
|
|
gap: 4
|
|
}, createElement(FocalPointUnitControl, {
|
|
__next40pxDefaultSize: __next40pxDefaultSize,
|
|
label: __('Left'),
|
|
"aria-label": __('Focal point left position'),
|
|
value: [valueX, '%'].join(''),
|
|
onChange: next => handleChange(next, 'x'),
|
|
dragDirection: "e"
|
|
}), createElement(FocalPointUnitControl, {
|
|
__next40pxDefaultSize: __next40pxDefaultSize,
|
|
label: __('Top'),
|
|
"aria-label": __('Focal point top position'),
|
|
value: [valueY, '%'].join(''),
|
|
onChange: next => handleChange(next, 'y'),
|
|
dragDirection: "s"
|
|
}));
|
|
}
|
|
function FocalPointUnitControl(props) {
|
|
return createElement(StyledUnitControl, {
|
|
className: "focal-point-picker__controls-position-unit-control",
|
|
labelPosition: "top",
|
|
max: TEXTCONTROL_MAX,
|
|
min: TEXTCONTROL_MIN,
|
|
units: [{
|
|
value: '%',
|
|
label: '%'
|
|
}],
|
|
...props
|
|
});
|
|
}
|
|
//# sourceMappingURL=controls.js.map
|