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>
94 lines
2.8 KiB
JavaScript
94 lines
2.8 KiB
JavaScript
import { createElement, Fragment } from "react";
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { PanelBody, RadioControl, RangeControl } from '@wordpress/components';
|
|
import { __ } from '@wordpress/i18n';
|
|
import { useState } from '@wordpress/element';
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import { colorsUtils } from '../mobile/color-settings/utils';
|
|
import { getGradientAstWithDefault } from './utils';
|
|
import { serializeGradient } from './serializer';
|
|
import { DEFAULT_LINEAR_GRADIENT_ANGLE, HORIZONTAL_GRADIENT_ORIENTATION } from './constants';
|
|
import styles from './style.scss';
|
|
function CustomGradientPicker({
|
|
setColor,
|
|
currentValue,
|
|
isGradientColor
|
|
}) {
|
|
const [gradientOrientation, setGradientOrientation] = useState(HORIZONTAL_GRADIENT_ORIENTATION);
|
|
const [currentColor, setCurrentColor] = useState(currentValue);
|
|
const {
|
|
getGradientType,
|
|
gradients,
|
|
gradientOptions
|
|
} = colorsUtils;
|
|
const {
|
|
gradientAST
|
|
} = getGradientAstWithDefault(currentColor);
|
|
const gradientType = getGradientType(currentColor);
|
|
function isLinearGradient(type) {
|
|
return type === gradients.linear;
|
|
}
|
|
function getGradientColor(type) {
|
|
const {
|
|
orientation,
|
|
...restGradientAST
|
|
} = gradientAST;
|
|
if (orientation) {
|
|
setGradientOrientation(orientation);
|
|
}
|
|
return serializeGradient(isLinearGradient(type) ? {
|
|
...gradientAST,
|
|
...(gradientAST.orientation ? {} : {
|
|
orientation: gradientOrientation
|
|
}),
|
|
type
|
|
} : {
|
|
...restGradientAST,
|
|
type
|
|
});
|
|
}
|
|
function onGradientTypeChange(type) {
|
|
const gradientColor = getGradientColor(type);
|
|
setCurrentColor(gradientColor);
|
|
setColor(gradientColor);
|
|
}
|
|
function setGradientAngle(value) {
|
|
const gradientColor = serializeGradient({
|
|
...gradientAST,
|
|
orientation: {
|
|
type: 'angular',
|
|
value
|
|
}
|
|
});
|
|
if (isGradientColor && gradientColor !== currentColor) {
|
|
setCurrentColor(gradientColor);
|
|
setColor(gradientColor);
|
|
}
|
|
}
|
|
function getGradientAngle() {
|
|
var _gradientAST$orientat;
|
|
return (_gradientAST$orientat = gradientAST?.orientation?.value) !== null && _gradientAST$orientat !== void 0 ? _gradientAST$orientat : DEFAULT_LINEAR_GRADIENT_ANGLE;
|
|
}
|
|
return createElement(Fragment, null, createElement(PanelBody, {
|
|
title: __('Gradient Type')
|
|
}, createElement(RadioControl, {
|
|
selected: gradientType,
|
|
options: gradientOptions,
|
|
onChange: onGradientTypeChange
|
|
})), isLinearGradient(gradientType) && createElement(PanelBody, {
|
|
style: styles.angleControl
|
|
}, createElement(RangeControl, {
|
|
label: __('Angle'),
|
|
minimumValue: 0,
|
|
maximumValue: 360,
|
|
value: getGradientAngle(),
|
|
onChange: setGradientAngle
|
|
})));
|
|
}
|
|
export default CustomGradientPicker;
|
|
//# sourceMappingURL=index.native.js.map
|