mirror of
https://github.com/temetro/temetro.git
synced 2026-09-03 06:17:55 +00:00
929bec8f31
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>
89 lines
2.0 KiB
Markdown
89 lines
2.0 KiB
Markdown
# coss Toggle Group
|
|
|
|
## When to use
|
|
|
|
- Grouped pressed-state controls (single or multiple).
|
|
- Formatting/action sets needing button-like toggles with shared state.
|
|
|
|
## Install
|
|
|
|
```bash
|
|
npx shadcn@latest add @coss/toggle-group
|
|
```
|
|
|
|
Manual deps from docs:
|
|
|
|
```bash
|
|
npm install @base-ui/react
|
|
```
|
|
|
|
## Canonical imports
|
|
|
|
```tsx
|
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
|
|
```
|
|
|
|
## Minimal pattern
|
|
|
|
```tsx
|
|
<ToggleGroup>
|
|
<ToggleGroupItem>Bold</ToggleGroupItem>
|
|
<ToggleGroupItem>Italic</ToggleGroupItem>
|
|
<ToggleGroupItem>Underline</ToggleGroupItem>
|
|
</ToggleGroup>
|
|
```
|
|
|
|
## Patterns from coss particles
|
|
|
|
### Key patterns
|
|
|
|
Toggle group with icon buttons:
|
|
|
|
```tsx
|
|
<ToggleGroup defaultValue={["bold"]}>
|
|
<ToggleGroupItem aria-label="Toggle bold" value="bold">
|
|
<BoldIcon aria-hidden="true" />
|
|
</ToggleGroupItem>
|
|
<ToggleGroupItem aria-label="Toggle italic" value="italic">
|
|
<ItalicIcon aria-hidden="true" />
|
|
</ToggleGroupItem>
|
|
<ToggleGroupItem aria-label="Toggle underline" value="underline">
|
|
<UnderlineIcon aria-hidden="true" />
|
|
</ToggleGroupItem>
|
|
</ToggleGroup>
|
|
```
|
|
|
|
Multiple selection (default). For single selection use `type="single"`.
|
|
|
|
Controlled toggle group:
|
|
|
|
```tsx
|
|
const [value, setValue] = useState(["bold"])
|
|
|
|
<ToggleGroup value={value} onValueChange={setValue}>
|
|
<ToggleGroupItem value="bold">Bold</ToggleGroupItem>
|
|
...
|
|
</ToggleGroup>
|
|
```
|
|
|
|
### More examples
|
|
|
|
See `p-toggle-group-1` through `p-toggle-group-9` for sizes, outline, vertical, disabled, multiple, and tooltip patterns.
|
|
|
|
## Common pitfalls
|
|
|
|
- Using toggle-group when plain buttons (no pressed state) are more appropriate.
|
|
- Wrong value shape for mode (`multiple` array vs single selection).
|
|
- Missing accessible labels on icon-only toggle items.
|
|
|
|
## Useful particle references
|
|
|
|
- small toggles: `p-toggle-group-2`
|
|
- large toggles: `p-toggle-group-3`
|
|
- with outline toggles: `p-toggle-group-4`
|
|
- vertical: `p-toggle-group-5`
|
|
- disabled: `p-toggle-group-6`
|
|
- with disabled toggle: `p-toggle-group-7`
|
|
- multiple selection: `p-toggle-group-8`
|
|
- with tooltips: `p-toggle-group-9`
|