@kumix/ui 0.3.9 → 0.3.10
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/README.md +15 -14
- package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +15 -7
- package/dist/components/motion/availability-scheduler/day-row.js.map +1 -1
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/button/index.d.ts +2 -1
- package/dist/components/motion/button/index.js +2 -1
- package/dist/components/motion/button/metallic.d.ts +10 -0
- package/dist/components/motion/button/metallic.d.ts.map +1 -0
- package/dist/components/motion/button/metallic.js +71 -0
- package/dist/components/motion/button/metallic.js.map +1 -0
- package/dist/components/motion/expandable-control.d.ts +28 -0
- package/dist/components/motion/expandable-control.d.ts.map +1 -0
- package/dist/components/motion/expandable-control.js +149 -0
- package/dist/components/motion/expandable-control.js.map +1 -0
- package/dist/components/motion/expanding-arrow-button.d.ts +12 -0
- package/dist/components/motion/expanding-arrow-button.d.ts.map +1 -0
- package/dist/components/motion/expanding-arrow-button.js +142 -0
- package/dist/components/motion/expanding-arrow-button.js.map +1 -0
- package/dist/components/motion/file-tree.d.ts +42 -0
- package/dist/components/motion/file-tree.d.ts.map +1 -0
- package/dist/components/motion/file-tree.js +272 -0
- package/dist/components/motion/file-tree.js.map +1 -0
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/code-block/code-block-highlight.d.ts +216 -0
- package/dist/components/reui/code-block/code-block-highlight.d.ts.map +1 -0
- package/dist/components/reui/code-block/code-block-highlight.js +792 -0
- package/dist/components/reui/code-block/code-block-highlight.js.map +1 -0
- package/dist/components/reui/code-block/code-block.d.ts +197 -0
- package/dist/components/reui/code-block/code-block.d.ts.map +1 -0
- package/dist/components/reui/code-block/code-block.js +1150 -0
- package/dist/components/reui/code-block/code-block.js.map +1 -0
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +42 -12
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
- package/dist/components/reui/gantt/gantt-dnd.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-dnd.js +22 -7
- package/dist/components/reui/gantt/gantt-dnd.js.map +1 -1
- package/dist/components/reui/gantt/gantt-i18n.d.ts +8 -0
- package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-i18n.js +6 -1
- package/dist/components/reui/gantt/gantt-i18n.js.map +1 -1
- package/dist/components/reui/gantt/gantt-lib.d.ts +59 -2
- package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-lib.js +67 -2
- package/dist/components/reui/gantt/gantt-lib.js.map +1 -1
- package/dist/components/reui/gantt/gantt-recurrence.js +3 -3
- package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -1
- package/dist/components/reui/gantt/gantt-types.d.ts +32 -1
- package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-view.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +324 -35
- package/dist/components/reui/gantt/gantt-view.js.map +1 -1
- package/dist/components/reui/gantt/gantt.d.ts +71 -2
- package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt.js +8 -0
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/tabs.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/{copy-menu-1FKoMc9o.js → copy-menu-C5GaT4Z-.js} +67 -2
- package/dist/copy-menu-C5GaT4Z-.js.map +1 -0
- package/dist/types-smkWN_7x.d.ts.map +1 -1
- package/package.json +5 -11
- package/dist/copy-menu-1FKoMc9o.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gantt-lib.js","names":[],"sources":["../../../../src/components/reui/gantt/gantt-lib.tsx"],"sourcesContent":["\"use client\";\n\nimport { TZDate } from \"@date-fns/tz\";\nimport {\n addDays,\n addMonths,\n addWeeks,\n addYears,\n differenceInMinutes,\n format,\n startOfDay,\n startOfMonth,\n startOfQuarter,\n startOfWeek,\n startOfYear,\n} from \"date-fns\";\n\nimport { expandRecurrence } from \"./gantt-recurrence\";\nimport type {\n GanttDateRange,\n GanttEvent,\n GanttOccurrence,\n GanttOffDaysConfig,\n GanttResource,\n GanttScale,\n GanttSegment,\n} from \"./gantt-types\";\n\ntype WeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Packing-effective minimum in minutes so tiny events do not stack invisibly.\n * It is a packing FOOTPRINT, not a render size: two schedules less than this\n * apart are treated as concurrent and split into separate lanes even though\n * their real ranges do not touch.\n */\nconst MIN_PACK_SLOT = 30;\n\n/** The instant re-expressed in the display time zone (TZDate extends Date). */\nfunction toZoned(date: Date, timeZone: string): TZDate {\n return new TZDate(date.getTime(), timeZone);\n}\n\n/** Zoned midnight of the day containing the instant. */\nfunction zonedStartOfDay(date: Date, timeZone: string): TZDate {\n return startOfDay(toZoned(date, timeZone));\n}\n\n/** Stable per-day key in the display time zone. */\nfunction getDayKey(date: Date, timeZone: string): string {\n return format(toZoned(date, timeZone), \"yyyy-MM-dd\");\n}\n\n/** Day length in minutes; 1380/1500 on DST transition days - never assume 1440. */\nfunction getDayTotalMinutes(dayStart: Date, timeZone: string): number {\n const next = zonedStartOfDay(addDays(toZoned(dayStart, timeZone), 1), timeZone);\n return differenceInMinutes(next, dayStart);\n}\n\nfunction snapMinutes(minutes: number, snap: number): number {\n return Math.round(minutes / snap) * snap;\n}\n\ninterface ViewRangeOptions {\n timeZone: string;\n weekStartsOn: WeekStartsOn;\n}\n\ninterface ViewDateRanges {\n visibleRange: GanttDateRange;\n activeRange: GanttDateRange;\n}\n\n/** Axis range for the anchor date at the given scale. */\nfunction getGanttDateRange(scale: GanttScale, date: Date, opts: ViewRangeOptions): ViewDateRanges {\n const { timeZone, weekStartsOn } = opts;\n const zoned = toZoned(date, timeZone);\n\n if (scale === \"week\") {\n const start = startOfWeek(zoned, { weekStartsOn });\n const range = { start, end: addWeeks(start, 1) };\n return { activeRange: range, visibleRange: range };\n }\n if (scale === \"month\") {\n // exact month: no outside days on the horizontal axis\n const start = startOfMonth(zoned);\n const range = { start, end: startOfMonth(addMonths(zoned, 1)) };\n return { activeRange: range, visibleRange: range };\n }\n if (scale === \"quarter\") {\n // week-aligned so the axis partitions into uniform week units\n const quarterStart = startOfQuarter(zoned);\n const quarterEnd = startOfQuarter(addMonths(zoned, 3));\n const start = startOfWeek(quarterStart, { weekStartsOn });\n let end = startOfWeek(quarterEnd, { weekStartsOn });\n if (end < quarterEnd) end = addWeeks(end, 1);\n return {\n activeRange: { start: quarterStart, end: quarterEnd },\n visibleRange: { start, end },\n };\n }\n if (scale === \"year\") {\n const start = startOfYear(zoned);\n const range = { start, end: startOfYear(addYears(zoned, 1)) };\n return { activeRange: range, visibleRange: range };\n }\n const start = startOfDay(zoned);\n const range = { start, end: addDays(start, 1) };\n return { activeRange: range, visibleRange: range };\n}\n\n/** The anchor date stepped one period forward or backward for the scale. */\nfunction stepGanttDate(\n scale: GanttScale,\n date: Date,\n direction: 1 | -1,\n opts: Pick<ViewRangeOptions, \"timeZone\">,\n): Date {\n const zoned = toZoned(date, opts.timeZone);\n if (scale === \"week\") return addWeeks(zoned, direction);\n if (scale === \"month\") return addMonths(zoned, direction);\n if (scale === \"quarter\") return addMonths(zoned, direction * 3);\n if (scale === \"year\") return addYears(zoned, direction);\n return addDays(zoned, direction);\n}\n\nfunction rangesIntersect(a: GanttDateRange, b: GanttDateRange): boolean {\n return a.start < b.end && a.end > b.start;\n}\n\nfunction eventsOverlap(a: { start: Date; end: Date }, b: { start: Date; end: Date }): boolean {\n return a.start < b.end && a.end > b.start;\n}\n\nfunction spansMultipleDays(occ: { start: Date; end: Date }): boolean {\n // An event ending exactly at the next midnight is still single-day\n // (exclusive end), so compare against a strictly-later instant.\n return occ.end.getTime() - occ.start.getTime() > 24 * 60 * 60 * 1000;\n}\n\n/**\n * Identity of a schedule ACROSS time edits. `occurrence.key` embeds the start\n * instant, so it changes the moment a schedule is moved or start-resized -\n * useless as lane memory. This key survives the edit: the event id plus, for a\n * recurring series, the occurrence's position in it.\n */\nfunction getLaneKey(occurrence: { eventId: string; recurrenceIndex?: number }): string {\n return `${occurrence.eventId}::${occurrence.recurrenceIndex ?? 0}`;\n}\n\n/**\n * What one schedule held on the previous layout pass. The TIMES are what make\n * this more than a lane number: they are how the packer tells the schedule the\n * user just edited apart from the ones that merely sat still.\n */\ninterface GanttLaneMemo {\n lane: number;\n startMs: number;\n endMs: number;\n}\n\ninterface PackOptions {\n /**\n * Where each schedule sat on the previous pass, by getLaneKey.\n *\n * A schedule whose times are UNCHANGED keeps its lane if that lane is still\n * free, so editing one schedule never re-indexes the ones around it. A\n * schedule whose times CHANGED - the one the user just dragged or resized -\n * deliberately forfeits its pin and re-seeks the lowest free lane. That is\n * what makes the arrangement live rather than frozen: a schedule dragged\n * onto its neighbours stacks DOWN into the first free lane, and one dragged\n * clear of them comes back UP inline. Only the edited schedule moves.\n */\n preferredLanes?: Map<string, GanttLaneMemo>;\n /** \"single\" collapses the row to one track; see GanttScheduleMode. */\n mode?: \"single\" | \"multiple\";\n}\n\n/**\n * Overlap packing for one row's timed segments.\n * Mutates column/columnCount/columnSpan on the segments, in place.\n * z resolution happens at render: event.zIndex verbatim, else 10 + column.\n */\nfunction packTimedSegments<TData>(\n segments: GanttSegment<TData>[],\n options: PackOptions = {},\n): void {\n if (segments.length === 0) return;\n\n if (options.mode === \"single\") {\n // one track: every schedule shares lane 0 and the row never grows\n for (const seg of segments) {\n seg.column = 0;\n seg.columnCount = 1;\n seg.columnSpan = 1;\n }\n return;\n }\n\n const preferredLanes = options.preferredLanes;\n\n type Working = {\n seg: GanttSegment<TData>;\n startMin: number;\n effEnd: number;\n lane: number;\n /** The occupancy entry this item added, so a settle can take it back. */\n interval?: { from: number; to: number };\n };\n\n const items: Working[] = segments\n .map((seg) => {\n const startMin = seg.startMin ?? 0;\n const endMin = seg.endMin ?? startMin;\n return {\n seg,\n startMin,\n effEnd: Math.max(endMin, startMin + MIN_PACK_SLOT),\n lane: -1,\n };\n })\n .sort(\n (a, b) =>\n a.startMin - b.startMin ||\n b.effEnd - b.startMin - (a.effEnd - a.startMin) ||\n a.seg.occurrence.key.localeCompare(b.seg.occurrence.key),\n );\n\n // Sweep into connected clusters\n const clusters: Working[][] = [];\n let current: Working[] = [];\n let clusterEnd = -Infinity;\n for (const item of items) {\n if (item.startMin >= clusterEnd) {\n current = [];\n clusters.push(current);\n clusterEnd = -Infinity;\n }\n current.push(item);\n clusterEnd = Math.max(clusterEnd, item.effEnd);\n }\n\n for (const cluster of clusters) {\n // Per-lane occupancy INTERVALS, not a single running end: pass 1 claims\n // remembered lanes out of time order, so a lane can be free before an\n // occupant and busy after it.\n const laneIntervals: Array<Array<{ from: number; to: number }>> = [];\n const isFree = (lane: number, item: Working) =>\n !(laneIntervals[lane] ?? []).some((iv) => iv.from < item.effEnd && iv.to > item.startMin);\n const claim = (lane: number, item: Working) => {\n while (laneIntervals.length <= lane) laneIntervals.push([]);\n const interval = { from: item.startMin, to: item.effEnd };\n laneIntervals[lane].push(interval);\n item.lane = lane;\n item.interval = interval;\n };\n const release = (item: Working) => {\n const occupants = laneIntervals[item.lane] ?? [];\n const at = occupants.indexOf(item.interval!);\n if (at >= 0) occupants.splice(at, 1);\n };\n\n // pass 1: schedules that did not move keep the lane they had. The one the\n // user just edited is NOT pinned - its times differ from the memo, so it\n // falls through to pass 2 and re-seeks a lane against its new span.\n const pending: Working[] = [];\n for (const item of cluster) {\n const memo = preferredLanes?.get(getLaneKey(item.seg.occurrence));\n const untouched =\n memo !== undefined &&\n memo.startMs === item.seg.occurrence.start.getTime() &&\n memo.endMs === item.seg.occurrence.end.getTime();\n if (untouched && memo.lane >= 0 && isFree(memo.lane, item)) {\n claim(memo.lane, item);\n } else {\n pending.push(item);\n }\n }\n // pass 2: the rest take the lowest free lane - overlapping goes DOWN into\n // the first lane with room, fitting comes back UP to lane 0\n for (const item of pending) {\n let lane = 0;\n while (!isFree(lane, item)) lane++;\n claim(lane, item);\n }\n\n // pass 3: nothing floats above an empty lane. A pin only survives while\n // something above it still needs the space - once the schedule that was\n // there moves away or is deleted, its neighbour settles down into the\n // gap. Without this a row keeps a permanently blank top lane and never\n // shrinks back. Settling in lane order, and only ever DOWNWARD into space\n // that is genuinely free, means two schedules can never trade places -\n // so an edit still moves at most the schedule it touched.\n const byLane = [...cluster].sort((a, b) => a.lane - b.lane || a.startMin - b.startMin);\n for (const item of byLane) {\n if (item.lane === 0) continue;\n let lane = 0;\n while (lane < item.lane && !isFree(lane, item)) lane++;\n if (lane < item.lane) {\n release(item);\n claim(lane, item);\n }\n }\n }\n\n // Lane memory can leave holes (the schedule that held lane 0 was deleted or\n // moved away). Collapse the row's USED lanes onto 0..n-1: relative stacking\n // order survives, so nothing reshuffles, but the row cannot creep taller\n // than the lanes it actually needs.\n const used = [...new Set(items.map((item) => item.lane))].sort((a, b) => a - b);\n const compacted = new Map(used.map((lane, index) => [lane, index]));\n const columnCount = used.length;\n for (const item of items) {\n item.lane = compacted.get(item.lane) ?? 0;\n item.seg.column = item.lane;\n item.seg.columnCount = columnCount;\n }\n\n // Partial-overlap expansion: widen rightward into free lanes\n for (const cluster of clusters) {\n for (const item of cluster) {\n let span = 1;\n while (item.lane + span < columnCount) {\n const blocked = cluster.some(\n (other) =>\n other !== item &&\n other.lane === item.lane + span &&\n other.startMin < item.effEnd &&\n other.effEnd > item.startMin,\n );\n if (blocked) break;\n span++;\n }\n item.seg.columnSpan = span;\n }\n }\n}\n\nfunction defaultEventOrder(a: GanttOccurrence, b: GanttOccurrence): number {\n return (\n a.start.getTime() - b.start.getTime() ||\n b.end.getTime() - b.start.getTime() - (a.end.getTime() - a.start.getTime()) ||\n a.key.localeCompare(b.key)\n );\n}\n\ninterface BuildIndexOptions<TData = unknown> {\n timeZone: string;\n /** Escape hatch for exotic recurrence: return the expanded occurrences. */\n getOccurrences?: (\n event: GanttEvent<TData>,\n range: GanttDateRange,\n ctx: { timeZone: string },\n ) => Array<{ start: Date; end: Date }> | null | undefined;\n eventOrder?: (a: GanttOccurrence<TData>, b: GanttOccurrence<TData>) => number;\n}\n\ninterface GanttIndex<TData = unknown> {\n occurrences: GanttOccurrence<TData>[];\n}\n\nfunction buildEventIndex<TData>(\n events: GanttEvent<TData>[],\n visibleRange: GanttDateRange,\n opts: BuildIndexOptions<TData>,\n): GanttIndex<TData> {\n const { timeZone } = opts;\n const order = opts.eventOrder ?? defaultEventOrder;\n\n // RECURRENCE-ID override replacement: an event carrying recurringEventId +\n // originalStart is an edited single occurrence of that series. The parent's\n // expansion drops the replaced instant; the override renders as its own\n // occurrence through the normal path below.\n const overrideTimes = new Map<string, Set<number>>();\n for (const event of events) {\n if (!event.recurringEventId || !event.originalStart) continue;\n let times = overrideTimes.get(event.recurringEventId);\n if (!times) {\n times = new Set();\n overrideTimes.set(event.recurringEventId, times);\n }\n times.add(event.originalStart.getTime());\n }\n\n const occurrences: GanttOccurrence<TData>[] = [];\n for (const event of events) {\n const replaced = overrideTimes.get(event.id);\n const custom = opts.getOccurrences?.(event, visibleRange, { timeZone });\n if (custom) {\n custom.forEach((occ, i) => {\n if (replaced?.has(occ.start.getTime())) return;\n if (!rangesIntersect({ start: occ.start, end: occ.end }, visibleRange)) return;\n occurrences.push({\n key: `${event.id}::${occ.start.toISOString()}`,\n eventId: event.id,\n event,\n start: occ.start,\n end: occ.end,\n allDay: event.allDay ?? false,\n isRecurring: true,\n recurrenceIndex: i,\n });\n });\n continue;\n }\n const expanded = expandRecurrence(event, visibleRange, { timeZone });\n occurrences.push(\n ...(replaced ? expanded.filter((occ) => !replaced.has(occ.start.getTime())) : expanded),\n );\n }\n occurrences.sort(order);\n return { occurrences };\n}\n\n/** Cache key for index memoization; cheap string compare. */\nfunction getRangeKey(range: GanttDateRange): string {\n return `${range.start.getTime()}-${range.end.getTime()}`;\n}\n\n/** Depth-first flatten of the resource tree (parents included). */\nfunction flattenResources(\n resources: GanttResource[],\n depth = 0,\n): Array<{ resource: GanttResource; depth: number }> {\n const rows: Array<{ resource: GanttResource; depth: number }> = [];\n for (const resource of resources) {\n rows.push({ resource, depth });\n if (resource.children?.length) {\n rows.push(...flattenResources(resource.children, depth + 1));\n }\n }\n return rows;\n}\n\n/** Depth-first lookup of one node in the tree. */\nfunction findResource(resources: GanttResource[], id: string): GanttResource | null {\n for (const resource of resources) {\n if (resource.id === id) return resource;\n const found = resource.children?.length ? findResource(resource.children, id) : null;\n if (found) return found;\n }\n return null;\n}\n\n/**\n * Pure tree move: removes `resourceId` from wherever it sits and reinserts it\n * under `parentId` (null = root) at `index`. Returns a new tree; the original\n * is untouched. Returns null for impossible moves (unknown ids, or dropping a\n * node into its own subtree).\n */\nfunction reorderResources(\n resources: GanttResource[],\n resourceId: string,\n parentId: string | null,\n index: number,\n): GanttResource[] | null {\n let moved: GanttResource | null = null;\n\n const strip = (nodes: GanttResource[]): GanttResource[] =>\n nodes.flatMap((node) => {\n if (node.id === resourceId) {\n moved = node;\n return [];\n }\n if (!node.children?.length) return [node];\n return [{ ...node, children: strip(node.children) }];\n });\n\n const stripped = strip(resources);\n if (!moved) return null;\n\n const contains = (node: GanttResource, id: string): boolean =>\n node.id === id || !!node.children?.some((child) => contains(child, id));\n if (parentId !== null && contains(moved, parentId)) return null;\n\n const insert = (nodes: GanttResource[]): GanttResource[] => {\n if (parentId === null) {\n const next = [...nodes];\n next.splice(Math.min(Math.max(index, 0), next.length), 0, moved!);\n return next;\n }\n return nodes.map((node) => {\n if (node.id === parentId) {\n const children = [...(node.children ?? [])];\n children.splice(Math.min(Math.max(index, 0), children.length), 0, moved!);\n return { ...node, children };\n }\n if (!node.children?.length) return node;\n return { ...node, children: insert(node.children) };\n });\n };\n\n const next = insert(stripped);\n // unknown parentId: the node vanished - reject\n if (parentId !== null) {\n const flat = flattenResources(next);\n if (!flat.some(({ resource }) => resource.id === resourceId)) return null;\n }\n return next;\n}\n\nconst DEFAULT_WEEKEND_DAYS = [0, 6];\n\n/** Resolves whether a day is an off day (non-working) in the display zone. */\nfunction resolveOffDay(\n day: Date,\n timeZone: string,\n config: boolean | GanttOffDaysConfig | undefined,\n): boolean {\n if (!config) return false;\n const resolved: GanttOffDaysConfig = config === true ? {} : config;\n const weekendDays = resolved.weekendDays ?? DEFAULT_WEEKEND_DAYS;\n const zoned = toZoned(day, timeZone);\n if (weekendDays.includes(zoned.getDay())) return true;\n if (resolved.dates?.length) {\n const key = getDayKey(day, timeZone);\n if (resolved.dates.some((date) => getDayKey(date, timeZone) === key)) {\n return true;\n }\n }\n return resolved.isOffDay?.(day) ?? false;\n}\n\nexport type {\n BuildIndexOptions,\n GanttIndex,\n GanttLaneMemo,\n PackOptions,\n ViewDateRanges,\n ViewRangeOptions,\n WeekStartsOn,\n};\nexport {\n buildEventIndex,\n defaultEventOrder,\n eventsOverlap,\n findResource,\n flattenResources,\n getDayKey,\n getDayTotalMinutes,\n getGanttDateRange,\n getLaneKey,\n getRangeKey,\n MIN_PACK_SLOT,\n packTimedSegments,\n rangesIntersect,\n reorderResources,\n resolveOffDay,\n snapMinutes,\n spansMultipleDays,\n stepGanttDate,\n toZoned,\n zonedStartOfDay,\n};\n"],"mappings":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,OAAO;CACpB,MAAM,WAA+B,WAAW,OAAO,CAAC,IAAI;CAC5D,MAAM,cAAc,SAAS,eAAe;CAC5C,MAAM,QAAQ,QAAQ,KAAK,QAAQ;CACnC,IAAI,YAAY,SAAS,MAAM,OAAO,CAAC,GAAG,OAAO;CACjD,IAAI,SAAS,OAAO,QAAQ;EAC1B,MAAM,MAAM,UAAU,KAAK,QAAQ;EACnC,IAAI,SAAS,MAAM,MAAM,SAAS,UAAU,MAAM,QAAQ,MAAM,GAAG,GACjE,OAAO;CAEX;CACA,OAAO,SAAS,WAAW,GAAG,KAAK;AACrC"}
|
|
1
|
+
{"version":3,"file":"gantt-lib.js","names":[],"sources":["../../../../src/components/reui/gantt/gantt-lib.tsx"],"sourcesContent":["\"use client\";\n\nimport { TZDate } from \"@date-fns/tz\";\nimport {\n addDays,\n addMonths,\n addWeeks,\n addYears,\n differenceInMinutes,\n format,\n startOfDay,\n startOfMonth,\n startOfQuarter,\n startOfWeek,\n startOfYear,\n} from \"date-fns\";\n\nimport { expandRecurrence } from \"./gantt-recurrence\";\nimport type {\n GanttBaseline,\n GanttBaselineVariance,\n GanttDateRange,\n GanttEvent,\n GanttOccurrence,\n GanttOffDaysConfig,\n GanttRecurrenceRule,\n GanttResource,\n GanttScale,\n GanttSegment,\n} from \"./gantt-types\";\n\ntype WeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Packing-effective minimum in minutes so tiny events do not stack invisibly.\n * It is a packing FOOTPRINT, not a render size: two schedules less than this\n * apart are treated as concurrent and split into separate lanes even though\n * their real ranges do not touch.\n */\nconst MIN_PACK_SLOT = 30;\n\n/** The instant re-expressed in the display time zone (TZDate extends Date). */\nfunction toZoned(date: Date, timeZone: string): TZDate {\n return new TZDate(date.getTime(), timeZone);\n}\n\n/** Zoned midnight of the day containing the instant. */\nfunction zonedStartOfDay(date: Date, timeZone: string): TZDate {\n return startOfDay(toZoned(date, timeZone));\n}\n\n/** Stable per-day key in the display time zone. */\nfunction getDayKey(date: Date, timeZone: string): string {\n return format(toZoned(date, timeZone), \"yyyy-MM-dd\");\n}\n\n/** Day length in minutes; 1380/1500 on DST transition days - never assume 1440. */\nfunction getDayTotalMinutes(dayStart: Date, timeZone: string): number {\n const next = zonedStartOfDay(addDays(toZoned(dayStart, timeZone), 1), timeZone);\n return differenceInMinutes(next, dayStart);\n}\n\nfunction snapMinutes(minutes: number, snap: number): number {\n return Math.round(minutes / snap) * snap;\n}\n\ninterface ViewRangeOptions {\n timeZone: string;\n weekStartsOn: WeekStartsOn;\n}\n\ninterface ViewDateRanges {\n visibleRange: GanttDateRange;\n activeRange: GanttDateRange;\n}\n\n/** Axis range for the anchor date at the given scale. */\nfunction getGanttDateRange(scale: GanttScale, date: Date, opts: ViewRangeOptions): ViewDateRanges {\n const { timeZone, weekStartsOn } = opts;\n const zoned = toZoned(date, timeZone);\n\n if (scale === \"week\") {\n const start = startOfWeek(zoned, { weekStartsOn });\n const range = { start, end: addWeeks(start, 1) };\n return { activeRange: range, visibleRange: range };\n }\n if (scale === \"month\") {\n // exact month: no outside days on the horizontal axis\n const start = startOfMonth(zoned);\n const range = { start, end: startOfMonth(addMonths(zoned, 1)) };\n return { activeRange: range, visibleRange: range };\n }\n if (scale === \"quarter\") {\n // week-aligned so the axis partitions into uniform week units\n const quarterStart = startOfQuarter(zoned);\n const quarterEnd = startOfQuarter(addMonths(zoned, 3));\n const start = startOfWeek(quarterStart, { weekStartsOn });\n let end = startOfWeek(quarterEnd, { weekStartsOn });\n if (end < quarterEnd) end = addWeeks(end, 1);\n return {\n activeRange: { start: quarterStart, end: quarterEnd },\n visibleRange: { start, end },\n };\n }\n if (scale === \"year\") {\n const start = startOfYear(zoned);\n const range = { start, end: startOfYear(addYears(zoned, 1)) };\n return { activeRange: range, visibleRange: range };\n }\n const start = startOfDay(zoned);\n const range = { start, end: addDays(start, 1) };\n return { activeRange: range, visibleRange: range };\n}\n\n/** The anchor date stepped one period forward or backward for the scale. */\nfunction stepGanttDate(\n scale: GanttScale,\n date: Date,\n direction: 1 | -1,\n opts: Pick<ViewRangeOptions, \"timeZone\">,\n): Date {\n const zoned = toZoned(date, opts.timeZone);\n if (scale === \"week\") return addWeeks(zoned, direction);\n if (scale === \"month\") return addMonths(zoned, direction);\n if (scale === \"quarter\") return addMonths(zoned, direction * 3);\n if (scale === \"year\") return addYears(zoned, direction);\n return addDays(zoned, direction);\n}\n\nfunction rangesIntersect(a: GanttDateRange, b: GanttDateRange): boolean {\n return a.start < b.end && a.end > b.start;\n}\n\nfunction eventsOverlap(a: { start: Date; end: Date }, b: { start: Date; end: Date }): boolean {\n return a.start < b.end && a.end > b.start;\n}\n\n/**\n * Range visibility for an occurrence: half-open like rangesIntersect, except\n * a zero-length occurrence (a milestone). The plain test can never admit an\n * instant sitting exactly on the range start, so milestones compare the\n * start closed; the end stays exclusive - an instant on the range end\n * belongs to the next period. gantt-recurrence inlines this same rule\n * (importing it back here would cycle the modules).\n */\nfunction occurrenceIntersects(occ: { start: Date; end: Date }, range: GanttDateRange): boolean {\n if (occ.end.getTime() === occ.start.getTime()) {\n return occ.start >= range.start && occ.start < range.end;\n }\n return rangesIntersect(occ, range);\n}\n\nfunction spansMultipleDays(occ: { start: Date; end: Date }): boolean {\n // An event ending exactly at the next midnight is still single-day\n // (exclusive end), so compare against a strictly-later instant.\n return occ.end.getTime() - occ.start.getTime() > 24 * 60 * 60 * 1000;\n}\n\n/**\n * The subject's validated planned window, or null: both instants present,\n * end not before start, and (for events) non-recurring - a series has no\n * single planned window. An edited single occurrence (recurringEventId\n * without its own rule) is a plain event here and keeps its baseline.\n * Structural on purpose: a GanttResource node's own baseline pair resolves\n * through the same rule.\n */\nfunction resolveEventBaseline(subject: {\n baselineStart?: Date;\n baselineEnd?: Date;\n recurrence?: GanttRecurrenceRule | string;\n}): GanttBaseline | null {\n if (!subject.baselineStart || !subject.baselineEnd || subject.recurrence) {\n return null;\n }\n const startMs = subject.baselineStart.getTime();\n const endMs = subject.baselineEnd.getTime();\n if (endMs < startMs) return null;\n return {\n start: subject.baselineStart,\n end: subject.baselineEnd,\n milestone: endMs === startMs,\n };\n}\n\ninterface GanttDependencyGeometry {\n /** Orthogonal elbow path for the connector line, in the caller's units. */\n line: string;\n /** Filled arrowhead at the target anchor, pointing along +x. */\n arrow: string;\n}\n\n/**\n * Finish-to-start connector geometry from a predecessor's END anchor to a\n * successor's START anchor, in whatever units the caller works in (the view\n * passes rem). A target with room ahead takes the classic Z route: out by\n * `clearance`, across to the target lane, in. A target at or behind the\n * source's exit loops instead: out, hop `laneStep` toward the target's side\n * (down when level - below reads as \"later\"), back past the target, in.\n * The line stops `arrowSize` short of the anchor so it never pokes through\n * the head. The exit stub can sit under an outside-after bar label; a\n * consumer that shows those widens the label's start margin instead of the\n * routing changing shape (a drop-first exit was tried and read worse\n * everywhere else).\n */\nfunction buildDependencyPath(\n from: { x: number; y: number },\n to: { x: number; y: number },\n opts: { clearance: number; laneStep: number; arrowSize: number },\n): GanttDependencyGeometry {\n const { clearance, laneStep, arrowSize } = opts;\n const lineEndX = to.x - arrowSize;\n const arrow = `M ${to.x} ${to.y} L ${lineEndX} ${to.y - arrowSize * 0.6} L ${lineEndX} ${to.y + arrowSize * 0.6} Z`;\n if (lineEndX >= from.x + clearance) {\n return {\n line: `M ${from.x} ${from.y} H ${from.x + clearance} V ${to.y} H ${lineEndX}`,\n arrow,\n };\n }\n const midY = to.y >= from.y ? from.y + laneStep : from.y - laneStep;\n return {\n line: `M ${from.x} ${from.y} H ${from.x + clearance} V ${midY} H ${to.x - clearance} V ${to.y} H ${lineEndX}`,\n arrow,\n };\n}\n\n/** Actual end against the planned end; null when no valid baseline exists. */\nfunction getBaselineVariance<TData>(event: GanttEvent<TData>): GanttBaselineVariance | null {\n const baseline = resolveEventBaseline(event);\n if (!baseline) return null;\n const deltaMs = event.end.getTime() - baseline.end.getTime();\n return deltaMs > 0 ? \"late\" : deltaMs < 0 ? \"early\" : \"on-time\";\n}\n\n/**\n * Identity of a schedule ACROSS time edits. `occurrence.key` embeds the start\n * instant, so it changes the moment a schedule is moved or start-resized -\n * useless as lane memory. This key survives the edit: the event id plus, for a\n * recurring series, the occurrence's position in it.\n */\nfunction getLaneKey(occurrence: { eventId: string; recurrenceIndex?: number }): string {\n return `${occurrence.eventId}::${occurrence.recurrenceIndex ?? 0}`;\n}\n\n/**\n * What one schedule held on the previous layout pass. The TIMES are what make\n * this more than a lane number: they are how the packer tells the schedule the\n * user just edited apart from the ones that merely sat still.\n */\ninterface GanttLaneMemo {\n lane: number;\n startMs: number;\n endMs: number;\n}\n\ninterface PackOptions {\n /**\n * Where each schedule sat on the previous pass, by getLaneKey.\n *\n * A schedule whose times are UNCHANGED keeps its lane if that lane is still\n * free, so editing one schedule never re-indexes the ones around it. A\n * schedule whose times CHANGED - the one the user just dragged or resized -\n * deliberately forfeits its pin and re-seeks the lowest free lane. That is\n * what makes the arrangement live rather than frozen: a schedule dragged\n * onto its neighbours stacks DOWN into the first free lane, and one dragged\n * clear of them comes back UP inline. Only the edited schedule moves.\n */\n preferredLanes?: Map<string, GanttLaneMemo>;\n /** \"single\" collapses the row to one track; see GanttScheduleMode. */\n mode?: \"single\" | \"multiple\";\n}\n\n/**\n * Overlap packing for one row's timed segments.\n * Mutates column/columnCount/columnSpan on the segments, in place.\n * z resolution happens at render: event.zIndex verbatim, else 10 + column.\n */\nfunction packTimedSegments<TData>(\n segments: GanttSegment<TData>[],\n options: PackOptions = {},\n): void {\n if (segments.length === 0) return;\n\n if (options.mode === \"single\") {\n // one track: every schedule shares lane 0 and the row never grows\n for (const seg of segments) {\n seg.column = 0;\n seg.columnCount = 1;\n seg.columnSpan = 1;\n }\n return;\n }\n\n const preferredLanes = options.preferredLanes;\n\n type Working = {\n seg: GanttSegment<TData>;\n startMin: number;\n effEnd: number;\n lane: number;\n /** The occupancy entry this item added, so a settle can take it back. */\n interval?: { from: number; to: number };\n };\n\n const items: Working[] = segments\n .map((seg) => {\n const startMin = seg.startMin ?? 0;\n const endMin = seg.endMin ?? startMin;\n return {\n seg,\n startMin,\n effEnd: Math.max(endMin, startMin + MIN_PACK_SLOT),\n lane: -1,\n };\n })\n .sort(\n (a, b) =>\n a.startMin - b.startMin ||\n b.effEnd - b.startMin - (a.effEnd - a.startMin) ||\n a.seg.occurrence.key.localeCompare(b.seg.occurrence.key),\n );\n\n // Sweep into connected clusters\n const clusters: Working[][] = [];\n let current: Working[] = [];\n let clusterEnd = -Infinity;\n for (const item of items) {\n if (item.startMin >= clusterEnd) {\n current = [];\n clusters.push(current);\n clusterEnd = -Infinity;\n }\n current.push(item);\n clusterEnd = Math.max(clusterEnd, item.effEnd);\n }\n\n for (const cluster of clusters) {\n // Per-lane occupancy INTERVALS, not a single running end: pass 1 claims\n // remembered lanes out of time order, so a lane can be free before an\n // occupant and busy after it.\n const laneIntervals: Array<Array<{ from: number; to: number }>> = [];\n const isFree = (lane: number, item: Working) =>\n !(laneIntervals[lane] ?? []).some((iv) => iv.from < item.effEnd && iv.to > item.startMin);\n const claim = (lane: number, item: Working) => {\n while (laneIntervals.length <= lane) laneIntervals.push([]);\n const interval = { from: item.startMin, to: item.effEnd };\n laneIntervals[lane].push(interval);\n item.lane = lane;\n item.interval = interval;\n };\n const release = (item: Working) => {\n const occupants = laneIntervals[item.lane] ?? [];\n const at = occupants.indexOf(item.interval!);\n if (at >= 0) occupants.splice(at, 1);\n };\n\n // pass 1: schedules that did not move keep the lane they had. The one the\n // user just edited is NOT pinned - its times differ from the memo, so it\n // falls through to pass 2 and re-seeks a lane against its new span.\n const pending: Working[] = [];\n for (const item of cluster) {\n const memo = preferredLanes?.get(getLaneKey(item.seg.occurrence));\n const untouched =\n memo !== undefined &&\n memo.startMs === item.seg.occurrence.start.getTime() &&\n memo.endMs === item.seg.occurrence.end.getTime();\n if (untouched && memo.lane >= 0 && isFree(memo.lane, item)) {\n claim(memo.lane, item);\n } else {\n pending.push(item);\n }\n }\n // pass 2: the rest take the lowest free lane - overlapping goes DOWN into\n // the first lane with room, fitting comes back UP to lane 0\n for (const item of pending) {\n let lane = 0;\n while (!isFree(lane, item)) lane++;\n claim(lane, item);\n }\n\n // pass 3: nothing floats above an empty lane. A pin only survives while\n // something above it still needs the space - once the schedule that was\n // there moves away or is deleted, its neighbour settles down into the\n // gap. Without this a row keeps a permanently blank top lane and never\n // shrinks back. Settling in lane order, and only ever DOWNWARD into space\n // that is genuinely free, means two schedules can never trade places -\n // so an edit still moves at most the schedule it touched.\n const byLane = [...cluster].sort((a, b) => a.lane - b.lane || a.startMin - b.startMin);\n for (const item of byLane) {\n if (item.lane === 0) continue;\n let lane = 0;\n while (lane < item.lane && !isFree(lane, item)) lane++;\n if (lane < item.lane) {\n release(item);\n claim(lane, item);\n }\n }\n }\n\n // Lane memory can leave holes (the schedule that held lane 0 was deleted or\n // moved away). Collapse the row's USED lanes onto 0..n-1: relative stacking\n // order survives, so nothing reshuffles, but the row cannot creep taller\n // than the lanes it actually needs.\n const used = [...new Set(items.map((item) => item.lane))].sort((a, b) => a - b);\n const compacted = new Map(used.map((lane, index) => [lane, index]));\n const columnCount = used.length;\n for (const item of items) {\n item.lane = compacted.get(item.lane) ?? 0;\n item.seg.column = item.lane;\n item.seg.columnCount = columnCount;\n }\n\n // Partial-overlap expansion: widen rightward into free lanes\n for (const cluster of clusters) {\n for (const item of cluster) {\n let span = 1;\n while (item.lane + span < columnCount) {\n const blocked = cluster.some(\n (other) =>\n other !== item &&\n other.lane === item.lane + span &&\n other.startMin < item.effEnd &&\n other.effEnd > item.startMin,\n );\n if (blocked) break;\n span++;\n }\n item.seg.columnSpan = span;\n }\n }\n}\n\nfunction defaultEventOrder(a: GanttOccurrence, b: GanttOccurrence): number {\n return (\n a.start.getTime() - b.start.getTime() ||\n b.end.getTime() - b.start.getTime() - (a.end.getTime() - a.start.getTime()) ||\n a.key.localeCompare(b.key)\n );\n}\n\ninterface BuildIndexOptions<TData = unknown> {\n timeZone: string;\n /** Escape hatch for exotic recurrence: return the expanded occurrences. */\n getOccurrences?: (\n event: GanttEvent<TData>,\n range: GanttDateRange,\n ctx: { timeZone: string },\n ) => Array<{ start: Date; end: Date }> | null | undefined;\n eventOrder?: (a: GanttOccurrence<TData>, b: GanttOccurrence<TData>) => number;\n}\n\ninterface GanttIndex<TData = unknown> {\n occurrences: GanttOccurrence<TData>[];\n}\n\nfunction buildEventIndex<TData>(\n events: GanttEvent<TData>[],\n visibleRange: GanttDateRange,\n opts: BuildIndexOptions<TData>,\n): GanttIndex<TData> {\n const { timeZone } = opts;\n const order = opts.eventOrder ?? defaultEventOrder;\n\n // RECURRENCE-ID override replacement: an event carrying recurringEventId +\n // originalStart is an edited single occurrence of that series. The parent's\n // expansion drops the replaced instant; the override renders as its own\n // occurrence through the normal path below.\n const overrideTimes = new Map<string, Set<number>>();\n for (const event of events) {\n if (!event.recurringEventId || !event.originalStart) continue;\n let times = overrideTimes.get(event.recurringEventId);\n if (!times) {\n times = new Set();\n overrideTimes.set(event.recurringEventId, times);\n }\n times.add(event.originalStart.getTime());\n }\n\n const occurrences: GanttOccurrence<TData>[] = [];\n for (const event of events) {\n const replaced = overrideTimes.get(event.id);\n const custom = opts.getOccurrences?.(event, visibleRange, { timeZone });\n if (custom) {\n custom.forEach((occ, i) => {\n if (replaced?.has(occ.start.getTime())) return;\n if (!occurrenceIntersects({ start: occ.start, end: occ.end }, visibleRange)) return;\n occurrences.push({\n key: `${event.id}::${occ.start.toISOString()}`,\n eventId: event.id,\n event,\n start: occ.start,\n end: occ.end,\n allDay: event.allDay ?? false,\n isRecurring: true,\n recurrenceIndex: i,\n });\n });\n continue;\n }\n const expanded = expandRecurrence(event, visibleRange, { timeZone });\n occurrences.push(\n ...(replaced ? expanded.filter((occ) => !replaced.has(occ.start.getTime())) : expanded),\n );\n }\n occurrences.sort(order);\n return { occurrences };\n}\n\n/** Cache key for index memoization; cheap string compare. */\nfunction getRangeKey(range: GanttDateRange): string {\n return `${range.start.getTime()}-${range.end.getTime()}`;\n}\n\n/** Depth-first flatten of the resource tree (parents included). */\nfunction flattenResources(\n resources: GanttResource[],\n depth = 0,\n): Array<{ resource: GanttResource; depth: number }> {\n const rows: Array<{ resource: GanttResource; depth: number }> = [];\n for (const resource of resources) {\n rows.push({ resource, depth });\n if (resource.children?.length) {\n rows.push(...flattenResources(resource.children, depth + 1));\n }\n }\n return rows;\n}\n\n/** Depth-first lookup of one node in the tree. */\nfunction findResource(resources: GanttResource[], id: string): GanttResource | null {\n for (const resource of resources) {\n if (resource.id === id) return resource;\n const found = resource.children?.length ? findResource(resource.children, id) : null;\n if (found) return found;\n }\n return null;\n}\n\n/**\n * Pure tree move: removes `resourceId` from wherever it sits and reinserts it\n * under `parentId` (null = root) at `index`. Returns a new tree; the original\n * is untouched. Returns null for impossible moves (unknown ids, or dropping a\n * node into its own subtree).\n */\nfunction reorderResources(\n resources: GanttResource[],\n resourceId: string,\n parentId: string | null,\n index: number,\n): GanttResource[] | null {\n let moved: GanttResource | null = null;\n\n const strip = (nodes: GanttResource[]): GanttResource[] =>\n nodes.flatMap((node) => {\n if (node.id === resourceId) {\n moved = node;\n return [];\n }\n if (!node.children?.length) return [node];\n return [{ ...node, children: strip(node.children) }];\n });\n\n const stripped = strip(resources);\n if (!moved) return null;\n\n const contains = (node: GanttResource, id: string): boolean =>\n node.id === id || !!node.children?.some((child) => contains(child, id));\n if (parentId !== null && contains(moved, parentId)) return null;\n\n const insert = (nodes: GanttResource[]): GanttResource[] => {\n if (parentId === null) {\n const next = [...nodes];\n next.splice(Math.min(Math.max(index, 0), next.length), 0, moved!);\n return next;\n }\n return nodes.map((node) => {\n if (node.id === parentId) {\n const children = [...(node.children ?? [])];\n children.splice(Math.min(Math.max(index, 0), children.length), 0, moved!);\n return { ...node, children };\n }\n if (!node.children?.length) return node;\n return { ...node, children: insert(node.children) };\n });\n };\n\n const next = insert(stripped);\n // unknown parentId: the node vanished - reject\n if (parentId !== null) {\n const flat = flattenResources(next);\n if (!flat.some(({ resource }) => resource.id === resourceId)) return null;\n }\n return next;\n}\n\nconst DEFAULT_WEEKEND_DAYS = [0, 6];\n\n/** Resolves whether a day is an off day (non-working) in the display zone. */\nfunction resolveOffDay(\n day: Date,\n timeZone: string,\n config: boolean | GanttOffDaysConfig | undefined,\n): boolean {\n if (!config) return false;\n const resolved: GanttOffDaysConfig = config === true ? {} : config;\n const weekendDays = resolved.weekendDays ?? DEFAULT_WEEKEND_DAYS;\n const zoned = toZoned(day, timeZone);\n if (weekendDays.includes(zoned.getDay())) return true;\n if (resolved.dates?.length) {\n const key = getDayKey(day, timeZone);\n if (resolved.dates.some((date) => getDayKey(date, timeZone) === key)) {\n return true;\n }\n }\n return resolved.isOffDay?.(day) ?? false;\n}\n\nexport type {\n BuildIndexOptions,\n GanttDependencyGeometry,\n GanttIndex,\n GanttLaneMemo,\n PackOptions,\n ViewDateRanges,\n ViewRangeOptions,\n WeekStartsOn,\n};\nexport {\n buildDependencyPath,\n buildEventIndex,\n defaultEventOrder,\n eventsOverlap,\n findResource,\n flattenResources,\n getBaselineVariance,\n getDayKey,\n getDayTotalMinutes,\n getGanttDateRange,\n getLaneKey,\n getRangeKey,\n MIN_PACK_SLOT,\n occurrenceIntersects,\n packTimedSegments,\n rangesIntersect,\n reorderResources,\n resolveEventBaseline,\n resolveOffDay,\n snapMinutes,\n spansMultipleDays,\n stepGanttDate,\n toZoned,\n zonedStartOfDay,\n};\n"],"mappings":";;;;;;;;;;;AAuCA,MAAM,gBAAgB;;AAGtB,SAAS,QAAQ,MAAY,UAA0B;CACrD,OAAO,IAAI,OAAO,KAAK,QAAQ,GAAG,QAAQ;AAC5C;;AAGA,SAAS,gBAAgB,MAAY,UAA0B;CAC7D,OAAO,WAAW,QAAQ,MAAM,QAAQ,CAAC;AAC3C;;AAGA,SAAS,UAAU,MAAY,UAA0B;CACvD,OAAO,OAAO,QAAQ,MAAM,QAAQ,GAAG,YAAY;AACrD;;AAGA,SAAS,mBAAmB,UAAgB,UAA0B;CACpE,MAAM,OAAO,gBAAgB,QAAQ,QAAQ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,MAAM,MAAM,SAAS,UAAU,MAAM,QAAQ,MAAM,GAAG,GACjE,OAAO;CAEX;CACA,OAAO,SAAS,WAAW,GAAG,KAAK;AACrC"}
|
|
@@ -121,7 +121,7 @@ function resolveRule(recurrence, timeZone) {
|
|
|
121
121
|
function expandRecurrence(event, range, ctx) {
|
|
122
122
|
const allDay = event.allDay ?? false;
|
|
123
123
|
if (!event.recurrence) {
|
|
124
|
-
if (event.start < range.end && event.end > range.start) return [{
|
|
124
|
+
if (event.end.getTime() === event.start.getTime() ? event.start >= range.start && event.start < range.end : event.start < range.end && event.end > range.start) return [{
|
|
125
125
|
key: `${event.id}::${event.start.toISOString()}`,
|
|
126
126
|
eventId: event.id,
|
|
127
127
|
event,
|
|
@@ -169,7 +169,7 @@ function expandRecurrence(event, range, ctx) {
|
|
|
169
169
|
const start = new Date(rawStart.getTime());
|
|
170
170
|
if (exTimes.has(start.getTime())) return;
|
|
171
171
|
const end = new Date(start.getTime() + durationMs);
|
|
172
|
-
if (start < range.end && end > range.start) occurrences.push({
|
|
172
|
+
if (durationMs === 0 ? start >= range.start && start < range.end : start < range.end && end > range.start) occurrences.push({
|
|
173
173
|
key: `${event.id}::${start.toISOString()}`,
|
|
174
174
|
eventId: event.id,
|
|
175
175
|
event,
|
|
@@ -208,7 +208,7 @@ function expandRecurrence(event, range, ctx) {
|
|
|
208
208
|
const start = new Date(rDate.getTime());
|
|
209
209
|
if (seen.has(start.getTime()) || exTimes.has(start.getTime())) continue;
|
|
210
210
|
const end = new Date(start.getTime() + durationMs);
|
|
211
|
-
if (start >= range.end || end <= range.start) continue;
|
|
211
|
+
if (durationMs === 0 ? start < range.start || start >= range.end : start >= range.end || end <= range.start) continue;
|
|
212
212
|
seen.add(start.getTime());
|
|
213
213
|
occurrences.push({
|
|
214
214
|
key: `${event.id}::${start.toISOString()}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gantt-recurrence.js","names":[],"sources":["../../../../src/components/reui/gantt/gantt-recurrence.tsx"],"sourcesContent":["\"use client\";\n\nimport { TZDate } from \"@date-fns/tz\";\nimport { addDays, addMonths, addWeeks, addYears } from \"date-fns\";\n\nimport type {\n GanttDateRange,\n GanttEvent,\n GanttOccurrence,\n GanttRecurrenceRule,\n GanttWeekday,\n} from \"./gantt-types\";\n\n/** Guard: max occurrences per event per expansion. */\nconst MAX_OCCURRENCES = 1000;\n\nconst WEEKDAYS: GanttWeekday[] = [\"SU\", \"MO\", \"TU\", \"WE\", \"TH\", \"FR\", \"SA\"];\n\nclass GanttRecurrenceError extends Error {\n constructor(part: string) {\n super(\n `Unsupported recurrence part: ${part}. Use the getOccurrences prop to plug a full RRULE engine for exotic rules.`,\n );\n this.name = \"GanttRecurrenceError\";\n }\n}\n\n/**\n * Parses a raw RRULE line (with or without the \"RRULE:\" prefix) into the\n * structured subset. Pass the display time zone so a floating UNTIL\n * (no trailing Z) resolves there instead of in the runtime's local zone.\n */\nfunction parseRRuleString(input: string, timeZone?: string): GanttRecurrenceRule {\n const body = input.trim().replace(/^RRULE:/i, \"\");\n const rule: Partial<GanttRecurrenceRule> = {};\n\n for (const pair of body.split(\";\")) {\n if (!pair) continue;\n const [rawKey, rawValue] = pair.split(\"=\");\n const key = rawKey?.toUpperCase();\n const value = rawValue ?? \"\";\n\n switch (key) {\n case \"FREQ\": {\n const freq = value.toLowerCase();\n if (freq !== \"daily\" && freq !== \"weekly\" && freq !== \"monthly\" && freq !== \"yearly\") {\n throw new GanttRecurrenceError(`FREQ=${value}`);\n }\n rule.freq = freq;\n break;\n }\n case \"INTERVAL\":\n rule.interval = Math.max(1, parseInt(value, 10) || 1);\n break;\n case \"COUNT\":\n rule.count = Math.max(1, parseInt(value, 10) || 1);\n break;\n case \"UNTIL\":\n rule.until = parseRRuleDate(value, timeZone);\n break;\n case \"BYDAY\":\n rule.byWeekday = value.split(\",\").map((token) => {\n const match = /^(-?\\d+)?(SU|MO|TU|WE|TH|FR|SA)$/.exec(token.trim());\n if (!match) throw new GanttRecurrenceError(`BYDAY=${token}`);\n const day = match[2] as GanttWeekday;\n return match[1] ? { day, ordinal: parseInt(match[1], 10) } : day;\n });\n break;\n case \"BYMONTHDAY\":\n rule.byMonthDay = value.split(\",\").map((v) => parseInt(v, 10));\n break;\n case \"BYMONTH\":\n rule.byMonth = value.split(\",\").map((v) => parseInt(v, 10));\n break;\n case \"WKST\": {\n if (!WEEKDAYS.includes(value as GanttWeekday)) {\n throw new GanttRecurrenceError(`WKST=${value}`);\n }\n rule.weekStart = value as GanttWeekday;\n break;\n }\n default:\n throw new GanttRecurrenceError(key ?? pair);\n }\n }\n\n if (!rule.freq) throw new GanttRecurrenceError(\"missing FREQ\");\n return rule as GanttRecurrenceRule;\n}\n\nfunction parseRRuleDate(value: string, timeZone?: string): Date {\n // RFC 5545 basic formats: YYYYMMDD or YYYYMMDDTHHMMSS(Z)\n const match = /^(\\d{4})(\\d{2})(\\d{2})(?:T(\\d{2})(\\d{2})(\\d{2})(Z)?)?$/.exec(value);\n if (!match) throw new GanttRecurrenceError(`UNTIL=${value}`);\n const [, y, m, d, hh = \"23\", mm = \"59\", ss = \"59\", z] = match;\n // Floating (non-Z) boundaries resolve in the DISPLAY zone when known -\n // local-zone parsing would shift the series end per visitor machine.\n const date =\n !z && timeZone\n ? new TZDate(+y, +m - 1, +d, +hh, +mm, +ss, timeZone)\n : new Date(`${y}-${m}-${d}T${hh}:${mm}:${ss}${z ? \"Z\" : \"\"}`);\n if (Number.isNaN(date.getTime())) {\n throw new GanttRecurrenceError(`UNTIL=${value}`);\n }\n return new Date(date.getTime());\n}\n\n/** Serializes the structured subset back to an RRULE line (without prefix). */\nfunction formatRRuleString(rule: GanttRecurrenceRule): string {\n const parts: string[] = [`FREQ=${rule.freq.toUpperCase()}`];\n if (rule.interval && rule.interval > 1) parts.push(`INTERVAL=${rule.interval}`);\n if (rule.count) parts.push(`COUNT=${rule.count}`);\n if (rule.until) {\n const u = rule.until;\n const pad = (n: number) => String(n).padStart(2, \"0\");\n parts.push(\n `UNTIL=${u.getUTCFullYear()}${pad(u.getUTCMonth() + 1)}${pad(u.getUTCDate())}T${pad(u.getUTCHours())}${pad(u.getUTCMinutes())}${pad(u.getUTCSeconds())}Z`,\n );\n }\n if (rule.byWeekday?.length) {\n parts.push(\n `BYDAY=${rule.byWeekday\n .map((d) => (typeof d === \"string\" ? d : `${d.ordinal}${d.day}`))\n .join(\",\")}`,\n );\n }\n if (rule.byMonthDay?.length) parts.push(`BYMONTHDAY=${rule.byMonthDay.join(\",\")}`);\n if (rule.byMonth?.length) parts.push(`BYMONTH=${rule.byMonth.join(\",\")}`);\n if (rule.weekStart) parts.push(`WKST=${rule.weekStart}`);\n return parts.join(\";\");\n}\n\nfunction resolveRule(\n recurrence: GanttRecurrenceRule | string,\n timeZone?: string,\n): GanttRecurrenceRule {\n return typeof recurrence === \"string\" ? parseRRuleString(recurrence, timeZone) : recurrence;\n}\n\n/**\n * Expands one event into its occurrences intersecting the range.\n * Non-recurring events yield at most one occurrence. Recurrence iteration is\n * wall-time based in the display zone (DST-safe day/week/month steps).\n *\n * Supported subset: FREQ daily/weekly/monthly/yearly, INTERVAL, COUNT, UNTIL,\n * weekly BYDAY (no ordinals). Parsed-but-unimplemented filters (BYMONTHDAY,\n * BYMONTH, BYDAY outside weekly) throw a GanttRecurrenceError instead of\n * silently mis-expanding; plug the getOccurrences prop for a full engine.\n * WKST parses and round-trips; week emission is Sunday-anchored.\n *\n * exDates remove exactly-matching instants (after COUNT numbering,\n * Google-style: an exception still consumes its COUNT slot); rDates add extra\n * instants with the same duration. RECURRENCE-ID override replacement lives\n * in buildEventIndex, where the override event and its parent series meet.\n */\nfunction expandRecurrence<TData>(\n event: GanttEvent<TData>,\n range: GanttDateRange,\n ctx: { timeZone: string },\n): GanttOccurrence<TData>[] {\n const allDay = event.allDay ?? false;\n\n if (!event.recurrence) {\n if (event.start < range.end && event.end > range.start) {\n return [\n {\n key: `${event.id}::${event.start.toISOString()}`,\n eventId: event.id,\n event,\n start: event.start,\n end: event.end,\n allDay,\n isRecurring: false,\n },\n ];\n }\n return [];\n }\n\n const rule = resolveRule(event.recurrence, ctx.timeZone);\n // Loud contract: silently ignoring a filter would emit WRONG occurrences.\n if (rule.byMonthDay?.length) throw new GanttRecurrenceError(\"BYMONTHDAY\");\n if (rule.byMonth?.length) throw new GanttRecurrenceError(\"BYMONTH\");\n if (rule.byWeekday?.length && rule.freq !== \"weekly\") {\n throw new GanttRecurrenceError(\"BYDAY outside FREQ=WEEKLY\");\n }\n const interval = Math.max(1, rule.interval ?? 1);\n const durationMs = event.end.getTime() - event.start.getTime();\n const zonedStart = new TZDate(event.start.getTime(), ctx.timeZone);\n // Excluded instants matched exactly; filtering happens at push time so an\n // exception still consumes its COUNT slot (Google-style numbering).\n const exTimes = new Set((rule.exDates ?? []).map((d) => d.getTime()));\n\n const weeklyDays: number[] | null =\n rule.freq === \"weekly\" && rule.byWeekday?.length\n ? rule.byWeekday.map((d) => {\n if (typeof d !== \"string\") {\n throw new GanttRecurrenceError(\"BYDAY ordinal outside monthly/yearly\");\n }\n return WEEKDAYS.indexOf(d);\n })\n : null;\n\n const occurrences: GanttOccurrence<TData>[] = [];\n let produced = 0;\n let index = 0;\n let cursor = zonedStart;\n\n const advance = (from: TZDate, steps: number): TZDate =>\n rule.freq === \"daily\"\n ? addDays(from, steps * interval)\n : rule.freq === \"weekly\"\n ? addWeeks(from, steps * interval)\n : rule.freq === \"monthly\"\n ? addMonths(from, steps * interval)\n : addYears(from, steps * interval);\n\n // Fast-forward past periods entirely before the range: they produce\n // nothing and must not consume the occurrence cap (an old-enough daily\n // series would otherwise exhaust MAX_OCCURRENCES before reaching the\n // window and silently vanish). COUNT rules jump too: the skipped periods\n // are credited to `index`, which is what terminates the series, so the\n // count still ends it on exactly the right instant. Leaving them on full\n // iteration would hide any series whose count exceeds MAX_OCCURRENCES.\n //\n // Daily and weekly ONLY. Their step is a fixed wall-time length, so one jump\n // of N steps lands exactly where N single steps land. addMonths/addYears\n // CLAMP instead: a Jan 31 monthly anchor steps to Feb 28 and never returns to\n // the 31st, while a single jump from the anchor clamps at most once. Jumping\n // those would make the same occurrence render on a different day depending on\n // which window the viewer scrolled in from, so they always iterate.\n const canFastForward = rule.freq === \"daily\" || rule.freq === \"weekly\";\n // weekly BYDAY emits across the cursor's whole Sunday week\n const weekSlackMs = weeklyDays ? 6 * 86_400_000 : 0;\n // divide by the LONGEST possible step so the jump can never overshoot\n const maxStepMs =\n (rule.freq === \"daily\"\n ? 24\n : rule.freq === \"weekly\"\n ? 7 * 24\n : rule.freq === \"monthly\"\n ? 31 * 24\n : 366 * 24) *\n 3_600_000 *\n interval +\n 3_600_000;\n for (let pass = 0; canFastForward && pass < 2; pass++) {\n const gap = range.start.getTime() - durationMs - weekSlackMs - cursor.getTime();\n const skip = Math.floor(gap / maxStepMs);\n if (skip <= 0) break;\n cursor = advance(cursor, skip);\n index += skip * (weeklyDays ? weeklyDays.length : 1);\n }\n // close the remainder step by step (bounded by the jump math)\n let guard = 0;\n while (\n guard++ < 10_000 &&\n !(rule.until && cursor.getTime() > rule.until.getTime()) &&\n cursor.getTime() + durationMs + weekSlackMs < range.start.getTime()\n ) {\n cursor = advance(cursor, 1);\n index += weeklyDays ? weeklyDays.length : 1;\n }\n // The jump credits a whole week of selected days per skipped week, but full\n // iteration never counts the selected days that fall BEFORE the anchor\n // inside the anchor's own week. Drop them once so both paths number the\n // same instant identically (index counts occurrences at or after the\n // anchor, and only those).\n if (weeklyDays && index > 0) {\n index -= weeklyDays.filter((day) => day < zonedStart.getDay()).length;\n }\n\n const pushIfVisible = (rawStart: Date) => {\n // normalize to a plain instant so consumers never receive zone-carrying\n // TZDate instances (mixed-zone formatting bugs)\n const start = new Date(rawStart.getTime());\n if (exTimes.has(start.getTime())) return;\n const end = new Date(start.getTime() + durationMs);\n if (start < range.end && end > range.start) {\n occurrences.push({\n key: `${event.id}::${start.toISOString()}`,\n eventId: event.id,\n event,\n start,\n end,\n allDay,\n isRecurring: true,\n recurrenceIndex: index,\n });\n }\n };\n\n while (produced < MAX_OCCURRENCES) {\n if (rule.until && cursor.getTime() > rule.until.getTime()) break;\n // COUNT is series-absolute, so it reads `index` (the position in the\n // series, fast-forward included) rather than `produced` (emissions in\n // this loop, which MAX_OCCURRENCES caps).\n if (rule.count !== undefined && index >= rule.count) break;\n // Past the visible window with no count to honor - stop iterating. For\n // weekly BYDAY the WEEK START decides: selected days earlier in the\n // anchor's week can still fall before range.end.\n const horizonMs = weeklyDays ? addDays(cursor, -cursor.getDay()).getTime() : cursor.getTime();\n if (horizonMs >= range.end.getTime() && rule.count === undefined) {\n break;\n }\n\n if (rule.freq === \"weekly\" && weeklyDays) {\n // Emit each selected weekday within the cursor's week\n for (let d = 0; d < 7; d++) {\n const candidate = addDays(cursor, d - cursor.getDay());\n if (!weeklyDays.includes(candidate.getDay())) continue;\n if (candidate.getTime() < zonedStart.getTime()) continue;\n if (rule.until && candidate.getTime() > rule.until.getTime()) continue;\n // the cap is checked here too, or a week that crosses it mid-loop\n // still emits its remaining selected days\n if (produced >= MAX_OCCURRENCES) break;\n if (rule.count !== undefined && index >= rule.count) break;\n pushIfVisible(candidate);\n produced++;\n index++;\n }\n } else {\n pushIfVisible(cursor);\n produced++;\n index++;\n }\n\n cursor = advance(cursor, 1);\n }\n\n // RDATE: extra instants join the set (deduped against generated starts and\n // exclusions) with the same wall-time duration. Sorted so direct consumers\n // still receive chronological order (buildEventIndex re-sorts regardless).\n if (rule.rDates?.length) {\n const seen = new Set(occurrences.map((o) => o.start.getTime()));\n for (const rDate of rule.rDates) {\n const start = new Date(rDate.getTime());\n if (seen.has(start.getTime()) || exTimes.has(start.getTime())) continue;\n const end = new Date(start.getTime() + durationMs);\n if (start >= range.end || end <= range.start) continue;\n seen.add(start.getTime());\n occurrences.push({\n key: `${event.id}::${start.toISOString()}`,\n eventId: event.id,\n event,\n start,\n end,\n allDay,\n isRecurring: true,\n // keep counting past the generated instants: an RDATE with no index\n // would fall back to 0 and collide with the series' first occurrence\n // in any consumer that identifies an instance by its position\n recurrenceIndex: index++,\n });\n }\n occurrences.sort((a, b) => a.start.getTime() - b.start.getTime());\n }\n\n return occurrences;\n}\n\nexport {\n expandRecurrence,\n formatRRuleString,\n GanttRecurrenceError,\n MAX_OCCURRENCES,\n parseRRuleString,\n};\n"],"mappings":";;;;;AAcA,MAAM,kBAAkB;AAExB,MAAM,WAA2B;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI;AAE1E,IAAM,uBAAN,cAAmC,MAAM;CACvC,YAAY,MAAc;EACxB,MACE,gCAAgC,KAAK,4EACvC;EACA,KAAK,OAAO;CACd;AACF;;;;;;AAOA,SAAS,iBAAiB,OAAe,UAAwC;CAC/E,MAAM,OAAO,MAAM,KAAK,CAAC,CAAC,QAAQ,YAAY,EAAE;CAChD,MAAM,OAAqC,CAAC;CAE5C,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG;EAClC,IAAI,CAAC,MAAM;EACX,MAAM,CAAC,QAAQ,YAAY,KAAK,MAAM,GAAG;EACzC,MAAM,MAAM,QAAQ,YAAY;EAChC,MAAM,QAAQ,YAAY;EAE1B,QAAQ,KAAR;GACE,KAAK,QAAQ;IACX,MAAM,OAAO,MAAM,YAAY;IAC/B,IAAI,SAAS,WAAW,SAAS,YAAY,SAAS,aAAa,SAAS,UAC1E,MAAM,IAAI,qBAAqB,QAAQ,OAAO;IAEhD,KAAK,OAAO;IACZ;GACF;GACA,KAAK;IACH,KAAK,WAAW,KAAK,IAAI,GAAG,SAAS,OAAO,EAAE,KAAK,CAAC;IACpD;GACF,KAAK;IACH,KAAK,QAAQ,KAAK,IAAI,GAAG,SAAS,OAAO,EAAE,KAAK,CAAC;IACjD;GACF,KAAK;IACH,KAAK,QAAQ,eAAe,OAAO,QAAQ;IAC3C;GACF,KAAK;IACH,KAAK,YAAY,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,UAAU;KAC/C,MAAM,QAAQ,mCAAmC,KAAK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ACH;EACA,YAAY,MAAM,GAAG,MAAM,EAAE,MAAM,QAAQ,IAAI,EAAE,MAAM,QAAQ,CAAC;CAClE;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"gantt-recurrence.js","names":[],"sources":["../../../../src/components/reui/gantt/gantt-recurrence.tsx"],"sourcesContent":["\"use client\";\n\nimport { TZDate } from \"@date-fns/tz\";\nimport { addDays, addMonths, addWeeks, addYears } from \"date-fns\";\n\nimport type {\n GanttDateRange,\n GanttEvent,\n GanttOccurrence,\n GanttRecurrenceRule,\n GanttWeekday,\n} from \"./gantt-types\";\n\n/** Guard: max occurrences per event per expansion. */\nconst MAX_OCCURRENCES = 1000;\n\nconst WEEKDAYS: GanttWeekday[] = [\"SU\", \"MO\", \"TU\", \"WE\", \"TH\", \"FR\", \"SA\"];\n\nclass GanttRecurrenceError extends Error {\n constructor(part: string) {\n super(\n `Unsupported recurrence part: ${part}. Use the getOccurrences prop to plug a full RRULE engine for exotic rules.`,\n );\n this.name = \"GanttRecurrenceError\";\n }\n}\n\n/**\n * Parses a raw RRULE line (with or without the \"RRULE:\" prefix) into the\n * structured subset. Pass the display time zone so a floating UNTIL\n * (no trailing Z) resolves there instead of in the runtime's local zone.\n */\nfunction parseRRuleString(input: string, timeZone?: string): GanttRecurrenceRule {\n const body = input.trim().replace(/^RRULE:/i, \"\");\n const rule: Partial<GanttRecurrenceRule> = {};\n\n for (const pair of body.split(\";\")) {\n if (!pair) continue;\n const [rawKey, rawValue] = pair.split(\"=\");\n const key = rawKey?.toUpperCase();\n const value = rawValue ?? \"\";\n\n switch (key) {\n case \"FREQ\": {\n const freq = value.toLowerCase();\n if (freq !== \"daily\" && freq !== \"weekly\" && freq !== \"monthly\" && freq !== \"yearly\") {\n throw new GanttRecurrenceError(`FREQ=${value}`);\n }\n rule.freq = freq;\n break;\n }\n case \"INTERVAL\":\n rule.interval = Math.max(1, parseInt(value, 10) || 1);\n break;\n case \"COUNT\":\n rule.count = Math.max(1, parseInt(value, 10) || 1);\n break;\n case \"UNTIL\":\n rule.until = parseRRuleDate(value, timeZone);\n break;\n case \"BYDAY\":\n rule.byWeekday = value.split(\",\").map((token) => {\n const match = /^(-?\\d+)?(SU|MO|TU|WE|TH|FR|SA)$/.exec(token.trim());\n if (!match) throw new GanttRecurrenceError(`BYDAY=${token}`);\n const day = match[2] as GanttWeekday;\n return match[1] ? { day, ordinal: parseInt(match[1], 10) } : day;\n });\n break;\n case \"BYMONTHDAY\":\n rule.byMonthDay = value.split(\",\").map((v) => parseInt(v, 10));\n break;\n case \"BYMONTH\":\n rule.byMonth = value.split(\",\").map((v) => parseInt(v, 10));\n break;\n case \"WKST\": {\n if (!WEEKDAYS.includes(value as GanttWeekday)) {\n throw new GanttRecurrenceError(`WKST=${value}`);\n }\n rule.weekStart = value as GanttWeekday;\n break;\n }\n default:\n throw new GanttRecurrenceError(key ?? pair);\n }\n }\n\n if (!rule.freq) throw new GanttRecurrenceError(\"missing FREQ\");\n return rule as GanttRecurrenceRule;\n}\n\nfunction parseRRuleDate(value: string, timeZone?: string): Date {\n // RFC 5545 basic formats: YYYYMMDD or YYYYMMDDTHHMMSS(Z)\n const match = /^(\\d{4})(\\d{2})(\\d{2})(?:T(\\d{2})(\\d{2})(\\d{2})(Z)?)?$/.exec(value);\n if (!match) throw new GanttRecurrenceError(`UNTIL=${value}`);\n const [, y, m, d, hh = \"23\", mm = \"59\", ss = \"59\", z] = match;\n // Floating (non-Z) boundaries resolve in the DISPLAY zone when known -\n // local-zone parsing would shift the series end per visitor machine.\n const date =\n !z && timeZone\n ? new TZDate(+y, +m - 1, +d, +hh, +mm, +ss, timeZone)\n : new Date(`${y}-${m}-${d}T${hh}:${mm}:${ss}${z ? \"Z\" : \"\"}`);\n if (Number.isNaN(date.getTime())) {\n throw new GanttRecurrenceError(`UNTIL=${value}`);\n }\n return new Date(date.getTime());\n}\n\n/** Serializes the structured subset back to an RRULE line (without prefix). */\nfunction formatRRuleString(rule: GanttRecurrenceRule): string {\n const parts: string[] = [`FREQ=${rule.freq.toUpperCase()}`];\n if (rule.interval && rule.interval > 1) parts.push(`INTERVAL=${rule.interval}`);\n if (rule.count) parts.push(`COUNT=${rule.count}`);\n if (rule.until) {\n const u = rule.until;\n const pad = (n: number) => String(n).padStart(2, \"0\");\n parts.push(\n `UNTIL=${u.getUTCFullYear()}${pad(u.getUTCMonth() + 1)}${pad(u.getUTCDate())}T${pad(u.getUTCHours())}${pad(u.getUTCMinutes())}${pad(u.getUTCSeconds())}Z`,\n );\n }\n if (rule.byWeekday?.length) {\n parts.push(\n `BYDAY=${rule.byWeekday\n .map((d) => (typeof d === \"string\" ? d : `${d.ordinal}${d.day}`))\n .join(\",\")}`,\n );\n }\n if (rule.byMonthDay?.length) parts.push(`BYMONTHDAY=${rule.byMonthDay.join(\",\")}`);\n if (rule.byMonth?.length) parts.push(`BYMONTH=${rule.byMonth.join(\",\")}`);\n if (rule.weekStart) parts.push(`WKST=${rule.weekStart}`);\n return parts.join(\";\");\n}\n\nfunction resolveRule(\n recurrence: GanttRecurrenceRule | string,\n timeZone?: string,\n): GanttRecurrenceRule {\n return typeof recurrence === \"string\" ? parseRRuleString(recurrence, timeZone) : recurrence;\n}\n\n/**\n * Expands one event into its occurrences intersecting the range.\n * Non-recurring events yield at most one occurrence. Recurrence iteration is\n * wall-time based in the display zone (DST-safe day/week/month steps).\n *\n * Supported subset: FREQ daily/weekly/monthly/yearly, INTERVAL, COUNT, UNTIL,\n * weekly BYDAY (no ordinals). Parsed-but-unimplemented filters (BYMONTHDAY,\n * BYMONTH, BYDAY outside weekly) throw a GanttRecurrenceError instead of\n * silently mis-expanding; plug the getOccurrences prop for a full engine.\n * WKST parses and round-trips; week emission is Sunday-anchored.\n *\n * exDates remove exactly-matching instants (after COUNT numbering,\n * Google-style: an exception still consumes its COUNT slot); rDates add extra\n * instants with the same duration. RECURRENCE-ID override replacement lives\n * in buildEventIndex, where the override event and its parent series meet.\n */\nfunction expandRecurrence<TData>(\n event: GanttEvent<TData>,\n range: GanttDateRange,\n ctx: { timeZone: string },\n): GanttOccurrence<TData>[] {\n const allDay = event.allDay ?? false;\n\n if (!event.recurrence) {\n // Same rule as occurrenceIntersects in gantt-lib, inlined (importing it\n // back would cycle the modules): half-open, except a zero-length\n // milestone sitting exactly on the range start stays visible.\n const visible =\n event.end.getTime() === event.start.getTime()\n ? event.start >= range.start && event.start < range.end\n : event.start < range.end && event.end > range.start;\n if (visible) {\n return [\n {\n key: `${event.id}::${event.start.toISOString()}`,\n eventId: event.id,\n event,\n start: event.start,\n end: event.end,\n allDay,\n isRecurring: false,\n },\n ];\n }\n return [];\n }\n\n const rule = resolveRule(event.recurrence, ctx.timeZone);\n // Loud contract: silently ignoring a filter would emit WRONG occurrences.\n if (rule.byMonthDay?.length) throw new GanttRecurrenceError(\"BYMONTHDAY\");\n if (rule.byMonth?.length) throw new GanttRecurrenceError(\"BYMONTH\");\n if (rule.byWeekday?.length && rule.freq !== \"weekly\") {\n throw new GanttRecurrenceError(\"BYDAY outside FREQ=WEEKLY\");\n }\n const interval = Math.max(1, rule.interval ?? 1);\n const durationMs = event.end.getTime() - event.start.getTime();\n const zonedStart = new TZDate(event.start.getTime(), ctx.timeZone);\n // Excluded instants matched exactly; filtering happens at push time so an\n // exception still consumes its COUNT slot (Google-style numbering).\n const exTimes = new Set((rule.exDates ?? []).map((d) => d.getTime()));\n\n const weeklyDays: number[] | null =\n rule.freq === \"weekly\" && rule.byWeekday?.length\n ? rule.byWeekday.map((d) => {\n if (typeof d !== \"string\") {\n throw new GanttRecurrenceError(\"BYDAY ordinal outside monthly/yearly\");\n }\n return WEEKDAYS.indexOf(d);\n })\n : null;\n\n const occurrences: GanttOccurrence<TData>[] = [];\n let produced = 0;\n let index = 0;\n let cursor = zonedStart;\n\n const advance = (from: TZDate, steps: number): TZDate =>\n rule.freq === \"daily\"\n ? addDays(from, steps * interval)\n : rule.freq === \"weekly\"\n ? addWeeks(from, steps * interval)\n : rule.freq === \"monthly\"\n ? addMonths(from, steps * interval)\n : addYears(from, steps * interval);\n\n // Fast-forward past periods entirely before the range: they produce\n // nothing and must not consume the occurrence cap (an old-enough daily\n // series would otherwise exhaust MAX_OCCURRENCES before reaching the\n // window and silently vanish). COUNT rules jump too: the skipped periods\n // are credited to `index`, which is what terminates the series, so the\n // count still ends it on exactly the right instant. Leaving them on full\n // iteration would hide any series whose count exceeds MAX_OCCURRENCES.\n //\n // Daily and weekly ONLY. Their step is a fixed wall-time length, so one jump\n // of N steps lands exactly where N single steps land. addMonths/addYears\n // CLAMP instead: a Jan 31 monthly anchor steps to Feb 28 and never returns to\n // the 31st, while a single jump from the anchor clamps at most once. Jumping\n // those would make the same occurrence render on a different day depending on\n // which window the viewer scrolled in from, so they always iterate.\n const canFastForward = rule.freq === \"daily\" || rule.freq === \"weekly\";\n // weekly BYDAY emits across the cursor's whole Sunday week\n const weekSlackMs = weeklyDays ? 6 * 86_400_000 : 0;\n // divide by the LONGEST possible step so the jump can never overshoot\n const maxStepMs =\n (rule.freq === \"daily\"\n ? 24\n : rule.freq === \"weekly\"\n ? 7 * 24\n : rule.freq === \"monthly\"\n ? 31 * 24\n : 366 * 24) *\n 3_600_000 *\n interval +\n 3_600_000;\n for (let pass = 0; canFastForward && pass < 2; pass++) {\n const gap = range.start.getTime() - durationMs - weekSlackMs - cursor.getTime();\n const skip = Math.floor(gap / maxStepMs);\n if (skip <= 0) break;\n cursor = advance(cursor, skip);\n index += skip * (weeklyDays ? weeklyDays.length : 1);\n }\n // close the remainder step by step (bounded by the jump math)\n let guard = 0;\n while (\n guard++ < 10_000 &&\n !(rule.until && cursor.getTime() > rule.until.getTime()) &&\n cursor.getTime() + durationMs + weekSlackMs < range.start.getTime()\n ) {\n cursor = advance(cursor, 1);\n index += weeklyDays ? weeklyDays.length : 1;\n }\n // The jump credits a whole week of selected days per skipped week, but full\n // iteration never counts the selected days that fall BEFORE the anchor\n // inside the anchor's own week. Drop them once so both paths number the\n // same instant identically (index counts occurrences at or after the\n // anchor, and only those).\n if (weeklyDays && index > 0) {\n index -= weeklyDays.filter((day) => day < zonedStart.getDay()).length;\n }\n\n const pushIfVisible = (rawStart: Date) => {\n // normalize to a plain instant so consumers never receive zone-carrying\n // TZDate instances (mixed-zone formatting bugs)\n const start = new Date(rawStart.getTime());\n if (exTimes.has(start.getTime())) return;\n const end = new Date(start.getTime() + durationMs);\n // zero-length instances (milestones) keep the closed-start visibility\n // rule; see the non-recurring branch above\n const visible =\n durationMs === 0\n ? start >= range.start && start < range.end\n : start < range.end && end > range.start;\n if (visible) {\n occurrences.push({\n key: `${event.id}::${start.toISOString()}`,\n eventId: event.id,\n event,\n start,\n end,\n allDay,\n isRecurring: true,\n recurrenceIndex: index,\n });\n }\n };\n\n while (produced < MAX_OCCURRENCES) {\n if (rule.until && cursor.getTime() > rule.until.getTime()) break;\n // COUNT is series-absolute, so it reads `index` (the position in the\n // series, fast-forward included) rather than `produced` (emissions in\n // this loop, which MAX_OCCURRENCES caps).\n if (rule.count !== undefined && index >= rule.count) break;\n // Past the visible window with no count to honor - stop iterating. For\n // weekly BYDAY the WEEK START decides: selected days earlier in the\n // anchor's week can still fall before range.end.\n const horizonMs = weeklyDays ? addDays(cursor, -cursor.getDay()).getTime() : cursor.getTime();\n if (horizonMs >= range.end.getTime() && rule.count === undefined) {\n break;\n }\n\n if (rule.freq === \"weekly\" && weeklyDays) {\n // Emit each selected weekday within the cursor's week\n for (let d = 0; d < 7; d++) {\n const candidate = addDays(cursor, d - cursor.getDay());\n if (!weeklyDays.includes(candidate.getDay())) continue;\n if (candidate.getTime() < zonedStart.getTime()) continue;\n if (rule.until && candidate.getTime() > rule.until.getTime()) continue;\n // the cap is checked here too, or a week that crosses it mid-loop\n // still emits its remaining selected days\n if (produced >= MAX_OCCURRENCES) break;\n if (rule.count !== undefined && index >= rule.count) break;\n pushIfVisible(candidate);\n produced++;\n index++;\n }\n } else {\n pushIfVisible(cursor);\n produced++;\n index++;\n }\n\n cursor = advance(cursor, 1);\n }\n\n // RDATE: extra instants join the set (deduped against generated starts and\n // exclusions) with the same wall-time duration. Sorted so direct consumers\n // still receive chronological order (buildEventIndex re-sorts regardless).\n if (rule.rDates?.length) {\n const seen = new Set(occurrences.map((o) => o.start.getTime()));\n for (const rDate of rule.rDates) {\n const start = new Date(rDate.getTime());\n if (seen.has(start.getTime()) || exTimes.has(start.getTime())) continue;\n const end = new Date(start.getTime() + durationMs);\n // mirrored visibility rule: zero-length RDATEs stay closed at the start\n const hidden =\n durationMs === 0\n ? start < range.start || start >= range.end\n : start >= range.end || end <= range.start;\n if (hidden) continue;\n seen.add(start.getTime());\n occurrences.push({\n key: `${event.id}::${start.toISOString()}`,\n eventId: event.id,\n event,\n start,\n end,\n allDay,\n isRecurring: true,\n // keep counting past the generated instants: an RDATE with no index\n // would fall back to 0 and collide with the series' first occurrence\n // in any consumer that identifies an instance by its position\n recurrenceIndex: index++,\n });\n }\n occurrences.sort((a, b) => a.start.getTime() - b.start.getTime());\n }\n\n return occurrences;\n}\n\nexport {\n expandRecurrence,\n formatRRuleString,\n GanttRecurrenceError,\n MAX_OCCURRENCES,\n parseRRuleString,\n};\n"],"mappings":";;;;;AAcA,MAAM,kBAAkB;AAExB,MAAM,WAA2B;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI;AAE1E,IAAM,uBAAN,cAAmC,MAAM;CACvC,YAAY,MAAc;EACxB,MACE,gCAAgC,KAAK,4EACvC;EACA,KAAK,OAAO;CACd;AACF;;;;;;AAOA,SAAS,iBAAiB,OAAe,UAAwC;CAC/E,MAAM,OAAO,MAAM,KAAK,CAAC,CAAC,QAAQ,YAAY,EAAE;CAChD,MAAM,OAAqC,CAAC;CAE5C,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG;EAClC,IAAI,CAAC,MAAM;EACX,MAAM,CAAC,QAAQ,YAAY,KAAK,MAAM,GAAG;EACzC,MAAM,MAAM,QAAQ,YAAY;EAChC,MAAM,QAAQ,YAAY;EAE1B,QAAQ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EACF;OACK;GACL,cAAc,MAAM;GACpB;GACA;EACF;EAEA,SAAS,QAAQ,QAAQ,CAAC;CAC5B;CAKA,IAAI,KAAK,QAAQ,QAAQ;EACvB,MAAM,OAAO,IAAI,IAAI,YAAY,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC,CAAC;EAC9D,KAAK,MAAM,SAAS,KAAK,QAAQ;GAC/B,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;GACtC,IAAI,KAAK,IAAI,MAAM,QAAQ,CAAC,KAAK,QAAQ,IAAI,MAAM,QAAQ,CAAC,GAAG;GAC/D,MAAM,MAAM,IAAI,KAAK,MAAM,QAAQ,IAAI,UAAU;GAMjD,IAHE,eAAe,IACX,QAAQ,MAAM,SAAS,SAAS,MAAM,MACtC,SAAS,MAAM,OAAO,OAAO,MAAM,OAC7B;GACZ,KAAK,IAAI,MAAM,QAAQ,CAAC;GACxB,YAAY,KAAK;IACf,KAAK,GAAG,MAAM,GAAG,IAAI,MAAM,YAAY;IACvC,SAAS,MAAM;IACf;IACA;IACA;IACA;IACA,aAAa;IAIb,iBAAiB;GACnB,CAAC;EACH;EACA,YAAY,MAAM,GAAG,MAAM,EAAE,MAAM,QAAQ,IAAI,EAAE,MAAM,QAAQ,CAAC;CAClE;CAEA,OAAO;AACT"}
|
|
@@ -29,6 +29,13 @@ interface GanttResource {
|
|
|
29
29
|
color?: string;
|
|
30
30
|
/** Per-node cardinality; falls back to the view-level default. */
|
|
31
31
|
scheduleMode?: GanttScheduleMode;
|
|
32
|
+
/**
|
|
33
|
+
* Planned (as-built baseline) window for the WHOLE node, ghosted as a
|
|
34
|
+
* band behind its lanes - independent of any per-event baselines. Half
|
|
35
|
+
* open; set both or neither. Equal instants mark a planned milestone.
|
|
36
|
+
*/
|
|
37
|
+
baselineStart?: Date;
|
|
38
|
+
baselineEnd?: Date;
|
|
32
39
|
children?: GanttResource[];
|
|
33
40
|
}
|
|
34
41
|
/** Preferred name for a tree node; `GanttResource` is the legacy alias. */
|
|
@@ -77,9 +84,25 @@ interface GanttEvent<TData = unknown> {
|
|
|
77
84
|
priority?: number;
|
|
78
85
|
/** Completion 0-100, not 0-1. */
|
|
79
86
|
progress?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Planned (as-built baseline) window, drawn behind the bar so the actual
|
|
89
|
+
* start/end read against it. Half-open like start/end; set both or
|
|
90
|
+
* neither. Equal instants mark a planned milestone. A recurring series
|
|
91
|
+
* has no single planned window, so events with `recurrence` render none.
|
|
92
|
+
*/
|
|
93
|
+
baselineStart?: Date;
|
|
94
|
+
baselineEnd?: Date;
|
|
80
95
|
/** Explicit stacking override; wins over the computed z. */
|
|
81
96
|
zIndex?: number;
|
|
82
97
|
resourceId?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Ids of the events this one waits on (finish-to-start). The view draws an
|
|
100
|
+
* elbow arrow from each named event's end into this one's start; unknown
|
|
101
|
+
* ids, recurring series, and endpoints on hidden rows are skipped.
|
|
102
|
+
* Rendering only - the gantt never reschedules dependents; enforcement
|
|
103
|
+
* stays consumer territory (canDropEvent/onEventUpdate).
|
|
104
|
+
*/
|
|
105
|
+
dependencies?: GanttBarId[];
|
|
83
106
|
data?: TData;
|
|
84
107
|
}
|
|
85
108
|
interface GanttOccurrence<TData = unknown> {
|
|
@@ -109,6 +132,14 @@ interface GanttSegment<TData = unknown> {
|
|
|
109
132
|
columnCount?: number;
|
|
110
133
|
columnSpan?: number;
|
|
111
134
|
}
|
|
135
|
+
/** A validated planned window; `milestone` when start and end coincide. */
|
|
136
|
+
interface GanttBaseline {
|
|
137
|
+
start: Date;
|
|
138
|
+
end: Date;
|
|
139
|
+
milestone: boolean;
|
|
140
|
+
}
|
|
141
|
+
/** Actual end against the planned end: before it, after it, or exactly on it. */
|
|
142
|
+
type GanttBaselineVariance = "early" | "late" | "on-time";
|
|
112
143
|
interface GanttSelection {
|
|
113
144
|
eventKeys: string[];
|
|
114
145
|
slot: {
|
|
@@ -201,5 +232,5 @@ interface GanttDataAdapter<TData = unknown> {
|
|
|
201
232
|
getEvents(range: GanttDateRange, signal?: AbortSignal): Promise<GanttEvent<TData>[]>;
|
|
202
233
|
}
|
|
203
234
|
//#endregion
|
|
204
|
-
export type { GanttBarId, GanttDataAdapter, GanttDateRange, GanttDragState, GanttEvent, GanttInteractions, GanttNode, GanttOccurrence, GanttOffDaysConfig, GanttOverlapPolicy, GanttProposedUpdate, GanttRangeInfo, GanttRecurrenceRule, GanttResource, GanttResourceReorder, GanttRowAlign, GanttScale, GanttScheduleMode, GanttSegment, GanttSelection, GanttSlotDraft, GanttSlotInfo, GanttState, GanttUpdateResult, GanttWeekday };
|
|
235
|
+
export type { GanttBarId, GanttBaseline, GanttBaselineVariance, GanttDataAdapter, GanttDateRange, GanttDragState, GanttEvent, GanttInteractions, GanttNode, GanttOccurrence, GanttOffDaysConfig, GanttOverlapPolicy, GanttProposedUpdate, GanttRangeInfo, GanttRecurrenceRule, GanttResource, GanttResourceReorder, GanttRowAlign, GanttScale, GanttScheduleMode, GanttSegment, GanttSelection, GanttSlotDraft, GanttSlotInfo, GanttState, GanttUpdateResult, GanttWeekday };
|
|
205
236
|
//# sourceMappingURL=gantt-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gantt-types.d.ts","names":[],"sources":["../../../../src/components/reui/gantt/gantt-types.tsx"],"mappings":";KAEK;KAEA;;UAGK;EACR;EACA;;EAEA;EACA,WAAW;;;;;;KAOR;;;;;;KAOA;;KAGA;;UAGK;EACR;EACA;EACA;;EAEA,eAAe;
|
|
1
|
+
{"version":3,"file":"gantt-types.d.ts","names":[],"sources":["../../../../src/components/reui/gantt/gantt-types.tsx"],"mappings":";KAEK;KAEA;;UAGK;EACR;EACA;;EAEA;EACA,WAAW;;;;;;KAOR;;;;;;KAOA;;KAGA;;UAGK;EACR;EACA;EACA;;EAEA,eAAe;;;;;;EAMf,gBAAgB;EAChB,cAAc;EACd,WAAW;;;KAIR,YAAY;;UAG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;;;UAIQ,iBAAiB;EACzB,UAAU,OAAO,gBAAgB,SAAS,cAAc,QAAQ,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gantt-view.d.ts","names":[],"sources":["../../../../src/components/reui/gantt/gantt-view.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"gantt-view.d.ts","names":[],"sources":["../../../../src/components/reui/gantt/gantt-view.tsx"],"mappings":";;UAiWU,uBAAuB,UAAU;;EAEzC;;iBAkBO,YAAY,WAAW,QAAQ,UAAU,iBAAiB,SAAS,iCAAc,+CAAA"}
|