UNPKG

vue-gantt-3

Version:

A gantt component for Vue 3

67 lines (66 loc) 1.96 kB
const getRound = (floatNum, num = 3) => { return parseFloat(floatNum.toFixed(num)); }; function treeForEachSkipChildren(tree, fn, childrenKey = "children", parent) { let size = tree.length; for (let i = 0; i < size; i++) { const curNode = tree[i]; const res = fn(curNode, parent); if (res === false) return false; if (res === "skipChildren") continue; const children = curNode == null ? void 0 : curNode[childrenKey]; if (children == null ? void 0 : children.length) { if (treeForEachSkipChildren(children, fn, childrenKey, curNode) === false) { return false; } } } } function treeForEach(tree, fn, childrenKey = "children", parent) { let size = tree.length; for (let i = 0; i < size; i++) { const curNode = tree[i]; if (fn(curNode, parent) === false) return false; const children = curNode == null ? void 0 : curNode[childrenKey]; if (children == null ? void 0 : children.length) { if (treeForEach(children, fn, childrenKey, curNode) === false) { return false; } } } } const arrangementArr = (source, target, idKey = "id") => { const targetIds = target.map((item) => item[idKey]); const arr = new Array(source.length); const indexMap = /* @__PURE__ */ new Map(); targetIds.forEach((id, index) => { indexMap.set(id, index); }); const unMatchArr = source.filter((item) => { const id = item[idKey]; if (indexMap.has(id)) { let index = indexMap.get(id); arr[index] = item; } return !indexMap.has(id); }); if (unMatchArr.length > 0) { let index = 0; for (let i = 0; i < arr.length; i++) { if (arr[i] === void 0) { arr[i] = unMatchArr[index++]; } if (index >= unMatchArr.length) { break; } } } return arr.filter((item) => item !== void 0); }; export { arrangementArr, getRound, treeForEach, treeForEachSkipChildren }; //# sourceMappingURL=common.mjs.map