How to use the match-sorter function in match-sorter

To help you get started, we’ve selected a few match-sorter 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 austintackaberry / jobsort / client / src / components / InputTechnologies.jsx View on Github external
addTechnology({ selection, highlightedIndex }) {
    const { inputValue } = this.state;
    const { allTechs, userTechnologies } = this.props;
    // If there is a selection then make that the value
    let lastUserAddedTechnology = selection;
    if (!lastUserAddedTechnology) {
      if (highlightedIndex === null) {
        // If the user didn't select an option from dropdown, use the input as the value
        lastUserAddedTechnology = inputValue.toLowerCase();
      } else {
        const matches = matchSorter(allTechs, inputValue.toLowerCase()).filter(
          i => !inputValue.toLowerCase() || i.includes(inputValue.toLowerCase())
        );
        if (matches[highlightedIndex] === inputValue) {
          // This is only for edge cases (user types "java" but selects "javascript")
          // Note that in the case above, addTechnology gets called twice. Once with a
          // selection, and once without a selection
          lastUserAddedTechnology = inputValue.toLowerCase();
        }
      }
    }
    if (
      !userTechnologies.some(
        element => element.language === lastUserAddedTechnology
      ) &&
      allTechs.includes(lastUserAddedTechnology)
    ) {
github Thorium-Sim / thorium / src / helpers / soundPicker.js View on Github external
    () => matchSorter(allObjects, search, {keys: ["name"]}),
    [allObjects, search],
github baidu / amis / src / components / Select.tsx View on Github external
checkAll,
      checkAllLabel,
      searchable,
      createBtnLabel,
      disabled,
      searchPromptText,
      editable,
      removable
    } = this.props;
    const { selection } = this.state;

    let checkedAll = false;
    let checkedPartial = false;
    let filtedOptions: Array<option> =
      inputValue &amp;&amp; isOpen &amp;&amp; !loadOptions
        ? matchSorter(options, inputValue, {
            keys: [labelField || "label", valueField || "value"]
          })
        : options.concat();

    const selectionValues = selection.map(select =&gt; select.value);
    if (multiple &amp;&amp; checkAll) {
      const optionsValues = options.map(option =&gt; option.value);

      checkedAll = optionsValues.every(
        option =&gt; selectionValues.indexOf(option) &gt; -1
      );
      checkedPartial = optionsValues.some(
        option =&gt; selectionValues.indexOf(option) &gt; -1
      );
    }
</option>
github slidewiki / slidewiki-platform / components / common / SWAutocompleteShared.js View on Github external
function getItems(filter) {
    return filter
        ? matchSorter(allItems, filter, {
            keys: ['name'],
        })
        : allItems;
}
github tannerlinsley / react-table / examples / kitchen-sink-controlled / src / App.js View on Github external
function fuzzyTextFilterFn(rows, id, filterValue) {
  return matchSorter(rows, filterValue, { keys: [row => row.values[id]] })
}
github downshift-js / downshift / stories / examples / semi-controlled-list.js View on Github external
getItemProps,
        highlightedIndex,
        inputValue,
        isOpen,
        selectedItem,
      }) =&gt; (
        <div>
          <input color="">
          {isOpen &amp;&amp; (
            <div style="{{border:">
              {(inputValue ? matchSorter(items, inputValue) : items).map(
                (item, index) =&gt; (
                  
                    {item}
                  
                ),
              )}
            </div>
          )}
        </div>
github rakannimer / react-firebase / modules / tutorial-bookmarking-app / src / AutoComplete.tsx View on Github external
aria-label="Clear Input"
                    onClick={() =&gt; {
                      clearSelection();
                    }}
                    onMouseDown={() =&gt; {}}
                  &gt;
                    
                  
                
              }
              {...getInputProps()}
            /&gt;

            <div>
              {isOpen
                ? matchSorter(items, `${inputValue}`, {
                    keys: ["link_description"]
                  }).map((item, index) =&gt; (
                    
                      
                        </div>
github EddyVinck / ConfTalks / client / components / generic / MultiSelect.tsx View on Github external
const getItems = (filter) => {
    return filter
      ? matchSorter(props.items, filter, {
          keys: props.itemFilterKeys,
        })
      : props.items;
  }
github tannerlinsley / react-table / examples / animated / src / App.js View on Github external
function fuzzyTextFilterFn(rows, id, filterValue) {
  return matchSorter(rows, filterValue, { keys: [row => row.values[id]] })
}

match-sorter

Simple, expected, and deterministic best-match sorting of an array in JavaScript

MIT
Latest version published 3 months ago

Package Health Score

91 / 100
Full package analysis