Notifications and messages sections; live nav badges

- notifications: day groups, unread/read/all, type filters with counts,
  mark one/all read with undo, «Перейти» routes to the section
- messages: inbox with search and dm/group filter, thread with day
  dividers and grouped bubbles, Enter to send, per-chat drafts shown
  in the inbox, «Написать» colleague picker that opens or creates a DM;
  single pane on narrow screens
- sidebar badges for notifications/messages come from the stores
- sidebar collapses to an icon rail below 768px
- shared createStore (tasks store moved onto it), date helpers,
  SearchInput in the kit
- fix: effects returned scrollIntoView's Promise in recent Chrome

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilya Mukhortov 2026-10-23 22:16:37 +10:00
parent 37c0248629
commit c4cc228d80
3 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,13 @@
import * as React from "react"
export function useMediaQuery(query: string) {
const subscribe = React.useCallback(
(onChange: () => void) => {
const mql = window.matchMedia(query)
mql.addEventListener("change", onChange)
return () => mql.removeEventListener("change", onChange)
},
[query],
)
return React.useSyncExternalStore(subscribe, () => window.matchMedia(query).matches)
}

View File

@ -14,5 +14,6 @@ export * from "./pagination"
export * from "./patient-avatar" export * from "./patient-avatar"
export * from "./patient-panel" export * from "./patient-panel"
export * from "./person-chip" export * from "./person-chip"
export * from "./search-input"
export * from "./stat-tile" export * from "./stat-tile"
export * from "./status-badge" export * from "./status-badge"

71
src/kit/search-input.tsx Normal file
View File

@ -0,0 +1,71 @@
import * as React from "react"
import { SearchIcon, XIcon } from "lucide-react"
import { cn } from "@/lib/utils"
/** Поле поиска на мягкой подложке: иконка, крестик очистки. */
export const SearchInput = React.forwardRef<
HTMLInputElement,
Omit<React.ComponentProps<"input">, "value" | "onChange" | "size"> & {
value: string
onValueChange: (value: string) => void
size?: "sm" | "md" | "lg"
/** Что показать справа, пока поле пустое (подсказка клавиши). */
trailing?: React.ReactNode
}
>(function SearchInput({ value, onValueChange, size = "md", trailing, className, ...props }, ref) {
const innerRef = React.useRef<HTMLInputElement>(null)
React.useImperativeHandle(ref, () => innerRef.current!)
return (
<div className={cn("relative", className)}>
<SearchIcon
className={cn(
"pointer-events-none absolute top-1/2 -translate-y-1/2 text-muted-foreground",
size === "lg" ? "left-4 size-5" : "left-3 size-4",
)}
/>
<input
ref={innerRef}
type="search"
value={value}
onChange={(e) => onValueChange(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Escape" && value) {
e.stopPropagation()
onValueChange("")
}
props.onKeyDown?.(e)
}}
className={cn(
"w-full rounded-lg border border-transparent bg-muted/70 transition outline-none placeholder:text-muted-foreground/80 [&::-webkit-search-cancel-button]:hidden",
"focus:border-primary/40 focus:bg-card focus:ring-4 focus:ring-primary/10",
size === "sm" && "h-8 pr-8 pl-9 text-sm",
size === "md" && "h-9 pr-8 pl-9 text-sm",
size === "lg" && "h-12 rounded-xl pr-12 pl-12 text-base",
)}
{...props}
/>
<div className="absolute top-1/2 right-2 flex -translate-y-1/2 items-center">
{value ? (
<button
type="button"
aria-label="Очистить"
onClick={() => {
onValueChange("")
innerRef.current?.focus()
}}
className={cn(
"grid place-items-center rounded-md text-muted-foreground hover:bg-muted",
size === "lg" ? "size-7" : "size-5",
)}
>
<XIcon className={size === "lg" ? "size-4" : "size-3.5"} />
</button>
) : (
trailing
)}
</div>
</div>
)
})