import { FC, ReactNode, Context } from 'react'; import { SchedulerGroup } from '../types/scheduler-types'; import { CellData, ResourceTreeItem } from '../types/internal-interface'; import { ResourceGroupingMetadata, ResourceLevel, TimelineResourceRowMeta } from '../services/ResourceGroupingService'; /** * Resource grouping context value type * * @private */ export interface ResourceGroupingContextType { /** * Whether resource grouping is active */ isGroupingEnabled: boolean; /** * Resource grouping configuration */ groupConfig: SchedulerGroup; /** * Mode-aware (compact-narrowed when `isCompact === true`, otherwise the * full list) hierarchical resource tree. Most renderers — including * timeline, month, week, day, agenda, header rows, and the compact * sidebar — should read this field directly. */ resourceTree: ResourceLevel[]; /** * Mode-aware (compact-narrowed when `isCompact === true`, otherwise the * full list) leaf-level resources. Most renderers should read this field * directly. */ leafResources: ResourceLevel[]; /** * Grouping metadata */ metadata: ResourceGroupingMetadata; /** * Mode-aware (compact-narrowed when `isCompact === true`, otherwise the * full hierarchy) column header levels. Each cell carries its own * `date`/`groupIndex`/`groupOrder`. Most renderers should read this * field directly. */ columnLevels: CellData[][]; /** * Unfiltered, mode-agnostic counterpart of `leafResources`. `cell.groupIndex` * values index this list. Modules that must resolve a leaf by `groupIndex` * regardless of compact mode — quick-info popups, the editor popup, and * any other code that needs the full set — must use this field. */ allLeafResources: ResourceLevel[]; /** * Unfiltered, mode-agnostic counterpart of `resourceTree`. Mirrors * `allLeafResources` for tree consumers (e.g. quick-info popups, the * editor popup). */ allResourceTree: ResourceLevel[]; /** * Unfiltered, mode-agnostic counterpart of `columnLevels`. Mirrors * `allLeafResources` for column-level consumers that need the full * hierarchy (e.g. quick-info popups, the editor popup). */ allColumnLevels: CellData[][]; /** * Column header levels specifically for Month view rendering * Uses weekday slots (7 per week) instead of full render dates */ monthColumnLevels?: CellData[][]; /** * Flat tree of all resource rows. Populated for timeline views and * compact view mode (any view type) for the sidebar TreeView. * * @private */ timelineResourceHeaders?: TimelineResourceRowMeta[]; /** * `ResourceTreeItem[]` for the compact-view `TreeView`. * * @private */ resourceTreeData: ResourceTreeItem[]; /** * `selectedIds` for the compact-view `TreeView`. * * @private */ selectedTreeIds: string[]; /** * `defaultExpandedIds` for the compact-view `TreeView`. * * @private */ defaultExpandedTreeIds: string[]; /** * Rows visible after expand/collapse. Populated for timeline views and * compact view mode (any view type). * * @private */ visibleResourceHeaders?: TimelineResourceRowMeta[]; /** * Expand/collapse state per groupIndex. Populated for timeline views and * compact view mode (any view type). * * @private */ expandedState?: Map; /** * Toggle a resource row's expanded state. Populated for timeline views and * compact view mode (any view type). * * @private */ toggleExpanded?: (groupIndex: number) => void; /** * Measured heights for timeline resource rows. * * @private */ resourceRowHeights?: Map; /** * Update the measured height of a timeline resource row. * * @private */ updateResourceRowHeight?: (groupIndex: number, height: number) => void; /** * `true` only when all of the following hold: `group.enableCompactView === true`, * resource grouping is active, and there is at least one leaf resource. * * @private */ isCompact: boolean; /** * Index of the currently selected leaf resource within `allLeafResources`. * * @private */ selectedGroupIndex: number; /** * Whether the compact-view resource tree sidebar is currently visible. * * @private */ treeVisible: boolean; /** * Toggle the compact-view resource tree sidebar. Pass an explicit boolean * to force the next value, or omit to flip the current value. * * @private */ toggleTree: (next?: boolean) => void; /** * Programmatically select a leaf resource by its index in `allLeafResources`. * Fires `onResourceChange` exactly once when the index actually changes * and closes the tree on every selection. * * @private */ selectResource: (nextIndex: number) => void; /** * Currently selected `ResourceLevel` leaf, or `undefined` when grouping is off * or there are no leaves. * * @private */ selectedLeaf: ResourceLevel | null; /** * Breadcrumb of resource names (root → leaf) for the currently selected * leaf. Empty when no resource is selected. * * @private */ selectedResourcePath: string[]; } /** * React Context for resource grouping * * @private */ declare const ResourceGroupingContext: Context; /** * Resource Grouping Context Provider Props * * @private */ export interface ResourceGroupingProviderProps { /** * Child components */ children: ReactNode; } /** * Unified provider for all views. Computes grouping fields for every view and * also builds timeline-style resource headers (and expand/collapse state) for * timeline views and compact view mode (any view type), since the compact * sidebar mounts the ResourceTreeView everywhere. * * @param {ResourceGroupingProviderProps} root0 - Provider props. * @param {ReactNode} root0.children - Child content to render. * @returns {ReactNode} The resource grouping context provider * @private */ export declare const ResourceGroupingProvider: FC; /** * Hook to access resource grouping context * * @returns {ResourceGroupingContextType} Resource grouping context value * @throws Error if used outside ResourceGroupingProvider * * @private */ export declare function useResourceGrouping(): ResourceGroupingContextType; /** * Hook to safely access resource grouping context (returns null if not provided) * * @returns {ResourceGroupingContextType|null} Resource grouping context value or null * * @private */ export declare function useResourceGroupingContext(): ResourceGroupingContextType | null; export default ResourceGroupingContext;