Files
formipay/node_modules/@wordpress/components/build-module/input-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

127 lines
3.5 KiB
JavaScript

import { createElement } from "react";
/**
* External dependencies
*/
import classNames from 'classnames';
/**
* WordPress dependencies
*/
import { useInstanceId } from '@wordpress/compose';
import { useState, forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import InputBase from './input-base';
import InputField from './input-field';
import { space } from '../utils/space';
import { useDraft } from './utils';
import BaseControl from '../base-control';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
const noop = () => {};
function useUniqueId(idProp) {
const instanceId = useInstanceId(InputControl);
const id = `inspector-input-control-${instanceId}`;
return idProp || id;
}
export function UnforwardedInputControl(props, ref) {
const {
__next40pxDefaultSize,
__unstableStateReducer: stateReducer = state => state,
__unstableInputWidth,
className,
disabled = false,
help,
hideLabelFromVision = false,
id: idProp,
isPressEnterToChange = false,
label,
labelPosition = 'top',
onChange = noop,
onValidate = noop,
onKeyDown = noop,
prefix,
size = 'default',
style,
suffix,
value,
...restProps
} = useDeprecated36pxDefaultSizeProp(props, 'wp.components.InputControl', '6.4');
const [isFocused, setIsFocused] = useState(false);
const id = useUniqueId(idProp);
const classes = classNames('components-input-control', className);
const draftHookProps = useDraft({
value,
onBlur: restProps.onBlur,
onChange
});
// ARIA descriptions can only contain plain text, so fall back to aria-details if not.
const helpPropName = typeof help === 'string' ? 'aria-describedby' : 'aria-details';
const helpProp = !!help ? {
[helpPropName]: `${id}__help`
} : {};
return createElement(BaseControl, {
className: classes,
help: help,
id: id,
__nextHasNoMarginBottom: true
}, createElement(InputBase, {
__next40pxDefaultSize: __next40pxDefaultSize,
__unstableInputWidth: __unstableInputWidth,
disabled: disabled,
gap: 3,
hideLabelFromVision: hideLabelFromVision,
id: id,
isFocused: isFocused,
justify: "left",
label: label,
labelPosition: labelPosition,
prefix: prefix,
size: size,
style: style,
suffix: suffix
}, createElement(InputField, {
...restProps,
...helpProp,
__next40pxDefaultSize: __next40pxDefaultSize,
className: "components-input-control__input",
disabled: disabled,
id: id,
isFocused: isFocused,
isPressEnterToChange: isPressEnterToChange,
onKeyDown: onKeyDown,
onValidate: onValidate,
paddingInlineStart: prefix ? space(2) : undefined,
paddingInlineEnd: suffix ? space(2) : undefined,
ref: ref,
setIsFocused: setIsFocused,
size: size,
stateReducer: stateReducer,
...draftHookProps
})));
}
/**
* InputControl components let users enter and edit text. This is an experimental component
* intended to (in time) merge with or replace `TextControl`.
*
* ```jsx
* import { __experimentalInputControl as InputControl } from '@wordpress/components';
* import { useState } from '@wordpress/compose';
*
* const Example = () => {
* const [ value, setValue ] = useState( '' );
*
* return (
* <InputControl
* value={ value }
* onChange={ ( nextValue ) => setValue( nextValue ?? '' ) }
* />
* );
* };
* ```
*/
export const InputControl = forwardRef(UnforwardedInputControl);
export default InputControl;
//# sourceMappingURL=index.js.map