import { ReactNode } from 'react'; import { StateCreator } from 'zustand'; export type ClosingTabSlice = { // State - actions per tab ID tabActions: Record; // Actions setTabActions: (tabId: string, actions: ReactNode) => void; clearTabActions: (tabId: string) => void; clearAllTabActions: () => void; }; export const createClosingTabSlice: StateCreator< ClosingTabSlice, [], [], ClosingTabSlice > = (set) => ({ tabActions: {}, setTabActions: (tabId, actions) => set((state) => ({ tabActions: { ...state.tabActions, [tabId]: actions, }, })), clearTabActions: (tabId) => set((state) => { const { [tabId]: _, ...rest } = state.tabActions; return { tabActions: rest }; }), clearAllTabActions: () => set({ tabActions: {} }), });