hy-vue-gantt
Version:
Evolution of vue-ganttastic package
80 lines • 3.02 kB
TypeScript
import { type Ref, type Slots, type ComputedRef } from "vue";
import type { ChartRow, GanttBarObject, LabelColumnConfig, SortState } from "../types";
/**
* Interface defining the return object from the useRows composable
* Provides methods and reactive references for managing Gantt chart rows
*/
export interface UseRowsReturn {
rows: Ref<ChartRow[]>;
updateRows: (newRows: ChartRow[]) => void;
sortState: Ref<SortState>;
toggleSort: (column: string) => void;
getChartRows: () => ChartRow[];
onSortChange: (callback: () => void) => () => void;
toggleGroupExpansion: (rowId: string | number) => void;
isGroupExpanded: (rowId: string | number) => boolean;
getFlattenedRows: () => ChartRow[];
onGroupExpansionChange: (callback: () => void) => () => void;
customOrder: Ref<Map<string | number, number>>;
resetCustomOrder: () => void;
expandAllGroups: () => void;
collapseAllGroups: () => void;
canUndo: ComputedRef<boolean>;
canRedo: ComputedRef<boolean>;
undo: () => HistoryChange;
redo: () => HistoryChange;
clearHistory: () => void;
onBarMove: () => void;
areAllGroupsExpanded: ComputedRef<boolean>;
areAllGroupsCollapsed: ComputedRef<boolean>;
}
/**
* Interface defining the required properties for the useRows composable
*/
export interface UseRowsProps {
barStart: Ref<string>;
barEnd: Ref<string>;
dateFormat: Ref<string | false>;
multiColumnLabel: Ref<LabelColumnConfig[]>;
onSort: (sortState: SortState) => void;
initialSort?: SortState;
onGroupExpansion: (rowId: string | number) => void;
}
interface BarHistoryChange {
barId: string;
rowId: string | number;
oldStart?: string;
newStart?: string;
oldEnd?: string;
newEnd?: string;
}
interface RowHistoryChange {
type: "reorder" | "group";
sourceRow: ChartRow;
targetRow?: ChartRow;
oldIndex: number;
newIndex: number;
oldParentId?: string | number;
newParentId?: string | number;
}
interface HistoryChange {
rowChanges: RowHistoryChange[];
barChanges: BarHistoryChange[];
}
/**
* Recursively searches for a bar by ID through all rows
* @param rows - Array of rows to search
* @param barId - ID of bar to find
* @returns Found bar object or null if not found
*/
export declare function findBarInRows(rows: ChartRow[], barId: string): GanttBarObject | null;
/**
* A composable that manages rows in a Gantt chart, providing sorting, grouping, and row manipulation functionality
* @param slots - Vue slots object for accessing slot content
* @param props - Configuration properties for the rows
* @param initialRows - Optional initial rows data
* @returns UseRowsReturn object containing row management methods and state
*/
export declare function useRows(slots: Slots, { barStart, barEnd, dateFormat, multiColumnLabel, onSort, initialSort, onGroupExpansion }: UseRowsProps, initialRows?: Ref<ChartRow[]>): UseRowsReturn;
export {};
//# sourceMappingURL=useRows.d.ts.map