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,47 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
var _element = require("@wordpress/element");
var _ = _interopRequireDefault(require("."));
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function UnforwardedIconButton({
label,
labelPosition,
size,
tooltip,
...props
}, ref) {
(0, _deprecated.default)('wp.components.IconButton', {
since: '5.4',
alternative: 'wp.components.Button',
version: '6.2'
});
return (0, _react.createElement)(_.default, {
...props,
ref: ref,
tooltipPosition: labelPosition,
iconSize: size,
showTooltip: tooltip !== undefined ? !!tooltip : undefined,
label: tooltip || label
});
}
var _default = (0, _element.forwardRef)(UnforwardedIconButton);
exports.default = _default;
//# sourceMappingURL=deprecated.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_deprecated","_interopRequireDefault","require","_element","_","UnforwardedIconButton","label","labelPosition","size","tooltip","props","ref","deprecated","since","alternative","version","_react","createElement","default","tooltipPosition","iconSize","showTooltip","undefined","_default","forwardRef","exports"],"sources":["@wordpress/components/src/button/deprecated.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Button from '.';\nimport type { DeprecatedIconButtonProps } from './types';\n\nfunction UnforwardedIconButton(\n\t{\n\t\tlabel,\n\t\tlabelPosition,\n\t\tsize,\n\t\ttooltip,\n\t\t...props\n\t}: React.ComponentPropsWithoutRef< typeof Button > &\n\t\tDeprecatedIconButtonProps,\n\tref: ForwardedRef< any >\n) {\n\tdeprecated( 'wp.components.IconButton', {\n\t\tsince: '5.4',\n\t\talternative: 'wp.components.Button',\n\t\tversion: '6.2',\n\t} );\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t\ttooltipPosition={ labelPosition }\n\t\t\ticonSize={ size }\n\t\t\tshowTooltip={ tooltip !== undefined ? !! tooltip : undefined }\n\t\t\tlabel={ tooltip || label }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( UnforwardedIconButton );\n"],"mappings":";;;;;;;;AAQA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,CAAA,GAAAH,sBAAA,CAAAC,OAAA;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAIA,SAASG,qBAAqBA,CAC7B;EACCC,KAAK;EACLC,aAAa;EACbC,IAAI;EACJC,OAAO;EACP,GAAGC;AAEqB,CAAC,EAC1BC,GAAwB,EACvB;EACD,IAAAC,mBAAU,EAAE,0BAA0B,EAAE;IACvCC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE,sBAAsB;IACnCC,OAAO,EAAE;EACV,CAAE,CAAC;EAEH,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACb,CAAA,CAAAc,OAAM;IAAA,GACDR,KAAK;IACVC,GAAG,EAAGA,GAAK;IACXQ,eAAe,EAAGZ,aAAe;IACjCa,QAAQ,EAAGZ,IAAM;IACjBa,WAAW,EAAGZ,OAAO,KAAKa,SAAS,GAAG,CAAC,CAAEb,OAAO,GAAGa,SAAW;IAC9DhB,KAAK,EAAGG,OAAO,IAAIH;EAAO,CAC1B,CAAC;AAEJ;AAAC,IAAAiB,QAAA,GAEc,IAAAC,mBAAU,EAAEnB,qBAAsB,CAAC;AAAAoB,OAAA,CAAAP,OAAA,GAAAK,QAAA"}

View File

@@ -0,0 +1,242 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Button = void 0;
exports.UnforwardedButton = UnforwardedButton;
exports.default = void 0;
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
var _element = require("@wordpress/element");
var _compose = require("@wordpress/compose");
var _tooltip = _interopRequireDefault(require("../tooltip"));
var _icon = _interopRequireDefault(require("../icon"));
var _visuallyHidden = require("../visually-hidden");
var _utils = require("../popover/utils");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const disabledEventsOnDisabledButton = ['onMouseDown', 'onClick'];
function useDeprecatedProps({
isDefault,
isPrimary,
isSecondary,
isTertiary,
isLink,
isPressed,
isSmall,
size,
variant,
...otherProps
}) {
let computedSize = size;
let computedVariant = variant;
const newProps = {
// @TODO Mark `isPressed` as deprecated
'aria-pressed': isPressed
};
if (isSmall) {
var _computedSize;
(_computedSize = computedSize) !== null && _computedSize !== void 0 ? _computedSize : computedSize = 'small';
}
if (isPrimary) {
var _computedVariant;
(_computedVariant = computedVariant) !== null && _computedVariant !== void 0 ? _computedVariant : computedVariant = 'primary';
}
if (isTertiary) {
var _computedVariant2;
(_computedVariant2 = computedVariant) !== null && _computedVariant2 !== void 0 ? _computedVariant2 : computedVariant = 'tertiary';
}
if (isSecondary) {
var _computedVariant3;
(_computedVariant3 = computedVariant) !== null && _computedVariant3 !== void 0 ? _computedVariant3 : computedVariant = 'secondary';
}
if (isDefault) {
var _computedVariant4;
(0, _deprecated.default)('Button isDefault prop', {
since: '5.4',
alternative: 'variant="secondary"',
version: '6.2'
});
(_computedVariant4 = computedVariant) !== null && _computedVariant4 !== void 0 ? _computedVariant4 : computedVariant = 'secondary';
}
if (isLink) {
var _computedVariant5;
(_computedVariant5 = computedVariant) !== null && _computedVariant5 !== void 0 ? _computedVariant5 : computedVariant = 'link';
}
return {
...newProps,
...otherProps,
size: computedSize,
variant: computedVariant
};
}
function UnforwardedButton(props, ref) {
const {
__next40pxDefaultSize,
isBusy,
isDestructive,
className,
disabled,
icon,
iconPosition = 'left',
iconSize,
showTooltip,
tooltipPosition,
shortcut,
label,
children,
size = 'default',
text,
variant,
__experimentalIsFocusable: isFocusable,
describedBy,
...buttonOrAnchorProps
} = useDeprecatedProps(props);
const {
href,
target,
'aria-checked': ariaChecked,
'aria-pressed': ariaPressed,
'aria-selected': ariaSelected,
...additionalProps
} = 'href' in buttonOrAnchorProps ? buttonOrAnchorProps : {
href: undefined,
target: undefined,
...buttonOrAnchorProps
};
const instanceId = (0, _compose.useInstanceId)(Button, 'components-button__description');
const hasChildren = 'string' === typeof children && !!children || Array.isArray(children) && children?.[0] && children[0] !== null &&
// Tooltip should not considered as a child
children?.[0]?.props?.className !== 'components-tooltip';
const truthyAriaPressedValues = [true, 'true', 'mixed'];
const classes = (0, _classnames.default)('components-button', className, {
'is-next-40px-default-size': __next40pxDefaultSize,
'is-secondary': variant === 'secondary',
'is-primary': variant === 'primary',
'is-small': size === 'small',
'is-compact': size === 'compact',
'is-tertiary': variant === 'tertiary',
'is-pressed': truthyAriaPressedValues.includes(ariaPressed),
'is-pressed-mixed': ariaPressed === 'mixed',
'is-busy': isBusy,
'is-link': variant === 'link',
'is-destructive': isDestructive,
'has-text': !!icon && (hasChildren || text),
'has-icon': !!icon
});
const trulyDisabled = disabled && !isFocusable;
const Tag = href !== undefined && !trulyDisabled ? 'a' : 'button';
const buttonProps = Tag === 'button' ? {
type: 'button',
disabled: trulyDisabled,
'aria-checked': ariaChecked,
'aria-pressed': ariaPressed,
'aria-selected': ariaSelected
} : {};
const anchorProps = Tag === 'a' ? {
href,
target
} : {};
if (disabled && isFocusable) {
// In this case, the button will be disabled, but still focusable and
// perceivable by screen reader users.
buttonProps['aria-disabled'] = true;
anchorProps['aria-disabled'] = true;
for (const disabledEvent of disabledEventsOnDisabledButton) {
additionalProps[disabledEvent] = event => {
if (event) {
event.stopPropagation();
event.preventDefault();
}
};
}
}
// Should show the tooltip if...
const shouldShowTooltip = !trulyDisabled && (
// An explicit tooltip is passed or...
showTooltip && !!label ||
// There's a shortcut or...
!!shortcut ||
// There's a label and...
!!label &&
// The children are empty and...
!children?.length &&
// The tooltip is not explicitly disabled.
false !== showTooltip);
const descriptionId = describedBy ? instanceId : undefined;
const describedById = additionalProps['aria-describedby'] || descriptionId;
const commonProps = {
className: classes,
'aria-label': additionalProps['aria-label'] || label,
'aria-describedby': describedById,
ref
};
const elementChildren = (0, _react.createElement)(_react.Fragment, null, icon && iconPosition === 'left' && (0, _react.createElement)(_icon.default, {
icon: icon,
size: iconSize
}), text && (0, _react.createElement)(_react.Fragment, null, text), icon && iconPosition === 'right' && (0, _react.createElement)(_icon.default, {
icon: icon,
size: iconSize
}), children);
const element = Tag === 'a' ? (0, _react.createElement)("a", {
...anchorProps,
...additionalProps,
...commonProps
}, elementChildren) : (0, _react.createElement)("button", {
...buttonProps,
...additionalProps,
...commonProps
}, elementChildren);
// In order to avoid some React reconciliation issues, we are always rendering
// the `Tooltip` component even when `shouldShowTooltip` is `false`.
// In order to make sure that the tooltip doesn't show when it shouldn't,
// we don't pass the props to the `Tooltip` component.
const tooltipProps = shouldShowTooltip ? {
text: children?.length && describedBy ? describedBy : label,
shortcut,
placement: tooltipPosition &&
// Convert legacy `position` values to be used with the new `placement` prop
(0, _utils.positionToPlacement)(tooltipPosition)
} : {};
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_tooltip.default, {
...tooltipProps
}, element), describedBy && (0, _react.createElement)(_visuallyHidden.VisuallyHidden, null, (0, _react.createElement)("span", {
id: descriptionId
}, describedBy)));
}
/**
* Lets users take actions and make choices with a single click or tap.
*
* ```jsx
* import { Button } from '@wordpress/components';
* const Mybutton = () => (
* <Button
* variant="primary"
* onClick={ handleClick }
* >
* Click here
* </Button>
* );
* ```
*/
const Button = (0, _element.forwardRef)(UnforwardedButton);
exports.Button = Button;
var _default = Button;
exports.default = _default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,194 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Button = Button;
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _reactNativeGestureHandler = require("react-native-gesture-handler");
var _element = require("@wordpress/element");
var _compose = require("@wordpress/compose");
var _tooltip = _interopRequireDefault(require("../tooltip"));
var _icon = _interopRequireDefault(require("../icon"));
var _style = _interopRequireDefault(require("./style.scss"));
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const isAndroid = _reactNative.Platform.OS === 'android';
const marginBottom = isAndroid ? -0.5 : 0;
const marginLeft = -3;
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1,
padding: 3,
justifyContent: 'center',
alignItems: 'center'
},
buttonInactive: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center'
},
fixedRatio: {
aspectRatio: 1
},
buttonActive: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 6
},
subscriptInactive: {
color: '#7b9ab1',
// $toolbar-button.
fontWeight: 'bold',
fontSize: 13,
alignSelf: 'flex-end',
marginLeft,
marginBottom
},
subscriptInactiveDark: {
color: '#a7aaad' // $gray_20.
},
subscriptActive: {
color: 'white',
fontWeight: 'bold',
fontSize: 13,
alignSelf: 'flex-end',
marginLeft,
marginBottom
}
});
function Button(props) {
const {
children,
onClick,
onLongPress,
disabled,
hint,
fixedRatio = true,
isPressed,
'aria-disabled': ariaDisabled,
'data-subscript': subscript,
testID,
icon,
iconSize,
showTooltip,
label,
shortcut,
tooltipPosition,
isActiveStyle,
customContainerStyles,
hitSlop
} = props;
const preferredColorScheme = (0, _compose.usePreferredColorScheme)();
const isDisabled = ariaDisabled || disabled;
const containerStyle = [styles.container, customContainerStyles && {
...customContainerStyles
}];
const buttonActiveColorStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default['components-button-light--active'], _style.default['components-button-dark--active']);
const buttonViewStyle = {
opacity: isDisabled ? 0.3 : 1,
...(fixedRatio && styles.fixedRatio),
...(isPressed ? styles.buttonActive : styles.buttonInactive),
...(isPressed ? buttonActiveColorStyles : {}),
...(isPressed && isActiveStyle?.borderRadius && {
borderRadius: isActiveStyle.borderRadius
}),
...(isActiveStyle?.backgroundColor && {
backgroundColor: isActiveStyle.backgroundColor
})
};
const states = [];
if (isPressed) {
states.push('selected');
}
if (isDisabled) {
states.push('disabled');
}
const subscriptInactive = (0, _compose.usePreferredColorSchemeStyle)(styles.subscriptInactive, styles.subscriptInactiveDark);
const newChildren = _element.Children.map(children, child => {
return child ? (0, _element.cloneElement)(child, {
colorScheme: preferredColorScheme,
isPressed
}) : child;
});
// Should show the tooltip if...
const shouldShowTooltip = !isDisabled && (
// An explicit tooltip is passed or...
showTooltip && label ||
// There's a shortcut or...
shortcut ||
// There's a label and...
!!label && (
// The children are empty and...
!children || Array.isArray(children) && !children.length) &&
// The tooltip is not explicitly disabled.
false !== showTooltip);
const newIcon = icon ? (0, _element.cloneElement)((0, _react.createElement)(_icon.default, {
icon: icon,
size: iconSize
}), {
isPressed
}) : null;
const longPressHandler = (0, _element.useCallback)(({
nativeEvent
}) => {
if (nativeEvent.state === _reactNativeGestureHandler.State.ACTIVE && onLongPress) {
onLongPress();
}
}, [onLongPress]);
const element = (0, _react.createElement)(_reactNative.TouchableOpacity, {
activeOpacity: 0.7,
accessible: true,
accessibilityLabel: label,
accessibilityStates: states,
accessibilityRole: 'button',
accessibilityHint: hint,
onPress: onClick,
style: containerStyle,
disabled: isDisabled,
testID: testID,
hitSlop: hitSlop
}, (0, _react.createElement)(_reactNativeGestureHandler.LongPressGestureHandler, {
minDurationMs: 500,
maxDist: 150,
onHandlerStateChange: longPressHandler
}, (0, _react.createElement)(_reactNative.View, {
style: buttonViewStyle
}, (0, _react.createElement)(_reactNative.View, {
style: {
flexDirection: 'row'
}
}, newIcon, newChildren, subscript && (0, _react.createElement)(_reactNative.Text, {
style: isPressed ? styles.subscriptActive : subscriptInactive
}, subscript)))));
if (!shouldShowTooltip) {
return element;
}
return (0, _react.createElement)(_tooltip.default, {
text: label,
shortcut: shortcut,
position: tooltipPosition,
visible: showTooltip === true
}, element);
}
var _default = Button;
exports.default = _default;
//# sourceMappingURL=index.native.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

File diff suppressed because one or more lines are too long