Skip to content
bahtuiv0.6.0

<baht-reference-picker>

Reference lookup: read-only input plus a magnifier that opens a typeahead. You supply fetcher(term); it owns debounce, dropdown and keyboard.

Lookup with a fetcher

Clearing emits baht-change with empty value and label. Set href to add an open-record link.

<baht-reference-picker label="Assigned to" placeholder="Search people"></baht-reference-picker>

<script>
  const el = document.querySelector('baht-reference-picker');
  const people = [
  { value: 'u1', label: 'Alice Tanaka' },
  { value: 'u2', label: 'Nok Srisuk' },
  { value: 'u3', label: 'Chai Boonmee' },
  ];
  el.fetcher = (term) =>
  Promise.resolve(people.filter((p) => p.label.toLowerCase().includes(term.toLowerCase())));
  el.addEventListener('baht-change', (e) => console.log(e.detail)); // { value, label }
</script>
NameTypeDefaultDescription
labelstring'Reference'Field label
valuestring''Selected record id
displaystring''Text shown for the value
placeholderstring''Input placeholder
disabledbooleanfalseDisabled
invalidbooleanfalseError styling
hrefstring''Open-record link next to the lookup
lookup-labelstring'Look up records'Accessible name of the magnifier
debouncenumber200Milliseconds before a search
fetcherJS((term: string) => Promise<ReferenceOption[]>) | nullnullSearch function; options are { value, label }
EventdetailDescription
nameCustomEvent
baht-change{ value, label }A record picked or cleared