Skip to content

Commit 2791dd6

Browse files
committed
add meta property in candidate entry to show meta information
1 parent 2b83216 commit 2791dd6

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/scripts/Lookup.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const LookupEntryType = PropTypes.shape({
6565
icon: PropTypes.string,
6666
label: PropTypes.string,
6767
value: PropTypes.string,
68+
meta: PropTypes.string,
6869
});
6970

7071
LookupSelection.propTypes = {
@@ -360,26 +361,37 @@ export class LookupCandidateList extends Component {
360361
}
361362

362363
renderCandidate(entry) {
364+
const { category, icon, label, value, meta } = entry;
363365
return (
364-
<li className='slds-lookup__item' key={ entry.value }>
366+
<li key={ value } role='presentation'>
365367
<a
366-
className='slds-truncate react-slds-candidate'
368+
className='slds-lookup__item-action react-slds-candidate'
367369
tabIndex={ -1 }
368370
role='option'
369371
onKeyDown={ e => e.keyCode === 13 && this.onSelect(entry) }
370372
onBlur={ this.props.onBlur }
371373
onClick={ () => this.onSelect(entry) }
372374
>
373-
{
374-
entry.icon ?
375-
<Icon
376-
category={ entry.category }
377-
icon={ entry.icon }
378-
size='small'
379-
/> :
380-
undefined
381-
}
382-
{ entry.label }
375+
<span className='slds-media slds-media--center slds-truncate'>
376+
{
377+
icon ?
378+
<Icon
379+
className='slds-media__figure'
380+
category={ category }
381+
icon={ icon }
382+
size='small'
383+
/> :
384+
undefined
385+
}
386+
<div className='slds-media__body slds-truncate'>
387+
<span className='slds-lookup__result-text slds-truncate'>{ label }</span>
388+
{
389+
meta ?
390+
<span className='slds-lookup__result-meta slds-truncate'>{ meta }</span> :
391+
undefined
392+
}
393+
</div>
394+
</span>
383395
</a>
384396
</li>
385397
);

stories/LookupStories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const COMPANY_DATA = COMPANIES.map((label, i) => ({
1515
icon: 'standard:account',
1616
label,
1717
value: `10000${i}`,
18+
meta: '(888)000-0000 / 1234 XXX Ave, BBB City, CA, 90210 USA',
1819
scope: 'Account',
1920
}));
2021

0 commit comments

Comments
 (0)