/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ /** * Status / control strip above the results table. Shows the active grouping * and sum columns as removable chips, plus expand/collapse and live totals — * the connective tissue between the table and the list definition. */ import { Group, Sigma, X, ChevronsDownUp, ChevronsUpDown } from 'lucide-react'; import { cn } from '@/lib/utils'; interface ListGroupingBarProps { groupLabel: string | null; sums: { id: string; label: string }[]; groupCount: number; count: number; allExpanded: boolean; onClearGroup: () => void; onRemoveSum: (id: string) => void; onToggleExpandAll: () => void; } function Chip({ icon, children, onRemove }: { icon: React.ReactNode; children: React.ReactNode; onRemove: () => void }) { return ( {icon} {children} ); } export function ListGroupingBar({ groupLabel, sums, groupCount, count, allExpanded, onClearGroup, onRemoveSum, onToggleExpandAll, }: ListGroupingBarProps) { const grouped = groupLabel !== null; return (
{grouped && ( )} {grouped ? } onRemove={onClearGroup}>Grouped by {groupLabel} : No grouping — use a column's menu to group or sum} {sums.map((s) => ( } onRemove={() => onRemoveSum(s.id)}>{s.label} ))} {grouped && <>{groupCount.toLocaleString()} group{groupCount === 1 ? '' : 's'} · } {count.toLocaleString()} element{count === 1 ? '' : 's'}
); }