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,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=emotion.d.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/utils/hooks/emotion.d.ts"],"sourcesContent":["import type { EmotionCache } from '@emotion/utils';\n\ndeclare module '@emotion/react' {\n\texport function __unsafe_useEmotionCache(): EmotionCache | null;\n}\n"],"mappings":""}

View File

@@ -0,0 +1,42 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useControlledState", {
enumerable: true,
get: function () {
return _useControlledState.default;
}
});
Object.defineProperty(exports, "useControlledValue", {
enumerable: true,
get: function () {
return _useControlledValue.useControlledValue;
}
});
Object.defineProperty(exports, "useCx", {
enumerable: true,
get: function () {
return _useCx.useCx;
}
});
Object.defineProperty(exports, "useLatestRef", {
enumerable: true,
get: function () {
return _useLatestRef.useLatestRef;
}
});
Object.defineProperty(exports, "useUpdateEffect", {
enumerable: true,
get: function () {
return _useUpdateEffect.default;
}
});
var _useControlledState = _interopRequireDefault(require("./use-controlled-state"));
var _useUpdateEffect = _interopRequireDefault(require("./use-update-effect"));
var _useControlledValue = require("./use-controlled-value");
var _useCx = require("./use-cx");
var _useLatestRef = require("./use-latest-ref");
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_useControlledState","_interopRequireDefault","require","_useUpdateEffect","_useControlledValue","_useCx","_useLatestRef"],"sources":["@wordpress/components/src/utils/hooks/index.js"],"sourcesContent":["export { default as useControlledState } from './use-controlled-state';\nexport { default as useUpdateEffect } from './use-update-effect';\nexport { useControlledValue } from './use-controlled-value';\nexport { useCx } from './use-cx';\nexport { useLatestRef } from './use-latest-ref';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA"}

View File

@@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _element = require("@wordpress/element");
var _values = require("../values");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* @template T
* @typedef Options
* @property {T} [initial] Initial value
* @property {T | ""} fallback Fallback value
*/
/** @type {Readonly<{ initial: undefined, fallback: '' }>} */
const defaultOptions = {
initial: undefined,
/**
* Defaults to empty string, as that is preferred for usage with
* <input />, <textarea />, and <select /> form elements.
*/
fallback: ''
};
/**
* Custom hooks for "controlled" components to track and consolidate internal
* state and incoming values. This is useful for components that render
* `input`, `textarea`, or `select` HTML elements.
*
* https://reactjs.org/docs/forms.html#controlled-components
*
* At first, a component using useControlledState receives an initial prop
* value, which is used as initial internal state.
*
* This internal state can be maintained and updated without
* relying on new incoming prop values.
*
* Unlike the basic useState hook, useControlledState's state can
* be updated if a new incoming prop value is changed.
*
* @template T
*
* @param {T | undefined} currentState The current value.
* @param {Options<T>} [options=defaultOptions] Additional options for the hook.
*
* @return {[T | "", (nextState: T) => void]} The controlled value and the value setter.
*/
function useControlledState(currentState, options = defaultOptions) {
const {
initial,
fallback
} = {
...defaultOptions,
...options
};
const [internalState, setInternalState] = (0, _element.useState)(currentState);
const hasCurrentState = (0, _values.isValueDefined)(currentState);
/*
* Resets internal state if value every changes from uncontrolled <-> controlled.
*/
(0, _element.useEffect)(() => {
if (hasCurrentState && internalState) {
setInternalState(undefined);
}
}, [hasCurrentState, internalState]);
const state = (0, _values.getDefinedValue)([currentState, internalState, initial], fallback);
/* eslint-disable jsdoc/no-undefined-types */
/** @type {(nextState: T) => void} */
const setState = (0, _element.useCallback)(nextState => {
if (!hasCurrentState) {
setInternalState(nextState);
}
}, [hasCurrentState]);
/* eslint-enable jsdoc/no-undefined-types */
return [state, setState];
}
var _default = useControlledState;
exports.default = _default;
//# sourceMappingURL=use-controlled-state.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_values","defaultOptions","initial","undefined","fallback","useControlledState","currentState","options","internalState","setInternalState","useState","hasCurrentState","isValueDefined","useEffect","state","getDefinedValue","setState","useCallback","nextState","_default","exports","default"],"sources":["@wordpress/components/src/utils/hooks/use-controlled-state.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { isValueDefined, getDefinedValue } from '../values';\n\n/**\n * @template T\n * @typedef Options\n * @property {T} [initial] Initial value\n * @property {T | \"\"} fallback Fallback value\n */\n\n/** @type {Readonly<{ initial: undefined, fallback: '' }>} */\nconst defaultOptions = {\n\tinitial: undefined,\n\t/**\n\t * Defaults to empty string, as that is preferred for usage with\n\t * <input />, <textarea />, and <select /> form elements.\n\t */\n\tfallback: '',\n};\n\n/**\n * Custom hooks for \"controlled\" components to track and consolidate internal\n * state and incoming values. This is useful for components that render\n * `input`, `textarea`, or `select` HTML elements.\n *\n * https://reactjs.org/docs/forms.html#controlled-components\n *\n * At first, a component using useControlledState receives an initial prop\n * value, which is used as initial internal state.\n *\n * This internal state can be maintained and updated without\n * relying on new incoming prop values.\n *\n * Unlike the basic useState hook, useControlledState's state can\n * be updated if a new incoming prop value is changed.\n *\n * @template T\n *\n * @param {T | undefined} currentState The current value.\n * @param {Options<T>} [options=defaultOptions] Additional options for the hook.\n *\n * @return {[T | \"\", (nextState: T) => void]} The controlled value and the value setter.\n */\nfunction useControlledState( currentState, options = defaultOptions ) {\n\tconst { initial, fallback } = { ...defaultOptions, ...options };\n\n\tconst [ internalState, setInternalState ] = useState( currentState );\n\tconst hasCurrentState = isValueDefined( currentState );\n\n\t/*\n\t * Resets internal state if value every changes from uncontrolled <-> controlled.\n\t */\n\tuseEffect( () => {\n\t\tif ( hasCurrentState && internalState ) {\n\t\t\tsetInternalState( undefined );\n\t\t}\n\t}, [ hasCurrentState, internalState ] );\n\n\tconst state = getDefinedValue(\n\t\t[ currentState, internalState, initial ],\n\t\tfallback\n\t);\n\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {(nextState: T) => void} */\n\tconst setState = useCallback(\n\t\t( nextState ) => {\n\t\t\tif ( ! hasCurrentState ) {\n\t\t\t\tsetInternalState( nextState );\n\t\t\t}\n\t\t},\n\t\t[ hasCurrentState ]\n\t);\n\t/* eslint-enable jsdoc/no-undefined-types */\n\n\treturn [ state, setState ];\n}\n\nexport default useControlledState;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAME,cAAc,GAAG;EACtBC,OAAO,EAAEC,SAAS;EAClB;AACD;AACA;AACA;EACCC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAEC,YAAY,EAAEC,OAAO,GAAGN,cAAc,EAAG;EACrE,MAAM;IAAEC,OAAO;IAAEE;EAAS,CAAC,GAAG;IAAE,GAAGH,cAAc;IAAE,GAAGM;EAAQ,CAAC;EAE/D,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAG,IAAAC,iBAAQ,EAAEJ,YAAa,CAAC;EACpE,MAAMK,eAAe,GAAG,IAAAC,sBAAc,EAAEN,YAAa,CAAC;;EAEtD;AACD;AACA;EACC,IAAAO,kBAAS,EAAE,MAAM;IAChB,IAAKF,eAAe,IAAIH,aAAa,EAAG;MACvCC,gBAAgB,CAAEN,SAAU,CAAC;IAC9B;EACD,CAAC,EAAE,CAAEQ,eAAe,EAAEH,aAAa,CAAG,CAAC;EAEvC,MAAMM,KAAK,GAAG,IAAAC,uBAAe,EAC5B,CAAET,YAAY,EAAEE,aAAa,EAAEN,OAAO,CAAE,EACxCE,QACD,CAAC;;EAED;EACA;EACA,MAAMY,QAAQ,GAAG,IAAAC,oBAAW,EACzBC,SAAS,IAAM;IAChB,IAAK,CAAEP,eAAe,EAAG;MACxBF,gBAAgB,CAAES,SAAU,CAAC;IAC9B;EACD,CAAC,EACD,CAAEP,eAAe,CAClB,CAAC;EACD;;EAEA,OAAO,CAAEG,KAAK,EAAEE,QAAQ,CAAE;AAC3B;AAAC,IAAAG,QAAA,GAEcd,kBAAkB;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useControlledValue = useControlledValue;
var _element = require("@wordpress/element");
/**
* WordPress dependencies
*/
/**
* Simplified and improved implementation of useControlledState.
*
* @param props
* @param props.defaultValue
* @param props.value
* @param props.onChange
* @return The controlled value and the value setter.
*/
function useControlledValue({
defaultValue,
onChange,
value: valueProp
}) {
const hasValue = typeof valueProp !== 'undefined';
const initialValue = hasValue ? valueProp : defaultValue;
const [state, setState] = (0, _element.useState)(initialValue);
const value = hasValue ? valueProp : state;
let setValue;
if (hasValue && typeof onChange === 'function') {
setValue = onChange;
} else if (!hasValue && typeof onChange === 'function') {
setValue = nextValue => {
onChange(nextValue);
setState(nextValue);
};
} else {
setValue = setState;
}
return [value, setValue];
}
//# sourceMappingURL=use-controlled-value.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","useControlledValue","defaultValue","onChange","value","valueProp","hasValue","initialValue","state","setState","useState","setValue","nextValue"],"sources":["@wordpress/components/src/utils/hooks/use-controlled-value.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\ntype Props< T > = {\n\tdefaultValue?: T;\n\tvalue?: T;\n\tonChange?: ( value: T ) => void;\n};\n\n/**\n * Simplified and improved implementation of useControlledState.\n *\n * @param props\n * @param props.defaultValue\n * @param props.value\n * @param props.onChange\n * @return The controlled value and the value setter.\n */\nexport function useControlledValue< T >( {\n\tdefaultValue,\n\tonChange,\n\tvalue: valueProp,\n}: Props< T > ) {\n\tconst hasValue = typeof valueProp !== 'undefined';\n\tconst initialValue = hasValue ? valueProp : defaultValue;\n\tconst [ state, setState ] = useState( initialValue );\n\tconst value = hasValue ? valueProp : state;\n\n\tlet setValue: ( nextValue: T ) => void;\n\tif ( hasValue && typeof onChange === 'function' ) {\n\t\tsetValue = onChange;\n\t} else if ( ! hasValue && typeof onChange === 'function' ) {\n\t\tsetValue = ( nextValue ) => {\n\t\t\tonChange( nextValue );\n\t\t\tsetState( nextValue );\n\t\t};\n\t} else {\n\t\tsetValue = setState;\n\t}\n\n\treturn [ value, setValue as typeof setState ] as const;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAO;EACxCC,YAAY;EACZC,QAAQ;EACRC,KAAK,EAAEC;AACI,CAAC,EAAG;EACf,MAAMC,QAAQ,GAAG,OAAOD,SAAS,KAAK,WAAW;EACjD,MAAME,YAAY,GAAGD,QAAQ,GAAGD,SAAS,GAAGH,YAAY;EACxD,MAAM,CAAEM,KAAK,EAAEC,QAAQ,CAAE,GAAG,IAAAC,iBAAQ,EAAEH,YAAa,CAAC;EACpD,MAAMH,KAAK,GAAGE,QAAQ,GAAGD,SAAS,GAAGG,KAAK;EAE1C,IAAIG,QAAkC;EACtC,IAAKL,QAAQ,IAAI,OAAOH,QAAQ,KAAK,UAAU,EAAG;IACjDQ,QAAQ,GAAGR,QAAQ;EACpB,CAAC,MAAM,IAAK,CAAEG,QAAQ,IAAI,OAAOH,QAAQ,KAAK,UAAU,EAAG;IAC1DQ,QAAQ,GAAKC,SAAS,IAAM;MAC3BT,QAAQ,CAAES,SAAU,CAAC;MACrBH,QAAQ,CAAEG,SAAU,CAAC;IACtB,CAAC;EACF,CAAC,MAAM;IACND,QAAQ,GAAGF,QAAQ;EACpB;EAEA,OAAO,CAAEL,KAAK,EAAEO,QAAQ,CAAqB;AAC9C"}

View File

@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useCx = void 0;
var _react = require("@emotion/react");
var _utils = require("@emotion/utils");
var _css = require("@emotion/css");
var _element = require("@wordpress/element");
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
/**
* WordPress dependencies
*/
const isSerializedStyles = o => typeof o !== 'undefined' && o !== null && ['name', 'styles'].every(p => typeof o[p] !== 'undefined');
/**
* Retrieve a `cx` function that knows how to handle `SerializedStyles`
* returned by the `@emotion/react` `css` function in addition to what
* `cx` normally knows how to handle. It also hooks into the Emotion
* Cache, allowing `css` calls to work inside iframes.
*
* ```jsx
* import { css } from '@emotion/react';
*
* const styles = css`
* color: red
* `;
*
* function RedText( { className, ...props } ) {
* const cx = useCx();
*
* const classes = cx(styles, className);
*
* return <span className={classes} {...props} />;
* }
* ```
*/
const useCx = () => {
const cache = (0, _react.__unsafe_useEmotionCache)();
const cx = (0, _element.useCallback)((...classNames) => {
if (cache === null) {
throw new Error('The `useCx` hook should be only used within a valid Emotion Cache Context');
}
return (0, _css.cx)(...classNames.map(arg => {
if (isSerializedStyles(arg)) {
(0, _utils.insertStyles)(cache, arg, false);
return `${cache.key}-${arg.name}`;
}
return arg;
}));
}, [cache]);
return cx;
};
exports.useCx = useCx;
//# sourceMappingURL=use-cx.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_react","require","_utils","_css","_element","isSerializedStyles","o","every","p","useCx","cache","useEmotionCache","cx","useCallback","classNames","Error","innerCx","map","arg","insertStyles","key","name","exports"],"sources":["@wordpress/components/src/utils/hooks/use-cx.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { __unsafe_useEmotionCache as useEmotionCache } from '@emotion/react';\nimport type { SerializedStyles } from '@emotion/serialize';\nimport { insertStyles } from '@emotion/utils';\n// eslint-disable-next-line no-restricted-imports\nimport type { ClassNamesArg } from '@emotion/css';\n// eslint-disable-next-line no-restricted-imports\nimport { cx as innerCx } from '@emotion/css';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\nconst isSerializedStyles = ( o: any ): o is SerializedStyles =>\n\ttypeof o !== 'undefined' &&\n\to !== null &&\n\t[ 'name', 'styles' ].every( ( p ) => typeof o[ p ] !== 'undefined' );\n\n/**\n * Retrieve a `cx` function that knows how to handle `SerializedStyles`\n * returned by the `@emotion/react` `css` function in addition to what\n * `cx` normally knows how to handle. It also hooks into the Emotion\n * Cache, allowing `css` calls to work inside iframes.\n *\n * ```jsx\n * import { css } from '@emotion/react';\n *\n * const styles = css`\n * \tcolor: red\n * `;\n *\n * function RedText( { className, ...props } ) {\n * \tconst cx = useCx();\n *\n * \tconst classes = cx(styles, className);\n *\n * \treturn <span className={classes} {...props} />;\n * }\n * ```\n */\nexport const useCx = () => {\n\tconst cache = useEmotionCache();\n\n\tconst cx = useCallback(\n\t\t( ...classNames: ( ClassNamesArg | SerializedStyles )[] ) => {\n\t\t\tif ( cache === null ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The `useCx` hook should be only used within a valid Emotion Cache Context'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn innerCx(\n\t\t\t\t...classNames.map( ( arg ) => {\n\t\t\t\t\tif ( isSerializedStyles( arg ) ) {\n\t\t\t\t\t\tinsertStyles( cache, arg, false );\n\t\t\t\t\t\treturn `${ cache.key }-${ arg.name }`;\n\t\t\t\t\t}\n\t\t\t\t\treturn arg;\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t[ cache ]\n\t);\n\n\treturn cx;\n};\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAIA,IAAAE,IAAA,GAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AAdA;AACA;AACA;;AAMA;;AAGA;AACA;AACA;;AAGA,MAAMI,kBAAkB,GAAKC,CAAM,IAClC,OAAOA,CAAC,KAAK,WAAW,IACxBA,CAAC,KAAK,IAAI,IACV,CAAE,MAAM,EAAE,QAAQ,CAAE,CAACC,KAAK,CAAIC,CAAC,IAAM,OAAOF,CAAC,CAAEE,CAAC,CAAE,KAAK,WAAY,CAAC;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,KAAK,GAAGA,CAAA,KAAM;EAC1B,MAAMC,KAAK,GAAG,IAAAC,+BAAe,EAAC,CAAC;EAE/B,MAAMC,EAAE,GAAG,IAAAC,oBAAW,EACrB,CAAE,GAAGC,UAAkD,KAAM;IAC5D,IAAKJ,KAAK,KAAK,IAAI,EAAG;MACrB,MAAM,IAAIK,KAAK,CACd,2EACD,CAAC;IACF;IAEA,OAAO,IAAAC,OAAO,EACb,GAAGF,UAAU,CAACG,GAAG,CAAIC,GAAG,IAAM;MAC7B,IAAKb,kBAAkB,CAAEa,GAAI,CAAC,EAAG;QAChC,IAAAC,mBAAY,EAAET,KAAK,EAAEQ,GAAG,EAAE,KAAM,CAAC;QACjC,OAAQ,GAAGR,KAAK,CAACU,GAAK,IAAIF,GAAG,CAACG,IAAM,EAAC;MACtC;MACA,OAAOH,GAAG;IACX,CAAE,CACH,CAAC;EACF,CAAC,EACD,CAAER,KAAK,CACR,CAAC;EAED,OAAOE,EAAE;AACV,CAAC;AAACU,OAAA,CAAAb,KAAA,GAAAA,KAAA"}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useLatestRef = useLatestRef;
var _element = require("@wordpress/element");
var _compose = require("@wordpress/compose");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Creates a reference for a prop. This is useful for preserving dependency
* memoization for hooks like useCallback.
*
* @see https://codesandbox.io/s/uselatestref-mlj3i?file=/src/App.tsx
*
* @param value The value to reference
* @return The prop reference.
*/
function useLatestRef(value) {
const ref = (0, _element.useRef)(value);
(0, _compose.useIsomorphicLayoutEffect)(() => {
ref.current = value;
});
return ref;
}
//# sourceMappingURL=use-latest-ref.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_compose","useLatestRef","value","ref","useRef","useIsomorphicLayoutEffect","current"],"sources":["@wordpress/components/src/utils/hooks/use-latest-ref.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Creates a reference for a prop. This is useful for preserving dependency\n * memoization for hooks like useCallback.\n *\n * @see https://codesandbox.io/s/uselatestref-mlj3i?file=/src/App.tsx\n *\n * @param value The value to reference\n * @return The prop reference.\n */\nexport function useLatestRef< T >( value: T ): RefObject< T > {\n\tconst ref = useRef( value );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tref.current = value;\n\t} );\n\n\treturn ref;\n}\n"],"mappings":";;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAAOC,KAAQ,EAAmB;EAC7D,MAAMC,GAAG,GAAG,IAAAC,eAAM,EAAEF,KAAM,CAAC;EAE3B,IAAAG,kCAAyB,EAAE,MAAM;IAChCF,GAAG,CAACG,OAAO,GAAGJ,KAAK;EACpB,CAAE,CAAC;EAEH,OAAOC,GAAG;AACX"}

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _element = require("@wordpress/element");
/**
* WordPress dependencies
*/
/**
* A `React.useEffect` that will not run on the first render.
* Source:
* https://github.com/reakit/reakit/blob/HEAD/packages/reakit-utils/src/useUpdateEffect.ts
*
* @param {import('react').EffectCallback} effect
* @param {import('react').DependencyList} deps
*/
function useUpdateEffect(effect, deps) {
const mounted = (0, _element.useRef)(false);
(0, _element.useEffect)(() => {
if (mounted.current) {
return effect();
}
mounted.current = true;
return undefined;
// Disable reasons:
// 1. This hook needs to pass a dep list that isn't an array literal
// 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings
// see https://github.com/WordPress/gutenberg/pull/41166
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);
}
var _default = useUpdateEffect;
exports.default = _default;
//# sourceMappingURL=use-update-effect.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","useUpdateEffect","effect","deps","mounted","useRef","useEffect","current","undefined","_default","exports","default"],"sources":["@wordpress/components/src/utils/hooks/use-update-effect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\n/**\n * A `React.useEffect` that will not run on the first render.\n * Source:\n * https://github.com/reakit/reakit/blob/HEAD/packages/reakit-utils/src/useUpdateEffect.ts\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mounted = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mounted.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmounted.current = true;\n\t\treturn undefined;\n\t\t// Disable reasons:\n\t\t// 1. This hook needs to pass a dep list that isn't an array literal\n\t\t// 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, deps );\n}\n\nexport default useUpdateEffect;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EACxC,MAAMC,OAAO,GAAG,IAAAC,eAAM,EAAE,KAAM,CAAC;EAC/B,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKF,OAAO,CAACG,OAAO,EAAG;MACtB,OAAOL,MAAM,CAAC,CAAC;IAChB;IACAE,OAAO,CAACG,OAAO,GAAG,IAAI;IACtB,OAAOC,SAAS;IAChB;IACA;IACA;IACA;IACA;EACD,CAAC,EAAEL,IAAK,CAAC;AACV;AAAC,IAAAM,QAAA,GAEcR,eAAe;AAAAS,OAAA,CAAAC,OAAA,GAAAF,QAAA"}