Files
MikrotikManager/components/data-page-toolbar.tsx
T
Denozordec fe32c9313a
Docker images / prepare-release (push) Successful in 9s
Docker images / backend-image (push) Successful in 1m43s
Docker images / frontend-image (push) Successful in 2m58s
Docker images / notify-webhook (push) Skipped
Docker images / updater-image (push) Successful in 39s
Docker images / publish-release (push) Successful in 8s
feat(ui): integrate KpiStatGrid for enhanced statistics display
Replaced existing KPI display implementations across multiple pages with the new KpiStatGrid component for a more consistent and visually appealing presentation of statistics. Updated the Backups, BGP, Certificates, Communities, Containers, Dashboard, and Data Collection pages to utilize the KpiStatGrid, improving the overall user experience and maintainability of the codebase. Additionally, added new dependencies in package.json for required libraries.
2026-09-06 17:58:05 +07:00

103 lines
2.5 KiB
TypeScript

"use client"
import { ReactNode } from "react"
import { SearchIcon } from "lucide-react"
import { cn } from "@/lib/utils"
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
} from "@/components/ui/input-group"
import {
Filters,
type Filter,
type FilterFieldConfig,
} from "@/components/reui/filters"
import { SegmentedControl } from "@/components/form-kit"
import { DATA_PAGE_TOOLBAR_CLASS } from "@/components/data-grids/shared/data-grid-layout"
function DataPageToolbarFrame({
children,
className,
}: {
children: ReactNode
className?: string
}) {
return (
<div className={cn(DATA_PAGE_TOOLBAR_CLASS, className)}>
{children}
</div>
)
}
interface DataPageToolbarProps<T extends string = string> {
leading?: ReactNode
search?: string
onSearchChange?: (value: string) => void
searchPlaceholder?: string
segmented?: {
value: T
onChange: (value: T) => void
options: { value: T; label: string; count?: number }[]
}
filters?: Filter[]
onFiltersChange?: (filters: Filter[]) => void
filterFields?: FilterFieldConfig[]
countLabel?: string
actions?: ReactNode
className?: string
}
function DataPageToolbar<T extends string = string>({
leading,
search,
onSearchChange,
searchPlaceholder = "Поиск…",
segmented,
filters,
onFiltersChange,
filterFields,
countLabel,
actions,
className,
}: DataPageToolbarProps<T>) {
return (
<DataPageToolbarFrame className={className}>
{leading}
{segmented && (
<SegmentedControl
value={segmented.value}
onChange={segmented.onChange}
options={segmented.options}
/>
)}
{filterFields && filters && onFiltersChange && (
<Filters
filters={filters}
fields={filterFields}
onChange={onFiltersChange}
size="sm"
/>
)}
{onSearchChange != null && (
<InputGroup className="min-w-[220px] max-w-sm">
<InputGroupAddon>
<SearchIcon className="size-3.5" />
</InputGroupAddon>
<InputGroupInput
placeholder={searchPlaceholder}
value={search ?? ""}
onChange={(e) => onSearchChange(e.target.value)}
/>
</InputGroup>
)}
{countLabel && (
<span className="text-sm text-muted-foreground ml-auto">{countLabel}</span>
)}
{actions}
</DataPageToolbarFrame>
)
}
export { DataPageToolbar, DataPageToolbarFrame, type DataPageToolbarProps }