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>
85 lines
2.4 KiB
JavaScript
85 lines
2.4 KiB
JavaScript
import { createElement, Fragment } from "react";
|
|
/**
|
|
* External dependencies
|
|
*/
|
|
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { forwardRef, useContext } from '@wordpress/element';
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import BaseFill from './fill';
|
|
import BaseSlot from './slot';
|
|
import BubblesVirtuallyFill from './bubbles-virtually/fill';
|
|
import BubblesVirtuallySlot from './bubbles-virtually/slot';
|
|
import BubblesVirtuallySlotFillProvider from './bubbles-virtually/slot-fill-provider';
|
|
import SlotFillProvider from './provider';
|
|
import SlotFillContext from './bubbles-virtually/slot-fill-context';
|
|
export { default as useSlot } from './bubbles-virtually/use-slot';
|
|
export { default as useSlotFills } from './bubbles-virtually/use-slot-fills';
|
|
export function Fill(props) {
|
|
// We're adding both Fills here so they can register themselves before
|
|
// their respective slot has been registered. Only the Fill that has a slot
|
|
// will render. The other one will return null.
|
|
return createElement(Fragment, null, createElement(BaseFill, {
|
|
...props
|
|
}), createElement(BubblesVirtuallyFill, {
|
|
...props
|
|
}));
|
|
}
|
|
export function UnforwardedSlot(props, ref) {
|
|
const {
|
|
bubblesVirtually,
|
|
...restProps
|
|
} = props;
|
|
if (bubblesVirtually) {
|
|
return createElement(BubblesVirtuallySlot, {
|
|
...restProps,
|
|
ref: ref
|
|
});
|
|
}
|
|
return createElement(BaseSlot, {
|
|
...restProps
|
|
});
|
|
}
|
|
export const Slot = forwardRef(UnforwardedSlot);
|
|
export function Provider({
|
|
children,
|
|
passthrough = false
|
|
}) {
|
|
const parent = useContext(SlotFillContext);
|
|
if (!parent.isDefault && passthrough) {
|
|
return createElement(Fragment, null, children);
|
|
}
|
|
return createElement(SlotFillProvider, null, createElement(BubblesVirtuallySlotFillProvider, null, children));
|
|
}
|
|
export function createSlotFill(key) {
|
|
const baseName = typeof key === 'symbol' ? key.description : key;
|
|
const FillComponent = props => createElement(Fill, {
|
|
name: key,
|
|
...props
|
|
});
|
|
FillComponent.displayName = `${baseName}Fill`;
|
|
const SlotComponent = props => createElement(Slot, {
|
|
name: key,
|
|
...props
|
|
});
|
|
SlotComponent.displayName = `${baseName}Slot`;
|
|
SlotComponent.__unstableName = key;
|
|
return {
|
|
Fill: FillComponent,
|
|
Slot: SlotComponent
|
|
};
|
|
}
|
|
export const createPrivateSlotFill = name => {
|
|
const privateKey = Symbol(name);
|
|
const privateSlotFill = createSlotFill(privateKey);
|
|
return {
|
|
privateKey,
|
|
...privateSlotFill
|
|
};
|
|
};
|
|
//# sourceMappingURL=index.js.map
|