@burdenoff/microfe-calendar 2026.1124.1 → 2026.1124.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.
Files changed (156) hide show
  1. package/dist/generated/wspace-operations.d.ts +658 -0
  2. package/dist/generated/wspace-operations.js +179 -6
  3. package/dist/generated/wspace-operations.js.map +1 -1
  4. package/dist/generated/wspace-types.d.ts +1243 -10
  5. package/dist/hooks/useSafePermissions.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/pages/ResourcesPage.js.map +1 -1
  8. package/dist/providers/CalendarProvider.d.ts +3 -1
  9. package/dist/providers/CalendarProvider.js +12 -10
  10. package/dist/providers/CalendarProvider.js.map +1 -1
  11. package/dist/translations/en.d.ts +291 -1
  12. package/dist/types/index.d.ts +9 -0
  13. package/dist/v2/CalendarPageV2.js +44 -39
  14. package/dist/v2/CalendarPageV2.js.map +1 -1
  15. package/dist/v2/data/enums.d.ts +1 -0
  16. package/dist/v2/data/enums.js +6 -2
  17. package/dist/v2/data/enums.js.map +1 -1
  18. package/dist/v2/dialogs/CalendarDialogsV2.js +12 -9
  19. package/dist/v2/dialogs/CalendarDialogsV2.js.map +1 -1
  20. package/dist/v2/event/CustomRepeat.d.ts +5 -0
  21. package/dist/v2/event/CustomRepeat.js +246 -0
  22. package/dist/v2/event/CustomRepeat.js.map +1 -0
  23. package/dist/v2/event/EventDetailsTab.d.ts +6 -0
  24. package/dist/v2/event/EventDetailsTab.js +291 -0
  25. package/dist/v2/event/EventDetailsTab.js.map +1 -0
  26. package/dist/v2/event/EventDialog.d.ts +25 -0
  27. package/dist/v2/event/EventDialog.js +365 -0
  28. package/dist/v2/event/EventDialog.js.map +1 -0
  29. package/dist/v2/event/EventDialogs.d.ts +3 -0
  30. package/dist/v2/event/EventDialogs.js +111 -0
  31. package/dist/v2/event/EventDialogs.js.map +1 -0
  32. package/dist/v2/event/EventMoreTab.d.ts +4 -0
  33. package/dist/v2/event/EventMoreTab.js +214 -0
  34. package/dist/v2/event/EventMoreTab.js.map +1 -0
  35. package/dist/v2/event/EventPeopleTab.d.ts +8 -0
  36. package/dist/v2/event/EventPeopleTab.js +422 -0
  37. package/dist/v2/event/EventPeopleTab.js.map +1 -0
  38. package/dist/v2/event/EventPlaceTab.d.ts +6 -0
  39. package/dist/v2/event/EventPlaceTab.js +264 -0
  40. package/dist/v2/event/EventPlaceTab.js.map +1 -0
  41. package/dist/v2/event/FindTimeDialog.d.ts +26 -0
  42. package/dist/v2/event/FindTimeDialog.js +667 -0
  43. package/dist/v2/event/FindTimeDialog.js.map +1 -0
  44. package/dist/v2/event/RepeatField.d.ts +5 -0
  45. package/dist/v2/event/RepeatField.js +88 -0
  46. package/dist/v2/event/RepeatField.js.map +1 -0
  47. package/dist/v2/event/dialogLogic.d.ts +87 -0
  48. package/dist/v2/event/dialogLogic.js +117 -0
  49. package/dist/v2/event/dialogLogic.js.map +1 -0
  50. package/dist/v2/event/dialogModel.d.ts +48 -0
  51. package/dist/v2/event/dialogModel.js +13 -0
  52. package/dist/v2/event/dialogModel.js.map +1 -0
  53. package/dist/v2/event/eventForm.d.ts +209 -0
  54. package/dist/v2/event/eventForm.js +397 -0
  55. package/dist/v2/event/eventForm.js.map +1 -0
  56. package/dist/v2/event/findTime.d.ts +120 -0
  57. package/dist/v2/event/findTime.js +149 -0
  58. package/dist/v2/event/findTime.js.map +1 -0
  59. package/dist/v2/event/findTimeSource.d.ts +102 -0
  60. package/dist/v2/event/findTimeSource.js +107 -0
  61. package/dist/v2/event/findTimeSource.js.map +1 -0
  62. package/dist/v2/event/parts.d.ts +46 -0
  63. package/dist/v2/event/parts.js +124 -0
  64. package/dist/v2/event/parts.js.map +1 -0
  65. package/dist/v2/event/place.d.ts +64 -0
  66. package/dist/v2/event/place.js +48 -0
  67. package/dist/v2/event/place.js.map +1 -0
  68. package/dist/v2/event/repeatWords.d.ts +19 -0
  69. package/dist/v2/event/repeatWords.js +130 -0
  70. package/dist/v2/event/repeatWords.js.map +1 -0
  71. package/dist/v2/event/rrule.d.ts +90 -0
  72. package/dist/v2/event/rrule.js +368 -0
  73. package/dist/v2/event/rrule.js.map +1 -0
  74. package/dist/v2/event/savePlan.d.ts +50 -0
  75. package/dist/v2/event/savePlan.js +125 -0
  76. package/dist/v2/event/savePlan.js.map +1 -0
  77. package/dist/v2/event/useEventData.d.ts +91 -0
  78. package/dist/v2/event/useEventData.js +202 -0
  79. package/dist/v2/event/useEventData.js.map +1 -0
  80. package/dist/v2/event/useEventDialogModel.d.ts +37 -0
  81. package/dist/v2/event/useEventDialogModel.js +129 -0
  82. package/dist/v2/event/useEventDialogModel.js.map +1 -0
  83. package/dist/v2/event/useEventSave.d.ts +41 -0
  84. package/dist/v2/event/useEventSave.js +185 -0
  85. package/dist/v2/event/useEventSave.js.map +1 -0
  86. package/dist/v2/format.d.ts +2 -0
  87. package/dist/v2/format.js +4 -0
  88. package/dist/v2/format.js.map +1 -1
  89. package/dist/v2/grid/GridParts.js +100 -94
  90. package/dist/v2/grid/GridParts.js.map +1 -1
  91. package/dist/v2/grid/TimeGrid.js +98 -89
  92. package/dist/v2/grid/TimeGrid.js.map +1 -1
  93. package/dist/v2/list/ListViewV2.d.ts +6 -2
  94. package/dist/v2/list/ListViewV2.js +50 -44
  95. package/dist/v2/list/ListViewV2.js.map +1 -1
  96. package/dist/v2/month/MonthView.js +130 -126
  97. package/dist/v2/month/MonthView.js.map +1 -1
  98. package/dist/v2/peek/EventPeek.js.map +1 -1
  99. package/dist/v2/peek/PeekEvent.js.map +1 -1
  100. package/dist/v2/rail/CalendarRail.js +54 -80
  101. package/dist/v2/rail/CalendarRail.js.map +1 -1
  102. package/dist/v2/runs/RunPeek.d.ts +2 -0
  103. package/dist/v2/runs/RunPeek.js +382 -0
  104. package/dist/v2/runs/RunPeek.js.map +1 -0
  105. package/dist/v2/runs/RunPills.d.ts +28 -0
  106. package/dist/v2/runs/RunPills.js +179 -0
  107. package/dist/v2/runs/RunPills.js.map +1 -0
  108. package/dist/v2/runs/RunRows.d.ts +21 -0
  109. package/dist/v2/runs/RunRows.js +140 -0
  110. package/dist/v2/runs/RunRows.js.map +1 -0
  111. package/dist/v2/runs/RunsNotices.d.ts +1 -0
  112. package/dist/v2/runs/RunsNotices.js +37 -0
  113. package/dist/v2/runs/RunsNotices.js.map +1 -0
  114. package/dist/v2/runs/RunsSwitch.d.ts +1 -0
  115. package/dist/v2/runs/RunsSwitch.js +54 -0
  116. package/dist/v2/runs/RunsSwitch.js.map +1 -0
  117. package/dist/v2/runs/WorkflowRunsLayer.d.ts +4 -0
  118. package/dist/v2/runs/WorkflowRunsLayer.js +82 -0
  119. package/dist/v2/runs/WorkflowRunsLayer.js.map +1 -0
  120. package/dist/v2/runs/runAccess.d.ts +37 -0
  121. package/dist/v2/runs/runAccess.js +14 -0
  122. package/dist/v2/runs/runAccess.js.map +1 -0
  123. package/dist/v2/runs/runLayout.d.ts +76 -0
  124. package/dist/v2/runs/runLayout.js +129 -0
  125. package/dist/v2/runs/runLayout.js.map +1 -0
  126. package/dist/v2/runs/runLinks.d.ts +32 -0
  127. package/dist/v2/runs/runLinks.js +50 -0
  128. package/dist/v2/runs/runLinks.js.map +1 -0
  129. package/dist/v2/runs/runModel.d.ts +97 -0
  130. package/dist/v2/runs/runModel.js +132 -0
  131. package/dist/v2/runs/runModel.js.map +1 -0
  132. package/dist/v2/runs/runPeekState.d.ts +53 -0
  133. package/dist/v2/runs/runPeekState.js +62 -0
  134. package/dist/v2/runs/runPeekState.js.map +1 -0
  135. package/dist/v2/runs/runTypes.d.ts +60 -0
  136. package/dist/v2/runs/runWords.d.ts +23 -0
  137. package/dist/v2/runs/runWords.js +83 -0
  138. package/dist/v2/runs/runWords.js.map +1 -0
  139. package/dist/v2/runs/runsLayerContext.d.ts +26 -0
  140. package/dist/v2/runs/runsLayerContext.js +33 -0
  141. package/dist/v2/runs/runsLayerContext.js.map +1 -0
  142. package/dist/v2/runs/useRunHrefs.d.ts +10 -0
  143. package/dist/v2/runs/useRunHrefs.js +60 -0
  144. package/dist/v2/runs/useRunHrefs.js.map +1 -0
  145. package/dist/v2/runs/useRunLabels.d.ts +6 -0
  146. package/dist/v2/runs/useRunLabels.js +27 -0
  147. package/dist/v2/runs/useRunLabels.js.map +1 -0
  148. package/dist/v2/runs/useRunsAccess.d.ts +2 -0
  149. package/dist/v2/runs/useRunsAccess.js +14 -0
  150. package/dist/v2/runs/useRunsAccess.js.map +1 -0
  151. package/dist/v2/runs/useWorkflowRuns.d.ts +61 -0
  152. package/dist/v2/runs/useWorkflowRuns.js +119 -0
  153. package/dist/v2/runs/useWorkflowRuns.js.map +1 -0
  154. package/dist/v2/states/CalendarStates.js.map +1 -1
  155. package/dist/v2/types.d.ts +2 -0
  156. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"GridParts.js","names":["_Fragment","HOURS","hour","DayHeaderRow","page","useCalendarPage","offsetLabel","formatTimeZoneOffset","timeZone","format","zoneLabel","tr","columnsStyle","nav","cn","FOCUS_RING","compact","days","DayHeader","day","today","weekend","isWeekendDay","tone","isToday","formatDay","HourGutter","showsToday","nowMinute","hourHeight","formatMinutes","minuteOffset","OffHours","hours","workingHoursOn","Fragment","offHours","stretch","NowLine","DayColumn","lineStyle","placed","look","piece","EventBlock","selectedId","ghost","GridGhost","calendarHueStyle","formatMinuteRange","formatDuration","quick","cursorMinute","quickAnchor","hueStyle","start","end","label","GridEmpty","EmptyState","Button","Plus","CalendarPlus"],"sources":["../../../src/v2/grid/GridParts.tsx"],"sourcesContent":["/**\n * The time grid's parts (BOFF-15698 A1): the row of days, the hours down the side with the now\n * time, a day's column (working hours unshaded, its events, the now line, a drag's ghost, the\n * quick create's slot and the keyboard cursor), and the \"nothing on these days\" card.\n */\nimport type { CSSProperties, KeyboardEvent } from 'react';\nimport { CalendarPlus, Plus } from 'lucide-react';\nimport { Button, EmptyState, formatTimeZoneOffset, type DateValue } from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { calendarHueStyle } from '../colors';\nimport { formatDay, formatDuration, formatMinuteRange, formatMinutes } from '../format';\nimport { useCalendarPage, type QuickDraft } from '../page/CalendarPageContext';\nimport { FOCUS_RING } from '../styles';\nimport { isWeekendDay } from '../time/calendarTime';\nimport type { CalendarEventV2, PlacedSegment } from '../types';\nimport { EventBlock } from './EventBlock';\nimport { CURSOR_STEP, minuteOffset } from './geometry';\nimport type { DragGhost } from './useGridDrag';\nimport { offHours } from './workingHours';\n\nconst HOURS = Array.from({ length: 24 }, (_, hour) => hour);\n\n/** The time zone (it opens Calendar settings) and the shown days (each opens its Day view). */\nexport function DayHeaderRow({ columnsStyle }: { columnsStyle: CSSProperties }) {\n const page = useCalendarPage();\n const { tr, format, timeZone, compact, days, today, nav } = page;\n const offsetLabel = formatTimeZoneOffset(timeZone, page.now, format.locale);\n const zoneLabel = tr('calendar.v2.timeZoneButton', 'Time zone: {{zone}}', { zone: timeZone });\n return (\n <div className=\"grid border-b border-border-subtle\" style={columnsStyle}>\n <div className=\"flex items-end justify-end pe-1 pb-1.5\">\n <button\n type=\"button\"\n onClick={() => nav.openDialog('settings')}\n title={zoneLabel}\n aria-label={zoneLabel}\n className={cn(\n 'rounded px-[3px] py-0.5 text-[10px] whitespace-nowrap tabular-nums text-text-muted hover:bg-bg-sunken hover:text-text-primary',\n FOCUS_RING\n )}\n >\n {compact ? offsetLabel.replace(/^[^+−-]*/, '') : offsetLabel}\n </button>\n </div>\n {days.map((day) => (\n <DayHeader key={day} day={day} isToday={day === today} />\n ))}\n </div>\n );\n}\n\nfunction DayHeader({ day, isToday }: { day: DateValue; isToday: boolean }) {\n const { tr, format, compact, nav } = useCalendarPage();\n const weekend = isWeekendDay(day);\n const tone = isToday ? 'today' : weekend ? 'weekend' : 'day';\n return (\n <button\n type=\"button\"\n onClick={() => nav.goTo({ view: 'day', date: day })}\n aria-current={isToday ? 'date' : undefined}\n aria-label={tr('calendar.v2.openDay', '{{day}}. Open the day', {\n day: formatDay(day, format, 'full'),\n })}\n className={cn(\n 'flex min-w-0 items-center justify-center gap-1.5 border-s border-border-subtle px-0.5 py-[7px] hover:bg-bg-sunken',\n compact && 'flex-col gap-px py-[5px]',\n FOCUS_RING\n )}\n >\n <span\n className={cn(\n 'text-[11px] font-semibold uppercase tracking-[0.06em]',\n tone === 'today' && 'text-action-primary-bg',\n tone === 'weekend' && 'text-text-muted',\n tone === 'day' && 'text-text-secondary'\n )}\n >\n {formatDay(day, format, 'weekday')}\n </span>\n <span\n className={cn(\n 'grid h-[30px] min-w-[30px] place-items-center rounded-full px-1 text-lg font-semibold tabular-nums',\n compact && 'h-7 min-w-7 text-base',\n tone === 'today' && 'bg-action-primary-bg text-action-primary-text',\n tone === 'weekend' && 'text-text-muted',\n tone === 'day' && 'text-text-primary'\n )}\n >\n {formatDay(day, format, 'dayNumber')}\n </span>\n </button>\n );\n}\n\n/** The hours down the side, and the time now beside the now line (when today is shown). */\nexport function HourGutter({ hourHeight }: { hourHeight: number }) {\n const { format, days, today, nowMinute } = useCalendarPage();\n const showsToday = days.includes(today);\n return (\n <div className=\"relative\" aria-hidden=\"true\">\n {HOURS.map((hour) =>\n hour === 0 || (showsToday && Math.abs(hour * 60 - nowMinute) < 13) ? null : (\n <span\n key={hour}\n className=\"absolute end-[7px] -translate-y-1/2 text-[11px] leading-none whitespace-nowrap tabular-nums text-text-muted\"\n style={{ top: hour * hourHeight }}\n >\n {formatMinutes(hour * 60, format)}\n </span>\n )\n )}\n {showsToday ? (\n <span\n className=\"absolute end-[3px] z-[4] -translate-y-1/2 rounded-full bg-action-primary-bg px-[5px] py-[3px] text-[10.5px] leading-none font-bold whitespace-nowrap tabular-nums text-action-primary-text\"\n style={{ top: minuteOffset(nowMinute, hourHeight) }}\n >\n {formatMinutes(nowMinute, format)}\n </span>\n ) : null}\n </div>\n );\n}\n\n/** The hours outside the working day, shaded (a day off is shaded whole). */\nfunction OffHours({ day, hourHeight }: { day: DateValue; hourHeight: number }) {\n const { workingHoursOn } = useCalendarPage();\n const hours = workingHoursOn(day);\n // Not known (free/busy hasn't answered, or failed): no shading rather than a guess.\n if (hours === undefined) return null;\n return (\n <>\n {offHours(hours).map((stretch) => (\n <div\n key={stretch.start}\n className=\"pointer-events-none absolute inset-x-0 bg-bg-sunken/70\"\n style={{\n top: minuteOffset(stretch.start, hourHeight),\n height: minuteOffset(stretch.end - stretch.start, hourHeight),\n }}\n />\n ))}\n </>\n );\n}\n\n/** Now: a line with a dot across today, faint across the other shown days. */\nfunction NowLine({ isToday, hourHeight }: { isToday: boolean; hourHeight: number }) {\n const { nowMinute } = useCalendarPage();\n return (\n <div\n aria-hidden=\"true\"\n className={cn(\n 'pointer-events-none absolute inset-x-0',\n isToday\n ? '-start-px z-[5] -mt-px h-0.5 bg-action-primary-bg before:absolute before:-start-[5px] before:-top-1 before:size-2.5 before:rounded-full before:bg-action-primary-bg'\n : 'z-[2] h-px bg-[color-mix(in_oklab,var(--color-action-primary-bg)_40%,transparent)]'\n )}\n style={{ top: minuteOffset(nowMinute, hourHeight) }}\n />\n );\n}\n\nexport interface DayColumnProps {\n day: DateValue;\n placed: readonly PlacedSegment<CalendarEventV2>[];\n hourHeight: number;\n selectedId: string | null;\n onOpen: (event: CalendarEventV2, element: HTMLElement) => void;\n onKeyDown: (event: KeyboardEvent<HTMLButtonElement>, calendarEvent: CalendarEventV2) => void;\n consumeClick: () => boolean;\n /** A drag's preview in this column. */\n ghost: DragGhost | null;\n /** The quick create's slot in this column. */\n quick: QuickDraft | null;\n /** The keyboard cursor's minute in this column. */\n cursorMinute: number | null;\n}\n\n/** One day of the grid: its working hours, events, the now line and what's being made. */\nexport function DayColumn({\n day,\n placed,\n hourHeight,\n selectedId,\n onOpen,\n onKeyDown,\n consumeClick,\n ghost,\n quick,\n cursorMinute,\n}: DayColumnProps) {\n const page = useCalendarPage();\n const { tr, format, compact, today, days } = page;\n const isToday = day === today;\n const lineStyle: CSSProperties = {\n backgroundImage:\n 'linear-gradient(to bottom, var(--color-border-subtle) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in oklab, var(--color-border-subtle) 45%, transparent) 1px, transparent 1px)',\n backgroundSize: `100% ${hourHeight}px, 100% ${hourHeight}px`,\n backgroundPosition: `0 0, 0 ${hourHeight / 2}px`,\n };\n return (\n <div\n data-grid-day={day}\n role=\"group\"\n aria-label={tr('calendar.v2.dayColumn', '{{day}}: {{count}} events', {\n day: formatDay(day, format, 'full'),\n count: placed.length,\n })}\n className={cn('relative border-s border-border-subtle', isToday && 'bg-accent-soft/30')}\n style={lineStyle}\n >\n <OffHours day={day} hourHeight={hourHeight} />\n {placed.map((piece) => {\n const look = page.lookOf(piece.event);\n return (\n <EventBlock\n key={`${piece.event.id}|${piece.date}`}\n placed={piece}\n hourHeight={hourHeight}\n look={look}\n hue={page.hueOf(piece.event.calendarId)}\n label={page.labelOf(piece.event)}\n format={format}\n selected={selectedId === piece.event.id}\n resizable={look.movable && !compact && !piece.continuesAfter}\n onOpen={onOpen}\n onKeyDown={onKeyDown}\n consumeClick={consumeClick}\n />\n );\n })}\n {days.includes(today) ? <NowLine isToday={isToday} hourHeight={hourHeight} /> : null}\n {ghost ? (\n <GridGhost\n start={ghost.start}\n end={ghost.end}\n hourHeight={hourHeight}\n hueStyle={ghost.event ? calendarHueStyle(page.hueOf(ghost.event.calendarId)) : undefined}\n label={\n ghost.event\n ? `${ghost.event.title} · ${formatMinuteRange(ghost.start, ghost.end, format)}`\n : `${formatMinuteRange(ghost.start, ghost.end, format)} · ${formatDuration(ghost.end - ghost.start, page.durationWords)}`\n }\n />\n ) : null}\n {quick ? (\n <GridGhost\n start={quick.start}\n end={quick.end}\n hourHeight={hourHeight}\n label={formatMinuteRange(quick.start, quick.end, format)}\n quickAnchor\n />\n ) : null}\n {cursorMinute !== null ? (\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0.5 z-[8] rounded-md border-2 border-[var(--color-focus-ring)] bg-accent-soft/40 px-1.5 text-[11px] font-semibold text-text-primary\"\n style={{\n top: minuteOffset(cursorMinute, hourHeight),\n height: minuteOffset(CURSOR_STEP, hourHeight) - 2,\n }}\n >\n {formatMinuteRange(cursorMinute, cursorMinute + CURSOR_STEP, format)}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport function GridGhost({\n start,\n end,\n hourHeight,\n label,\n hueStyle,\n quickAnchor = false,\n}: {\n start: number;\n end: number;\n hourHeight: number;\n label: string;\n hueStyle?: CSSProperties;\n quickAnchor?: boolean;\n}) {\n return (\n <div\n aria-hidden=\"true\"\n data-quick-ghost={quickAnchor || undefined}\n className={cn(\n 'pointer-events-none absolute inset-x-0.5 z-[9] overflow-hidden rounded-md border border-dashed px-1.5 py-0.5 text-[11px] font-semibold text-text-primary',\n hueStyle\n ? 'border-[var(--cal-hue)] bg-[color-mix(in_oklab,var(--cal-hue)_22%,var(--color-bg-surface))]'\n : 'border-action-primary-bg bg-accent-soft/70'\n )}\n style={{\n ...hueStyle,\n top: minuteOffset(start, hourHeight),\n height: Math.max(18, minuteOffset(end - start, hourHeight) - 2),\n }}\n >\n {label}\n </div>\n );\n}\n\n/** Nothing on the shown days: a card over the grid, which stays usable around it. */\nexport function GridEmpty() {\n const page = useCalendarPage();\n const { tr, compact } = page;\n const day = page.days.includes(page.today) ? page.today : (page.days[0] ?? page.today);\n return (\n <div className=\"pointer-events-none absolute inset-0 z-30 grid place-items-center p-4\">\n <div className=\"pointer-events-auto w-full max-w-sm rounded-card border border-border-default bg-bg-elevated shadow-elevation-3\">\n <EmptyState\n compact\n size=\"panel\"\n kind=\"first-use\"\n illustration=\"calendar\"\n title={tr('calendar.v2.emptyDays', 'Nothing on these days')}\n description={\n compact\n ? tr(\n 'calendar.v2.emptyDaysPhone',\n 'Add an event, or bring in a team, holiday or other calendar.'\n )\n : tr(\n 'calendar.v2.emptyDaysDesktop',\n 'Click and drag on the grid to add an event, or bring in a team, holiday or other calendar.'\n )\n }\n action={\n <Button\n type=\"button\"\n onClick={() =>\n page.openEventDialog({\n date: day,\n start: page.workingHoursOn(day)?.start ?? 9 * 60,\n end: (page.workingHoursOn(day)?.start ?? 9 * 60) + page.prefs.defaultDuration,\n allDay: false,\n })\n }\n >\n <Plus aria-hidden=\"true\" />\n {tr('calendar.v2.newEvent', 'New event')}\n </Button>\n }\n secondaryAction={\n <Button type=\"button\" variant=\"outline\" onClick={() => page.nav.openDialog('share')}>\n <CalendarPlus aria-hidden=\"true\" />\n {tr('calendar.v2.addCalendar', 'Add a calendar')}\n </Button>\n }\n />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,IAAMC,IAAQ,MAAM,KAAK,EAAE,QAAQ,GAAG,IAAI,GAAG,MAASC,CAAI;AAG1D,SAAgBC,EAAa,EAAE,mBAAiD;CAC9E,IAAMC,IAAOC,EAAgB,GACvB,EAAE,OAAI,WAAQ,aAAU,YAAS,SAAM,UAAO,WAAQD,GACtDE,IAAcC,EAAqBC,GAAUJ,EAAK,KAAKK,EAAO,MAAM,GACpEC,IAAYC,EAAG,8BAA8B,uBAAuB,EAAE,MAAMH,EAAS,CAAC;CAC5F,OACE,kBAAC,OAAD;EAAK,WAAU;EAAqC,OAAOI;EAA3D,UAAA,CACE,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAAC,UAAD;IACE,MAAK;IACL,eAAeC,EAAI,WAAW,UAAU;IACxC,OAAOH;IACP,cAAYA;IACZ,WAAWI,EACT,iIACAC,CACF;IAEC,UAAAC,IAAUV,EAAY,QAAQ,YAAY,EAAE,IAAIA;GAC3C,CAAA;EACL,CAAA,GACJW,EAAK,KAAK,MACT,kBAACC,GAAD;GAA0B;GAAK,SAASC,MAAQC;EAAQ,GAAxCD,CAAwC,CACzD,CACE;;AAET;AAEA,SAASD,EAAU,EAAE,QAAK,cAAiD;CACzE,IAAM,EAAE,OAAI,WAAQ,YAAS,WAAQb,EAAgB,GAC/CgB,IAAUC,EAAaH,CAAG,GAC1BI,IAAOC,IAAU,UAAUH,IAAU,YAA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BAAkBM,KAAe,KAAA;EACjC,WAAWvC,EACT,4JACAwC,IACI,gGACA,4CACN;EACA,OAAO;GACL,GAAGA;GACH,KAAKvB,EAAawB,GAAO1B,CAAU;GACnC,QAAQ,KAAK,IAAI,IAAIE,EAAayB,IAAMD,GAAO1B,CAAU,IAAI,CAAC;EAChE;EAEC,UAAA4B;CACE,CAAA;AAET;AAGA,SAAgBC,IAAY;CAC1B,IAAMtD,IAAOC,EAAgB,GACvB,EAAE,OAAI,eAAYD,GAClBe,IAAMf,EAAK,KAAK,SAASA,EAAK,KAAK,IAAIA,EAAK,QAASA,EAAK,KAAK,MAAMA,EAAK;CAChF,OACE,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAACuD,GAAD;IACE,SAAA;IACA,MAAK;IACL,MAAK;IACL,cAAa;IACb,OAAOhD,EAAG,yBAAyB,uBAAuB;IAC1D,aACEK,IACIL,EACE,8BACA,8DACF,IACAA,EACE,gCACA,4FACF;IAEN,QACE,kBAACiD,GAAD;KACE,MAAK;KACL,eACExD,EAAK,gBAAgB;MACnB,MAAMe;MACN,OAAOf,EAAK,eAAee,CAAG,CAAC,EAAE,SAAS;MAC1C,MAAMf,EAAK,eAAee,CAAG,CAAC,EAAE,SAAS,OAAUf,EAAK,MAAM;MAC9D,QAAQ;KACV,CAAC;KARL,UAAA,CAWE,kBAACyD,GAAD,EAAM,eAAY,OAAQ,CAAA,GACzBlD,EAAG,wBAAwB,WAAW,CACjC;;IAEV,iBACE,kBAACiD,GAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,eAAexD,EAAK,IAAI,WAAW,OAAO;KAAlF,UAAA,CACE,kBAAC0D,GAAD,EAAc,eAAY,OAAQ,CAAA,GACjCnD,EAAG,2BAA2B,gBAAgB,CACzC;;GAEX,CAAA;EACE,CAAA;CACF,CAAA;AAET"}
1
+ {"version":3,"file":"GridParts.js","names":["_Fragment","HOURS","hour","DayHeaderRow","page","useCalendarPage","offsetLabel","formatTimeZoneOffset","timeZone","format","zoneLabel","tr","columnsStyle","nav","cn","FOCUS_RING","compact","days","DayHeader","day","today","weekend","isWeekendDay","tone","isToday","formatDay","HourGutter","showsToday","nowMinute","hourHeight","formatMinutes","minuteOffset","OffHours","hours","workingHoursOn","Fragment","offHours","stretch","NowLine","DayColumn","lineStyle","placed","look","piece","EventBlock","selectedId","DayRunPills","ghost","GridGhost","calendarHueStyle","formatMinuteRange","formatDuration","quick","cursorMinute","quickAnchor","hueStyle","start","end","label","GridEmpty","EmptyState","Button","Plus","CalendarPlus"],"sources":["../../../src/v2/grid/GridParts.tsx"],"sourcesContent":["/**\n * The time grid's parts (BOFF-15698 A1): the row of days, the hours down the side with the now\n * time, a day's column (working hours unshaded, its events, its workflow runs (B5), the now\n * line, a drag's ghost, the quick create's slot and the keyboard cursor), and the \"nothing on\n * these days\" card.\n */\nimport type { CSSProperties, KeyboardEvent } from 'react';\nimport { CalendarPlus, Plus } from 'lucide-react';\nimport { Button, EmptyState, formatTimeZoneOffset, type DateValue } from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { calendarHueStyle } from '../colors';\nimport { formatDay, formatDuration, formatMinuteRange, formatMinutes } from '../format';\nimport { useCalendarPage, type QuickDraft } from '../page/CalendarPageContext';\nimport { DayRunPills } from '../runs/RunPills';\nimport { FOCUS_RING } from '../styles';\nimport { isWeekendDay } from '../time/calendarTime';\nimport type { CalendarEventV2, PlacedSegment } from '../types';\nimport { EventBlock } from './EventBlock';\nimport { CURSOR_STEP, minuteOffset } from './geometry';\nimport type { DragGhost } from './useGridDrag';\nimport { offHours } from './workingHours';\n\nconst HOURS = Array.from({ length: 24 }, (_, hour) => hour);\n\n/** The time zone (it opens Calendar settings) and the shown days (each opens its Day view). */\nexport function DayHeaderRow({ columnsStyle }: { columnsStyle: CSSProperties }) {\n const page = useCalendarPage();\n const { tr, format, timeZone, compact, days, today, nav } = page;\n const offsetLabel = formatTimeZoneOffset(timeZone, page.now, format.locale);\n const zoneLabel = tr('calendar.v2.timeZoneButton', 'Time zone: {{zone}}', { zone: timeZone });\n return (\n <div className=\"grid border-b border-border-subtle\" style={columnsStyle}>\n <div className=\"flex items-end justify-end pe-1 pb-1.5\">\n <button\n type=\"button\"\n onClick={() => nav.openDialog('settings')}\n title={zoneLabel}\n aria-label={zoneLabel}\n className={cn(\n 'rounded px-[3px] py-0.5 text-[10px] whitespace-nowrap tabular-nums text-text-muted hover:bg-bg-sunken hover:text-text-primary',\n FOCUS_RING\n )}\n >\n {compact ? offsetLabel.replace(/^[^+−-]*/, '') : offsetLabel}\n </button>\n </div>\n {days.map((day) => (\n <DayHeader key={day} day={day} isToday={day === today} />\n ))}\n </div>\n );\n}\n\nfunction DayHeader({ day, isToday }: { day: DateValue; isToday: boolean }) {\n const { tr, format, compact, nav } = useCalendarPage();\n const weekend = isWeekendDay(day);\n const tone = isToday ? 'today' : weekend ? 'weekend' : 'day';\n return (\n <button\n type=\"button\"\n onClick={() => nav.goTo({ view: 'day', date: day })}\n aria-current={isToday ? 'date' : undefined}\n aria-label={tr('calendar.v2.openDay', '{{day}}. Open the day', {\n day: formatDay(day, format, 'full'),\n })}\n className={cn(\n 'flex min-w-0 items-center justify-center gap-1.5 border-s border-border-subtle px-0.5 py-[7px] hover:bg-bg-sunken',\n compact && 'flex-col gap-px py-[5px]',\n FOCUS_RING\n )}\n >\n <span\n className={cn(\n 'text-[11px] font-semibold uppercase tracking-[0.06em]',\n tone === 'today' && 'text-action-primary-bg',\n tone === 'weekend' && 'text-text-muted',\n tone === 'day' && 'text-text-secondary'\n )}\n >\n {formatDay(day, format, 'weekday')}\n </span>\n <span\n className={cn(\n 'grid h-[30px] min-w-[30px] place-items-center rounded-full px-1 text-lg font-semibold tabular-nums',\n compact && 'h-7 min-w-7 text-base',\n tone === 'today' && 'bg-action-primary-bg text-action-primary-text',\n tone === 'weekend' && 'text-text-muted',\n tone === 'day' && 'text-text-primary'\n )}\n >\n {formatDay(day, format, 'dayNumber')}\n </span>\n </button>\n );\n}\n\n/** The hours down the side, and the time now beside the now line (when today is shown). */\nexport function HourGutter({ hourHeight }: { hourHeight: number }) {\n const { format, days, today, nowMinute } = useCalendarPage();\n const showsToday = days.includes(today);\n return (\n <div className=\"relative\" aria-hidden=\"true\">\n {HOURS.map((hour) =>\n hour === 0 || (showsToday && Math.abs(hour * 60 - nowMinute) < 13) ? null : (\n <span\n key={hour}\n className=\"absolute end-[7px] -translate-y-1/2 text-[11px] leading-none whitespace-nowrap tabular-nums text-text-muted\"\n style={{ top: hour * hourHeight }}\n >\n {formatMinutes(hour * 60, format)}\n </span>\n )\n )}\n {showsToday ? (\n <span\n className=\"absolute end-[3px] z-[4] -translate-y-1/2 rounded-full bg-action-primary-bg px-[5px] py-[3px] text-[10.5px] leading-none font-bold whitespace-nowrap tabular-nums text-action-primary-text\"\n style={{ top: minuteOffset(nowMinute, hourHeight) }}\n >\n {formatMinutes(nowMinute, format)}\n </span>\n ) : null}\n </div>\n );\n}\n\n/** The hours outside the working day, shaded (a day off is shaded whole). */\nfunction OffHours({ day, hourHeight }: { day: DateValue; hourHeight: number }) {\n const { workingHoursOn } = useCalendarPage();\n const hours = workingHoursOn(day);\n // Not known (free/busy hasn't answered, or failed): no shading rather than a guess.\n if (hours === undefined) return null;\n return (\n <>\n {offHours(hours).map((stretch) => (\n <div\n key={stretch.start}\n className=\"pointer-events-none absolute inset-x-0 bg-bg-sunken/70\"\n style={{\n top: minuteOffset(stretch.start, hourHeight),\n height: minuteOffset(stretch.end - stretch.start, hourHeight),\n }}\n />\n ))}\n </>\n );\n}\n\n/** Now: a line with a dot across today, faint across the other shown days. */\nfunction NowLine({ isToday, hourHeight }: { isToday: boolean; hourHeight: number }) {\n const { nowMinute } = useCalendarPage();\n return (\n <div\n aria-hidden=\"true\"\n className={cn(\n 'pointer-events-none absolute inset-x-0',\n isToday\n ? '-start-px z-[5] -mt-px h-0.5 bg-action-primary-bg before:absolute before:-start-[5px] before:-top-1 before:size-2.5 before:rounded-full before:bg-action-primary-bg'\n : 'z-[2] h-px bg-[color-mix(in_oklab,var(--color-action-primary-bg)_40%,transparent)]'\n )}\n style={{ top: minuteOffset(nowMinute, hourHeight) }}\n />\n );\n}\n\nexport interface DayColumnProps {\n day: DateValue;\n placed: readonly PlacedSegment<CalendarEventV2>[];\n hourHeight: number;\n selectedId: string | null;\n onOpen: (event: CalendarEventV2, element: HTMLElement) => void;\n onKeyDown: (event: KeyboardEvent<HTMLButtonElement>, calendarEvent: CalendarEventV2) => void;\n consumeClick: () => boolean;\n /** A drag's preview in this column. */\n ghost: DragGhost | null;\n /** The quick create's slot in this column. */\n quick: QuickDraft | null;\n /** The keyboard cursor's minute in this column. */\n cursorMinute: number | null;\n}\n\n/** One day of the grid: its working hours, events, the now line and what's being made. */\nexport function DayColumn({\n day,\n placed,\n hourHeight,\n selectedId,\n onOpen,\n onKeyDown,\n consumeClick,\n ghost,\n quick,\n cursorMinute,\n}: DayColumnProps) {\n const page = useCalendarPage();\n const { tr, format, compact, today, days } = page;\n const isToday = day === today;\n const lineStyle: CSSProperties = {\n backgroundImage:\n 'linear-gradient(to bottom, var(--color-border-subtle) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in oklab, var(--color-border-subtle) 45%, transparent) 1px, transparent 1px)',\n backgroundSize: `100% ${hourHeight}px, 100% ${hourHeight}px`,\n backgroundPosition: `0 0, 0 ${hourHeight / 2}px`,\n };\n return (\n <div\n data-grid-day={day}\n role=\"group\"\n aria-label={tr('calendar.v2.dayColumn', '{{day}}: {{count}} events', {\n day: formatDay(day, format, 'full'),\n count: placed.length,\n })}\n className={cn('relative border-s border-border-subtle', isToday && 'bg-accent-soft/30')}\n style={lineStyle}\n >\n <OffHours day={day} hourHeight={hourHeight} />\n {placed.map((piece) => {\n const look = page.lookOf(piece.event);\n return (\n <EventBlock\n key={`${piece.event.id}|${piece.date}`}\n placed={piece}\n hourHeight={hourHeight}\n look={look}\n hue={page.hueOf(piece.event.calendarId)}\n label={page.labelOf(piece.event)}\n format={format}\n selected={selectedId === piece.event.id}\n resizable={look.movable && !compact && !piece.continuesAfter}\n onOpen={onOpen}\n onKeyDown={onKeyDown}\n consumeClick={consumeClick}\n />\n );\n })}\n <DayRunPills day={day} hourHeight={hourHeight} placed={placed} />\n {days.includes(today) ? <NowLine isToday={isToday} hourHeight={hourHeight} /> : null}\n {ghost ? (\n <GridGhost\n start={ghost.start}\n end={ghost.end}\n hourHeight={hourHeight}\n hueStyle={ghost.event ? calendarHueStyle(page.hueOf(ghost.event.calendarId)) : undefined}\n label={\n ghost.event\n ? `${ghost.event.title} · ${formatMinuteRange(ghost.start, ghost.end, format)}`\n : `${formatMinuteRange(ghost.start, ghost.end, format)} · ${formatDuration(ghost.end - ghost.start, page.durationWords)}`\n }\n />\n ) : null}\n {quick ? (\n <GridGhost\n start={quick.start}\n end={quick.end}\n hourHeight={hourHeight}\n label={formatMinuteRange(quick.start, quick.end, format)}\n quickAnchor\n />\n ) : null}\n {cursorMinute !== null ? (\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0.5 z-[8] rounded-md border-2 border-[var(--color-focus-ring)] bg-accent-soft/40 px-1.5 text-[11px] font-semibold text-text-primary\"\n style={{\n top: minuteOffset(cursorMinute, hourHeight),\n height: minuteOffset(CURSOR_STEP, hourHeight) - 2,\n }}\n >\n {formatMinuteRange(cursorMinute, cursorMinute + CURSOR_STEP, format)}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport function GridGhost({\n start,\n end,\n hourHeight,\n label,\n hueStyle,\n quickAnchor = false,\n}: {\n start: number;\n end: number;\n hourHeight: number;\n label: string;\n hueStyle?: CSSProperties;\n quickAnchor?: boolean;\n}) {\n return (\n <div\n aria-hidden=\"true\"\n data-quick-ghost={quickAnchor || undefined}\n className={cn(\n 'pointer-events-none absolute inset-x-0.5 z-[9] overflow-hidden rounded-md border border-dashed px-1.5 py-0.5 text-[11px] font-semibold text-text-primary',\n hueStyle\n ? 'border-[var(--cal-hue)] bg-[color-mix(in_oklab,var(--cal-hue)_22%,var(--color-bg-surface))]'\n : 'border-action-primary-bg bg-accent-soft/70'\n )}\n style={{\n ...hueStyle,\n top: minuteOffset(start, hourHeight),\n height: Math.max(18, minuteOffset(end - start, hourHeight) - 2),\n }}\n >\n {label}\n </div>\n );\n}\n\n/** Nothing on the shown days: a card over the grid, which stays usable around it. */\nexport function GridEmpty() {\n const page = useCalendarPage();\n const { tr, compact } = page;\n const day = page.days.includes(page.today) ? page.today : (page.days[0] ?? page.today);\n return (\n <div className=\"pointer-events-none absolute inset-0 z-30 grid place-items-center p-4\">\n <div className=\"pointer-events-auto w-full max-w-sm rounded-card border border-border-default bg-bg-elevated shadow-elevation-3\">\n <EmptyState\n compact\n size=\"panel\"\n kind=\"first-use\"\n illustration=\"calendar\"\n title={tr('calendar.v2.emptyDays', 'Nothing on these days')}\n description={\n compact\n ? tr(\n 'calendar.v2.emptyDaysPhone',\n 'Add an event, or bring in a team, holiday or other calendar.'\n )\n : tr(\n 'calendar.v2.emptyDaysDesktop',\n 'Click and drag on the grid to add an event, or bring in a team, holiday or other calendar.'\n )\n }\n action={\n <Button\n type=\"button\"\n onClick={() =>\n page.openEventDialog({\n date: day,\n start: page.workingHoursOn(day)?.start ?? 9 * 60,\n end: (page.workingHoursOn(day)?.start ?? 9 * 60) + page.prefs.defaultDuration,\n allDay: false,\n })\n }\n >\n <Plus aria-hidden=\"true\" />\n {tr('calendar.v2.newEvent', 'New event')}\n </Button>\n }\n secondaryAction={\n <Button type=\"button\" variant=\"outline\" onClick={() => page.nav.openDialog('share')}>\n <CalendarPlus aria-hidden=\"true\" />\n {tr('calendar.v2.addCalendar', 'Add a calendar')}\n </Button>\n }\n />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,IAAMC,IAAQ,MAAM,KAAK,EAAE,QAAQ,GAAG,IAAI,GAAG,MAASC,CAAI;AAG1D,SAAgBC,EAAa,EAAE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C,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAACwD,GAAD;IACE,SAAA;IACA,MAAK;IACL,MAAK;IACL,cAAa;IACb,OAAOjD,EAAG,yBAAyB,uBAAuB;IAC1D,aACEK,IACIL,EACE,8BACA,8DACF,IACAA,EACE,gCACA,4FACF;IAEN,QACE,kBAACkD,GAAD;KACE,MAAK;KACL,eACEzD,EAAK,gBAAgB;MACnB,MAAMe;MACN,OAAOf,EAAK,eAAee,CAAG,CAAC,EAAE,SAAS;MAC1C,MAAMf,EAAK,eAAee,CAAG,CAAC,EAAE,SAAS,OAAUf,EAAK,MAAM;MAC9D,QAAQ;KACV,CAAC;KARL,UAAA,CAWE,kBAAC0D,GAAD,EAAM,eAAY,OAAQ,CAAA,GACzBnD,EAAG,wBAAwB,WAAW,CACjC;;IAEV,iBACE,kBAACkD,GAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,eAAezD,EAAK,IAAI,WAAW,OAAO;KAAlF,UAAA,CACE,kBAAC2D,GAAD,EAAc,eAAY,OAAQ,CAAA,GACjCpD,EAAG,2BAA2B,gBAAgB,CACzC;;GAEX,CAAA;EACE,CAAA;CACF,CAAA;AAET"}
@@ -1,61 +1,63 @@
1
1
  import { allDayItems as e, timedSegmentsByDay as t } from "../events/eventModel.js";
2
2
  import { formatDay as n } from "../format.js";
3
3
  import { useCalendarPage as r } from "../page/CalendarPageContext.js";
4
- import { MINUTES_PER_DAY as i } from "../time/calendarTime.js";
5
- import { VIEW_PANEL as a } from "../styles.js";
6
- import { AllDayRow as o } from "./AllDayRow.js";
7
- import { HOUR_HEIGHT as s, minBlockMinutes as ee, openingScrollTop as c, planKeyboardMove as l, sameTimes as u } from "./geometry.js";
8
- import { DayColumn as d, DayHeaderRow as f, GridEmpty as p, HourGutter as te } from "./GridParts.js";
9
- import { allDayLanes as ne, layoutDay as re } from "./layout.js";
10
- import { useGridDrag as m } from "./useGridDrag.js";
11
- import { useSlotCursor as h } from "./useSlotCursor.js";
12
- import { useCallback as g, useLayoutEffect as _, useMemo as v, useRef as y, useState as ie } from "react";
13
- import { jsx as b, jsxs as x } from "react/jsx-runtime";
14
- import { cn as ae } from "@burdenoff/fe-libs/utils";
4
+ import { RunsRow as i } from "../runs/RunPills.js";
5
+ import { useWorkflowRunsLayer as a } from "../runs/runsLayerContext.js";
6
+ import { MINUTES_PER_DAY as o } from "../time/calendarTime.js";
7
+ import { VIEW_PANEL as s } from "../styles.js";
8
+ import { AllDayRow as c } from "./AllDayRow.js";
9
+ import { HOUR_HEIGHT as l, minBlockMinutes as ee, openingScrollTop as u, planKeyboardMove as d, sameTimes as te } from "./geometry.js";
10
+ import { DayColumn as ne, DayHeaderRow as re, GridEmpty as f, HourGutter as p } from "./GridParts.js";
11
+ import { allDayLanes as ie, layoutDay as ae } from "./layout.js";
12
+ import { useGridDrag as oe } from "./useGridDrag.js";
13
+ import { useSlotCursor as m } from "./useSlotCursor.js";
14
+ import { useCallback as h, useLayoutEffect as g, useMemo as _, useRef as v, useState as se } from "react";
15
+ import { jsx as y, jsxs as b } from "react/jsx-runtime";
16
+ import { cn as x } from "@burdenoff/fe-libs/utils";
15
17
  // src/v2/grid/TimeGrid.tsx
16
18
  var S = {
17
19
  regular: 58,
18
20
  compact: 44
19
21
  }, C = (e) => e.id;
20
22
  function w() {
21
- let w = r(), { tr: oe, format: T, timeZone: E, compact: D, days: O, today: k, nowMinute: se, nav: A, prefs: j, events: M } = w, N = D ? s.compact : s.regular, P = D ? S.compact : S.regular, F = y(null), I = y(null), L = y(null), R = O[0] ?? A.date, z = O[O.length - 1] ?? A.date, B = O.includes(k), V = `${A.view}|${R}|${O.length}|${N}`, H = y(null);
22
- _(() => {
23
- let e = F.current;
23
+ let w = r(), { tr: T, format: E, timeZone: D, compact: O, days: k, today: A, nowMinute: ce, nav: j, prefs: M, events: N } = w, P = O ? l.compact : l.regular, F = O ? S.compact : S.regular, I = v(null), L = v(null), R = v(null), z = k[0] ?? j.date, B = k[k.length - 1] ?? j.date, V = k.includes(A), H = `${j.view}|${z}|${k.length}|${P}`, U = v(null);
24
+ g(() => {
25
+ let e = I.current;
24
26
  if (!e) return;
25
27
  let t = () => {
26
- H.current === V || e.scrollHeight <= e.clientHeight || (e.scrollTop = c(N), H.current = V);
28
+ U.current === H || e.scrollHeight <= e.clientHeight || (e.scrollTop = u(P), U.current = H);
27
29
  };
28
30
  if (t(), typeof ResizeObserver != "function") return;
29
31
  let n = new ResizeObserver(t);
30
32
  return n.observe(e), () => n.disconnect();
31
- }, [V, N]);
32
- let U = v(() => t(M, O, E), [
33
- O,
34
- M,
35
- E
36
- ]), W = v(() => {
37
- let e = ee(N);
38
- return new Map(O.map((t) => [t, re(U.get(t) ?? [], e, C)]));
39
- }, [
40
- O,
33
+ }, [H, P]);
34
+ let W = _(() => t(N, k, D), [
35
+ k,
41
36
  N,
42
- U
43
- ]), [G, ce] = ie(!1), K = v(() => ne(e(M, R, z, E), O, G ? Infinity : 3, C), [
37
+ D
38
+ ]), le = _(() => {
39
+ let e = ee(P);
40
+ return new Map(k.map((t) => [t, ae(W.get(t) ?? [], e, C)]));
41
+ }, [
42
+ k,
43
+ P,
44
+ W
45
+ ]), [G, ue] = se(!1), K = _(() => ie(e(N, z, B, D), k, G ? Infinity : 3, C), [
44
46
  G,
45
- O,
46
- M,
47
- R,
47
+ k,
48
+ N,
48
49
  z,
49
- E
50
- ]), le = v(() => new Map(M.map((e) => [e.id, e])), [M]), ue = g((e, t, n) => {
50
+ B,
51
+ D
52
+ ]), de = _(() => new Map(N.map((e) => [e.id, e])), [N]), fe = h((e, t, n) => {
51
53
  w.actions.changeTimes(e, t, n);
52
- }, [w.actions]), q = m({
53
- containerRef: I,
54
- hourHeight: N,
55
- timeZone: E,
56
- disabled: D,
57
- defaultDuration: j.defaultDuration,
58
- eventById: (e) => le.get(e),
54
+ }, [w.actions]), q = oe({
55
+ containerRef: L,
56
+ hourHeight: P,
57
+ timeZone: D,
58
+ disabled: O,
59
+ defaultDuration: M.defaultDuration,
60
+ eventById: (e) => de.get(e),
59
61
  canMove: (e) => w.lookOf(e).movable,
60
62
  onCreate: (e) => {
61
63
  w.closePeek(), w.openQuickCreate({
@@ -64,10 +66,10 @@ function w() {
64
66
  anchor: null
65
67
  });
66
68
  },
67
- onChange: ue
68
- }), de = (e, t) => {
69
- let n = Math.min(i, t + j.defaultDuration);
70
- D ? w.openEventDialog({
69
+ onChange: fe
70
+ }), pe = (e, t) => {
71
+ let n = Math.min(o, t + M.defaultDuration);
72
+ O ? w.openEventDialog({
71
73
  date: e,
72
74
  start: t,
73
75
  end: n,
@@ -79,21 +81,21 @@ function w() {
79
81
  allDay: !1,
80
82
  anchor: null
81
83
  }));
82
- }, J = h({
83
- scrollRef: F,
84
- headerRef: L,
85
- hourHeight: N,
86
- days: O,
87
- format: T,
84
+ }, J = m({
85
+ scrollRef: I,
86
+ headerRef: R,
87
+ hourHeight: P,
88
+ days: k,
89
+ format: E,
88
90
  workingHoursOn: w.workingHoursOn,
89
- start: () => B ? {
90
- date: k,
91
- minute: Math.min(i - 30, Math.ceil(se / 30) * 30)
91
+ start: () => V ? {
92
+ date: A,
93
+ minute: Math.min(o - 30, Math.ceil(ce / 30) * 30)
92
94
  } : {
93
- date: R,
94
- minute: w.workingHoursOn(R)?.start ?? 540
95
+ date: z,
96
+ minute: w.workingHoursOn(z)?.start ?? 540
95
97
  },
96
- onCreate: (e) => de(e.date, e.minute)
98
+ onCreate: (e) => pe(e.date, e.minute)
97
99
  }), Y = (e, t) => {
98
100
  let n = w.lookOf(t), r = e.key;
99
101
  if ((r === "Delete" || r === "Backspace") && n.editable) {
@@ -106,55 +108,62 @@ function w() {
106
108
  let e = {
107
109
  start: t.start,
108
110
  end: t.end
109
- }, i = l(e, r, E);
110
- if (u(e, i)) return;
111
- w.actions.changeTimes(t, i, "move"), requestAnimationFrame(() => F.current?.querySelector(`[data-event-id="${CSS.escape(t.id)}"]`)?.focus());
111
+ }, i = d(e, r, D);
112
+ if (te(e, i)) return;
113
+ w.actions.changeTimes(t, i, "move"), requestAnimationFrame(() => I.current?.querySelector(`[data-event-id="${CSS.escape(t.id)}"]`)?.focus());
112
114
  return;
113
115
  }
114
- let i = [...F.current?.querySelectorAll("[data-event-id]") ?? []], a = i.indexOf(e.currentTarget);
116
+ let i = [...I.current?.querySelectorAll("[data-event-id]") ?? []], a = i.indexOf(e.currentTarget);
115
117
  (r === "ArrowDown" || r === "ArrowRight" ? i[a + 1] : i[a - 1])?.focus();
116
- }, X = A.eventId, Z = (e, t) => {
117
- !D && X === e.id ? w.closePeek() : w.openPeek(e, t);
118
- }, Q = w.quickDraft && O.includes(w.quickDraft.date) && !w.quickDraft.allDay ? w.quickDraft : null, fe = w.state.kind === "ready" && w.state.empty && K.bars.length === 0, $ = { gridTemplateColumns: `${P}px repeat(${O.length}, minmax(0, 1fr))` }, pe = A.view === "day" ? n(R, T, "full") : `${n(R, T, "short")} – ${n(z, T, "short")}`;
119
- return /* @__PURE__ */ x("section", {
120
- className: a,
121
- "aria-label": pe,
118
+ }, X = j.eventId, Z = (e, t) => {
119
+ !O && X === e.id ? w.closePeek() : w.openPeek(e, t);
120
+ }, Q = w.quickDraft && k.includes(w.quickDraft.date) && !w.quickDraft.allDay ? w.quickDraft : null, me = a().shownCount > 0, he = w.state.kind === "ready" && w.state.empty && K.bars.length === 0 && !me, $ = { gridTemplateColumns: `${F}px repeat(${k.length}, minmax(0, 1fr))` }, ge = j.view === "day" ? n(z, E, "full") : `${n(z, E, "short")} – ${n(B, E, "short")}`;
121
+ return /* @__PURE__ */ b("section", {
122
+ className: s,
123
+ "aria-label": ge,
122
124
  "data-testid": "time-grid",
123
125
  children: [
124
- /* @__PURE__ */ x("div", {
125
- ref: F,
126
+ /* @__PURE__ */ b("div", {
127
+ ref: I,
126
128
  tabIndex: 0,
127
129
  role: "group",
128
- "aria-label": oe("calendar.v2.gridLabel", "Time grid. Arrow keys pick a time, Enter adds an event, Tab moves through events."),
130
+ "aria-label": T("calendar.v2.gridLabel", "Time grid. Arrow keys pick a time, Enter adds an event, Tab moves through events."),
129
131
  onFocus: J.onFocus,
130
132
  onBlur: J.onBlur,
131
133
  onKeyDown: J.onKeyDown,
132
- className: ae("relative min-h-0 flex-1 overflow-auto overscroll-contain [overflow-anchor:none] focus-visible:outline-none", q.dragging && "cursor-grabbing select-none"),
133
- children: [/* @__PURE__ */ x("div", {
134
- ref: L,
134
+ className: x("relative min-h-0 flex-1 overflow-auto overscroll-contain [overflow-anchor:none] focus-visible:outline-none", q.dragging && "cursor-grabbing select-none"),
135
+ children: [/* @__PURE__ */ b("div", {
136
+ ref: R,
135
137
  className: "sticky top-0 z-20 bg-bg-surface",
136
- children: [/* @__PURE__ */ b(f, { columnsStyle: $ }), /* @__PURE__ */ b(o, {
137
- days: O,
138
- lanes: K,
139
- expanded: G,
140
- onToggle: () => ce((e) => !e),
141
- gutter: P,
142
- selectedId: X,
143
- onOpen: Z,
144
- onKeyDown: Y
145
- })]
146
- }), /* @__PURE__ */ x("div", {
147
- ref: I,
138
+ children: [
139
+ /* @__PURE__ */ y(re, { columnsStyle: $ }),
140
+ /* @__PURE__ */ y(c, {
141
+ days: k,
142
+ lanes: K,
143
+ expanded: G,
144
+ onToggle: () => ue((e) => !e),
145
+ gutter: F,
146
+ selectedId: X,
147
+ onOpen: Z,
148
+ onKeyDown: Y
149
+ }),
150
+ /* @__PURE__ */ y(i, {
151
+ days: k,
152
+ gutter: F
153
+ })
154
+ ]
155
+ }), /* @__PURE__ */ b("div", {
156
+ ref: L,
148
157
  className: "relative grid",
149
158
  style: {
150
159
  ...$,
151
- height: 24 * N
160
+ height: 24 * P
152
161
  },
153
162
  ...q.handlers,
154
- children: [/* @__PURE__ */ b(te, { hourHeight: N }), O.map((e) => /* @__PURE__ */ b(d, {
163
+ children: [/* @__PURE__ */ y(p, { hourHeight: P }), k.map((e) => /* @__PURE__ */ y(ne, {
155
164
  day: e,
156
- placed: W.get(e) ?? [],
157
- hourHeight: N,
165
+ placed: le.get(e) ?? [],
166
+ hourHeight: P,
158
167
  selectedId: X,
159
168
  onOpen: Z,
160
169
  onKeyDown: Y,
@@ -165,12 +174,12 @@ function w() {
165
174
  }, e))]
166
175
  })]
167
176
  }),
168
- /* @__PURE__ */ b("p", {
177
+ /* @__PURE__ */ y("p", {
169
178
  className: "sr-only",
170
179
  "aria-live": "polite",
171
180
  children: J.announcement
172
181
  }),
173
- fe ? /* @__PURE__ */ b(p, {}) : null
182
+ he ? /* @__PURE__ */ y(f, {}) : null
174
183
  ]
175
184
  });
176
185
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TimeGrid.js","names":["GUTTER","eventKey","event","TimeGrid","page","useCalendarPage","hourHeight","compact","HOUR_HEIGHT","gutter","scrollRef","useRef","bodyRef","topRef","first","days","nav","last","showsToday","today","openingKey","openedRef","scroller","open","openingScrollTop","observer","segments","useMemo","timedSegmentsByDay","events","timeZone","placedByDay","minMinutes","minBlockMinutes","day","layoutDay","allDayOpen","setAllDayOpen","useState","lanes","allDayLanes","allDayItems","eventsById","changeTimes","useCallback","next","kind","drag","useGridDrag","prefs","id","draft","newEventAt","end","MINUTES_PER_DAY","start","slot","useSlotCursor","nowMinute","cursor","onEventKeyDown","look","calendarEvent","key","keyEvent","times","planKeyboardMove","sameTimes","all","at","selectedId","openEvent","element","quick","showEmpty","columnsStyle","title","formatDay","format","VIEW_PANEL","tr","cn","DayHeaderRow","AllDayRow","HourGutter","DayColumn","GridEmpty"],"sources":["../../../src/v2/grid/TimeGrid.tsx"],"sourcesContent":["/**\n * The time grid (BOFF-15698 A1): Week (7 days, or 5 without the weekend), Day, and 3 days on\n * phones. A sticky header with the days and the all-day row; then 24 hours that open scrolled\n * so 08:00 is fully visible; working hours unshaded; the now line with its time; events laid\n * out side by side where they overlap.\n *\n * Desktop: click-drag on free time makes an event, events drag to move and resize (Undo in the\n * toast). Keyboard: the grid takes focus as a slot cursor (arrows pick a half hour, Enter makes\n * an event there), Tab and the arrows go through events, Shift + arrows move one, Delete deletes\n * one (Undo in the toast).\n */\nimport {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n} from 'react';\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { allDayItems, timedSegmentsByDay } from '../events/eventModel';\nimport { formatDay } from '../format';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { MINUTES_PER_DAY } from '../time/calendarTime';\nimport { VIEW_PANEL } from '../styles';\nimport type { CalendarEventV2 } from '../types';\nimport { AllDayRow, ALL_DAY_MAX_LANES } from './AllDayRow';\nimport {\n CURSOR_STEP,\n HOUR_HEIGHT,\n minBlockMinutes,\n openingScrollTop,\n planKeyboardMove,\n sameTimes,\n type EventTimes,\n} from './geometry';\nimport { DayColumn, DayHeaderRow, GridEmpty, HourGutter } from './GridParts';\nimport { allDayLanes, layoutDay } from './layout';\nimport { useGridDrag } from './useGridDrag';\nimport { useSlotCursor } from './useSlotCursor';\n\nconst GUTTER = { regular: 58, compact: 44 } as const;\n\nconst eventKey = (event: CalendarEventV2) => event.id;\n\nexport function TimeGrid() {\n const page = useCalendarPage();\n const { tr, format, timeZone, compact, days, today, nowMinute, nav, prefs, events } = page;\n const hourHeight = compact ? HOUR_HEIGHT.compact : HOUR_HEIGHT.regular;\n const gutter = compact ? GUTTER.compact : GUTTER.regular;\n const scrollRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const topRef = useRef<HTMLDivElement>(null);\n const first = days[0] ?? nav.date;\n const last = days[days.length - 1] ?? nav.date;\n const showsToday = days.includes(today);\n\n // Opens at 08:00 whenever the view or its days change, as soon as the grid can scroll (the\n // page measures its height after the first paint).\n const openingKey = `${nav.view}|${first}|${days.length}|${hourHeight}`;\n const openedRef = useRef<string | null>(null);\n useLayoutEffect(() => {\n const scroller = scrollRef.current;\n if (!scroller) return undefined;\n const open = () => {\n if (openedRef.current === openingKey || scroller.scrollHeight <= scroller.clientHeight)\n return;\n scroller.scrollTop = openingScrollTop(hourHeight);\n openedRef.current = openingKey;\n };\n open();\n if (typeof ResizeObserver !== 'function') return undefined;\n const observer = new ResizeObserver(open);\n observer.observe(scroller);\n return () => observer.disconnect();\n }, [openingKey, hourHeight]);\n\n const segments = useMemo(\n () => timedSegmentsByDay(events, days, timeZone),\n [days, events, timeZone]\n );\n const placedByDay = useMemo(() => {\n const minMinutes = minBlockMinutes(hourHeight);\n return new Map(\n days.map((day) => [day, layoutDay(segments.get(day) ?? [], minMinutes, eventKey)])\n );\n }, [days, hourHeight, segments]);\n const [allDayOpen, setAllDayOpen] = useState(false);\n const lanes = useMemo(\n () =>\n allDayLanes(\n allDayItems(events, first, last, timeZone),\n days,\n allDayOpen ? Number.POSITIVE_INFINITY : ALL_DAY_MAX_LANES,\n eventKey\n ),\n [allDayOpen, days, events, first, last, timeZone]\n );\n\n const eventsById = useMemo(() => new Map(events.map((event) => [event.id, event])), [events]);\n const changeTimes = useCallback(\n (event: CalendarEventV2, next: EventTimes, kind: 'move' | 'resize') => {\n void page.actions.changeTimes(event, next, kind);\n },\n [page.actions]\n );\n const drag = useGridDrag({\n containerRef: bodyRef,\n hourHeight,\n timeZone,\n disabled: compact,\n defaultDuration: prefs.defaultDuration,\n eventById: (id) => eventsById.get(id),\n canMove: (event) => page.lookOf(event).movable,\n onCreate: (draft) => {\n page.closePeek();\n page.openQuickCreate({ ...draft, allDay: false, anchor: null });\n },\n onChange: changeTimes,\n });\n\n // ── the slot cursor (keyboard) ──\n const newEventAt = (date: DateValue, start: number) => {\n const end = Math.min(MINUTES_PER_DAY, start + prefs.defaultDuration);\n if (compact) {\n page.openEventDialog({ date, start, end, allDay: false });\n return;\n }\n page.closePeek();\n page.openQuickCreate({ date, start, end, allDay: false, anchor: null });\n };\n const slot = useSlotCursor({\n scrollRef,\n headerRef: topRef,\n hourHeight,\n days,\n format,\n workingHoursOn: page.workingHoursOn,\n // Today at the coming half hour, else the first day's working start.\n start: () =>\n showsToday\n ? {\n date: today,\n minute: Math.min(\n MINUTES_PER_DAY - CURSOR_STEP,\n Math.ceil(nowMinute / CURSOR_STEP) * CURSOR_STEP\n ),\n }\n : { date: first, minute: page.workingHoursOn(first)?.start ?? 9 * 60 },\n onCreate: (cursor) => newEventAt(cursor.date, cursor.minute),\n });\n\n // Keys on an event: Delete, Shift + arrows to move, arrows to go to the next one.\n const onEventKeyDown = (\n keyEvent: KeyboardEvent<HTMLButtonElement>,\n calendarEvent: CalendarEventV2\n ) => {\n const look = page.lookOf(calendarEvent);\n const key = keyEvent.key;\n if ((key === 'Delete' || key === 'Backspace') && look.editable) {\n keyEvent.preventDefault();\n void page.actions.remove(calendarEvent);\n return;\n }\n const arrow =\n key === 'ArrowUp' || key === 'ArrowDown' || key === 'ArrowLeft' || key === 'ArrowRight';\n if (!arrow) return;\n keyEvent.preventDefault();\n if (keyEvent.shiftKey) {\n if (!look.movable) return;\n const times = { start: calendarEvent.start, end: calendarEvent.end };\n const next = planKeyboardMove(times, key, timeZone);\n if (sameTimes(times, next)) return;\n void page.actions.changeTimes(calendarEvent, next, 'move');\n // The event shows at its new place at once (on another day, a new block): keep the focus on it.\n requestAnimationFrame(() =>\n scrollRef.current\n ?.querySelector<HTMLElement>(`[data-event-id=\"${CSS.escape(calendarEvent.id)}\"]`)\n ?.focus()\n );\n return;\n }\n const all = [...(scrollRef.current?.querySelectorAll<HTMLElement>('[data-event-id]') ?? [])];\n const at = all.indexOf(keyEvent.currentTarget);\n const next = key === 'ArrowDown' || key === 'ArrowRight' ? all[at + 1] : all[at - 1];\n next?.focus();\n };\n\n const selectedId = nav.eventId;\n const openEvent = (event: CalendarEventV2, element: HTMLElement) => {\n if (!compact && selectedId === event.id) {\n page.closePeek();\n return;\n }\n page.openPeek(event, element);\n };\n\n const quick =\n page.quickDraft && days.includes(page.quickDraft.date) && !page.quickDraft.allDay\n ? page.quickDraft\n : null;\n const showEmpty = page.state.kind === 'ready' && page.state.empty && lanes.bars.length === 0;\n const columnsStyle: CSSProperties = {\n gridTemplateColumns: `${gutter}px repeat(${days.length}, minmax(0, 1fr))`,\n };\n const title =\n nav.view === 'day'\n ? formatDay(first, format, 'full')\n : `${formatDay(first, format, 'short')} – ${formatDay(last, format, 'short')}`;\n\n return (\n <section className={VIEW_PANEL} aria-label={title} data-testid=\"time-grid\">\n <div\n ref={scrollRef}\n tabIndex={0}\n role=\"group\"\n aria-label={tr(\n 'calendar.v2.gridLabel',\n 'Time grid. Arrow keys pick a time, Enter adds an event, Tab moves through events.'\n )}\n onFocus={slot.onFocus}\n onBlur={slot.onBlur}\n onKeyDown={slot.onKeyDown}\n className={cn(\n 'relative min-h-0 flex-1 overflow-auto overscroll-contain [overflow-anchor:none] focus-visible:outline-none',\n drag.dragging && 'cursor-grabbing select-none'\n )}\n >\n <div ref={topRef} className=\"sticky top-0 z-20 bg-bg-surface\">\n <DayHeaderRow columnsStyle={columnsStyle} />\n <AllDayRow\n days={days}\n lanes={lanes}\n expanded={allDayOpen}\n onToggle={() => setAllDayOpen((open) => !open)}\n gutter={gutter}\n selectedId={selectedId}\n onOpen={openEvent}\n onKeyDown={onEventKeyDown}\n />\n </div>\n\n <div\n ref={bodyRef}\n className=\"relative grid\"\n style={{ ...columnsStyle, height: 24 * hourHeight }}\n {...drag.handlers}\n >\n <HourGutter hourHeight={hourHeight} />\n {days.map((day) => (\n <DayColumn\n key={day}\n day={day}\n placed={placedByDay.get(day) ?? []}\n hourHeight={hourHeight}\n selectedId={selectedId}\n onOpen={openEvent}\n onKeyDown={onEventKeyDown}\n consumeClick={drag.consumeClick}\n ghost={drag.ghost && drag.ghost.date === day ? drag.ghost : null}\n quick={quick && quick.date === day && !drag.ghost ? quick : null}\n cursorMinute={slot.cursor && slot.cursor.date === day ? slot.cursor.minute : null}\n />\n ))}\n </div>\n </div>\n <p className=\"sr-only\" aria-live=\"polite\">\n {slot.announcement}\n </p>\n {showEmpty ? <GridEmpty /> : null}\n </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,KAAK,CAAC;MACrB;MACA;MACZ,QAAQqC;MACR,WAAWX;MACX,cAAcb,EAAK;MACnB,OAAOA,EAAK,SAASA,EAAK,MAAM,SAASb,IAAMa,EAAK,QAAQ;MAC5D,OAAO0B,KAASA,EAAM,SAASvC,KAAO,CAACa,EAAK,QAAQ0B,IAAQ;MAC5D,cAAcjB,EAAK,UAAUA,EAAK,OAAO,SAAStB,IAAMsB,EAAK,OAAO,SAAS;KAC9E,GAXMtB,CAWN,CACF,CACE;IACF,CAAA,CAAA;;GACL,kBAAC,KAAD;IAAG,WAAU;IAAU,aAAU;IAC9B,UAAAsB,EAAK;GACL,CAAA;GACFkB,KAAY,kBAACY,GAAD,CAAY,CAAA,IAAI;EACtB;;AAEb"}
1
+ {"version":3,"file":"TimeGrid.js","names":["GUTTER","eventKey","event","TimeGrid","page","useCalendarPage","hourHeight","compact","HOUR_HEIGHT","gutter","scrollRef","useRef","bodyRef","topRef","first","days","nav","last","showsToday","today","openingKey","openedRef","scroller","open","openingScrollTop","observer","segments","useMemo","timedSegmentsByDay","events","timeZone","placedByDay","minMinutes","minBlockMinutes","day","layoutDay","allDayOpen","setAllDayOpen","useState","lanes","allDayLanes","allDayItems","eventsById","changeTimes","useCallback","next","kind","drag","useGridDrag","prefs","id","draft","newEventAt","end","MINUTES_PER_DAY","start","slot","useSlotCursor","nowMinute","cursor","onEventKeyDown","look","calendarEvent","key","keyEvent","times","planKeyboardMove","sameTimes","all","at","selectedId","openEvent","element","quick","runsShown","useWorkflowRunsLayer","showEmpty","columnsStyle","title","formatDay","format","VIEW_PANEL","tr","cn","DayHeaderRow","AllDayRow","RunsRow","HourGutter","DayColumn","GridEmpty"],"sources":["../../../src/v2/grid/TimeGrid.tsx"],"sourcesContent":["/**\n * The time grid (BOFF-15698 A1): Week (7 days, or 5 without the weekend), Day, and 3 days on\n * phones. A sticky header with the days and the all-day row; then 24 hours that open scrolled\n * so 08:00 is fully visible; working hours unshaded; the now line with its time; events laid\n * out side by side where they overlap.\n *\n * Desktop: click-drag on free time makes an event, events drag to move and resize (Undo in the\n * toast). Keyboard: the grid takes focus as a slot cursor (arrows pick a half hour, Enter makes\n * an event there), Tab and the arrows go through events, Shift + arrows move one, Delete deletes\n * one (Undo in the toast).\n */\nimport {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n} from 'react';\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { allDayItems, timedSegmentsByDay } from '../events/eventModel';\nimport { formatDay } from '../format';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { RunsRow } from '../runs/RunPills';\nimport { useWorkflowRunsLayer } from '../runs/runsLayerContext';\nimport { MINUTES_PER_DAY } from '../time/calendarTime';\nimport { VIEW_PANEL } from '../styles';\nimport type { CalendarEventV2 } from '../types';\nimport { AllDayRow, ALL_DAY_MAX_LANES } from './AllDayRow';\nimport {\n CURSOR_STEP,\n HOUR_HEIGHT,\n minBlockMinutes,\n openingScrollTop,\n planKeyboardMove,\n sameTimes,\n type EventTimes,\n} from './geometry';\nimport { DayColumn, DayHeaderRow, GridEmpty, HourGutter } from './GridParts';\nimport { allDayLanes, layoutDay } from './layout';\nimport { useGridDrag } from './useGridDrag';\nimport { useSlotCursor } from './useSlotCursor';\n\nconst GUTTER = { regular: 58, compact: 44 } as const;\n\nconst eventKey = (event: CalendarEventV2) => event.id;\n\nexport function TimeGrid() {\n const page = useCalendarPage();\n const { tr, format, timeZone, compact, days, today, nowMinute, nav, prefs, events } = page;\n const hourHeight = compact ? HOUR_HEIGHT.compact : HOUR_HEIGHT.regular;\n const gutter = compact ? GUTTER.compact : GUTTER.regular;\n const scrollRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const topRef = useRef<HTMLDivElement>(null);\n const first = days[0] ?? nav.date;\n const last = days[days.length - 1] ?? nav.date;\n const showsToday = days.includes(today);\n\n // Opens at 08:00 whenever the view or its days change, as soon as the grid can scroll (the\n // page measures its height after the first paint).\n const openingKey = `${nav.view}|${first}|${days.length}|${hourHeight}`;\n const openedRef = useRef<string | null>(null);\n useLayoutEffect(() => {\n const scroller = scrollRef.current;\n if (!scroller) return undefined;\n const open = () => {\n if (openedRef.current === openingKey || scroller.scrollHeight <= scroller.clientHeight)\n return;\n scroller.scrollTop = openingScrollTop(hourHeight);\n openedRef.current = openingKey;\n };\n open();\n if (typeof ResizeObserver !== 'function') return undefined;\n const observer = new ResizeObserver(open);\n observer.observe(scroller);\n return () => observer.disconnect();\n }, [openingKey, hourHeight]);\n\n const segments = useMemo(\n () => timedSegmentsByDay(events, days, timeZone),\n [days, events, timeZone]\n );\n const placedByDay = useMemo(() => {\n const minMinutes = minBlockMinutes(hourHeight);\n return new Map(\n days.map((day) => [day, layoutDay(segments.get(day) ?? [], minMinutes, eventKey)])\n );\n }, [days, hourHeight, segments]);\n const [allDayOpen, setAllDayOpen] = useState(false);\n const lanes = useMemo(\n () =>\n allDayLanes(\n allDayItems(events, first, last, timeZone),\n days,\n allDayOpen ? Number.POSITIVE_INFINITY : ALL_DAY_MAX_LANES,\n eventKey\n ),\n [allDayOpen, days, events, first, last, timeZone]\n );\n\n const eventsById = useMemo(() => new Map(events.map((event) => [event.id, event])), [events]);\n const changeTimes = useCallback(\n (event: CalendarEventV2, next: EventTimes, kind: 'move' | 'resize') => {\n void page.actions.changeTimes(event, next, kind);\n },\n [page.actions]\n );\n const drag = useGridDrag({\n containerRef: bodyRef,\n hourHeight,\n timeZone,\n disabled: compact,\n defaultDuration: prefs.defaultDuration,\n eventById: (id) => eventsById.get(id),\n canMove: (event) => page.lookOf(event).movable,\n onCreate: (draft) => {\n page.closePeek();\n page.openQuickCreate({ ...draft, allDay: false, anchor: null });\n },\n onChange: changeTimes,\n });\n\n // ── the slot cursor (keyboard) ──\n const newEventAt = (date: DateValue, start: number) => {\n const end = Math.min(MINUTES_PER_DAY, start + prefs.defaultDuration);\n if (compact) {\n page.openEventDialog({ date, start, end, allDay: false });\n return;\n }\n page.closePeek();\n page.openQuickCreate({ date, start, end, allDay: false, anchor: null });\n };\n const slot = useSlotCursor({\n scrollRef,\n headerRef: topRef,\n hourHeight,\n days,\n format,\n workingHoursOn: page.workingHoursOn,\n // Today at the coming half hour, else the first day's working start.\n start: () =>\n showsToday\n ? {\n date: today,\n minute: Math.min(\n MINUTES_PER_DAY - CURSOR_STEP,\n Math.ceil(nowMinute / CURSOR_STEP) * CURSOR_STEP\n ),\n }\n : { date: first, minute: page.workingHoursOn(first)?.start ?? 9 * 60 },\n onCreate: (cursor) => newEventAt(cursor.date, cursor.minute),\n });\n\n // Keys on an event: Delete, Shift + arrows to move, arrows to go to the next one.\n const onEventKeyDown = (\n keyEvent: KeyboardEvent<HTMLButtonElement>,\n calendarEvent: CalendarEventV2\n ) => {\n const look = page.lookOf(calendarEvent);\n const key = keyEvent.key;\n if ((key === 'Delete' || key === 'Backspace') && look.editable) {\n keyEvent.preventDefault();\n void page.actions.remove(calendarEvent);\n return;\n }\n const arrow =\n key === 'ArrowUp' || key === 'ArrowDown' || key === 'ArrowLeft' || key === 'ArrowRight';\n if (!arrow) return;\n keyEvent.preventDefault();\n if (keyEvent.shiftKey) {\n if (!look.movable) return;\n const times = { start: calendarEvent.start, end: calendarEvent.end };\n const next = planKeyboardMove(times, key, timeZone);\n if (sameTimes(times, next)) return;\n void page.actions.changeTimes(calendarEvent, next, 'move');\n // The event shows at its new place at once (on another day, a new block): keep the focus on it.\n requestAnimationFrame(() =>\n scrollRef.current\n ?.querySelector<HTMLElement>(`[data-event-id=\"${CSS.escape(calendarEvent.id)}\"]`)\n ?.focus()\n );\n return;\n }\n const all = [...(scrollRef.current?.querySelectorAll<HTMLElement>('[data-event-id]') ?? [])];\n const at = all.indexOf(keyEvent.currentTarget);\n const next = key === 'ArrowDown' || key === 'ArrowRight' ? all[at + 1] : all[at - 1];\n next?.focus();\n };\n\n const selectedId = nav.eventId;\n const openEvent = (event: CalendarEventV2, element: HTMLElement) => {\n if (!compact && selectedId === event.id) {\n page.closePeek();\n return;\n }\n page.openPeek(event, element);\n };\n\n const quick =\n page.quickDraft && days.includes(page.quickDraft.date) && !page.quickDraft.allDay\n ? page.quickDraft\n : null;\n // Workflow runs on these days aren't \"nothing\" either.\n const runsShown = useWorkflowRunsLayer().shownCount > 0;\n const showEmpty =\n page.state.kind === 'ready' && page.state.empty && lanes.bars.length === 0 && !runsShown;\n const columnsStyle: CSSProperties = {\n gridTemplateColumns: `${gutter}px repeat(${days.length}, minmax(0, 1fr))`,\n };\n const title =\n nav.view === 'day'\n ? formatDay(first, format, 'full')\n : `${formatDay(first, format, 'short')} – ${formatDay(last, format, 'short')}`;\n\n return (\n <section className={VIEW_PANEL} aria-label={title} data-testid=\"time-grid\">\n <div\n ref={scrollRef}\n tabIndex={0}\n role=\"group\"\n aria-label={tr(\n 'calendar.v2.gridLabel',\n 'Time grid. Arrow keys pick a time, Enter adds an event, Tab moves through events.'\n )}\n onFocus={slot.onFocus}\n onBlur={slot.onBlur}\n onKeyDown={slot.onKeyDown}\n className={cn(\n 'relative min-h-0 flex-1 overflow-auto overscroll-contain [overflow-anchor:none] focus-visible:outline-none',\n drag.dragging && 'cursor-grabbing select-none'\n )}\n >\n <div ref={topRef} className=\"sticky top-0 z-20 bg-bg-surface\">\n <DayHeaderRow columnsStyle={columnsStyle} />\n <AllDayRow\n days={days}\n lanes={lanes}\n expanded={allDayOpen}\n onToggle={() => setAllDayOpen((open) => !open)}\n gutter={gutter}\n selectedId={selectedId}\n onOpen={openEvent}\n onKeyDown={onEventKeyDown}\n />\n <RunsRow days={days} gutter={gutter} />\n </div>\n\n <div\n ref={bodyRef}\n className=\"relative grid\"\n style={{ ...columnsStyle, height: 24 * hourHeight }}\n {...drag.handlers}\n >\n <HourGutter hourHeight={hourHeight} />\n {days.map((day) => (\n <DayColumn\n key={day}\n day={day}\n placed={placedByDay.get(day) ?? []}\n hourHeight={hourHeight}\n selectedId={selectedId}\n onOpen={openEvent}\n onKeyDown={onEventKeyDown}\n consumeClick={drag.consumeClick}\n ghost={drag.ghost && drag.ghost.date === day ? drag.ghost : null}\n quick={quick && quick.date === day && !drag.ghost ? quick : null}\n cursorMinute={slot.cursor && slot.cursor.date === day ? slot.cursor.minute : null}\n />\n ))}\n </div>\n </div>\n <p className=\"sr-only\" aria-live=\"polite\">\n {slot.announcement}\n </p>\n {showEmpty ? <GridEmpty /> : null}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,IAAMA,IAAS;CAAE,SAAS;CAAI,SAAS;AAAG,GAEpCC,KAAY,MAA2BC,EAAM;AAEnD,SAAgBC,IAAW;CACzB,IAAMC,IAAOC,EAAgB,GACvB,EAAE,OAAI,WAAQ,aAAU,YAAS,SAAM,UAAO,eAAW,QAAK,UAAO,cAAWD,GAChFE,IAAaC,IAAUC,EAAY,UAAUA,EAAY,SACzDC,IAASF,IAAUP,EAAO,UAAUA,EAAO,SAC3CU,IAAYC,EAAuB,IAAI,GACvCC,IAAUD,EAAuB,IAAI,GACrCE,IAASF,EAAuB,IAAI,GACpCG,IAAQC,EAAK,MAAMC,EAAI,MACvBC,IAAOF,EAAKA,EAAK,SAAS,MAAMC,EAAI,MACpCE,IAAaH,EAAK,SAASI,CAAK,GAIhCC,IAAa,GAAGJ,EAAI,KAAK,GAAGF,EAAM,GAAGC,EAAK,OAAO,GAAGT,KACpDe,IAAYV,EAAsB,IAAI;CAC5C,QAAsB;EACpB,IAAMW,IAAWZ,EAAU;EAC3B,IAAI,CAACY,GAAU;EACf,IAAMC,UAAa;GACjB,AAAIF,EAAU,YAAYD,KAAcE,EAAS,gBAAgBA,EAAS,iBAE1E,EAAS,YAAYE,EAAiBlB,CAAU,GAChD,EAAU,UAAUc;EACtB;EAEA,IADAG,EAAK,GACD,OAAO,kBAAmB,YAAY;EAC1C,IAAME,IAAW,IAAI,eAAeF,CAAI;EAExC,OADAE,EAAS,QAAQH,CAAQ,SACZG,E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gBC,IAAe,MAAS,CAACd,CAAI;OACrC;OACI;OACZ,QAAQgD;OACR,WAAWX;MACZ,CAAA;MACD,kBAAC0B,GAAD;OAAe;OAAc;MAAS,CAAA;KACnC;IAEL,CAAA,GAAA,kBAAC,OAAD;KACE,KAAK1E;KACL,WAAU;KACV,OAAO;MAAE,GAAGiE;MAAc,QAAQ,KAAKvE;KAAW;KAClD,GAAIyC,EAAK;KAJX,UAAA,CAME,kBAACwC,GAAD,EAAwB,cAAa,CAAA,GACpCxE,EAAK,KAAK,MACT,kBAACyE,IAAD;MAEO;MACL,QAAQzD,GAAY,IAAIG,CAAG,KAAK,CAAC;MACrB;MACA;MACZ,QAAQqC;MACR,WAAWX;MACX,cAAcb,EAAK;MACnB,OAAOA,EAAK,SAASA,EAAK,MAAM,SAASb,IAAMa,EAAK,QAAQ;MAC5D,OAAO0B,KAASA,EAAM,SAASvC,KAAO,CAACa,EAAK,QAAQ0B,IAAQ;MAC5D,cAAcjB,EAAK,UAAUA,EAAK,OAAO,SAAStB,IAAMsB,EAAK,OAAO,SAAS;KAC9E,GAXMtB,CAWN,CACF,CACE;IACF,CAAA,CAAA;;GACL,kBAAC,KAAD;IAAG,WAAU;IAAU,aAAU;IAC9B,UAAAsB,EAAK;GACL,CAAA;GACFoB,KAAY,kBAACa,GAAD,CAAY,CAAA,IAAI;EACtB;;AAEb"}
@@ -4,9 +4,13 @@ export interface DayGroup {
4
4
  date: DateValue;
5
5
  events: CalendarEventV2[];
6
6
  }
7
- /** Days and their events, each day's heading on the left (above on phones). */
8
- export declare function DayGroups({ groups, label }: {
7
+ /**
8
+ * Days and their events, each day's heading on the left (above on phones). `withRuns`: the
9
+ * workflow runs among them (the List view; search lists events only).
10
+ */
11
+ export declare function DayGroups({ groups, label, withRuns, }: {
9
12
  groups: readonly DayGroup[];
10
13
  label: string;
14
+ withRuns?: boolean;
11
15
  }): import('react').JSX.Element;
12
16
  export declare function ListViewV2(): import('react').JSX.Element;
@@ -1,44 +1,49 @@
1
1
  import { eventsOnDay as e } from "../events/eventModel.js";
2
2
  import { formatDay as t } from "../format.js";
3
3
  import { useCalendarPage as n } from "../page/CalendarPageContext.js";
4
- import { VIEW_PANEL as r } from "../styles.js";
5
- import { EventListRow as i } from "./EventListRow.js";
6
- import { Plus as a } from "lucide-react";
7
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
- import { Button as c, EmptyState as l, addDays as u } from "@burdenoff/fe-libs/ui";
9
- import { cn as d } from "@burdenoff/fe-libs/utils";
4
+ import { DayRowsWithRuns as r } from "../runs/RunRows.js";
5
+ import { useWorkflowRunsLayer as i } from "../runs/runsLayerContext.js";
6
+ import { VIEW_PANEL as a } from "../styles.js";
7
+ import { EventListRow as o } from "./EventListRow.js";
8
+ import { Plus as s } from "lucide-react";
9
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
10
+ import { Button as u, EmptyState as d, addDays as f } from "@burdenoff/fe-libs/ui";
11
+ import { cn as p } from "@burdenoff/fe-libs/utils";
10
12
  // src/v2/list/ListViewV2.tsx
11
- function f({ date: e }) {
12
- let { tr: r, format: i, today: a } = n(), c = e === a, l = c ? r("calendar.v2.today", "Today") : e === u(a, 1) ? r("calendar.v2.tomorrow", "Tomorrow") : e === u(a, -1) ? r("calendar.v2.yesterday", "Yesterday") : null;
13
- return /* @__PURE__ */ s("div", {
13
+ function m({ date: e }) {
14
+ let { tr: r, format: i, today: a } = n(), o = e === a, s = o ? r("calendar.v2.today", "Today") : e === f(a, 1) ? r("calendar.v2.tomorrow", "Tomorrow") : e === f(a, -1) ? r("calendar.v2.yesterday", "Yesterday") : null;
15
+ return /* @__PURE__ */ l("div", {
14
16
  className: "flex w-[92px] shrink-0 flex-wrap content-start items-baseline gap-x-1.5 pt-2.5 max-md:w-auto max-md:pt-2",
15
17
  children: [
16
- /* @__PURE__ */ o("span", {
17
- className: d("text-2xl font-semibold tabular-nums max-md:text-lg", c ? "text-action-primary-bg" : "text-text-primary"),
18
+ /* @__PURE__ */ c("span", {
19
+ className: p("text-2xl font-semibold tabular-nums max-md:text-lg", o ? "text-action-primary-bg" : "text-text-primary"),
18
20
  children: t(e, i, "dayNumber")
19
21
  }),
20
- /* @__PURE__ */ o("span", {
21
- className: d("text-xs font-semibold uppercase", c ? "text-action-primary-bg" : "text-text-secondary"),
22
+ /* @__PURE__ */ c("span", {
23
+ className: p("text-xs font-semibold uppercase", o ? "text-action-primary-bg" : "text-text-secondary"),
22
24
  children: t(e, i, "weekday")
23
25
  }),
24
- /* @__PURE__ */ s("span", {
25
- className: d("w-full text-xs text-text-muted max-md:w-auto", c && "font-semibold text-action-primary-bg"),
26
- children: [t(e, i, "monthShort"), l ? ` · ${l}` : ""]
26
+ /* @__PURE__ */ l("span", {
27
+ className: p("w-full text-xs text-text-muted max-md:w-auto", o && "font-semibold text-action-primary-bg"),
28
+ children: [t(e, i, "monthShort"), s ? ` · ${s}` : ""]
27
29
  })
28
30
  ]
29
31
  });
30
32
  }
31
- function p({ groups: e, label: r }) {
32
- let { format: a, today: c } = n();
33
- return /* @__PURE__ */ o("ul", {
33
+ function h({ groups: e, label: i, withRuns: a = !1 }) {
34
+ let { format: s, today: u } = n();
35
+ return /* @__PURE__ */ c("ul", {
34
36
  className: "min-h-0 flex-1 overflow-y-auto",
35
- "aria-label": r,
36
- children: e.map((e) => /* @__PURE__ */ s("li", {
37
- "aria-label": t(e.date, a, "full"),
38
- className: d("flex gap-4 border-b border-border-default px-4 py-2 last:border-b-0 max-md:flex-col max-md:gap-0 max-md:px-3", e.date < c && "opacity-80"),
39
- children: [/* @__PURE__ */ o(f, { date: e.date }), /* @__PURE__ */ o("div", {
37
+ "aria-label": i,
38
+ children: e.map((e) => /* @__PURE__ */ l("li", {
39
+ "aria-label": t(e.date, s, "full"),
40
+ className: p("flex gap-4 border-b border-border-default px-4 py-2 last:border-b-0 max-md:flex-col max-md:gap-0 max-md:px-3", e.date < u && "opacity-80"),
41
+ children: [/* @__PURE__ */ c(m, { date: e.date }), /* @__PURE__ */ c("div", {
40
42
  className: "min-w-0 flex-1",
41
- children: e.events.map((t) => /* @__PURE__ */ o(i, {
43
+ children: a ? /* @__PURE__ */ c(r, {
44
+ events: e.events,
45
+ day: e.date
46
+ }) : e.events.map((t) => /* @__PURE__ */ c(o, {
42
47
  event: t,
43
48
  day: e.date
44
49
  }, t.id))
@@ -46,26 +51,27 @@ function p({ groups: e, label: r }) {
46
51
  }, e.date))
47
52
  });
48
53
  }
49
- function m() {
50
- let t = n(), { tr: i, timeZone: u, days: d, events: f } = t, m = d.map((t) => ({
54
+ function g() {
55
+ let t = n(), { tr: r, timeZone: o, days: f, events: p } = t, m = i(), g = f.map((t) => ({
51
56
  date: t,
52
- events: e(f, t, u)
53
- })).filter((e) => e.events.length > 0), h = t.state.kind === "ready" && t.state.empty;
54
- return /* @__PURE__ */ o("section", {
55
- className: r,
56
- "aria-label": i("calendar.v2.listLabel", "List"),
57
- children: m.length > 0 ? /* @__PURE__ */ o(p, {
58
- groups: m,
59
- label: i("calendar.v2.listLabel", "List")
60
- }) : h ? /* @__PURE__ */ o("div", {
57
+ events: e(p, t, o)
58
+ })).filter((e) => e.events.length > 0 || m.runsOn(e.date) !== void 0), _ = t.state.kind === "ready" && t.state.empty;
59
+ return /* @__PURE__ */ c("section", {
60
+ className: a,
61
+ "aria-label": r("calendar.v2.listLabel", "List"),
62
+ children: g.length > 0 ? /* @__PURE__ */ c(h, {
63
+ groups: g,
64
+ label: r("calendar.v2.listLabel", "List"),
65
+ withRuns: !0
66
+ }) : _ ? /* @__PURE__ */ c("div", {
61
67
  className: "grid flex-1 place-items-center p-6",
62
- children: /* @__PURE__ */ o(l, {
68
+ children: /* @__PURE__ */ c(d, {
63
69
  size: "panel",
64
70
  kind: "first-use",
65
71
  illustration: "calendar",
66
- title: i("calendar.v2.emptyList", "Nothing in these two weeks"),
67
- description: i("calendar.v2.emptyListBody", "New events and invitations show here, grouped by day."),
68
- action: /* @__PURE__ */ s(c, {
72
+ title: r("calendar.v2.emptyList", "Nothing in these two weeks"),
73
+ description: r("calendar.v2.emptyListBody", "New events and invitations show here, grouped by day."),
74
+ action: /* @__PURE__ */ l(u, {
69
75
  type: "button",
70
76
  onClick: () => {
71
77
  let e = t.days.includes(t.today) ? t.today : t.days[0] ?? t.today, n = t.workingHoursOn(e)?.start ?? 540;
@@ -76,15 +82,15 @@ function m() {
76
82
  allDay: !1
77
83
  });
78
84
  },
79
- children: [/* @__PURE__ */ o(a, { "aria-hidden": "true" }), i("calendar.v2.newEvent", "New event")]
85
+ children: [/* @__PURE__ */ c(s, { "aria-hidden": "true" }), r("calendar.v2.newEvent", "New event")]
80
86
  })
81
87
  })
82
- }) : t.state.kind === "ready" ? /* @__PURE__ */ o("p", {
88
+ }) : t.state.kind === "ready" ? /* @__PURE__ */ c("p", {
83
89
  className: "grid flex-1 place-items-center p-6 text-center text-sm text-text-secondary",
84
- children: i("calendar.v2.partialNothing", "Nothing to show from the calendars that loaded.")
90
+ children: r("calendar.v2.partialNothing", "Nothing to show from the calendars that loaded.")
85
91
  }) : null
86
92
  });
87
93
  }
88
- export { p as DayGroups, m as ListViewV2 };
94
+ export { h as DayGroups, g as ListViewV2 };
89
95
 
90
96
  //# sourceMappingURL=ListViewV2.js.map