function filterOptions(searchValue, options, _ref2) {
  var optionFilterProp = _ref2.optionFilterProp,
      filterOption = _ref2.filterOption;
  var filteredOptions = [];
  var filterFunc;

  if (filterOption === false) {
    return options;
  }

  if (typeof filterOption === 'function') {
    filterFunc = filterOption;
  } else {
    filterFunc = getFilterFunction(optionFilterProp);
  }

  options.forEach(function (item) {
    // Group should check child options
    if ('options' in item) {
      // Check group first
      var matchGroup = filterFunc(searchValue, item);

      if (matchGroup) {
        filteredOptions.push(item);
      } else {
        // Check option
        var subOptions = item.options.filter(function (subItem) {
          return filterFunc(searchValue, subItem);
        });

        if (subOptions.length) {
          filteredOptions.push(_objectSpread(_objectSpread({}, item), {}, {
            options: subOptions
          }));
        }
      }

      return;
    }

    if (filterFunc(searchValue, injectPropsWithOption(item))) {
      filteredOptions.push(item);
    }
  });
  return filteredOptions;
}
/** Filter options and return a new options by the search text */
Filter options and return a new options by the search text
Filter options and return a new options by the search text
function filterOptions(searchValue, options, _ref2) {
  var optionFilterProp = _ref2.optionFilterProp,
      filterOption = _ref2.filterOption;
  var filteredOptions = [];
  var filterFunc;
  if (filterOption === false) {
    return options;
  }
  if (typeof filterOption === 'function') {
    filterFunc = filterOption;
  } else {
    filterFunc = getFilterFunction(optionFilterProp);
  }
  options.forEach(function (item) {
    if ('options' in item) {
      var matchGroup = filterFunc(searchValue, item);
      if (matchGroup) {
        filteredOptions.push(item);
      } else {
        var subOptions = item.options.filter(function (subItem) {
          return filterFunc(searchValue, subItem);
        });
        if (subOptions.length) {
          filteredOptions.push(_objectSpread(_objectSpread({}, item), {}, {
            options: subOptions
          }));
        }
      }
      return;
    }
    if (filterFunc(searchValue, injectPropsWithOption(item))) {
      filteredOptions.push(item);
    }
  });
  return filteredOptions;
}
function filterOptions ( searchValue , options , _ref2 ) { var optionFilterProp = _ref2 . optionFilterProp , filterOption = _ref2 . filterOption ; var filteredOptions = [ ] ; var filterFunc ; if ( filterOption === false ) { return options ; } if ( typeof filterOption === 'function' ) { filterFunc = filterOption ; } else { filterFunc = getFilterFunction ( optionFilterProp ) ; } options . forEach ( function ( item ) { if ( 'options' in item ) { var matchGroup = filterFunc ( searchValue , item ) ; if ( matchGroup ) { filteredOptions . push ( item ) ; } else { var subOptions = item . options . filter ( function ( subItem ) { return filterFunc ( searchValue , subItem ) ; } ) ; if ( subOptions . length ) { filteredOptions . push ( _objectSpread ( _objectSpread ( { } , item ) , { } , { options : subOptions } ) ) ; } } return ; } if ( filterFunc ( searchValue , injectPropsWithOption ( item ) ) ) { filteredOptions . push ( item ) ; } } ) ; return filteredOptions ; }
Filter options and return a new options by the search text
Filter options and return a new options by the search text
// Group should check child options // Check group first // Check option