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>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

View File

@@ -0,0 +1,7 @@
/**
* External dependencies
*/
import { KeyboardAvoidingView as AndroidKeyboardAvoidingView } from 'react-native';
export const KeyboardAvoidingView = AndroidKeyboardAvoidingView;
export default KeyboardAvoidingView;
//# sourceMappingURL=index.android.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["KeyboardAvoidingView","AndroidKeyboardAvoidingView"],"sources":["@wordpress/components/src/mobile/keyboard-avoiding-view/index.android.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { KeyboardAvoidingView as AndroidKeyboardAvoidingView } from 'react-native';\n\nexport const KeyboardAvoidingView = AndroidKeyboardAvoidingView;\n\nexport default KeyboardAvoidingView;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,oBAAoB,IAAIC,2BAA2B,QAAQ,cAAc;AAElF,OAAO,MAAMD,oBAAoB,GAAGC,2BAA2B;AAE/D,eAAeD,oBAAoB"}

View File

@@ -0,0 +1,107 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { KeyboardAvoidingView as IOSKeyboardAvoidingView, Animated, Keyboard, Dimensions, View } from 'react-native';
import SafeArea from 'react-native-safe-area';
/**
* WordPress dependencies
*/
import { useEffect, useRef, useState } from '@wordpress/element';
import { useResizeObserver } from '@wordpress/compose';
/**
* Internal dependencies
*/
import useIsFloatingKeyboard from '../utils/use-is-floating-keyboard';
import styles from './styles.scss';
const AnimatedKeyboardAvoidingView = Animated.createAnimatedComponent(IOSKeyboardAvoidingView);
const MIN_HEIGHT = 44;
export const KeyboardAvoidingView = ({
parentHeight,
style,
withAnimatedHeight = false,
...otherProps
}) => {
const [resizeObserver, sizes] = useResizeObserver();
const [isKeyboardOpen, setIsKeyboardOpen] = useState(false);
const [safeAreaBottomInset, setSafeAreaBottomInset] = useState(0);
const {
height = 0
} = sizes || {};
const floatingKeyboard = useIsFloatingKeyboard();
const animatedHeight = useRef(new Animated.Value(MIN_HEIGHT)).current;
const {
height: fullHeight
} = Dimensions.get('screen');
const keyboardVerticalOffset = fullHeight - parentHeight;
useEffect(() => {
SafeArea.getSafeAreaInsetsForRootView().then(({
safeAreaInsets
}) => {
setSafeAreaBottomInset(safeAreaInsets.bottom);
});
const safeAreaSubscription = SafeArea.addEventListener('safeAreaInsetsForRootViewDidChange', onSafeAreaInsetsUpdate);
const keyboardShowSubscription = Keyboard.addListener('keyboardWillShow', onKeyboardWillShow);
const keyboardHideSubscription = Keyboard.addListener('keyboardWillHide', onKeyboardWillHide);
return () => {
safeAreaSubscription.remove();
keyboardShowSubscription.remove();
keyboardHideSubscription.remove();
};
// Disable reason: deferring this refactor to the native team.
// see https://github.com/WordPress/gutenberg/pull/41166
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
function onSafeAreaInsetsUpdate({
safeAreaInsets
}) {
setSafeAreaBottomInset(safeAreaInsets.bottom);
}
function onKeyboardWillShow({
endCoordinates
}) {
setIsKeyboardOpen(true);
animatedHeight.setValue(endCoordinates.height + MIN_HEIGHT);
}
function onKeyboardWillHide({
duration,
startCoordinates
}) {
// The startCoordinates.height is set to wrong value when we use cmd + k for hide the keyboard (Have no idea why).
// Because of that the `setIsKeyboardOpened` is not invoked and the state of keyboard is wrong.
// The keyboardIsOpenBreakpoint use 100 as a fallback if the startCoordinates.height is too small (cmd + k case)
const keyboardIsOpenBreakpoint = startCoordinates.height > 100 ? startCoordinates.height / 3 : 100;
const animatedListenerId = animatedHeight.addListener(({
value
}) => {
if (value < keyboardIsOpenBreakpoint) {
setIsKeyboardOpen(false);
}
});
Animated.timing(animatedHeight, {
toValue: MIN_HEIGHT,
duration,
useNativeDriver: false
}).start(() => {
animatedHeight.removeListener(animatedListenerId);
});
}
return createElement(AnimatedKeyboardAvoidingView, {
...otherProps,
enabled: !floatingKeyboard,
behavior: "padding",
keyboardVerticalOffset: keyboardVerticalOffset,
style: withAnimatedHeight ? [style, {
height: animatedHeight,
marginBottom: isKeyboardOpen ? -safeAreaBottomInset : 0
}] : style
}, createElement(View, {
style: [{
top: -height + MIN_HEIGHT
}, styles.animatedChildStyle, !withAnimatedHeight && styles.defaultChildStyle]
}, resizeObserver, otherProps.children));
};
export default KeyboardAvoidingView;
//# sourceMappingURL=index.ios.js.map

File diff suppressed because one or more lines are too long