mirror of
https://github.com/fergalmoran/turnstone.git
synced 2025-12-22 09:49:56 +00:00
Add group ID
This commit is contained in:
@@ -12,6 +12,7 @@ const noItemsMessage = 'We found no places that match your search'
|
|||||||
|
|
||||||
const listbox = [
|
const listbox = [
|
||||||
{
|
{
|
||||||
|
id: 'cities',
|
||||||
name: 'Cities',
|
name: 'Cities',
|
||||||
ratio: 8,
|
ratio: 8,
|
||||||
displayField: 'name',
|
displayField: 'name',
|
||||||
@@ -21,6 +22,7 @@ const listbox = [
|
|||||||
searchType: 'startswith'
|
searchType: 'startswith'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id: 'airports',
|
||||||
name: 'Airports',
|
name: 'Airports',
|
||||||
ratio: 2,
|
ratio: 2,
|
||||||
displayField: 'name',
|
displayField: 'name',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import styles from './groupName.module.css'
|
|||||||
|
|
||||||
export default function GroupName(props) {
|
export default function GroupName(props) {
|
||||||
const {
|
const {
|
||||||
|
id,
|
||||||
children: name
|
children: name
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ export default function GroupName(props) {
|
|||||||
airports: '\u{2708}'
|
airports: '\u{2708}'
|
||||||
}
|
}
|
||||||
|
|
||||||
const icon = icons[name.toLowerCase()] || ''
|
const icon = icons[id] || ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ export const fetcher = (query, listbox, defaultListbox, minQueryLength, maxItems
|
|||||||
value: item,
|
value: item,
|
||||||
text: itemText(item, listboxProp[groupIndex].displayField),
|
text: itemText(item, listboxProp[groupIndex].displayField),
|
||||||
groupIndex,
|
groupIndex,
|
||||||
|
groupId: listboxProp[groupIndex].id,
|
||||||
groupName: listboxProp[groupIndex].name,
|
groupName: listboxProp[groupIndex].name,
|
||||||
searchType: listboxProp[groupIndex].searchType,
|
searchType: listboxProp[groupIndex].searchType,
|
||||||
defaultListbox: isDefaultListbox
|
defaultListbox: isDefaultListbox
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default function ItemFirst(props) {
|
|||||||
|
|
||||||
const groupHeading = !!groupName && (
|
const groupHeading = !!groupName && (
|
||||||
GroupName
|
GroupName
|
||||||
? <GroupName index={item.groupIndex}>{groupName}</GroupName>
|
? <GroupName id={item.groupId} index={item.groupIndex}>{groupName}</GroupName>
|
||||||
: groupName
|
: groupName
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ const listboxRules = PropTypes.oneOfType([
|
|||||||
]).isRequired,
|
]).isRequired,
|
||||||
searchType: PropTypes.oneOf(searchTypes),
|
searchType: PropTypes.oneOf(searchTypes),
|
||||||
displayField: PropTypes.string,
|
displayField: PropTypes.string,
|
||||||
|
id: PropTypes.string,
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
ratio: PropTypes.number
|
ratio: PropTypes.number
|
||||||
})),
|
})),
|
||||||
|
|||||||
Reference in New Issue
Block a user