@mantine/schedule 9.5.0 → 9.5.1-alpha.0

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.
Files changed (43) hide show
  1. package/cjs/components/ResourcesMonthView/ResourcesMonthView.cjs +105 -35
  2. package/cjs/components/ResourcesMonthView/ResourcesMonthView.cjs.map +1 -1
  3. package/cjs/components/ResourcesMonthView/ResourcesMonthView.module.cjs +3 -1
  4. package/cjs/components/ResourcesMonthView/ResourcesMonthView.module.cjs.map +1 -1
  5. package/cjs/components/ResourcesSchedule/ResourcesSchedule.cjs +3 -0
  6. package/cjs/components/ResourcesSchedule/ResourcesSchedule.cjs.map +1 -1
  7. package/cjs/components/YearView/YearView.cjs +23 -4
  8. package/cjs/components/YearView/YearView.cjs.map +1 -1
  9. package/cjs/components/YearView/YearView.module.cjs.map +1 -1
  10. package/cjs/components/YearView/YearViewMonth.cjs +18 -6
  11. package/cjs/components/YearView/YearViewMonth.cjs.map +1 -1
  12. package/cjs/components/YearView/get-visible-week-days.cjs +24 -0
  13. package/cjs/components/YearView/get-visible-week-days.cjs.map +1 -0
  14. package/cjs/hooks/use-day-grid-event-resize.cjs +119 -0
  15. package/cjs/hooks/use-day-grid-event-resize.cjs.map +1 -0
  16. package/cjs/utils/calculate-month-resize-dates/calculate-month-resize-dates.cjs +39 -0
  17. package/cjs/utils/calculate-month-resize-dates/calculate-month-resize-dates.cjs.map +1 -0
  18. package/esm/components/ResourcesMonthView/ResourcesMonthView.mjs +106 -36
  19. package/esm/components/ResourcesMonthView/ResourcesMonthView.mjs.map +1 -1
  20. package/esm/components/ResourcesMonthView/ResourcesMonthView.module.mjs +3 -1
  21. package/esm/components/ResourcesMonthView/ResourcesMonthView.module.mjs.map +1 -1
  22. package/esm/components/ResourcesSchedule/ResourcesSchedule.mjs +3 -0
  23. package/esm/components/ResourcesSchedule/ResourcesSchedule.mjs.map +1 -1
  24. package/esm/components/YearView/YearView.mjs +23 -4
  25. package/esm/components/YearView/YearView.mjs.map +1 -1
  26. package/esm/components/YearView/YearView.module.mjs.map +1 -1
  27. package/esm/components/YearView/YearViewMonth.mjs +18 -6
  28. package/esm/components/YearView/YearViewMonth.mjs.map +1 -1
  29. package/esm/components/YearView/get-visible-week-days.mjs +21 -0
  30. package/esm/components/YearView/get-visible-week-days.mjs.map +1 -0
  31. package/esm/hooks/use-day-grid-event-resize.mjs +117 -0
  32. package/esm/hooks/use-day-grid-event-resize.mjs.map +1 -0
  33. package/esm/utils/calculate-month-resize-dates/calculate-month-resize-dates.mjs +37 -0
  34. package/esm/utils/calculate-month-resize-dates/calculate-month-resize-dates.mjs.map +1 -0
  35. package/lib/components/ResourcesMonthView/ResourcesMonthView.d.ts +12 -1
  36. package/lib/components/ResourcesSchedule/ResourcesSchedule.d.ts +1 -1
  37. package/lib/components/YearView/YearViewMonth.d.ts +3 -1
  38. package/lib/components/YearView/get-visible-week-days.d.ts +19 -0
  39. package/lib/hooks/use-day-grid-event-resize.d.ts +35 -0
  40. package/lib/utils/calculate-month-resize-dates/calculate-month-resize-dates.d.ts +17 -0
  41. package/package.json +4 -4
  42. package/styles.css +63 -2
  43. package/styles.layer.css +63 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ResourcesSchedule.cjs","names":["ResourcesDayView","ResourcesWeekView","ResourcesMonthView","Box","classes"],"sources":["../../../src/components/ResourcesSchedule/ResourcesSchedule.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n ElementProps,\n factory,\n Factory,\n MantineRadius,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { useUncontrolled } from '@mantine/hooks';\nimport { ScheduleLabelsOverride } from '../../labels';\nimport {\n DateStringValue,\n DateTimeStringValue,\n ScheduleEventData,\n ScheduleMode,\n ScheduleResourceData,\n ScheduleViewLevel,\n} from '../../types';\nimport {\n ResourcesDayView,\n ResourcesDayViewProps,\n ResourcesDayViewStylesNames,\n} from '../ResourcesDayView/ResourcesDayView';\nimport {\n ResourcesMonthView,\n ResourcesMonthViewProps,\n ResourcesMonthViewStylesNames,\n} from '../ResourcesMonthView/ResourcesMonthView';\nimport {\n ResourcesWeekView,\n ResourcesWeekViewProps,\n ResourcesWeekViewStylesNames,\n} from '../ResourcesWeekView/ResourcesWeekView';\nimport { RenderEventBody } from '../ScheduleEvent/ScheduleEvent';\nimport classes from './ResourcesSchedule.module.css';\n\nexport type ResourcesScheduleStylesNames =\n | 'root'\n | ResourcesDayViewStylesNames\n | ResourcesWeekViewStylesNames\n | ResourcesMonthViewStylesNames;\n\nexport type ResourcesScheduleViewLevel = 'day' | 'week' | 'month';\n\ntype ResourcesScheduleCommonProps =\n | 'date'\n | 'onDateChange'\n | 'resources'\n | 'events'\n | 'locale'\n | 'radius'\n | 'labels'\n | 'renderEventBody'\n | 'renderResourceLabel'\n | 'withEventsDragAndDrop'\n | 'onEventDrop'\n | 'canDragEvent'\n | 'onEventDragStart'\n | 'onEventDragEnd'\n | 'onTimeSlotClick'\n | 'onEventClick'\n | 'onDayClick'\n | 'withDragSlotSelect'\n | 'onSlotDragEnd'\n | 'view'\n | 'onViewChange'\n | 'mode'\n | 'onExternalEventDrop'\n | 'withEventResize'\n | 'onEventResize'\n | 'canResizeEvent'\n | 'recurrenceExpansionLimit';\n\ntype ResourcesScheduleViewProps<T> = Partial<Omit<T, ResourcesScheduleCommonProps>>;\n\nexport interface ResourcesScheduleProps\n extends BoxProps, StylesApiProps<ResourcesScheduleFactory>, ElementProps<'div'> {\n __staticSelector?: string;\n\n /** List of resources to display */\n resources: ScheduleResourceData[];\n\n /** Current date to display (controlled) */\n date?: Date | DateStringValue;\n\n /** Default date (uncontrolled) */\n defaultDate?: Date | DateStringValue;\n\n /** Called when date changes via navigation */\n onDateChange?: (date: DateStringValue) => void;\n\n /** Current view level (controlled) */\n view?: ResourcesScheduleViewLevel;\n\n /** Default view level (uncontrolled) @default 'day' */\n defaultView?: ResourcesScheduleViewLevel;\n\n /** Called when view level changes */\n onViewChange?: (view: ResourcesScheduleViewLevel) => void;\n\n /** Events to display across all views */\n events?: ScheduleEventData[];\n\n /** Locale for date formatting */\n locale?: string;\n\n /** Key of theme.radius or any valid CSS value to set border-radius */\n radius?: MantineRadius;\n\n /** Labels override for i18n */\n labels?: ScheduleLabelsOverride;\n\n /** Custom event body renderer */\n renderEventBody?: RenderEventBody;\n\n /** Custom resource label renderer */\n renderResourceLabel?: (resource: ScheduleResourceData) => React.ReactNode;\n\n /** Enable drag and drop for events @default false */\n withEventsDragAndDrop?: boolean;\n\n /** Called when event is dropped */\n onEventDrop?: (data: {\n eventId: string | number;\n newStart: DateTimeStringValue;\n newEnd: DateTimeStringValue;\n event: ScheduleEventData;\n resourceId?: string | number;\n }) => void;\n\n /** Function to determine if event can be dragged */\n canDragEvent?: (event: ScheduleEventData) => boolean;\n\n /** Called when any event drag starts */\n onEventDragStart?: (event: ScheduleEventData) => void;\n\n /** Called when any event drag ends */\n onEventDragEnd?: () => void;\n\n /** Called when time slot is clicked */\n onTimeSlotClick?: (data: {\n slotStart: DateTimeStringValue;\n slotEnd: DateTimeStringValue;\n nativeEvent: React.MouseEvent<HTMLButtonElement>;\n resourceId?: string | number;\n }) => void;\n\n /** Called when day is clicked in month view */\n onDayClick?: (data: {\n date: DateStringValue;\n nativeEvent: React.MouseEvent<HTMLButtonElement>;\n resourceId?: string | number;\n }) => void;\n\n /** Called when event is clicked */\n onEventClick?: (event: ScheduleEventData, e: React.MouseEvent<HTMLButtonElement>) => void;\n\n /** If set, enables drag-to-select slot ranges @default false */\n withDragSlotSelect?: boolean;\n\n /** Called when a slot range is selected by dragging */\n onSlotDragEnd?: (data: {\n rangeStart: DateTimeStringValue;\n rangeEnd: DateTimeStringValue;\n resourceId?: string | number;\n }) => void;\n\n /** Interaction mode @default default */\n mode?: ScheduleMode;\n\n /** Called when an external item is dropped onto the schedule */\n onExternalEventDrop?: (data: {\n dataTransfer: DataTransfer;\n dropDateTime: DateTimeStringValue;\n resourceId?: string | number;\n }) => void;\n\n /** If true, events can be resized @default false */\n withEventResize?: boolean;\n\n /** Called when event is resized */\n onEventResize?: (data: {\n eventId: string | number;\n newStart: DateTimeStringValue;\n newEnd: DateTimeStringValue;\n event: ScheduleEventData;\n }) => void;\n\n /** Function to determine if event can be resized */\n canResizeEvent?: (event: ScheduleEventData) => boolean;\n\n /** Max number of generated recurring instances @default 2000 */\n recurrenceExpansionLimit?: number;\n\n /** Props specific to ResourcesDayView */\n dayViewProps?: ResourcesScheduleViewProps<ResourcesDayViewProps>;\n\n /** Props specific to ResourcesWeekView */\n weekViewProps?: ResourcesScheduleViewProps<ResourcesWeekViewProps>;\n\n /** Props specific to ResourcesMonthView */\n monthViewProps?: ResourcesScheduleViewProps<ResourcesMonthViewProps>;\n}\n\nexport type ResourcesScheduleFactory = Factory<{\n props: ResourcesScheduleProps;\n ref: HTMLDivElement;\n stylesNames: ResourcesScheduleStylesNames;\n}>;\n\nconst defaultProps: Partial<ResourcesScheduleProps> = {\n defaultView: 'day',\n mode: 'default',\n};\n\nexport const ResourcesSchedule = factory<ResourcesScheduleFactory>((_props) => {\n const props = useProps('ResourcesSchedule', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n resources,\n date,\n defaultDate,\n onDateChange,\n view,\n defaultView,\n onViewChange,\n events,\n locale,\n radius,\n labels,\n renderEventBody,\n renderResourceLabel,\n withEventsDragAndDrop,\n onEventDrop,\n canDragEvent,\n onEventDragStart,\n onEventDragEnd,\n onTimeSlotClick,\n onDayClick,\n onEventClick,\n withDragSlotSelect,\n onSlotDragEnd,\n onExternalEventDrop,\n withEventResize,\n onEventResize,\n canResizeEvent,\n recurrenceExpansionLimit,\n mode,\n dayViewProps,\n weekViewProps,\n monthViewProps,\n __staticSelector,\n mod,\n ...others\n } = props;\n\n const getStyles = useStyles<ResourcesScheduleFactory>({\n name: __staticSelector || 'ResourcesSchedule',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n vars,\n });\n\n const [_view, _setView] = useUncontrolled<ResourcesScheduleViewLevel>({\n value: view,\n defaultValue: defaultView,\n onChange: onViewChange,\n });\n\n const [_date, _setDate] = useUncontrolled<Date | DateStringValue>({\n value: date,\n defaultValue: defaultDate ?? new Date(),\n });\n\n const handleDateChange = (newDate: DateStringValue) => {\n _setDate(newDate);\n onDateChange?.(newDate);\n };\n\n const handleViewChange = (newView: ScheduleViewLevel) => {\n if (newView === 'day' || newView === 'week' || newView === 'month') {\n _setView(newView);\n }\n };\n\n const commonProps = {\n resources,\n date: _date,\n onDateChange: handleDateChange,\n onViewChange: handleViewChange,\n events,\n locale,\n radius,\n labels,\n renderEventBody,\n renderResourceLabel,\n withEventsDragAndDrop: mode === 'static' ? false : withEventsDragAndDrop,\n onEventDrop,\n canDragEvent,\n onEventDragStart,\n onEventDragEnd,\n onEventClick,\n withDragSlotSelect,\n onSlotDragEnd,\n onExternalEventDrop,\n recurrenceExpansionLimit,\n mode,\n };\n\n const content = (() => {\n switch (_view) {\n case 'day':\n return (\n <ResourcesDayView\n {...commonProps}\n onTimeSlotClick={onTimeSlotClick}\n withEventResize={mode === 'static' ? false : withEventResize}\n onEventResize={onEventResize}\n canResizeEvent={canResizeEvent}\n {...dayViewProps}\n />\n );\n case 'week':\n return (\n <ResourcesWeekView\n {...commonProps}\n onTimeSlotClick={onTimeSlotClick}\n withEventResize={mode === 'static' ? false : withEventResize}\n onEventResize={onEventResize}\n canResizeEvent={canResizeEvent}\n {...weekViewProps}\n />\n );\n case 'month':\n return <ResourcesMonthView {...commonProps} onDayClick={onDayClick} {...monthViewProps} />;\n default:\n return null;\n }\n })();\n\n return (\n <Box {...getStyles('root')} mod={mod} {...others}>\n {content}\n </Box>\n );\n});\n\nResourcesSchedule.displayName = '@mantine/schedule/ResourcesSchedule';\nResourcesSchedule.classes = classes;\n\nexport namespace ResourcesSchedule {\n export type Props = ResourcesScheduleProps;\n export type StylesNames = ResourcesScheduleStylesNames;\n export type Factory = ResourcesScheduleFactory;\n export type ViewLevel = ResourcesScheduleViewLevel;\n}\n"],"mappings":";;;;;;;;;AAqNA,MAAM,eAAgD;CACpD,aAAa;CACb,MAAM;AACR;AAEA,MAAa,qBAAA,GAAA,cAAA,QAAA,EAAuD,WAAW;CAC7E,MAAM,SAAA,GAAA,cAAA,SAAA,CAAiB,qBAAqB,cAAc,MAAM;CAChE,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,WACA,MACA,aACA,cACA,MACA,aACA,cACA,QACA,QACA,QACA,QACA,iBACA,qBACA,uBACA,aACA,cACA,kBACA,gBACA,iBACA,YACA,cACA,oBACA,eACA,qBACA,iBACA,eACA,gBACA,0BACA,MACA,cACA,eACA,gBACA,kBACA,KACA,GAAG,WACD;CAEJ,MAAM,aAAA,GAAA,cAAA,UAAA,CAAgD;EACpD,MAAM,oBAAoB;EAC1B,SAAA,iCAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,CAAC,OAAO,aAAA,GAAA,eAAA,gBAAA,CAAwD;EACpE,OAAO;EACP,cAAc;EACd,UAAU;CACZ,CAAC;CAED,MAAM,CAAC,OAAO,aAAA,GAAA,eAAA,gBAAA,CAAoD;EAChE,OAAO;EACP,cAAc,+BAAe,IAAI,KAAK;CACxC,CAAC;CAED,MAAM,oBAAoB,YAA6B;EACrD,SAAS,OAAO;EAChB,eAAe,OAAO;CACxB;CAEA,MAAM,oBAAoB,YAA+B;EACvD,IAAI,YAAY,SAAS,YAAY,UAAU,YAAY,SACzD,SAAS,OAAO;CAEpB;CAEA,MAAM,cAAc;EAClB;EACA,MAAM;EACN,cAAc;EACd,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;EACA,uBAAuB,SAAS,WAAW,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,MAAM,iBAAiB;EACrB,QAAQ,OAAR;GACE,KAAK,OACH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,yBAAAA,kBAAD;IACE,GAAI;IACa;IACjB,iBAAiB,SAAS,WAAW,QAAQ;IAC9B;IACC;IAChB,GAAI;GACL,CAAA;GAEL,KAAK,QACH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,0BAAAA,mBAAD;IACE,GAAI;IACa;IACjB,iBAAiB,SAAS,WAAW,QAAQ;IAC9B;IACC;IAChB,GAAI;GACL,CAAA;GAEL,KAAK,SACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,2BAAAA,oBAAD;IAAoB,GAAI;IAAyB;IAAY,GAAI;GAAiB,CAAA;GAC3F,SACE,OAAO;EACX;CACF,EAAA,CAAG;CAEH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,KAAD;EAAK,GAAI,UAAU,MAAM;EAAQ;EAAK,GAAI;YACvC;CACE,CAAA;AAET,CAAC;AAED,kBAAkB,cAAc;AAChC,kBAAkB,UAAUC,iCAAAA"}
1
+ {"version":3,"file":"ResourcesSchedule.cjs","names":["ResourcesDayView","ResourcesWeekView","ResourcesMonthView","Box","classes"],"sources":["../../../src/components/ResourcesSchedule/ResourcesSchedule.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n ElementProps,\n factory,\n Factory,\n MantineRadius,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { useUncontrolled } from '@mantine/hooks';\nimport { ScheduleLabelsOverride } from '../../labels';\nimport {\n DateStringValue,\n DateTimeStringValue,\n ScheduleEventData,\n ScheduleMode,\n ScheduleResourceData,\n ScheduleViewLevel,\n} from '../../types';\nimport {\n ResourcesDayView,\n ResourcesDayViewProps,\n ResourcesDayViewStylesNames,\n} from '../ResourcesDayView/ResourcesDayView';\nimport {\n ResourcesMonthView,\n ResourcesMonthViewProps,\n ResourcesMonthViewStylesNames,\n} from '../ResourcesMonthView/ResourcesMonthView';\nimport {\n ResourcesWeekView,\n ResourcesWeekViewProps,\n ResourcesWeekViewStylesNames,\n} from '../ResourcesWeekView/ResourcesWeekView';\nimport { RenderEventBody } from '../ScheduleEvent/ScheduleEvent';\nimport classes from './ResourcesSchedule.module.css';\n\nexport type ResourcesScheduleStylesNames =\n | 'root'\n | ResourcesDayViewStylesNames\n | ResourcesWeekViewStylesNames\n | ResourcesMonthViewStylesNames;\n\nexport type ResourcesScheduleViewLevel = 'day' | 'week' | 'month';\n\ntype ResourcesScheduleCommonProps =\n | 'date'\n | 'onDateChange'\n | 'resources'\n | 'events'\n | 'locale'\n | 'radius'\n | 'labels'\n | 'renderEventBody'\n | 'renderResourceLabel'\n | 'withEventsDragAndDrop'\n | 'onEventDrop'\n | 'canDragEvent'\n | 'onEventDragStart'\n | 'onEventDragEnd'\n | 'onTimeSlotClick'\n | 'onEventClick'\n | 'onDayClick'\n | 'withDragSlotSelect'\n | 'onSlotDragEnd'\n | 'view'\n | 'onViewChange'\n | 'mode'\n | 'onExternalEventDrop'\n | 'withEventResize'\n | 'onEventResize'\n | 'canResizeEvent'\n | 'recurrenceExpansionLimit';\n\ntype ResourcesScheduleViewProps<T> = Partial<Omit<T, ResourcesScheduleCommonProps>>;\n\nexport interface ResourcesScheduleProps\n extends BoxProps, StylesApiProps<ResourcesScheduleFactory>, ElementProps<'div'> {\n __staticSelector?: string;\n\n /** List of resources to display */\n resources: ScheduleResourceData[];\n\n /** Current date to display (controlled) */\n date?: Date | DateStringValue;\n\n /** Default date (uncontrolled) */\n defaultDate?: Date | DateStringValue;\n\n /** Called when date changes via navigation */\n onDateChange?: (date: DateStringValue) => void;\n\n /** Current view level (controlled) */\n view?: ResourcesScheduleViewLevel;\n\n /** Default view level (uncontrolled) @default 'day' */\n defaultView?: ResourcesScheduleViewLevel;\n\n /** Called when view level changes */\n onViewChange?: (view: ResourcesScheduleViewLevel) => void;\n\n /** Events to display across all views */\n events?: ScheduleEventData[];\n\n /** Locale for date formatting */\n locale?: string;\n\n /** Key of theme.radius or any valid CSS value to set border-radius */\n radius?: MantineRadius;\n\n /** Labels override for i18n */\n labels?: ScheduleLabelsOverride;\n\n /** Custom event body renderer */\n renderEventBody?: RenderEventBody;\n\n /** Custom resource label renderer */\n renderResourceLabel?: (resource: ScheduleResourceData) => React.ReactNode;\n\n /** Enable drag and drop for events @default false */\n withEventsDragAndDrop?: boolean;\n\n /** Called when event is dropped */\n onEventDrop?: (data: {\n eventId: string | number;\n newStart: DateTimeStringValue;\n newEnd: DateTimeStringValue;\n event: ScheduleEventData;\n resourceId?: string | number;\n }) => void;\n\n /** Function to determine if event can be dragged */\n canDragEvent?: (event: ScheduleEventData) => boolean;\n\n /** Called when any event drag starts */\n onEventDragStart?: (event: ScheduleEventData) => void;\n\n /** Called when any event drag ends */\n onEventDragEnd?: () => void;\n\n /** Called when time slot is clicked */\n onTimeSlotClick?: (data: {\n slotStart: DateTimeStringValue;\n slotEnd: DateTimeStringValue;\n nativeEvent: React.MouseEvent<HTMLButtonElement>;\n resourceId?: string | number;\n }) => void;\n\n /** Called when day is clicked in month view */\n onDayClick?: (data: {\n date: DateStringValue;\n nativeEvent: React.MouseEvent<HTMLButtonElement>;\n resourceId?: string | number;\n }) => void;\n\n /** Called when event is clicked */\n onEventClick?: (event: ScheduleEventData, e: React.MouseEvent<HTMLButtonElement>) => void;\n\n /** If set, enables drag-to-select slot ranges @default false */\n withDragSlotSelect?: boolean;\n\n /** Called when a slot range is selected by dragging */\n onSlotDragEnd?: (data: {\n rangeStart: DateTimeStringValue;\n rangeEnd: DateTimeStringValue;\n resourceId?: string | number;\n }) => void;\n\n /** Interaction mode @default default */\n mode?: ScheduleMode;\n\n /** Called when an external item is dropped onto the schedule */\n onExternalEventDrop?: (data: {\n dataTransfer: DataTransfer;\n dropDateTime: DateTimeStringValue;\n resourceId?: string | number;\n }) => void;\n\n /** If true, events can be resized by dragging their edges, resizing snaps to whole days in month view @default false */\n withEventResize?: boolean;\n\n /** Called when event is resized */\n onEventResize?: (data: {\n eventId: string | number;\n newStart: DateTimeStringValue;\n newEnd: DateTimeStringValue;\n event: ScheduleEventData;\n }) => void;\n\n /** Function to determine if event can be resized */\n canResizeEvent?: (event: ScheduleEventData) => boolean;\n\n /** Max number of generated recurring instances @default 2000 */\n recurrenceExpansionLimit?: number;\n\n /** Props specific to ResourcesDayView */\n dayViewProps?: ResourcesScheduleViewProps<ResourcesDayViewProps>;\n\n /** Props specific to ResourcesWeekView */\n weekViewProps?: ResourcesScheduleViewProps<ResourcesWeekViewProps>;\n\n /** Props specific to ResourcesMonthView */\n monthViewProps?: ResourcesScheduleViewProps<ResourcesMonthViewProps>;\n}\n\nexport type ResourcesScheduleFactory = Factory<{\n props: ResourcesScheduleProps;\n ref: HTMLDivElement;\n stylesNames: ResourcesScheduleStylesNames;\n}>;\n\nconst defaultProps: Partial<ResourcesScheduleProps> = {\n defaultView: 'day',\n mode: 'default',\n};\n\nexport const ResourcesSchedule = factory<ResourcesScheduleFactory>((_props) => {\n const props = useProps('ResourcesSchedule', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n resources,\n date,\n defaultDate,\n onDateChange,\n view,\n defaultView,\n onViewChange,\n events,\n locale,\n radius,\n labels,\n renderEventBody,\n renderResourceLabel,\n withEventsDragAndDrop,\n onEventDrop,\n canDragEvent,\n onEventDragStart,\n onEventDragEnd,\n onTimeSlotClick,\n onDayClick,\n onEventClick,\n withDragSlotSelect,\n onSlotDragEnd,\n onExternalEventDrop,\n withEventResize,\n onEventResize,\n canResizeEvent,\n recurrenceExpansionLimit,\n mode,\n dayViewProps,\n weekViewProps,\n monthViewProps,\n __staticSelector,\n mod,\n ...others\n } = props;\n\n const getStyles = useStyles<ResourcesScheduleFactory>({\n name: __staticSelector || 'ResourcesSchedule',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n vars,\n });\n\n const [_view, _setView] = useUncontrolled<ResourcesScheduleViewLevel>({\n value: view,\n defaultValue: defaultView,\n onChange: onViewChange,\n });\n\n const [_date, _setDate] = useUncontrolled<Date | DateStringValue>({\n value: date,\n defaultValue: defaultDate ?? new Date(),\n });\n\n const handleDateChange = (newDate: DateStringValue) => {\n _setDate(newDate);\n onDateChange?.(newDate);\n };\n\n const handleViewChange = (newView: ScheduleViewLevel) => {\n if (newView === 'day' || newView === 'week' || newView === 'month') {\n _setView(newView);\n }\n };\n\n const commonProps = {\n resources,\n date: _date,\n onDateChange: handleDateChange,\n onViewChange: handleViewChange,\n events,\n locale,\n radius,\n labels,\n renderEventBody,\n renderResourceLabel,\n withEventsDragAndDrop: mode === 'static' ? false : withEventsDragAndDrop,\n onEventDrop,\n canDragEvent,\n onEventDragStart,\n onEventDragEnd,\n onEventClick,\n withDragSlotSelect,\n onSlotDragEnd,\n onExternalEventDrop,\n recurrenceExpansionLimit,\n mode,\n };\n\n const content = (() => {\n switch (_view) {\n case 'day':\n return (\n <ResourcesDayView\n {...commonProps}\n onTimeSlotClick={onTimeSlotClick}\n withEventResize={mode === 'static' ? false : withEventResize}\n onEventResize={onEventResize}\n canResizeEvent={canResizeEvent}\n {...dayViewProps}\n />\n );\n case 'week':\n return (\n <ResourcesWeekView\n {...commonProps}\n onTimeSlotClick={onTimeSlotClick}\n withEventResize={mode === 'static' ? false : withEventResize}\n onEventResize={onEventResize}\n canResizeEvent={canResizeEvent}\n {...weekViewProps}\n />\n );\n case 'month':\n return (\n <ResourcesMonthView\n {...commonProps}\n onDayClick={onDayClick}\n withEventResize={mode === 'static' ? false : withEventResize}\n onEventResize={onEventResize}\n canResizeEvent={canResizeEvent}\n {...monthViewProps}\n />\n );\n default:\n return null;\n }\n })();\n\n return (\n <Box {...getStyles('root')} mod={mod} {...others}>\n {content}\n </Box>\n );\n});\n\nResourcesSchedule.displayName = '@mantine/schedule/ResourcesSchedule';\nResourcesSchedule.classes = classes;\n\nexport namespace ResourcesSchedule {\n export type Props = ResourcesScheduleProps;\n export type StylesNames = ResourcesScheduleStylesNames;\n export type Factory = ResourcesScheduleFactory;\n export type ViewLevel = ResourcesScheduleViewLevel;\n}\n"],"mappings":";;;;;;;;;AAqNA,MAAM,eAAgD;CAC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AI;GACL,CAAA;GAEL,KAAK,QACH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,0BAAAA,mBAAD;IACE,GAAI;IACa;IACjB,iBAAiB,SAAS,WAAW,QAAQ;IAC9B;IACC;IAChB,GAAI;GACL,CAAA;GAEL,KAAK,SACH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,2BAAAA,oBAAD;IACE,GAAI;IACQ;IACZ,iBAAiB,SAAS,WAAW,QAAQ;IAC9B;IACC;IAChB,GAAI;GACL,CAAA;GAEL,SACE,OAAO;EACX;CACF,EAAA,CAAG;CAEH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,KAAD;EAAK,GAAI,UAAU,MAAM;EAAQ;EAAK,GAAI;YACvC;CACE,CAAA;AAET,CAAC;AAED,kBAAkB,cAAc;AAChC,kBAAkB,UAAUC,iCAAAA"}
@@ -6,6 +6,7 @@ const require_get_months_by_quarter = require("../../utils/get-months-by-quarter
6
6
  const require_to_date_string = require("../../utils/to-date-string/to-date-string.cjs");
7
7
  const require_expand_recurring_events = require("../../utils/expand-recurring-events/expand-recurring-events.cjs");
8
8
  const require_ScheduleHeaderBase = require("../ScheduleHeader/ScheduleHeaderBase.cjs");
9
+ const require_get_visible_week_days = require("./get-visible-week-days.cjs");
9
10
  const require_get_year_view_events = require("./get-year-view-events/get-year-view-events.cjs");
10
11
  const require_handle_year_view_key_down = require("./handle-year-view-key-down.cjs");
11
12
  const require_YearViewMonth = require("./YearViewMonth.cjs");
@@ -21,6 +22,7 @@ const defaultProps = {
21
22
  __staticSelector: "YearView",
22
23
  monthLabelFormat: "MMMM",
23
24
  withWeekDays: true,
25
+ withWeekendDays: true,
24
26
  highlightToday: true,
25
27
  withHeader: true,
26
28
  withOutsideDays: true,
@@ -29,7 +31,7 @@ const defaultProps = {
29
31
  const varsResolver = (0, _mantine_core.createVarsResolver)((_theme, { radius }) => ({ yearView: { "--year-view-radius": radius !== void 0 ? (0, _mantine_core.getRadius)(radius) : void 0 } }));
30
32
  const YearView = (0, _mantine_core.factory)((_props) => {
31
33
  const props = (0, _mantine_core.useProps)("YearView", defaultProps, _props);
32
- const { date, onDateChange, events, monthLabelFormat, withWeekNumbers, withWeekDays, locale, firstDayOfWeek, weekdayFormat, weekendDays, onMonthClick, onDayClick, onWeekNumberClick, getDayProps, getWeekNumberProps, highlightToday, labels, withOutsideDays, withHeader, monthYearSelectProps, onViewChange, previousControlProps, nextControlProps, todayControlProps, viewSelectProps, __staticSelector, classNames, className, style, styles, unstyled, vars, attributes, radius, mode, recurrenceExpansionLimit, ...others } = props;
34
+ const { date, onDateChange, events, monthLabelFormat, withWeekNumbers, withWeekDays, locale, firstDayOfWeek, weekdayFormat, weekendDays, withWeekendDays, onMonthClick, onDayClick, onWeekNumberClick, getDayProps, getWeekNumberProps, highlightToday, labels, withOutsideDays, withHeader, monthYearSelectProps, onViewChange, previousControlProps, nextControlProps, todayControlProps, viewSelectProps, __staticSelector, classNames, className, style, styles, unstyled, vars, attributes, radius, mode, recurrenceExpansionLimit, ...others } = props;
33
35
  const ctx = (0, _mantine_dates.useDatesContext)();
34
36
  const getStyles = (0, _mantine_core.useStyles)({
35
37
  name: __staticSelector,
@@ -67,14 +69,26 @@ const YearView = (0, _mantine_core.factory)((_props) => {
67
69
  })
68
70
  });
69
71
  const daysRef = (0, react.useRef)([]);
72
+ const resolvedFirstDayOfWeek = ctx.getFirstDayOfWeek(firstDayOfWeek);
73
+ const resolvedWeekendDays = ctx.getWeekendDays(weekendDays);
74
+ const hiddenColumns = require_get_visible_week_days.getHiddenWeekendColumns({
75
+ weekendDays: resolvedWeekendDays,
76
+ firstDayOfWeek: resolvedFirstDayOfWeek,
77
+ withWeekendDays
78
+ });
79
+ const columnsCount = 7 - hiddenColumns.length;
70
80
  const getFirstDayIndex = (month) => {
71
81
  const weeks = require_get_month_days.getMonthDays({
72
82
  month: (0, dayjs.default)(month).format("YYYY-MM-DD"),
73
- firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek),
83
+ firstDayOfWeek: resolvedFirstDayOfWeek,
74
84
  consistentWeeks: true
75
85
  });
76
86
  for (let weekIndex = 0; weekIndex < weeks.length; weekIndex++) {
77
- const week = weeks[weekIndex];
87
+ const week = require_get_visible_week_days.getVisibleWeekDays({
88
+ week: weeks[weekIndex],
89
+ weekendDays: resolvedWeekendDays,
90
+ withWeekendDays
91
+ });
78
92
  for (let dayIndex = 0; dayIndex < week.length; dayIndex++) {
79
93
  const dayDate = week[dayIndex];
80
94
  if (require_is_same_month.isSameMonth(dayDate, month)) return {
@@ -98,6 +112,7 @@ const YearView = (0, _mantine_core.factory)((_props) => {
98
112
  firstDayOfWeek,
99
113
  weekdayFormat: weekdayFormat || ((date) => (0, dayjs.default)(date).locale(ctx.getLocale(locale)).format("dd").slice(0, 1)),
100
114
  weekendDays,
115
+ withWeekendDays,
101
116
  getDayProps,
102
117
  getWeekNumberProps,
103
118
  onMonthClick,
@@ -126,7 +141,11 @@ const YearView = (0, _mantine_core.factory)((_props) => {
126
141
  });
127
142
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mantine_core.Box, {
128
143
  ...getStyles("yearView"),
129
- mod: { static: mode === "static" },
144
+ mod: {
145
+ static: mode === "static",
146
+ "without-weekend-days": hiddenColumns.length > 0
147
+ },
148
+ __vars: hiddenColumns.length > 0 ? { "--year-view-columns": `${columnsCount}` } : void 0,
130
149
  ...others,
131
150
  children: [withHeader && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ScheduleHeaderBase.ScheduleHeaderBase, {
132
151
  view: "year",
@@ -1 +1 @@
1
- {"version":3,"file":"YearView.cjs","names":["getYearViewEvents","expandRecurringEvents","getMonthDays","isSameMonth","getMonthsByQuarter","YearViewMonth","Box","ScheduleHeaderBase","toDateString","classes"],"sources":["../../../src/components/YearView/YearView.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport { useRef } from 'react';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n factory,\n Factory,\n getRadius,\n MantineRadius,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { useDatesContext } from '@mantine/dates';\nimport { DateStringValue, ScheduleEventData, ScheduleMode, ScheduleViewLevel } from '../../types';\nimport {\n expandRecurringEvents,\n getMonthDays,\n getMonthsByQuarter,\n isSameMonth,\n toDateString,\n} from '../../utils';\nimport { MonthYearSelectProps } from '../ScheduleHeader/MonthYearSelect/MonthYearSelect';\nimport { CombinedScheduleHeaderStylesNames } from '../ScheduleHeader/ScheduleHeader';\nimport { ScheduleHeaderBase } from '../ScheduleHeader/ScheduleHeaderBase';\nimport { ViewSelectProps } from '../ScheduleHeader/ViewSelect/ViewSelect';\nimport { getYearViewEvents } from './get-year-view-events/get-year-view-events';\nimport { handleYearViewKeyDown, YearViewControlsRef } from './handle-year-view-key-down';\nimport { YearViewMonth, YearViewMonthSettings } from './YearViewMonth';\nimport classes from './YearView.module.css';\n\nexport type YearViewStylesNames =\n | 'yearView'\n | 'yearViewMonths'\n | 'yearViewMonth'\n | 'yearViewWeekday'\n | 'yearViewDay'\n | 'yearViewWeek'\n | 'yearViewWeekNumber'\n | 'yearViewWeekdays'\n | 'yearViewWeekdaysCorner'\n | 'yearViewMonthCaption'\n | 'yearViewDayIndicators'\n | 'yearViewDayIndicator'\n | CombinedScheduleHeaderStylesNames;\n\nexport type YearViewCssVariables = {\n yearView: '--year-view-radius';\n};\n\nexport interface YearViewProps\n extends YearViewMonthSettings, BoxProps, StylesApiProps<YearViewFactory>, ElementProps<'div'> {\n __staticSelector?: string;\n\n /** Date to display, Date object or date string in `YYYY-MM-DD 00:00:00` format */\n date: Date | string;\n\n /** Called with the new date value when a date is selected */\n onDateChange?: (value: DateStringValue) => void;\n\n /** Events to display, must be a stable reference */\n events?: ScheduleEventData[];\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius` @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** If set, highlights the current day @default true */\n highlightToday?: boolean;\n\n /** If set, the header is displayed @default true */\n withHeader?: boolean;\n\n /** Props passed down to `MonthYearSelect` component in the header */\n monthYearSelectProps?: Partial<MonthYearSelectProps>;\n\n /** Called when view level select button is clicked */\n onViewChange?: (view: ScheduleViewLevel) => void;\n\n /** Props passed to previous month control */\n previousControlProps?: React.ComponentProps<'button'> & DataAttributes;\n\n /** Props passed to next month control */\n nextControlProps?: React.ComponentProps<'button'> & DataAttributes;\n\n /** Props passed to today control */\n todayControlProps?: React.ComponentProps<'button'> & DataAttributes;\n\n /** Props passed to view level select */\n viewSelectProps?: Partial<ViewSelectProps> & DataAttributes;\n\n /** Interaction mode: 'default' allows all interactions, 'static' disables event interactions @default default */\n mode?: ScheduleMode;\n\n /** Max number of generated recurring instances per recurring series @default 2000 */\n recurrenceExpansionLimit?: number;\n}\n\nexport type YearViewFactory = Factory<{\n props: YearViewProps;\n ref: HTMLDivElement;\n stylesNames: YearViewStylesNames;\n vars: YearViewCssVariables;\n}>;\n\nconst defaultProps = {\n __staticSelector: 'YearView',\n monthLabelFormat: 'MMMM',\n withWeekDays: true,\n highlightToday: true,\n withHeader: true,\n withOutsideDays: true,\n mode: 'default',\n} satisfies Partial<YearViewProps>;\n\nconst varsResolver = createVarsResolver<YearViewFactory>((_theme, { radius }) => ({\n yearView: { '--year-view-radius': radius !== undefined ? getRadius(radius) : undefined },\n}));\n\nexport const YearView = factory<YearViewFactory>((_props) => {\n const props = useProps('YearView', defaultProps, _props);\n const {\n // YearView props\n date,\n onDateChange,\n events,\n\n // YearViewMonth settings\n monthLabelFormat,\n withWeekNumbers,\n withWeekDays,\n locale,\n firstDayOfWeek,\n weekdayFormat,\n weekendDays,\n onMonthClick,\n onDayClick,\n onWeekNumberClick,\n getDayProps,\n getWeekNumberProps,\n highlightToday,\n labels,\n withOutsideDays,\n\n // ScheduleHeader props\n withHeader,\n monthYearSelectProps,\n onViewChange,\n previousControlProps,\n nextControlProps,\n todayControlProps,\n viewSelectProps,\n\n // System props\n __staticSelector,\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n attributes,\n radius,\n mode,\n recurrenceExpansionLimit,\n ...others\n } = props;\n\n const ctx = useDatesContext();\n\n const getStyles = useStyles<YearViewFactory>({\n name: __staticSelector,\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n vars,\n varsResolver,\n attributes,\n rootSelector: 'yearView',\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<YearViewFactory>({\n classNames,\n styles,\n props,\n });\n\n const stylesApiProps = {\n classNames: resolvedClassNames,\n styles: resolvedStyles,\n attributes,\n __staticSelector,\n radius,\n };\n\n const expandedEvents = expandRecurringEvents({\n events,\n rangeStart: dayjs(date).startOf('year').toDate(),\n rangeEnd: dayjs(date).endOf('year').toDate(),\n expansionLimit: recurrenceExpansionLimit,\n });\n\n const groupedEvents = getYearViewEvents({ date, events: expandedEvents });\n\n // [monthIndex][weekIndex][dayIndex]\n const daysRef = useRef<HTMLButtonElement[][][]>([]) as YearViewControlsRef;\n\n const getFirstDayIndex = (month: string): { weekIndex: number; dayIndex: number } | undefined => {\n const weeks = getMonthDays({\n month: dayjs(month).format('YYYY-MM-DD'),\n firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek),\n consistentWeeks: true,\n });\n\n for (let weekIndex = 0; weekIndex < weeks.length; weekIndex++) {\n const week = weeks[weekIndex];\n for (let dayIndex = 0; dayIndex < week.length; dayIndex++) {\n const dayDate = week[dayIndex];\n if (isSameMonth(dayDate, month)) {\n return { weekIndex, dayIndex };\n }\n }\n }\n\n return undefined;\n };\n\n let globalMonthIndex = 0;\n const months = getMonthsByQuarter(dayjs(date).format('YYYY-MM-DD'))\n .flat()\n .map((month) => {\n const currentMonthIndex = globalMonthIndex;\n globalMonthIndex++;\n\n return (\n <YearViewMonth\n key={month}\n month={month}\n getStyles={getStyles}\n monthLabelFormat={monthLabelFormat}\n withWeekNumbers={withWeekNumbers}\n withWeekDays={withWeekDays}\n locale={locale}\n firstDayOfWeek={firstDayOfWeek}\n weekdayFormat={\n weekdayFormat ||\n ((date) => dayjs(date).locale(ctx.getLocale(locale)).format('dd').slice(0, 1))\n }\n weekendDays={weekendDays}\n getDayProps={getDayProps}\n getWeekNumberProps={getWeekNumberProps}\n onMonthClick={onMonthClick}\n onDayClick={onDayClick}\n onWeekNumberClick={onWeekNumberClick}\n highlightToday={highlightToday}\n groupedEvents={groupedEvents}\n mode={mode}\n withOutsideDays={withOutsideDays}\n firstDayIndex={getFirstDayIndex(month)}\n __getDayRef={(weekIndex, dayIndex, node) => {\n if (!Array.isArray(daysRef.current[currentMonthIndex])) {\n daysRef.current[currentMonthIndex] = [];\n }\n if (!Array.isArray(daysRef.current[currentMonthIndex][weekIndex])) {\n daysRef.current[currentMonthIndex][weekIndex] = [];\n }\n daysRef.current[currentMonthIndex][weekIndex][dayIndex] = node;\n }}\n __onDayKeyDown={(event, payload) => {\n handleYearViewKeyDown({\n controlsRef: daysRef,\n monthIndex: currentMonthIndex,\n weekIndex: payload.weekIndex,\n dayIndex: payload.dayIndex,\n event,\n });\n }}\n />\n );\n });\n\n return (\n <Box {...getStyles('yearView')} mod={{ static: mode === 'static' }} {...others}>\n {withHeader && (\n <ScheduleHeaderBase\n view=\"year\"\n navigationHandlers={{\n previous: () => toDateString(dayjs(date).subtract(1, 'year').startOf('year')),\n next: () => toDateString(dayjs(date).add(1, 'year').startOf('year')),\n today: () => toDateString(dayjs()),\n }}\n control={{\n monthYearSelect: {\n locale,\n withMonths: false,\n yearValue: dayjs(date).get('year'),\n monthValue: dayjs(date).get('month'),\n onYearChange: (year) =>\n onDateChange?.(toDateString(dayjs(date).set('year', year).startOf('year'))),\n ...monthYearSelectProps,\n },\n }}\n labels={labels}\n onDateChange={onDateChange}\n onViewChange={onViewChange}\n previousControlProps={previousControlProps}\n nextControlProps={nextControlProps}\n todayControlProps={todayControlProps}\n viewSelectProps={viewSelectProps}\n stylesApiProps={stylesApiProps}\n />\n )}\n\n <div {...getStyles('yearViewMonths')}>{months}</div>\n </Box>\n );\n});\n\nYearView.displayName = '@mantine/schedule/YearView';\nYearView.classes = classes;\nYearView.varsResolver = varsResolver;\n\nexport namespace YearView {\n export type Props = YearViewProps;\n export type Factory = YearViewFactory;\n export type StylesNames = YearViewStylesNames;\n export type CssVariables = YearViewCssVariables;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4GA,MAAM,eAAe;CACnB,kBAAkB;CAClB,kBAAkB;CAClB,cAAc;CACd,gBAAgB;CAChB,YAAY;CACZ,iBAAiB;CACjB,MAAM;AACR;AAEA,MAAM,gBAAA,GAAA,cAAA,mBAAA,EAAoD,QAAQ,EAAE,cAAc,EAChF,UAAU,EAAE,sBAAsB,WAAW,KAAA,KAAA,GAAA,cAAA,UAAA,CAAsB,MAAM,IAAI,KAAA,EAAU,EACzF,EAAE;AAEF,MAAa,YAAA,GAAA,cAAA,QAAA,EAAqC,WAAW;CAC3D,MAAM,SAAA,GAAA,cAAA,SAAA,CAAiB,YAAY,cAAc,MAAM;CACvD,MAAM,EAEJ,MACA,cACA,QAGA,kBACA,iBACA,cACA,QACA,gBACA,eACA,aACA,cACA,YACA,mBACA,aACA,oBACA,gBACA,QACA,iBAGA,YACA,sBACA,cACA,sBACA,kBACA,mBACA,iBAGA,kBACA,YACA,WACA,OACA,QACA,UACA,MACA,YACA,QACA,MACA,0BACA,GAAG,WACD;CAEJ,MAAM,OAAA,GAAA,eAAA,gBAAA,CAAsB;CAE5B,MAAM,aAAA,GAAA,cAAA,UAAA,CAAuC;EAC3C,MAAM;EACN,SAAA,wBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;CAChB,CAAC;CAED,MAAM,EAAE,oBAAoB,oBAAA,GAAA,cAAA,qBAAA,CAAyD;EACnF;EACA;EACA;CACF,CAAC;CAED,MAAM,iBAAiB;EACrB,YAAY;EACZ,QAAQ;EACR;EACA;EACA;CACF;CASA,MAAM,gBAAgBA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ACb,eAAeA,uBAAAA,cAAAA,GAAAA,MAAAA,QAAAA,CAAmB,IAAI,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC,QAAQ,MAAM,CAAC,CAAC;IAC5E,GAAG;GACL,EACF;GACQ;GACM;GACA;GACQ;GACJ;GACC;GACF;GACD;EACjB,CAAA,GAGH,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,GAAI,UAAU,gBAAgB;aAAI;EAAY,CAAA,CAChD;;AAET,CAAC;AAED,SAAS,cAAc;AACvB,SAAS,UAAUC,wBAAAA;AACnB,SAAS,eAAe"}
1
+ {"version":3,"file":"YearView.cjs","names":["getYearViewEvents","expandRecurringEvents","getHiddenWeekendColumns","getMonthDays","getVisibleWeekDays","isSameMonth","getMonthsByQuarter","YearViewMonth","Box","ScheduleHeaderBase","toDateString","classes"],"sources":["../../../src/components/YearView/YearView.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport { useRef } from 'react';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n factory,\n Factory,\n getRadius,\n MantineRadius,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { useDatesContext } from '@mantine/dates';\nimport { DateStringValue, ScheduleEventData, ScheduleMode, ScheduleViewLevel } from '../../types';\nimport {\n expandRecurringEvents,\n getMonthDays,\n getMonthsByQuarter,\n isSameMonth,\n toDateString,\n} from '../../utils';\nimport { MonthYearSelectProps } from '../ScheduleHeader/MonthYearSelect/MonthYearSelect';\nimport { CombinedScheduleHeaderStylesNames } from '../ScheduleHeader/ScheduleHeader';\nimport { ScheduleHeaderBase } from '../ScheduleHeader/ScheduleHeaderBase';\nimport { ViewSelectProps } from '../ScheduleHeader/ViewSelect/ViewSelect';\nimport { getHiddenWeekendColumns, getVisibleWeekDays } from './get-visible-week-days';\nimport { getYearViewEvents } from './get-year-view-events/get-year-view-events';\nimport { handleYearViewKeyDown, YearViewControlsRef } from './handle-year-view-key-down';\nimport { YearViewMonth, YearViewMonthSettings } from './YearViewMonth';\nimport classes from './YearView.module.css';\n\nexport type YearViewStylesNames =\n | 'yearView'\n | 'yearViewMonths'\n | 'yearViewMonth'\n | 'yearViewWeekday'\n | 'yearViewDay'\n | 'yearViewWeek'\n | 'yearViewWeekNumber'\n | 'yearViewWeekdays'\n | 'yearViewWeekdaysCorner'\n | 'yearViewMonthCaption'\n | 'yearViewDayIndicators'\n | 'yearViewDayIndicator'\n | CombinedScheduleHeaderStylesNames;\n\nexport type YearViewCssVariables = {\n yearView: '--year-view-radius';\n};\n\nexport interface YearViewProps\n extends YearViewMonthSettings, BoxProps, StylesApiProps<YearViewFactory>, ElementProps<'div'> {\n __staticSelector?: string;\n\n /** Date to display, Date object or date string in `YYYY-MM-DD 00:00:00` format */\n date: Date | string;\n\n /** Called with the new date value when a date is selected */\n onDateChange?: (value: DateStringValue) => void;\n\n /** Events to display, must be a stable reference */\n events?: ScheduleEventData[];\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius` @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** If set, highlights the current day @default true */\n highlightToday?: boolean;\n\n /** If set, the header is displayed @default true */\n withHeader?: boolean;\n\n /** Props passed down to `MonthYearSelect` component in the header */\n monthYearSelectProps?: Partial<MonthYearSelectProps>;\n\n /** Called when view level select button is clicked */\n onViewChange?: (view: ScheduleViewLevel) => void;\n\n /** Props passed to previous month control */\n previousControlProps?: React.ComponentProps<'button'> & DataAttributes;\n\n /** Props passed to next month control */\n nextControlProps?: React.ComponentProps<'button'> & DataAttributes;\n\n /** Props passed to today control */\n todayControlProps?: React.ComponentProps<'button'> & DataAttributes;\n\n /** Props passed to view level select */\n viewSelectProps?: Partial<ViewSelectProps> & DataAttributes;\n\n /** Interaction mode: 'default' allows all interactions, 'static' disables event interactions @default default */\n mode?: ScheduleMode;\n\n /** Max number of generated recurring instances per recurring series @default 2000 */\n recurrenceExpansionLimit?: number;\n}\n\nexport type YearViewFactory = Factory<{\n props: YearViewProps;\n ref: HTMLDivElement;\n stylesNames: YearViewStylesNames;\n vars: YearViewCssVariables;\n}>;\n\nconst defaultProps = {\n __staticSelector: 'YearView',\n monthLabelFormat: 'MMMM',\n withWeekDays: true,\n withWeekendDays: true,\n highlightToday: true,\n withHeader: true,\n withOutsideDays: true,\n mode: 'default',\n} satisfies Partial<YearViewProps>;\n\nconst varsResolver = createVarsResolver<YearViewFactory>((_theme, { radius }) => ({\n yearView: { '--year-view-radius': radius !== undefined ? getRadius(radius) : undefined },\n}));\n\nexport const YearView = factory<YearViewFactory>((_props) => {\n const props = useProps('YearView', defaultProps, _props);\n const {\n // YearView props\n date,\n onDateChange,\n events,\n\n // YearViewMonth settings\n monthLabelFormat,\n withWeekNumbers,\n withWeekDays,\n locale,\n firstDayOfWeek,\n weekdayFormat,\n weekendDays,\n withWeekendDays,\n onMonthClick,\n onDayClick,\n onWeekNumberClick,\n getDayProps,\n getWeekNumberProps,\n highlightToday,\n labels,\n withOutsideDays,\n\n // ScheduleHeader props\n withHeader,\n monthYearSelectProps,\n onViewChange,\n previousControlProps,\n nextControlProps,\n todayControlProps,\n viewSelectProps,\n\n // System props\n __staticSelector,\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n attributes,\n radius,\n mode,\n recurrenceExpansionLimit,\n ...others\n } = props;\n\n const ctx = useDatesContext();\n\n const getStyles = useStyles<YearViewFactory>({\n name: __staticSelector,\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n vars,\n varsResolver,\n attributes,\n rootSelector: 'yearView',\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<YearViewFactory>({\n classNames,\n styles,\n props,\n });\n\n const stylesApiProps = {\n classNames: resolvedClassNames,\n styles: resolvedStyles,\n attributes,\n __staticSelector,\n radius,\n };\n\n const expandedEvents = expandRecurringEvents({\n events,\n rangeStart: dayjs(date).startOf('year').toDate(),\n rangeEnd: dayjs(date).endOf('year').toDate(),\n expansionLimit: recurrenceExpansionLimit,\n });\n\n const groupedEvents = getYearViewEvents({ date, events: expandedEvents });\n\n // [monthIndex][weekIndex][dayIndex]\n const daysRef = useRef<HTMLButtonElement[][][]>([]) as YearViewControlsRef;\n\n const resolvedFirstDayOfWeek = ctx.getFirstDayOfWeek(firstDayOfWeek);\n const resolvedWeekendDays = ctx.getWeekendDays(weekendDays);\n const hiddenColumns = getHiddenWeekendColumns({\n weekendDays: resolvedWeekendDays,\n firstDayOfWeek: resolvedFirstDayOfWeek,\n withWeekendDays,\n });\n const columnsCount = 7 - hiddenColumns.length;\n\n const getFirstDayIndex = (month: string): { weekIndex: number; dayIndex: number } | undefined => {\n const weeks = getMonthDays({\n month: dayjs(month).format('YYYY-MM-DD'),\n firstDayOfWeek: resolvedFirstDayOfWeek,\n consistentWeeks: true,\n });\n\n for (let weekIndex = 0; weekIndex < weeks.length; weekIndex++) {\n const week = getVisibleWeekDays({\n week: weeks[weekIndex],\n weekendDays: resolvedWeekendDays,\n withWeekendDays,\n });\n\n for (let dayIndex = 0; dayIndex < week.length; dayIndex++) {\n const dayDate = week[dayIndex];\n if (isSameMonth(dayDate, month)) {\n return { weekIndex, dayIndex };\n }\n }\n }\n\n return undefined;\n };\n\n let globalMonthIndex = 0;\n const months = getMonthsByQuarter(dayjs(date).format('YYYY-MM-DD'))\n .flat()\n .map((month) => {\n const currentMonthIndex = globalMonthIndex;\n globalMonthIndex++;\n\n return (\n <YearViewMonth\n key={month}\n month={month}\n getStyles={getStyles}\n monthLabelFormat={monthLabelFormat}\n withWeekNumbers={withWeekNumbers}\n withWeekDays={withWeekDays}\n locale={locale}\n firstDayOfWeek={firstDayOfWeek}\n weekdayFormat={\n weekdayFormat ||\n ((date) => dayjs(date).locale(ctx.getLocale(locale)).format('dd').slice(0, 1))\n }\n weekendDays={weekendDays}\n withWeekendDays={withWeekendDays}\n getDayProps={getDayProps}\n getWeekNumberProps={getWeekNumberProps}\n onMonthClick={onMonthClick}\n onDayClick={onDayClick}\n onWeekNumberClick={onWeekNumberClick}\n highlightToday={highlightToday}\n groupedEvents={groupedEvents}\n mode={mode}\n withOutsideDays={withOutsideDays}\n firstDayIndex={getFirstDayIndex(month)}\n __getDayRef={(weekIndex, dayIndex, node) => {\n if (!Array.isArray(daysRef.current[currentMonthIndex])) {\n daysRef.current[currentMonthIndex] = [];\n }\n if (!Array.isArray(daysRef.current[currentMonthIndex][weekIndex])) {\n daysRef.current[currentMonthIndex][weekIndex] = [];\n }\n daysRef.current[currentMonthIndex][weekIndex][dayIndex] = node;\n }}\n __onDayKeyDown={(event, payload) => {\n handleYearViewKeyDown({\n controlsRef: daysRef,\n monthIndex: currentMonthIndex,\n weekIndex: payload.weekIndex,\n dayIndex: payload.dayIndex,\n event,\n });\n }}\n />\n );\n });\n\n return (\n <Box\n {...getStyles('yearView')}\n mod={{ static: mode === 'static', 'without-weekend-days': hiddenColumns.length > 0 }}\n __vars={hiddenColumns.length > 0 ? { '--year-view-columns': `${columnsCount}` } : undefined}\n {...others}\n >\n {withHeader && (\n <ScheduleHeaderBase\n view=\"year\"\n navigationHandlers={{\n previous: () => toDateString(dayjs(date).subtract(1, 'year').startOf('year')),\n next: () => toDateString(dayjs(date).add(1, 'year').startOf('year')),\n today: () => toDateString(dayjs()),\n }}\n control={{\n monthYearSelect: {\n locale,\n withMonths: false,\n yearValue: dayjs(date).get('year'),\n monthValue: dayjs(date).get('month'),\n onYearChange: (year) =>\n onDateChange?.(toDateString(dayjs(date).set('year', year).startOf('year'))),\n ...monthYearSelectProps,\n },\n }}\n labels={labels}\n onDateChange={onDateChange}\n onViewChange={onViewChange}\n previousControlProps={previousControlProps}\n nextControlProps={nextControlProps}\n todayControlProps={todayControlProps}\n viewSelectProps={viewSelectProps}\n stylesApiProps={stylesApiProps}\n />\n )}\n\n <div {...getStyles('yearViewMonths')}>{months}</div>\n </Box>\n );\n});\n\nYearView.displayName = '@mantine/schedule/YearView';\nYearView.classes = classes;\nYearView.varsResolver = varsResolver;\n\nexport namespace YearView {\n export type Props = YearViewProps;\n export type Factory = YearViewFactory;\n export type StylesNames = YearViewStylesNames;\n export type CssVariables = YearViewCssVariables;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6GA,MAAM,eAAe;CACnB,kBAAkB;CAClB,kBAAkB;CAClB,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,YAAY;CACZ,iBAAiB;CACjB,MAAM;AACR;AAEA,MAAM,gBAAA,GAAA,cAAA,mBAAA,EAAoD,QAAQ,EAAE,cAAc,EAChF,UAAU,EAAE,sBAAsB,WAAW,KAAA,KAAA,GAAA,cAAA,UAAA,CAAsB,MAAM,IAAI,KAAA,EAAU,EACzF,EAAE;AAEF,MAAa,YAAA,GAAA,cAAA,QAAA,EAAqC,WAAW;CAC3D,MAAM,SAAA,GAAA,cAAA,SAAA,CAAiB,YAAY,cAAc,MAAM;CACvD,MAAM,EAEJ,MACA,cACA,QAGA,kBACA,iBACA,cACA,QACA,gBACA,eACA,aACA,iBACA,cACA,YACA,mBACA,aACA,oBACA,gBACA,QACA,iBAGA,YACA,sBACA,cACA,sBACA,kBACA,mBACA,iBAGA,kBACA,YACA,WACA,OACA,QACA,UACA,MACA,YACA,QACA,MACA,0BACA,GAAG,WACD;CAEJ,MAAM,OAAA,GAAA,eAAA,gBAAA,CAAsB;CAE5B,MAAM,aAAA,GAAA,cAAA,UAAA,CAAuC;EAC3C,MAAM;EACN,SAAA,wBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;CAChB,CAAC;CAED,MAAM,EAAE,oBAAoB,oBAAA,GAAA,cAAA,qBAAA,CAAyD;EACnF;EACA;EACA;CACF,CAAC;CAED,MAAM,iBAAiB;EACrB,YAAY;EACZ,QAAQ;EACR;EACA;EACA;CACF;CASA,MAAM,gBAAgBA,6BAAAA,kBAAkB;EAAE;EAAM,QAPzBC,gCAAAA,sBAAsB;GAC3C;GACA,aAAA,GAAA,MAAA,QAAA,CAAkB,IAAI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AAAA,MAAAA,QAAAA,CAAmB,CAAC;GACnC;GACA,SAAS,EACP,iBAAiB;IACf;IACA,YAAY;IACZ,YAAA,GAAA,MAAA,QAAA,CAAiB,IAAI,CAAC,CAAC,IAAI,MAAM;IACjC,aAAA,GAAA,MAAA,QAAA,CAAkB,IAAI,CAAC,CAAC,IAAI,OAAO;IACnC,eAAe,SACb,eAAeA,uBAAAA,cAAAA,GAAAA,MAAAA,QAAAA,CAAmB,IAAI,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC,QAAQ,MAAM,CAAC,CAAC;IAC5E,GAAG;GACL,EACF;GACQ;GACM;GACA;GACQ;GACJ;GACC;GACF;GACD;EACjB,CAAA,GAGH,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,GAAI,UAAU,gBAAgB;aAAI;EAAY,CAAA,CAChD;;AAET,CAAC;AAED,SAAS,cAAc;AACvB,SAAS,UAAUC,wBAAAA;AACnB,SAAS,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"YearView.module.cjs","names":[],"sources":["../../../src/components/YearView/YearView.module.css"],"sourcesContent":[".yearView {\n --year-view-radius: var(--schedule-radius, var(--mantine-radius-default));\n --year-view-font-size: var(--mantine-font-size-sm);\n container-type: inline-size;\n\n @mixin where-light {\n --year-view-border-color: var(--mantine-color-gray-3);\n }\n\n @mixin where-dark {\n --year-view-border-color: var(--mantine-color-dark-4);\n }\n}\n\n.yearViewMonths {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n\n @container (width <= 850px) {\n --year-view-font-size: calc(var(--mantine-font-size-sm) - 2px);\n }\n\n @container (width <= 750px) {\n grid-template-columns: repeat(2, 1fr);\n --year-view-font-size: var(--mantine-font-size-xs);\n }\n\n @container (width <= 520px) {\n --year-view-font-size: calc(var(--mantine-font-size-xs) - 2px);\n }\n\n @container (width <= 420px) {\n grid-template-columns: 1fr;\n --year-view-font-size: var(--mantine-font-size-xs);\n }\n}\n\n.yearViewMonth {\n --week-numbers-offset: 0rem;\n --day-base-color: var(--mantine-color-text);\n --day-dimmed-color: alpha(var(--day-base-color), 0.35);\n\n &:where([data-with-week-numbers]) {\n --week-numbers-offset: 28px;\n }\n\n min-width: 0;\n border: 1px solid var(--year-view-border-color);\n padding: var(--mantine-spacing-md);\n margin-top: -1px;\n margin-inline-start: -1px;\n\n &:where(:nth-child(3n + 1)) {\n margin-inline-start: 0;\n }\n\n &:where(:nth-child(-n + 3)) {\n margin-top: 0;\n }\n\n &:where(:nth-child(1)) {\n border-start-start-radius: var(--year-view-radius);\n }\n\n &:where(:nth-child(3)) {\n border-start-end-radius: var(--year-view-radius);\n }\n\n &:where(:nth-last-child(3)) {\n border-end-start-radius: var(--year-view-radius);\n }\n\n &:where(:nth-last-child(1)) {\n border-end-end-radius: var(--year-view-radius);\n }\n\n @container (width <= 750px) {\n border: 0;\n padding: 8px;\n margin: 0;\n\n &:where([data-with-week-numbers]) {\n --week-numbers-offset: 14px;\n }\n }\n\n @container (width <= 420px) {\n padding: 6px;\n }\n}\n\n.yearViewWeekdays {\n display: flex;\n}\n\n.yearViewWeek {\n display: flex;\n}\n\n.yearViewWeekNumber {\n flex: 0 0 calc(var(--week-numbers-offset) - rem(4px));\n margin-inline-end: rem(4px);\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: var(--year-view-font-size);\n border-radius: var(--year-view-radius);\n padding: 4px;\n font-weight: var(--mantine-font-weight-medium);\n cursor: pointer;\n user-select: none;\n color: var(--day-dimmed-color);\n\n @container (width <= 750px) {\n padding: 0;\n }\n\n @mixin hover {\n @mixin where-light {\n background-color: var(--mantine-color-gray-0);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-6);\n }\n }\n\n &:where([data-static]) {\n cursor: default;\n pointer-events: none;\n }\n}\n\n.yearViewWeekday {\n flex: 0 0 calc(100% / 7 - var(--week-numbers-offset) / 7);\n height: 36px;\n font-size: var(--year-view-font-size);\n font-weight: var(--mantine-font-weight-medium);\n text-align: center;\n text-transform: capitalize;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: default;\n user-select: none;\n color: var(--day-dimmed-color);\n\n @container (width <= 750px) {\n height: auto;\n padding-block: 2px;\n }\n}\n\n.yearViewWeekdaysCorner {\n flex: 0 0 var(--week-numbers-offset);\n}\n\n.yearViewDay {\n flex: 0 0 calc(100% / 7 - var(--week-numbers-offset) / 7);\n padding: 4px;\n font-size: var(--year-view-font-size);\n color: var(--day-base-color);\n cursor: pointer;\n user-select: none;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 100%;\n aspect-ratio: 1;\n position: relative;\n\n @container (width <= 750px) {\n padding: 0;\n }\n\n &:where([data-day-placeholder]) {\n background-color: transparent;\n cursor: default;\n pointer-events: none;\n }\n\n &:where([data-weekend]) {\n color: var(--mantine-color-red-6);\n }\n\n &:where([data-outside]) {\n color: var(--day-dimmed-color);\n }\n\n @mixin hover {\n &:where(:not([data-today], [data-day-placeholder])) {\n @mixin where-light {\n background-color: var(--mantine-color-gray-0);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-6);\n }\n }\n }\n\n &:where([data-today]:not([data-outside])) {\n background-color: var(--mantine-primary-color-filled);\n color: var(--mantine-primary-color-contrast);\n\n @mixin hover {\n background-color: var(--mantine-primary-color-filled-hover);\n }\n }\n\n &:where([data-static]) {\n cursor: default;\n pointer-events: none;\n }\n}\n\n.yearViewMonthCaption {\n padding-inline: var(--mantine-spacing-sm);\n width: 100%;\n padding-block: 4px;\n margin-bottom: 4px;\n font-size: var(--year-view-font-size);\n font-weight: var(--mantine-font-weight-medium);\n text-transform: capitalize;\n border-radius: var(--year-view-radius);\n\n @mixin hover {\n @mixin where-light {\n background-color: var(--mantine-color-gray-0);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-6);\n }\n }\n\n &:where([data-static]) {\n cursor: default;\n pointer-events: none;\n }\n}\n\n.yearViewDayIndicators {\n position: absolute;\n bottom: 0;\n inset-inline: 0;\n display: flex;\n justify-content: center;\n padding-inline-start: 2px;\n}\n\n.yearViewDayIndicator {\n width: 8px;\n height: 8px;\n border-radius: 100%;\n margin-inline-start: -2px;\n border: 1px solid var(--mantine-color-body);\n}\n"],"mappings":""}
1
+ {"version":3,"file":"YearView.module.cjs","names":[],"sources":["../../../src/components/YearView/YearView.module.css"],"sourcesContent":[".yearView {\n --year-view-radius: var(--schedule-radius, var(--mantine-radius-default));\n --year-view-font-size: var(--mantine-font-size-sm);\n --year-view-columns: 7;\n container-type: inline-size;\n\n @mixin where-light {\n --year-view-border-color: var(--mantine-color-gray-3);\n }\n\n @mixin where-dark {\n --year-view-border-color: var(--mantine-color-dark-4);\n }\n}\n\n.yearViewMonths {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n\n @container (width <= 850px) {\n --year-view-font-size: calc(var(--mantine-font-size-sm) - 2px);\n }\n\n @container (width <= 750px) {\n grid-template-columns: repeat(2, 1fr);\n --year-view-font-size: var(--mantine-font-size-xs);\n }\n\n @container (width <= 520px) {\n --year-view-font-size: calc(var(--mantine-font-size-xs) - 2px);\n }\n\n @container (width <= 420px) {\n grid-template-columns: 1fr;\n --year-view-font-size: var(--mantine-font-size-xs);\n }\n}\n\n.yearViewMonth {\n --week-numbers-offset: 0rem;\n --day-base-color: var(--mantine-color-text);\n --day-dimmed-color: alpha(var(--day-base-color), 0.35);\n\n &:where([data-with-week-numbers]) {\n --week-numbers-offset: 28px;\n }\n\n min-width: 0;\n border: 1px solid var(--year-view-border-color);\n padding: var(--mantine-spacing-md);\n margin-top: -1px;\n margin-inline-start: -1px;\n\n &:where(:nth-child(3n + 1)) {\n margin-inline-start: 0;\n }\n\n &:where(:nth-child(-n + 3)) {\n margin-top: 0;\n }\n\n &:where(:nth-child(1)) {\n border-start-start-radius: var(--year-view-radius);\n }\n\n &:where(:nth-child(3)) {\n border-start-end-radius: var(--year-view-radius);\n }\n\n &:where(:nth-last-child(3)) {\n border-end-start-radius: var(--year-view-radius);\n }\n\n &:where(:nth-last-child(1)) {\n border-end-end-radius: var(--year-view-radius);\n }\n\n @container (width <= 750px) {\n border: 0;\n padding: 8px;\n margin: 0;\n\n &:where([data-with-week-numbers]) {\n --week-numbers-offset: 14px;\n }\n }\n\n @container (width <= 420px) {\n padding: 6px;\n }\n}\n\n.yearViewWeekdays {\n display: flex;\n}\n\n.yearViewWeek {\n display: flex;\n}\n\n.yearViewWeekNumber {\n flex: 0 0 calc(var(--week-numbers-offset) - rem(4px));\n margin-inline-end: rem(4px);\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: var(--year-view-font-size);\n border-radius: var(--year-view-radius);\n padding: 4px;\n font-weight: var(--mantine-font-weight-medium);\n cursor: pointer;\n user-select: none;\n color: var(--day-dimmed-color);\n\n @container (width <= 750px) {\n padding: 0;\n }\n\n @mixin hover {\n @mixin where-light {\n background-color: var(--mantine-color-gray-0);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-6);\n }\n }\n\n &:where([data-static]) {\n cursor: default;\n pointer-events: none;\n }\n}\n\n.yearViewWeekday {\n flex: 0 0\n calc(100% / var(--year-view-columns) - var(--week-numbers-offset) / var(--year-view-columns));\n height: 36px;\n font-size: var(--year-view-font-size);\n font-weight: var(--mantine-font-weight-medium);\n text-align: center;\n text-transform: capitalize;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: default;\n user-select: none;\n color: var(--day-dimmed-color);\n\n @container (width <= 750px) {\n height: auto;\n padding-block: 2px;\n }\n}\n\n.yearViewWeekdaysCorner {\n flex: 0 0 var(--week-numbers-offset);\n}\n\n.yearViewDay {\n flex: 0 0\n calc(100% / var(--year-view-columns) - var(--week-numbers-offset) / var(--year-view-columns));\n padding: 4px;\n font-size: var(--year-view-font-size);\n color: var(--day-base-color);\n cursor: pointer;\n user-select: none;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 100%;\n aspect-ratio: 1;\n position: relative;\n\n @container (width <= 750px) {\n padding: 0;\n }\n\n &:where([data-day-placeholder]) {\n background-color: transparent;\n cursor: default;\n pointer-events: none;\n }\n\n &:where([data-weekend]) {\n color: var(--mantine-color-red-6);\n }\n\n &:where([data-outside]) {\n color: var(--day-dimmed-color);\n }\n\n @mixin hover {\n &:where(:not([data-today], [data-day-placeholder])) {\n @mixin where-light {\n background-color: var(--mantine-color-gray-0);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-6);\n }\n }\n }\n\n &:where([data-today]:not([data-outside])) {\n background-color: var(--mantine-primary-color-filled);\n color: var(--mantine-primary-color-contrast);\n\n @mixin hover {\n background-color: var(--mantine-primary-color-filled-hover);\n }\n }\n\n &:where([data-static]) {\n cursor: default;\n pointer-events: none;\n }\n}\n\n.yearViewMonthCaption {\n padding-inline: var(--mantine-spacing-sm);\n width: 100%;\n padding-block: 4px;\n margin-bottom: 4px;\n font-size: var(--year-view-font-size);\n font-weight: var(--mantine-font-weight-medium);\n text-transform: capitalize;\n border-radius: var(--year-view-radius);\n\n @mixin hover {\n @mixin where-light {\n background-color: var(--mantine-color-gray-0);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-6);\n }\n }\n\n &:where([data-static]) {\n cursor: default;\n pointer-events: none;\n }\n}\n\n.yearViewDayIndicators {\n position: absolute;\n bottom: 0;\n inset-inline: 0;\n display: flex;\n justify-content: center;\n padding-inline-start: 2px;\n}\n\n.yearViewDayIndicator {\n width: 8px;\n height: 8px;\n border-radius: 100%;\n margin-inline-start: -2px;\n border: 1px solid var(--mantine-color-body);\n}\n"],"mappings":""}
@@ -5,6 +5,7 @@ const require_get_weekdays_names = require("../../utils/get-weekdays-names/get-w
5
5
  const require_get_week_number = require("../../utils/get-week-number/get-week-number.cjs");
6
6
  const require_get_month_days = require("../../utils/get-month-days/get-month-days.cjs");
7
7
  const require_is_same_month = require("../../utils/is-same-month/is-same-month.cjs");
8
+ const require_get_visible_week_days = require("./get-visible-week-days.cjs");
8
9
  let dayjs = require("dayjs");
9
10
  dayjs = require_runtime.__toESM(dayjs);
10
11
  let _mantine_core = require("@mantine/core");
@@ -12,31 +13,42 @@ let react = require("react");
12
13
  let _mantine_dates = require("@mantine/dates");
13
14
  let react_jsx_runtime = require("react/jsx-runtime");
14
15
  //#region packages/@mantine/schedule/src/components/YearView/YearViewMonth.tsx
15
- function YearViewMonth({ month, getStyles, monthLabelFormat = "MMMM", withWeekNumbers, withWeekDays, locale, firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, onDayClick, onWeekNumberClick, onMonthClick, getWeekNumberProps, highlightToday, groupedEvents, mode, withOutsideDays, __getDayRef, __onDayKeyDown, firstDayIndex }) {
16
+ function YearViewMonth({ month, getStyles, monthLabelFormat = "MMMM", withWeekNumbers, withWeekDays, locale, firstDayOfWeek, weekdayFormat, weekendDays, withWeekendDays, getDayProps, onDayClick, onWeekNumberClick, onMonthClick, getWeekNumberProps, highlightToday, groupedEvents, mode, withOutsideDays, __getDayRef, __onDayKeyDown, firstDayIndex }) {
16
17
  const ctx = (0, _mantine_dates.useDatesContext)();
17
18
  const theme = (0, _mantine_core.useMantineTheme)();
18
19
  const today = (0, dayjs.default)();
20
+ const resolvedFirstDayOfWeek = ctx.getFirstDayOfWeek(firstDayOfWeek);
21
+ const resolvedWeekendDays = ctx.getWeekendDays(weekendDays);
22
+ const hiddenColumns = new Set(require_get_visible_week_days.getHiddenWeekendColumns({
23
+ weekendDays: resolvedWeekendDays,
24
+ firstDayOfWeek: resolvedFirstDayOfWeek,
25
+ withWeekendDays
26
+ }));
19
27
  const weekdays = withWeekDays ? require_get_weekdays_names.getWeekdaysNames({
20
28
  locale: ctx.getLocale(locale),
21
29
  format: weekdayFormat,
22
- firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek)
23
- }).map((day, index) => /* @__PURE__ */ (0, react.createElement)("div", {
30
+ firstDayOfWeek: resolvedFirstDayOfWeek
31
+ }).filter((_, index) => !hiddenColumns.has(index)).map((day, index) => /* @__PURE__ */ (0, react.createElement)("div", {
24
32
  ...getStyles("yearViewWeekday"),
25
33
  key: index
26
34
  }, day)) : null;
27
35
  const weeks = require_get_month_days.getMonthDays({
28
36
  month: (0, dayjs.default)(month).format("YYYY-MM-DD"),
29
- firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek),
37
+ firstDayOfWeek: resolvedFirstDayOfWeek,
30
38
  consistentWeeks: true
31
39
  }).map((week, weekIndex) => {
32
- const days = week.map((date, dayIndex) => {
40
+ const days = require_get_visible_week_days.getVisibleWeekDays({
41
+ week,
42
+ weekendDays: resolvedWeekendDays,
43
+ withWeekendDays
44
+ }).map((date, dayIndex) => {
33
45
  const outside = !require_is_same_month.isSameMonth(date, month);
34
46
  if (outside && !withOutsideDays) return /* @__PURE__ */ (0, react.createElement)("div", {
35
47
  ...getStyles("yearViewDay"),
36
48
  "data-day-placeholder": true,
37
49
  key: date
38
50
  });
39
- const weekend = ctx.getWeekendDays(weekendDays).includes((0, dayjs.default)(date).day());
51
+ const weekend = resolvedWeekendDays.includes((0, dayjs.default)(date).day());
40
52
  const ariaLabel = (0, dayjs.default)(date).locale(locale || ctx.locale).format("MMMM D, YYYY");
41
53
  const dayProps = getDayProps?.((0, dayjs.default)(date).format("YYYY-MM-DD")) || {};
42
54
  const isToday = (0, dayjs.default)(date).isSame(today, "day") && highlightToday;
@@ -1 +1 @@
1
- {"version":3,"file":"YearViewMonth.cjs","names":["getWeekdaysNames","getMonthDays","isSameMonth","UnstyledButton","getWeekNumber","Box","formatDate"],"sources":["../../../src/components/YearView/YearViewMonth.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport { Box, GetStylesApi, getThemeColor, UnstyledButton, useMantineTheme } from '@mantine/core';\nimport { useDatesContext } from '@mantine/dates';\nimport { ScheduleLabelsOverride } from '../../labels';\nimport { DateLabelFormat, DateStringValue, DayOfWeek, ScheduleMode } from '../../types';\nimport {\n formatDate,\n getMonthDays,\n getWeekdaysNames,\n getWeekNumber,\n isSameMonth,\n} from '../../utils';\nimport { GroupedEvents } from './get-year-view-events/get-year-view-events';\nimport type { YearViewFactory } from './YearView';\n\nexport interface YearViewDayKeydownPayload {\n weekIndex: number;\n dayIndex: number;\n date: string;\n}\n\nexport interface YearViewMonthSettings {\n /** `dayjs` format for month label @default 'MMMM' */\n monthLabelFormat?: DateLabelFormat;\n\n /** If set, show week numbers */\n withWeekNumbers?: boolean;\n\n /** If set, weekdays names are displayed in the first row @default true */\n withWeekDays?: boolean;\n\n /** Locale passed down to dayjs, overrides value defined on `DatesProvider` */\n locale?: string;\n\n /** Number 0-6, where 0 – Sunday and 6 – Saturday @default 0 */\n firstDayOfWeek?: DayOfWeek;\n\n /** `dayjs` format for weekdays names @default 'd' */\n weekdayFormat?: DateLabelFormat;\n\n /** Indices of weekend days, 0-6, where 0 is Sunday and 6 is Saturday. The default value is defined by `DatesProvider`. */\n weekendDays?: DayOfWeek[];\n\n /** Props passed down to the week number button */\n getWeekNumberProps?: (weekStartDate: DateStringValue) => Record<string, any>;\n\n /** Props passed down to the day button */\n getDayProps?: (date: DateStringValue) => Record<string, any>;\n\n /** Called when day is clicked */\n onDayClick?: (date: DateStringValue, event: React.MouseEvent<HTMLButtonElement>) => void;\n\n /** Called with first day of the week when week number is clicked */\n onWeekNumberClick?: (date: DateStringValue, event: React.MouseEvent<HTMLButtonElement>) => void;\n\n /** Called with the first day of the month when month label is clicked */\n onMonthClick?: (date: DateStringValue, event: React.MouseEvent<HTMLButtonElement>) => void;\n\n /** If set, highlights the current day @default true */\n highlightToday?: boolean;\n\n /** Labels override for i18n */\n labels?: ScheduleLabelsOverride;\n\n /** Interaction mode: 'default' allows all interactions, 'static' disables event interactions */\n mode?: ScheduleMode;\n\n /** If true, days from adjacent months are displayed @default true */\n withOutsideDays?: boolean;\n}\n\nexport interface YearViewMonthProps extends YearViewMonthSettings {\n /** Month to display, Date object or date string in `YYYY-MM-DD` format */\n month: Date | string;\n\n /** `useStyles` return value of `YearView` */\n getStyles: GetStylesApi<YearViewFactory>;\n\n /** Events grouped by date */\n groupedEvents?: GroupedEvents;\n\n /** Assigns ref of every day based on its position in the month, used for keyboard navigation */\n __getDayRef?: (weekIndex: number, dayIndex: number, node: HTMLButtonElement) => void;\n\n /** Called when any keydown event is registered on day, used for keyboard navigation */\n __onDayKeyDown?: (\n event: React.KeyboardEvent<HTMLButtonElement>,\n payload: YearViewDayKeydownPayload\n ) => void;\n\n /** Index of the first day of the month in the grid (for determining which day should be in tab order) */\n firstDayIndex?: { weekIndex: number; dayIndex: number };\n}\n\nexport function YearViewMonth({\n month,\n getStyles,\n monthLabelFormat = 'MMMM',\n withWeekNumbers,\n withWeekDays,\n locale,\n firstDayOfWeek,\n weekdayFormat,\n weekendDays,\n getDayProps,\n onDayClick,\n onWeekNumberClick,\n onMonthClick,\n getWeekNumberProps,\n highlightToday,\n groupedEvents,\n mode,\n withOutsideDays,\n __getDayRef,\n __onDayKeyDown,\n firstDayIndex,\n}: YearViewMonthProps) {\n const ctx = useDatesContext();\n const theme = useMantineTheme();\n const today = dayjs();\n\n const weekdays = withWeekDays\n ? getWeekdaysNames({\n locale: ctx.getLocale(locale),\n format: weekdayFormat,\n firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek),\n }).map((day, index) => (\n <div {...getStyles('yearViewWeekday')} key={index}>\n {day}\n </div>\n ))\n : null;\n\n const weeks = getMonthDays({\n month: dayjs(month).format('YYYY-MM-DD'),\n firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek),\n consistentWeeks: true,\n }).map((week, weekIndex) => {\n const days = week.map((date, dayIndex) => {\n const outside = !isSameMonth(date, month);\n\n if (outside && !withOutsideDays) {\n return <div {...getStyles('yearViewDay')} data-day-placeholder key={date} />;\n }\n\n const weekend = ctx.getWeekendDays(weekendDays).includes(dayjs(date).day());\n const ariaLabel = dayjs(date)\n .locale(locale || ctx.locale)\n .format('MMMM D, YYYY');\n\n const dayProps = getDayProps?.(dayjs(date).format('YYYY-MM-DD')) || {};\n const isToday = dayjs(date).isSame(today, 'day') && highlightToday;\n const dayEvents = groupedEvents?.[dayjs(date).format('YYYY-MM-DD')] || [];\n\n // Determine if this day should be in the tab order\n // Only the first day of the month (not outside) should be focusable via tab\n const isFirstDayOfMonth =\n firstDayIndex &&\n weekIndex === firstDayIndex.weekIndex &&\n dayIndex === firstDayIndex.dayIndex;\n const isInTabOrder = mode !== 'static' && !outside && isFirstDayOfMonth;\n\n const indicators = dayEvents.slice(0, 3).map((event) => (\n <div\n {...getStyles('yearViewDayIndicator', {\n style: { backgroundColor: getThemeColor(event.color, theme) },\n })}\n key={event.id}\n />\n ));\n\n return (\n <UnstyledButton\n aria-label={ariaLabel}\n {...dayProps}\n {...getStyles('yearViewDay', { className: dayProps.className, style: dayProps.style })}\n key={date}\n mod={[{ outside, weekend, today: isToday, static: mode === 'static' }, dayProps.mod]}\n tabIndex={isInTabOrder ? 0 : -1}\n ref={(node) => {\n if (node) {\n __getDayRef?.(weekIndex, dayIndex, node);\n }\n }}\n onKeyDown={(event) => {\n dayProps.onKeyDown?.(event);\n __onDayKeyDown?.(event, { weekIndex, dayIndex, date });\n }}\n onClick={\n mode === 'static'\n ? undefined\n : (event) => {\n onDayClick?.(dayjs(date).format('YYYY-MM-DD'), event);\n dayProps.onClick?.(event);\n }\n }\n >\n {dayjs(date).format('D')}\n\n <div {...getStyles('yearViewDayIndicators')}>{indicators}</div>\n </UnstyledButton>\n );\n });\n\n const weekNumberProps = getWeekNumberProps?.(dayjs(week[0]).format('YYYY-MM-DD')) || {};\n const weekNumber = getWeekNumber(week);\n\n return (\n <div {...getStyles('yearViewWeek')} key={weekIndex}>\n {withWeekNumbers && (\n <UnstyledButton\n key={weekNumber}\n aria-label={`Week ${weekNumber}`}\n title={`Week ${weekNumber}`}\n {...weekNumberProps}\n onClick={\n mode === 'static'\n ? undefined\n : (event) => {\n onWeekNumberClick?.(dayjs(week[0]).format('YYYY-MM-DD'), event);\n weekNumberProps.onClick?.(event);\n }\n }\n mod={{ static: mode === 'static' }}\n tabIndex={mode === 'static' ? -1 : 0}\n {...getStyles('yearViewWeekNumber', {\n className: weekNumberProps.className,\n style: weekNumberProps.style,\n })}\n >\n {weekNumber}\n </UnstyledButton>\n )}\n\n {days}\n </div>\n );\n });\n\n return (\n <Box\n mod={[\n {\n 'with-week-numbers': withWeekNumbers,\n 'with-weekdays': withWeekDays,\n static: mode === 'static',\n },\n ]}\n {...getStyles('yearViewMonth')}\n >\n <UnstyledButton\n onClick={\n mode === 'static'\n ? undefined\n : (event) => onMonthClick?.(dayjs(month).startOf('month').format('YYYY-MM-DD'), event)\n }\n mod={{ static: mode === 'static' }}\n tabIndex={mode === 'static' ? -1 : 0}\n {...getStyles('yearViewMonthCaption')}\n >\n {formatDate({ locale: ctx.getLocale(locale), date: month, format: monthLabelFormat })}\n </UnstyledButton>\n\n {weekdays && (\n <div {...getStyles('yearViewWeekdays')}>\n {withWeekNumbers && <div {...getStyles('yearViewWeekdaysCorner')} />}\n {weekdays}\n </div>\n )}\n\n {weeks}\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA8FA,SAAgB,cAAc,EAC5B,OACA,WACA,mBAAmB,QACnB,iBACA,cACA,QACA,gBACA,eACA,aACA,aACA,YACA,mBACA,cACA,oBACA,gBACA,eACA,MACA,iBACA,aACA,gBACA,iBACqB;CACrB,MAAM,OAAA,GAAA,eAAA,gBAAA,CAAsB;CAC5B,MAAM,SAAA,GAAA,cAAA,gBAAA,CAAwB;CAC9B,MAAM,SAAA,GAAA,MAAA,QAAA,CAAc;CAEpB,MAAM,WAAW,eACbA,2BAAAA,iBAAiB;EACf,QAAQ,IAAI,UAAU,MAAM;EAC5B,QAAQ;EACR,gBAAgB,IAAI,kBAAkB,cAAc;CACtD,CAAC,CAAC,CAAC,KAAK,KAAK,UACX,iBAAA,GAAA,MAAA,cAAA,CAAC,OAAD;EAAK,GAAI,UAAU,iBAAiB;EAAG,KAAK;CAEvC,GADF,GACE,CACN,IACD;CAEJ,MAAM,QAAQC,uBAAAA,aAAa;EACzB,QAAA,GAAA,MAAA,QAAA,CAAa,KAAK,C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EN,KAAK,EAAE,QAAQ,SAAS,SAAS;GACjC,UAAU,SAAS,WAAW,KAAK;GACnC,GAAI,UAAU,sBAAsB;IAClC,WAAW,gBAAgB;IAC3B,OAAO,gBAAgB;GACzB,CAAC;aAEA;EACa,GApBT,UAoBS,GAGjB,IACE;CAET,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAACE,cAAAA,KAAD;EACE,KAAK,CACH;GACE,qBAAqB;GACrB,iBAAiB;GACjB,QAAQ,SAAS;EACnB,CACF;EACA,GAAI,UAAU,eAAe;YAR/B;GAUE,iBAAA,GAAA,kBAAA,IAAA,CAACF,cAAAA,gBAAD;IACE,SACE,SAAS,WACL,KAAA,KACC,UAAU,gBAAA,GAAA,MAAA,QAAA,CAAqB,KAAK,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,YAAY,GAAG,KAAK;IAEzF,KAAK,EAAE,QAAQ,SAAS,SAAS;IACjC,UAAU,SAAS,WAAW,KAAK;IACnC,GAAI,UAAU,sBAAsB;cAEnCG,oBAAAA,WAAW;KAAE,QAAQ,IAAI,UAAU,MAAM;KAAG,MAAM;KAAO,QAAQ;IAAiB,CAAC;GACtE,CAAA;GAEf,YACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;IAAK,GAAI,UAAU,kBAAkB;cAArC,CACG,mBAAmB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAK,GAAI,UAAU,wBAAwB,EAAI,CAAA,GAClE,QACE;;GAGN;EACE;;AAET"}
1
+ {"version":3,"file":"YearViewMonth.cjs","names":["getHiddenWeekendColumns","getWeekdaysNames","getMonthDays","getVisibleWeekDays","isSameMonth","UnstyledButton","getWeekNumber","Box","formatDate"],"sources":["../../../src/components/YearView/YearViewMonth.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport { Box, GetStylesApi, getThemeColor, UnstyledButton, useMantineTheme } from '@mantine/core';\nimport { useDatesContext } from '@mantine/dates';\nimport { ScheduleLabelsOverride } from '../../labels';\nimport { DateLabelFormat, DateStringValue, DayOfWeek, ScheduleMode } from '../../types';\nimport {\n formatDate,\n getMonthDays,\n getWeekdaysNames,\n getWeekNumber,\n isSameMonth,\n} from '../../utils';\nimport { getHiddenWeekendColumns, getVisibleWeekDays } from './get-visible-week-days';\nimport { GroupedEvents } from './get-year-view-events/get-year-view-events';\nimport type { YearViewFactory } from './YearView';\n\nexport interface YearViewDayKeydownPayload {\n weekIndex: number;\n dayIndex: number;\n date: string;\n}\n\nexport interface YearViewMonthSettings {\n /** `dayjs` format for month label @default 'MMMM' */\n monthLabelFormat?: DateLabelFormat;\n\n /** If set, show week numbers */\n withWeekNumbers?: boolean;\n\n /** If set, weekdays names are displayed in the first row @default true */\n withWeekDays?: boolean;\n\n /** Locale passed down to dayjs, overrides value defined on `DatesProvider` */\n locale?: string;\n\n /** Number 0-6, where 0 – Sunday and 6 – Saturday @default 0 */\n firstDayOfWeek?: DayOfWeek;\n\n /** `dayjs` format for weekdays names @default 'd' */\n weekdayFormat?: DateLabelFormat;\n\n /** Indices of weekend days, 0-6, where 0 is Sunday and 6 is Saturday. The default value is defined by `DatesProvider`. */\n weekendDays?: DayOfWeek[];\n\n /** If set, weekend days are displayed. When `false`, weekend columns are hidden and the month grid shrinks. @default true */\n withWeekendDays?: boolean;\n\n /** Props passed down to the week number button */\n getWeekNumberProps?: (weekStartDate: DateStringValue) => Record<string, any>;\n\n /** Props passed down to the day button */\n getDayProps?: (date: DateStringValue) => Record<string, any>;\n\n /** Called when day is clicked */\n onDayClick?: (date: DateStringValue, event: React.MouseEvent<HTMLButtonElement>) => void;\n\n /** Called with first day of the week when week number is clicked */\n onWeekNumberClick?: (date: DateStringValue, event: React.MouseEvent<HTMLButtonElement>) => void;\n\n /** Called with the first day of the month when month label is clicked */\n onMonthClick?: (date: DateStringValue, event: React.MouseEvent<HTMLButtonElement>) => void;\n\n /** If set, highlights the current day @default true */\n highlightToday?: boolean;\n\n /** Labels override for i18n */\n labels?: ScheduleLabelsOverride;\n\n /** Interaction mode: 'default' allows all interactions, 'static' disables event interactions */\n mode?: ScheduleMode;\n\n /** If true, days from adjacent months are displayed @default true */\n withOutsideDays?: boolean;\n}\n\nexport interface YearViewMonthProps extends YearViewMonthSettings {\n /** Month to display, Date object or date string in `YYYY-MM-DD` format */\n month: Date | string;\n\n /** `useStyles` return value of `YearView` */\n getStyles: GetStylesApi<YearViewFactory>;\n\n /** Events grouped by date */\n groupedEvents?: GroupedEvents;\n\n /** Assigns ref of every day based on its position in the month, used for keyboard navigation */\n __getDayRef?: (weekIndex: number, dayIndex: number, node: HTMLButtonElement) => void;\n\n /** Called when any keydown event is registered on day, used for keyboard navigation */\n __onDayKeyDown?: (\n event: React.KeyboardEvent<HTMLButtonElement>,\n payload: YearViewDayKeydownPayload\n ) => void;\n\n /** Index of the first day of the month in the grid (for determining which day should be in tab order) */\n firstDayIndex?: { weekIndex: number; dayIndex: number };\n}\n\nexport function YearViewMonth({\n month,\n getStyles,\n monthLabelFormat = 'MMMM',\n withWeekNumbers,\n withWeekDays,\n locale,\n firstDayOfWeek,\n weekdayFormat,\n weekendDays,\n withWeekendDays,\n getDayProps,\n onDayClick,\n onWeekNumberClick,\n onMonthClick,\n getWeekNumberProps,\n highlightToday,\n groupedEvents,\n mode,\n withOutsideDays,\n __getDayRef,\n __onDayKeyDown,\n firstDayIndex,\n}: YearViewMonthProps) {\n const ctx = useDatesContext();\n const theme = useMantineTheme();\n const today = dayjs();\n\n const resolvedFirstDayOfWeek = ctx.getFirstDayOfWeek(firstDayOfWeek);\n const resolvedWeekendDays = ctx.getWeekendDays(weekendDays);\n const hiddenColumns = new Set(\n getHiddenWeekendColumns({\n weekendDays: resolvedWeekendDays,\n firstDayOfWeek: resolvedFirstDayOfWeek,\n withWeekendDays,\n })\n );\n\n const weekdays = withWeekDays\n ? getWeekdaysNames({\n locale: ctx.getLocale(locale),\n format: weekdayFormat,\n firstDayOfWeek: resolvedFirstDayOfWeek,\n })\n .filter((_, index) => !hiddenColumns.has(index))\n .map((day, index) => (\n <div {...getStyles('yearViewWeekday')} key={index}>\n {day}\n </div>\n ))\n : null;\n\n const weeks = getMonthDays({\n month: dayjs(month).format('YYYY-MM-DD'),\n firstDayOfWeek: resolvedFirstDayOfWeek,\n consistentWeeks: true,\n }).map((week, weekIndex) => {\n const visibleDays = getVisibleWeekDays({\n week,\n weekendDays: resolvedWeekendDays,\n withWeekendDays,\n });\n\n const days = visibleDays.map((date, dayIndex) => {\n const outside = !isSameMonth(date, month);\n\n if (outside && !withOutsideDays) {\n return <div {...getStyles('yearViewDay')} data-day-placeholder key={date} />;\n }\n\n const weekend = resolvedWeekendDays.includes(dayjs(date).day() as DayOfWeek);\n const ariaLabel = dayjs(date)\n .locale(locale || ctx.locale)\n .format('MMMM D, YYYY');\n\n const dayProps = getDayProps?.(dayjs(date).format('YYYY-MM-DD')) || {};\n const isToday = dayjs(date).isSame(today, 'day') && highlightToday;\n const dayEvents = groupedEvents?.[dayjs(date).format('YYYY-MM-DD')] || [];\n\n // Determine if this day should be in the tab order\n // Only the first day of the month (not outside) should be focusable via tab\n const isFirstDayOfMonth =\n firstDayIndex &&\n weekIndex === firstDayIndex.weekIndex &&\n dayIndex === firstDayIndex.dayIndex;\n const isInTabOrder = mode !== 'static' && !outside && isFirstDayOfMonth;\n\n const indicators = dayEvents.slice(0, 3).map((event) => (\n <div\n {...getStyles('yearViewDayIndicator', {\n style: { backgroundColor: getThemeColor(event.color, theme) },\n })}\n key={event.id}\n />\n ));\n\n return (\n <UnstyledButton\n aria-label={ariaLabel}\n {...dayProps}\n {...getStyles('yearViewDay', { className: dayProps.className, style: dayProps.style })}\n key={date}\n mod={[{ outside, weekend, today: isToday, static: mode === 'static' }, dayProps.mod]}\n tabIndex={isInTabOrder ? 0 : -1}\n ref={(node) => {\n if (node) {\n __getDayRef?.(weekIndex, dayIndex, node);\n }\n }}\n onKeyDown={(event) => {\n dayProps.onKeyDown?.(event);\n __onDayKeyDown?.(event, { weekIndex, dayIndex, date });\n }}\n onClick={\n mode === 'static'\n ? undefined\n : (event) => {\n onDayClick?.(dayjs(date).format('YYYY-MM-DD'), event);\n dayProps.onClick?.(event);\n }\n }\n >\n {dayjs(date).format('D')}\n\n <div {...getStyles('yearViewDayIndicators')}>{indicators}</div>\n </UnstyledButton>\n );\n });\n\n const weekNumberProps = getWeekNumberProps?.(dayjs(week[0]).format('YYYY-MM-DD')) || {};\n const weekNumber = getWeekNumber(week);\n\n return (\n <div {...getStyles('yearViewWeek')} key={weekIndex}>\n {withWeekNumbers && (\n <UnstyledButton\n key={weekNumber}\n aria-label={`Week ${weekNumber}`}\n title={`Week ${weekNumber}`}\n {...weekNumberProps}\n onClick={\n mode === 'static'\n ? undefined\n : (event) => {\n onWeekNumberClick?.(dayjs(week[0]).format('YYYY-MM-DD'), event);\n weekNumberProps.onClick?.(event);\n }\n }\n mod={{ static: mode === 'static' }}\n tabIndex={mode === 'static' ? -1 : 0}\n {...getStyles('yearViewWeekNumber', {\n className: weekNumberProps.className,\n style: weekNumberProps.style,\n })}\n >\n {weekNumber}\n </UnstyledButton>\n )}\n\n {days}\n </div>\n );\n });\n\n return (\n <Box\n mod={[\n {\n 'with-week-numbers': withWeekNumbers,\n 'with-weekdays': withWeekDays,\n static: mode === 'static',\n },\n ]}\n {...getStyles('yearViewMonth')}\n >\n <UnstyledButton\n onClick={\n mode === 'static'\n ? undefined\n : (event) => onMonthClick?.(dayjs(month).startOf('month').format('YYYY-MM-DD'), event)\n }\n mod={{ static: mode === 'static' }}\n tabIndex={mode === 'static' ? -1 : 0}\n {...getStyles('yearViewMonthCaption')}\n >\n {formatDate({ locale: ctx.getLocale(locale), date: month, format: monthLabelFormat })}\n </UnstyledButton>\n\n {weekdays && (\n <div {...getStyles('yearViewWeekdays')}>\n {withWeekNumbers && <div {...getStyles('yearViewWeekdaysCorner')} />}\n {weekdays}\n </div>\n )}\n\n {weeks}\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkGA,S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A,IAAA,CAACF,cAAAA,gBAAD;IACE,SACE,SAAS,WACL,KAAA,KACC,UAAU,gBAAA,GAAA,MAAA,QAAA,CAAqB,KAAK,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,YAAY,GAAG,KAAK;IAEzF,KAAK,EAAE,QAAQ,SAAS,SAAS;IACjC,UAAU,SAAS,WAAW,KAAK;IACnC,GAAI,UAAU,sBAAsB;cAEnCG,oBAAAA,WAAW;KAAE,QAAQ,IAAI,UAAU,MAAM;KAAG,MAAM;KAAO,QAAQ;IAAiB,CAAC;GACtE,CAAA;GAEf,YACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;IAAK,GAAI,UAAU,kBAAkB;cAArC,CACG,mBAAmB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAK,GAAI,UAAU,wBAAwB,EAAI,CAAA,GAClE,QACE;;GAGN;EACE;;AAET"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
+ let dayjs = require("dayjs");
4
+ dayjs = require_runtime.__toESM(dayjs);
5
+ //#region packages/@mantine/schedule/src/components/YearView/get-visible-week-days.ts
6
+ const DAYS_IN_WEEK = 7;
7
+ /**
8
+ * Returns indices of week columns (0-6, relative to `firstDayOfWeek`) that are
9
+ * hidden because they fall on a weekend day and `withWeekendDays` is `false`.
10
+ */
11
+ function getHiddenWeekendColumns({ weekendDays, firstDayOfWeek, withWeekendDays }) {
12
+ if (withWeekendDays !== false) return [];
13
+ return Array.from({ length: DAYS_IN_WEEK }, (_, index) => index).filter((index) => weekendDays.includes((firstDayOfWeek + index) % DAYS_IN_WEEK));
14
+ }
15
+ /** Filters out weekend days from a week when `withWeekendDays` is `false` */
16
+ function getVisibleWeekDays({ week, weekendDays, withWeekendDays }) {
17
+ if (withWeekendDays !== false) return week;
18
+ return week.filter((date) => !weekendDays.includes((0, dayjs.default)(date).day()));
19
+ }
20
+ //#endregion
21
+ exports.getHiddenWeekendColumns = getHiddenWeekendColumns;
22
+ exports.getVisibleWeekDays = getVisibleWeekDays;
23
+
24
+ //# sourceMappingURL=get-visible-week-days.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-visible-week-days.cjs","names":[],"sources":["../../../src/components/YearView/get-visible-week-days.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue, DayOfWeek } from '../../types';\n\nconst DAYS_IN_WEEK = 7;\n\ninterface HiddenWeekendColumnsInput {\n weekendDays: DayOfWeek[];\n firstDayOfWeek: DayOfWeek;\n withWeekendDays: boolean | undefined;\n}\n\n/**\n * Returns indices of week columns (0-6, relative to `firstDayOfWeek`) that are\n * hidden because they fall on a weekend day and `withWeekendDays` is `false`.\n */\nexport function getHiddenWeekendColumns({\n weekendDays,\n firstDayOfWeek,\n withWeekendDays,\n}: HiddenWeekendColumnsInput): number[] {\n if (withWeekendDays !== false) {\n return [];\n }\n\n return Array.from({ length: DAYS_IN_WEEK }, (_, index) => index).filter((index) =>\n weekendDays.includes(((firstDayOfWeek + index) % DAYS_IN_WEEK) as DayOfWeek)\n );\n}\n\ninterface VisibleWeekDaysInput {\n week: DateStringValue[];\n weekendDays: DayOfWeek[];\n withWeekendDays: boolean | undefined;\n}\n\n/** Filters out weekend days from a week when `withWeekendDays` is `false` */\nexport function getVisibleWeekDays({\n week,\n weekendDays,\n withWeekendDays,\n}: VisibleWeekDaysInput): DateStringValue[] {\n if (withWeekendDays !== false) {\n return week;\n }\n\n return week.filter((date) => !weekendDays.includes(dayjs(date).day() as DayOfWeek));\n}\n"],"mappings":";;;;;AAGA,MAAM,eAAe;;;;;AAYrB,SAAgB,wBAAwB,EACtC,aACA,gBACA,mBACsC;CACtC,IAAI,oBAAoB,OACtB,OAAO,CAAC;CAGV,OAAO,MAAM,KAAK,EAAE,QAAQ,aAAa,IAAI,GAAG,UAAU,KAAK,CAAC,CAAC,QAAQ,UACvE,YAAY,UAAW,iBAAiB,SAAS,YAA0B,CAC7E;AACF;;AASA,SAAgB,mBAAmB,EACjC,MACA,aACA,mBAC0C;CAC1C,IAAI,oBAAoB,OACtB,OAAO;CAGT,OAAO,KAAK,QAAQ,SAAS,CAAC,YAAY,UAAA,GAAA,MAAA,QAAA,CAAe,IAAI,CAAC,CAAC,IAAI,CAAc,CAAC;AACpF"}
@@ -0,0 +1,119 @@
1
+ "use client";
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_get_index_from_drag_point = require("../utils/get-index-from-drag-point/get-index-from-drag-point.cjs");
4
+ const require_calculate_month_resize_dates = require("../utils/calculate-month-resize-dates/calculate-month-resize-dates.cjs");
5
+ let dayjs = require("dayjs");
6
+ dayjs = require_runtime.__toESM(dayjs);
7
+ let react = require("react");
8
+ //#region packages/@mantine/schedule/src/hooks/use-day-grid-event-resize.ts
9
+ /**
10
+ * Resizes an event by dragging its start or end edge across a strip of day cells.
11
+ * The target day is resolved by hit-testing `cells` with the pointer position, so
12
+ * the hook works for any layout that renders one element per day in a single row.
13
+ */
14
+ function useDayGridEventResize({ enabled = false, mode = "default", onEventResize, canResizeEvent }) {
15
+ const [resizeState, setResizeState] = (0, react.useState)(null);
16
+ const resizeRef = (0, react.useRef)(null);
17
+ const justResizedRef = (0, react.useRef)(false);
18
+ const stableOnEventResize = (0, react.useEffectEvent)(onEventResize || (() => {}));
19
+ const handleResizeStart = (0, react.useCallback)(({ event, edge, cells, days, pointerEvent }) => {
20
+ if (!enabled || mode === "static") return;
21
+ pointerEvent.preventDefault();
22
+ pointerEvent.stopPropagation();
23
+ const originalStart = (0, dayjs.default)(event.start).format("YYYY-MM-DD HH:mm:ss");
24
+ const originalEnd = (0, dayjs.default)(event.end).format("YYYY-MM-DD HH:mm:ss");
25
+ const state = {
26
+ eventId: event.id,
27
+ event,
28
+ edge,
29
+ cells,
30
+ days,
31
+ dayIndex: -1,
32
+ originalStart,
33
+ originalEnd,
34
+ start: originalStart,
35
+ end: originalEnd
36
+ };
37
+ resizeRef.current = state;
38
+ setResizeState(state);
39
+ }, [enabled, mode]);
40
+ const isResizing = resizeState !== null;
41
+ (0, react.useEffect)(() => {
42
+ if (!isResizing) return;
43
+ const savedUserSelect = document.body.style.userSelect;
44
+ const savedCursor = document.body.style.cursor;
45
+ document.body.style.userSelect = "none";
46
+ document.body.style.cursor = "ew-resize";
47
+ const handlePointerMove = (e) => {
48
+ const state = resizeRef.current;
49
+ if (!state) return;
50
+ const dayIndex = require_get_index_from_drag_point.getIndexFromDragPoint(state.cells, e.clientX);
51
+ if (dayIndex === null || dayIndex === state.dayIndex) return;
52
+ const targetDay = state.days[dayIndex];
53
+ if (!targetDay) return;
54
+ const { start, end } = require_calculate_month_resize_dates.calculateMonthResizeDates({
55
+ event: state.event,
56
+ edge: state.edge,
57
+ targetDay
58
+ });
59
+ resizeRef.current = {
60
+ ...state,
61
+ dayIndex,
62
+ start,
63
+ end
64
+ };
65
+ setResizeState(resizeRef.current);
66
+ };
67
+ const endGesture = () => {
68
+ resizeRef.current = null;
69
+ setResizeState(null);
70
+ justResizedRef.current = true;
71
+ requestAnimationFrame(() => {
72
+ justResizedRef.current = false;
73
+ });
74
+ };
75
+ const handlePointerUp = () => {
76
+ const state = resizeRef.current;
77
+ if (state && (state.start !== state.originalStart || state.end !== state.originalEnd)) stableOnEventResize({
78
+ eventId: state.eventId,
79
+ newStart: state.start,
80
+ newEnd: state.end,
81
+ event: state.event
82
+ });
83
+ endGesture();
84
+ };
85
+ document.addEventListener("pointermove", handlePointerMove);
86
+ document.addEventListener("pointerup", handlePointerUp);
87
+ document.addEventListener("pointercancel", endGesture);
88
+ return () => {
89
+ document.body.style.userSelect = savedUserSelect;
90
+ document.body.style.cursor = savedCursor;
91
+ document.removeEventListener("pointermove", handlePointerMove);
92
+ document.removeEventListener("pointerup", handlePointerUp);
93
+ document.removeEventListener("pointercancel", endGesture);
94
+ };
95
+ }, [isResizing]);
96
+ const isResizableEvent = (0, react.useCallback)((event) => {
97
+ if (!enabled || mode === "static" || event.display === "background") return false;
98
+ return canResizeEvent ? canResizeEvent(event) : true;
99
+ }, [
100
+ enabled,
101
+ mode,
102
+ canResizeEvent
103
+ ]);
104
+ const wasResizing = (0, react.useCallback)(() => justResizedRef.current, []);
105
+ return {
106
+ handleResizeStart,
107
+ isResizing,
108
+ resizingEventId: resizeState?.eventId ?? null,
109
+ resizingEdge: resizeState?.edge ?? null,
110
+ previewStart: resizeState?.start ?? null,
111
+ previewEnd: resizeState?.end ?? null,
112
+ isResizableEvent,
113
+ wasResizing
114
+ };
115
+ }
116
+ //#endregion
117
+ exports.useDayGridEventResize = useDayGridEventResize;
118
+
119
+ //# sourceMappingURL=use-day-grid-event-resize.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-day-grid-event-resize.cjs","names":["getIndexFromDragPoint","calculateMonthResizeDates"],"sources":["../../src/hooks/use-day-grid-event-resize.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { useCallback, useEffect, useEffectEvent, useRef, useState } from 'react';\nimport { DateStringValue, DateTimeStringValue, ScheduleEventData, ScheduleMode } from '../types';\nimport {\n calculateMonthResizeDates,\n MonthResizeEdge,\n} from '../utils/calculate-month-resize-dates/calculate-month-resize-dates';\nimport { getIndexFromDragPoint } from '../utils/get-index-from-drag-point/get-index-from-drag-point';\n\ninterface ResizeState {\n eventId: string | number;\n event: ScheduleEventData;\n edge: MonthResizeEdge;\n cells: (HTMLElement | null)[];\n days: DateStringValue[];\n dayIndex: number;\n originalStart: DateTimeStringValue;\n originalEnd: DateTimeStringValue;\n start: DateTimeStringValue;\n end: DateTimeStringValue;\n}\n\nexport interface UseDayGridEventResizeInput {\n enabled?: boolean;\n mode?: ScheduleMode;\n onEventResize?: (data: {\n eventId: string | number;\n newStart: DateTimeStringValue;\n newEnd: DateTimeStringValue;\n event: ScheduleEventData;\n }) => void;\n canResizeEvent?: (event: ScheduleEventData) => boolean;\n}\n\nexport interface DayGridResizeStartInput {\n event: ScheduleEventData;\n edge: MonthResizeEdge;\n cells: (HTMLElement | null)[];\n days: DateStringValue[];\n pointerEvent: React.PointerEvent;\n}\n\n/**\n * Resizes an event by dragging its start or end edge across a strip of day cells.\n * The target day is resolved by hit-testing `cells` with the pointer position, so\n * the hook works for any layout that renders one element per day in a single row.\n */\nexport function useDayGridEventResize({\n enabled = false,\n mode = 'default',\n onEventResize,\n canResizeEvent,\n}: UseDayGridEventResizeInput) {\n const [resizeState, setResizeState] = useState<ResizeState | null>(null);\n const resizeRef = useRef<ResizeState | null>(null);\n const justResizedRef = useRef(false);\n const stableOnEventResize = useEffectEvent(onEventResize || (() => {}));\n\n const handleResizeStart = useCallback(\n ({ event, edge, cells, days, pointerEvent }: DayGridResizeStartInput) => {\n if (!enabled || mode === 'static') {\n return;\n }\n\n pointerEvent.preventDefault();\n pointerEvent.stopPropagation();\n\n const originalStart = dayjs(event.start).format('YYYY-MM-DD HH:mm:ss');\n const originalEnd = dayjs(event.end).format('YYYY-MM-DD HH:mm:ss');\n\n const state: ResizeState = {\n eventId: event.id,\n event,\n edge,\n cells,\n days,\n dayIndex: -1,\n originalStart,\n originalEnd,\n start: originalStart,\n end: originalEnd,\n };\n\n resizeRef.current = state;\n setResizeState(state);\n },\n [enabled, mode]\n );\n\n const isResizing = resizeState !== null;\n\n useEffect(() => {\n if (!isResizing) {\n return undefined;\n }\n\n const savedUserSelect = document.body.style.userSelect;\n const savedCursor = document.body.style.cursor;\n document.body.style.userSelect = 'none';\n document.body.style.cursor = 'ew-resize';\n\n const handlePointerMove = (e: PointerEvent) => {\n const state = resizeRef.current;\n if (!state) {\n return;\n }\n\n const dayIndex = getIndexFromDragPoint(state.cells, e.clientX);\n if (dayIndex === null || dayIndex === state.dayIndex) {\n return;\n }\n\n const targetDay = state.days[dayIndex];\n if (!targetDay) {\n return;\n }\n\n const { start, end } = calculateMonthResizeDates({\n event: state.event,\n edge: state.edge,\n targetDay,\n });\n\n resizeRef.current = { ...state, dayIndex, start, end };\n setResizeState(resizeRef.current);\n };\n\n const endGesture = () => {\n resizeRef.current = null;\n setResizeState(null);\n justResizedRef.current = true;\n requestAnimationFrame(() => {\n justResizedRef.current = false;\n });\n };\n\n const handlePointerUp = () => {\n const state = resizeRef.current;\n if (state && (state.start !== state.originalStart || state.end !== state.originalEnd)) {\n stableOnEventResize({\n eventId: state.eventId,\n newStart: state.start,\n newEnd: state.end,\n event: state.event,\n });\n }\n\n endGesture();\n };\n\n document.addEventListener('pointermove', handlePointerMove);\n document.addEventListener('pointerup', handlePointerUp);\n document.addEventListener('pointercancel', endGesture);\n\n return () => {\n document.body.style.userSelect = savedUserSelect;\n document.body.style.cursor = savedCursor;\n document.removeEventListener('pointermove', handlePointerMove);\n document.removeEventListener('pointerup', handlePointerUp);\n document.removeEventListener('pointercancel', endGesture);\n };\n }, [isResizing]);\n\n const isResizableEvent = useCallback(\n (event: ScheduleEventData) => {\n if (!enabled || mode === 'static' || event.display === 'background') {\n return false;\n }\n return canResizeEvent ? canResizeEvent(event) : true;\n },\n [enabled, mode, canResizeEvent]\n );\n\n const wasResizing = useCallback(() => justResizedRef.current, []);\n\n return {\n handleResizeStart,\n isResizing,\n resizingEventId: resizeState?.eventId ?? null,\n resizingEdge: resizeState?.edge ?? null,\n previewStart: resizeState?.start ?? null,\n previewEnd: resizeState?.end ?? null,\n isResizableEvent,\n wasResizing,\n };\n}\n"],"mappings":";;;;;;;;;;;;;AA+CA,SAAgB,sBAAsB,EACpC,UAAU,OACV,OAAO,WACP,eACA,kBAC6B;CAC7B,MAAM,CAAC,aAAa,mBAAA,GAAA,MAAA,SAAA,CAA+C,IAAI;CACvE,MAAM,aAAA,GAAA,MAAA,OAAA,CAAuC,IAAI;CACjD,MAAM,kBAAA,GAAA,MAAA,OAAA,CAAwB,KAAK;CACnC,MAAM,uBAAA,GAAA,MAAA,eAAA,CAAqC,wBAAwB,CAAC,EAAE;CAEtE,MAAM,qBAAA,GAAA,MAAA,YAAA,EACH,EAAE,OAAO,MAAM,OAAO,MAAM,mBAA4C;EACvE,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xB,IAAI,UAAU,MAAM,UAAU,MAAM,iBAAiB,MAAM,QAAQ,MAAM,cACvE,oBAAoB;IAClB,SAAS,MAAM;IACf,UAAU,MAAM;IAChB,QAAQ,MAAM;IACd,OAAO,MAAM;GACf,CAAC;GAGH,WAAW;EACb;EAEA,SAAS,iBAAiB,eAAe,iBAAiB;EAC1D,SAAS,iBAAiB,aAAa,eAAe;EACtD,SAAS,iBAAiB,iBAAiB,UAAU;EAErD,aAAa;GACX,SAAS,KAAK,MAAM,aAAa;GACjC,SAAS,KAAK,MAAM,SAAS;GAC7B,SAAS,oBAAoB,eAAe,iBAAiB;GAC7D,SAAS,oBAAoB,aAAa,eAAe;GACzD,SAAS,oBAAoB,iBAAiB,UAAU;EAC1D;CACF,GAAG,CAAC,UAAU,CAAC;CAEf,MAAM,oBAAA,GAAA,MAAA,YAAA,EACH,UAA6B;EAC5B,IAAI,CAAC,WAAW,SAAS,YAAY,MAAM,YAAY,cACrD,OAAO;EAET,OAAO,iBAAiB,eAAe,KAAK,IAAI;CAClD,GACA;EAAC;EAAS;EAAM;CAAc,CAChC;CAEA,MAAM,eAAA,GAAA,MAAA,YAAA,OAAgC,eAAe,SAAS,CAAC,CAAC;CAEhE,OAAO;EACL;EACA;EACA,iBAAiB,aAAa,WAAW;EACzC,cAAc,aAAa,QAAQ;EACnC,cAAc,aAAa,SAAS;EACpC,YAAY,aAAa,OAAO;EAChC;EACA;CACF;AACF"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
+ let dayjs = require("dayjs");
4
+ dayjs = require_runtime.__toESM(dayjs);
5
+ //#region packages/@mantine/schedule/src/utils/calculate-month-resize-dates/calculate-month-resize-dates.ts
6
+ const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
7
+ function isExclusiveMidnight(value) {
8
+ return value.hour() === 0 && value.minute() === 0 && value.second() === 0;
9
+ }
10
+ function withTimeOf(day, source) {
11
+ return day.startOf("day").hour(source.hour()).minute(source.minute()).second(source.second()).millisecond(source.millisecond());
12
+ }
13
+ function calculateMonthResizeDates({ event, edge, targetDay }) {
14
+ const originalStart = (0, dayjs.default)(event.start);
15
+ const originalEnd = (0, dayjs.default)(event.end);
16
+ const target = (0, dayjs.default)(targetDay).startOf("day");
17
+ const startDay = originalStart.startOf("day");
18
+ const endAtMidnight = isExclusiveMidnight(originalEnd);
19
+ const endDay = endAtMidnight ? originalEnd.startOf("day").subtract(1, "day") : originalEnd.startOf("day");
20
+ if (edge === "start") {
21
+ let newStart = withTimeOf(target.isAfter(endDay) ? endDay : target, originalStart);
22
+ if (!newStart.isBefore(originalEnd)) newStart = newStart.subtract(1, "day");
23
+ return {
24
+ start: newStart.format(DATE_TIME_FORMAT),
25
+ end: originalEnd.format(DATE_TIME_FORMAT)
26
+ };
27
+ }
28
+ const clampedDay = target.isBefore(startDay) ? startDay : target;
29
+ let newEnd = endAtMidnight ? clampedDay.add(1, "day").startOf("day") : withTimeOf(clampedDay, originalEnd);
30
+ if (!newEnd.isAfter(originalStart)) newEnd = newEnd.add(1, "day");
31
+ return {
32
+ start: originalStart.format(DATE_TIME_FORMAT),
33
+ end: newEnd.format(DATE_TIME_FORMAT)
34
+ };
35
+ }
36
+ //#endregion
37
+ exports.calculateMonthResizeDates = calculateMonthResizeDates;
38
+
39
+ //# sourceMappingURL=calculate-month-resize-dates.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-month-resize-dates.cjs","names":[],"sources":["../../../src/utils/calculate-month-resize-dates/calculate-month-resize-dates.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue, DateTimeStringValue, ScheduleEventData } from '../../types';\n\nexport type MonthResizeEdge = 'start' | 'end';\n\nexport interface CalculateMonthResizeDatesInput {\n /** The event being resized */\n event: ScheduleEventData;\n\n /** Edge of the event that is being dragged */\n edge: MonthResizeEdge;\n\n /** The day on which the dragged edge was released */\n targetDay: DateStringValue;\n}\n\nexport interface CalculateMonthResizeDatesResult {\n /** New start date for the event */\n start: DateTimeStringValue;\n\n /** New end date for the event */\n end: DateTimeStringValue;\n}\n\nconst DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';\n\nfunction isExclusiveMidnight(value: dayjs.Dayjs): boolean {\n return value.hour() === 0 && value.minute() === 0 && value.second() === 0;\n}\n\nfunction withTimeOf(day: dayjs.Dayjs, source: dayjs.Dayjs): dayjs.Dayjs {\n return day\n .startOf('day')\n .hour(source.hour())\n .minute(source.minute())\n .second(source.second())\n .millisecond(source.millisecond());\n}\n\nexport function calculateMonthResizeDates({\n event,\n edge,\n targetDay,\n}: CalculateMonthResizeDatesInput): CalculateMonthResizeDatesResult {\n const originalStart = dayjs(event.start);\n const originalEnd = dayjs(event.end);\n const target = dayjs(targetDay).startOf('day');\n\n const startDay = originalStart.startOf('day');\n const endAtMidnight = isExclusiveMidnight(originalEnd);\n const endDay = endAtMidnight\n ? originalEnd.startOf('day').subtract(1, 'day')\n : originalEnd.startOf('day');\n\n if (edge === 'start') {\n const clampedDay = target.isAfter(endDay) ? endDay : target;\n let newStart = withTimeOf(clampedDay, originalStart);\n\n if (!newStart.isBefore(originalEnd)) {\n newStart = newStart.subtract(1, 'day');\n }\n\n return {\n start: newStart.format(DATE_TIME_FORMAT),\n end: originalEnd.format(DATE_TIME_FORMAT),\n };\n }\n\n const clampedDay = target.isBefore(startDay) ? startDay : target;\n let newEnd = endAtMidnight\n ? clampedDay.add(1, 'day').startOf('day')\n : withTimeOf(clampedDay, originalEnd);\n\n if (!newEnd.isAfter(originalStart)) {\n newEnd = newEnd.add(1, 'day');\n }\n\n return {\n start: originalStart.format(DATE_TIME_FORMAT),\n end: newEnd.format(DATE_TIME_FORMAT),\n };\n}\n"],"mappings":";;;;;AAwBA,MAAM,mBAAmB;AAEzB,SAAS,oBAAoB,OAA6B;CACxD,OAAO,MAAM,KAAK,MAAM,KAAK,MAAM,OAAO,MAAM,KAAK,MAAM,OAAO,MAAM;AAC1E;A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