@mantine/schedule 9.7.2 → 9.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/DayView/DayView.cjs +45 -29
- package/cjs/components/DayView/DayView.cjs.map +1 -1
- package/cjs/components/DayView/DayView.module.cjs.map +1 -1
- package/cjs/components/MobileMonthView/MobileMonthView.cjs +54 -22
- package/cjs/components/MobileMonthView/MobileMonthView.cjs.map +1 -1
- package/cjs/components/MobileMonthView/MobileMonthView.module.cjs.map +1 -1
- package/cjs/components/MobileMonthView/get-mobile-month-view-weeks.cjs +32 -0
- package/cjs/components/MobileMonthView/get-mobile-month-view-weeks.cjs.map +1 -0
- package/cjs/components/ResourcesDayView/ResourcesDayView.cjs +15 -7
- package/cjs/components/ResourcesDayView/ResourcesDayView.cjs.map +1 -1
- package/cjs/components/ResourcesDayView/ResourcesDayView.module.cjs.map +1 -1
- package/cjs/components/ResourcesDayView/ResourcesDayViewColumn.cjs +11 -6
- package/cjs/components/ResourcesDayView/ResourcesDayViewColumn.cjs.map +1 -1
- package/cjs/components/ResourcesWeekView/ResourcesWeekView.cjs +15 -7
- package/cjs/components/ResourcesWeekView/ResourcesWeekView.cjs.map +1 -1
- package/cjs/components/ResourcesWeekView/ResourcesWeekView.module.cjs.map +1 -1
- package/cjs/components/ResourcesWeekView/ResourcesWeekViewRow.cjs +11 -6
- package/cjs/components/ResourcesWeekView/ResourcesWeekViewRow.cjs.map +1 -1
- package/cjs/components/Schedule/Schedule.cjs +2 -0
- package/cjs/components/Schedule/Schedule.cjs.map +1 -1
- package/cjs/components/WeekView/WeekView.cjs +29 -19
- package/cjs/components/WeekView/WeekView.cjs.map +1 -1
- package/cjs/components/WeekView/WeekView.module.cjs.map +1 -1
- package/cjs/components/WeekView/WeekViewDay.cjs +13 -7
- package/cjs/components/WeekView/WeekViewDay.cjs.map +1 -1
- package/cjs/components/YearView/YearView.cjs +1 -1
- package/cjs/components/YearView/YearView.cjs.map +1 -1
- package/cjs/components/YearView/YearViewMonth.cjs +1 -1
- package/cjs/components/YearView/YearViewMonth.cjs.map +1 -1
- package/cjs/index.cjs +10 -0
- package/cjs/utils/add-minutes-to-time/add-minutes-to-time.cjs +17 -0
- package/cjs/utils/add-minutes-to-time/add-minutes-to-time.cjs.map +1 -0
- package/cjs/utils/clamp-slot-label-interval/clamp-slot-label-interval.cjs +22 -0
- package/cjs/utils/clamp-slot-label-interval/clamp-slot-label-interval.cjs.map +1 -0
- package/cjs/utils/get-business-hours-mod/get-business-hours-mod.cjs +74 -17
- package/cjs/utils/get-business-hours-mod/get-business-hours-mod.cjs.map +1 -1
- package/cjs/utils/get-day-time-intervals/get-day-time-intervals.cjs +7 -2
- package/cjs/utils/get-day-time-intervals/get-day-time-intervals.cjs.map +1 -1
- package/cjs/utils/get-slot-label-groups/get-slot-label-groups.cjs +26 -0
- package/cjs/utils/get-slot-label-groups/get-slot-label-groups.cjs.map +1 -0
- package/cjs/{components/YearView → utils/get-visible-week-days}/get-visible-week-days.cjs +1 -1
- package/cjs/utils/get-visible-week-days/get-visible-week-days.cjs.map +1 -0
- package/esm/components/DayView/DayView.mjs +46 -30
- package/esm/components/DayView/DayView.mjs.map +1 -1
- package/esm/components/DayView/DayView.module.mjs.map +1 -1
- package/esm/components/MobileMonthView/MobileMonthView.mjs +54 -22
- package/esm/components/MobileMonthView/MobileMonthView.mjs.map +1 -1
- package/esm/components/MobileMonthView/MobileMonthView.module.mjs.map +1 -1
- package/esm/components/MobileMonthView/get-mobile-month-view-weeks.mjs +30 -0
- package/esm/components/MobileMonthView/get-mobile-month-view-weeks.mjs.map +1 -0
- package/esm/components/ResourcesDayView/ResourcesDayView.mjs +16 -8
- package/esm/components/ResourcesDayView/ResourcesDayView.mjs.map +1 -1
- package/esm/components/ResourcesDayView/ResourcesDayView.module.mjs.map +1 -1
- package/esm/components/ResourcesDayView/ResourcesDayViewColumn.mjs +12 -7
- package/esm/components/ResourcesDayView/ResourcesDayViewColumn.mjs.map +1 -1
- package/esm/components/ResourcesWeekView/ResourcesWeekView.mjs +16 -8
- package/esm/components/ResourcesWeekView/ResourcesWeekView.mjs.map +1 -1
- package/esm/components/ResourcesWeekView/ResourcesWeekView.module.mjs.map +1 -1
- package/esm/components/ResourcesWeekView/ResourcesWeekViewRow.mjs +12 -7
- package/esm/components/ResourcesWeekView/ResourcesWeekViewRow.mjs.map +1 -1
- package/esm/components/Schedule/Schedule.mjs +2 -0
- package/esm/components/Schedule/Schedule.mjs.map +1 -1
- package/esm/components/WeekView/WeekView.mjs +30 -20
- package/esm/components/WeekView/WeekView.mjs.map +1 -1
- package/esm/components/WeekView/WeekView.module.mjs.map +1 -1
- package/esm/components/WeekView/WeekViewDay.mjs +14 -8
- package/esm/components/WeekView/WeekViewDay.mjs.map +1 -1
- package/esm/components/YearView/YearView.mjs +1 -1
- package/esm/components/YearView/YearView.mjs.map +1 -1
- package/esm/components/YearView/YearViewMonth.mjs +1 -1
- package/esm/components/YearView/YearViewMonth.mjs.map +1 -1
- package/esm/index.mjs +6 -2
- package/esm/utils/add-minutes-to-time/add-minutes-to-time.mjs +17 -0
- package/esm/utils/add-minutes-to-time/add-minutes-to-time.mjs.map +1 -0
- package/esm/utils/clamp-slot-label-interval/clamp-slot-label-interval.mjs +22 -0
- package/esm/utils/clamp-slot-label-interval/clamp-slot-label-interval.mjs.map +1 -0
- package/esm/utils/get-business-hours-mod/get-business-hours-mod.mjs +74 -18
- package/esm/utils/get-business-hours-mod/get-business-hours-mod.mjs.map +1 -1
- package/esm/utils/get-day-time-intervals/get-day-time-intervals.mjs +7 -2
- package/esm/utils/get-day-time-intervals/get-day-time-intervals.mjs.map +1 -1
- package/esm/utils/get-slot-label-groups/get-slot-label-groups.mjs +26 -0
- package/esm/utils/get-slot-label-groups/get-slot-label-groups.mjs.map +1 -0
- package/esm/{components/YearView → utils/get-visible-week-days}/get-visible-week-days.mjs +1 -1
- package/esm/utils/get-visible-week-days/get-visible-week-days.mjs.map +1 -0
- package/lib/components/DayView/DayView.d.ts +3 -1
- package/lib/components/MobileMonthView/MobileMonthView.d.ts +2 -0
- package/lib/components/MobileMonthView/get-mobile-month-view-weeks.d.ts +11 -0
- package/lib/components/ResourcesDayView/ResourcesDayView.d.ts +1 -1
- package/lib/components/ResourcesDayView/ResourcesDayViewColumn.d.ts +2 -1
- package/lib/components/ResourcesWeekView/ResourcesWeekView.d.ts +1 -1
- package/lib/components/ResourcesWeekView/ResourcesWeekViewRow.d.ts +2 -1
- package/lib/components/Schedule/Schedule.d.ts +1 -1
- package/lib/components/WeekView/WeekView.d.ts +3 -1
- package/lib/utils/add-minutes-to-time/add-minutes-to-time.d.ts +1 -0
- package/lib/utils/clamp-slot-label-interval/clamp-slot-label-interval.d.ts +9 -0
- package/lib/utils/get-business-hours-mod/get-business-hours-mod.d.ts +24 -5
- package/lib/utils/get-day-time-intervals/get-day-time-intervals.d.ts +5 -1
- package/lib/utils/get-slot-label-groups/get-slot-label-groups.d.ts +15 -0
- package/lib/utils/index.d.ts +7 -2
- package/package.json +4 -4
- package/styles.css +175 -6
- package/styles.layer.css +175 -6
- package/cjs/components/YearView/get-visible-week-days.cjs.map +0 -1
- package/esm/components/YearView/get-visible-week-days.mjs.map +0 -1
- /package/lib/{components/YearView → utils/get-visible-week-days}/get-visible-week-days.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YearViewMonth.cjs","names":["useDatesContext","useMantineTheme","getHiddenWeekendColumns","getWeekdaysNames","getMonthDays","getVisibleWeekDays","isSameMonth","getThemeColor","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 {\n DateLabelFormat,\n DateStringValue,\n DayOfWeek,\n ScheduleEventData,\n ScheduleMode,\n} 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 type YearViewRenderDay = (\n date: DateStringValue,\n events: ScheduleEventData[]\n) => React.ReactNode;\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 /**\n * A function to replace the entire content of a day cell, called with the day date\n * and the events grouped on that day – the same list that is used to render the default\n * indicators. When set, default event indicators are not rendered.\n */\n renderDay?: YearViewRenderDay;\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 renderDay,\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 dayContent =\n typeof renderDay === 'function' ? (\n renderDay(dayjs(date).format('YYYY-MM-DD'), dayEvents)\n ) : (\n <>\n {dayjs(date).format('D')}\n\n <div {...getStyles('yearViewDayIndicators')}>\n {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 </div>\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 {dayContent}\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":";;;;;;;;;;;;;;;AAoHA,SAAgB,cAAc,EAC5B,OACA,WACA,mBAAmB,QACnB,iBACA,cACA,QACA,gBACA,eACA,aACA,iBACA,aACA,YACA,mBACA,cACA,oBACA,gBACA,eACA,MACA,iBACA,WACA,aACA,gBACA,iBACqB;CACrB,MAAM,OAAA,GAAMA,eAAAA,gBAAAA,CAAgB;CAC5B,MAAM,SAAA,GAAQC,cAAAA,gBAAAA,CAAgB;CAC9B,MAAM,SAAA,GAAQ,MAAA,QAAA,CAAM;CAEpB,MAAM,yBAAyB,IAAI,kBAAkB,cAAc;CACnE,MAAM,sBAAsB,IAAI,eAAe,WAAW;CAC1D,MAAM,gBAAgB,IAAI,IACxBC,8BAAAA,wBAAwB;EACtB,aAAa;EACb,gBAAgB;EAChB;CACF,CAAC,CACH;CAEA,MAAM,WAAW,eACbC,2BAAAA,iBAAiB;EACf,QAAQ,IAAI,UAAU,MAAM;EAC5B,QAAQ;EACR,gBAAgB;CAClB,CAAC,CAAC,CACC,QAAQ,GAAG,UAAU,CAAC,cAAc,IAAI,KAAK,CAAC,CAAC,CAC/C,KAAK,KAAK,UACT,iBAAA,GAAA,MAAA,cAAA,CAAC,OAAD;EAAK,GAAI,UAAU,iBAAiB;EAAG,KAAK;CAEvC,GADF,GACE,CACN,IACH;CAEJ,MAAM,QAAQC,uBAAAA,aAAa;EACzB,QAAA,GAAO,MAAA,QAAA,CAAM,KAAK,CAAC,CAAC,OAAO,YAAY;EACvC,gBAAgB;EAChB,iBAAiB;CACnB,CAAC,CAAC,CAAC,KAAK,MAAM,cAAc;EAO1B,MAAM,OANcC,8BAAAA,mBAAmB;GACrC;G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,YAAY,GAAG,KAAK;IAC9D,gBAAgB,UAAU,KAAK;GACjC;GAEN,KAAK,EAAE,QAAQ,SAAS,SAAS;GACjC,UAAU,SAAS,WAAW,KAAK;GACnC,GAAI,UAAU,sBAAsB;IAClC,WAAW,gBAAgB;IAC3B,OAAO,gBAAgB;GACzB,CAAC;GAEA,UAAA;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;EAR/B,UAAA;GAUE,iBAAA,GAAA,kBAAA,IAAA,CAACF,cAAAA,gBAAD;IACE,SACE,SAAS,WACL,KAAA,KACC,UAAU,gBAAA,GAAe,MAAA,QAAA,CAAM,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;IAEnCG,UAAAA,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;IAArC,UAAA,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":["useDatesContext","useMantineTheme","getHiddenWeekendColumns","getWeekdaysNames","getMonthDays","getVisibleWeekDays","isSameMonth","getThemeColor","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 {\n DateLabelFormat,\n DateStringValue,\n DayOfWeek,\n ScheduleEventData,\n ScheduleMode,\n} from '../../types';\nimport {\n formatDate,\n getMonthDays,\n getWeekdaysNames,\n getWeekNumber,\n isSameMonth,\n} from '../../utils';\nimport {\n getHiddenWeekendColumns,\n getVisibleWeekDays,\n} from '../../utils/get-visible-week-days/get-visible-week-days';\nimport { GroupedEvents } from './get-year-view-events/get-year-view-events';\nimport type { YearViewFactory } from './YearView';\n\nexport type YearViewRenderDay = (\n date: DateStringValue,\n events: ScheduleEventData[]\n) => React.ReactNode;\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 /**\n * A function to replace the entire content of a day cell, called with the day date\n * and the events grouped on that day – the same list that is used to render the default\n * indicators. When set, default event indicators are not rendered.\n */\n renderDay?: YearViewRenderDay;\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 renderDay,\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 dayContent =\n typeof renderDay === 'function' ? (\n renderDay(dayjs(date).format('YYYY-MM-DD'), dayEvents)\n ) : (\n <>\n {dayjs(date).format('D')}\n\n <div {...getStyles('yearViewDayIndicators')}>\n {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 </div>\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 {dayContent}\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":";;;;;;;;;;;;;;;AAuHA,SAAgB,cAAc,EAC5B,OACA,WACA,mBAAmB,QACnB,iBACA,cACA,QACA,gBACA,eACA,aACA,iBACA,aACA,YACA,mBACA,cACA,oBACA,gBACA,eACA,MACA,iBACA,WACA,aACA,gBACA,iBACqB;CACrB,MAAM,OAAA,GAAMA,eAAAA,gBAAAA,CAAgB;CAC5B,MAAM,SAAA,GAAQC,cAAAA,gBAAAA,CAAgB;CAC9B,MAAM,SAAA,GAAQ,MAAA,QAAA,CAAM;CAEpB,MAAM,yBAAyB,IAAI,kBAAkB,cAAc;CACnE,MAAM,sBAAsB,IAAI,eAAe,WAAW;CAC1D,MAAM,gBAAgB,IAAI,IACxBC,8BAAAA,wBAAwB;EACtB,aAAa;EACb,gBAAgB;EAChB;CACF,CAAC,CACH;CAEA,MAAM,WAAW,eACbC,2BAAAA,iBAAiB;EACf,QAAQ,IAAI,UAAU,MAAM;EAC5B,QAAQ;EACR,gBAAgB;CAClB,CAAC,CAAC,CACC,QAAQ,GAAG,UAAU,CAAC,cAAc,IAAI,KAAK,CAAC,CAAC,CAC/C,KAAK,KAAK,UACT,iBAAA,GAAA,MAAA,cAAA,CAAC,OAAD;EAAK,GAAI,UAAU,iBAAiB;EAAG,KAAK;CAEvC,GADF,GACE,CACN,IACH;CAEJ,MA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package/cjs/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const require_is_before_max_date = require("./utils/is-before-max-date/is-before
|
|
|
11
11
|
const require_is_same_month = require("./utils/is-same-month/is-same-month.cjs");
|
|
12
12
|
const require_get_months_by_quarter = require("./utils/get-months-by-quarter/get-months-by-quarter.cjs");
|
|
13
13
|
const require_clamp_interval_minutes = require("./utils/clamp-interval-minutes/clamp-interval-minutes.cjs");
|
|
14
|
+
const require_clamp_slot_label_interval = require("./utils/clamp-slot-label-interval/clamp-slot-label-interval.cjs");
|
|
14
15
|
const require_parse_time_string = require("./utils/parse-time-string/parse-time-string.cjs");
|
|
15
16
|
const require_to_time_string = require("./utils/to-time-string/to-time-string.cjs");
|
|
16
17
|
const require_get_day_time_intervals = require("./utils/get-day-time-intervals/get-day-time-intervals.cjs");
|
|
@@ -20,6 +21,7 @@ const require_get_months_list = require("./utils/get-months-list/get-months-list
|
|
|
20
21
|
const require_get_years_list = require("./utils/get-years-list/get-years-list.cjs");
|
|
21
22
|
const require_next_week = require("./utils/next-week/next-week.cjs");
|
|
22
23
|
const require_previous_week = require("./utils/previous-week/previous-week.cjs");
|
|
24
|
+
const require_get_slot_label_groups = require("./utils/get-slot-label-groups/get-slot-label-groups.cjs");
|
|
23
25
|
const require_get_current_time_position = require("./utils/get-current-time-position/get-current-time-position.cjs");
|
|
24
26
|
const require_is_in_time_range = require("./utils/is-in-time-range/is-in-time-range.cjs");
|
|
25
27
|
const require_is_all_day_event = require("./utils/is-all-day-event/is-all-day-event.cjs");
|
|
@@ -38,6 +40,7 @@ const require_calculate_month_drop_date = require("./utils/calculate-month-drop-
|
|
|
38
40
|
const require_get_business_hours_mod = require("./utils/get-business-hours-mod/get-business-hours-mod.cjs");
|
|
39
41
|
const require_expand_recurring_events = require("./utils/expand-recurring-events/expand-recurring-events.cjs");
|
|
40
42
|
const require_get_ordered_resources = require("./utils/get-ordered-resources/get-ordered-resources.cjs");
|
|
43
|
+
const require_add_minutes_to_time = require("./utils/add-minutes-to-time/add-minutes-to-time.cjs");
|
|
41
44
|
const require_handle_resources_grid_key_down = require("./utils/handle-resources-grid-key-down/handle-resources-grid-key-down.cjs");
|
|
42
45
|
const require_get_group_to_resource_id_map = require("./utils/get-group-to-resource-id-map/get-group-to-resource-id-map.cjs");
|
|
43
46
|
const require_get_index_from_drag_point = require("./utils/get-index-from-drag-point/get-index-from-drag-point.cjs");
|
|
@@ -45,6 +48,7 @@ const require_get_day_relative_percent = require("./utils/get-day-relative-perce
|
|
|
45
48
|
const require_get_overlap_clusters = require("./utils/get-overlap-clusters/get-overlap-clusters.cjs");
|
|
46
49
|
const require_apply_cascade_layout = require("./utils/apply-cascade-layout/apply-cascade-layout.cjs");
|
|
47
50
|
const require_is_event_placement_allowed = require("./utils/is-event-placement-allowed/is-event-placement-allowed.cjs");
|
|
51
|
+
const require_get_visible_week_days = require("./utils/get-visible-week-days/get-visible-week-days.cjs");
|
|
48
52
|
const require_AgendaView = require("./components/AgendaView/AgendaView.cjs");
|
|
49
53
|
const require_CurrentTimeIndicator = require("./components/CurrentTimeIndicator/CurrentTimeIndicator.cjs");
|
|
50
54
|
const require_DragContext = require("./components/DragContext/DragContext.cjs");
|
|
@@ -80,19 +84,23 @@ exports.ScheduleEvent = require_ScheduleEvent.ScheduleEvent;
|
|
|
80
84
|
exports.ScheduleHeader = require_ScheduleHeader.ScheduleHeader;
|
|
81
85
|
exports.WeekView = require_WeekView.WeekView;
|
|
82
86
|
exports.YearView = require_YearView.YearView;
|
|
87
|
+
exports.addMinutesToTime = require_add_minutes_to_time.addMinutesToTime;
|
|
83
88
|
exports.applyCascadeLayout = require_apply_cascade_layout.applyCascadeLayout;
|
|
84
89
|
exports.calculateDropTime = require_calculate_drop_time.calculateDropTime;
|
|
85
90
|
exports.calculateMonthDropDate = require_calculate_month_drop_date.calculateMonthDropDate;
|
|
86
91
|
exports.clampIntervalMinutes = require_clamp_interval_minutes.clampIntervalMinutes;
|
|
92
|
+
exports.clampSlotLabelInterval = require_clamp_slot_label_interval.clampSlotLabelInterval;
|
|
87
93
|
exports.expandRecurringEvents = require_expand_recurring_events.expandRecurringEvents;
|
|
88
94
|
exports.formatDate = require_format_date.formatDate;
|
|
89
95
|
exports.getBusinessHoursMod = require_get_business_hours_mod.getBusinessHoursMod;
|
|
96
|
+
exports.getBusinessHoursState = require_get_business_hours_mod.getBusinessHoursState;
|
|
90
97
|
exports.getCurrentTimePosition = require_get_current_time_position.getCurrentTimePosition;
|
|
91
98
|
exports.getDayPosition = require_get_day_position.getDayPosition;
|
|
92
99
|
exports.getDayRelativePercent = require_get_day_relative_percent.getDayRelativePercent;
|
|
93
100
|
exports.getDayTimeIntervals = require_get_day_time_intervals.getDayTimeIntervals;
|
|
94
101
|
exports.getEndOfWeek = require_get_end_of_week.getEndOfWeek;
|
|
95
102
|
exports.getGroupToResourceIdMap = require_get_group_to_resource_id_map.getGroupToResourceIdMap;
|
|
103
|
+
exports.getHiddenWeekendColumns = require_get_visible_week_days.getHiddenWeekendColumns;
|
|
96
104
|
exports.getIndexFromDragPoint = require_get_index_from_drag_point.getIndexFromDragPoint;
|
|
97
105
|
exports.getLabel = require_labels.getLabel;
|
|
98
106
|
exports.getMonthDays = require_get_month_days.getMonthDays;
|
|
@@ -101,9 +109,11 @@ exports.getMonthsByQuarter = require_get_months_by_quarter.getMonthsByQuarter;
|
|
|
101
109
|
exports.getMonthsList = require_get_months_list.getMonthsList;
|
|
102
110
|
exports.getOrderedResources = require_get_ordered_resources.getOrderedResources;
|
|
103
111
|
exports.getOverlapClusters = require_get_overlap_clusters.getOverlapClusters;
|
|
112
|
+
exports.getSlotLabelGroups = require_get_slot_label_groups.getSlotLabelGroups;
|
|
104
113
|
exports.getStartOfWeek = require_get_start_of_week.getStartOfWeek;
|
|
105
114
|
exports.getTimeAxisEventStyle = require_get_time_axis_event_style.getTimeAxisEventStyle;
|
|
106
115
|
exports.getVisibleEvents = require_get_visible_events.getVisibleEvents;
|
|
116
|
+
exports.getVisibleWeekDays = require_get_visible_week_days.getVisibleWeekDays;
|
|
107
117
|
exports.getWeekDays = require_get_week_days.getWeekDays;
|
|
108
118
|
exports.getWeekNumber = require_get_week_number.getWeekNumber;
|
|
109
119
|
exports.getWeekdaysNames = require_get_weekdays_names.getWeekdaysNames;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_parse_time_string = require("../parse-time-string/parse-time-string.cjs");
|
|
3
|
+
const require_to_time_string = require("../to-time-string/to-time-string.cjs");
|
|
4
|
+
//#region packages/@mantine/schedule/src/utils/add-minutes-to-time/add-minutes-to-time.ts
|
|
5
|
+
function addMinutesToTime(time, minutes) {
|
|
6
|
+
const parsed = require_parse_time_string.parseTimeString(time);
|
|
7
|
+
const total = parsed.hours * 3600 + parsed.minutes * 60 + parsed.seconds + minutes * 60;
|
|
8
|
+
return require_to_time_string.toTimeString({
|
|
9
|
+
hours: Math.floor(total / 3600),
|
|
10
|
+
minutes: Math.floor(total % 3600 / 60),
|
|
11
|
+
seconds: total % 60
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.addMinutesToTime = addMinutesToTime;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=add-minutes-to-time.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-minutes-to-time.cjs","names":["parseTimeString","toTimeString"],"sources":["../../../src/utils/add-minutes-to-time/add-minutes-to-time.ts"],"sourcesContent":["import { parseTimeString } from '../parse-time-string/parse-time-string';\nimport { toTimeString } from '../to-time-string/to-time-string';\n\nexport function addMinutesToTime(time: string, minutes: number) {\n const parsed = parseTimeString(time);\n const total = parsed.hours * 3600 + parsed.minutes * 60 + parsed.seconds + minutes * 60;\n\n return toTimeString({\n hours: Math.floor(total / 3600),\n minutes: Math.floor((total % 3600) / 60),\n seconds: total % 60,\n });\n}\n"],"mappings":";;;;AAGA,SAAgB,iBAAiB,MAAc,SAAiB;CAC9D,MAAM,SAASA,0BAAAA,gBAAgB,IAAI;CACnC,MAAM,QAAQ,OAAO,QAAQ,OAAO,OAAO,UAAU,KAAK,OAAO,UAAU,UAAU;CAErF,OAAOC,uBAAAA,aAAa;EAClB,OAAO,KAAK,MAAM,QAAQ,IAAI;EAC9B,SAAS,KAAK,MAAO,QAAQ,OAAQ,EAAE;EACvC,SAAS,QAAQ;CACnB,CAAC;AACH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_clamp_interval_minutes = require("../clamp-interval-minutes/clamp-interval-minutes.cjs");
|
|
3
|
+
//#region packages/@mantine/schedule/src/utils/clamp-slot-label-interval/clamp-slot-label-interval.ts
|
|
4
|
+
/**
|
|
5
|
+
* Clamps slot label interval so that every label lines up with a slot boundary:
|
|
6
|
+
*
|
|
7
|
+
* - Non-positive and non-finite values fall back to `60`.
|
|
8
|
+
* - The value is clamped with the same rules as `intervalMinutes` (see `clampIntervalMinutes`).
|
|
9
|
+
* - The result is rounded up to the next multiple of the clamped `intervalMinutes` that
|
|
10
|
+
* satisfies the same rules and is never smaller than it. It is capped to a single day (`1440`).
|
|
11
|
+
*/
|
|
12
|
+
function clampSlotLabelInterval(slotLabelInterval, intervalMinutes) {
|
|
13
|
+
const interval = require_clamp_interval_minutes.clampIntervalMinutes(intervalMinutes);
|
|
14
|
+
const label = require_clamp_interval_minutes.clampIntervalMinutes(Number.isFinite(slotLabelInterval) && slotLabelInterval > 0 ? slotLabelInterval : 60);
|
|
15
|
+
let result = Math.ceil(label / interval) * interval;
|
|
16
|
+
while (result < 1440 && require_clamp_interval_minutes.clampIntervalMinutes(result) !== result) result += interval;
|
|
17
|
+
return Math.min(1440, result);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.clampSlotLabelInterval = clampSlotLabelInterval;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=clamp-slot-label-interval.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp-slot-label-interval.cjs","names":["clampIntervalMinutes"],"sources":["../../../src/utils/clamp-slot-label-interval/clamp-slot-label-interval.ts"],"sourcesContent":["import { clampIntervalMinutes } from '../clamp-interval-minutes/clamp-interval-minutes';\n\n/**\n * Clamps slot label interval so that every label lines up with a slot boundary:\n *\n * - Non-positive and non-finite values fall back to `60`.\n * - The value is clamped with the same rules as `intervalMinutes` (see `clampIntervalMinutes`).\n * - The result is rounded up to the next multiple of the clamped `intervalMinutes` that\n * satisfies the same rules and is never smaller than it. It is capped to a single day (`1440`).\n */\nexport function clampSlotLabelInterval(slotLabelInterval: number, intervalMinutes: number): number {\n const interval = clampIntervalMinutes(intervalMinutes);\n const label = clampIntervalMinutes(\n Number.isFinite(slotLabelInterval) && slotLabelInterval > 0 ? slotLabelInterval : 60\n );\n\n let result = Math.ceil(label / interval) * interval;\n\n while (result < 1440 && clampIntervalMinutes(result) !== result) {\n result += interval;\n }\n\n return Math.min(1440, result);\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,uBAAuB,mBAA2B,iBAAiC;CACjG,MAAM,WAAWA,+BAAAA,qBAAqB,eAAe;CACrD,MAAM,QAAQA,+BAAAA,qBACZ,OAAO,SAAS,iBAAiB,KAAK,oBAAoB,IAAI,oBAAoB,EACpF;CAEA,IAAI,SAAS,KAAK,KAAK,QAAQ,QAAQ,IAAI;CAE3C,OAAO,SAAS,QAAQA,+BAAAA,qBAAqB,MAAM,MAAM,QACvD,UAAU;CAGZ,OAAO,KAAK,IAAI,MAAM,MAAM;AAC9B"}
|
|
@@ -1,42 +1,99 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
const require_parse_time_string = require("../parse-time-string/parse-time-string.cjs");
|
|
2
3
|
//#region packages/@mantine/schedule/src/utils/get-business-hours-mod/get-business-hours-mod.ts
|
|
4
|
+
const NONE = {
|
|
5
|
+
"business-hours": false,
|
|
6
|
+
"non-business-hours": false,
|
|
7
|
+
"partial-business-hours": false
|
|
8
|
+
};
|
|
9
|
+
const INSIDE = {
|
|
10
|
+
"business-hours": true,
|
|
11
|
+
"non-business-hours": false,
|
|
12
|
+
"partial-business-hours": false
|
|
13
|
+
};
|
|
14
|
+
const OUTSIDE = {
|
|
15
|
+
"business-hours": false,
|
|
16
|
+
"non-business-hours": true,
|
|
17
|
+
"partial-business-hours": false
|
|
18
|
+
};
|
|
19
|
+
const PARTIAL = {
|
|
20
|
+
"business-hours": false,
|
|
21
|
+
"non-business-hours": false,
|
|
22
|
+
"partial-business-hours": true
|
|
23
|
+
};
|
|
3
24
|
function isBusinessHoursRange(value) {
|
|
4
25
|
return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "string";
|
|
5
26
|
}
|
|
27
|
+
function toSeconds(time) {
|
|
28
|
+
const { hours, minutes, seconds } = require_parse_time_string.parseTimeString(time);
|
|
29
|
+
return hours * 3600 + minutes * 60 + seconds;
|
|
30
|
+
}
|
|
31
|
+
function toPercent(value) {
|
|
32
|
+
return `${Math.round(value * 1e4) / 100}%`;
|
|
33
|
+
}
|
|
6
34
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
* @param businessHours - Tuple of [start, end] times in HH:mm:ss format, or per-day record keyed by day of the week
|
|
10
|
-
* @param highlightBusinessHours - Whether to highlight business hours
|
|
11
|
-
* @param dayOfWeek - Day of the week (0 – Sunday, 6 – Saturday), used to resolve per-day business hours
|
|
12
|
-
* @returns Modifier object for styling business/non-business hours
|
|
35
|
+
* Resolves business hours state of a time interval
|
|
36
|
+
* @returns `mod` – modifiers for styling business/non-business/partial intervals, `vars` – CSS variables with the business hours boundaries inside a partial interval
|
|
13
37
|
*/
|
|
14
|
-
function
|
|
38
|
+
function getBusinessHoursState({ time, endTime, businessHours, highlightBusinessHours, dayOfWeek }) {
|
|
15
39
|
if (!highlightBusinessHours || !businessHours) return {
|
|
16
|
-
|
|
17
|
-
|
|
40
|
+
mod: NONE,
|
|
41
|
+
vars: void 0
|
|
18
42
|
};
|
|
19
43
|
let range;
|
|
20
44
|
if (isBusinessHoursRange(businessHours)) range = businessHours;
|
|
21
45
|
else {
|
|
22
46
|
if (dayOfWeek === void 0) return {
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
mod: NONE,
|
|
48
|
+
vars: void 0
|
|
25
49
|
};
|
|
26
50
|
range = businessHours[dayOfWeek] ?? null;
|
|
27
51
|
}
|
|
28
52
|
if (!range) return {
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
mod: OUTSIDE,
|
|
54
|
+
vars: void 0
|
|
55
|
+
};
|
|
56
|
+
const start = toSeconds(time);
|
|
57
|
+
const rangeStart = toSeconds(range[0]);
|
|
58
|
+
const rangeEnd = toSeconds(range[1]);
|
|
59
|
+
const end = endTime === void 0 ? start : toSeconds(endTime);
|
|
60
|
+
if (end <= start) return {
|
|
61
|
+
mod: start >= rangeStart && start < rangeEnd ? INSIDE : OUTSIDE,
|
|
62
|
+
vars: void 0
|
|
63
|
+
};
|
|
64
|
+
const overlapStart = Math.max(start, rangeStart);
|
|
65
|
+
const overlapEnd = Math.min(end, rangeEnd);
|
|
66
|
+
if (overlapEnd <= overlapStart) return {
|
|
67
|
+
mod: OUTSIDE,
|
|
68
|
+
vars: void 0
|
|
31
69
|
};
|
|
32
|
-
|
|
33
|
-
|
|
70
|
+
if (overlapStart === start && overlapEnd === end) return {
|
|
71
|
+
mod: INSIDE,
|
|
72
|
+
vars: void 0
|
|
73
|
+
};
|
|
74
|
+
const duration = end - start;
|
|
34
75
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
76
|
+
mod: PARTIAL,
|
|
77
|
+
vars: {
|
|
78
|
+
"--business-hours-from": toPercent((overlapStart - start) / duration),
|
|
79
|
+
"--business-hours-to": toPercent((overlapEnd - start) / duration)
|
|
80
|
+
}
|
|
37
81
|
};
|
|
38
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Determines if a given time interval is within business hours and returns modifier object
|
|
85
|
+
* @param time - Start time in HH:mm:ss format
|
|
86
|
+
* @param endTime - End time in HH:mm:ss format, enables the partial state for intervals that contain a boundary
|
|
87
|
+
* @param businessHours - Tuple of [start, end] times in HH:mm:ss or HH:mm format, or per-day record keyed by day of the week
|
|
88
|
+
* @param highlightBusinessHours - Whether to highlight business hours
|
|
89
|
+
* @param dayOfWeek - Day of the week (0 – Sunday, 6 – Saturday), used to resolve per-day business hours
|
|
90
|
+
* @returns Modifier object for styling business/non-business hours
|
|
91
|
+
*/
|
|
92
|
+
function getBusinessHoursMod(input) {
|
|
93
|
+
return getBusinessHoursState(input).mod;
|
|
94
|
+
}
|
|
39
95
|
//#endregion
|
|
40
96
|
exports.getBusinessHoursMod = getBusinessHoursMod;
|
|
97
|
+
exports.getBusinessHoursState = getBusinessHoursState;
|
|
41
98
|
|
|
42
99
|
//# sourceMappingURL=get-business-hours-mod.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-business-hours-mod.cjs","names":[],"sources":["../../../src/utils/get-business-hours-mod/get-business-hours-mod.ts"],"sourcesContent":["import { DayOfWeek } from '../../types';\n\n/** Business hours range in `HH:mm:ss` format */\nexport type BusinessHoursRange = [string, string];\n\n/** Per-day business hours map keyed by day of the week (0 – Sunday, 6 – Saturday). `null` marks a day as fully outside business hours. */\nexport type BusinessHoursPerDay = Partial<Record<DayOfWeek, BusinessHoursRange | null>>;\n\n/** Business hours value – tuple applies to every day, record configures business hours per day */\nexport type BusinessHoursValue = BusinessHoursRange | BusinessHoursPerDay;\n\nexport interface GetBusinessHoursModInput {\n time: string;\n businessHours?: BusinessHoursValue;\n highlightBusinessHours?: boolean;\n dayOfWeek?: DayOfWeek;\n}\n\nexport interface BusinessHoursMod {\n 'business-hours': boolean;\n 'non-business-hours': boolean;\n}\n\nfunction isBusinessHoursRange(value: BusinessHoursValue): value is BusinessHoursRange {\n return (\n Array.isArray(value) &&\n value.length === 2 &&\n typeof value[0] === 'string' &&\n typeof value[1] === 'string'\n );\n}\n\
|
|
1
|
+
{"version":3,"file":"get-business-hours-mod.cjs","names":["parseTimeString"],"sources":["../../../src/utils/get-business-hours-mod/get-business-hours-mod.ts"],"sourcesContent":["import { DayOfWeek } from '../../types';\nimport { parseTimeString } from '../parse-time-string/parse-time-string';\n\n/** Business hours range in `HH:mm:ss` or `HH:mm` format */\nexport type BusinessHoursRange = [string, string];\n\n/** Per-day business hours map keyed by day of the week (0 – Sunday, 6 – Saturday). `null` marks a day as fully outside business hours. */\nexport type BusinessHoursPerDay = Partial<Record<DayOfWeek, BusinessHoursRange | null>>;\n\n/** Business hours value – tuple applies to every day, record configures business hours per day */\nexport type BusinessHoursValue = BusinessHoursRange | BusinessHoursPerDay;\n\nexport interface GetBusinessHoursModInput {\n /** Start of the interval in `HH:mm:ss` format */\n time: string;\n\n /** End of the interval in `HH:mm:ss` format. When set, intervals that contain a business hours boundary get the partial state. */\n endTime?: string;\n\n businessHours?: BusinessHoursValue;\n highlightBusinessHours?: boolean;\n dayOfWeek?: DayOfWeek;\n}\n\nexport interface BusinessHoursMod {\n 'business-hours': boolean;\n 'non-business-hours': boolean;\n 'partial-business-hours': boolean;\n}\n\n/** CSS variables applied to partial intervals, percentage of the interval where business hours start and end */\nexport type BusinessHoursVars = {\n '--business-hours-from': string;\n '--business-hours-to': string;\n};\n\nexport interface BusinessHoursState {\n mod: BusinessHoursMod;\n vars: BusinessHoursVars | undefined;\n}\n\nconst NONE: BusinessHoursMod = {\n 'business-hours': false,\n 'non-business-hours': false,\n 'partial-business-hours': false,\n};\n\nconst INSIDE: BusinessHoursMod = {\n 'business-hours': true,\n 'non-business-hours': false,\n 'partial-business-hours': false,\n};\n\nconst OUTSIDE: BusinessHoursMod = {\n 'business-hours': false,\n 'non-business-hours': true,\n 'partial-business-hours': false,\n};\n\nconst PARTIAL: BusinessHoursMod = {\n 'business-hours': false,\n 'non-business-hours': false,\n 'partial-business-hours': true,\n};\n\nfunction isBusinessHoursRange(value: BusinessHoursValue): value is BusinessHoursRange {\n return (\n Array.isArray(value) &&\n value.length === 2 &&\n typeof value[0] === 'string' &&\n typeof value[1] === 'string'\n );\n}\n\nfunction toSeconds(time: string) {\n const { hours, minutes, seconds } = parseTimeString(time);\n return hours * 3600 + minutes * 60 + seconds;\n}\n\nfunction toPercent(value: number) {\n return `${Math.round(value * 10000) / 100}%`;\n}\n\n/**\n * Resolves business hours state of a time interval\n * @returns `mod` – modifiers for styling business/non-business/partial intervals, `vars` – CSS variables with the business hours boundaries inside a partial interval\n */\nexport function getBusinessHoursState({\n time,\n endTime,\n businessHours,\n highlightBusinessHours,\n dayOfWeek,\n}: GetBusinessHoursModInput): BusinessHoursState {\n if (!highlightBusinessHours || !businessHours) {\n return { mod: NONE, vars: undefined };\n }\n\n let range: BusinessHoursRange | null;\n if (isBusinessHoursRange(businessHours)) {\n range = businessHours;\n } else {\n if (dayOfWeek === undefined) {\n return { mod: NONE, vars: undefined };\n }\n range = businessHours[dayOfWeek] ?? null;\n }\n\n if (!range) {\n return { mod: OUTSIDE, vars: undefined };\n }\n\n const start = toSeconds(time);\n const rangeStart = toSeconds(range[0]);\n const rangeEnd = toSeconds(range[1]);\n const end = endTime === undefined ? start : toSeconds(endTime);\n\n if (end <= start) {\n const isInside = start >= rangeStart && start < rangeEnd;\n return { mod: isInside ? INSIDE : OUTSIDE, vars: undefined };\n }\n\n const overlapStart = Math.max(start, rangeStart);\n const overlapEnd = Math.min(end, rangeEnd);\n\n if (overlapEnd <= overlapStart) {\n return { mod: OUTSIDE, vars: undefined };\n }\n\n if (overlapStart === start && overlapEnd === end) {\n return { mod: INSIDE, vars: undefined };\n }\n\n const duration = end - start;\n\n return {\n mod: PARTIAL,\n vars: {\n '--business-hours-from': toPercent((overlapStart - start) / duration),\n '--business-hours-to': toPercent((overlapEnd - start) / duration),\n },\n };\n}\n\n/**\n * Determines if a given time interval is within business hours and returns modifier object\n * @param time - Start time in HH:mm:ss format\n * @param endTime - End time in HH:mm:ss format, enables the partial state for intervals that contain a boundary\n * @param businessHours - Tuple of [start, end] times in HH:mm:ss or HH:mm format, or per-day record keyed by day of the week\n * @param highlightBusinessHours - Whether to highlight business hours\n * @param dayOfWeek - Day of the week (0 – Sunday, 6 – Saturday), used to resolve per-day business hours\n * @returns Modifier object for styling business/non-business hours\n */\nexport function getBusinessHoursMod(input: GetBusinessHoursModInput): BusinessHoursMod {\n return getBusinessHoursState(input).mod;\n}\n"],"mappings":";;;AAyCA,MAAM,OAAyB;CAC7B,kBAAkB;CAClB,sBAAsB;CACtB,0BAA0B;AAC5B;AAEA,MAAM,SAA2B;CAC/B,kBAAkB;CAClB,sBAAsB;CACtB,0BAA0B;AAC5B;AAEA,MAAM,UAA4B;CAChC,kBAAkB;CAClB,sBAAsB;CACtB,0BAA0B;AAC5B;AAEA,MAAM,UAA4B;CAChC,kBAAkB;CAClB,sBAAsB;CACtB,0BAA0B;AAC5B;AAEA,SAAS,qBAAqB,OAAwD;CACpF,OACE,MAAM,QAAQ,KAAK,KACnB,MAAM,WAAW,KACjB,OAAO,MAAM,OAAO,YACpB,OAAO,MAAM,OAAO;AAExB;AAEA,SAAS,UAAU,MAAc;CAC/B,MAAM,EAAE,OAAO,SAAS,YAAYA,0BAAAA,gBAAgB,IAAI;CACxD,OAAO,QAAQ,OAAO,UAAU,KAAK;AACvC;AAEA,SAAS,UAAU,OAAe;CAChC,OAAO,GAAG,KAAK,MAAM,QAAQ,GAAK,IAAI,IAAI;AAC5C;;;;;AAMA,SAAgB,sBAAsB,EACpC,MACA,SACA,eACA,wBACA,aAC+C;CAC/C,IAAI,CAAC,0BAA0B,CAAC,eAC9B,OAAO;EAAE,KAAK;EAAM,MAAM,KAAA;CAAU;CAGtC,IAAI;CACJ,IAAI,qBAAqB,aAAa,GACpC,QAAQ;MACH;EACL,IAAI,cAAc,KAAA,GAChB,OAAO;GAAE,KAAK;GAAM,MAAM,KAAA;EAAU;EAEtC,QAAQ,cAAc,cAAc;CACtC;CAEA,IAAI,CAAC,OACH,OAAO;EAAE,KAAK;EAAS,MAAM,KAAA;CAAU;CAGzC,MAAM,QAAQ,UAAU,IAAI;CAC5B,MAAM,aAAa,UAAU,MAAM,EAAE;CACrC,MAAM,WAAW,UAAU,MAAM,EAAE;CACnC,MAAM,MAAM,YAAY,KAAA,IAAY,QAAQ,UAAU,OAAO;CAE7D,IAAI,OAAO,OAET,OAAO;EAAE,KADQ,SAAS,cAAc,QAAQ,WACvB,SAAS;EAAS,MAAM,KAAA;CAAU;CAG7D,MAAM,eAAe,KAAK,IAAI,OAAO,UAAU;CAC/C,MAAM,aAAa,KAAK,IAAI,KAAK,QAAQ;CAEzC,IAAI,cAAc,cAChB,OAAO;EAAE,KAAK;EAAS,MAAM,KAAA;CAAU;CAGzC,IAAI,iBAAiB,SAAS,eAAe,KAC3C,OAAO;EAAE,KAAK;EAAQ,MAAM,KAAA;CAAU;CAGxC,MAAM,WAAW,MAAM;CAEvB,OAAO;EACL,KAAK;EACL,MAAM;GACJ,yBAAyB,WAAW,eAAe,SAAS,QAAQ;GACpE,uBAAuB,WAAW,aAAa,SAAS,QAAQ;EAClE;CACF;AACF;;;;;;;;;;AAWA,SAAgB,oBAAoB,OAAmD;CACrF,OAAO,sBAAsB,KAAK,CAAC,CAAC;AACtC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_clamp_interval_minutes = require("../clamp-interval-minutes/clamp-interval-minutes.cjs");
|
|
3
|
+
const require_clamp_slot_label_interval = require("../clamp-slot-label-interval/clamp-slot-label-interval.cjs");
|
|
3
4
|
const require_parse_time_string = require("../parse-time-string/parse-time-string.cjs");
|
|
4
5
|
const require_to_time_string = require("../to-time-string/to-time-string.cjs");
|
|
5
6
|
//#region packages/@mantine/schedule/src/utils/get-day-time-intervals/get-day-time-intervals.ts
|
|
6
|
-
function getDayTimeIntervals({ startTime, endTime, intervalMinutes: _intervalMinutes = 60 }) {
|
|
7
|
+
function getDayTimeIntervals({ startTime, endTime, intervalMinutes: _intervalMinutes = 60, labelIntervalMinutes: _labelIntervalMinutes = 60 }) {
|
|
7
8
|
const intervalMinutes = require_clamp_interval_minutes.clampIntervalMinutes(_intervalMinutes);
|
|
9
|
+
const labelIntervalSeconds = require_clamp_slot_label_interval.clampSlotLabelInterval(_labelIntervalMinutes, intervalMinutes) * 60;
|
|
8
10
|
const start = require_parse_time_string.parseTimeString(startTime);
|
|
9
11
|
const end = endTime ? require_parse_time_string.parseTimeString(endTime) : {
|
|
10
12
|
hours: 23,
|
|
@@ -14,6 +16,7 @@ function getDayTimeIntervals({ startTime, endTime, intervalMinutes: _intervalMin
|
|
|
14
16
|
const startSeconds = start.hours * 3600 + start.minutes * 60 + start.seconds;
|
|
15
17
|
const endSeconds = end.hours * 3600 + end.minutes * 60 + end.seconds;
|
|
16
18
|
const intervalSeconds = intervalMinutes * 60;
|
|
19
|
+
const labelOriginSeconds = startSeconds % labelIntervalSeconds % intervalSeconds === 0 ? 0 : startSeconds;
|
|
17
20
|
const intervals = [];
|
|
18
21
|
let currentSeconds = startSeconds;
|
|
19
22
|
while (currentSeconds < endSeconds) {
|
|
@@ -28,6 +31,7 @@ function getDayTimeIntervals({ startTime, endTime, intervalMinutes: _intervalMin
|
|
|
28
31
|
const endSecs = intervalEndSeconds % 60;
|
|
29
32
|
const durationSeconds = intervalEndSeconds - intervalStartSeconds;
|
|
30
33
|
const isHourStart = startMinutes === 0 && startSecs === 0;
|
|
34
|
+
const isLabelStart = (intervalStartSeconds - labelOriginSeconds) % labelIntervalSeconds === 0;
|
|
31
35
|
intervals.push({
|
|
32
36
|
startTime: require_to_time_string.toTimeString({
|
|
33
37
|
hours: startHours,
|
|
@@ -40,7 +44,8 @@ function getDayTimeIntervals({ startTime, endTime, intervalMinutes: _intervalMin
|
|
|
40
44
|
seconds: endSecs
|
|
41
45
|
}),
|
|
42
46
|
duration: durationSeconds,
|
|
43
|
-
isHourStart
|
|
47
|
+
isHourStart,
|
|
48
|
+
isLabelStart
|
|
44
49
|
});
|
|
45
50
|
currentSeconds = intervalEndSeconds;
|
|
46
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-day-time-intervals.cjs","names":["clampIntervalMinutes","parseTimeString","toTimeString"],"sources":["../../../src/utils/get-day-time-intervals/get-day-time-intervals.ts"],"sourcesContent":["import { clampIntervalMinutes } from '../clamp-interval-minutes/clamp-interval-minutes';\nimport { parseTimeString } from '../parse-time-string/parse-time-string';\nimport { toTimeString } from '../to-time-string/to-time-string';\n\nexport interface DayTimeInterval {\n /** Start time of the interval in HH:mm:ss format */\n startTime: string;\n\n /** End time of the interval in HH:mm:ss format */\n endTime: string;\n\n /** Duration of the interval in seconds */\n duration: number;\n\n /** Indicates if the interval starts at the beginning of an hour */\n isHourStart: boolean;\n}\n\nexport interface GetDayTimeIntervalsInput {\n /** Start time in HH:mm:ss format */\n startTime: string;\n\n /** End time in HH:mm:ss format, end of the day by default */\n endTime?: string;\n\n /** Interval in minutes, 60 by default */\n intervalMinutes?: number;\n}\n\nexport function getDayTimeIntervals({\n startTime,\n endTime,\n intervalMinutes: _intervalMinutes = 60,\n}: GetDayTimeIntervalsInput): DayTimeInterval[] {\n const intervalMinutes = clampIntervalMinutes(_intervalMinutes);\n\n const start = parseTimeString(startTime);\n const end = endTime ? parseTimeString(endTime) : { hours: 23, minutes: 59, seconds: 59 };\n\n const startSeconds = start.hours * 3600 + start.minutes * 60 + start.seconds;\n const endSeconds = end.hours * 3600 + end.minutes * 60 + end.seconds;\n const intervalSeconds = intervalMinutes * 60;\n\n const intervals: DayTimeInterval[] = [];\n let currentSeconds = startSeconds;\n\n while (currentSeconds < endSeconds) {\n const intervalStartSeconds = currentSeconds;\n let intervalEndSeconds = currentSeconds + intervalSeconds;\n\n if (intervalEndSeconds > endSeconds) {\n intervalEndSeconds = endSeconds;\n }\n\n const startHours = Math.floor(intervalStartSeconds / 3600);\n const startMinutes = Math.floor((intervalStartSeconds % 3600) / 60);\n const startSecs = intervalStartSeconds % 60;\n\n const endHours = Math.floor(intervalEndSeconds / 3600);\n const endMinutes = Math.floor((intervalEndSeconds % 3600) / 60);\n const endSecs = intervalEndSeconds % 60;\n\n const durationSeconds = intervalEndSeconds - intervalStartSeconds;\n const isHourStart = startMinutes === 0 && startSecs === 0;\n\n intervals.push({\n startTime: toTimeString({ hours: startHours, minutes: startMinutes, seconds: startSecs }),\n endTime: toTimeString({ hours: endHours, minutes: endMinutes, seconds: endSecs }),\n duration: durationSeconds,\n isHourStart,\n });\n\n currentSeconds = intervalEndSeconds;\n }\n\n return intervals;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-day-time-intervals.cjs","names":["clampIntervalMinutes","clampSlotLabelInterval","parseTimeString","toTimeString"],"sources":["../../../src/utils/get-day-time-intervals/get-day-time-intervals.ts"],"sourcesContent":["import { clampIntervalMinutes } from '../clamp-interval-minutes/clamp-interval-minutes';\nimport { clampSlotLabelInterval } from '../clamp-slot-label-interval/clamp-slot-label-interval';\nimport { parseTimeString } from '../parse-time-string/parse-time-string';\nimport { toTimeString } from '../to-time-string/to-time-string';\n\nexport interface DayTimeInterval {\n /** Start time of the interval in HH:mm:ss format */\n startTime: string;\n\n /** End time of the interval in HH:mm:ss format */\n endTime: string;\n\n /** Duration of the interval in seconds */\n duration: number;\n\n /** Indicates if the interval starts at the beginning of an hour */\n isHourStart: boolean;\n\n /** Indicates if the interval starts at a label boundary defined by `labelIntervalMinutes`. Boundaries are aligned to the clock when the slots grid reaches them, otherwise they are counted from `startTime`. */\n isLabelStart: boolean;\n}\n\nexport interface GetDayTimeIntervalsInput {\n /** Start time in HH:mm:ss format */\n startTime: string;\n\n /** End time in HH:mm:ss format, end of the day by default */\n endTime?: string;\n\n /** Interval in minutes, 60 by default */\n intervalMinutes?: number;\n\n /** Interval between labeled slots in minutes, 60 by default */\n labelIntervalMinutes?: number;\n}\n\nexport function getDayTimeIntervals({\n startTime,\n endTime,\n intervalMinutes: _intervalMinutes = 60,\n labelIntervalMinutes: _labelIntervalMinutes = 60,\n}: GetDayTimeIntervalsInput): DayTimeInterval[] {\n const intervalMinutes = clampIntervalMinutes(_intervalMinutes);\n const labelIntervalSeconds = clampSlotLabelInterval(_labelIntervalMinutes, intervalMinutes) * 60;\n\n const start = parseTimeString(startTime);\n const end = endTime ? parseTimeString(endTime) : { hours: 23, minutes: 59, seconds: 59 };\n\n const startSeconds = start.hours * 3600 + start.minutes * 60 + start.seconds;\n const endSeconds = end.hours * 3600 + end.minutes * 60 + end.seconds;\n const intervalSeconds = intervalMinutes * 60;\n const labelOriginSeconds =\n (startSeconds % labelIntervalSeconds) % intervalSeconds === 0 ? 0 : startSeconds;\n\n const intervals: DayTimeInterval[] = [];\n let currentSeconds = startSeconds;\n\n while (currentSeconds < endSeconds) {\n const intervalStartSeconds = currentSeconds;\n let intervalEndSeconds = currentSeconds + intervalSeconds;\n\n if (intervalEndSeconds > endSeconds) {\n intervalEndSeconds = endSeconds;\n }\n\n const startHours = Math.floor(intervalStartSeconds / 3600);\n const startMinutes = Math.floor((intervalStartSeconds % 3600) / 60);\n const startSecs = intervalStartSeconds % 60;\n\n const endHours = Math.floor(intervalEndSeconds / 3600);\n const endMinutes = Math.floor((intervalEndSeconds % 3600) / 60);\n const endSecs = intervalEndSeconds % 60;\n\n const durationSeconds = intervalEndSeconds - intervalStartSeconds;\n const isHourStart = startMinutes === 0 && startSecs === 0;\n const isLabelStart = (intervalStartSeconds - labelOriginSeconds) % labelIntervalSeconds === 0;\n\n intervals.push({\n startTime: toTimeString({ hours: startHours, minutes: startMinutes, seconds: startSecs }),\n endTime: toTimeString({ hours: endHours, minutes: endMinutes, seconds: endSecs }),\n duration: durationSeconds,\n isHourStart,\n isLabelStart,\n });\n\n currentSeconds = intervalEndSeconds;\n }\n\n return intervals;\n}\n"],"mappings":";;;;;;AAoCA,SAAgB,oBAAoB,EAClC,WACA,SACA,iBAAiB,mBAAmB,IACpC,sBAAsB,wBAAwB,MACA;CAC9C,MAAM,kBAAkBA,+BAAAA,qBAAqB,gBAAgB;CAC7D,MAAM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ule/src/utils/get-slot-label-groups/get-slot-label-groups.ts
|
|
3
|
+
/** Groups consecutive time intervals by label boundaries, the first group may start before the first label */
|
|
4
|
+
function getSlotLabelGroups(intervals) {
|
|
5
|
+
const groups = [];
|
|
6
|
+
intervals.forEach((interval) => {
|
|
7
|
+
const current = groups[groups.length - 1];
|
|
8
|
+
if (current && !interval.isLabelStart) {
|
|
9
|
+
current.endTime = interval.endTime;
|
|
10
|
+
current.slotsCount += 1;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
groups.push({
|
|
14
|
+
startTime: interval.startTime,
|
|
15
|
+
endTime: interval.endTime,
|
|
16
|
+
slotsCount: 1,
|
|
17
|
+
isLabelStart: interval.isLabelStart,
|
|
18
|
+
isHourStart: interval.isHourStart
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
return groups;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.getSlotLabelGroups = getSlotLabelGroups;
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=get-slot-label-groups.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-slot-label-groups.cjs","names":[],"sources":["../../../src/utils/get-slot-label-groups/get-slot-label-groups.ts"],"sourcesContent":["import { DayTimeInterval } from '../get-day-time-intervals/get-day-time-intervals';\n\nexport interface SlotLabelGroup {\n /** Start time of the first slot in the group in HH:mm:ss format */\n startTime: string;\n\n /** End time of the last slot in the group in HH:mm:ss format */\n endTime: string;\n\n /** Number of slots covered by the group */\n slotsCount: number;\n\n /** Indicates if the group starts at a label boundary, `false` for the leading group without a label */\n isLabelStart: boolean;\n\n /** Indicates if the group starts at the beginning of an hour */\n isHourStart: boolean;\n}\n\n/** Groups consecutive time intervals by label boundaries, the first group may start before the first label */\nexport function getSlotLabelGroups(intervals: DayTimeInterval[]): SlotLabelGroup[] {\n const groups: SlotLabelGroup[] = [];\n\n intervals.forEach((interval) => {\n const current = groups[groups.length - 1];\n\n if (current && !interval.isLabelStart) {\n current.endTime = interval.endTime;\n current.slotsCount += 1;\n return;\n }\n\n groups.push({\n startTime: interval.startTime,\n endTime: interval.endTime,\n slotsCount: 1,\n isLabelStart: interval.isLabelStart,\n isHourStart: interval.isHourStart,\n });\n });\n\n return groups;\n}\n"],"mappings":";;;AAoBA,SAAgB,mBAAmB,WAAgD;CACjF,MAAM,SAA2B,CAAC;CAElC,UAAU,SAAS,aAAa;EAC9B,MAAM,UAAU,OAAO,OAAO,SAAS;EAEvC,IAAI,WAAW,CAAC,SAAS,cAAc;GACrC,QAAQ,UAAU,SAAS;GAC3B,QAAQ,cAAc;GACtB;EACF;EAEA,OAAO,KAAK;GACV,WAAW,SAAS;GACpB,SAAS,SAAS;GAClB,YAAY;GACZ,cAAc,SAAS;GACvB,aAAa,SAAS;EACxB,CAAC;CACH,CAAC;CAED,OAAO;AACT"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let dayjs = require("dayjs");
|
|
4
4
|
dayjs = require_runtime.__toESM(dayjs);
|
|
5
|
-
//#region packages/@mantine/schedule/src/
|
|
5
|
+
//#region packages/@mantine/schedule/src/utils/get-visible-week-days/get-visible-week-days.ts
|
|
6
6
|
const DAYS_IN_WEEK = 7;
|
|
7
7
|
/**
|
|
8
8
|
* Returns indices of week columns (0-6, relative to `firstDayOfWeek`) that are
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-visible-week-days.cjs","names":[],"sources":["../../../src/utils/get-visible-week-days/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,GAAS,MAAA,QAAA,CAAM,IAAI,CAAC,CAAC,IAAI,CAAc,CAAC;AACpF"}
|
|
@@ -4,13 +4,15 @@ import { formatDate } from "../../utils/format-date/format-date.mjs";
|
|
|
4
4
|
import { clampIntervalMinutes } from "../../utils/clamp-interval-minutes/clamp-interval-minutes.mjs";
|
|
5
5
|
import { getDayTimeIntervals } from "../../utils/get-day-time-intervals/get-day-time-intervals.mjs";
|
|
6
6
|
import { toDateString } from "../../utils/to-date-string/to-date-string.mjs";
|
|
7
|
+
import { getSlotLabelGroups } from "../../utils/get-slot-label-groups/get-slot-label-groups.mjs";
|
|
7
8
|
import { isAllDayEvent } from "../../utils/is-all-day-event/is-all-day-event.mjs";
|
|
8
9
|
import { getVisibleEvents } from "../../utils/get-visible-events/get-visible-events.mjs";
|
|
9
10
|
import { getDayPosition } from "../../utils/get-day-position/get-day-position.mjs";
|
|
10
11
|
import { getTimeAxisEventStyle } from "../../utils/get-time-axis-event-style/get-time-axis-event-style.mjs";
|
|
11
12
|
import { calculateDropTime } from "../../utils/calculate-drop-time/calculate-drop-time.mjs";
|
|
12
|
-
import {
|
|
13
|
+
import { getBusinessHoursState } from "../../utils/get-business-hours-mod/get-business-hours-mod.mjs";
|
|
13
14
|
import { expandRecurringEvents } from "../../utils/expand-recurring-events/expand-recurring-events.mjs";
|
|
15
|
+
import { addMinutesToTime } from "../../utils/add-minutes-to-time/add-minutes-to-time.mjs";
|
|
14
16
|
import { useAutoScrollOnDrag } from "../../hooks/use-auto-scroll-on-drag.mjs";
|
|
15
17
|
import { useDragDropHandlers } from "../../hooks/use-drag-drop-handlers.mjs";
|
|
16
18
|
import { useEventResize } from "../../hooks/use-event-resize.mjs";
|
|
@@ -39,6 +41,7 @@ const defaultProps = {
|
|
|
39
41
|
withSubHourGridLines: true,
|
|
40
42
|
withAllDaySlot: true,
|
|
41
43
|
slotLabelFormat: "HH:mm",
|
|
44
|
+
slotLabelInterval: 60,
|
|
42
45
|
headerFormat: "MMMM D, YYYY",
|
|
43
46
|
withCurrentTimeBubble: true,
|
|
44
47
|
withHeader: true,
|
|
@@ -55,11 +58,13 @@ const defaultProps = {
|
|
|
55
58
|
const varsResolver = createVarsResolver((_theme, { radius, slotHeight, allDaySlotHeight }) => ({ dayView: {
|
|
56
59
|
"--day-view-radius": radius !== void 0 ? getRadius(radius) : void 0,
|
|
57
60
|
"--day-view-slot-height": rem(slotHeight),
|
|
58
|
-
"--day-view-all-day-slot-height": rem(allDaySlotHeight)
|
|
61
|
+
"--day-view-all-day-slot-height": rem(allDaySlotHeight),
|
|
62
|
+
"--day-view-business-hours-bg": void 0,
|
|
63
|
+
"--day-view-non-business-hours-bg": void 0
|
|
59
64
|
} }));
|
|
60
65
|
const DayView = factory((_props) => {
|
|
61
66
|
const props = useProps("DayView", defaultProps, _props);
|
|
62
|
-
const { classNames, className, style, styles, unstyled, attributes, vars, __staticSelector, startTime, endTime, intervalMinutes, withSubHourGridLines, eventOverlapMode, eventOverlapRaiseDelay, withAllDaySlot, date, locale, slotLabelFormat, headerFormat, getCurrentTime, withCurrentTimeIndicator, withCurrentTimeBubble, withHeader, radius, onDateChange, onViewChange, previousControlProps, nextControlProps, todayControlProps, viewSelectProps, slotHeight, allDaySlotHeight, scrollAreaProps, events, moreEventsProps, renderEventBody, renderEvent, labels, highlightBusinessHours, businessHours, withEventsDragAndDrop, onEventDrop, canDragEvent, eventDragInterval, onEventDragStart, onEventDragEnd, onTimeSlotClick, onAllDaySlotClick, onEventClick, withInteractiveBackgroundEvents, withDragSlotSelect, onSlotDragEnd, mode, startScrollTime, onExternalEventDrop, withEventResize, onEventResize, canResizeEvent, canDropEvent, canDropExternalEvent, canResizeEventTo, preventEventOverlap, onEventPlacementRejected, eventResizeInterval, recurrenceExpansionLimit, getTimeSlotProps, withAgenda, ...others } = props;
|
|
67
|
+
const { classNames, className, style, styles, unstyled, attributes, vars, __staticSelector, startTime, endTime, intervalMinutes, withSubHourGridLines, eventOverlapMode, eventOverlapRaiseDelay, withAllDaySlot, date, locale, slotLabelFormat, slotLabelInterval, headerFormat, getCurrentTime, withCurrentTimeIndicator, withCurrentTimeBubble, withHeader, radius, onDateChange, onViewChange, previousControlProps, nextControlProps, todayControlProps, viewSelectProps, slotHeight, allDaySlotHeight, scrollAreaProps, events, moreEventsProps, renderEventBody, renderEvent, labels, highlightBusinessHours, businessHours, withEventsDragAndDrop, onEventDrop, canDragEvent, eventDragInterval, onEventDragStart, onEventDragEnd, onTimeSlotClick, onAllDaySlotClick, onEventClick, withInteractiveBackgroundEvents, withDragSlotSelect, onSlotDragEnd, mode, startScrollTime, onExternalEventDrop, withEventResize, onEventResize, canResizeEvent, canDropEvent, canDropExternalEvent, canResizeEventTo, preventEventOverlap, onEventPlacementRejected, eventResizeInterval, recurrenceExpansionLimit, getTimeSlotProps, withAgenda, ...others } = props;
|
|
63
68
|
const [agendaOpen, setAgendaOpen] = useState(false);
|
|
64
69
|
const getStyles = useStyles({
|
|
65
70
|
name: __staticSelector,
|
|
@@ -93,7 +98,8 @@ const DayView = factory((_props) => {
|
|
|
93
98
|
const slots = getDayTimeIntervals({
|
|
94
99
|
startTime,
|
|
95
100
|
endTime,
|
|
96
|
-
intervalMinutes
|
|
101
|
+
intervalMinutes,
|
|
102
|
+
labelIntervalMinutes: slotLabelInterval
|
|
97
103
|
});
|
|
98
104
|
const slotsRef = useRef([]);
|
|
99
105
|
const viewportRef = useRef(null);
|
|
@@ -360,6 +366,12 @@ const DayView = factory((_props) => {
|
|
|
360
366
|
});
|
|
361
367
|
externalOnClick?.(event);
|
|
362
368
|
};
|
|
369
|
+
const businessHoursState = getBusinessHoursState({
|
|
370
|
+
time: slot.startTime,
|
|
371
|
+
endTime: addMinutesToTime(slot.startTime, clampIntervalMinutes(intervalMinutes)),
|
|
372
|
+
businessHours,
|
|
373
|
+
highlightBusinessHours
|
|
374
|
+
});
|
|
363
375
|
return /* @__PURE__ */ createElement(UnstyledButton, {
|
|
364
376
|
...getStyles("dayViewSlot"),
|
|
365
377
|
key: slot.startTime,
|
|
@@ -369,16 +381,15 @@ const DayView = factory((_props) => {
|
|
|
369
381
|
mod: {
|
|
370
382
|
first: index === 0,
|
|
371
383
|
"hour-start": slot.isHourStart,
|
|
372
|
-
...
|
|
373
|
-
time: slot.startTime,
|
|
374
|
-
businessHours,
|
|
375
|
-
highlightBusinessHours
|
|
376
|
-
}),
|
|
384
|
+
...businessHoursState.mod,
|
|
377
385
|
"drop-target": isDropTarget,
|
|
378
386
|
"drag-selected": isDragSelected,
|
|
379
387
|
static: mode === "static"
|
|
380
388
|
},
|
|
381
|
-
__vars: {
|
|
389
|
+
__vars: {
|
|
390
|
+
"--slot-size": `${clampIntervalMinutes(intervalMinutes) / 60}`,
|
|
391
|
+
...businessHoursState.vars
|
|
392
|
+
},
|
|
382
393
|
"aria-label": `${getLabel("timeSlot", labels)} ${slot.startTime} - ${slot.endTime}`,
|
|
383
394
|
tabIndex: mode === "static" ? -1 : index === 0 ? 0 : -1,
|
|
384
395
|
"data-drag-slot-index": withDragSlotSelect && mode !== "static" ? index : void 0,
|
|
@@ -390,26 +401,31 @@ const DayView = factory((_props) => {
|
|
|
390
401
|
...externalSlotProps
|
|
391
402
|
});
|
|
392
403
|
});
|
|
393
|
-
const slotsLabels = slots.
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
404
|
+
const slotsLabels = getSlotLabelGroups(slots).map((group) => {
|
|
405
|
+
const label = group.isLabelStart ? formatDate({
|
|
406
|
+
locale: ctx.getLocale(locale),
|
|
407
|
+
date: dayjs(`${dayjs(date).format("YYYY-MM-DD")} ${group.startTime}`),
|
|
408
|
+
format: slotLabelFormat
|
|
409
|
+
}) : null;
|
|
410
|
+
const labelBusinessHours = getBusinessHoursState({
|
|
411
|
+
time: group.startTime,
|
|
412
|
+
endTime: group.endTime,
|
|
413
|
+
businessHours,
|
|
414
|
+
highlightBusinessHours
|
|
415
|
+
});
|
|
416
|
+
return /* @__PURE__ */ createElement(Box, {
|
|
417
|
+
...getStyles("dayViewSlotLabel"),
|
|
418
|
+
key: group.startTime,
|
|
419
|
+
mod: {
|
|
420
|
+
"sub-hour": !group.isHourStart,
|
|
421
|
+
...labelBusinessHours.mod
|
|
422
|
+
},
|
|
423
|
+
__vars: {
|
|
424
|
+
...labelBusinessHours.vars,
|
|
425
|
+
"--slot-label-size": `${group.slotsCount * clampIntervalMinutes(intervalMinutes) / 60}`
|
|
426
|
+
}
|
|
427
|
+
}, label);
|
|
428
|
+
});
|
|
413
429
|
const interactiveBackgroundEvents = withInteractiveBackgroundEvents && mode !== "static";
|
|
414
430
|
const backgroundAllDayEventNodes = eventsData.backgroundAllDayEvents.map((event) => /* @__PURE__ */ jsx(ScheduleBackgroundEvent, {
|
|
415
431
|
event,
|