mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
42
src/components/ContactsMultiSelect.js
Normal file
42
src/components/ContactsMultiSelect.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import { MenuItem } from '@blueprintjs/core';
|
||||
import { MultiSelect } from '../components/MultiSelectTaggable';
|
||||
|
||||
/**
|
||||
* Contacts multi-select component.
|
||||
*/
|
||||
export default function ContactsMultiSelect({ ...multiSelectProps }) {
|
||||
// Filters accounts items.
|
||||
const filterContactsPredicater = useCallback(
|
||||
(query, contact, _index, exactMatch) => {
|
||||
const normalizedTitle = contact.display_name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
if (exactMatch) {
|
||||
return normalizedTitle === normalizedQuery;
|
||||
} else {
|
||||
return normalizedTitle.indexOf(normalizedQuery) >= 0;
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
<MultiSelect
|
||||
itemRenderer={(contact, { selected, active, handleClick }) => (
|
||||
<MenuItem
|
||||
active={active}
|
||||
icon={selected ? 'tick' : 'blank'}
|
||||
text={contact.display_name}
|
||||
key={contact.id}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
)}
|
||||
popoverProps={{ minimal: true }}
|
||||
fill={true}
|
||||
itemPredicate={filterContactsPredicater}
|
||||
tagRenderer={(item) => item.display_name}
|
||||
{...multiSelectProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user