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>
46 lines
2.3 KiB
JavaScript
46 lines
2.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.validateSpanningCellConfig = void 0;
|
|
const utils_1 = require("./utils");
|
|
const inRange = (start, end, value) => {
|
|
return start <= value && value <= end;
|
|
};
|
|
const validateSpanningCellConfig = (rows, configs) => {
|
|
const [nRow, nCol] = [rows.length, rows[0].length];
|
|
configs.forEach((config, configIndex) => {
|
|
const { colSpan, rowSpan } = config;
|
|
if (colSpan === undefined && rowSpan === undefined) {
|
|
throw new Error(`Expect at least colSpan or rowSpan is provided in config.spanningCells[${configIndex}]`);
|
|
}
|
|
if (colSpan !== undefined && colSpan < 1) {
|
|
throw new Error(`Expect colSpan is not equal zero, instead got: ${colSpan} in config.spanningCells[${configIndex}]`);
|
|
}
|
|
if (rowSpan !== undefined && rowSpan < 1) {
|
|
throw new Error(`Expect rowSpan is not equal zero, instead got: ${rowSpan} in config.spanningCells[${configIndex}]`);
|
|
}
|
|
});
|
|
const rangeCoordinates = configs.map(utils_1.calculateRangeCoordinate);
|
|
rangeCoordinates.forEach(({ topLeft, bottomRight }, rangeIndex) => {
|
|
if (!inRange(0, nCol - 1, topLeft.col) ||
|
|
!inRange(0, nRow - 1, topLeft.row) ||
|
|
!inRange(0, nCol - 1, bottomRight.col) ||
|
|
!inRange(0, nRow - 1, bottomRight.row)) {
|
|
throw new Error(`Some cells in config.spanningCells[${rangeIndex}] are out of the table`);
|
|
}
|
|
});
|
|
const configOccupy = Array.from({ length: nRow }, () => {
|
|
return Array.from({ length: nCol });
|
|
});
|
|
rangeCoordinates.forEach(({ topLeft, bottomRight }, rangeIndex) => {
|
|
(0, utils_1.sequence)(topLeft.row, bottomRight.row).forEach((row) => {
|
|
(0, utils_1.sequence)(topLeft.col, bottomRight.col).forEach((col) => {
|
|
if (configOccupy[row][col] !== undefined) {
|
|
throw new Error(`Spanning cells in config.spanningCells[${configOccupy[row][col]}] and config.spanningCells[${rangeIndex}] are overlap each other`);
|
|
}
|
|
configOccupy[row][col] = rangeIndex;
|
|
});
|
|
});
|
|
});
|
|
};
|
|
exports.validateSpanningCellConfig = validateSpanningCellConfig;
|
|
//# sourceMappingURL=validateSpanningCellConfig.js.map
|