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,93 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { View } from 'react-native';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Component, Fragment } from '@wordpress/element';
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
import { PanelBody, TextControl } from '@wordpress/components';
/**
* Internal dependencies
*/
import BottomSheet from '../bottom-sheet';
import styles from './styles.scss';
function Separator() {
const separatorStyle = usePreferredColorSchemeStyle(styles['components-picker__separator'], styles['components-picker__separator--dark']);
return createElement(View, {
style: separatorStyle
});
}
export default class Picker extends Component {
constructor() {
super(...arguments);
this.onClose = this.onClose.bind(this);
this.onCellPress = this.onCellPress.bind(this);
this.state = {
isVisible: false
};
}
presentPicker() {
this.setState({
isVisible: true
});
}
onClose() {
this.setState({
isVisible: false
});
}
onCellPress(value) {
const {
onChange
} = this.props;
onChange(value);
this.onClose();
}
getOptions() {
const {
options,
leftAlign
} = this.props;
return options.map(option => createElement(Fragment, {
key: `${option.label}-${option.value}`
}, options.length > 1 && option.separated && createElement(Separator, null), createElement(BottomSheet.Cell, {
icon: option.icon,
leftAlign: leftAlign,
label: option.label,
separatorType: 'none',
onPress: () => this.onCellPress(option.value),
disabled: option.disabled,
style: option.disabled && styles['components-picker__button--disabled']
})));
}
render() {
const {
hideCancelButton,
title,
testID
} = this.props;
const {
isVisible
} = this.state;
return createElement(BottomSheet, {
isVisible: isVisible,
onClose: this.onClose,
hideHeader: true,
testID: testID
}, createElement(PanelBody, {
title: title,
style: styles['components-picker__panel']
}, this.getOptions(), !hideCancelButton && createElement(TextControl, {
label: __('Cancel'),
onPress: this.onClose,
separatorType: 'none'
})));
}
}
//# sourceMappingURL=index.android.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,85 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { ActionSheetIOS } from 'react-native';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Component, forwardRef, useContext } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
import { BottomSheetContext } from '@wordpress/components';
import { usePreferredColorScheme } from '@wordpress/compose';
/**
* Internal dependencies
*/
import styles from './styles.scss';
class Picker extends Component {
presentPicker() {
const {
options,
onChange,
title,
destructiveButtonIndex,
disabledButtonIndices,
getAnchor,
isBottomSheetOpened,
closeBottomSheet,
onHandleClosingBottomSheet,
colorScheme
} = this.props;
const labels = options.map(({
label
}) => label);
const fullOptions = [__('Cancel')].concat(labels);
const buttonTitleColor = colorScheme === 'light' ? styles['components-picker__button-title'].color : styles['components-picker__button-title--dark'].color;
ActionSheetIOS.showActionSheetWithOptions({
title,
options: fullOptions,
cancelButtonIndex: 0,
destructiveButtonIndex,
disabledButtonIndices,
anchor: getAnchor && getAnchor(),
tintColor: buttonTitleColor
}, buttonIndex => {
if (buttonIndex === 0) {
return;
}
const selected = options[buttonIndex - 1];
if (selected.requiresModal && isBottomSheetOpened) {
onHandleClosingBottomSheet(() => {
onChange(selected.value);
});
closeBottomSheet();
} else {
onChange(selected.value);
}
});
}
render() {
return null;
}
}
const PickerComponent = forwardRef((props, ref) => {
const isBottomSheetOpened = useSelect(select => select('core/edit-post').isEditorSidebarOpened());
const {
closeGeneralSidebar
} = useDispatch('core/edit-post');
const {
onHandleClosingBottomSheet
} = useContext(BottomSheetContext);
const colorScheme = usePreferredColorScheme();
return createElement(Picker, {
ref: ref,
...props,
isBottomSheetOpened: isBottomSheetOpened,
closeBottomSheet: closeGeneralSidebar,
onHandleClosingBottomSheet: onHandleClosingBottomSheet,
colorScheme: colorScheme
});
});
export default PickerComponent;
//# sourceMappingURL=index.ios.js.map

File diff suppressed because one or more lines are too long