strategyUtil.js
938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { isCheckDisabled } from './valueUtil';
export var SHOW_ALL = 'SHOW_ALL';
export var SHOW_PARENT = 'SHOW_PARENT';
export var SHOW_CHILD = 'SHOW_CHILD';
export function formatStrategyKeys(keys, strategy, keyEntities) {
var keySet = new Set(keys);
if (strategy === SHOW_CHILD) {
return keys.filter(function (key) {
var entity = keyEntities[key];
if (entity && entity.children && entity.children.every(function (_ref) {
var node = _ref.node;
return isCheckDisabled(node) || keySet.has(node.key);
})) {
return false;
}
return true;
});
}
if (strategy === SHOW_PARENT) {
return keys.filter(function (key) {
var entity = keyEntities[key];
var parent = entity ? entity.parent : null;
if (parent && !isCheckDisabled(parent.node) && keySet.has(parent.node.key)) {
return false;
}
return true;
});
}
return keys;
}