How to use array-tree-filter - 6 common examples

To help you get started, we’ve selected a few array-tree-filter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ant-design / ant-design / components / cascader / index.tsx View on Github external
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);
  }
github iuap-design / bee.tinper.org / tinper-bee / bee-cascader / src / rc / index.jsx View on Github external
getActiveOptions(activeValue) {
    return arrayTreeFilter(
      this.props.options || [],
      (o, level) => o[this.getFieldName('value')] === activeValue[level],
      { childrenKeyName: this.getFieldName('children') },
    );
  }
  setPopupVisible = popupVisible => {
github react-component / cascader / src / Cascader.tsx View on Github external
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);
  }
github NSFI / ppfish-components / source / components / Cascader / src / Cascader.js View on Github external
getActiveOptions(activeValue) {
    return arrayTreeFilter(
      this.props.options || [],
      (o, level) => o[this.getFieldName('value')] === activeValue[level],
      {childrenKeyName: this.getFieldName('children')}
    );
  }
github react-component / m-cascader / src / CascaderMixin.tsx View on Github external
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;
  },
};
github react-component / cascader / src / Menus.tsx View on Github external
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') },
    );
  }

array-tree-filter

filter in array tree

MIT
Latest version published 2 months ago

Package Health Score

80 / 100
Full package analysis

Popular array-tree-filter functions