Files
Khalid Abdi 321a6298a4 frontend: pharmacy inventory, lab add-result & analysis charts
- Pharmacy: the sidebar entry now expands into Pharmacy + a new Inventory page
  (searchable medication stock with derived in-stock/low/out availability,
  backed by /api/inventory). Fix the dispensing-queue "Expiring" badge so it
  only flags courses ending within the next 7 days, not ones already elapsed.
- Lab "Add analysis result": the patient picker no longer lists patients until
  you type and supports arrow-key + Enter selection; the test field offers a
  catalog of common analyses with an Advanced option (custom analysis + ref
  range); submitted results now show immediately in a Recent results feed.
- Analysis: add a Live panel (real-time line chart) and replace the flat trend
  sparklines with bklit-ui area + bar charts (installed from the @bklit shadcn
  registry; chart CSS variables wired into the theme for light and dark).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 19:22:07 +03:00

49 lines
1.5 KiB
TypeScript

export type ChartStatus = "loading" | "ready";
/**
* Internal visual lifecycle phase. Forward and reverse transitions add
* intermediate phases in later stack branches.
*/
export type ChartPhase =
| "loading"
| "exiting"
| "gridTweenReady"
| "revealing"
| "ready"
| "exitingReady"
| "gridTweenLoading"
| "revealingLoading";
export const DEFAULT_CHART_STATUS: ChartStatus = "ready";
/** Default Y-domain tween when transitioning loading ↔ ready (ms). */
export const DEFAULT_Y_DOMAIN_TWEEN_MS = 500;
/** Relative domain delta below which Y tween may be skipped (see plan). */
export const Y_DOMAIN_TWEEN_SKIP_THRESHOLD = 0.02;
/** Resting phase for a given status before transition orchestration runs. */
export function resolveRestingChartPhase(status: ChartStatus): ChartPhase {
return status === "loading" ? "loading" : "ready";
}
export function isChartInteractionPhase(phase: ChartPhase): boolean {
return phase === "ready";
}
export const DEFAULT_CHART_LIFECYCLE = {
chartPhase: "ready",
chartStatus: "ready",
loadingLabel: undefined,
yDomainTweenDuration: DEFAULT_Y_DOMAIN_TWEEN_MS,
yDomainSkeletonByAxis: { left: [0, 100] as [number, number] },
yDomainTargetByAxis: { left: [0, 100] as [number, number] },
} as const satisfies {
chartPhase: ChartPhase;
chartStatus: ChartStatus;
loadingLabel: undefined;
yDomainTweenDuration: number;
yDomainSkeletonByAxis: Record<string, [number, number]>;
yDomainTargetByAxis: Record<string, [number, number]>;
};