Files
temetro/.agents/skills/coss/references/primitives/combobox.md
T
Khalid Abdi 929bec8f31 feat: AI-added records save with placeholders + "Added by AI" provenance
Stop blocking AI imports/proposals on missing non-critical fields. Records
the chat agent drafts now save with safe placeholders, auto-generated file
numbers, and a source="ai" marker that surfaces an "Added by AI" badge so a
clinician can review/edit them later.

Backend:
- add `source` (manual|ai) column to patients/appointments/prescriptions
  (migration 0014) + canonical types, services, validation schemas
- relax patient/appointment validation: empty file number allowed, demographic
  + type/provider/initials fall back to placeholders (initials derived from name)
- patients.generateFileNumber() auto-assigns an MRN when one is missing
- proposeAppointment accepts a name when no file number resolves; AI commits +
  /api/ai/import stamp source="ai"

Frontend:
- `source` on Appointment/Patient/Prescription types; AI commits send source="ai"
- reusable <AiBadge> shown on the Patients table/detail and prescriptions list

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 19:27:17 +03:00

2.9 KiB

coss Combobox

When to use

  • Searchable selection combining text input and list selection.
  • Rich option rows with filtering and custom trigger behavior.

When NOT to use

  • If options are few and fixed (no search needed) -> use Select instead.
  • If you need free-form text suggestions without strict selection -> use Autocomplete instead.
  • If the user picks from a simple short list -> use RadioGroup or Select.

Install

npx shadcn@latest add @coss/combobox

Manual deps from docs:

npm install @base-ui/react

Canonical imports

import {
  Combobox,
  ComboboxClear,
  ComboboxCollection,
  ComboboxEmpty,
  ComboboxGroup,
  ComboboxGroupLabel,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
  ComboboxPopup,
  ComboboxSeparator,
  ComboboxValue,
  useComboboxFilter,
} from "@/components/ui/combobox"

Minimal pattern

const items = [
  { value: "apple", label: "Apple" },
  { value: "banana", label: "Banana" },
  { value: "orange", label: "Orange" },
  { value: "grape", label: "Grape" },
]

<Combobox items={items}>
  <ComboboxInput placeholder="Select an item..." />
  <ComboboxPopup>
    <ComboboxEmpty>No results found.</ComboboxEmpty>
    <ComboboxList>
      {(item) => <ComboboxItem key={item.value} value={item}>{item.label}</ComboboxItem>}
    </ComboboxList>
  </ComboboxPopup>
</Combobox>

For form-bound comboboxes, prefer Field composition (Field + FieldLabel + FieldError) instead of standalone controls.

Patterns from coss particles

  • Portal forwarding: optional portalProps on ComboboxPopup → Base UI Combobox.Portal (keepMounted, container, …). See portal-props.md.

Key patterns

Combobox with label in a Field:

<Field>
  <FieldLabel>Framework</FieldLabel>
  <Combobox items={items}>
    <ComboboxInput placeholder="Search..." />
    <ComboboxPopup>
      <ComboboxEmpty>No results found.</ComboboxEmpty>
      <ComboboxList>
        {(item) => <ComboboxItem key={item.value} value={item}>{item.label}</ComboboxItem>}
      </ComboboxList>
    </ComboboxPopup>
  </Combobox>
</Field>

Sizes: sm, default, lg on ComboboxInput.

More examples

See p-combobox-1 through p-combobox-9 for sizes, label, auto-highlight, clear button, groups, and multiple selection.

Common pitfalls

  • Mixing select and combobox APIs without validating item/value wiring.
  • Using object values without stable string serialization where needed.
  • Missing empty/loading states for remote or filtered datasets.

Useful particle references

  • disabled: p-combobox-2
  • small size: p-combobox-3
  • large size: p-combobox-4
  • with label: p-combobox-5
  • auto highlight: p-combobox-6
  • with clear button: p-combobox-7
  • with groups: p-combobox-8
  • with multiple selection: p-combobox-9
  • related search/selection references: p-autocomplete-1, p-select-1, p-input-group-1