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>
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
/* eslint-disable jsdoc/valid-types */
|
|
/**
|
|
* Determines if a value is null or undefined.
|
|
*
|
|
* @template T
|
|
*
|
|
* @param {T} value The value to check.
|
|
* @return {value is Exclude<T, null | undefined>} Whether value is not null or undefined.
|
|
*/
|
|
export function isValueDefined(value) {
|
|
return value !== undefined && value !== null;
|
|
}
|
|
/* eslint-enable jsdoc/valid-types */
|
|
|
|
/* eslint-disable jsdoc/valid-types */
|
|
/**
|
|
* Determines if a value is empty, null, or undefined.
|
|
*
|
|
* @param {string | number | null | undefined} value The value to check.
|
|
* @return {value is ("" | null | undefined)} Whether value is empty.
|
|
*/
|
|
export function isValueEmpty(value) {
|
|
const isEmptyString = value === '';
|
|
return !isValueDefined(value) || isEmptyString;
|
|
}
|
|
/* eslint-enable jsdoc/valid-types */
|
|
|
|
/**
|
|
* Get the first defined/non-null value from an array.
|
|
*
|
|
* @template T
|
|
*
|
|
* @param {Array<T | null | undefined>} values Values to derive from.
|
|
* @param {T} fallbackValue Fallback value if there are no defined values.
|
|
* @return {T} A defined value or the fallback value.
|
|
*/
|
|
export function getDefinedValue(values = [], fallbackValue) {
|
|
var _values$find;
|
|
return (_values$find = values.find(isValueDefined)) !== null && _values$find !== void 0 ? _values$find : fallbackValue;
|
|
}
|
|
|
|
/**
|
|
* Converts a string to a number.
|
|
*
|
|
* @param {string} value
|
|
* @return {number} String as a number.
|
|
*/
|
|
export const stringToNumber = value => {
|
|
return parseFloat(value);
|
|
};
|
|
|
|
/**
|
|
* Regardless of the input being a string or a number, returns a number.
|
|
*
|
|
* Returns `undefined` in case the string is `undefined` or not a valid numeric value.
|
|
*
|
|
* @param {string | number} value
|
|
* @return {number} The parsed number.
|
|
*/
|
|
export const ensureNumber = value => {
|
|
return typeof value === 'string' ? stringToNumber(value) : value;
|
|
};
|
|
//# sourceMappingURL=values.js.map
|