From 37c02486294495a0644913179dfe075248d7ed60 Mon Sep 17 00:00:00 2001 From: Ilya Mukhortov Date: Fri, 23 Oct 2026 22:08:57 +1000 Subject: [PATCH] Tasks section: list, create form, task card with section tabs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - tasks open as section tabs (#1004, «Новая задача»), mirrored in sidebar - list: search, status multi-select, segments, «мои задачи», reset, sorting and pagination; filters kept in the URL - create: validation, multi-selects, date/time, file drop with previews; draft survives tab switches - card: status change, priority, editable executors/observers, due badge, files, replies (private, reply-to, edit/delete own) - in-memory tasks store shared by all tabs - kit: MultiSelect, PersonChip/PersonAvatar, FileDrop, FormField/FormSection, removable FileGallery tiles Co-Authored-By: Claude Opus 5.5 --- src/kit/file-drop.tsx | 68 ++++++++++++++++++ src/kit/file-gallery.tsx | 34 ++++++++- src/kit/form-field.tsx | 40 +++++++++++ src/kit/index.ts | 4 ++ src/kit/multi-select.tsx | 145 +++++++++++++++++++++++++++++++++++++++ src/kit/person-chip.tsx | 61 ++++++++++++++++ src/ui/checkbox.tsx | 30 ++++++++ src/ui/label.tsx | 22 ++++++ src/ui/switch.tsx | 33 +++++++++ 9 files changed, 434 insertions(+), 3 deletions(-) create mode 100644 src/kit/file-drop.tsx create mode 100644 src/kit/form-field.tsx create mode 100644 src/kit/multi-select.tsx create mode 100644 src/kit/person-chip.tsx create mode 100644 src/ui/checkbox.tsx create mode 100644 src/ui/label.tsx create mode 100644 src/ui/switch.tsx diff --git a/src/kit/file-drop.tsx b/src/kit/file-drop.tsx new file mode 100644 index 0000000..95c0ac7 --- /dev/null +++ b/src/kit/file-drop.tsx @@ -0,0 +1,68 @@ +import * as React from "react" +import { UploadCloudIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +/** Зона загрузки: перетащить файлы или выбрать в диалоге. */ +export function FileDrop({ + onFiles, + multiple = true, + accept, + hint = "PDF, изображения, документы — до 20 МБ", + className, +}: { + onFiles: (files: File[]) => void + multiple?: boolean + accept?: string + hint?: string + className?: string +}) { + const inputRef = React.useRef(null) + const [over, setOver] = React.useState(false) + + return ( +
inputRef.current?.click()} + onKeyDown={(e) => (e.key === "Enter" || e.key === " ") && inputRef.current?.click()} + onDragOver={(e) => { + e.preventDefault() + setOver(true) + }} + onDragLeave={() => setOver(false)} + onDrop={(e) => { + e.preventDefault() + setOver(false) + onFiles([...e.dataTransfer.files]) + }} + className={cn( + "flex cursor-pointer flex-col items-center gap-1.5 rounded-xl border-2 border-dashed px-6 py-6 text-center transition outline-none focus-visible:ring-2 focus-visible:ring-ring/50", + over ? "border-primary bg-accent/50" : "border-border hover:border-primary/40 hover:bg-muted/40", + className, + )} + > + +
+ Выберите файлы или перетащите сюда +
+
{hint}
+ { + onFiles([...(e.target.files ?? [])]) + e.target.value = "" + }} + /> +
+ ) +} + +/** File из браузера → элемент для FileGallery (превью через object URL). */ +export function fileToItem(file: File) { + return { name: file.name, size: file.size, type: file.type, src: URL.createObjectURL(file) } +} diff --git a/src/kit/file-gallery.tsx b/src/kit/file-gallery.tsx index f2a9b3a..ae0b94e 100644 --- a/src/kit/file-gallery.tsx +++ b/src/kit/file-gallery.tsx @@ -58,10 +58,13 @@ const tileSize: Record = { export function FileGallery({ files, size = "md", + onRemove, className, }: { files: readonly FileItem[] size?: FileGallerySize + /** Показать крестик «убрать» на плитке (вложения в форме). */ + onRemove?: (file: FileItem, index: number) => void className?: string }) { const [openIndex, setOpenIndex] = React.useState(null) @@ -79,7 +82,12 @@ export function FileGallery({
    {files.map((file, index) => (
  • - open(file, index)} /> + open(file, index)} + onRemove={onRemove && (() => onRemove(file, index))} + />
  • ))}
@@ -97,14 +105,34 @@ export function FileGallery({ ) } -function FileTile({ file, size, onOpen }: { file: FileItem; size: FileGallerySize; onOpen: () => void }) { +function FileTile({ + file, + size, + onOpen, + onRemove, +}: { + file: FileItem + size: FileGallerySize + onOpen: () => void + onRemove?: () => void +}) { const [broken, setBroken] = React.useState(false) const Icon = fileIcon(file) const image = isImageFile(file) && file.src && !broken const previewable = Boolean(file.src) && (isImageFile(file) || isPdfFile(file)) return ( -
+
+ {onRemove && ( + + )} + + )) + )} +
+ {compact && value.length > 0 && ( + + )} + +
+ + + + {items.length > 6 && } + + Ничего не найдено + + {items.map((o) => { + const checked = value.includes(o.value) + return ( + toggle(o.value)}> + + {checked && } + + {o.label} + + ) + })} + + + + + + ) +} diff --git a/src/kit/person-chip.tsx b/src/kit/person-chip.tsx new file mode 100644 index 0000000..0059725 --- /dev/null +++ b/src/kit/person-chip.tsx @@ -0,0 +1,61 @@ +import { XIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +export function initialsOf(name: string) { + const parts = name.replace(/\./g, " ").trim().split(/\s+/) + return ((parts[0]?.[0] ?? "") + (parts[1]?.[0] ?? "")).toUpperCase() || "?" +} + +/** Кружок с инициалами сотрудника. */ +export function PersonAvatar({ name, className }: { name: string; className?: string }) { + return ( + + {initialsOf(name)} + + ) +} + +/** Сотрудник чипом: инициалы, имя, опционально «убрать». */ +export function PersonChip({ + name, + highlight, + onRemove, + className, +}: { + name: string + /** Подсветить (например, текущего пользователя). */ + highlight?: boolean + onRemove?: () => void + className?: string +}) { + return ( + + + {name} + {onRemove && ( + + )} + + ) +} diff --git a/src/ui/checkbox.tsx b/src/ui/checkbox.tsx new file mode 100644 index 0000000..85ff86d --- /dev/null +++ b/src/ui/checkbox.tsx @@ -0,0 +1,30 @@ + +import * as React from "react" +import { cn } from "@/lib/utils" +import { CheckIcon } from "lucide-react" +import { Checkbox as CheckboxPrimitive } from "radix-ui" + +function Checkbox({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + + + ) +} + +export { Checkbox } diff --git a/src/ui/label.tsx b/src/ui/label.tsx new file mode 100644 index 0000000..00f7d60 --- /dev/null +++ b/src/ui/label.tsx @@ -0,0 +1,22 @@ + +import * as React from "react" +import { cn } from "@/lib/utils" +import { Label as LabelPrimitive } from "radix-ui" + +function Label({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { Label } diff --git a/src/ui/switch.tsx b/src/ui/switch.tsx new file mode 100644 index 0000000..bddbec7 --- /dev/null +++ b/src/ui/switch.tsx @@ -0,0 +1,33 @@ + +import * as React from "react" +import { cn } from "@/lib/utils" +import { Switch as SwitchPrimitive } from "radix-ui" + +function Switch({ + className, + size = "default", + ...props +}: React.ComponentProps & { + size?: "sm" | "default" +}) { + return ( + + + + ) +} + +export { Switch }