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,72 @@
import { createElement } from "react";
/**
* WordPress dependencies
*/
import { useInstanceId } from '@wordpress/compose';
import { forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import BaseControl from '../base-control';
import { StyledTextarea } from './styles/textarea-control-styles';
function UnforwardedTextareaControl(props, ref) {
const {
__nextHasNoMarginBottom,
label,
hideLabelFromVision,
value,
help,
onChange,
rows = 4,
className,
...additionalProps
} = props;
const instanceId = useInstanceId(TextareaControl);
const id = `inspector-textarea-control-${instanceId}`;
const onChangeValue = event => onChange(event.target.value);
return createElement(BaseControl, {
__nextHasNoMarginBottom: __nextHasNoMarginBottom,
label: label,
hideLabelFromVision: hideLabelFromVision,
id: id,
help: help,
className: className
}, createElement(StyledTextarea, {
className: "components-textarea-control__input",
id: id,
rows: rows,
onChange: onChangeValue,
"aria-describedby": !!help ? id + '__help' : undefined,
value: value,
ref: ref,
...additionalProps
}));
}
/**
* TextareaControls are TextControls that allow for multiple lines of text, and
* wrap overflow text onto a new line. They are a fixed height and scroll
* vertically when the cursor reaches the bottom of the field.
*
* ```jsx
* import { TextareaControl } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const MyTextareaControl = () => {
* const [ text, setText ] = useState( '' );
*
* return (
* <TextareaControl
* label="Text"
* help="Enter some text"
* value={ text }
* onChange={ ( value ) => setText( value ) }
* />
* );
* };
* ```
*/
export const TextareaControl = forwardRef(UnforwardedTextareaControl);
export default TextareaControl;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useInstanceId","forwardRef","BaseControl","StyledTextarea","UnforwardedTextareaControl","props","ref","__nextHasNoMarginBottom","label","hideLabelFromVision","value","help","onChange","rows","className","additionalProps","instanceId","TextareaControl","id","onChangeValue","event","target","createElement","undefined"],"sources":["@wordpress/components/src/textarea-control/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport { StyledTextarea } from './styles/textarea-control-styles';\nimport type { TextareaControlProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nfunction UnforwardedTextareaControl(\n\tprops: WordPressComponentProps< TextareaControlProps, 'textarea', false >,\n\tref: React.ForwardedRef< HTMLTextAreaElement >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom,\n\t\tlabel,\n\t\thideLabelFromVision,\n\t\tvalue,\n\t\thelp,\n\t\tonChange,\n\t\trows = 4,\n\t\tclassName,\n\t\t...additionalProps\n\t} = props;\n\tconst instanceId = useInstanceId( TextareaControl );\n\tconst id = `inspector-textarea-control-${ instanceId }`;\n\tconst onChangeValue = ( event: React.ChangeEvent< HTMLTextAreaElement > ) =>\n\t\tonChange( event.target.value );\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tid={ id }\n\t\t\thelp={ help }\n\t\t\tclassName={ className }\n\t\t>\n\t\t\t<StyledTextarea\n\t\t\t\tclassName=\"components-textarea-control__input\"\n\t\t\t\tid={ id }\n\t\t\t\trows={ rows }\n\t\t\t\tonChange={ onChangeValue }\n\t\t\t\taria-describedby={ !! help ? id + '__help' : undefined }\n\t\t\t\tvalue={ value }\n\t\t\t\tref={ ref }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * TextareaControls are TextControls that allow for multiple lines of text, and\n * wrap overflow text onto a new line. They are a fixed height and scroll\n * vertically when the cursor reaches the bottom of the field.\n *\n * ```jsx\n * import { TextareaControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTextareaControl = () => {\n * const [ text, setText ] = useState( '' );\n *\n * return (\n * <TextareaControl\n * label=\"Text\"\n * help=\"Enter some text\"\n * value={ text }\n * onChange={ ( value ) => setText( value ) }\n * />\n * );\n * };\n * ```\n */\nexport const TextareaControl = forwardRef( UnforwardedTextareaControl );\n\nexport default TextareaControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,OAAOC,WAAW,MAAM,iBAAiB;AACzC,SAASC,cAAc,QAAQ,kCAAkC;AAIjE,SAASC,0BAA0BA,CAClCC,KAAyE,EACzEC,GAA8C,EAC7C;EACD,MAAM;IACLC,uBAAuB;IACvBC,KAAK;IACLC,mBAAmB;IACnBC,KAAK;IACLC,IAAI;IACJC,QAAQ;IACRC,IAAI,GAAG,CAAC;IACRC,SAAS;IACT,GAAGC;EACJ,CAAC,GAAGV,KAAK;EACT,MAAMW,UAAU,GAAGhB,aAAa,CAAEiB,eAAgB,CAAC;EACnD,MAAMC,EAAE,GAAI,8BAA8BF,UAAY,EAAC;EACvD,MAAMG,aAAa,GAAKC,KAA+C,IACtER,QAAQ,CAAEQ,KAAK,CAACC,MAAM,CAACX,KAAM,CAAC;EAE/B,OACCY,aAAA,CAACpB,WAAW;IACXK,uBAAuB,EAAGA,uBAAyB;IACnDC,KAAK,EAAGA,KAAO;IACfC,mBAAmB,EAAGA,mBAAqB;IAC3CS,EAAE,EAAGA,EAAI;IACTP,IAAI,EAAGA,IAAM;IACbG,SAAS,EAAGA;EAAW,GAEvBQ,aAAA,CAACnB,cAAc;IACdW,SAAS,EAAC,oCAAoC;IAC9CI,EAAE,EAAGA,EAAI;IACTL,IAAI,EAAGA,IAAM;IACbD,QAAQ,EAAGO,aAAe;IAC1B,oBAAmB,CAAC,CAAER,IAAI,GAAGO,EAAE,GAAG,QAAQ,GAAGK,SAAW;IACxDb,KAAK,EAAGA,KAAO;IACfJ,GAAG,EAAGA,GAAK;IAAA,GACNS;EAAe,CACpB,CACW,CAAC;AAEhB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,eAAe,GAAGhB,UAAU,CAAEG,0BAA2B,CAAC;AAEvE,eAAea,eAAe"}

View File

@@ -0,0 +1,35 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { TextInput } from 'react-native';
/**
* Internal dependencies
*/
import BaseControl from '../base-control';
function TextareaControl({
label,
value,
help,
onChange,
rows = 4
}) {
return createElement(BaseControl, {
label: label,
help: help
}, createElement(TextInput, {
style: {
height: 80,
borderColor: 'gray',
borderWidth: 1
},
value: value,
onChangeText: onChange,
numberOfLines: rows,
multiline: rows > 1,
textAlignVertical: "top"
}));
}
export default TextareaControl;
//# sourceMappingURL=index.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["TextInput","BaseControl","TextareaControl","label","value","help","onChange","rows","createElement","style","height","borderColor","borderWidth","onChangeText","numberOfLines","multiline","textAlignVertical"],"sources":["@wordpress/components/src/textarea-control/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { TextInput } from 'react-native';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\n\nfunction TextareaControl( { label, value, help, onChange, rows = 4 } ) {\n\treturn (\n\t\t<BaseControl label={ label } help={ help }>\n\t\t\t<TextInput\n\t\t\t\tstyle={ { height: 80, borderColor: 'gray', borderWidth: 1 } }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChangeText={ onChange }\n\t\t\t\tnumberOfLines={ rows }\n\t\t\t\tmultiline={ rows > 1 }\n\t\t\t\ttextAlignVertical=\"top\"\n\t\t\t/>\n\t\t</BaseControl>\n\t);\n}\n\nexport default TextareaControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,cAAc;;AAExC;AACA;AACA;AACA,OAAOC,WAAW,MAAM,iBAAiB;AAEzC,SAASC,eAAeA,CAAE;EAAEC,KAAK;EAAEC,KAAK;EAAEC,IAAI;EAAEC,QAAQ;EAAEC,IAAI,GAAG;AAAE,CAAC,EAAG;EACtE,OACCC,aAAA,CAACP,WAAW;IAACE,KAAK,EAAGA,KAAO;IAACE,IAAI,EAAGA;EAAM,GACzCG,aAAA,CAACR,SAAS;IACTS,KAAK,EAAG;MAAEC,MAAM,EAAE,EAAE;MAAEC,WAAW,EAAE,MAAM;MAAEC,WAAW,EAAE;IAAE,CAAG;IAC7DR,KAAK,EAAGA,KAAO;IACfS,YAAY,EAAGP,QAAU;IACzBQ,aAAa,EAAGP,IAAM;IACtBQ,SAAS,EAAGR,IAAI,GAAG,CAAG;IACtBS,iBAAiB,EAAC;EAAK,CACvB,CACW,CAAC;AAEhB;AAEA,eAAed,eAAe"}

View File

@@ -0,0 +1,16 @@
import _styled from "@emotion/styled/base";
/**
* External dependencies
*/
/**
* Internal dependencies
*/
import { inputControl } from '../../utils/input';
export const StyledTextarea = _styled("textarea", process.env.NODE_ENV === "production" ? {
target: "e1w5nnrk0"
} : {
target: "e1w5nnrk0",
label: "StyledTextarea"
})("width:100%;", inputControl, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dGFyZWEtY29udHJvbC9zdHlsZXMvdGV4dGFyZWEtY29udHJvbC1zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBVTZDIiwiZmlsZSI6IkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dGFyZWEtY29udHJvbC9zdHlsZXMvdGV4dGFyZWEtY29udHJvbC1zdHlsZXMudHMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEV4dGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5cbi8qKlxuICogSW50ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IGlucHV0Q29udHJvbCB9IGZyb20gJy4uLy4uL3V0aWxzL2lucHV0JztcblxuZXhwb3J0IGNvbnN0IFN0eWxlZFRleHRhcmVhID0gc3R5bGVkLnRleHRhcmVhYFxuXHR3aWR0aDogMTAwJTtcblx0JHsgaW5wdXRDb250cm9sIH1cbmA7XG4iXX0= */"));
//# sourceMappingURL=textarea-control-styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["inputControl","StyledTextarea","_styled","process","env","NODE_ENV","target","label"],"sources":["@wordpress/components/src/textarea-control/styles/textarea-control-styles.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\n\n/**\n * Internal dependencies\n */\nimport { inputControl } from '../../utils/input';\n\nexport const StyledTextarea = styled.textarea`\n\twidth: 100%;\n\t${ inputControl }\n`;\n"],"mappings":";AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,mBAAmB;AAEhD,OAAO,MAAMC,cAAc,GAAAC,OAAA,aAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,kBAEvBP,YAAY,SAAAG,OAAA,CAAAC,GAAA,CAAAC,QAAA,wvBACf"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/textarea-control/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { TextareaHTMLAttributes } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { BaseControlProps } from '../base-control/types';\n\nexport type TextareaControlProps = Pick<\n\tBaseControlProps,\n\t'hideLabelFromVision' | 'help' | 'label' | '__nextHasNoMarginBottom'\n> & {\n\t/**\n\t * A function that receives the new value of the textarea each time it\n\t * changes.\n\t */\n\tonChange: ( value: string ) => void;\n\t/**\n\t * The current value of the textarea.\n\t */\n\tvalue: string;\n\t/**\n\t * The number of rows the textarea should contain.\n\t *\n\t * @default 4\n\t */\n\trows?: TextareaHTMLAttributes< HTMLTextAreaElement >[ 'rows' ];\n};\n"],"mappings":""}