@kumix/ui 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts +2 -2
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +9 -2
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +158 -3
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +1 -0
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.d.ts.map +1 -1
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +12 -4
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts +3 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.js +100 -20
- package/dist/components/reui/event-calendar/event-calendar-dnd.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +5 -4
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts +16 -4
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-i18n.js +10 -9
- package/dist/components/reui/event-calendar/event-calendar-i18n.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-lib.d.ts +13 -6
- package/dist/components/reui/event-calendar/event-calendar-lib.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-lib.js +30 -12
- package/dist/components/reui/event-calendar/event-calendar-lib.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +43 -6
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-recurrence.d.ts +3 -2
- package/dist/components/reui/event-calendar/event-calendar-recurrence.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js +56 -22
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js +13 -4
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +21 -5
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts +5 -0
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.d.ts +2 -2
- package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +106 -10
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/frame.d.ts +7 -8
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js +13 -11
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-i18n.js +2 -1
- package/dist/components/reui/gantt/gantt-i18n.js.map +1 -1
- package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-lib.js +2 -1
- package/dist/components/reui/gantt/gantt-lib.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.d.ts +1 -1
- package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt-recurrence.js +18 -17
- package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +53 -6
- package/dist/components/reui/gantt/gantt-view.js.map +1 -1
- package/dist/components/reui/gantt/gantt.d.ts +8 -0
- package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt.js +2 -0
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-stack.d.ts +2 -3
- package/dist/components/reui/icon-stack.d.ts.map +1 -1
- package/dist/components/reui/icon-stack.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +37 -0
- package/dist/components/reui/icon-tile.d.ts.map +1 -0
- package/dist/components/reui/icon-tile.js +103 -0
- package/dist/components/reui/icon-tile.js.map +1 -0
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +23 -8
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.d.ts +7 -8
- package/dist/components/reui/number-field.d.ts.map +1 -1
- package/dist/components/reui/number-field.js +4 -4
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/scrollspy.d.ts.map +1 -1
- package/dist/components/reui/scrollspy.js.map +1 -1
- package/dist/components/reui/sortable.d.ts.map +1 -1
- package/dist/components/reui/sortable.js +21 -10
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/ui/aspect-ratio.d.ts +2 -3
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
- package/dist/components/ui/aspect-ratio.js.map +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.js +2 -0
- package/dist/components/ui/breadcrumb.js.map +1 -1
- package/dist/components/ui/button-group.d.ts +3 -4
- package/dist/components/ui/button-group.d.ts.map +1 -1
- package/dist/components/ui/button-group.js.map +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel.js +1 -2
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/empty.d.ts +6 -7
- package/dist/components/ui/empty.d.ts.map +1 -1
- package/dist/components/ui/empty.js.map +1 -1
- package/dist/components/ui/field.d.ts +14 -15
- package/dist/components/ui/field.d.ts.map +1 -1
- package/dist/components/ui/field.js.map +1 -1
- package/dist/components/ui/kbd.d.ts +2 -3
- package/dist/components/ui/kbd.d.ts.map +1 -1
- package/dist/components/ui/kbd.js +1 -1
- package/dist/components/ui/kbd.js.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts +8 -9
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +3 -3
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/skeleton.d.ts +1 -2
- package/dist/components/ui/skeleton.d.ts.map +1 -1
- package/dist/components/ui/skeleton.js.map +1 -1
- package/dist/components/ui/spinner.d.ts +1 -2
- package/dist/components/ui/spinner.d.ts.map +1 -1
- package/dist/components/ui/spinner.js.map +1 -1
- package/dist/components/ui/toast.d.ts +19 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +124 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/package.json +4 -4
|
@@ -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 keep full iteration - every\n // period consumes the count, so they stay exact and are bounded by count.\n if (rule.count === undefined) {\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; 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 }\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 if (rule.count !== undefined && produced >= 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 if (rule.count !== undefined && produced >= 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,MAAM,KAAK,CAAC;KAClE,IAAI,CA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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,QA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a;IAIb,iBAAiB;GACnB,CAAC;EACH;EACA,YAAY,MAAM,GAAG,MAAM,EAAE,MAAM,QAAQ,IAAI,EAAE,MAAM,QAAQ,CAAC;CAClE;CAEA,OAAO;AACT"}
|
|
@@ -733,6 +733,7 @@ function GanttView({ className, render, interval: intervalProp, ...props }) {
|
|
|
733
733
|
let unforward = null;
|
|
734
734
|
if (treeViewport.hasAttribute("data-gantt-native-scroll")) {
|
|
735
735
|
const onWheel = (e) => {
|
|
736
|
+
if (e.ctrlKey || e.metaKey) return;
|
|
736
737
|
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
|
|
737
738
|
const dy = e.deltaMode === 1 ? e.deltaY * 16 : e.deltaY;
|
|
738
739
|
timelineViewport.scrollTop += dy;
|
|
@@ -742,6 +743,7 @@ function GanttView({ className, render, interval: intervalProp, ...props }) {
|
|
|
742
743
|
unforward = () => treeViewport.removeEventListener("wheel", onWheel);
|
|
743
744
|
} else {
|
|
744
745
|
const onWheel = (e) => {
|
|
746
|
+
if (e.ctrlKey || e.metaKey) return;
|
|
745
747
|
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
|
|
746
748
|
const max = timelineViewport.scrollHeight - timelineViewport.clientHeight;
|
|
747
749
|
if (max <= 0) return;
|
|
@@ -869,15 +871,19 @@ function GanttView({ className, render, interval: intervalProp, ...props }) {
|
|
|
869
871
|
const markIntent = () => {
|
|
870
872
|
lastUserScrollRef.current = performance.now();
|
|
871
873
|
};
|
|
874
|
+
const markWheelIntent = (e) => {
|
|
875
|
+
if (e.ctrlKey || e.metaKey) return;
|
|
876
|
+
markIntent();
|
|
877
|
+
};
|
|
872
878
|
const onPointerDown = (e) => {
|
|
873
879
|
if (e.target?.closest("[data-slot=scroll-area-scrollbar], [data-slot=gantt-timeline-header], [data-gantt-native-scroll]")) markIntent();
|
|
874
880
|
};
|
|
875
|
-
pane.addEventListener("wheel",
|
|
881
|
+
pane.addEventListener("wheel", markWheelIntent, { passive: true });
|
|
876
882
|
pane.addEventListener("pointerdown", onPointerDown);
|
|
877
883
|
pane.addEventListener("touchstart", markIntent, { passive: true });
|
|
878
884
|
pane.addEventListener("keydown", markIntent);
|
|
879
885
|
return () => {
|
|
880
|
-
pane.removeEventListener("wheel",
|
|
886
|
+
pane.removeEventListener("wheel", markWheelIntent);
|
|
881
887
|
pane.removeEventListener("pointerdown", onPointerDown);
|
|
882
888
|
pane.removeEventListener("touchstart", markIntent);
|
|
883
889
|
pane.removeEventListener("keydown", markIntent);
|
|
@@ -915,6 +921,7 @@ function GanttView({ className, render, interval: intervalProp, ...props }) {
|
|
|
915
921
|
tryExtend(direction);
|
|
916
922
|
};
|
|
917
923
|
const onWheel = (e) => {
|
|
924
|
+
if (e.ctrlKey || e.metaKey) return;
|
|
918
925
|
if (extendLockRef.current || e.deltaX === 0) return;
|
|
919
926
|
if (viewport.scrollWidth <= viewport.clientWidth + 8) return;
|
|
920
927
|
const towardStart = isRtl ? e.deltaX > 0 : e.deltaX < 0;
|
|
@@ -982,10 +989,10 @@ function GanttView({ className, render, interval: intervalProp, ...props }) {
|
|
|
982
989
|
raf = requestAnimationFrame(seat);
|
|
983
990
|
return;
|
|
984
991
|
}
|
|
985
|
-
const { ms, align } = pendingRestoreRef.current;
|
|
992
|
+
const { ms, align, offsetPx } = pendingRestoreRef.current;
|
|
986
993
|
pendingRestoreRef.current = null;
|
|
987
994
|
const fraction = Math.min(Math.max((ms - rangeStartMs) / (rangeEndMs - rangeStartMs), 0), 1);
|
|
988
|
-
const offset = align === "center" ? viewport.clientWidth / 2 : 0;
|
|
995
|
+
const offset = offsetPx ?? (align === "center" ? viewport.clientWidth / 2 : 0);
|
|
989
996
|
setScrollStart(viewport, Math.max(0, fraction * viewport.scrollWidth - offset));
|
|
990
997
|
}
|
|
991
998
|
extendLockRef.current = false;
|
|
@@ -1012,6 +1019,46 @@ function GanttView({ className, render, interval: intervalProp, ...props }) {
|
|
|
1012
1019
|
align: "center"
|
|
1013
1020
|
};
|
|
1014
1021
|
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Keep the instant under the POINTER pinned across a zoom step. The buttons
|
|
1024
|
+
* anchor the viewport center, but a wheel or pinch gesture points at
|
|
1025
|
+
* something - zooming away from it reads as the content sliding out from
|
|
1026
|
+
* under the cursor.
|
|
1027
|
+
*/
|
|
1028
|
+
const anchorZoomPointer = (clientX) => {
|
|
1029
|
+
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
1030
|
+
const axis = viewport?.querySelector("[data-gantt-axis]");
|
|
1031
|
+
if (!viewport || !axis) return;
|
|
1032
|
+
const liveStart = Number(axis.dataset.ganttRangeStart);
|
|
1033
|
+
const liveEnd = Number(axis.dataset.ganttRangeEnd);
|
|
1034
|
+
if (Number.isNaN(liveStart) || Number.isNaN(liveEnd)) return;
|
|
1035
|
+
const offsetPx = trackPoint(viewport, clientX).offset;
|
|
1036
|
+
pendingRestoreRef.current = {
|
|
1037
|
+
ms: liveStart + (getScrollStart(viewport) + offsetPx) / viewport.scrollWidth * (liveEnd - liveStart),
|
|
1038
|
+
align: "start",
|
|
1039
|
+
offsetPx
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
1042
|
+
const wheelZoomRef = useRef(null);
|
|
1043
|
+
useEffect(() => {
|
|
1044
|
+
wheelZoomRef.current = (e) => {
|
|
1045
|
+
if (!viewConfig.wheelZoom) return;
|
|
1046
|
+
if (!e.ctrlKey && !e.metaKey) return;
|
|
1047
|
+
const lines = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 400 : 1;
|
|
1048
|
+
const next = clampZoom(zoom * Math.exp(-e.deltaY * lines * .002));
|
|
1049
|
+
if (Math.abs(next - zoom) < 1e-4) return;
|
|
1050
|
+
e.preventDefault();
|
|
1051
|
+
if (viewConfig.zoom === void 0) anchorZoomPointer(e.clientX);
|
|
1052
|
+
setZoomValue(+next.toFixed(4));
|
|
1053
|
+
};
|
|
1054
|
+
});
|
|
1055
|
+
useEffect(() => {
|
|
1056
|
+
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
1057
|
+
if (!viewport) return;
|
|
1058
|
+
const onWheel = (e) => wheelZoomRef.current?.(e);
|
|
1059
|
+
viewport.addEventListener("wheel", onWheel, { passive: false });
|
|
1060
|
+
return () => viewport.removeEventListener("wheel", onWheel);
|
|
1061
|
+
}, []);
|
|
1015
1062
|
const beginHeaderPan = (e) => {
|
|
1016
1063
|
if (e.button !== 0) return;
|
|
1017
1064
|
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
@@ -2061,7 +2108,7 @@ function sameChips(a, b) {
|
|
|
2061
2108
|
* clicking scrolls the bar back into view. Reads geometry straight from the
|
|
2062
2109
|
* DOM (row data attributes), so scrolling never re-renders the grid.
|
|
2063
2110
|
*/
|
|
2064
|
-
function GanttOffscreenChips({ paneRef, locale
|
|
2111
|
+
function GanttOffscreenChips({ paneRef, locale }) {
|
|
2065
2112
|
const settings = useGanttSettings();
|
|
2066
2113
|
const [chips, setChips] = useState([]);
|
|
2067
2114
|
useEffect(() => {
|
|
@@ -2131,7 +2178,7 @@ function GanttOffscreenChips({ paneRef, locale, refreshKey }) {
|
|
|
2131
2178
|
observer.disconnect();
|
|
2132
2179
|
if (raf) cancelAnimationFrame(raf);
|
|
2133
2180
|
};
|
|
2134
|
-
}, [paneRef
|
|
2181
|
+
}, [paneRef]);
|
|
2135
2182
|
if (chips.length === 0) return null;
|
|
2136
2183
|
const scrollTo = (chip) => {
|
|
2137
2184
|
const viewport = getPaneViewport(paneRef.current);
|