@innosolutions/inno-calendar 1.0.70 → 1.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agenda-widget-Bl-Gb588.cjs +2 -0
- package/dist/agenda-widget-Bl-Gb588.cjs.map +1 -0
- package/dist/{agenda-widget-GRHaHwQ2.js → agenda-widget-DrRyLzTK.js} +89 -87
- package/dist/agenda-widget-DrRyLzTK.js.map +1 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/components/inno-calendar.d.ts +23 -1
- package/dist/components/inno-calendar.d.ts.map +1 -1
- package/dist/core/context/inno-calendar-provider.d.ts +8 -2
- package/dist/core/context/inno-calendar-provider.d.ts.map +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.mjs +4 -4
- package/dist/core/types.d.ts +40 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/utils/view-storage.d.ts +14 -10
- package/dist/core/utils/view-storage.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +7 -7
- package/dist/position-utils-D_KpwRus.js +1053 -0
- package/dist/position-utils-D_KpwRus.js.map +1 -0
- package/dist/position-utils-ksZ_IjXC.cjs +2 -0
- package/dist/position-utils-ksZ_IjXC.cjs.map +1 -0
- package/dist/presets/index.cjs +1 -1
- package/dist/presets/index.mjs +1 -1
- package/dist/slot-selection-context-CLYZU6ul.cjs +2 -0
- package/dist/{slot-selection-context-DvTn_R-Z.cjs.map → slot-selection-context-CLYZU6ul.cjs.map} +1 -1
- package/dist/slot-selection-context-Ct5cVcKW.js +611 -0
- package/dist/{slot-selection-context-D6zo91K_.js.map → slot-selection-context-Ct5cVcKW.js.map} +1 -1
- package/dist/{tailwind-calendar-BA7v_Wgx.cjs → tailwind-calendar-BbUb61uY.cjs} +2 -2
- package/dist/{tailwind-calendar-BA7v_Wgx.cjs.map → tailwind-calendar-BbUb61uY.cjs.map} +1 -1
- package/dist/{tailwind-calendar-Bh1yB1jf.js → tailwind-calendar-DrwGVSF-.js} +3 -3
- package/dist/{tailwind-calendar-Bh1yB1jf.js.map → tailwind-calendar-DrwGVSF-.js.map} +1 -1
- package/dist/{use-calendar-BwqE_WNA.cjs → use-calendar-BK0nQYJq.cjs} +2 -2
- package/dist/{use-calendar-BwqE_WNA.cjs.map → use-calendar-BK0nQYJq.cjs.map} +1 -1
- package/dist/{use-calendar--JnbGA3L.js → use-calendar-DJI35SSd.js} +2 -2
- package/dist/{use-calendar--JnbGA3L.js.map → use-calendar-DJI35SSd.js.map} +1 -1
- package/dist/{use-slot-selection-C1tk-o0j.cjs → use-slot-selection-CCE11R4j.cjs} +2 -2
- package/dist/{use-slot-selection-C1tk-o0j.cjs.map → use-slot-selection-CCE11R4j.cjs.map} +1 -1
- package/dist/{use-slot-selection-BLCDzQzo.js → use-slot-selection-CX1w8EdM.js} +3 -3
- package/dist/{use-slot-selection-BLCDzQzo.js.map → use-slot-selection-CX1w8EdM.js.map} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.mjs +1 -1
- package/dist/{week-view-D1wefMb8.cjs → week-view-BXmaRChB.cjs} +2 -2
- package/dist/{week-view-D1wefMb8.cjs.map → week-view-BXmaRChB.cjs.map} +1 -1
- package/dist/{week-view-BbtTpJTU.js → week-view-BeasFcyR.js} +3 -3
- package/dist/{week-view-BbtTpJTU.js.map → week-view-BeasFcyR.js.map} +1 -1
- package/package.json +1 -1
- package/dist/agenda-widget-GRHaHwQ2.js.map +0 -1
- package/dist/agenda-widget-TLJuxen3.cjs +0 -2
- package/dist/agenda-widget-TLJuxen3.cjs.map +0 -1
- package/dist/position-utils-BzmOPdvQ.js +0 -1038
- package/dist/position-utils-BzmOPdvQ.js.map +0 -1
- package/dist/position-utils-EQTCC4tZ.cjs +0 -2
- package/dist/position-utils-EQTCC4tZ.cjs.map +0 -1
- package/dist/slot-selection-context-D6zo91K_.js +0 -610
- package/dist/slot-selection-context-DvTn_R-Z.cjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-calendar--JnbGA3L.js","sources":["../src/core/context/calendar-context.tsx","../src/core/hooks/use-calendar.ts"],"sourcesContent":["/**\n * CalendarContext - React Context for Calendar State\n *\n * Provides calendar state to deeply nested components without prop drilling.\n */\n\nimport { createContext, type ReactNode, useContext } from 'react';\nimport type { UseCalendarReturn } from '../hooks/use-calendar';\n\n// ============================================================================\n// CONTEXT\n// ============================================================================\n\n/**\n * Calendar context type - generic to support any event data type\n * We use `any` here because context consumers may not know the exact type\n * Use the typed hooks below for type-safe access\n */\n// biome-ignore lint/suspicious/noExplicitAny: Context needs to be flexible for different event types\nconst CalendarContext = createContext<UseCalendarReturn<any, any, any> | undefined>(undefined);\n\n// ============================================================================\n// PROVIDER\n// ============================================================================\n\nexport interface CalendarProviderProps<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n> {\n\tchildren: ReactNode;\n\tvalue: UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData>;\n}\n\nexport function CalendarProvider<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n>({ children, value }: CalendarProviderProps<TEventData, TScheduleTypeData, TResourceData>) {\n\treturn <CalendarContext.Provider value={value}>{children}</CalendarContext.Provider>;\n}\n\n// ============================================================================\n// HOOKS\n// ============================================================================\n\n/**\n * Get the full calendar context (throws if not in provider)\n */\nexport function useCalendarContext<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n>(): UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData> {\n\tconst context = useContext(CalendarContext);\n\tif (!context) {\n\t\tthrow new Error('useCalendarContext must be used within a CalendarProvider');\n\t}\n\treturn context as UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData>;\n}\n\n/**\n * Get the calendar context or undefined (safe version)\n */\nexport function useOptionalCalendarContext<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n>(): UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData> | undefined {\n\tconst context = useContext(CalendarContext);\n\treturn context as UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData> | undefined;\n}\n\n// ============================================================================\n// CONVENIENCE HOOKS\n// ============================================================================\n\n/**\n * Get current view\n */\nexport function useCalendarView() {\n\tconst { view, setView } = useCalendarContext();\n\treturn { view, setView };\n}\n\n/**\n * Get current date and navigation\n */\nexport function useCalendarDate() {\n\tconst { currentDate, setCurrentDate, goToNext, goToPrev, goToToday, goToDate } =\n\t\tuseCalendarContext();\n\treturn { currentDate, setCurrentDate, goToNext, goToPrev, goToToday, goToDate };\n}\n\n/**\n * Get filtered events\n */\nexport function useCalendarEvents<TEventData = Record<string, unknown>>() {\n\tconst { events, filteredEvents } = useCalendarContext<TEventData>();\n\treturn { events, filteredEvents };\n}\n\n/**\n * Get filters\n */\nexport function useCalendarFilters() {\n\tconst { filters, setFilters, updateFilters, clearFilters } = useCalendarContext();\n\treturn { filters, setFilters, updateFilters, clearFilters };\n}\n\n/**\n * Get preferences\n */\nexport function useCalendarPreferences() {\n\tconst { preferences, setPreferences } = useCalendarContext();\n\treturn { preferences, setPreferences };\n}\n\n// ============================================================================\n// ALIASES (for agenda-v2 naming convention compatibility)\n// ============================================================================\n\n/**\n * Alias for useCalendarContext - matches agenda-v2 naming convention\n */\nexport { useCalendarContext as useCalendar };\n\n/**\n * Alias for useOptionalCalendarContext - matches agenda-v2 naming convention\n */\nexport { useOptionalCalendarContext as useOptionalCalendar };\n","/**\n * useCalendar - Main Calendar Hook\n *\n * This hook provides all the state and methods needed to build a calendar.\n * It is fully generic, allowing consumers to define their own event data types.\n *\n * @example\n * ```tsx\n * interface MyEventData {\n * projectId: number;\n * priority: 'low' | 'medium' | 'high';\n * }\n *\n * const calendar = useCalendar<MyEventData>({\n * events: myEvents,\n * onEventClick: (event) => {\n * console.log(event.data?.projectId);\n * },\n * });\n * ```\n */\n\nimport { useCallback, useMemo, useState } from 'react';\nimport { DEFAULT_PREFERENCES } from '../constants';\nimport type {\n\tCalendarEvent,\n\tICalendarFilters,\n\tICalendarPreferences,\n\tIDateRange,\n\tIResource,\n\tIScheduleType,\n\tISelectionResult,\n\tTCalendarView,\n} from '../types';\nimport {\n\tfilterEventsByDateRange,\n\tfilterEventsByResource,\n\tfilterEventsByScheduleType,\n\tfilterEventsBySearch,\n\tfilterOutCanceled,\n\tsortEventsByStart,\n} from '../utils/event-utils';\nimport {\n\tgetViewDateRange,\n\tgetViewTitle,\n\tnavigateNext,\n\tnavigatePrev,\n\tnavigateToday,\n} from '../utils/grid-utils';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\n/**\n * Options for useCalendar hook\n */\nexport interface UseCalendarOptions<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n> {\n\t/** Events to display */\n\tevents: CalendarEvent<TEventData>[];\n\n\t/** Available resources (for resource views) */\n\tresources?: IResource<TResourceData>[] | undefined;\n\n\t/** Available schedule types */\n\tscheduleTypes?: IScheduleType<TScheduleTypeData>[] | undefined;\n\n\t/** Initial view */\n\tinitialView?: TCalendarView | undefined;\n\n\t/** Initial date */\n\tinitialDate?: Date | undefined;\n\n\t/** Initial filters */\n\tinitialFilters?: ICalendarFilters | undefined;\n\n\t/** User preferences */\n\tpreferences?: Partial<ICalendarPreferences> | undefined;\n\n\t/** Locked preferences (cannot be changed by user) */\n\tlockedPreferences?: Partial<ICalendarPreferences> | undefined;\n\n\t/** Locale for formatting */\n\tlocale?: string | undefined;\n\n\t/** Callback when view changes */\n\tonViewChange?: ((view: TCalendarView) => void) | undefined;\n\n\t/** Callback when date changes */\n\tonDateChange?: ((date: Date) => void) | undefined;\n\n\t/** Callback when event is clicked */\n\tonEventClick?: ((event: CalendarEvent<TEventData>) => void) | undefined;\n\n\t/** Callback when slot is selected */\n\tonSlotSelect?: ((selection: ISelectionResult) => void) | undefined;\n\n\t/** Callback when filters change */\n\tonFiltersChange?: ((filters: ICalendarFilters) => void) | undefined;\n}\n\n/**\n * Return type for useCalendar hook\n */\nexport interface UseCalendarReturn<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n> {\n\t// State\n\tview: TCalendarView;\n\tcurrentDate: Date;\n\tdateRange: IDateRange;\n\tfilters: ICalendarFilters;\n\tpreferences: ICalendarPreferences;\n\n\t// Computed\n\tfilteredEvents: CalendarEvent<TEventData>[];\n\tviewTitle: string;\n\n\t// Data\n\tevents: CalendarEvent<TEventData>[];\n\tresources: IResource<TResourceData>[];\n\tscheduleTypes: IScheduleType<TScheduleTypeData>[];\n\n\t// Actions\n\tsetView: (view: TCalendarView) => void;\n\tsetCurrentDate: (date: Date) => void;\n\tgoToNext: () => void;\n\tgoToPrev: () => void;\n\tgoToToday: () => void;\n\tgoToDate: (date: Date) => void;\n\n\t// Filters\n\tsetFilters: (filters: ICalendarFilters) => void;\n\tupdateFilters: (updates: Partial<ICalendarFilters>) => void;\n\tclearFilters: () => void;\n\n\t// Preferences\n\tsetPreferences: (prefs: Partial<ICalendarPreferences>) => void;\n\n\t// Event handlers\n\thandleEventClick: (event: CalendarEvent<TEventData>) => void;\n\thandleSlotSelect: (selection: ISelectionResult) => void;\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function useCalendar<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n>(\n\toptions: UseCalendarOptions<TEventData, TScheduleTypeData, TResourceData>\n): UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData> {\n\tconst {\n\t\tevents,\n\t\tresources = [],\n\t\tscheduleTypes = [],\n\t\tinitialView = 'week',\n\t\tinitialDate,\n\t\tinitialFilters = {},\n\t\tpreferences: userPreferences = {},\n\t\tlockedPreferences = {},\n\t\tlocale = 'en-US',\n\t\tonViewChange,\n\t\tonDateChange,\n\t\tonEventClick,\n\t\tonSlotSelect,\n\t\tonFiltersChange,\n\t} = options;\n\n\t// ========================================================================\n\t// STATE\n\t// ========================================================================\n\n\tconst [view, setViewState] = useState<TCalendarView>(initialView);\n\tconst [currentDate, setCurrentDateState] = useState<Date>(() => initialDate ?? new Date());\n\tconst [filters, setFiltersState] = useState<ICalendarFilters>(initialFilters);\n\tconst [preferences, setPreferencesState] = useState<ICalendarPreferences>(() => ({\n\t\t...DEFAULT_PREFERENCES,\n\t\t...userPreferences,\n\t\t...lockedPreferences,\n\t}));\n\n\t// ========================================================================\n\t// COMPUTED\n\t// ========================================================================\n\n\tconst dateRange = useMemo(\n\t\t() => getViewDateRange(currentDate, view, preferences.firstDayOfWeek),\n\t\t[currentDate, view, preferences.firstDayOfWeek]\n\t);\n\n\tconst viewTitle = useMemo(\n\t\t() => getViewTitle(currentDate, view, locale),\n\t\t[currentDate, view, locale]\n\t);\n\n\tconst filteredEvents = useMemo(() => {\n\t\tlet result = [...events];\n\n\t\t// Filter by date range\n\t\tresult = filterEventsByDateRange(result, dateRange.startDate, dateRange.endDate);\n\n\t\t// Filter by schedule types\n\t\tconst scheduleTypeIds = filters.scheduleTypeIds;\n\t\tif (scheduleTypeIds && scheduleTypeIds.length > 0) {\n\t\t\tresult = filterEventsByScheduleType(result, scheduleTypeIds);\n\t\t}\n\n\t\t// Filter by resources\n\t\tconst resourceIds = filters.resourceIds;\n\t\tif (resourceIds && resourceIds.length > 0) {\n\t\t\tresult = filterEventsByResource(result, resourceIds);\n\t\t}\n\n\t\t// Filter by search\n\t\tconst search = filters.search;\n\t\tif (search) {\n\t\t\tresult = filterEventsBySearch(result, search);\n\t\t}\n\n\t\t// Filter canceled\n\t\tif (!preferences.showCanceledEvents) {\n\t\t\tresult = filterOutCanceled(result);\n\t\t}\n\n\t\t// Sort by start date\n\t\treturn sortEventsByStart(result);\n\t}, [events, dateRange, filters, preferences.showCanceledEvents]);\n\n\t// ========================================================================\n\t// ACTIONS\n\t// ========================================================================\n\n\tconst setView = useCallback(\n\t\t(newView: TCalendarView) => {\n\t\t\tsetViewState(newView);\n\t\t\tonViewChange?.(newView);\n\t\t},\n\t\t[onViewChange]\n\t);\n\n\tconst setCurrentDate = useCallback(\n\t\t(date: Date) => {\n\t\t\tsetCurrentDateState(date);\n\t\t\tonDateChange?.(date);\n\t\t},\n\t\t[onDateChange]\n\t);\n\n\tconst goToNext = useCallback(() => {\n\t\tconst newDate = navigateNext(currentDate, view);\n\t\tsetCurrentDate(newDate);\n\t}, [currentDate, view, setCurrentDate]);\n\n\tconst goToPrev = useCallback(() => {\n\t\tconst newDate = navigatePrev(currentDate, view);\n\t\tsetCurrentDate(newDate);\n\t}, [currentDate, view, setCurrentDate]);\n\n\tconst goToToday = useCallback(() => {\n\t\tsetCurrentDate(navigateToday());\n\t}, [setCurrentDate]);\n\n\tconst goToDate = useCallback(\n\t\t(date: Date) => {\n\t\t\tsetCurrentDate(date);\n\t\t},\n\t\t[setCurrentDate]\n\t);\n\n\t// ========================================================================\n\t// FILTERS\n\t// ========================================================================\n\n\tconst setFilters = useCallback(\n\t\t(newFilters: ICalendarFilters) => {\n\t\t\tsetFiltersState(newFilters);\n\t\t\tonFiltersChange?.(newFilters);\n\t\t},\n\t\t[onFiltersChange]\n\t);\n\n\tconst updateFilters = useCallback(\n\t\t(updates: Partial<ICalendarFilters>) => {\n\t\t\tsetFiltersState((prev) => {\n\t\t\t\tconst next = { ...prev, ...updates };\n\t\t\t\tonFiltersChange?.(next);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\t[onFiltersChange]\n\t);\n\n\tconst clearFilters = useCallback(() => {\n\t\tconst emptyFilters: ICalendarFilters = {};\n\t\tsetFiltersState(emptyFilters);\n\t\tonFiltersChange?.(emptyFilters);\n\t}, [onFiltersChange]);\n\n\t// ========================================================================\n\t// PREFERENCES\n\t// ========================================================================\n\n\tconst setPreferences = useCallback(\n\t\t(prefs: Partial<ICalendarPreferences>) => {\n\t\t\tsetPreferencesState((prev) => ({\n\t\t\t\t...prev,\n\t\t\t\t...prefs,\n\t\t\t\t...lockedPreferences, // Locked prefs always override\n\t\t\t}));\n\t\t},\n\t\t[lockedPreferences]\n\t);\n\n\t// ========================================================================\n\t// EVENT HANDLERS\n\t// ========================================================================\n\n\tconst handleEventClick = useCallback(\n\t\t(event: CalendarEvent<TEventData>) => {\n\t\t\tonEventClick?.(event);\n\t\t},\n\t\t[onEventClick]\n\t);\n\n\tconst handleSlotSelect = useCallback(\n\t\t(selection: ISelectionResult) => {\n\t\t\tonSlotSelect?.(selection);\n\t\t},\n\t\t[onSlotSelect]\n\t);\n\n\t// ========================================================================\n\t// RETURN\n\t// ========================================================================\n\n\treturn {\n\t\t// State\n\t\tview,\n\t\tcurrentDate,\n\t\tdateRange,\n\t\tfilters,\n\t\tpreferences,\n\n\t\t// Computed\n\t\tfilteredEvents,\n\t\tviewTitle,\n\n\t\t// Data\n\t\tevents,\n\t\tresources,\n\t\tscheduleTypes,\n\n\t\t// Actions\n\t\tsetView,\n\t\tsetCurrentDate,\n\t\tgoToNext,\n\t\tgoToPrev,\n\t\tgoToToday,\n\t\tgoToDate,\n\n\t\t// Filters\n\t\tsetFilters,\n\t\tupdateFilters,\n\t\tclearFilters,\n\n\t\t// Preferences\n\t\tsetPreferences,\n\n\t\t// Event handlers\n\t\thandleEventClick,\n\t\thandleSlotSelect,\n\t};\n}\n"],"names":["CalendarContext","createContext","CalendarProvider","children","value","jsx","useCalendarContext","context","useContext","useOptionalCalendarContext","useCalendarView","view","setView","useCalendarDate","currentDate","setCurrentDate","goToNext","goToPrev","goToToday","goToDate","useCalendarEvents","events","filteredEvents","useCalendarFilters","filters","setFilters","updateFilters","clearFilters","useCalendarPreferences","preferences","setPreferences","useCalendar","options","resources","scheduleTypes","initialView","initialDate","initialFilters","userPreferences","lockedPreferences","locale","onViewChange","onDateChange","onEventClick","onSlotSelect","onFiltersChange","setViewState","useState","setCurrentDateState","setFiltersState","setPreferencesState","DEFAULT_PREFERENCES","dateRange","useMemo","getViewDateRange","viewTitle","getViewTitle","result","filterEventsByDateRange","scheduleTypeIds","filterEventsByScheduleType","resourceIds","filterEventsByResource","search","filterEventsBySearch","filterOutCanceled","sortEventsByStart","useCallback","newView","date","newDate","navigateNext","navigatePrev","navigateToday","newFilters","updates","prev","next","emptyFilters","prefs","handleEventClick","event","handleSlotSelect","selection"],"mappings":";;;AAmBA,MAAMA,IAAkBC,EAA4D,MAAS;AAetF,SAASC,GAId,EAAE,UAAAC,GAAU,OAAAC,KAA8E;AAC3F,SAAO,gBAAAC,EAACL,EAAgB,UAAhB,EAAyB,OAAAI,GAAe,UAAAD,EAAA,CAAS;AAC1D;AASO,SAASG,IAIqD;AACpE,QAAMC,IAAUC,EAAWR,CAAe;AAC1C,MAAI,CAACO;AACJ,UAAM,IAAI,MAAM,2DAA2D;AAE5E,SAAOA;AACR;AAKO,SAASE,KAIiE;AAEhF,SADgBD,EAAWR,CAAe;AAE3C;AASO,SAASU,KAAkB;AACjC,QAAM,EAAE,MAAAC,GAAM,SAAAC,EAAA,IAAYN,EAAA;AAC1B,SAAO,EAAE,MAAAK,GAAM,SAAAC,EAAA;AAChB;AAKO,SAASC,KAAkB;AACjC,QAAM,EAAE,aAAAC,GAAa,gBAAAC,GAAgB,UAAAC,GAAU,UAAAC,GAAU,WAAAC,GAAW,UAAAC,EAAA,IACnEb,EAAA;AACD,SAAO,EAAE,aAAAQ,GAAa,gBAAAC,GAAgB,UAAAC,GAAU,UAAAC,GAAU,WAAAC,GAAW,UAAAC,EAAA;AACtE;AAKO,SAASC,KAA0D;AACzE,QAAM,EAAE,QAAAC,GAAQ,gBAAAC,EAAA,IAAmBhB,EAAA;AACnC,SAAO,EAAE,QAAAe,GAAQ,gBAAAC,EAAA;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AA,IAGA,gBAAAP;AAAA,IACA,WAAAiC;AAAA;AAAA,IAGA,QAAAlC;AAAA,IACA,WAAAY;AAAA,IACA,eAAAC;AAAA;AAAA,IAGA,SAAAtB;AAAA,IACA,gBAAAG;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA;AAAA,IAGA,YAAAM;AAAA,IACA,eAAAC;AAAA,IACA,cAAAC;AAAA;AAAA,IAGA,gBAAAG;AAAA;AAAA,IAGA,kBAAAkD;AAAA,IACA,kBAAAE;AAAA,EAAA;AAEF;"}
|
|
1
|
+
{"version":3,"file":"use-calendar-DJI35SSd.js","sources":["../src/core/context/calendar-context.tsx","../src/core/hooks/use-calendar.ts"],"sourcesContent":["/**\n * CalendarContext - React Context for Calendar State\n *\n * Provides calendar state to deeply nested components without prop drilling.\n */\n\nimport { createContext, type ReactNode, useContext } from 'react';\nimport type { UseCalendarReturn } from '../hooks/use-calendar';\n\n// ============================================================================\n// CONTEXT\n// ============================================================================\n\n/**\n * Calendar context type - generic to support any event data type\n * We use `any` here because context consumers may not know the exact type\n * Use the typed hooks below for type-safe access\n */\n// biome-ignore lint/suspicious/noExplicitAny: Context needs to be flexible for different event types\nconst CalendarContext = createContext<UseCalendarReturn<any, any, any> | undefined>(undefined);\n\n// ============================================================================\n// PROVIDER\n// ============================================================================\n\nexport interface CalendarProviderProps<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n> {\n\tchildren: ReactNode;\n\tvalue: UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData>;\n}\n\nexport function CalendarProvider<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n>({ children, value }: CalendarProviderProps<TEventData, TScheduleTypeData, TResourceData>) {\n\treturn <CalendarContext.Provider value={value}>{children}</CalendarContext.Provider>;\n}\n\n// ============================================================================\n// HOOKS\n// ============================================================================\n\n/**\n * Get the full calendar context (throws if not in provider)\n */\nexport function useCalendarContext<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n>(): UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData> {\n\tconst context = useContext(CalendarContext);\n\tif (!context) {\n\t\tthrow new Error('useCalendarContext must be used within a CalendarProvider');\n\t}\n\treturn context as UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData>;\n}\n\n/**\n * Get the calendar context or undefined (safe version)\n */\nexport function useOptionalCalendarContext<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n>(): UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData> | undefined {\n\tconst context = useContext(CalendarContext);\n\treturn context as UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData> | undefined;\n}\n\n// ============================================================================\n// CONVENIENCE HOOKS\n// ============================================================================\n\n/**\n * Get current view\n */\nexport function useCalendarView() {\n\tconst { view, setView } = useCalendarContext();\n\treturn { view, setView };\n}\n\n/**\n * Get current date and navigation\n */\nexport function useCalendarDate() {\n\tconst { currentDate, setCurrentDate, goToNext, goToPrev, goToToday, goToDate } =\n\t\tuseCalendarContext();\n\treturn { currentDate, setCurrentDate, goToNext, goToPrev, goToToday, goToDate };\n}\n\n/**\n * Get filtered events\n */\nexport function useCalendarEvents<TEventData = Record<string, unknown>>() {\n\tconst { events, filteredEvents } = useCalendarContext<TEventData>();\n\treturn { events, filteredEvents };\n}\n\n/**\n * Get filters\n */\nexport function useCalendarFilters() {\n\tconst { filters, setFilters, updateFilters, clearFilters } = useCalendarContext();\n\treturn { filters, setFilters, updateFilters, clearFilters };\n}\n\n/**\n * Get preferences\n */\nexport function useCalendarPreferences() {\n\tconst { preferences, setPreferences } = useCalendarContext();\n\treturn { preferences, setPreferences };\n}\n\n// ============================================================================\n// ALIASES (for agenda-v2 naming convention compatibility)\n// ============================================================================\n\n/**\n * Alias for useCalendarContext - matches agenda-v2 naming convention\n */\nexport { useCalendarContext as useCalendar };\n\n/**\n * Alias for useOptionalCalendarContext - matches agenda-v2 naming convention\n */\nexport { useOptionalCalendarContext as useOptionalCalendar };\n","/**\n * useCalendar - Main Calendar Hook\n *\n * This hook provides all the state and methods needed to build a calendar.\n * It is fully generic, allowing consumers to define their own event data types.\n *\n * @example\n * ```tsx\n * interface MyEventData {\n * projectId: number;\n * priority: 'low' | 'medium' | 'high';\n * }\n *\n * const calendar = useCalendar<MyEventData>({\n * events: myEvents,\n * onEventClick: (event) => {\n * console.log(event.data?.projectId);\n * },\n * });\n * ```\n */\n\nimport { useCallback, useMemo, useState } from 'react';\nimport { DEFAULT_PREFERENCES } from '../constants';\nimport type {\n\tCalendarEvent,\n\tICalendarFilters,\n\tICalendarPreferences,\n\tIDateRange,\n\tIResource,\n\tIScheduleType,\n\tISelectionResult,\n\tTCalendarView,\n} from '../types';\nimport {\n\tfilterEventsByDateRange,\n\tfilterEventsByResource,\n\tfilterEventsByScheduleType,\n\tfilterEventsBySearch,\n\tfilterOutCanceled,\n\tsortEventsByStart,\n} from '../utils/event-utils';\nimport {\n\tgetViewDateRange,\n\tgetViewTitle,\n\tnavigateNext,\n\tnavigatePrev,\n\tnavigateToday,\n} from '../utils/grid-utils';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\n/**\n * Options for useCalendar hook\n */\nexport interface UseCalendarOptions<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n> {\n\t/** Events to display */\n\tevents: CalendarEvent<TEventData>[];\n\n\t/** Available resources (for resource views) */\n\tresources?: IResource<TResourceData>[] | undefined;\n\n\t/** Available schedule types */\n\tscheduleTypes?: IScheduleType<TScheduleTypeData>[] | undefined;\n\n\t/** Initial view */\n\tinitialView?: TCalendarView | undefined;\n\n\t/** Initial date */\n\tinitialDate?: Date | undefined;\n\n\t/** Initial filters */\n\tinitialFilters?: ICalendarFilters | undefined;\n\n\t/** User preferences */\n\tpreferences?: Partial<ICalendarPreferences> | undefined;\n\n\t/** Locked preferences (cannot be changed by user) */\n\tlockedPreferences?: Partial<ICalendarPreferences> | undefined;\n\n\t/** Locale for formatting */\n\tlocale?: string | undefined;\n\n\t/** Callback when view changes */\n\tonViewChange?: ((view: TCalendarView) => void) | undefined;\n\n\t/** Callback when date changes */\n\tonDateChange?: ((date: Date) => void) | undefined;\n\n\t/** Callback when event is clicked */\n\tonEventClick?: ((event: CalendarEvent<TEventData>) => void) | undefined;\n\n\t/** Callback when slot is selected */\n\tonSlotSelect?: ((selection: ISelectionResult) => void) | undefined;\n\n\t/** Callback when filters change */\n\tonFiltersChange?: ((filters: ICalendarFilters) => void) | undefined;\n}\n\n/**\n * Return type for useCalendar hook\n */\nexport interface UseCalendarReturn<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n> {\n\t// State\n\tview: TCalendarView;\n\tcurrentDate: Date;\n\tdateRange: IDateRange;\n\tfilters: ICalendarFilters;\n\tpreferences: ICalendarPreferences;\n\n\t// Computed\n\tfilteredEvents: CalendarEvent<TEventData>[];\n\tviewTitle: string;\n\n\t// Data\n\tevents: CalendarEvent<TEventData>[];\n\tresources: IResource<TResourceData>[];\n\tscheduleTypes: IScheduleType<TScheduleTypeData>[];\n\n\t// Actions\n\tsetView: (view: TCalendarView) => void;\n\tsetCurrentDate: (date: Date) => void;\n\tgoToNext: () => void;\n\tgoToPrev: () => void;\n\tgoToToday: () => void;\n\tgoToDate: (date: Date) => void;\n\n\t// Filters\n\tsetFilters: (filters: ICalendarFilters) => void;\n\tupdateFilters: (updates: Partial<ICalendarFilters>) => void;\n\tclearFilters: () => void;\n\n\t// Preferences\n\tsetPreferences: (prefs: Partial<ICalendarPreferences>) => void;\n\n\t// Event handlers\n\thandleEventClick: (event: CalendarEvent<TEventData>) => void;\n\thandleSlotSelect: (selection: ISelectionResult) => void;\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function useCalendar<\n\tTEventData = Record<string, unknown>,\n\tTScheduleTypeData = Record<string, unknown>,\n\tTResourceData = Record<string, unknown>,\n>(\n\toptions: UseCalendarOptions<TEventData, TScheduleTypeData, TResourceData>\n): UseCalendarReturn<TEventData, TScheduleTypeData, TResourceData> {\n\tconst {\n\t\tevents,\n\t\tresources = [],\n\t\tscheduleTypes = [],\n\t\tinitialView = 'week',\n\t\tinitialDate,\n\t\tinitialFilters = {},\n\t\tpreferences: userPreferences = {},\n\t\tlockedPreferences = {},\n\t\tlocale = 'en-US',\n\t\tonViewChange,\n\t\tonDateChange,\n\t\tonEventClick,\n\t\tonSlotSelect,\n\t\tonFiltersChange,\n\t} = options;\n\n\t// ========================================================================\n\t// STATE\n\t// ========================================================================\n\n\tconst [view, setViewState] = useState<TCalendarView>(initialView);\n\tconst [currentDate, setCurrentDateState] = useState<Date>(() => initialDate ?? new Date());\n\tconst [filters, setFiltersState] = useState<ICalendarFilters>(initialFilters);\n\tconst [preferences, setPreferencesState] = useState<ICalendarPreferences>(() => ({\n\t\t...DEFAULT_PREFERENCES,\n\t\t...userPreferences,\n\t\t...lockedPreferences,\n\t}));\n\n\t// ========================================================================\n\t// COMPUTED\n\t// ========================================================================\n\n\tconst dateRange = useMemo(\n\t\t() => getViewDateRange(currentDate, view, preferences.firstDayOfWeek),\n\t\t[currentDate, view, preferences.firstDayOfWeek]\n\t);\n\n\tconst viewTitle = useMemo(\n\t\t() => getViewTitle(currentDate, view, locale),\n\t\t[currentDate, view, locale]\n\t);\n\n\tconst filteredEvents = useMemo(() => {\n\t\tlet result = [...events];\n\n\t\t// Filter by date range\n\t\tresult = filterEventsByDateRange(result, dateRange.startDate, dateRange.endDate);\n\n\t\t// Filter by schedule types\n\t\tconst scheduleTypeIds = filters.scheduleTypeIds;\n\t\tif (scheduleTypeIds && scheduleTypeIds.length > 0) {\n\t\t\tresult = filterEventsByScheduleType(result, scheduleTypeIds);\n\t\t}\n\n\t\t// Filter by resources\n\t\tconst resourceIds = filters.resourceIds;\n\t\tif (resourceIds && resourceIds.length > 0) {\n\t\t\tresult = filterEventsByResource(result, resourceIds);\n\t\t}\n\n\t\t// Filter by search\n\t\tconst search = filters.search;\n\t\tif (search) {\n\t\t\tresult = filterEventsBySearch(result, search);\n\t\t}\n\n\t\t// Filter canceled\n\t\tif (!preferences.showCanceledEvents) {\n\t\t\tresult = filterOutCanceled(result);\n\t\t}\n\n\t\t// Sort by start date\n\t\treturn sortEventsByStart(result);\n\t}, [events, dateRange, filters, preferences.showCanceledEvents]);\n\n\t// ========================================================================\n\t// ACTIONS\n\t// ========================================================================\n\n\tconst setView = useCallback(\n\t\t(newView: TCalendarView) => {\n\t\t\tsetViewState(newView);\n\t\t\tonViewChange?.(newView);\n\t\t},\n\t\t[onViewChange]\n\t);\n\n\tconst setCurrentDate = useCallback(\n\t\t(date: Date) => {\n\t\t\tsetCurrentDateState(date);\n\t\t\tonDateChange?.(date);\n\t\t},\n\t\t[onDateChange]\n\t);\n\n\tconst goToNext = useCallback(() => {\n\t\tconst newDate = navigateNext(currentDate, view);\n\t\tsetCurrentDate(newDate);\n\t}, [currentDate, view, setCurrentDate]);\n\n\tconst goToPrev = useCallback(() => {\n\t\tconst newDate = navigatePrev(currentDate, view);\n\t\tsetCurrentDate(newDate);\n\t}, [currentDate, view, setCurrentDate]);\n\n\tconst goToToday = useCallback(() => {\n\t\tsetCurrentDate(navigateToday());\n\t}, [setCurrentDate]);\n\n\tconst goToDate = useCallback(\n\t\t(date: Date) => {\n\t\t\tsetCurrentDate(date);\n\t\t},\n\t\t[setCurrentDate]\n\t);\n\n\t// ========================================================================\n\t// FILTERS\n\t// ========================================================================\n\n\tconst setFilters = useCallback(\n\t\t(newFilters: ICalendarFilters) => {\n\t\t\tsetFiltersState(newFilters);\n\t\t\tonFiltersChange?.(newFilters);\n\t\t},\n\t\t[onFiltersChange]\n\t);\n\n\tconst updateFilters = useCallback(\n\t\t(updates: Partial<ICalendarFilters>) => {\n\t\t\tsetFiltersState((prev) => {\n\t\t\t\tconst next = { ...prev, ...updates };\n\t\t\t\tonFiltersChange?.(next);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\t[onFiltersChange]\n\t);\n\n\tconst clearFilters = useCallback(() => {\n\t\tconst emptyFilters: ICalendarFilters = {};\n\t\tsetFiltersState(emptyFilters);\n\t\tonFiltersChange?.(emptyFilters);\n\t}, [onFiltersChange]);\n\n\t// ========================================================================\n\t// PREFERENCES\n\t// ========================================================================\n\n\tconst setPreferences = useCallback(\n\t\t(prefs: Partial<ICalendarPreferences>) => {\n\t\t\tsetPreferencesState((prev) => ({\n\t\t\t\t...prev,\n\t\t\t\t...prefs,\n\t\t\t\t...lockedPreferences, // Locked prefs always override\n\t\t\t}));\n\t\t},\n\t\t[lockedPreferences]\n\t);\n\n\t// ========================================================================\n\t// EVENT HANDLERS\n\t// ========================================================================\n\n\tconst handleEventClick = useCallback(\n\t\t(event: CalendarEvent<TEventData>) => {\n\t\t\tonEventClick?.(event);\n\t\t},\n\t\t[onEventClick]\n\t);\n\n\tconst handleSlotSelect = useCallback(\n\t\t(selection: ISelectionResult) => {\n\t\t\tonSlotSelect?.(selection);\n\t\t},\n\t\t[onSlotSelect]\n\t);\n\n\t// ========================================================================\n\t// RETURN\n\t// ========================================================================\n\n\treturn {\n\t\t// State\n\t\tview,\n\t\tcurrentDate,\n\t\tdateRange,\n\t\tfilters,\n\t\tpreferences,\n\n\t\t// Computed\n\t\tfilteredEvents,\n\t\tviewTitle,\n\n\t\t// Data\n\t\tevents,\n\t\tresources,\n\t\tscheduleTypes,\n\n\t\t// Actions\n\t\tsetView,\n\t\tsetCurrentDate,\n\t\tgoToNext,\n\t\tgoToPrev,\n\t\tgoToToday,\n\t\tgoToDate,\n\n\t\t// Filters\n\t\tsetFilters,\n\t\tupdateFilters,\n\t\tclearFilters,\n\n\t\t// Preferences\n\t\tsetPreferences,\n\n\t\t// Event handlers\n\t\thandleEventClick,\n\t\thandleSlotSelect,\n\t};\n}\n"],"names":["CalendarContext","createContext","CalendarProvider","children","value","jsx","useCalendarContext","context","useContext","useOptionalCalendarContext","useCalendarView","view","setView","useCalendarDate","currentDate","setCurrentDate","goToNext","goToPrev","goToToday","goToDate","useCalendarEvents","events","filteredEvents","useCalendarFilters","filters","setFilters","updateFilters","clearFilters","useCalendarPreferences","preferences","setPreferences","useCalendar","options","resources","scheduleTypes","initialView","initialDate","initialFilters","userPreferences","lockedPreferences","locale","onViewChange","onDateChange","onEventClick","onSlotSelect","onFiltersChange","setViewState","useState","setCurrentDateState","setFiltersState","setPreferencesState","DEFAULT_PREFERENCES","dateRange","useMemo","getViewDateRange","viewTitle","getViewTitle","result","filterEventsByDateRange","scheduleTypeIds","filterEventsByScheduleType","resourceIds","filterEventsByResource","search","filterEventsBySearch","filterOutCanceled","sortEventsByStart","useCallback","newView","date","newDate","navigateNext","navigatePrev","navigateToday","newFilters","updates","prev","next","emptyFilters","prefs","handleEventClick","event","handleSlotSelect","selection"],"mappings":";;;AAmBA,MAAMA,IAAkBC,EAA4D,MAAS;AAetF,SAASC,GAId,EAAE,UAAAC,GAAU,OAAAC,KAA8E;AAC3F,SAAO,gBAAAC,EAACL,EAAgB,UAAhB,EAAyB,OAAAI,GAAe,UAAAD,EAAA,CAAS;AAC1D;AASO,SAASG,IAIqD;AACpE,QAAMC,IAAUC,EAAWR,CAAe;AAC1C,MAAI,CAACO;AACJ,UAAM,IAAI,MAAM,2DAA2D;AAE5E,SAAOA;AACR;AAKO,SAASE,KAIiE;AAEhF,SADgBD,EAAWR,CAAe;AAE3C;AASO,SAASU,KAAkB;AACjC,QAAM,EAAE,MAAAC,GAAM,SAAAC,EAAA,IAAYN,EAAA;AAC1B,SAAO,EAAE,MAAAK,GAAM,SAAAC,EAAA;AAChB;AAKO,SAASC,KAAkB;AACjC,QAAM,EAAE,aAAAC,GAAa,gBAAAC,GAAgB,U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esC,CAAK;AAAA,IACrB;AAAA,IACA,CAACtC,CAAY;AAAA,EAAA,GAGRuC,IAAmBf;AAAA,IACxB,CAACgB,MAAgC;AAChC,MAAAvC,IAAeuC,CAAS;AAAA,IACzB;AAAA,IACA,CAACvC,CAAY;AAAA,EAAA;AAOd,SAAO;AAAA;AAAA,IAEN,MAAAjC;AAAA,IACA,aAAAG;AAAA,IACA,WAAAsC;AAAA,IACA,SAAA5B;AAAA,IACA,aAAAK;AAAA;AAAA,IAGA,gBAAAP;AAAA,IACA,WAAAiC;AAAA;AAAA,IAGA,QAAAlC;AAAA,IACA,WAAAY;AAAA,IACA,eAAAC;AAAA;AAAA,IAGA,SAAAtB;AAAA,IACA,gBAAAG;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA;AAAA,IAGA,YAAAM;AAAA,IACA,eAAAC;AAAA,IACA,cAAAC;AAAA;AAAA,IAGA,gBAAAG;AAAA;AAAA,IAGA,kBAAAkD;AAAA,IACA,kBAAAE;AAAA,EAAA;AAEF;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const n=require("react"),T=require("./use-calendar-
|
|
2
|
-
//# sourceMappingURL=use-slot-selection-
|
|
1
|
+
"use strict";const n=require("react"),T=require("./use-calendar-BK0nQYJq.cjs"),d=require("./position-utils-ksZ_IjXC.cjs");function P(){const{preferences:t,setPreferences:s}=T.useCalendarContext(),a=n.useMemo(()=>({from:t.startHour,to:t.endHour}),[t.startHour,t.endHour]),u=n.useMemo(()=>({1:{from:t.startHour,to:t.endHour},2:{from:t.startHour,to:t.endHour},3:{from:t.startHour,to:t.endHour},4:{from:t.startHour,to:t.endHour},5:{from:t.startHour,to:t.endHour}}),[t.startHour,t.endHour]),o=n.useCallback(e=>{s({startHour:e.from,endHour:e.to})},[s]),f=n.useCallback(e=>{const r=Object.values(e)[0];r&&s({startHour:r.from,endHour:r.to})},[s]),D=n.useCallback(e=>{s({slotDuration:e})},[s]),H=n.useCallback(e=>{console.warn("showWorkingHoursOnly is not yet supported in core preferences")},[]);return{visibleHours:a,setVisibleHours:o,workingHours:u,setWorkingHours:f,slotDuration:t.slotDuration,setSlotDuration:D,showWorkingHoursOnly:!1,setShowWorkingHoursOnly:H}}function w(t={}){const{initial:s={},storageKey:a,onChange:u}=t,[o,f]=n.useState(()=>{if(a&&typeof window<"u")try{const r=localStorage.getItem(a);if(r){const S=JSON.parse(r);return{...d.DEFAULT_PREFERENCES,...S,...s}}}catch{}return{...d.DEFAULT_PREFERENCES,...s}});n.useEffect(()=>{if(a&&typeof window<"u")try{localStorage.setItem(a,JSON.stringify(o))}catch{}},[o,a]);const D=n.useCallback(r=>{f(S=>{const m={...S,...r};return u?.(m),m})},[u]),H=n.useCallback(()=>{const r={...d.DEFAULT_PREFERENCES,...s};f(r),u?.(r)},[s,u]),e=n.useCallback(r=>o[r],[o]);return{preferences:o,setPreferences:D,resetPreferences:H,getPreference:e}}const C={isSelecting:!1,startDate:null,endDate:null,startY:null,currentY:null,resourceId:void 0};function p(t){const{dayStart:s,visibleHours:a,hourHeight:u=d.DEFAULT_HOUR_HEIGHT,slotDuration:o=30,resourceId:f,enabled:D=!0,onSelect:H}=t,[e,r]=n.useState(C),S=n.useRef(0),m=n.useCallback((l,c)=>{if(!D)return;const i=l.clientY-c.top;S.current=c.height;const g=d.yToTime(i,s,a,u,o);r({isSelecting:!0,startDate:g,endDate:d.addMinutes(g,o),startY:i,currentY:i,resourceId:f})},[D,s,a,u,o,f]),b=n.useCallback((l,c)=>{if(!e.isSelecting||!e.startY)return;const i=Math.max(0,Math.min(l.clientY-c.top,c.height)),g=d.yToTime(i,s,a,u,o);r(h=>{if(!h.startDate)return h;const E=i>=(h.startY??0);return{...h,currentY:i,endDate:E?d.addMinutes(g,o):g,startDate:E?h.startDate:g}})},[e.isSelecting,e.startY,s,a,u,o]),Y=n.useCallback(()=>{if(!e.isSelecting||!e.startDate||!e.endDate){r(C);return}const l=e.startDate<e.endDate?e.startDate:e.endDate,c=e.startDate<e.endDate?e.endDate:e.startDate,i={startDate:l,endDate:c,resourceId:e.resourceId};H?.(i),r(C)},[e,H]),y=n.useCallback(()=>{r(C)},[]),k=(()=>{if(!e.isSelecting||e.startY===null||e.currentY===null)return{top:0,height:0,visible:!1};const l=Math.min(e.startY,e.currentY),c=Math.max(e.startY,e.currentY);return{top:l,height:Math.max(c-l,20),visible:!0}})();return{selection:e,overlay:k,handlePointerDown:m,handlePointerMove:b,handlePointerUp:Y,cancel:y,isSelecting:e.isSelecting}}exports.useCalendarTimeConfig=P;exports.usePreferences=w;exports.useSlotSelection=p;
|
|
2
|
+
//# sourceMappingURL=use-slot-selection-CCE11R4j.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slot-selection-C1tk-o0j.cjs","sources":["../src/core/hooks/use-calendar-time-config.ts","../src/core/hooks/use-preferences.ts","../src/core/hooks/use-slot-selection.ts"],"sourcesContent":["/**\n * useCalendarTimeConfig - Time Configuration Hook\n *\n * Convenience hook that provides access to time-related preferences\n * from the calendar context. Matches agenda-v2 naming conventions.\n *\n * @example\n * ```tsx\n * function TimeSettings() {\n * const {\n * visibleHours,\n * setVisibleHours,\n * workingHours,\n * setWorkingHours,\n * slotDuration,\n * setSlotDuration,\n * showWorkingHoursOnly,\n * setShowWorkingHoursOnly,\n * } = useCalendarTimeConfig();\n *\n * return (\n * <div>\n * <p>Visible: {visibleHours.from}:00 - {visibleHours.to}:00</p>\n * <p>Slot duration: {slotDuration} minutes</p>\n * </div>\n * );\n * }\n * ```\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { useCalendarContext } from '../context/calendar-context';\nimport type { IVisibleHoursConfig, TWorkingHoursConfig } from '../preferences/types';\nimport type { TSlotDuration } from '../types';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UseCalendarTimeConfigReturn {\n\t/** Current visible hours range */\n\tvisibleHours: IVisibleHoursConfig;\n\t/** Update visible hours */\n\tsetVisibleHours: (hours: IVisibleHoursConfig) => void;\n\t/** Current working hours configuration */\n\tworkingHours: TWorkingHoursConfig;\n\t/** Update working hours */\n\tsetWorkingHours: (hours: TWorkingHoursConfig) => void;\n\t/** Current slot duration in minutes */\n\tslotDuration: TSlotDuration;\n\t/** Update slot duration */\n\tsetSlotDuration: (duration: TSlotDuration) => void;\n\t/** Whether to show only working hours */\n\tshowWorkingHoursOnly: boolean;\n\t/** Toggle show working hours only */\n\tsetShowWorkingHoursOnly: (show: boolean) => void;\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\n/**\n * Get time configuration from calendar context\n *\n * Provides a focused subset of calendar preferences related to time display.\n * All setters will update the underlying preferences in the calendar context.\n *\n * Note: This hook maps the core preferences (startHour/endHour) to the\n * agenda-v2 naming convention (visibleHours.from/to, workingHours).\n */\nexport function useCalendarTimeConfig(): UseCalendarTimeConfigReturn {\n\tconst { preferences, setPreferences } = useCalendarContext();\n\n\t// Map core preferences to visible hours format\n\tconst visibleHours = useMemo<IVisibleHoursConfig>(\n\t\t() => ({\n\t\t\tfrom: preferences.startHour,\n\t\t\tto: preferences.endHour,\n\t\t}),\n\t\t[preferences.startHour, preferences.endHour]\n\t);\n\n\t// Default working hours based on visible hours (can be extended later)\n\tconst workingHours = useMemo<TWorkingHoursConfig>(\n\t\t() => ({\n\t\t\t// Default: Mon-Fri same hours\n\t\t\t1: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t2: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t3: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t4: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t5: { from: preferences.startHour, to: preferences.endHour },\n\t\t}),\n\t\t[preferences.startHour, preferences.endHour]\n\t);\n\n\tconst setVisibleHours = useCallback(\n\t\t(hours: IVisibleHoursConfig) => {\n\t\t\tsetPreferences({\n\t\t\t\tstartHour: hours.from,\n\t\t\t\tendHour: hours.to,\n\t\t\t});\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setWorkingHours = useCallback(\n\t\t(_hours: TWorkingHoursConfig) => {\n\t\t\t// Working hours per-day config would need to be added to core preferences\n\t\t\t// For now, we use the first available day's hours to set visible hours\n\t\t\tconst firstDay = Object.values(_hours)[0];\n\t\t\tif (firstDay) {\n\t\t\t\tsetPreferences({\n\t\t\t\t\tstartHour: firstDay.from,\n\t\t\t\t\tendHour: firstDay.to,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setSlotDuration = useCallback(\n\t\t(duration: TSlotDuration) => {\n\t\t\tsetPreferences({ slotDuration: duration });\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setShowWorkingHoursOnly = useCallback((_show: boolean) => {\n\t\t// This would need to be added to ICalendarPreferences\n\t\t// For now, this is a no-op but provides the API surface\n\t\tconsole.warn('showWorkingHoursOnly is not yet supported in core preferences');\n\t}, []);\n\n\treturn {\n\t\tvisibleHours,\n\t\tsetVisibleHours,\n\t\tworkingHours,\n\t\tsetWorkingHours,\n\t\tslotDuration: preferences.slotDuration as TSlotDuration,\n\t\tsetSlotDuration,\n\t\tshowWorkingHoursOnly: false, // Default until added to core preferences\n\t\tsetShowWorkingHoursOnly,\n\t};\n}\n","/**\n * usePreferences - Calendar Preferences Hook\n *\n * Manages user preferences with optional localStorage persistence.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { DEFAULT_PREFERENCES } from '../constants';\nimport type { ICalendarPreferences } from '../types';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UsePreferencesOptions {\n\t/** Initial preferences (overrides defaults) */\n\tinitial?: Partial<ICalendarPreferences>;\n\t/** Storage key for persistence (if provided, uses localStorage) */\n\tstorageKey?: string;\n\t/** Callback when preferences change */\n\tonChange?: (preferences: ICalendarPreferences) => void;\n}\n\nexport interface UsePreferencesReturn {\n\t/** Current preferences */\n\tpreferences: ICalendarPreferences;\n\t/** Update preferences */\n\tsetPreferences: (updates: Partial<ICalendarPreferences>) => void;\n\t/** Reset to defaults */\n\tresetPreferences: () => void;\n\t/** Get a specific preference */\n\tgetPreference: <K extends keyof ICalendarPreferences>(key: K) => ICalendarPreferences[K];\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function usePreferences(options: UsePreferencesOptions = {}): UsePreferencesReturn {\n\tconst { initial = {}, storageKey, onChange } = options;\n\n\t// Load from storage or use defaults\n\tconst [preferences, setPreferencesState] = useState<ICalendarPreferences>(() => {\n\t\tif (storageKey && typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tconst stored = localStorage.getItem(storageKey);\n\t\t\t\tif (stored) {\n\t\t\t\t\tconst parsed = JSON.parse(stored) as Partial<ICalendarPreferences>;\n\t\t\t\t\treturn { ...DEFAULT_PREFERENCES, ...parsed, ...initial };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore parsing errors\n\t\t\t}\n\t\t}\n\t\treturn { ...DEFAULT_PREFERENCES, ...initial };\n\t});\n\n\t// Persist to storage when preferences change\n\tuseEffect(() => {\n\t\tif (storageKey && typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tlocalStorage.setItem(storageKey, JSON.stringify(preferences));\n\t\t\t} catch {\n\t\t\t\t// Ignore storage errors\n\t\t\t}\n\t\t}\n\t}, [preferences, storageKey]);\n\n\tconst setPreferences = useCallback(\n\t\t(updates: Partial<ICalendarPreferences>) => {\n\t\t\tsetPreferencesState((prev) => {\n\t\t\t\tconst next = { ...prev, ...updates };\n\t\t\t\tonChange?.(next);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\t[onChange]\n\t);\n\n\tconst resetPreferences = useCallback(() => {\n\t\tconst defaults = { ...DEFAULT_PREFERENCES, ...initial };\n\t\tsetPreferencesState(defaults);\n\t\tonChange?.(defaults);\n\t}, [initial, onChange]);\n\n\tconst getPreference = useCallback(\n\t\t<K extends keyof ICalendarPreferences>(key: K): ICalendarPreferences[K] => {\n\t\t\treturn preferences[key];\n\t\t},\n\t\t[preferences]\n\t);\n\n\treturn {\n\t\tpreferences,\n\t\tsetPreferences,\n\t\tresetPreferences,\n\t\tgetPreference,\n\t};\n}\n","/**\n * useSlotSelection - Drag-to-Select Hook\n *\n * Handles mouse/touch interactions for creating events by\n * selecting time slots in the calendar grid.\n */\n\nimport { useCallback, useRef, useState } from 'react';\nimport { DEFAULT_HOUR_HEIGHT } from '../constants';\nimport type { ISelectionResult, ISlotSelection, IVisibleHours } from '../types';\nimport { addMinutes } from '../utils/date-utils';\nimport { yToTime } from '../utils/position-utils';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UseSlotSelectionOptions {\n\t/** Current day being selected on */\n\tdayStart: Date;\n\t/** Visible hours configuration */\n\tvisibleHours: IVisibleHours;\n\t/** Height of one hour in pixels */\n\thourHeight?: number;\n\t/** Slot duration in minutes for snapping */\n\tslotDuration?: number;\n\t/** Resource ID (for resource views) */\n\tresourceId?: string;\n\t/** Whether selection is enabled */\n\tenabled?: boolean;\n\t/** Callback when selection completes */\n\tonSelect?: (selection: ISelectionResult) => void;\n}\n\nexport interface UseSlotSelectionReturn {\n\t/** Current selection state */\n\tselection: ISlotSelection;\n\t/** Selection overlay for rendering */\n\toverlay: { top: number; height: number; visible: boolean };\n\t/** Handler for mouse/touch down */\n\thandlePointerDown: (e: React.PointerEvent, containerRect: DOMRect) => void;\n\t/** Handler for mouse/touch move */\n\thandlePointerMove: (e: React.PointerEvent, containerRect: DOMRect) => void;\n\t/** Handler for mouse/touch up */\n\thandlePointerUp: () => void;\n\t/** Cancel current selection */\n\tcancel: () => void;\n\t/** Whether currently selecting */\n\tisSelecting: boolean;\n}\n\n// ============================================================================\n// INITIAL STATE\n// ============================================================================\n\nconst INITIAL_SELECTION: ISlotSelection = {\n\tisSelecting: false,\n\tstartDate: null,\n\tendDate: null,\n\tstartY: null,\n\tcurrentY: null,\n\tresourceId: undefined,\n};\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function useSlotSelection(options: UseSlotSelectionOptions): UseSlotSelectionReturn {\n\tconst {\n\t\tdayStart,\n\t\tvisibleHours,\n\t\thourHeight = DEFAULT_HOUR_HEIGHT,\n\t\tslotDuration = 30,\n\t\tresourceId,\n\t\tenabled = true,\n\t\tonSelect,\n\t} = options;\n\n\tconst [selection, setSelection] = useState<ISlotSelection>(INITIAL_SELECTION);\n\tconst containerHeightRef = useRef<number>(0);\n\n\t// ========================================================================\n\t// HANDLERS\n\t// ========================================================================\n\n\tconst handlePointerDown = useCallback(\n\t\t(e: React.PointerEvent, containerRect: DOMRect) => {\n\t\t\tif (!enabled) return;\n\n\t\t\tconst y = e.clientY - containerRect.top;\n\t\t\tcontainerHeightRef.current = containerRect.height;\n\n\t\t\tconst startTime = yToTime(y, dayStart, visibleHours, hourHeight, slotDuration);\n\n\t\t\tsetSelection({\n\t\t\t\tisSelecting: true,\n\t\t\t\tstartDate: startTime,\n\t\t\t\tendDate: addMinutes(startTime, slotDuration),\n\t\t\t\tstartY: y,\n\t\t\t\tcurrentY: y,\n\t\t\t\tresourceId,\n\t\t\t});\n\t\t},\n\t\t[enabled, dayStart, visibleHours, hourHeight, slotDuration, resourceId]\n\t);\n\n\tconst handlePointerMove = useCallback(\n\t\t(e: React.PointerEvent, containerRect: DOMRect) => {\n\t\t\tif (!selection.isSelecting || !selection.startY) return;\n\n\t\t\tconst y = Math.max(0, Math.min(e.clientY - containerRect.top, containerRect.height));\n\t\t\tconst currentTime = yToTime(y, dayStart, visibleHours, hourHeight, slotDuration);\n\n\t\t\tsetSelection((prev) => {\n\t\t\t\tif (!prev.startDate) return prev;\n\n\t\t\t\t// Determine if dragging up or down\n\t\t\t\tconst isDraggingDown = y >= (prev.startY ?? 0);\n\n\t\t\t\treturn {\n\t\t\t\t\t...prev,\n\t\t\t\t\tcurrentY: y,\n\t\t\t\t\tendDate: isDraggingDown ? addMinutes(currentTime, slotDuration) : currentTime,\n\t\t\t\t\tstartDate: isDraggingDown ? prev.startDate : currentTime,\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\t[selection.isSelecting, selection.startY, dayStart, visibleHours, hourHeight, slotDuration]\n\t);\n\n\tconst handlePointerUp = useCallback(() => {\n\t\tif (!selection.isSelecting || !selection.startDate || !selection.endDate) {\n\t\t\tsetSelection(INITIAL_SELECTION);\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure start is before end\n\t\tconst start = selection.startDate < selection.endDate ? selection.startDate : selection.endDate;\n\t\tconst end = selection.startDate < selection.endDate ? selection.endDate : selection.startDate;\n\n\t\tconst result: ISelectionResult = {\n\t\t\tstartDate: start,\n\t\t\tendDate: end,\n\t\t\tresourceId: selection.resourceId,\n\t\t};\n\n\t\tonSelect?.(result);\n\t\tsetSelection(INITIAL_SELECTION);\n\t}, [selection, onSelect]);\n\n\tconst cancel = useCallback(() => {\n\t\tsetSelection(INITIAL_SELECTION);\n\t}, []);\n\n\t// ========================================================================\n\t// OVERLAY CALCULATION\n\t// ========================================================================\n\n\tconst overlay = (() => {\n\t\tif (!selection.isSelecting || selection.startY === null || selection.currentY === null) {\n\t\t\treturn { top: 0, height: 0, visible: false };\n\t\t}\n\n\t\tconst minY = Math.min(selection.startY, selection.currentY);\n\t\tconst maxY = Math.max(selection.startY, selection.currentY);\n\n\t\treturn {\n\t\t\ttop: minY,\n\t\t\theight: Math.max(maxY - minY, 20), // Minimum height\n\t\t\tvisible: true,\n\t\t};\n\t})();\n\n\t// ========================================================================\n\t// RETURN\n\t// ========================================================================\n\n\treturn {\n\t\tselection,\n\t\toverlay,\n\t\thandlePointerDown,\n\t\thandlePointerMove,\n\t\thandlePointerUp,\n\t\tcancel,\n\t\tisSelecting: selection.isSelecting,\n\t};\n}\n"],"names":["useCalendarTimeConfig","preferences","setPreferences","useCalendarContext","visibleHours","useMemo","workingHours","setVisibleHours","useCallback","hours","setWorkingHours","_hours","firstDay","setSlotDuration","duration","setShowWorkingHoursOnly","_show","usePreferences","options","initial","storageKey","onChange","setPreferencesState","useState","stored","parsed","DEFAULT_PREFERENCES","useEffect","updates","prev","next","resetPreferences","defaults","getPreference","key","INITIAL_SELECTION","useSlotSelection","dayStart","hourHeight","DEFAULT_HOUR_HEIGHT","slotDuration","resourceId","enabled","onSelect","selection","setSelection","containerHeightRef","useRef","handlePointerDown","e","containerRect","y","startTime","yToTime","addMinutes","handlePointerMove","currentTime","isDraggingDown","handlePointerUp","start","end","result","cancel","overlay","minY","maxY"],"mappings":"0HAuEO,SAASA,GAAqD,CACpE,KAAM,CAAE,YAAAC,EAAa,eAAAC,CAAA,EAAmBC,qBAAA,EAGlCC,EAAeC,EAAAA,QACpB,KAAO,CACN,KAAMJ,EAAY,UAClB,GAAIA,EAAY,OAAA,GAEjB,CAACA,EAAY,UAAWA,EAAY,OAAO,CAAA,EAItCK,EAAeD,EAAAA,QACpB,KAAO,CAEN,EAAG,CAAE,KAAMJ,EAAY,UAAW,GAAIA,EAAY,OAAA,EAClD,EAAG,CAAE,KAAMA,EAAY,UAAW,GAAIA,EAAY,OAAA,EAClD,EAAG,CAAE,KAAMA,EAAY,UAAW,GAAIA,EAAY,OAAA,EAClD,EAAG,CAAE,KAAMA,EAAY,UAAW,GAAIA,EAAY,OAAA,EAClD,EAAG,CAAE,KAAMA,EAAY,UAAW,GAAIA,EAAY,OAAA,CAAQ,GAE3D,CAACA,EAAY,UAAWA,EAAY,OAAO,CAAA,EAGtCM,EAAkBC,EAAAA,YACtBC,GAA+B,CAC/BP,EAAe,CACd,UAAWO,EAAM,KACjB,QAASA,EAAM,EAAA,CACf,CACF,EACA,CAACP,CAAc,CAAA,EAGVQ,EAAkBF,EAAAA,YACtBG,GAAgC,CAGhC,MAAMC,EAAW,OAAO,OAAOD,CAAM,EAAE,CAAC,EACpCC,GACHV,EAAe,CACd,UAAWU,EAAS,KACpB,QAASA,EAAS,EAAA,CAClB,CAEH,EACA,CAACV,CAAc,CAAA,EAGVW,EAAkBL,EAAAA,YACtBM,GAA4B,CAC5BZ,EAAe,CAA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AAmB,EACA,kBAAAf,EACA,kBAAAO,EACA,gBAAAG,EACA,OAAAI,EACA,YAAalB,EAAU,WAAA,CAEzB"}
|
|
1
|
+
{"version":3,"file":"use-slot-selection-CCE11R4j.cjs","sources":["../src/core/hooks/use-calendar-time-config.ts","../src/core/hooks/use-preferences.ts","../src/core/hooks/use-slot-selection.ts"],"sourcesContent":["/**\n * useCalendarTimeConfig - Time Configuration Hook\n *\n * Convenience hook that provides access to time-related preferences\n * from the calendar context. Matches agenda-v2 naming conventions.\n *\n * @example\n * ```tsx\n * function TimeSettings() {\n * const {\n * visibleHours,\n * setVisibleHours,\n * workingHours,\n * setWorkingHours,\n * slotDuration,\n * setSlotDuration,\n * showWorkingHoursOnly,\n * setShowWorkingHoursOnly,\n * } = useCalendarTimeConfig();\n *\n * return (\n * <div>\n * <p>Visible: {visibleHours.from}:00 - {visibleHours.to}:00</p>\n * <p>Slot duration: {slotDuration} minutes</p>\n * </div>\n * );\n * }\n * ```\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { useCalendarContext } from '../context/calendar-context';\nimport type { IVisibleHoursConfig, TWorkingHoursConfig } from '../preferences/types';\nimport type { TSlotDuration } from '../types';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UseCalendarTimeConfigReturn {\n\t/** Current visible hours range */\n\tvisibleHours: IVisibleHoursConfig;\n\t/** Update visible hours */\n\tsetVisibleHours: (hours: IVisibleHoursConfig) => void;\n\t/** Current working hours configuration */\n\tworkingHours: TWorkingHoursConfig;\n\t/** Update working hours */\n\tsetWorkingHours: (hours: TWorkingHoursConfig) => void;\n\t/** Current slot duration in minutes */\n\tslotDuration: TSlotDuration;\n\t/** Update slot duration */\n\tsetSlotDuration: (duration: TSlotDuration) => void;\n\t/** Whether to show only working hours */\n\tshowWorkingHoursOnly: boolean;\n\t/** Toggle show working hours only */\n\tsetShowWorkingHoursOnly: (show: boolean) => void;\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\n/**\n * Get time configuration from calendar context\n *\n * Provides a focused subset of calendar preferences related to time display.\n * All setters will update the underlying preferences in the calendar context.\n *\n * Note: This hook maps the core preferences (startHour/endHour) to the\n * agenda-v2 naming convention (visibleHours.from/to, workingHours).\n */\nexport function useCalendarTimeConfig(): UseCalendarTimeConfigReturn {\n\tconst { preferences, setPreferences } = useCalendarContext();\n\n\t// Map core preferences to visible hours format\n\tconst visibleHours = useMemo<IVisibleHoursConfig>(\n\t\t() => ({\n\t\t\tfrom: preferences.startHour,\n\t\t\tto: preferences.endHour,\n\t\t}),\n\t\t[preferences.startHour, preferences.endHour]\n\t);\n\n\t// Default working hours based on visible hours (can be extended later)\n\tconst workingHours = useMemo<TWorkingHoursConfig>(\n\t\t() => ({\n\t\t\t// Default: Mon-Fri same hours\n\t\t\t1: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t2: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t3: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t4: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t5: { from: preferences.startHour, to: preferences.endHour },\n\t\t}),\n\t\t[preferences.startHour, preferences.endHour]\n\t);\n\n\tconst setVisibleHours = useCallback(\n\t\t(hours: IVisibleHoursConfig) => {\n\t\t\tsetPreferences({\n\t\t\t\tstartHour: hours.from,\n\t\t\t\tendHour: hours.to,\n\t\t\t});\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setWorkingHours = useCallback(\n\t\t(_hours: TWorkingHoursConfig) => {\n\t\t\t// Working hours per-day config would need to be added to core preferences\n\t\t\t// For now, we use the first available day's hours to set visible hours\n\t\t\tconst firstDay = Object.values(_hours)[0];\n\t\t\tif (firstDay) {\n\t\t\t\tsetPreferences({\n\t\t\t\t\tstartHour: firstDay.from,\n\t\t\t\t\tendHour: firstDay.to,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setSlotDuration = useCallback(\n\t\t(duration: TSlotDuration) => {\n\t\t\tsetPreferences({ slotDuration: duration });\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setShowWorkingHoursOnly = useCallback((_show: boolean) => {\n\t\t// This would need to be added to ICalendarPreferences\n\t\t// For now, this is a no-op but provides the API surface\n\t\tconsole.warn('showWorkingHoursOnly is not yet supported in core preferences');\n\t}, []);\n\n\treturn {\n\t\tvisibleHours,\n\t\tsetVisibleHours,\n\t\tworkingHours,\n\t\tsetWorkingHours,\n\t\tslotDuration: preferences.slotDuration as TSlotDuration,\n\t\tsetSlotDuration,\n\t\tshowWorkingHoursOnly: false, // Default until added to core preferences\n\t\tsetShowWorkingHoursOnly,\n\t};\n}\n","/**\n * usePreferences - Calendar Preferences Hook\n *\n * Manages user preferences with optional localStorage persistence.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { DEFAULT_PREFERENCES } from '../constants';\nimport type { ICalendarPreferences } from '../types';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UsePreferencesOptions {\n\t/** Initial preferences (overrides defaults) */\n\tinitial?: Partial<ICalendarPreferences>;\n\t/** Storage key for persistence (if provided, uses localStorage) */\n\tstorageKey?: string;\n\t/** Callback when preferences change */\n\tonChange?: (preferences: ICalendarPreferences) => void;\n}\n\nexport interface UsePreferencesReturn {\n\t/** Current preferences */\n\tpreferences: ICalendarPreferences;\n\t/** Update preferences */\n\tsetPreferences: (updates: Partial<ICalendarPreferences>) => void;\n\t/** Reset to defaults */\n\tresetPreferences: () => void;\n\t/** Get a specific preference */\n\tgetPreference: <K extends keyof ICalendarPreferences>(key: K) => ICalendarPreferences[K];\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function usePreferences(options: UsePreferencesOptions = {}): UsePreferencesReturn {\n\tconst { initial = {}, storageKey, onChange } = options;\n\n\t// Load from storage or use defaults\n\tconst [preferences, setPreferencesState] = useState<ICalendarPreferences>(() => {\n\t\tif (storageKey && typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tconst stored = localStorage.getItem(storageKey);\n\t\t\t\tif (stored) {\n\t\t\t\t\tconst parsed = JSON.parse(stored) as Partial<ICalendarPreferences>;\n\t\t\t\t\treturn { ...DEFAULT_PREFERENCES, ...parsed, ...initial };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore parsing errors\n\t\t\t}\n\t\t}\n\t\treturn { ...DEFAULT_PREFERENCES, ...initial };\n\t});\n\n\t// Persist to storage when preferences change\n\tuseEffect(() => {\n\t\tif (storageKey && typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tlocalStorage.setItem(storageKey, JSON.stringify(preferences));\n\t\t\t} catch {\n\t\t\t\t// Ignore storage errors\n\t\t\t}\n\t\t}\n\t}, [preferences, storageKey]);\n\n\tconst setPreferences = useCallback(\n\t\t(updates: Partial<ICalendarPreferences>) => {\n\t\t\tsetPreferencesState((prev) => {\n\t\t\t\tconst next = { ...prev, ...updates };\n\t\t\t\tonChange?.(next);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\t[onChange]\n\t);\n\n\tconst resetPreferences = useCallback(() => {\n\t\tconst defaults = { ...DEFAULT_PREFERENCES, ...initial };\n\t\tsetPreferencesState(defaults);\n\t\tonChange?.(defaults);\n\t}, [initial, onChange]);\n\n\tconst getPreference = useCallback(\n\t\t<K extends keyof ICalendarPreferences>(key: K): ICalendarPreferences[K] => {\n\t\t\treturn preferences[key];\n\t\t},\n\t\t[preferences]\n\t);\n\n\treturn {\n\t\tpreferences,\n\t\tsetPreferences,\n\t\tresetPreferences,\n\t\tgetPreference,\n\t};\n}\n","/**\n * useSlotSelection - Drag-to-Select Hook\n *\n * Handles mouse/touch interactions for creating events by\n * selecting time slots in the calendar grid.\n */\n\nimport { useCallback, useRef, useState } from 'react';\nimport { DEFAULT_HOUR_HEIGHT } from '../constants';\nimport type { ISelectionResult, ISlotSelection, IVisibleHours } from '../types';\nimport { addMinutes } from '../utils/date-utils';\nimport { yToTime } from '../utils/position-utils';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UseSlotSelectionOptions {\n\t/** Current day being selected on */\n\tdayStart: Date;\n\t/** Visible hours configuration */\n\tvisibleHours: IVisibleHours;\n\t/** Height of one hour in pixels */\n\thourHeight?: number;\n\t/** Slot duration in minutes for snapping */\n\tslotDuration?: number;\n\t/** Resource ID (for resource views) */\n\tresourceId?: string;\n\t/** Whether selection is enabled */\n\tenabled?: boolean;\n\t/** Callback when selection completes */\n\tonSelect?: (selection: ISelectionResult) => void;\n}\n\nexport interface UseSlotSelectionReturn {\n\t/** Current selection state */\n\tselection: ISlotSelection;\n\t/** Selection overlay for rendering */\n\toverlay: { top: number; height: number; visible: boolean };\n\t/** Handler for mouse/touch down */\n\thandlePointerDown: (e: React.PointerEvent, containerRect: DOMRect) => void;\n\t/** Handler for mouse/touch move */\n\thandlePointerMove: (e: React.PointerEvent, containerRect: DOMRect) => void;\n\t/** Handler for mouse/touch up */\n\thandlePointerUp: () => void;\n\t/** Cancel current selection */\n\tcancel: () => void;\n\t/** Whether currently selecting */\n\tisSelecting: boolean;\n}\n\n// ============================================================================\n// INITIAL STATE\n// ============================================================================\n\nconst INITIAL_SELECTION: ISlotSelection = {\n\tisSelecting: false,\n\tstartDate: null,\n\tendDate: null,\n\tstartY: null,\n\tcurrentY: null,\n\tresourceId: undefined,\n};\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function useSlotSelection(options: UseSlotSelectionOptions): UseSlotSelectionReturn {\n\tconst {\n\t\tdayStart,\n\t\tvisibleHours,\n\t\thourHeight = DEFAULT_HOUR_HEIGHT,\n\t\tslotDuration = 30,\n\t\tresourceId,\n\t\tenabled = true,\n\t\tonSelect,\n\t} = options;\n\n\tconst [selection, setSelection] = useState<ISlotSelection>(INITIAL_SELECTION);\n\tconst containerHeightRef = useRef<number>(0);\n\n\t// ========================================================================\n\t// HANDLERS\n\t// ========================================================================\n\n\tconst handlePointerDown = useCallback(\n\t\t(e: React.PointerEvent, containerRect: DOMRect) => {\n\t\t\tif (!enabled) return;\n\n\t\t\tconst y = e.clientY - containerRect.top;\n\t\t\tcontainerHeightRef.current = containerRect.height;\n\n\t\t\tconst startTime = yToTime(y, dayStart, visibleHours, hourHeight, slotDuration);\n\n\t\t\tsetSelection({\n\t\t\t\tisSelecting: true,\n\t\t\t\tstartDate: startTime,\n\t\t\t\tendDate: addMinutes(startTime, slotDuration),\n\t\t\t\tstartY: y,\n\t\t\t\tcurrentY: y,\n\t\t\t\tresourceId,\n\t\t\t});\n\t\t},\n\t\t[enabled, dayStart, visibleHours, hourHeight, slotDuration, resourceId]\n\t);\n\n\tconst handlePointerMove = useCallback(\n\t\t(e: React.PointerEvent, containerRect: DOMRect) => {\n\t\t\tif (!selection.isSelecting || !selection.startY) return;\n\n\t\t\tconst y = Math.max(0, Math.min(e.clientY - containerRect.top, containerRect.height));\n\t\t\tconst currentTime = yToTime(y, dayStart, visibleHours, hourHeight, slotDuration);\n\n\t\t\tsetSelection((prev) => {\n\t\t\t\tif (!prev.startDate) return prev;\n\n\t\t\t\t// Determine if dragging up or down\n\t\t\t\tconst isDraggingDown = y >= (prev.startY ?? 0);\n\n\t\t\t\treturn {\n\t\t\t\t\t...prev,\n\t\t\t\t\tcurrentY: y,\n\t\t\t\t\tendDate: isDraggingDown ? addMinutes(currentTime, slotDuration) : currentTime,\n\t\t\t\t\tstartDate: isDraggingDown ? prev.startDate : currentTime,\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\t[selection.isSelecting, selection.startY, dayStart, visibleHours, hourHeight, slotDuration]\n\t);\n\n\tconst handlePointerUp = useCallback(() => {\n\t\tif (!selection.isSelecting || !selection.startDate || !selection.endDate) {\n\t\t\tsetSelection(INITIAL_SELECTION);\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure start is before end\n\t\tconst start = selection.startDate < selection.endDate ? selection.startDate : selection.endDate;\n\t\tconst end = selection.startDate < selection.endDate ? selection.endDate : selection.startDate;\n\n\t\tconst result: ISelectionResult = {\n\t\t\tstartDate: start,\n\t\t\tendDate: end,\n\t\t\tresourceId: selection.resourceId,\n\t\t};\n\n\t\tonSelect?.(result);\n\t\tsetSelection(INITIAL_SELECTION);\n\t}, [selection, onSelect]);\n\n\tconst cancel = useCallback(() => {\n\t\tsetSelection(INITIAL_SELECTION);\n\t}, []);\n\n\t// ========================================================================\n\t// OVERLAY CALCULATION\n\t// ========================================================================\n\n\tconst overlay = (() => {\n\t\tif (!selection.isSelecting || selection.startY === null || selection.currentY === null) {\n\t\t\treturn { top: 0, height: 0, visible: false };\n\t\t}\n\n\t\tconst minY = Math.min(selection.startY, selection.currentY);\n\t\tconst maxY = Math.max(selection.startY, selection.currentY);\n\n\t\treturn {\n\t\t\ttop: minY,\n\t\t\theight: Math.max(maxY - minY, 20), // Minimum height\n\t\t\tvisible: true,\n\t\t};\n\t})();\n\n\t// ========================================================================\n\t// RETURN\n\t// ========================================================================\n\n\treturn {\n\t\tselection,\n\t\toverlay,\n\t\thandlePointerDown,\n\t\thandlePointerMove,\n\t\thandlePointerUp,\n\t\tcancel,\n\t\tisSelecting: selection.isSelecting,\n\t};\n}\n"],"names":["useCalendarTimeConfig","preferences","setPreferences","useCalendarContext","visibleHours","useMemo","workingHours","setVisibleHours","useCallback","hours","setWorkingHours","_hours","firstDay","setSlotDuration","duration","setShowWorkingHoursOnly","_show","usePreferences","options","initial","storageKey","onChange","setPreferencesState","useState","stored","parsed","DEFAULT_PREFERENCES","useEffect","updates","prev","next","resetPreferences","defaults","getPreference","key","INITIAL_SELECTION","useSlotSelection","dayStart","hourHeight","DEFAULT_HOUR_HEIGHT","slotDuration","resourceId","enabled","onSelect","selection","setSelection","containerHeightRef","useRef","handlePointerDown","e","containerRect","y","startTime","yToTime","addMinutes","handlePointerMove","currentTime","isDraggingDown","handlePointerUp","start","end","result","cancel","overlay","minY","maxY"],"mappings":"0HAuEO,SAASA,GAAqD,CACpE,KAAM,CAAE,YAAAC,EAAa,eAAAC,CAAA,EAAmBC,qBAAA,EAGlCC,EAAeC,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AAI,CAACoC,EAAU,aAAe,CAACA,EAAU,WAAa,CAACA,EAAU,QAAS,CACzEC,EAAaV,CAAiB,EAC9B,MACD,CAGA,MAAMwB,EAAQf,EAAU,UAAYA,EAAU,QAAUA,EAAU,UAAYA,EAAU,QAClFgB,EAAMhB,EAAU,UAAYA,EAAU,QAAUA,EAAU,QAAUA,EAAU,UAE9EiB,EAA2B,CAChC,UAAWF,EACX,QAASC,EACT,WAAYhB,EAAU,UAAA,EAGvBD,IAAWkB,CAAM,EACjBhB,EAAaV,CAAiB,CAC/B,EAAG,CAACS,EAAWD,CAAQ,CAAC,EAElBmB,EAAStD,EAAAA,YAAY,IAAM,CAChCqC,EAAaV,CAAiB,CAC/B,EAAG,CAAA,CAAE,EAMC4B,GAAW,IAAM,CACtB,GAAI,CAACnB,EAAU,aAAeA,EAAU,SAAW,MAAQA,EAAU,WAAa,KACjF,MAAO,CAAE,IAAK,EAAG,OAAQ,EAAG,QAAS,EAAA,EAGtC,MAAMoB,EAAO,KAAK,IAAIpB,EAAU,OAAQA,EAAU,QAAQ,EACpDqB,EAAO,KAAK,IAAIrB,EAAU,OAAQA,EAAU,QAAQ,EAE1D,MAAO,CACN,IAAKoB,EACL,OAAQ,KAAK,IAAIC,EAAOD,EAAM,EAAE,EAChC,QAAS,EAAA,CAEX,GAAA,EAMA,MAAO,CACN,UAAApB,EACA,QAAAmB,EACA,kBAAAf,EACA,kBAAAO,EACA,gBAAAG,EACA,OAAAI,EACA,YAAalB,EAAU,WAAA,CAEzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo as p, useCallback as i, useState as I, useEffect as M, useRef as O } from "react";
|
|
2
|
-
import { a as x } from "./use-calendar
|
|
3
|
-
import { d as Y, c as k, bb as w, q as b } from "./position-utils-
|
|
2
|
+
import { a as x } from "./use-calendar-DJI35SSd.js";
|
|
3
|
+
import { d as Y, c as k, bb as w, q as b } from "./position-utils-D_KpwRus.js";
|
|
4
4
|
function L() {
|
|
5
5
|
const { preferences: e, setPreferences: n } = x(), o = p(
|
|
6
6
|
() => ({
|
|
@@ -185,4 +185,4 @@ export {
|
|
|
185
185
|
W as b,
|
|
186
186
|
L as u
|
|
187
187
|
};
|
|
188
|
-
//# sourceMappingURL=use-slot-selection-
|
|
188
|
+
//# sourceMappingURL=use-slot-selection-CX1w8EdM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slot-selection-BLCDzQzo.js","sources":["../src/core/hooks/use-calendar-time-config.ts","../src/core/hooks/use-preferences.ts","../src/core/hooks/use-slot-selection.ts"],"sourcesContent":["/**\n * useCalendarTimeConfig - Time Configuration Hook\n *\n * Convenience hook that provides access to time-related preferences\n * from the calendar context. Matches agenda-v2 naming conventions.\n *\n * @example\n * ```tsx\n * function TimeSettings() {\n * const {\n * visibleHours,\n * setVisibleHours,\n * workingHours,\n * setWorkingHours,\n * slotDuration,\n * setSlotDuration,\n * showWorkingHoursOnly,\n * setShowWorkingHoursOnly,\n * } = useCalendarTimeConfig();\n *\n * return (\n * <div>\n * <p>Visible: {visibleHours.from}:00 - {visibleHours.to}:00</p>\n * <p>Slot duration: {slotDuration} minutes</p>\n * </div>\n * );\n * }\n * ```\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { useCalendarContext } from '../context/calendar-context';\nimport type { IVisibleHoursConfig, TWorkingHoursConfig } from '../preferences/types';\nimport type { TSlotDuration } from '../types';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UseCalendarTimeConfigReturn {\n\t/** Current visible hours range */\n\tvisibleHours: IVisibleHoursConfig;\n\t/** Update visible hours */\n\tsetVisibleHours: (hours: IVisibleHoursConfig) => void;\n\t/** Current working hours configuration */\n\tworkingHours: TWorkingHoursConfig;\n\t/** Update working hours */\n\tsetWorkingHours: (hours: TWorkingHoursConfig) => void;\n\t/** Current slot duration in minutes */\n\tslotDuration: TSlotDuration;\n\t/** Update slot duration */\n\tsetSlotDuration: (duration: TSlotDuration) => void;\n\t/** Whether to show only working hours */\n\tshowWorkingHoursOnly: boolean;\n\t/** Toggle show working hours only */\n\tsetShowWorkingHoursOnly: (show: boolean) => void;\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\n/**\n * Get time configuration from calendar context\n *\n * Provides a focused subset of calendar preferences related to time display.\n * All setters will update the underlying preferences in the calendar context.\n *\n * Note: This hook maps the core preferences (startHour/endHour) to the\n * agenda-v2 naming convention (visibleHours.from/to, workingHours).\n */\nexport function useCalendarTimeConfig(): UseCalendarTimeConfigReturn {\n\tconst { preferences, setPreferences } = useCalendarContext();\n\n\t// Map core preferences to visible hours format\n\tconst visibleHours = useMemo<IVisibleHoursConfig>(\n\t\t() => ({\n\t\t\tfrom: preferences.startHour,\n\t\t\tto: preferences.endHour,\n\t\t}),\n\t\t[preferences.startHour, preferences.endHour]\n\t);\n\n\t// Default working hours based on visible hours (can be extended later)\n\tconst workingHours = useMemo<TWorkingHoursConfig>(\n\t\t() => ({\n\t\t\t// Default: Mon-Fri same hours\n\t\t\t1: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t2: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t3: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t4: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t5: { from: preferences.startHour, to: preferences.endHour },\n\t\t}),\n\t\t[preferences.startHour, preferences.endHour]\n\t);\n\n\tconst setVisibleHours = useCallback(\n\t\t(hours: IVisibleHoursConfig) => {\n\t\t\tsetPreferences({\n\t\t\t\tstartHour: hours.from,\n\t\t\t\tendHour: hours.to,\n\t\t\t});\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setWorkingHours = useCallback(\n\t\t(_hours: TWorkingHoursConfig) => {\n\t\t\t// Working hours per-day config would need to be added to core preferences\n\t\t\t// For now, we use the first available day's hours to set visible hours\n\t\t\tconst firstDay = Object.values(_hours)[0];\n\t\t\tif (firstDay) {\n\t\t\t\tsetPreferences({\n\t\t\t\t\tstartHour: firstDay.from,\n\t\t\t\t\tendHour: firstDay.to,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setSlotDuration = useCallback(\n\t\t(duration: TSlotDuration) => {\n\t\t\tsetPreferences({ slotDuration: duration });\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setShowWorkingHoursOnly = useCallback((_show: boolean) => {\n\t\t// This would need to be added to ICalendarPreferences\n\t\t// For now, this is a no-op but provides the API surface\n\t\tconsole.warn('showWorkingHoursOnly is not yet supported in core preferences');\n\t}, []);\n\n\treturn {\n\t\tvisibleHours,\n\t\tsetVisibleHours,\n\t\tworkingHours,\n\t\tsetWorkingHours,\n\t\tslotDuration: preferences.slotDuration as TSlotDuration,\n\t\tsetSlotDuration,\n\t\tshowWorkingHoursOnly: false, // Default until added to core preferences\n\t\tsetShowWorkingHoursOnly,\n\t};\n}\n","/**\n * usePreferences - Calendar Preferences Hook\n *\n * Manages user preferences with optional localStorage persistence.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { DEFAULT_PREFERENCES } from '../constants';\nimport type { ICalendarPreferences } from '../types';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UsePreferencesOptions {\n\t/** Initial preferences (overrides defaults) */\n\tinitial?: Partial<ICalendarPreferences>;\n\t/** Storage key for persistence (if provided, uses localStorage) */\n\tstorageKey?: string;\n\t/** Callback when preferences change */\n\tonChange?: (preferences: ICalendarPreferences) => void;\n}\n\nexport interface UsePreferencesReturn {\n\t/** Current preferences */\n\tpreferences: ICalendarPreferences;\n\t/** Update preferences */\n\tsetPreferences: (updates: Partial<ICalendarPreferences>) => void;\n\t/** Reset to defaults */\n\tresetPreferences: () => void;\n\t/** Get a specific preference */\n\tgetPreference: <K extends keyof ICalendarPreferences>(key: K) => ICalendarPreferences[K];\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function usePreferences(options: UsePreferencesOptions = {}): UsePreferencesReturn {\n\tconst { initial = {}, storageKey, onChange } = options;\n\n\t// Load from storage or use defaults\n\tconst [preferences, setPreferencesState] = useState<ICalendarPreferences>(() => {\n\t\tif (storageKey && typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tconst stored = localStorage.getItem(storageKey);\n\t\t\t\tif (stored) {\n\t\t\t\t\tconst parsed = JSON.parse(stored) as Partial<ICalendarPreferences>;\n\t\t\t\t\treturn { ...DEFAULT_PREFERENCES, ...parsed, ...initial };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore parsing errors\n\t\t\t}\n\t\t}\n\t\treturn { ...DEFAULT_PREFERENCES, ...initial };\n\t});\n\n\t// Persist to storage when preferences change\n\tuseEffect(() => {\n\t\tif (storageKey && typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tlocalStorage.setItem(storageKey, JSON.stringify(preferences));\n\t\t\t} catch {\n\t\t\t\t// Ignore storage errors\n\t\t\t}\n\t\t}\n\t}, [preferences, storageKey]);\n\n\tconst setPreferences = useCallback(\n\t\t(updates: Partial<ICalendarPreferences>) => {\n\t\t\tsetPreferencesState((prev) => {\n\t\t\t\tconst next = { ...prev, ...updates };\n\t\t\t\tonChange?.(next);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\t[onChange]\n\t);\n\n\tconst resetPreferences = useCallback(() => {\n\t\tconst defaults = { ...DEFAULT_PREFERENCES, ...initial };\n\t\tsetPreferencesState(defaults);\n\t\tonChange?.(defaults);\n\t}, [initial, onChange]);\n\n\tconst getPreference = useCallback(\n\t\t<K extends keyof ICalendarPreferences>(key: K): ICalendarPreferences[K] => {\n\t\t\treturn preferences[key];\n\t\t},\n\t\t[preferences]\n\t);\n\n\treturn {\n\t\tpreferences,\n\t\tsetPreferences,\n\t\tresetPreferences,\n\t\tgetPreference,\n\t};\n}\n","/**\n * useSlotSelection - Drag-to-Select Hook\n *\n * Handles mouse/touch interactions for creating events by\n * selecting time slots in the calendar grid.\n */\n\nimport { useCallback, useRef, useState } from 'react';\nimport { DEFAULT_HOUR_HEIGHT } from '../constants';\nimport type { ISelectionResult, ISlotSelection, IVisibleHours } from '../types';\nimport { addMinutes } from '../utils/date-utils';\nimport { yToTime } from '../utils/position-utils';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UseSlotSelectionOptions {\n\t/** Current day being selected on */\n\tdayStart: Date;\n\t/** Visible hours configuration */\n\tvisibleHours: IVisibleHours;\n\t/** Height of one hour in pixels */\n\thourHeight?: number;\n\t/** Slot duration in minutes for snapping */\n\tslotDuration?: number;\n\t/** Resource ID (for resource views) */\n\tresourceId?: string;\n\t/** Whether selection is enabled */\n\tenabled?: boolean;\n\t/** Callback when selection completes */\n\tonSelect?: (selection: ISelectionResult) => void;\n}\n\nexport interface UseSlotSelectionReturn {\n\t/** Current selection state */\n\tselection: ISlotSelection;\n\t/** Selection overlay for rendering */\n\toverlay: { top: number; height: number; visible: boolean };\n\t/** Handler for mouse/touch down */\n\thandlePointerDown: (e: React.PointerEvent, containerRect: DOMRect) => void;\n\t/** Handler for mouse/touch move */\n\thandlePointerMove: (e: React.PointerEvent, containerRect: DOMRect) => void;\n\t/** Handler for mouse/touch up */\n\thandlePointerUp: () => void;\n\t/** Cancel current selection */\n\tcancel: () => void;\n\t/** Whether currently selecting */\n\tisSelecting: boolean;\n}\n\n// ============================================================================\n// INITIAL STATE\n// ============================================================================\n\nconst INITIAL_SELECTION: ISlotSelection = {\n\tisSelecting: false,\n\tstartDate: null,\n\tendDate: null,\n\tstartY: null,\n\tcurrentY: null,\n\tresourceId: undefined,\n};\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function useSlotSelection(options: UseSlotSelectionOptions): UseSlotSelectionReturn {\n\tconst {\n\t\tdayStart,\n\t\tvisibleHours,\n\t\thourHeight = DEFAULT_HOUR_HEIGHT,\n\t\tslotDuration = 30,\n\t\tresourceId,\n\t\tenabled = true,\n\t\tonSelect,\n\t} = options;\n\n\tconst [selection, setSelection] = useState<ISlotSelection>(INITIAL_SELECTION);\n\tconst containerHeightRef = useRef<number>(0);\n\n\t// ========================================================================\n\t// HANDLERS\n\t// ========================================================================\n\n\tconst handlePointerDown = useCallback(\n\t\t(e: React.PointerEvent, containerRect: DOMRect) => {\n\t\t\tif (!enabled) return;\n\n\t\t\tconst y = e.clientY - containerRect.top;\n\t\t\tcontainerHeightRef.current = containerRect.height;\n\n\t\t\tconst startTime = yToTime(y, dayStart, visibleHours, hourHeight, slotDuration);\n\n\t\t\tsetSelection({\n\t\t\t\tisSelecting: true,\n\t\t\t\tstartDate: startTime,\n\t\t\t\tendDate: addMinutes(startTime, slotDuration),\n\t\t\t\tstartY: y,\n\t\t\t\tcurrentY: y,\n\t\t\t\tresourceId,\n\t\t\t});\n\t\t},\n\t\t[enabled, dayStart, visibleHours, hourHeight, slotDuration, resourceId]\n\t);\n\n\tconst handlePointerMove = useCallback(\n\t\t(e: React.PointerEvent, containerRect: DOMRect) => {\n\t\t\tif (!selection.isSelecting || !selection.startY) return;\n\n\t\t\tconst y = Math.max(0, Math.min(e.clientY - containerRect.top, containerRect.height));\n\t\t\tconst currentTime = yToTime(y, dayStart, visibleHours, hourHeight, slotDuration);\n\n\t\t\tsetSelection((prev) => {\n\t\t\t\tif (!prev.startDate) return prev;\n\n\t\t\t\t// Determine if dragging up or down\n\t\t\t\tconst isDraggingDown = y >= (prev.startY ?? 0);\n\n\t\t\t\treturn {\n\t\t\t\t\t...prev,\n\t\t\t\t\tcurrentY: y,\n\t\t\t\t\tendDate: isDraggingDown ? addMinutes(currentTime, slotDuration) : currentTime,\n\t\t\t\t\tstartDate: isDraggingDown ? prev.startDate : currentTime,\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\t[selection.isSelecting, selection.startY, dayStart, visibleHours, hourHeight, slotDuration]\n\t);\n\n\tconst handlePointerUp = useCallback(() => {\n\t\tif (!selection.isSelecting || !selection.startDate || !selection.endDate) {\n\t\t\tsetSelection(INITIAL_SELECTION);\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure start is before end\n\t\tconst start = selection.startDate < selection.endDate ? selection.startDate : selection.endDate;\n\t\tconst end = selection.startDate < selection.endDate ? selection.endDate : selection.startDate;\n\n\t\tconst result: ISelectionResult = {\n\t\t\tstartDate: start,\n\t\t\tendDate: end,\n\t\t\tresourceId: selection.resourceId,\n\t\t};\n\n\t\tonSelect?.(result);\n\t\tsetSelection(INITIAL_SELECTION);\n\t}, [selection, onSelect]);\n\n\tconst cancel = useCallback(() => {\n\t\tsetSelection(INITIAL_SELECTION);\n\t}, []);\n\n\t// ========================================================================\n\t// OVERLAY CALCULATION\n\t// ========================================================================\n\n\tconst overlay = (() => {\n\t\tif (!selection.isSelecting || selection.startY === null || selection.currentY === null) {\n\t\t\treturn { top: 0, height: 0, visible: false };\n\t\t}\n\n\t\tconst minY = Math.min(selection.startY, selection.currentY);\n\t\tconst maxY = Math.max(selection.startY, selection.currentY);\n\n\t\treturn {\n\t\t\ttop: minY,\n\t\t\theight: Math.max(maxY - minY, 20), // Minimum height\n\t\t\tvisible: true,\n\t\t};\n\t})();\n\n\t// ========================================================================\n\t// RETURN\n\t// ========================================================================\n\n\treturn {\n\t\tselection,\n\t\toverlay,\n\t\thandlePointerDown,\n\t\thandlePointerMove,\n\t\thandlePointerUp,\n\t\tcancel,\n\t\tisSelecting: selection.isSelecting,\n\t};\n}\n"],"names":["useCalendarTimeConfig","preferences","setPreferences","useCalendarContext","visibleHours","useMemo","workingHours","setVisibleHours","useCallback","hours","setWorkingHours","_hours","firstDay","setSlotDuration","duration","setShowWorkingHoursOnly","_show","usePreferences","options","initial","storageKey","onChange","setPreferencesState","useState","stored","parsed","DEFAULT_PREFERENCES","useEffect","updates","prev","next","resetPreferences","defaults","getPreference","key","INITIAL_SELECTION","useSlotSelection","dayStart","hourHeight","DEFAULT_HOUR_HEIGHT","slotDuration","resourceId","enabled","onSelect","selection","setSelection","containerHeightRef","useRef","handlePointerDown","e","containerRect","y","startTime","yToTime","addMinutes","handlePointerMove","currentTime","isDragg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AI,CAACnB,EAAU,eAAeA,EAAU,WAAW,QAAQA,EAAU,aAAa;AACjF,aAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAA;AAGtC,UAAMoB,IAAO,KAAK,IAAIpB,EAAU,QAAQA,EAAU,QAAQ,GACpDqB,IAAO,KAAK,IAAIrB,EAAU,QAAQA,EAAU,QAAQ;AAE1D,WAAO;AAAA,MACN,KAAKoB;AAAA,MACL,QAAQ,KAAK,IAAIC,IAAOD,GAAM,EAAE;AAAA;AAAA,MAChC,SAAS;AAAA,IAAA;AAAA,EAEX,GAAA;AAMA,SAAO;AAAA,IACN,WAAApB;AAAA,IACA,SAAAmB;AAAA,IACA,mBAAAf;AAAA,IACA,mBAAAO;AAAA,IACA,iBAAAG;AAAA,IACA,QAAAI;AAAA,IACA,aAAalB,EAAU;AAAA,EAAA;AAEzB;"}
|
|
1
|
+
{"version":3,"file":"use-slot-selection-CX1w8EdM.js","sources":["../src/core/hooks/use-calendar-time-config.ts","../src/core/hooks/use-preferences.ts","../src/core/hooks/use-slot-selection.ts"],"sourcesContent":["/**\n * useCalendarTimeConfig - Time Configuration Hook\n *\n * Convenience hook that provides access to time-related preferences\n * from the calendar context. Matches agenda-v2 naming conventions.\n *\n * @example\n * ```tsx\n * function TimeSettings() {\n * const {\n * visibleHours,\n * setVisibleHours,\n * workingHours,\n * setWorkingHours,\n * slotDuration,\n * setSlotDuration,\n * showWorkingHoursOnly,\n * setShowWorkingHoursOnly,\n * } = useCalendarTimeConfig();\n *\n * return (\n * <div>\n * <p>Visible: {visibleHours.from}:00 - {visibleHours.to}:00</p>\n * <p>Slot duration: {slotDuration} minutes</p>\n * </div>\n * );\n * }\n * ```\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { useCalendarContext } from '../context/calendar-context';\nimport type { IVisibleHoursConfig, TWorkingHoursConfig } from '../preferences/types';\nimport type { TSlotDuration } from '../types';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UseCalendarTimeConfigReturn {\n\t/** Current visible hours range */\n\tvisibleHours: IVisibleHoursConfig;\n\t/** Update visible hours */\n\tsetVisibleHours: (hours: IVisibleHoursConfig) => void;\n\t/** Current working hours configuration */\n\tworkingHours: TWorkingHoursConfig;\n\t/** Update working hours */\n\tsetWorkingHours: (hours: TWorkingHoursConfig) => void;\n\t/** Current slot duration in minutes */\n\tslotDuration: TSlotDuration;\n\t/** Update slot duration */\n\tsetSlotDuration: (duration: TSlotDuration) => void;\n\t/** Whether to show only working hours */\n\tshowWorkingHoursOnly: boolean;\n\t/** Toggle show working hours only */\n\tsetShowWorkingHoursOnly: (show: boolean) => void;\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\n/**\n * Get time configuration from calendar context\n *\n * Provides a focused subset of calendar preferences related to time display.\n * All setters will update the underlying preferences in the calendar context.\n *\n * Note: This hook maps the core preferences (startHour/endHour) to the\n * agenda-v2 naming convention (visibleHours.from/to, workingHours).\n */\nexport function useCalendarTimeConfig(): UseCalendarTimeConfigReturn {\n\tconst { preferences, setPreferences } = useCalendarContext();\n\n\t// Map core preferences to visible hours format\n\tconst visibleHours = useMemo<IVisibleHoursConfig>(\n\t\t() => ({\n\t\t\tfrom: preferences.startHour,\n\t\t\tto: preferences.endHour,\n\t\t}),\n\t\t[preferences.startHour, preferences.endHour]\n\t);\n\n\t// Default working hours based on visible hours (can be extended later)\n\tconst workingHours = useMemo<TWorkingHoursConfig>(\n\t\t() => ({\n\t\t\t// Default: Mon-Fri same hours\n\t\t\t1: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t2: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t3: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t4: { from: preferences.startHour, to: preferences.endHour },\n\t\t\t5: { from: preferences.startHour, to: preferences.endHour },\n\t\t}),\n\t\t[preferences.startHour, preferences.endHour]\n\t);\n\n\tconst setVisibleHours = useCallback(\n\t\t(hours: IVisibleHoursConfig) => {\n\t\t\tsetPreferences({\n\t\t\t\tstartHour: hours.from,\n\t\t\t\tendHour: hours.to,\n\t\t\t});\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setWorkingHours = useCallback(\n\t\t(_hours: TWorkingHoursConfig) => {\n\t\t\t// Working hours per-day config would need to be added to core preferences\n\t\t\t// For now, we use the first available day's hours to set visible hours\n\t\t\tconst firstDay = Object.values(_hours)[0];\n\t\t\tif (firstDay) {\n\t\t\t\tsetPreferences({\n\t\t\t\t\tstartHour: firstDay.from,\n\t\t\t\t\tendHour: firstDay.to,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setSlotDuration = useCallback(\n\t\t(duration: TSlotDuration) => {\n\t\t\tsetPreferences({ slotDuration: duration });\n\t\t},\n\t\t[setPreferences]\n\t);\n\n\tconst setShowWorkingHoursOnly = useCallback((_show: boolean) => {\n\t\t// This would need to be added to ICalendarPreferences\n\t\t// For now, this is a no-op but provides the API surface\n\t\tconsole.warn('showWorkingHoursOnly is not yet supported in core preferences');\n\t}, []);\n\n\treturn {\n\t\tvisibleHours,\n\t\tsetVisibleHours,\n\t\tworkingHours,\n\t\tsetWorkingHours,\n\t\tslotDuration: preferences.slotDuration as TSlotDuration,\n\t\tsetSlotDuration,\n\t\tshowWorkingHoursOnly: false, // Default until added to core preferences\n\t\tsetShowWorkingHoursOnly,\n\t};\n}\n","/**\n * usePreferences - Calendar Preferences Hook\n *\n * Manages user preferences with optional localStorage persistence.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { DEFAULT_PREFERENCES } from '../constants';\nimport type { ICalendarPreferences } from '../types';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UsePreferencesOptions {\n\t/** Initial preferences (overrides defaults) */\n\tinitial?: Partial<ICalendarPreferences>;\n\t/** Storage key for persistence (if provided, uses localStorage) */\n\tstorageKey?: string;\n\t/** Callback when preferences change */\n\tonChange?: (preferences: ICalendarPreferences) => void;\n}\n\nexport interface UsePreferencesReturn {\n\t/** Current preferences */\n\tpreferences: ICalendarPreferences;\n\t/** Update preferences */\n\tsetPreferences: (updates: Partial<ICalendarPreferences>) => void;\n\t/** Reset to defaults */\n\tresetPreferences: () => void;\n\t/** Get a specific preference */\n\tgetPreference: <K extends keyof ICalendarPreferences>(key: K) => ICalendarPreferences[K];\n}\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function usePreferences(options: UsePreferencesOptions = {}): UsePreferencesReturn {\n\tconst { initial = {}, storageKey, onChange } = options;\n\n\t// Load from storage or use defaults\n\tconst [preferences, setPreferencesState] = useState<ICalendarPreferences>(() => {\n\t\tif (storageKey && typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tconst stored = localStorage.getItem(storageKey);\n\t\t\t\tif (stored) {\n\t\t\t\t\tconst parsed = JSON.parse(stored) as Partial<ICalendarPreferences>;\n\t\t\t\t\treturn { ...DEFAULT_PREFERENCES, ...parsed, ...initial };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore parsing errors\n\t\t\t}\n\t\t}\n\t\treturn { ...DEFAULT_PREFERENCES, ...initial };\n\t});\n\n\t// Persist to storage when preferences change\n\tuseEffect(() => {\n\t\tif (storageKey && typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tlocalStorage.setItem(storageKey, JSON.stringify(preferences));\n\t\t\t} catch {\n\t\t\t\t// Ignore storage errors\n\t\t\t}\n\t\t}\n\t}, [preferences, storageKey]);\n\n\tconst setPreferences = useCallback(\n\t\t(updates: Partial<ICalendarPreferences>) => {\n\t\t\tsetPreferencesState((prev) => {\n\t\t\t\tconst next = { ...prev, ...updates };\n\t\t\t\tonChange?.(next);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\t[onChange]\n\t);\n\n\tconst resetPreferences = useCallback(() => {\n\t\tconst defaults = { ...DEFAULT_PREFERENCES, ...initial };\n\t\tsetPreferencesState(defaults);\n\t\tonChange?.(defaults);\n\t}, [initial, onChange]);\n\n\tconst getPreference = useCallback(\n\t\t<K extends keyof ICalendarPreferences>(key: K): ICalendarPreferences[K] => {\n\t\t\treturn preferences[key];\n\t\t},\n\t\t[preferences]\n\t);\n\n\treturn {\n\t\tpreferences,\n\t\tsetPreferences,\n\t\tresetPreferences,\n\t\tgetPreference,\n\t};\n}\n","/**\n * useSlotSelection - Drag-to-Select Hook\n *\n * Handles mouse/touch interactions for creating events by\n * selecting time slots in the calendar grid.\n */\n\nimport { useCallback, useRef, useState } from 'react';\nimport { DEFAULT_HOUR_HEIGHT } from '../constants';\nimport type { ISelectionResult, ISlotSelection, IVisibleHours } from '../types';\nimport { addMinutes } from '../utils/date-utils';\nimport { yToTime } from '../utils/position-utils';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\nexport interface UseSlotSelectionOptions {\n\t/** Current day being selected on */\n\tdayStart: Date;\n\t/** Visible hours configuration */\n\tvisibleHours: IVisibleHours;\n\t/** Height of one hour in pixels */\n\thourHeight?: number;\n\t/** Slot duration in minutes for snapping */\n\tslotDuration?: number;\n\t/** Resource ID (for resource views) */\n\tresourceId?: string;\n\t/** Whether selection is enabled */\n\tenabled?: boolean;\n\t/** Callback when selection completes */\n\tonSelect?: (selection: ISelectionResult) => void;\n}\n\nexport interface UseSlotSelectionReturn {\n\t/** Current selection state */\n\tselection: ISlotSelection;\n\t/** Selection overlay for rendering */\n\toverlay: { top: number; height: number; visible: boolean };\n\t/** Handler for mouse/touch down */\n\thandlePointerDown: (e: React.PointerEvent, containerRect: DOMRect) => void;\n\t/** Handler for mouse/touch move */\n\thandlePointerMove: (e: React.PointerEvent, containerRect: DOMRect) => void;\n\t/** Handler for mouse/touch up */\n\thandlePointerUp: () => void;\n\t/** Cancel current selection */\n\tcancel: () => void;\n\t/** Whether currently selecting */\n\tisSelecting: boolean;\n}\n\n// ============================================================================\n// INITIAL STATE\n// ============================================================================\n\nconst INITIAL_SELECTION: ISlotSelection = {\n\tisSelecting: false,\n\tstartDate: null,\n\tendDate: null,\n\tstartY: null,\n\tcurrentY: null,\n\tresourceId: undefined,\n};\n\n// ============================================================================\n// HOOK\n// ============================================================================\n\nexport function useSlotSelection(options: UseSlotSelectionOptions): UseSlotSelectionReturn {\n\tconst {\n\t\tdayStart,\n\t\tvisibleHours,\n\t\thourHeight = DEFAULT_HOUR_HEIGHT,\n\t\tslotDuration = 30,\n\t\tresourceId,\n\t\tenabled = true,\n\t\tonSelect,\n\t} = options;\n\n\tconst [selection, setSelection] = useState<ISlotSelection>(INITIAL_SELECTION);\n\tconst containerHeightRef = useRef<number>(0);\n\n\t// ========================================================================\n\t// HANDLERS\n\t// ========================================================================\n\n\tconst handlePointerDown = useCallback(\n\t\t(e: React.PointerEvent, containerRect: DOMRect) => {\n\t\t\tif (!enabled) return;\n\n\t\t\tconst y = e.clientY - containerRect.top;\n\t\t\tcontainerHeightRef.current = containerRect.height;\n\n\t\t\tconst startTime = yToTime(y, dayStart, visibleHours, hourHeight, slotDuration);\n\n\t\t\tsetSelection({\n\t\t\t\tisSelecting: true,\n\t\t\t\tstartDate: startTime,\n\t\t\t\tendDate: addMinutes(startTime, slotDuration),\n\t\t\t\tstartY: y,\n\t\t\t\tcurrentY: y,\n\t\t\t\tresourceId,\n\t\t\t});\n\t\t},\n\t\t[enabled, dayStart, visibleHours, hourHeight, slotDuration, resourceId]\n\t);\n\n\tconst handlePointerMove = useCallback(\n\t\t(e: React.PointerEvent, containerRect: DOMRect) => {\n\t\t\tif (!selection.isSelecting || !selection.startY) return;\n\n\t\t\tconst y = Math.max(0, Math.min(e.clientY - containerRect.top, containerRect.height));\n\t\t\tconst currentTime = yToTime(y, dayStart, visibleHours, hourHeight, slotDuration);\n\n\t\t\tsetSelection((prev) => {\n\t\t\t\tif (!prev.startDate) return prev;\n\n\t\t\t\t// Determine if dragging up or down\n\t\t\t\tconst isDraggingDown = y >= (prev.startY ?? 0);\n\n\t\t\t\treturn {\n\t\t\t\t\t...prev,\n\t\t\t\t\tcurrentY: y,\n\t\t\t\t\tendDate: isDraggingDown ? addMinutes(currentTime, slotDuration) : currentTime,\n\t\t\t\t\tstartDate: isDraggingDown ? prev.startDate : currentTime,\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\t[selection.isSelecting, selection.startY, dayStart, visibleHours, hourHeight, slotDuration]\n\t);\n\n\tconst handlePointerUp = useCallback(() => {\n\t\tif (!selection.isSelecting || !selection.startDate || !selection.endDate) {\n\t\t\tsetSelection(INITIAL_SELECTION);\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure start is before end\n\t\tconst start = selection.startDate < selection.endDate ? selection.startDate : selection.endDate;\n\t\tconst end = selection.startDate < selection.endDate ? selection.endDate : selection.startDate;\n\n\t\tconst result: ISelectionResult = {\n\t\t\tstartDate: start,\n\t\t\tendDate: end,\n\t\t\tresourceId: selection.resourceId,\n\t\t};\n\n\t\tonSelect?.(result);\n\t\tsetSelection(INITIAL_SELECTION);\n\t}, [selection, onSelect]);\n\n\tconst cancel = useCallback(() => {\n\t\tsetSelection(INITIAL_SELECTION);\n\t}, []);\n\n\t// ========================================================================\n\t// OVERLAY CALCULATION\n\t// ========================================================================\n\n\tconst overlay = (() => {\n\t\tif (!selection.isSelecting || selection.startY === null || selection.currentY === null) {\n\t\t\treturn { top: 0, height: 0, visible: false };\n\t\t}\n\n\t\tconst minY = Math.min(selection.startY, selection.currentY);\n\t\tconst maxY = Math.max(selection.startY, selection.currentY);\n\n\t\treturn {\n\t\t\ttop: minY,\n\t\t\theight: Math.max(maxY - minY, 20), // Minimum height\n\t\t\tvisible: true,\n\t\t};\n\t})();\n\n\t// ========================================================================\n\t// RETURN\n\t// ========================================================================\n\n\treturn {\n\t\tselection,\n\t\toverlay,\n\t\thandlePointerDown,\n\t\thandlePointerMove,\n\t\thandlePointerUp,\n\t\tcancel,\n\t\tisSelecting: selection.isSelecting,\n\t};\n}\n"],"names":["useCalendarTimeConfig","preferences","setPreferences","useCalendarContext","visibleHours","useMemo","workingHours","setVisibleHours","useCallback","hours","setWorkingHours","_hours","firstDay","setSlotDuration","duration","setShowWorkingHoursOnly","_show","usePreferences","options","initial","storageKey","onChange","setPreferencesState","useState","stored","parsed","DEFAULT_PREFERENCES","useEffect","updates","prev","next","resetPreferences","defaults","getPreference","key","INITIAL_SELECTION","useSlotSelection","dayStart","hourHeight","DEFAULT_HOUR_HEIGHT","slotDuration","resourceId","enabled","onSelect","selection","setSelection","containerHeightRef","useRef","handlePointerDown","e","containerRect","y","startTime","yToTime","addMinutes","handlePointerMove","currentTime","isDraggingDown","handlePointerUp","start","end","result","cancel","overlay","minY","maxY"],"mappings":";;;AAuEO,SAASA,IAAqD;AACpE,QAAM,EAAE,aAAAC,GAAa,gBAAAC,EAAA,IAAmBC,EAAA,GAGlCC,IAAeC;AAAA,IACpB,OAAO;AAAA,MACN,MAAMJ,EAAY;AAAA,MAClB,IAAIA,EAAY;AAAA,IAAA;AAAA,IAEjB,CAACA,EAAY,WAAWA,EAAY,OAAO;AAAA,EAAA,GAItCK,IAAeD;AAAA,IACpB,OAAO;AAAA;AAAA,MAEN,GAAG,EAAE,MAAMJ,EAAY,WAAW,IAAIA,EAAY,QAAA;AAAA,MAClD,GAAG,EAAE,MAAMA,EAAY,WAAW,IAAIA,EAAY,QAAA;AAAA,MAClD,GAAG,EAAE,MAAMA,EAAY,WAAW,IAAIA,EAAY,QAAA;AAAA,MAClD,GAAG,EAAE,MAAMA,EAAY,WAAW,IAAIA,EAAY,QAAA;AAAA,MAClD,GAAG,EAAE,MAAMA,EAAY,WAAW,IAAIA,EAAY,QAAA;AAAA,IAAQ;AAAA,IAE3D,CAACA,EAAY,WAAWA,EAAY,OAAO;AAAA,EAAA,GAGtCM,IAAkBC;AAAA,IACvB,CAACC,MAA+B;AAC/B,MAAAP,EAAe;AAAA,QACd,WAAWO,EAAM;AAAA,QACjB,SAASA,EAAM;AAAA,MAAA,CACf;AAAA,IACF;AAAA,IACA,CAACP,CAAc;AAAA,EAAA,GAGVQ,IAAkBF;AAAA,IACvB,CAACG,MAAgC;AAGhC,YAA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EiB,IAA2B;AAAA,MAChC,WAAWF;AAAA,MACX,SAASC;AAAA,MACT,YAAYhB,EAAU;AAAA,IAAA;AAGvB,IAAAD,IAAWkB,CAAM,GACjBhB,EAAaV,CAAiB;AAAA,EAC/B,GAAG,CAACS,GAAWD,CAAQ,CAAC,GAElBmB,IAAStD,EAAY,MAAM;AAChC,IAAAqC,EAAaV,CAAiB;AAAA,EAC/B,GAAG,CAAA,CAAE,GAMC4B,KAAW,MAAM;AACtB,QAAI,CAACnB,EAAU,eAAeA,EAAU,WAAW,QAAQA,EAAU,aAAa;AACjF,aAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAA;AAGtC,UAAMoB,IAAO,KAAK,IAAIpB,EAAU,QAAQA,EAAU,QAAQ,GACpDqB,IAAO,KAAK,IAAIrB,EAAU,QAAQA,EAAU,QAAQ;AAE1D,WAAO;AAAA,MACN,KAAKoB;AAAA,MACL,QAAQ,KAAK,IAAIC,IAAOD,GAAM,EAAE;AAAA;AAAA,MAChC,SAAS;AAAA,IAAA;AAAA,EAEX,GAAA;AAMA,SAAO;AAAA,IACN,WAAApB;AAAA,IACA,SAAAmB;AAAA,IACA,mBAAAf;AAAA,IACA,mBAAAO;AAAA,IACA,iBAAAG;AAAA,IACA,QAAAI;AAAA,IACA,aAAalB,EAAU;AAAA,EAAA;AAEzB;"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./position-utils-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./position-utils-ksZ_IjXC.cjs");exports.CALENDAR_VIEWS=e.CALENDAR_VIEWS;exports.CALENDAR_VIEW_STORAGE_KEY=e.CALENDAR_VIEW_STORAGE_KEY;exports.DEFAULT_BUSINESS_HOURS=e.DEFAULT_BUSINESS_HOURS;exports.DEFAULT_HEADER_HEIGHT=e.DEFAULT_HEADER_HEIGHT;exports.DEFAULT_HOUR_HEIGHT=e.DEFAULT_HOUR_HEIGHT;exports.DEFAULT_PREFERENCES=e.DEFAULT_PREFERENCES;exports.DEFAULT_RESOURCE_WIDTH=e.DEFAULT_RESOURCE_WIDTH;exports.DEFAULT_SLOT_HEIGHT=e.DEFAULT_SLOT_HEIGHT;exports.DEFAULT_VIEW_CONFIGS=e.DEFAULT_VIEW_CONFIGS;exports.DEFAULT_VISIBLE_HOURS=e.DEFAULT_VISIBLE_HOURS;exports.EVENT_COLORS=e.EVENT_COLORS;exports.EVENT_COLOR_CLASSES=e.EVENT_COLOR_CLASSES;exports.HEX_TO_EVENT_COLOR=e.HEX_TO_EVENT_COLOR;exports.HOURS_IN_DAY=e.HOURS_IN_DAY;exports.MINUTES_IN_HOUR=e.MINUTES_IN_HOUR;exports.MIN_EVENT_HEIGHT=e.MIN_EVENT_HEIGHT;exports.MS_PER_DAY=e.MS_PER_DAY;exports.MS_PER_HOUR=e.MS_PER_HOUR;exports.MS_PER_MINUTE=e.MS_PER_MINUTE;exports.RESOURCE_VIEW_STORAGE_KEY=e.RESOURCE_VIEW_STORAGE_KEY;exports.addDays=e.addDays;exports.addHours=e.addHours;exports.addMinutes=e.addMinutes;exports.addMonths=e.addMonths;exports.addWeeks=e.addWeeks;exports.addYears=e.addYears;exports.applyEventFilters=e.applyEventFilters;exports.calculateEventPosition=e.calculateEventPosition;exports.calculateOverlappingPositions=e.calculateOverlappingPositions;exports.calculateSelectionOverlay=e.calculateSelectionOverlay;exports.clearCalendarView=e.clearCalendarView;exports.clearResourceView=e.clearResourceView;exports.detectAllDayEvent=e.detectAllDayEvent;exports.differenceInDays=e.differenceInDays;exports.differenceInHours=e.differenceInHours;exports.differenceInMilliseconds=e.differenceInMilliseconds;exports.differenceInMinutes=e.differenceInMinutes;exports.eachDayOfInterval=e.eachDayOfInterval;exports.eachHourOfInterval=e.eachHourOfInterval;exports.endOfDay=e.endOfDay;exports.endOfMonth=e.endOfMonth;exports.endOfWeek=e.endOfWeek;exports.endOfYear=e.endOfYear;exports.eventsOverlap=e.eventsOverlap;exports.filterEventsByDateRange=e.filterEventsByDateRange;exports.filterEventsByResource=e.filterEventsByResource;exports.filterEventsByScheduleType=e.filterEventsByScheduleType;exports.filterEventsBySearch=e.filterEventsBySearch;exports.filterOutCanceled=e.filterOutCanceled;exports.formatDateISO=e.formatDateISO;exports.formatEventTimeDisplay=e.formatEventTimeDisplay;exports.formatHourLabel=e.formatHourLabel;exports.formatTime=e.formatTime;exports.generateHourLabels=e.generateHourLabels;exports.generateMonthCells=e.generateMonthCells;exports.generateMonthGrid=e.generateMonthGrid;exports.generateTimeSlots=e.generateTimeSlots;exports.generateWeekCells=e.generateWeekCells;exports.generateYearCells=e.generateYearCells;exports.getAllDayEvents=e.getAllDayEvents;exports.getDayOfWeek=e.getDayOfWeek;exports.getDaysInMonth=e.getDaysInMonth;exports.getDecimalHours=e.getDecimalHours;exports.getEventColor=e.getEventColor;exports.getEventDurationMinutes=e.getEventDurationMinutes;exports.getEventsCountInView=e.getEventsCountInView;exports.getEventsForDay=e.getEventsForDay;exports.getEventsInRange=e.getEventsInRange;exports.getMonthNames=e.getMonthNames;exports.getMultiDayEvents=e.getMultiDayEvents;exports.getOverlappingGroups=e.getOverlappingGroups;exports.getRangeText=e.getRangeText;exports.getTimedEvents=e.getTimedEvents;exports.getViewDateRange=e.getViewDateRange;exports.getViewTitle=e.getViewTitle;exports.getVisibleHoursArray=e.getVisibleHoursArray;exports.getWeekDays=e.getWeekDays;exports.getWeekNumber=e.getWeekNumber;exports.getWeekdayHeaders=e.getWeekdayHeaders;exports.getWeekdayNames=e.getWeekdayNames;exports.getWorkingHoursForDay=e.getWorkingHoursForDay;exports.getYearMonths=e.getYearMonths;exports.groupEventsByDate=e.groupEventsByDate;exports.groupEventsByResource=e.groupEventsByResource;exports.groupEventsByScheduleType=e.groupEventsByScheduleType;exports.isAfter=e.isAfter;exports.isBefore=e.isBefore;exports.isBetween=e.isBetween;exports.isCalendarGridView=e.isCalendarGridView;exports.isMultiDayEvent=e.isMultiDayEvent;exports.isResourceView=e.isResourceView;exports.isSameDay=e.isSameDay;exports.isSameMonth=e.isSameMonth;exports.isSameWeek=e.isSameWeek;exports.isSameYear=e.isSameYear;exports.isToday=e.isToday;exports.isWeekend=e.isWeekend;exports.isWorkingHour=e.isWorkingHour;exports.maxDate=e.maxDate;exports.minDate=e.minDate;exports.navigateNext=e.navigateNext;exports.navigatePrev=e.navigatePrev;exports.navigateToday=e.navigateToday;exports.parseISO=e.parseISO;exports.reactNodeToText=e.reactNodeToText;exports.readCalendarView=e.readCalendarView;exports.readPersistedView=e.readPersistedView;exports.readPreferencesView=e.readPreferencesView;exports.readResourceView=e.readResourceView;exports.resolveEventColor=e.resolveEventColor;exports.saveCalendarView=e.saveCalendarView;exports.saveResourceView=e.saveResourceView;exports.saveViewByFamily=e.saveViewByFamily;exports.separateEventsByDuration=e.separateEventsByDuration;exports.setTime=e.setTime;exports.shouldShowEventTime=e.shouldShowEventTime;exports.sortEventsByDuration=e.sortEventsByDuration;exports.sortEventsByEnd=e.sortEventsByEnd;exports.sortEventsByStart=e.sortEventsByStart;exports.startOfDay=e.startOfDay;exports.startOfMonth=e.startOfMonth;exports.startOfWeek=e.startOfWeek;exports.startOfYear=e.startOfYear;exports.subDays=e.subDays;exports.subMonths=e.subMonths;exports.subWeeks=e.subWeeks;exports.subYears=e.subYears;exports.timeToY=e.timeToY;exports.yToTime=e.yToTime;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as s, a as t, D as r, b as n, c as i, d as E, e as o, f as l, g as d, h as g, E as v, i as D, H as u, j as y, M as T, k as _, l as O, m as S, n as R, R as f, o as c, p as I, q as H, r as m, s as V, t as A, u as M, v as b, w as C, x as N, y as U, z as W, A as L, B as h, F as p, G as w, I as B, J as k, K as F, L as Y, N as G, O as P, Q as x, S as K, T as X, U as j, V as q, W as z, X as J, Y as Q, Z, _ as $, $ as aa, a0 as ea, a1 as sa, a2 as ta, a3 as ra, a4 as na, a5 as ia, a6 as Ea, a7 as oa, a8 as la, a9 as da, aa as ga, ab as va, ac as Da, ad as ua, ae as ya, af as Ta, ag as _a, ah as Oa, ai as Sa, aj as Ra, ak as fa, al as ca, am as Ia, an as Ha, ao as ma, ap as Va, aq as Aa, ar as Ma, as as ba, at as Ca, au as Na, av as Ua, aw as Wa, ax as La, ay as ha, az as pa, aA as wa, aB as Ba, aC as ka, aD as Fa, aE as Ya, aF as Ga, aG as Pa, aH as xa, aI as Ka, aJ as Xa, aK as ja, aL as qa, aM as za, aN as Ja, aO as Qa, aP as Za, aQ as $a, aR as ae, aS as ee, aT as se, aU as te, aV as re, aW as ne, aX as ie, aY as Ee, aZ as oe, a_ as le, a$ as de, b0 as ge, b1 as ve, b2 as De, b3 as ue, b4 as ye, b5 as Te, b6 as _e, b7 as Oe, b8 as Se, b9 as Re, ba as fe, bb as ce } from "./position-utils-
|
|
1
|
+
import { C as s, a as t, D as r, b as n, c as i, d as E, e as o, f as l, g as d, h as g, E as v, i as D, H as u, j as y, M as T, k as _, l as O, m as S, n as R, R as f, o as c, p as I, q as H, r as m, s as V, t as A, u as M, v as b, w as C, x as N, y as U, z as W, A as L, B as h, F as p, G as w, I as B, J as k, K as F, L as Y, N as G, O as P, Q as x, S as K, T as X, U as j, V as q, W as z, X as J, Y as Q, Z, _ as $, $ as aa, a0 as ea, a1 as sa, a2 as ta, a3 as ra, a4 as na, a5 as ia, a6 as Ea, a7 as oa, a8 as la, a9 as da, aa as ga, ab as va, ac as Da, ad as ua, ae as ya, af as Ta, ag as _a, ah as Oa, ai as Sa, aj as Ra, ak as fa, al as ca, am as Ia, an as Ha, ao as ma, ap as Va, aq as Aa, ar as Ma, as as ba, at as Ca, au as Na, av as Ua, aw as Wa, ax as La, ay as ha, az as pa, aA as wa, aB as Ba, aC as ka, aD as Fa, aE as Ya, aF as Ga, aG as Pa, aH as xa, aI as Ka, aJ as Xa, aK as ja, aL as qa, aM as za, aN as Ja, aO as Qa, aP as Za, aQ as $a, aR as ae, aS as ee, aT as se, aU as te, aV as re, aW as ne, aX as ie, aY as Ee, aZ as oe, a_ as le, a$ as de, b0 as ge, b1 as ve, b2 as De, b3 as ue, b4 as ye, b5 as Te, b6 as _e, b7 as Oe, b8 as Se, b9 as Re, ba as fe, bb as ce } from "./position-utils-D_KpwRus.js";
|
|
2
2
|
export {
|
|
3
3
|
s as CALENDAR_VIEWS,
|
|
4
4
|
t as CALENDAR_VIEW_STORAGE_KEY,
|