You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
892 B
37 lines
892 B
11 months ago
|
import { isLeaf } from '../../../utils/aria.mjs';
|
||
|
|
||
|
const getMenuIndex = (el) => {
|
||
|
if (!el)
|
||
|
return 0;
|
||
|
const pieces = el.id.split("-");
|
||
|
return Number(pieces[pieces.length - 2]);
|
||
|
};
|
||
|
const checkNode = (el) => {
|
||
|
if (!el)
|
||
|
return;
|
||
|
const input = el.querySelector("input");
|
||
|
if (input) {
|
||
|
input.click();
|
||
|
} else if (isLeaf(el)) {
|
||
|
el.click();
|
||
|
}
|
||
|
};
|
||
|
const sortByOriginalOrder = (oldNodes, newNodes) => {
|
||
|
const newNodesCopy = newNodes.slice(0);
|
||
|
const newIds = newNodesCopy.map((node) => node.uid);
|
||
|
const res = oldNodes.reduce((acc, item) => {
|
||
|
const index = newIds.indexOf(item.uid);
|
||
|
if (index > -1) {
|
||
|
acc.push(item);
|
||
|
newNodesCopy.splice(index, 1);
|
||
|
newIds.splice(index, 1);
|
||
|
}
|
||
|
return acc;
|
||
|
}, []);
|
||
|
res.push(...newNodesCopy);
|
||
|
return res;
|
||
|
};
|
||
|
|
||
|
export { checkNode, getMenuIndex, sortByOriginalOrder };
|
||
|
//# sourceMappingURL=utils.mjs.map
|