Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getLabel() {
const { options, displayRender = defaultDisplayRender as Function } = this.props;
const names = getFilledFieldNames(this.props);
const { value } = this.state;
const unwrappedValue = Array.isArray(value[0]) ? value[0] : value;
const selectedOptions: CascaderOptionType[] = arrayTreeFilter(
options,
(o: CascaderOptionType, level: number) => o[names.value] === unwrappedValue[level],
{ childrenKeyName: names.children },
);
const label = selectedOptions.map(o => o[names.label]);
return displayRender(label, selectedOptions);
}
getActiveOptions(activeValue) {
return arrayTreeFilter(
this.props.options || [],
(o, level) => o[this.getFieldName('value')] === activeValue[level],
{ childrenKeyName: this.getFieldName('children') },
);
}
setPopupVisible = popupVisible => {
getCurrentLevelOptions(): CascaderOption[] {
const { options = [] } = this.props;
const { activeValue = [] } = this.state;
const result = arrayTreeFilter(
options,
(o, level) => o[this.getFieldName('value')] === activeValue[level],
{ childrenKeyName: this.getFieldName('children') },
);
if (result[result.length - 2]) {
return result[result.length - 2][this.getFieldName('children')];
}
return [...options].filter(o => !o.disabled);
}
getActiveOptions(activeValue) {
return arrayTreeFilter(
this.props.options || [],
(o, level) => o[this.getFieldName('value')] === activeValue[level],
{childrenKeyName: this.getFieldName('children')}
);
}
getChildrenTree() {
const {data, cols} = this.props;
const value = this.state.value;
const childrenTree = arrayTreeFilter(data, (c, level) => {
return c.value === value[level];
}).map(c => c.children);
childrenTree.length = cols - 1;
childrenTree.unshift(data);
return childrenTree;
},
};
getActiveOptions(values?: CascaderOption[]): CascaderOption[] {
const { options } = this.props;
const activeValue = values || this.props.activeValue;
return arrayTreeFilter(
options,
(o, level) => o[this.getFieldName('value')] === activeValue[level],
{ childrenKeyName: this.getFieldName('children') },
);
}