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>
72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
import { createElement } from "react";
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { useInstanceId } from '@wordpress/compose';
|
|
import { forwardRef } from '@wordpress/element';
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import BaseControl from '../base-control';
|
|
import { StyledTextarea } from './styles/textarea-control-styles';
|
|
function UnforwardedTextareaControl(props, ref) {
|
|
const {
|
|
__nextHasNoMarginBottom,
|
|
label,
|
|
hideLabelFromVision,
|
|
value,
|
|
help,
|
|
onChange,
|
|
rows = 4,
|
|
className,
|
|
...additionalProps
|
|
} = props;
|
|
const instanceId = useInstanceId(TextareaControl);
|
|
const id = `inspector-textarea-control-${instanceId}`;
|
|
const onChangeValue = event => onChange(event.target.value);
|
|
return createElement(BaseControl, {
|
|
__nextHasNoMarginBottom: __nextHasNoMarginBottom,
|
|
label: label,
|
|
hideLabelFromVision: hideLabelFromVision,
|
|
id: id,
|
|
help: help,
|
|
className: className
|
|
}, createElement(StyledTextarea, {
|
|
className: "components-textarea-control__input",
|
|
id: id,
|
|
rows: rows,
|
|
onChange: onChangeValue,
|
|
"aria-describedby": !!help ? id + '__help' : undefined,
|
|
value: value,
|
|
ref: ref,
|
|
...additionalProps
|
|
}));
|
|
}
|
|
|
|
/**
|
|
* TextareaControls are TextControls that allow for multiple lines of text, and
|
|
* wrap overflow text onto a new line. They are a fixed height and scroll
|
|
* vertically when the cursor reaches the bottom of the field.
|
|
*
|
|
* ```jsx
|
|
* import { TextareaControl } from '@wordpress/components';
|
|
* import { useState } from '@wordpress/element';
|
|
*
|
|
* const MyTextareaControl = () => {
|
|
* const [ text, setText ] = useState( '' );
|
|
*
|
|
* return (
|
|
* <TextareaControl
|
|
* label="Text"
|
|
* help="Enter some text"
|
|
* value={ text }
|
|
* onChange={ ( value ) => setText( value ) }
|
|
* />
|
|
* );
|
|
* };
|
|
* ```
|
|
*/
|
|
export const TextareaControl = forwardRef(UnforwardedTextareaControl);
|
|
export default TextareaControl;
|
|
//# sourceMappingURL=index.js.map
|