Skip to content

Instantly share code, notes, and snippets.

@chrisdhanaraj
Last active May 24, 2021 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdhanaraj/5185f903367e6b8b2ffd07c316abb91f to your computer and use it in GitHub Desktop.
Save chrisdhanaraj/5185f903367e6b8b2ffd07c316abb91f to your computer and use it in GitHub Desktop.
Descrbing the filter bar

Filter Bar

Allow a user to type to either

A) Filter available keys by name B) Filter available keys by validation C) Filter available values for defined lists

When I say "list", then the getItemProps goes on every list item
that the editor renders.

For everything else, the getItemProps goes on the parent div

"Items", then, is

A) In idle state, it's all keys and all list items
B) In filter-key state, its all validated keys & all list items
C) In key-selected state, it's either
  1) If a list, it's each individual item
  2) If anything else, it's the parent div wrapper

So... items is actually only important when there is a list. Otherwise we can set it to [].

interface Configuration {
  key: {
    type: 'list' | 'date' | 'input',
    label: string;
    renderLabelValues: (selectedItems) => string;
    itemToString: (item) => string;
    renderEditorComponent: ({
      inputValue,
      selectedItems,
      selectItem,
      removeItem,
      selectMultipleItems
    }) => React.ReactCHild
  }
}

interface ListConfiguration {
  type: 'list',
  label: string;
  renderLabelValues: () => string;
  itemToString: () => string;
}

interface AddItem {}
interface RemoveItem {}

interface SelectedItems {
  `key-uuid`: {}
}
<FilterBar
  validations={({
    inputValue,
    defaultKeys,
    state
  }) => {
    return validKeys
  }}
  configuration={{
  }}
  onEvent={(event) => {
    if (event.type === 'ADD_ITEM') {}
    if (event.type === 'APPLY') {}
  }}

>
Apply ---> merges the keys into a straight object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment