3e947f38c2f858a67b32a63cc4207c3ea89b6a9cec32d2a2285576f40cdc4681418b4cc274f78192afc62353c4795093dd6ee1652ff6ea61d0f3cc4967209c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var aria = require('../../../utils/dom/aria.js');
  4. const getMenuIndex = (el) => {
  5. if (!el)
  6. return 0;
  7. const pieces = el.id.split("-");
  8. return Number(pieces[pieces.length - 2]);
  9. };
  10. const checkNode = (el) => {
  11. if (!el)
  12. return;
  13. const input = el.querySelector("input");
  14. if (input) {
  15. input.click();
  16. } else if (aria.isLeaf(el)) {
  17. el.click();
  18. }
  19. };
  20. const sortByOriginalOrder = (oldNodes, newNodes) => {
  21. const newNodesCopy = newNodes.slice(0);
  22. const newIds = newNodesCopy.map((node) => node.uid);
  23. const res = oldNodes.reduce((acc, item) => {
  24. const index = newIds.indexOf(item.uid);
  25. if (index > -1) {
  26. acc.push(item);
  27. newNodesCopy.splice(index, 1);
  28. newIds.splice(index, 1);
  29. }
  30. return acc;
  31. }, []);
  32. res.push(...newNodesCopy);
  33. return res;
  34. };
  35. exports.checkNode = checkNode;
  36. exports.getMenuIndex = getMenuIndex;
  37. exports.sortByOriginalOrder = sortByOriginalOrder;
  38. //# sourceMappingURL=utils.js.map