Files
formipay/node_modules/stylelint/lib/rules/named-grid-areas-no-invalid/utils/findNotContiguousOrRectangular.js
dwindown e8fbfb14c1 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>
2026-04-18 17:02:14 +07:00

65 lines
1.1 KiB
JavaScript

'use strict';
const arrayEqual = require('../../../utils/arrayEqual');
/**
*
* @param {string[][]} areas
* @param {string} name
* @returns {boolean}
*/
function isContiguousAndRectangular(areas, name) {
const indicesByRow = areas.map((row) => {
const indices = [];
let idx = row.indexOf(name);
while (idx !== -1) {
indices.push(idx);
idx = row.indexOf(name, idx + 1);
}
return indices;
});
for (let i = 0; i < indicesByRow.length; i++) {
for (let j = i + 1; j < indicesByRow.length; j++) {
const x = indicesByRow[i];
const y = indicesByRow[j];
if ((x && x.length === 0) || (y && y.length === 0)) {
continue;
}
if (!arrayEqual(x, y)) {
return false;
}
}
}
return true;
}
/**
*
* @param {string[][]} areas
* @returns {string[]}
*/
function namedAreas(areas) {
const names = new Set(areas.flat());
names.delete('.');
return [...names];
}
/**
*
* @param {string[][]} areas
* @returns {string[]}
*/
function findNotContiguousOrRectangular(areas) {
return namedAreas(areas).filter((name) => !isContiguousAndRectangular(areas, name));
}
module.exports = findNotContiguousOrRectangular;