From a9485423266e0143f27087b9aeba6a89ddd3ba15 Mon Sep 17 00:00:00 2001 From: Ilya Mukhortov Date: Fri, 30 Oct 2026 16:08:30 +1000 Subject: [PATCH] Add popover filters and calendar alignment --- src/kit/date-input.tsx | 5 +- src/kit/date-range-input.tsx | 5 +- src/kit/filter-bar.tsx | 139 +++++++++++++++++++++++------------ src/ui/popover.tsx | 7 ++ 4 files changed, 109 insertions(+), 47 deletions(-) diff --git a/src/kit/date-input.tsx b/src/kit/date-input.tsx index 39a9154..83d7d38 100644 --- a/src/kit/date-input.tsx +++ b/src/kit/date-input.tsx @@ -153,6 +153,7 @@ export function DateInput({ invalid, captionLayout = "label", yearCaption = "select", + calendarAlign = "end", onErrorChange, id, disabled, @@ -167,6 +168,8 @@ export function DateInput({ captionLayout?: "label" | "dropdown" /** Год в шапке календаря. «input» — набрать цифрами, когда список годов длинный. */ yearCaption?: "select" | "input" + /** Выравнивание всплывающего календаря относительно поля. */ + calendarAlign?: "start" | "center" | "end" /** Сообщение о неправильном вводе — чтобы показать его в FormField. */ onErrorChange?: (error: string | undefined) => void id?: string @@ -222,7 +225,7 @@ export function DateInput({ - + void /** Пустой массив — без быстрых периодов. */ presets?: readonly DateRangePreset[] + /** Выравнивание всплывающего календаря относительно поля. */ + calendarAlign?: "start" | "center" | "end" invalid?: boolean /** Сообщение о неправильном вводе (в том числе перевёрнутом диапазоне) — для FormField. */ onErrorChange?: (error: string | undefined) => void @@ -147,7 +150,7 @@ export function DateRangeInput({ - + {presets.length > 0 && (
{presets.map((preset) => { diff --git a/src/kit/filter-bar.tsx b/src/kit/filter-bar.tsx index c82c664..cc186fc 100644 --- a/src/kit/filter-bar.tsx +++ b/src/kit/filter-bar.tsx @@ -3,6 +3,7 @@ import { RotateCwIcon, SlidersHorizontalIcon } from "lucide-react" import { cn } from "../lib/utils" import { Button } from "../ui/button" +import { Popover, PopoverClose, PopoverContent, PopoverTrigger } from "../ui/popover" import { ScrollArea } from "../ui/scroll-area" import { Sheet, @@ -26,6 +27,7 @@ export function FilterBar({ more, moreCount = 0, moreTitle = "Фильтры", + moreVariant = "sheet", activeCount = 0, onReset, className, @@ -37,6 +39,8 @@ export function FilterBar({ moreCount?: number /** Заголовок панели. */ moreTitle?: string + /** Как открыть расширенные фильтры: в боковой панели или всплывающим слоем над контентом. */ + moreVariant?: "sheet" | "popover" /** Сколько фильтров отличается от умолчания: точка на «Сбросить», число — в подсказке. */ activeCount?: number /** Без него кнопки «Сбросить» нет. */ @@ -51,51 +55,6 @@ export function FilterBar({
{children}
{(more != null || onReset) && (
- {more != null && ( - - - - - {/* Как модальное окно кита (EditDialog): плавающая карточка с отступом от края, - шапка с иконкой, поля — на белых карточках, «Отмена/Готово» — внизу. */} - - - - - {moreTitle} - - {/* Описание нужно Radix для доступности; видно только скринридерам. */} - Фильтры применяются сразу - - -
{more}
-
- - {onReset ? ( - - ) : ( - - )} - - - - -
-
- )} {onReset && ( )} + {more != null && ( + moreVariant === "popover" ? ( + + + + + +
+ + {moreTitle} +
+ +
{more}
+
+
+ {onReset ? ( + + ) : ( + + )} + + + +
+
+
+ ) : ( + + + + + {/* Как модальное окно кита (EditDialog): плавающая карточка с отступом от края, + шапка с иконкой, поля — на белых карточках, «Отмена/Готово» — внизу. */} + + + + + {moreTitle} + + {/* Описание нужно Radix для доступности; видно только скринридерам. */} + Фильтры применяются сразу + + +
{more}
+
+ + {onReset ? ( + + ) : ( + + )} + + + + +
+
+ ) + )}
)}
) } +function MoreButton({ + moreCount, + className, + ...props +}: { moreCount: number } & React.ComponentProps) { + return ( + + ) +} + /** * Переключатель для панели расширенных фильтров: строка-карточка — подпись и подсказка слева, * тумблер справа; нажимается вся строка. Включённая строка подсвечена рамкой акцентного цвета. diff --git a/src/ui/popover.tsx b/src/ui/popover.tsx index 2eb5339..09bbbaf 100644 --- a/src/ui/popover.tsx +++ b/src/ui/popover.tsx @@ -15,6 +15,12 @@ function PopoverTrigger({ return } +function PopoverClose({ + ...props +}: React.ComponentProps) { + return +} + function PopoverContent({ className, align = "center", @@ -79,6 +85,7 @@ function PopoverDescription({ export { Popover, PopoverTrigger, + PopoverClose, PopoverContent, PopoverAnchor, PopoverHeader,