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>
86 lines
2.2 KiB
JavaScript
86 lines
2.2 KiB
JavaScript
import { createElement, Fragment } from "react";
|
|
/**
|
|
* External dependencies
|
|
*/
|
|
import classnames from 'classnames';
|
|
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import Icon from '../icon';
|
|
import SelectControl from '../select-control';
|
|
import sizesTable, { findSizeBySlug } from './sizes';
|
|
/**
|
|
* `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 }
|
|
* />
|
|
* );
|
|
* }
|
|
* ```
|
|
*/
|
|
export function DimensionControl(props) {
|
|
const {
|
|
__next40pxDefaultSize = false,
|
|
label,
|
|
value,
|
|
sizes = sizesTable,
|
|
icon,
|
|
onChange,
|
|
className = ''
|
|
} = props;
|
|
const onChangeSpacingSize = val => {
|
|
const theSize = 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: __('Default'),
|
|
value: ''
|
|
}, ...options];
|
|
};
|
|
const selectLabel = createElement(Fragment, null, icon && createElement(Icon, {
|
|
icon: icon
|
|
}), label);
|
|
return createElement(SelectControl, {
|
|
__next40pxDefaultSize: __next40pxDefaultSize,
|
|
className: classnames(className, 'block-editor-dimension-control'),
|
|
label: selectLabel,
|
|
hideLabelFromVision: false,
|
|
value: value,
|
|
onChange: onChangeSpacingSize,
|
|
options: formatSizesAsOptions(sizes)
|
|
});
|
|
}
|
|
export default DimensionControl;
|
|
//# sourceMappingURL=index.js.map
|