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,62 @@
import { createElement } from "react";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* Internal dependencies
*/
export const noop = () => {};
/**
* FormToggle switches a single setting on or off.
*
* ```jsx
* import { FormToggle } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const MyFormToggle = () => {
* const [ isChecked, setChecked ] = useState( true );
*
* return (
* <FormToggle
* checked={ isChecked }
* onChange={ () => setChecked( ( state ) => ! state ) }
* />
* );
* };
* ```
*/
export function FormToggle(props) {
const {
className,
checked,
id,
disabled,
onChange = noop,
...additionalProps
} = props;
const wrapperClasses = classnames('components-form-toggle', className, {
'is-checked': checked,
'is-disabled': disabled
});
return createElement("span", {
className: wrapperClasses
}, createElement("input", {
className: "components-form-toggle__input",
id: id,
type: "checkbox",
checked: checked,
onChange: onChange,
disabled: disabled,
...additionalProps
}), createElement("span", {
className: "components-form-toggle__track"
}), createElement("span", {
className: "components-form-toggle__thumb"
}));
}
export default FormToggle;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["classnames","noop","FormToggle","props","className","checked","id","disabled","onChange","additionalProps","wrapperClasses","createElement","type"],"sources":["@wordpress/components/src/form-toggle/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport type { FormToggleProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nexport const noop = () => {};\n\n/**\n * FormToggle switches a single setting on or off.\n *\n * ```jsx\n * import { FormToggle } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyFormToggle = () => {\n * const [ isChecked, setChecked ] = useState( true );\n *\n * return (\n * <FormToggle\n * checked={ isChecked }\n * onChange={ () => setChecked( ( state ) => ! state ) }\n * />\n * );\n * };\n * ```\n */\nexport function FormToggle(\n\tprops: WordPressComponentProps< FormToggleProps, 'input', false >\n) {\n\tconst {\n\t\tclassName,\n\t\tchecked,\n\t\tid,\n\t\tdisabled,\n\t\tonChange = noop,\n\t\t...additionalProps\n\t} = props;\n\tconst wrapperClasses = classnames( 'components-form-toggle', className, {\n\t\t'is-checked': checked,\n\t\t'is-disabled': disabled,\n\t} );\n\n\treturn (\n\t\t<span className={ wrapperClasses }>\n\t\t\t<input\n\t\t\t\tclassName=\"components-form-toggle__input\"\n\t\t\t\tid={ id }\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\tchecked={ checked }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t\t<span className=\"components-form-toggle__track\"></span>\n\t\t\t<span className=\"components-form-toggle__thumb\"></span>\n\t\t</span>\n\t);\n}\n\nexport default FormToggle;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;;AAIA,OAAO,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CACzBC,KAAiE,EAChE;EACD,MAAM;IACLC,SAAS;IACTC,OAAO;IACPC,EAAE;IACFC,QAAQ;IACRC,QAAQ,GAAGP,IAAI;IACf,GAAGQ;EACJ,CAAC,GAAGN,KAAK;EACT,MAAMO,cAAc,GAAGV,UAAU,CAAE,wBAAwB,EAAEI,SAAS,EAAE;IACvE,YAAY,EAAEC,OAAO;IACrB,aAAa,EAAEE;EAChB,CAAE,CAAC;EAEH,OACCI,aAAA;IAAMP,SAAS,EAAGM;EAAgB,GACjCC,aAAA;IACCP,SAAS,EAAC,+BAA+B;IACzCE,EAAE,EAAGA,EAAI;IACTM,IAAI,EAAC,UAAU;IACfP,OAAO,EAAGA,OAAS;IACnBG,QAAQ,EAAGA,QAAU;IACrBD,QAAQ,EAAGA,QAAU;IAAA,GAChBE;EAAe,CACpB,CAAC,EACFE,aAAA;IAAMP,SAAS,EAAC;EAA+B,CAAO,CAAC,EACvDO,aAAA;IAAMP,SAAS,EAAC;EAA+B,CAAO,CACjD,CAAC;AAET;AAEA,eAAeF,UAAU"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/form-toggle/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ChangeEvent } from 'react';\n\nexport type FormToggleProps = {\n\t/**\n\t * If checked is true the toggle will be checked. If checked is false the\n\t * toggle will be unchecked. If no value is passed the toggle will be\n\t * unchecked.\n\t */\n\tchecked?: boolean;\n\t/**\n\t * If disabled is true the toggle will be disabled and apply the appropriate\n\t * styles.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * A callback function invoked when the toggle is clicked.\n\t */\n\tonChange: ( event: ChangeEvent< HTMLInputElement > ) => void;\n};\n"],"mappings":""}