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

113 lines
2.9 KiB
JavaScript

import { createElement } from "react";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { useInstanceId, useMergeRefs } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';
import { Icon, search, closeSmall } from '@wordpress/icons';
import { forwardRef, useRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import Button from '../button';
import BaseControl from '../base-control';
function UnforwardedSearchControl({
__nextHasNoMarginBottom,
__next40pxDefaultSize = false,
className,
onChange,
onKeyDown,
value,
label,
placeholder = __('Search'),
hideLabelFromVision = true,
help,
onClose,
size = 'default',
...restProps
}, forwardedRef) {
const searchRef = useRef();
const instanceId = useInstanceId(SearchControl);
const id = `components-search-control-${instanceId}`;
const renderRightButton = () => {
if (onClose) {
return createElement(Button, {
__next40pxDefaultSize: __next40pxDefaultSize,
icon: closeSmall,
label: __('Close search'),
onClick: onClose,
size: size
});
}
if (!!value) {
return createElement(Button, {
__next40pxDefaultSize: __next40pxDefaultSize,
icon: closeSmall,
label: __('Reset search'),
onClick: () => {
onChange('');
searchRef.current?.focus();
},
size: size
});
}
return createElement(Icon, {
icon: search
});
};
return createElement(BaseControl, {
__nextHasNoMarginBottom: __nextHasNoMarginBottom,
label: label,
id: id,
hideLabelFromVision: hideLabelFromVision,
help: help,
className: classnames(className, 'components-search-control', {
'is-next-40px-default-size': __next40pxDefaultSize,
'is-size-compact': size === 'compact'
})
}, createElement("div", {
className: "components-search-control__input-wrapper"
}, createElement("input", {
...restProps,
ref: useMergeRefs([searchRef, forwardedRef]),
className: "components-search-control__input",
id: id,
type: "search",
placeholder: placeholder,
onChange: event => onChange(event.target.value),
onKeyDown: onKeyDown,
autoComplete: "off",
value: value || ''
}), createElement("div", {
className: "components-search-control__icon"
}, renderRightButton())));
}
/**
* SearchControl components let users display a search control.
*
* ```jsx
* import { SearchControl } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* function MySearchControl( { className, setState } ) {
* const [ searchInput, setSearchInput ] = useState( '' );
*
* return (
* <SearchControl
* value={ searchInput }
* onChange={ setSearchInput }
* />
* );
* }
* ```
*/
export const SearchControl = forwardRef(UnforwardedSearchControl);
export default SearchControl;
//# sourceMappingURL=index.js.map