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>
89 lines
2.2 KiB
JavaScript
89 lines
2.2 KiB
JavaScript
import { createElement } from "react";
|
|
/**
|
|
* External dependencies
|
|
*/
|
|
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { forwardRef } from '@wordpress/element';
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import NavigableContainer from './container';
|
|
export function UnforwardedTabbableContainer({
|
|
eventToOffset,
|
|
...props
|
|
}, ref) {
|
|
const innerEventToOffset = evt => {
|
|
const {
|
|
code,
|
|
shiftKey
|
|
} = evt;
|
|
if ('Tab' === code) {
|
|
return shiftKey ? -1 : 1;
|
|
}
|
|
|
|
// Allow custom handling of keys besides Tab.
|
|
//
|
|
// By default, TabbableContainer will move focus forward on Tab and
|
|
// backward on Shift+Tab. The handler below will be used for all other
|
|
// events. The semantics for `eventToOffset`'s return
|
|
// values are the following:
|
|
//
|
|
// - +1: move focus forward
|
|
// - -1: move focus backward
|
|
// - 0: don't move focus, but acknowledge event and thus stop it
|
|
// - undefined: do nothing, let the event propagate.
|
|
if (eventToOffset) {
|
|
return eventToOffset(evt);
|
|
}
|
|
return undefined;
|
|
};
|
|
return createElement(NavigableContainer, {
|
|
ref: ref,
|
|
stopNavigationEvents: true,
|
|
onlyBrowserTabstops: true,
|
|
eventToOffset: innerEventToOffset,
|
|
...props
|
|
});
|
|
}
|
|
|
|
/**
|
|
* A container for tabbable elements.
|
|
*
|
|
* ```jsx
|
|
* import {
|
|
* TabbableContainer,
|
|
* Button,
|
|
* } from '@wordpress/components';
|
|
*
|
|
* function onNavigate( index, target ) {
|
|
* console.log( `Navigates to ${ index }`, target );
|
|
* }
|
|
*
|
|
* const MyTabbableContainer = () => (
|
|
* <div>
|
|
* <span>Tabbable Container:</span>
|
|
* <TabbableContainer onNavigate={ onNavigate }>
|
|
* <Button variant="secondary" tabIndex="0">
|
|
* Section 1
|
|
* </Button>
|
|
* <Button variant="secondary" tabIndex="0">
|
|
* Section 2
|
|
* </Button>
|
|
* <Button variant="secondary" tabIndex="0">
|
|
* Section 3
|
|
* </Button>
|
|
* <Button variant="secondary" tabIndex="0">
|
|
* Section 4
|
|
* </Button>
|
|
* </TabbableContainer>
|
|
* </div>
|
|
* );
|
|
* ```
|
|
*/
|
|
export const TabbableContainer = forwardRef(UnforwardedTabbableContainer);
|
|
export default TabbableContainer;
|
|
//# sourceMappingURL=tabbable.js.map
|