@kumix/ui 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -88
- package/dist/components/reui/alert.d.ts +12 -0
- package/dist/components/reui/alert.d.ts.map +1 -0
- package/dist/components/reui/alert.js +58 -0
- package/dist/components/reui/alert.js.map +1 -0
- package/dist/components/reui/autocomplete.d.ts +43 -0
- package/dist/components/reui/autocomplete.d.ts.map +1 -0
- package/dist/components/reui/autocomplete.js +165 -0
- package/dist/components/reui/autocomplete.js.map +1 -0
- package/dist/components/reui/badge.d.ts +17 -0
- package/dist/components/reui/badge.d.ts.map +1 -0
- package/dist/components/reui/badge.js +75 -0
- package/dist/components/reui/badge.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts +17 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.js +127 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts +18 -0
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-header.js +228 -0
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts +10 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +28 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts +22 -0
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-pagination.js +144 -0
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts +12 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +289 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts +14 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +166 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +10 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +171 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +29 -0
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +269 -0
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table.d.ts +116 -0
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table.js +864 -0
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid.d.ts +112 -0
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid.js +134 -0
- package/dist/components/reui/data-grid/data-grid.js.map +1 -0
- package/dist/components/reui/date-selector.d.ts +131 -0
- package/dist/components/reui/date-selector.d.ts.map +1 -0
- package/dist/components/reui/date-selector.js +783 -0
- package/dist/components/reui/date-selector.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.d.ts +7 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +108 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-content.d.ts +15 -0
- package/dist/components/reui/event-calendar/event-calendar-content.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-content.js +44 -0
- package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts +30 -0
- package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-dnd.js +581 -0
- package/dist/components/reui/event-calendar/event-calendar-dnd.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts +73 -0
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-event.js +299 -0
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts +103 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.js +141 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-lib.d.ts +111 -0
- package/dist/components/reui/event-calendar/event-calendar-lib.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-lib.js +398 -0
- package/dist/components/reui/event-calendar/event-calendar-lib.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts +29 -0
- package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +530 -0
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-nav.d.ts +71 -0
- package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-nav.js +319 -0
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-recurrence.d.ts +32 -0
- package/dist/components/reui/event-calendar/event-calendar-recurrence.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js +300 -0
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts +14 -0
- package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js +355 -0
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts +35 -0
- package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +651 -0
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts +236 -0
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-types.js +2 -0
- package/dist/components/reui/event-calendar/event-calendar.d.ts +561 -0
- package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar.js +817 -0
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -0
- package/dist/components/reui/filters.d.ts +176 -0
- package/dist/components/reui/filters.d.ts.map +1 -0
- package/dist/components/reui/filters.js +1216 -0
- package/dist/components/reui/filters.js.map +1 -0
- package/dist/components/reui/frame.d.ts +32 -0
- package/dist/components/reui/frame.d.ts.map +1 -0
- package/dist/components/reui/frame.js +115 -0
- package/dist/components/reui/frame.js.map +1 -0
- package/dist/components/reui/gantt/gantt-bar.d.ts +44 -0
- package/dist/components/reui/gantt/gantt-bar.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-bar.js +229 -0
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -0
- package/dist/components/reui/gantt/gantt-dnd.d.ts +36 -0
- package/dist/components/reui/gantt/gantt-dnd.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-dnd.js +615 -0
- package/dist/components/reui/gantt/gantt-dnd.js.map +1 -0
- package/dist/components/reui/gantt/gantt-i18n.d.ts +91 -0
- package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-i18n.js +131 -0
- package/dist/components/reui/gantt/gantt-i18n.js.map +1 -0
- package/dist/components/reui/gantt/gantt-lib.d.ts +123 -0
- package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-lib.js +354 -0
- package/dist/components/reui/gantt/gantt-lib.js.map +1 -0
- package/dist/components/reui/gantt/gantt-nav.d.ts +60 -0
- package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-nav.js +266 -0
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -0
- package/dist/components/reui/gantt/gantt-recurrence.d.ts +37 -0
- package/dist/components/reui/gantt/gantt-recurrence.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-recurrence.js +230 -0
- package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -0
- package/dist/components/reui/gantt/gantt-types.d.ts +251 -0
- package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-types.js +2 -0
- package/dist/components/reui/gantt/gantt-view.d.ts +10 -0
- package/dist/components/reui/gantt/gantt-view.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-view.js +2193 -0
- package/dist/components/reui/gantt/gantt-view.js.map +1 -0
- package/dist/components/reui/gantt/gantt.d.ts +602 -0
- package/dist/components/reui/gantt/gantt.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt.js +796 -0
- package/dist/components/reui/gantt/gantt.js.map +1 -0
- package/dist/components/reui/icon-stack.d.ts +7 -0
- package/dist/components/reui/icon-stack.d.ts.map +1 -0
- package/dist/components/reui/icon-stack.js +76 -0
- package/dist/components/reui/icon-stack.js.map +1 -0
- package/dist/components/reui/kanban.d.ts +70 -0
- package/dist/components/reui/kanban.d.ts.map +1 -0
- package/dist/components/reui/kanban.js +519 -0
- package/dist/components/reui/kanban.js.map +1 -0
- package/dist/components/reui/number-field.d.ts +29 -0
- package/dist/components/reui/number-field.d.ts.map +1 -0
- package/dist/components/reui/number-field.js +127 -0
- package/dist/components/reui/number-field.js.map +1 -0
- package/dist/components/reui/phone-input.d.ts +13 -0
- package/dist/components/reui/phone-input.d.ts.map +1 -0
- package/dist/components/reui/phone-input.js +126 -0
- package/dist/components/reui/phone-input.js.map +1 -0
- package/dist/components/reui/rating.d.ts +34 -0
- package/dist/components/reui/rating.d.ts.map +1 -0
- package/dist/components/reui/rating.js +94 -0
- package/dist/components/reui/rating.js.map +1 -0
- package/dist/components/reui/scrollspy.d.ts +17 -0
- package/dist/components/reui/scrollspy.d.ts.map +1 -0
- package/dist/components/reui/scrollspy.js +130 -0
- package/dist/components/reui/scrollspy.js.map +1 -0
- package/dist/components/reui/sortable.d.ts +48 -0
- package/dist/components/reui/sortable.d.ts.map +1 -0
- package/dist/components/reui/sortable.js +230 -0
- package/dist/components/reui/sortable.js.map +1 -0
- package/dist/components/reui/stepper.d.ts +63 -0
- package/dist/components/reui/stepper.d.ts.map +1 -0
- package/dist/components/reui/stepper.js +234 -0
- package/dist/components/reui/stepper.js.map +1 -0
- package/dist/components/reui/timeline.d.ts +24 -0
- package/dist/components/reui/timeline.d.ts.map +1 -0
- package/dist/components/reui/timeline.js +123 -0
- package/dist/components/reui/timeline.js.map +1 -0
- package/dist/components/reui/tree.d.ts +23 -0
- package/dist/components/reui/tree.d.ts.map +1 -0
- package/dist/components/reui/tree.js +115 -0
- package/dist/components/reui/tree.js.map +1 -0
- package/dist/components/ui/accordion.d.ts +9 -0
- package/dist/components/ui/accordion.d.ts.map +1 -0
- package/dist/components/ui/accordion.js +56 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +21 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +96 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/alert.d.ts +13 -0
- package/dist/components/ui/alert.d.ts.map +1 -0
- package/dist/components/ui/alert.js +45 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/aspect-ratio.d.ts +8 -0
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -0
- package/dist/components/ui/aspect-ratio.js +16 -0
- package/dist/components/ui/aspect-ratio.js.map +1 -0
- package/dist/components/ui/attachment.d.ts +26 -0
- package/dist/components/ui/attachment.d.ts.map +1 -0
- package/dist/components/ui/attachment.js +106 -0
- package/dist/components/ui/attachment.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +14 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +52 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +32 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +13 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +72 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/bubble.d.ts +19 -0
- package/dist/components/ui/bubble.d.ts.map +1 -0
- package/dist/components/ui/bubble.js +75 -0
- package/dist/components/ui/bubble.js.map +1 -0
- package/dist/components/ui/button-group.d.ts +14 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button-group.js +44 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +47 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.d.ts +13 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +110 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/card.d.ts +14 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +58 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/carousel.d.ts +31 -0
- package/dist/components/ui/carousel.d.ts.map +1 -0
- package/dist/components/ui/carousel.js +135 -0
- package/dist/components/ui/carousel.js.map +1 -0
- package/dist/components/ui/chart.d.ts +47 -0
- package/dist/components/ui/chart.d.ts.map +1 -0
- package/dist/components/ui/chart.js +151 -0
- package/dist/components/ui/chart.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +6 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +22 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +8 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +26 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/combobox.d.ts +27 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +164 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/command.d.ts +22 -0
- package/dist/components/ui/command.d.ts.map +1 -0
- package/dist/components/ui/command.js +89 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/context-menu.d.ts +32 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +134 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +20 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +93 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/direction.d.ts +2 -0
- package/dist/components/ui/direction.js +3 -0
- package/dist/components/ui/drawer.d.ts +19 -0
- package/dist/components/ui/drawer.d.ts.map +1 -0
- package/dist/components/ui/drawer.js +125 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +32 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +138 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/empty.d.ts +15 -0
- package/dist/components/ui/empty.d.ts.map +1 -0
- package/dist/components/ui/empty.js +62 -0
- package/dist/components/ui/empty.js.map +1 -0
- package/dist/components/ui/field.d.ts +28 -0
- package/dist/components/ui/field.d.ts.map +1 -0
- package/dist/components/ui/field.js +112 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/hover-card.d.ts +8 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +38 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/input-group.d.ts +21 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input-group.js +80 -0
- package/dist/components/ui/input-group.js.map +1 -0
- package/dist/components/ui/input-otp.d.ts +14 -0
- package/dist/components/ui/input-otp.d.ts.map +1 -0
- package/dist/components/ui/input-otp.js +49 -0
- package/dist/components/ui/input-otp.js.map +1 -0
- package/dist/components/ui/input.d.ts +6 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +17 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/item.d.ts +25 -0
- package/dist/components/ui/item.d.ts.map +1 -0
- package/dist/components/ui/item.js +123 -0
- package/dist/components/ui/item.js.map +1 -0
- package/dist/components/ui/kbd.d.ts +7 -0
- package/dist/components/ui/kbd.d.ts.map +1 -0
- package/dist/components/ui/kbd.js +22 -0
- package/dist/components/ui/kbd.js.map +1 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +15 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/marker.d.ts +13 -0
- package/dist/components/ui/marker.d.ts.map +1 -0
- package/dist/components/ui/marker.js +45 -0
- package/dist/components/ui/marker.js.map +1 -0
- package/dist/components/ui/menubar.d.ts +32 -0
- package/dist/components/ui/menubar.d.ts.map +1 -0
- package/dist/components/ui/menubar.js +137 -0
- package/dist/components/ui/menubar.js.map +1 -0
- package/dist/components/ui/message-scroller.d.ts +13 -0
- package/dist/components/ui/message-scroller.d.ts.map +1 -0
- package/dist/components/ui/message-scroller.js +62 -0
- package/dist/components/ui/message-scroller.js.map +1 -0
- package/dist/components/ui/message.d.ts +13 -0
- package/dist/components/ui/message.d.ts.map +1 -0
- package/dist/components/ui/message.js +51 -0
- package/dist/components/ui/message.js.map +1 -0
- package/dist/components/ui/native-select.d.ts +11 -0
- package/dist/components/ui/native-select.d.ts.map +1 -0
- package/dist/components/ui/native-select.js +40 -0
- package/dist/components/ui/native-select.js.map +1 -0
- package/dist/components/ui/navigation-menu.d.ts +15 -0
- package/dist/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/components/ui/navigation-menu.js +85 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +20 -0
- package/dist/components/ui/pagination.d.ts.map +1 -0
- package/dist/components/ui/pagination.js +81 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/popover.d.ts +12 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +56 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +10 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +46 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +8 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +29 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/resizable.d.ts +10 -0
- package/dist/components/ui/resizable.d.ts.map +1 -0
- package/dist/components/ui/resizable.js +30 -0
- package/dist/components/ui/resizable.js.map +1 -0
- package/dist/components/ui/scroll-area.d.ts +7 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +38 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/select.d.ts +18 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +99 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/separator.d.ts +6 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +17 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +17 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +90 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +66 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +383 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +6 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +15 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/slider.d.ts +6 -0
- package/dist/components/ui/slider.d.ts.map +1 -0
- package/dist/components/ui/slider.js +36 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/sonner.d.ts +7 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +32 -0
- package/dist/components/ui/sonner.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +6 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +18 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/switch.d.ts +8 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +21 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +13 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +68 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +13 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +47 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +6 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +15 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/toggle-group.d.ts +14 -0
- package/dist/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/components/ui/toggle-group.js +54 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +11 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +38 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +9 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +43 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/hooks/use-body-classes.d.ts +27 -0
- package/dist/hooks/use-body-classes.d.ts.map +1 -0
- package/dist/hooks/use-body-classes.js +52 -0
- package/dist/hooks/use-body-classes.js.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +43 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.js +69 -0
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/hooks/use-file-upload.d.ts +49 -0
- package/dist/hooks/use-file-upload.d.ts.map +1 -0
- package/dist/hooks/use-file-upload.js +227 -0
- package/dist/hooks/use-file-upload.js.map +1 -0
- package/dist/hooks/use-hydrated.d.ts +37 -0
- package/dist/hooks/use-hydrated.d.ts.map +1 -0
- package/dist/hooks/use-hydrated.js +50 -0
- package/dist/hooks/use-hydrated.js.map +1 -0
- package/dist/hooks/use-intersection-observer.d.ts +55 -0
- package/dist/hooks/use-intersection-observer.d.ts.map +1 -0
- package/dist/hooks/use-intersection-observer.js +144 -0
- package/dist/hooks/use-intersection-observer.js.map +1 -0
- package/dist/hooks/use-is-mac.d.ts +28 -0
- package/dist/hooks/use-is-mac.d.ts.map +1 -0
- package/dist/hooks/use-is-mac.js +38 -0
- package/dist/hooks/use-is-mac.js.map +1 -0
- package/dist/hooks/use-media-query.d.ts +44 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +58 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-meta-color.d.ts +78 -0
- package/dist/hooks/use-meta-color.d.ts.map +1 -0
- package/dist/hooks/use-meta-color.js +138 -0
- package/dist/hooks/use-meta-color.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +5 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +21 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-mutation-observer.d.ts +61 -0
- package/dist/hooks/use-mutation-observer.d.ts.map +1 -0
- package/dist/hooks/use-mutation-observer.js +96 -0
- package/dist/hooks/use-mutation-observer.js.map +1 -0
- package/dist/hooks/use-scroll-position.d.ts +76 -0
- package/dist/hooks/use-scroll-position.d.ts.map +1 -0
- package/dist/hooks/use-scroll-position.js +97 -0
- package/dist/hooks/use-scroll-position.js.map +1 -0
- package/dist/hooks/use-slider-input.d.ts +94 -0
- package/dist/hooks/use-slider-input.d.ts.map +1 -0
- package/dist/hooks/use-slider-input.js +116 -0
- package/dist/hooks/use-slider-input.js.map +1 -0
- package/dist/hooks/use-viewport.d.ts +72 -0
- package/dist/hooks/use-viewport.d.ts.map +1 -0
- package/dist/hooks/use-viewport.js +91 -0
- package/dist/hooks/use-viewport.js.map +1 -0
- package/dist/theme.css +244 -0
- package/dist/theme.css.d.ts +3 -0
- package/package.json +105 -36
- package/dist/hooks.d.ts +0 -957
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js +0 -1391
- package/dist/hooks.js.map +0 -1
- package/dist/index.d.ts +0 -1993
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10647
- package/dist/index.js.map +0 -1
- package/dist/use-is-mobile-Dln4-L1O.js +0 -210
- package/dist/use-is-mobile-Dln4-L1O.js.map +0 -1
|
@@ -0,0 +1,2193 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ScrollArea as ScrollArea$1, ScrollBar } from "../../ui/scroll-area.js";
|
|
3
|
+
import { Button } from "../../ui/button.js";
|
|
4
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../ui/tooltip.js";
|
|
5
|
+
import { Checkbox } from "../../ui/checkbox.js";
|
|
6
|
+
import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from "../../ui/context-menu.js";
|
|
7
|
+
import { getDayKey, getLaneKey, getRangeKey, packTimedSegments, reorderResources, resolveOffDay, toZoned, zonedStartOfDay } from "./gantt-lib.js";
|
|
8
|
+
import { resolveScheduleMode, resolveTimelineLines, useGantt, useGanttSelector, useGanttSettings, useGanttViewConfig } from "./gantt.js";
|
|
9
|
+
import { cancelActiveGanttGestures, markGestureEnd, useGanttGestureTeardown, useGanttGestures, wasRecentDrag } from "./gantt-dnd.js";
|
|
10
|
+
import { GanttBar } from "./gantt-bar.js";
|
|
11
|
+
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
12
|
+
import { cn } from "@kumix/utils";
|
|
13
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { ChevronLeftIcon, ChevronRightIcon, GripVerticalIcon, MinusIcon, PlusIcon } from "lucide-react";
|
|
15
|
+
import { ScrollArea } from "@base-ui/react/scroll-area";
|
|
16
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
17
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
18
|
+
import { addDays, addMinutes, addMonths, format, getWeek, startOfMonth, startOfQuarter, startOfWeek } from "date-fns";
|
|
19
|
+
//#region src/components/reui/gantt/gantt-view.tsx
|
|
20
|
+
/** Current time, refreshed on an interval and on tab focus. */
|
|
21
|
+
function useNow(intervalMs = 3e4) {
|
|
22
|
+
const [now, setNow] = useState(() => /* @__PURE__ */ new Date());
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const tick = () => setNow(/* @__PURE__ */ new Date());
|
|
25
|
+
const id = setInterval(tick, intervalMs);
|
|
26
|
+
document.addEventListener("visibilitychange", tick);
|
|
27
|
+
window.addEventListener("focus", tick);
|
|
28
|
+
return () => {
|
|
29
|
+
clearInterval(id);
|
|
30
|
+
document.removeEventListener("visibilitychange", tick);
|
|
31
|
+
window.removeEventListener("focus", tick);
|
|
32
|
+
};
|
|
33
|
+
}, [intervalMs]);
|
|
34
|
+
return now;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Today's zoned day key, re-rendering only at the midnight rollover (and on
|
|
38
|
+
* focus/visibility) - the grid needs day granularity, not the 30s now tick.
|
|
39
|
+
*/
|
|
40
|
+
function useTodayKey(timeZone) {
|
|
41
|
+
const [key, setKey] = useState(() => getDayKey(/* @__PURE__ */ new Date(), timeZone));
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const tick = () => setKey((prev) => {
|
|
44
|
+
const next = getDayKey(/* @__PURE__ */ new Date(), timeZone);
|
|
45
|
+
return next === prev ? prev : next;
|
|
46
|
+
});
|
|
47
|
+
tick();
|
|
48
|
+
const id = setInterval(tick, 6e4);
|
|
49
|
+
document.addEventListener("visibilitychange", tick);
|
|
50
|
+
window.addEventListener("focus", tick);
|
|
51
|
+
return () => {
|
|
52
|
+
clearInterval(id);
|
|
53
|
+
document.removeEventListener("visibilitychange", tick);
|
|
54
|
+
window.removeEventListener("focus", tick);
|
|
55
|
+
};
|
|
56
|
+
}, [timeZone]);
|
|
57
|
+
return key;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Lowest lane free for [startMs, endMs) among a row's segments, padded by
|
|
61
|
+
* MIN_PACK_SLOT exactly as packTimedSegments pads its own occupancy test.
|
|
62
|
+
* Comparing raw instants instead lets a sub-slot bar read as clear, so an
|
|
63
|
+
* affordance would promise a lane the packer then refuses.
|
|
64
|
+
*
|
|
65
|
+
* Shared by the hover hint and the drag placeholder on purpose: two copies of
|
|
66
|
+
* this is how the ring and the range it paints end up on different tracks.
|
|
67
|
+
*/
|
|
68
|
+
function lowestFreeLane(segments, startMs, endMs) {
|
|
69
|
+
const padMs = 30 * 6e4;
|
|
70
|
+
const to = Math.max(endMs, startMs + padMs);
|
|
71
|
+
const busy = /* @__PURE__ */ new Set();
|
|
72
|
+
for (const segment of segments) {
|
|
73
|
+
const segStart = segment.occurrence.start.getTime();
|
|
74
|
+
const segEnd = Math.max(segment.occurrence.end.getTime(), segStart + padMs);
|
|
75
|
+
if (segStart < to && segEnd > startMs) busy.add(segment.column ?? 0);
|
|
76
|
+
}
|
|
77
|
+
let lane = 0;
|
|
78
|
+
while (busy.has(lane)) lane += 1;
|
|
79
|
+
return lane;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Pointer x resolved against the element's TIME axis: the 0..1 fraction and
|
|
83
|
+
* the same measurement in CSS pixels from the axis start. Mirrored in RTL,
|
|
84
|
+
* where the range start renders at the element's right edge. One rect read
|
|
85
|
+
* and one style read, because this runs on every pointer move.
|
|
86
|
+
*/
|
|
87
|
+
function trackPoint(el, clientX) {
|
|
88
|
+
const rect = el.getBoundingClientRect();
|
|
89
|
+
const rtl = getComputedStyle(el).direction === "rtl";
|
|
90
|
+
const offset = rtl ? rect.right - clientX : clientX - rect.left;
|
|
91
|
+
const snapped = rtl ? rect.right - Math.round(clientX) : Math.round(clientX) - rect.left;
|
|
92
|
+
return {
|
|
93
|
+
fraction: rect.width > 0 ? offset / rect.width : 0,
|
|
94
|
+
offset: snapped
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Fraction only, for the call sites that do not place anything. */
|
|
98
|
+
function trackFraction(el, clientX) {
|
|
99
|
+
return trackPoint(el, clientX).fraction;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Row geometry is three numbers: a bar is LANE_HEIGHT_REM tall, stacked bars
|
|
103
|
+
* are separated by LANE_GAP_REM, and the block as a whole is inset from the
|
|
104
|
+
* row's edges by ROW_PADDING_REM. Padding and gap are deliberately NOT the
|
|
105
|
+
* same value - schedules in one node belong together, so they sit tight, while
|
|
106
|
+
* the row still needs real breathing room above and below. Every inter-lane
|
|
107
|
+
* gap is identical, which is what keeps a stacked row reading evenly.
|
|
108
|
+
*/
|
|
109
|
+
const LANE_HEIGHT_REM = 1.25;
|
|
110
|
+
const LANE_GAP_REM = .1875;
|
|
111
|
+
const ROW_PADDING_REM = .5;
|
|
112
|
+
/** Drop-indicator height (h-5); it is centered inside its lane band. */
|
|
113
|
+
const GHOST_HEIGHT_REM = 1.25;
|
|
114
|
+
/** Bars narrower than this flip their title outside in barLabel "auto". */
|
|
115
|
+
const AUTO_LABEL_MIN_REM = 7;
|
|
116
|
+
const DEFAULT_TREE_PANEL = {
|
|
117
|
+
width: 288,
|
|
118
|
+
minWidth: 180,
|
|
119
|
+
maxWidth: 640,
|
|
120
|
+
resizable: true,
|
|
121
|
+
nameColumnWidth: 208
|
|
122
|
+
};
|
|
123
|
+
const DEFAULT_COLUMN_WIDTH = 96;
|
|
124
|
+
const DEFAULT_ZOOM_RANGE = {
|
|
125
|
+
min: .5,
|
|
126
|
+
max: 3
|
|
127
|
+
};
|
|
128
|
+
/** Timeline pane never shrinks below this so it stays usable on narrow screens. */
|
|
129
|
+
const MIN_TIMELINE_WIDTH = 200;
|
|
130
|
+
/** Scroll distance from an edge that triggers infinite-range growth. */
|
|
131
|
+
const INFINITE_EDGE_PX = 160;
|
|
132
|
+
/** The pane's scrollable viewport (custom ScrollArea or native host). */
|
|
133
|
+
function getPaneViewport(pane) {
|
|
134
|
+
return pane?.querySelector("[data-slot=scroll-area-viewport]") ?? null;
|
|
135
|
+
}
|
|
136
|
+
/** Distance scrolled from the inline-start edge (RTL reports negative). */
|
|
137
|
+
function getScrollStart(viewport) {
|
|
138
|
+
return Math.abs(viewport.scrollLeft);
|
|
139
|
+
}
|
|
140
|
+
/** Write a distance-from-inline-start back as a signed scrollLeft. */
|
|
141
|
+
function setScrollStart(viewport, value) {
|
|
142
|
+
viewport.scrollLeft = getComputedStyle(viewport).direction === "rtl" ? -value : value;
|
|
143
|
+
}
|
|
144
|
+
function GanttView({ className, render, interval: intervalProp, ...props }) {
|
|
145
|
+
const instance = useGantt();
|
|
146
|
+
const settings = useGanttSettings();
|
|
147
|
+
const viewConfig = useGanttViewConfig();
|
|
148
|
+
const range = useGanttSelector((state) => state.visibleRange, { isEqual: (a, b) => getRangeKey(a) === getRangeKey(b) });
|
|
149
|
+
const occurrences = useGanttSelector(() => instance.api.getOccurrences(), {
|
|
150
|
+
calendar: instance,
|
|
151
|
+
isEqual: (a, b) => a.length === b.length && a.every((occ, i) => occ.key === b[i]?.key && occ.start.getTime() === b[i]?.start.getTime() && occ.end.getTime() === b[i]?.end.getTime() && occ.event === b[i]?.event)
|
|
152
|
+
});
|
|
153
|
+
const [internalCollapsed, setInternalCollapsed] = useState(() => viewConfig.defaultCollapsedGroups ?? []);
|
|
154
|
+
const collapsedIds = viewConfig.collapsedGroups ?? internalCollapsed;
|
|
155
|
+
const collapsedGroups = useMemo(() => new Set(collapsedIds), [collapsedIds]);
|
|
156
|
+
const scale = useGanttSelector((state) => state.scale);
|
|
157
|
+
const interval = Math.min(Math.max(intervalProp ?? viewConfig.interval, 15), 240);
|
|
158
|
+
const metrics = viewConfig.metrics;
|
|
159
|
+
const laneHeightRem = metrics?.laneHeight ?? LANE_HEIGHT_REM;
|
|
160
|
+
const rowPaddingRem = metrics?.rowPadding ?? ROW_PADDING_REM;
|
|
161
|
+
const laneGapRem = metrics?.laneGap ?? LANE_GAP_REM;
|
|
162
|
+
const minRowRem = metrics?.minRowHeight ?? 2.5;
|
|
163
|
+
const minTimelineWidth = metrics?.minTimelineWidth ?? MIN_TIMELINE_WIDTH;
|
|
164
|
+
const infiniteEdgePx = metrics?.infiniteScrollEdge ?? INFINITE_EDGE_PX;
|
|
165
|
+
const timeZone = settings.timeZone;
|
|
166
|
+
const rangeStartMs = range.start.getTime();
|
|
167
|
+
const rangeEndMs = range.end.getTime();
|
|
168
|
+
const rangeKey = getRangeKey(range);
|
|
169
|
+
const snapMin = scale === "day" ? settings.snapDuration : 1440;
|
|
170
|
+
const todayDayKey = useTodayKey(timeZone);
|
|
171
|
+
const rows = useMemo(() => {
|
|
172
|
+
const result = [];
|
|
173
|
+
const walk = (resources, depth, parentId) => {
|
|
174
|
+
for (const resource of resources) {
|
|
175
|
+
const isGroup = !!resource.children?.length;
|
|
176
|
+
const collapsed = collapsedGroups.has(resource.id);
|
|
177
|
+
result.push({
|
|
178
|
+
resource,
|
|
179
|
+
parentId,
|
|
180
|
+
depth,
|
|
181
|
+
isGroup,
|
|
182
|
+
collapsed
|
|
183
|
+
});
|
|
184
|
+
if (isGroup && !collapsed) walk(resource.children, depth + 1, resource.id);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
walk(settings.resources, 0, null);
|
|
188
|
+
return result;
|
|
189
|
+
}, [settings.resources, collapsedGroups]);
|
|
190
|
+
const { units, groups, unitWidthRem } = useMemo(() => {
|
|
191
|
+
const units = [];
|
|
192
|
+
const groups = [];
|
|
193
|
+
const todayStartMs = zonedStartOfDay(/* @__PURE__ */ new Date(), timeZone).getTime();
|
|
194
|
+
if (scale === "day") {
|
|
195
|
+
const labelFormat = interval % 60 === 0 ? settings.i18n.formats.timeGutter : "h:mm";
|
|
196
|
+
let dayCursor = zonedStartOfDay(range.start, timeZone);
|
|
197
|
+
while (dayCursor.getTime() < rangeEndMs) {
|
|
198
|
+
const zonedDay = toZoned(dayCursor, timeZone);
|
|
199
|
+
const nextDay = zonedStartOfDay(addDays(zonedDay, 1), timeZone);
|
|
200
|
+
const dayMinutes = (nextDay.getTime() - dayCursor.getTime()) / 6e4;
|
|
201
|
+
const dayOff = resolveOffDay(dayCursor, timeZone, viewConfig.offDays ?? true);
|
|
202
|
+
let span = 0;
|
|
203
|
+
for (let m = 0; m < dayMinutes; m += interval) {
|
|
204
|
+
const time = addMinutes(zonedDay, m);
|
|
205
|
+
const weight = Math.min(interval, dayMinutes - m) / interval;
|
|
206
|
+
units.push({
|
|
207
|
+
key: `${getDayKey(dayCursor, timeZone)}-m${m}`,
|
|
208
|
+
label: format(time, labelFormat, { locale: settings.locale }),
|
|
209
|
+
ms: time.getTime(),
|
|
210
|
+
weight,
|
|
211
|
+
isOff: dayOff
|
|
212
|
+
});
|
|
213
|
+
span += weight;
|
|
214
|
+
}
|
|
215
|
+
groups.push({
|
|
216
|
+
key: getDayKey(dayCursor, timeZone),
|
|
217
|
+
label: format(zonedDay, settings.i18n.formats.dayTitle, { locale: settings.locale }),
|
|
218
|
+
span
|
|
219
|
+
});
|
|
220
|
+
dayCursor = nextDay;
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
units,
|
|
224
|
+
groups,
|
|
225
|
+
unitWidthRem: metrics?.unitWidths?.day ?? Math.max(2.5, 5 * (interval / 60))
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (scale === "quarter") {
|
|
229
|
+
let cursor = zonedStartOfDay(range.start, timeZone);
|
|
230
|
+
while (cursor.getTime() < rangeEndMs) {
|
|
231
|
+
const zoned = toZoned(cursor, timeZone);
|
|
232
|
+
const next = zonedStartOfDay(addDays(zoned, 7), timeZone);
|
|
233
|
+
const weight = (next.getTime() - cursor.getTime()) / (10080 * 6e4);
|
|
234
|
+
units.push({
|
|
235
|
+
key: getDayKey(cursor, timeZone),
|
|
236
|
+
label: format(zoned, "MMM d", { locale: settings.locale }),
|
|
237
|
+
ms: cursor.getTime(),
|
|
238
|
+
weight,
|
|
239
|
+
isToday: todayStartMs >= cursor.getTime() && todayStartMs < next.getTime()
|
|
240
|
+
});
|
|
241
|
+
const monthKey = format(zoned, "yyyy-MM");
|
|
242
|
+
const lastGroup = groups[groups.length - 1];
|
|
243
|
+
if (lastGroup && lastGroup.key === monthKey) lastGroup.span += weight;
|
|
244
|
+
else groups.push({
|
|
245
|
+
key: monthKey,
|
|
246
|
+
label: format(zoned, "MMMM", { locale: settings.locale }),
|
|
247
|
+
span: weight
|
|
248
|
+
});
|
|
249
|
+
cursor = next;
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
units,
|
|
253
|
+
groups,
|
|
254
|
+
unitWidthRem: metrics?.unitWidths?.quarter ?? 8
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
if (scale === "year") {
|
|
258
|
+
let cursor = startOfMonth(toZoned(range.start, timeZone));
|
|
259
|
+
while (cursor.getTime() < rangeEndMs) {
|
|
260
|
+
const next = startOfMonth(addMonths(cursor, 1));
|
|
261
|
+
const weight = (next.getTime() - cursor.getTime()) / (1440 * 6e4);
|
|
262
|
+
units.push({
|
|
263
|
+
key: format(cursor, "yyyy-MM"),
|
|
264
|
+
label: format(cursor, "MMM", { locale: settings.locale }),
|
|
265
|
+
ms: cursor.getTime(),
|
|
266
|
+
weight,
|
|
267
|
+
isToday: todayStartMs >= cursor.getTime() && todayStartMs < next.getTime()
|
|
268
|
+
});
|
|
269
|
+
const quarterStart = startOfQuarter(cursor);
|
|
270
|
+
const quarterKey = format(quarterStart, "yyyy-QQQ");
|
|
271
|
+
const lastGroup = groups[groups.length - 1];
|
|
272
|
+
if (lastGroup && lastGroup.key === quarterKey) lastGroup.span += weight;
|
|
273
|
+
else groups.push({
|
|
274
|
+
key: quarterKey,
|
|
275
|
+
label: format(quarterStart, "QQQ yyyy", { locale: settings.locale }),
|
|
276
|
+
span: weight
|
|
277
|
+
});
|
|
278
|
+
cursor = next;
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
units,
|
|
282
|
+
groups,
|
|
283
|
+
unitWidthRem: metrics?.unitWidths?.year ?? 10
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
let cursor = zonedStartOfDay(range.start, timeZone);
|
|
287
|
+
while (cursor.getTime() < rangeEndMs) {
|
|
288
|
+
const zoned = toZoned(cursor, timeZone);
|
|
289
|
+
const nextDay = zonedStartOfDay(addDays(zoned, 1), timeZone);
|
|
290
|
+
const weight = (nextDay.getTime() - cursor.getTime()) / (1440 * 6e4);
|
|
291
|
+
units.push({
|
|
292
|
+
key: getDayKey(cursor, timeZone),
|
|
293
|
+
label: format(zoned, "EEE d", { locale: settings.locale }),
|
|
294
|
+
ms: cursor.getTime(),
|
|
295
|
+
weight,
|
|
296
|
+
isToday: getDayKey(cursor, timeZone) === todayDayKey,
|
|
297
|
+
isOff: resolveOffDay(cursor, timeZone, viewConfig.offDays ?? true)
|
|
298
|
+
});
|
|
299
|
+
const weekNumber = getWeek(zoned, {
|
|
300
|
+
locale: settings.locale,
|
|
301
|
+
weekStartsOn: settings.weekStartsOn
|
|
302
|
+
});
|
|
303
|
+
const weekStart = startOfWeek(zoned, { weekStartsOn: settings.weekStartsOn });
|
|
304
|
+
const weekKey = `w-${format(weekStart, "yyyy-MM-dd")}`;
|
|
305
|
+
const lastGroup = groups[groups.length - 1];
|
|
306
|
+
if (lastGroup && lastGroup.key === weekKey) lastGroup.span += weight;
|
|
307
|
+
else groups.push({
|
|
308
|
+
key: weekKey,
|
|
309
|
+
label: `${settings.i18n.labels.week(weekNumber)} ${format(weekStart, "MMM d", { locale: settings.locale })} - ${format(addDays(weekStart, 6), "d", { locale: settings.locale })}`,
|
|
310
|
+
span: weight
|
|
311
|
+
});
|
|
312
|
+
cursor = nextDay;
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
units,
|
|
316
|
+
groups,
|
|
317
|
+
unitWidthRem: metrics?.unitWidths?.[scale] ?? (scale === "week" ? 10 : 4)
|
|
318
|
+
};
|
|
319
|
+
}, [
|
|
320
|
+
scale,
|
|
321
|
+
interval,
|
|
322
|
+
range.start,
|
|
323
|
+
rangeEndMs,
|
|
324
|
+
timeZone,
|
|
325
|
+
settings.i18n,
|
|
326
|
+
settings.locale,
|
|
327
|
+
settings.weekStartsOn,
|
|
328
|
+
viewConfig.offDays,
|
|
329
|
+
todayDayKey,
|
|
330
|
+
metrics
|
|
331
|
+
]);
|
|
332
|
+
const zoomRange = {
|
|
333
|
+
...DEFAULT_ZOOM_RANGE,
|
|
334
|
+
...viewConfig.zoomRange
|
|
335
|
+
};
|
|
336
|
+
const clampZoom = (value) => Math.min(Math.max(value, zoomRange.min), zoomRange.max);
|
|
337
|
+
const [internalZoom, setInternalZoom] = useState(() => viewConfig.defaultZoom ?? 1);
|
|
338
|
+
const zoom = clampZoom(viewConfig.zoom ?? internalZoom);
|
|
339
|
+
const setZoomValue = (next) => {
|
|
340
|
+
const clamped = clampZoom(next);
|
|
341
|
+
if (viewConfig.zoom === void 0) setInternalZoom(clamped);
|
|
342
|
+
viewConfig.onZoomChange?.(clamped);
|
|
343
|
+
};
|
|
344
|
+
const canZoomIn = zoom < zoomRange.max - 1e-9;
|
|
345
|
+
const canZoomOut = zoom > zoomRange.min + 1e-9;
|
|
346
|
+
const trackRemWidth = units.length * unitWidthRem * zoom;
|
|
347
|
+
const trackWidth = `${trackRemWidth}rem`;
|
|
348
|
+
const uniform = units.every((unit) => Math.abs(unit.weight - units[0].weight) < 1e-9);
|
|
349
|
+
const totalWeight = units.reduce((sum, unit) => sum + unit.weight, 0);
|
|
350
|
+
/** Cumulative start/width fractions per unit, for backdrop stripes/lines. */
|
|
351
|
+
const unitFractions = useMemo(() => {
|
|
352
|
+
let acc = 0;
|
|
353
|
+
return units.map((unit) => {
|
|
354
|
+
const start = acc / totalWeight;
|
|
355
|
+
acc += unit.weight;
|
|
356
|
+
return {
|
|
357
|
+
unit,
|
|
358
|
+
start,
|
|
359
|
+
width: unit.weight / totalWeight
|
|
360
|
+
};
|
|
361
|
+
});
|
|
362
|
+
}, [units, totalWeight]);
|
|
363
|
+
/** Snap a track fraction to its unit (hint preview target). */
|
|
364
|
+
const resolveHintStop = useMemo(() => {
|
|
365
|
+
return (fraction) => {
|
|
366
|
+
for (let i = 0; i < unitFractions.length; i++) {
|
|
367
|
+
const { unit, start, width } = unitFractions[i];
|
|
368
|
+
if (fraction < start + width || i === unitFractions.length - 1) return {
|
|
369
|
+
index: i,
|
|
370
|
+
center: start + width / 2,
|
|
371
|
+
ms: unit.ms,
|
|
372
|
+
endMs: unitFractions[i + 1]?.unit.ms ?? unit.ms
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
};
|
|
377
|
+
}, [unitFractions]);
|
|
378
|
+
/** Group boundary fractions; spans are in unit-weight terms everywhere. */
|
|
379
|
+
const groupBoundaries = useMemo(() => {
|
|
380
|
+
const fractions = [];
|
|
381
|
+
let acc = 0;
|
|
382
|
+
for (let i = 0; i < groups.length - 1; i++) {
|
|
383
|
+
acc += groups[i].span;
|
|
384
|
+
fractions.push(acc / totalWeight);
|
|
385
|
+
}
|
|
386
|
+
return fractions;
|
|
387
|
+
}, [groups, totalWeight]);
|
|
388
|
+
/** Resource id -> every descendant id, for parent rollups. */
|
|
389
|
+
const descendantIds = useMemo(() => {
|
|
390
|
+
const map = /* @__PURE__ */ new Map();
|
|
391
|
+
const walk = (resource) => {
|
|
392
|
+
const ids = (resource.children ?? []).flatMap((child) => [child.id, ...walk(child)]);
|
|
393
|
+
map.set(resource.id, ids);
|
|
394
|
+
return ids;
|
|
395
|
+
};
|
|
396
|
+
settings.resources.forEach(walk);
|
|
397
|
+
return map;
|
|
398
|
+
}, [settings.resources]);
|
|
399
|
+
const allEvents = useGanttSelector((state) => state.events);
|
|
400
|
+
const subtreeProgress = useMemo(() => {
|
|
401
|
+
if (viewConfig.getSummaryProgress) {
|
|
402
|
+
const byResource = /* @__PURE__ */ new Map();
|
|
403
|
+
for (const ev of allEvents) {
|
|
404
|
+
if (!ev.resourceId) continue;
|
|
405
|
+
const list = byResource.get(ev.resourceId);
|
|
406
|
+
if (list) list.push(ev);
|
|
407
|
+
else byResource.set(ev.resourceId, [ev]);
|
|
408
|
+
}
|
|
409
|
+
const map = /* @__PURE__ */ new Map();
|
|
410
|
+
for (const row of rows) {
|
|
411
|
+
if (!row.isGroup) continue;
|
|
412
|
+
const events = [];
|
|
413
|
+
for (const id of descendantIds.get(row.resource.id) ?? []) {
|
|
414
|
+
const list = byResource.get(id);
|
|
415
|
+
if (list) events.push(...list);
|
|
416
|
+
}
|
|
417
|
+
map.set(row.resource.id, viewConfig.getSummaryProgress({
|
|
418
|
+
resource: row.resource,
|
|
419
|
+
events
|
|
420
|
+
}));
|
|
421
|
+
}
|
|
422
|
+
return map;
|
|
423
|
+
}
|
|
424
|
+
const perResource = /* @__PURE__ */ new Map();
|
|
425
|
+
for (const ev of allEvents) {
|
|
426
|
+
if (!ev.resourceId) continue;
|
|
427
|
+
let agg = perResource.get(ev.resourceId);
|
|
428
|
+
if (!agg) {
|
|
429
|
+
agg = {
|
|
430
|
+
weighted: 0,
|
|
431
|
+
total: 0,
|
|
432
|
+
saw: false
|
|
433
|
+
};
|
|
434
|
+
perResource.set(ev.resourceId, agg);
|
|
435
|
+
}
|
|
436
|
+
const dur = Math.max(ev.end.getTime() - ev.start.getTime(), 1);
|
|
437
|
+
agg.total += dur;
|
|
438
|
+
if (typeof ev.progress === "number") {
|
|
439
|
+
agg.saw = true;
|
|
440
|
+
agg.weighted += ev.progress * dur;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const map = /* @__PURE__ */ new Map();
|
|
444
|
+
for (const row of rows) {
|
|
445
|
+
if (!row.isGroup) continue;
|
|
446
|
+
let weighted = 0;
|
|
447
|
+
let weightTotal = 0;
|
|
448
|
+
let saw = false;
|
|
449
|
+
for (const id of descendantIds.get(row.resource.id) ?? []) {
|
|
450
|
+
const agg = perResource.get(id);
|
|
451
|
+
if (!agg) continue;
|
|
452
|
+
weightTotal += agg.total;
|
|
453
|
+
if (agg.saw) {
|
|
454
|
+
saw = true;
|
|
455
|
+
weighted += agg.weighted;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
map.set(row.resource.id, saw && weightTotal > 0 ? Math.min(Math.max(Math.round(weighted / weightTotal), 0), 100) : null);
|
|
459
|
+
}
|
|
460
|
+
return map;
|
|
461
|
+
}, [
|
|
462
|
+
rows,
|
|
463
|
+
allEvents,
|
|
464
|
+
descendantIds,
|
|
465
|
+
viewConfig.getSummaryProgress
|
|
466
|
+
]);
|
|
467
|
+
const laneMemory = useRef(/* @__PURE__ */ new Map());
|
|
468
|
+
const scheduleMode = viewConfig.scheduleMode;
|
|
469
|
+
const draftLayout = useGanttSelector((state) => {
|
|
470
|
+
const slotDraft = state.slotDraft;
|
|
471
|
+
if (!slotDraft?.resourceId) return null;
|
|
472
|
+
return {
|
|
473
|
+
resourceId: slotDraft.resourceId,
|
|
474
|
+
startMs: slotDraft.start.getTime(),
|
|
475
|
+
endMs: slotDraft.end.getTime()
|
|
476
|
+
};
|
|
477
|
+
}, { isEqual: (a, b) => a === b || a !== null && b !== null && a.resourceId === b.resourceId && a.startMs === b.startMs && a.endMs === b.endMs });
|
|
478
|
+
const baseRowBars = useMemo(() => {
|
|
479
|
+
const map = /* @__PURE__ */ new Map();
|
|
480
|
+
const previousLanes = laneMemory.current;
|
|
481
|
+
const nextLanes = /* @__PURE__ */ new Map();
|
|
482
|
+
const totalMin = (rangeEndMs - rangeStartMs) / 6e4;
|
|
483
|
+
const byResource = /* @__PURE__ */ new Map();
|
|
484
|
+
const envelopes = /* @__PURE__ */ new Map();
|
|
485
|
+
for (const occ of occurrences) {
|
|
486
|
+
const rid = occ.event.resourceId;
|
|
487
|
+
if (!rid) continue;
|
|
488
|
+
const list = byResource.get(rid);
|
|
489
|
+
if (list) list.push(occ);
|
|
490
|
+
else byResource.set(rid, [occ]);
|
|
491
|
+
const fromMin = Math.max((occ.start.getTime() - rangeStartMs) / 6e4, 0);
|
|
492
|
+
const toMin = Math.min((occ.end.getTime() - rangeStartMs) / 6e4, totalMin);
|
|
493
|
+
const env = envelopes.get(rid);
|
|
494
|
+
if (!env) envelopes.set(rid, {
|
|
495
|
+
fromMin,
|
|
496
|
+
toMin
|
|
497
|
+
});
|
|
498
|
+
else {
|
|
499
|
+
env.fromMin = Math.min(env.fromMin, fromMin);
|
|
500
|
+
env.toMin = Math.max(env.toMin, toMin);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
for (const row of rows) {
|
|
504
|
+
const segments = (byResource.get(row.resource.id) ?? []).map((occurrence) => ({
|
|
505
|
+
occurrence,
|
|
506
|
+
day: new Date(rangeStartMs),
|
|
507
|
+
isStart: occurrence.start.getTime() >= rangeStartMs,
|
|
508
|
+
isEnd: occurrence.end.getTime() <= rangeEndMs,
|
|
509
|
+
continuesBefore: occurrence.start.getTime() < rangeStartMs,
|
|
510
|
+
continuesAfter: occurrence.end.getTime() > rangeEndMs,
|
|
511
|
+
startMin: Math.max((occurrence.start.getTime() - rangeStartMs) / 6e4, 0),
|
|
512
|
+
endMin: Math.min((occurrence.end.getTime() - rangeStartMs) / 6e4, totalMin)
|
|
513
|
+
}));
|
|
514
|
+
const mode = resolveScheduleMode(row.resource, scheduleMode);
|
|
515
|
+
packTimedSegments(segments, {
|
|
516
|
+
mode,
|
|
517
|
+
preferredLanes: previousLanes
|
|
518
|
+
});
|
|
519
|
+
for (const segment of segments) nextLanes.set(getLaneKey(segment.occurrence), {
|
|
520
|
+
lane: segment.column ?? 0,
|
|
521
|
+
startMs: segment.occurrence.start.getTime(),
|
|
522
|
+
endMs: segment.occurrence.end.getTime()
|
|
523
|
+
});
|
|
524
|
+
const laneCount = segments.reduce((max, segment) => Math.max(max, (segment.column ?? 0) + 1), 1);
|
|
525
|
+
let from = Infinity;
|
|
526
|
+
let to = -Infinity;
|
|
527
|
+
for (const segment of segments) {
|
|
528
|
+
from = Math.min(from, (segment.startMin ?? 0) / totalMin);
|
|
529
|
+
to = Math.max(to, (segment.endMin ?? 0) / totalMin);
|
|
530
|
+
}
|
|
531
|
+
let summary = null;
|
|
532
|
+
if (row.isGroup && segments.length === 0 && viewConfig.summaryBars) {
|
|
533
|
+
let sumFrom = Infinity;
|
|
534
|
+
let sumTo = -Infinity;
|
|
535
|
+
for (const id of descendantIds.get(row.resource.id) ?? []) {
|
|
536
|
+
const env = envelopes.get(id);
|
|
537
|
+
if (!env) continue;
|
|
538
|
+
sumFrom = Math.min(sumFrom, env.fromMin / totalMin);
|
|
539
|
+
sumTo = Math.max(sumTo, env.toMin / totalMin);
|
|
540
|
+
}
|
|
541
|
+
if (sumTo > sumFrom) summary = {
|
|
542
|
+
from: sumFrom,
|
|
543
|
+
to: sumTo,
|
|
544
|
+
progress: subtreeProgress.get(row.resource.id) ?? null
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
const blockRem = laneCount * laneHeightRem + (laneCount - 1) * laneGapRem;
|
|
548
|
+
const heightRem = Math.max(minRowRem, blockRem + 2 * rowPaddingRem);
|
|
549
|
+
const laneOffsetRem = (heightRem - blockRem) / 2;
|
|
550
|
+
map.set(row.resource.id, {
|
|
551
|
+
segments,
|
|
552
|
+
laneCount,
|
|
553
|
+
draftLane: null,
|
|
554
|
+
scheduleMode: mode,
|
|
555
|
+
heightRem,
|
|
556
|
+
laneOffsetRem,
|
|
557
|
+
bandRem: laneHeightRem + laneOffsetRem * 2,
|
|
558
|
+
extent: segments.length > 0 ? {
|
|
559
|
+
from,
|
|
560
|
+
to,
|
|
561
|
+
color: segments[0].occurrence.event.color,
|
|
562
|
+
label: segments.length === 1 ? segments[0].occurrence.event.title : settings.i18n.labels.events(segments.length),
|
|
563
|
+
startMs: Math.min(...segments.map((s) => s.occurrence.start.getTime()))
|
|
564
|
+
} : summary ? {
|
|
565
|
+
from: summary.from,
|
|
566
|
+
to: summary.to,
|
|
567
|
+
label: row.resource.title,
|
|
568
|
+
startMs: rangeStartMs + summary.from * (rangeEndMs - rangeStartMs)
|
|
569
|
+
} : null,
|
|
570
|
+
summary
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
laneMemory.current = nextLanes;
|
|
574
|
+
return map;
|
|
575
|
+
}, [
|
|
576
|
+
rows,
|
|
577
|
+
occurrences,
|
|
578
|
+
rangeStartMs,
|
|
579
|
+
rangeEndMs,
|
|
580
|
+
settings.i18n,
|
|
581
|
+
viewConfig.summaryBars,
|
|
582
|
+
descendantIds,
|
|
583
|
+
subtreeProgress,
|
|
584
|
+
laneHeightRem,
|
|
585
|
+
rowPaddingRem,
|
|
586
|
+
laneGapRem,
|
|
587
|
+
minRowRem,
|
|
588
|
+
scheduleMode
|
|
589
|
+
]);
|
|
590
|
+
const treeConfig = {
|
|
591
|
+
...DEFAULT_TREE_PANEL,
|
|
592
|
+
...viewConfig.treePanel
|
|
593
|
+
};
|
|
594
|
+
const clampTree = (width) => Math.min(Math.max(width, treeConfig.minWidth), treeConfig.maxWidth);
|
|
595
|
+
const [treeWidth, setTreeWidth] = useState(treeConfig.width);
|
|
596
|
+
const configuredTreeWidth = clampTree(treeWidth);
|
|
597
|
+
const columns = viewConfig.columns ?? [];
|
|
598
|
+
/**
|
|
599
|
+
* Reserve the track a drag-create in flight will land on - as a THIN overlay
|
|
600
|
+
* over the layout above, never as an input to it. Rebuilding the whole map
|
|
601
|
+
* per snapped step would hand every row a new `bars` object and defeat
|
|
602
|
+
* GanttTimelineRow's memo across the entire grid, so only the drafted row's
|
|
603
|
+
* entry is replaced; every other row keeps its identity and never re-renders.
|
|
604
|
+
*
|
|
605
|
+
* `laneOffsetRem` and `bandRem` are deliberately carried over UNCHANGED.
|
|
606
|
+
* Deriving them from the grown track count re-centres the row, which drags
|
|
607
|
+
* the settled bars and the tree label box with it - a 2px wobble by default
|
|
608
|
+
* and, under a consumer `metrics.minRowHeight` big enough to swallow the
|
|
609
|
+
* growth, an 11.5px jerk that snaps back on release. Growing a row must add
|
|
610
|
+
* space BELOW what is already there and move nothing.
|
|
611
|
+
*/
|
|
612
|
+
const rowBars = useMemo(() => {
|
|
613
|
+
if (!draftLayout) return baseRowBars;
|
|
614
|
+
const base = baseRowBars.get(draftLayout.resourceId);
|
|
615
|
+
if (!base) return baseRowBars;
|
|
616
|
+
const next = new Map(baseRowBars);
|
|
617
|
+
if (base.scheduleMode === "single") {
|
|
618
|
+
next.set(draftLayout.resourceId, {
|
|
619
|
+
...base,
|
|
620
|
+
draftLane: 0
|
|
621
|
+
});
|
|
622
|
+
return next;
|
|
623
|
+
}
|
|
624
|
+
const draftLane = lowestFreeLane(base.segments, draftLayout.startMs, draftLayout.endMs);
|
|
625
|
+
const trackCount = Math.max(base.laneCount, draftLane + 1);
|
|
626
|
+
const draftBlockRem = trackCount * laneHeightRem + (trackCount - 1) * laneGapRem;
|
|
627
|
+
next.set(draftLayout.resourceId, {
|
|
628
|
+
...base,
|
|
629
|
+
draftLane,
|
|
630
|
+
heightRem: Math.max(base.heightRem, base.laneOffsetRem * 2 + draftBlockRem)
|
|
631
|
+
});
|
|
632
|
+
return next;
|
|
633
|
+
}, [
|
|
634
|
+
baseRowBars,
|
|
635
|
+
draftLayout,
|
|
636
|
+
laneHeightRem,
|
|
637
|
+
laneGapRem
|
|
638
|
+
]);
|
|
639
|
+
const showCreateTask = viewConfig.displayCreateTaskHint && !!settings.onCreateTask && (settings.canCreateTask?.({ parentId: null }) ?? true);
|
|
640
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
641
|
+
const clampContainer = (width, container) => {
|
|
642
|
+
if (container <= 0) return width;
|
|
643
|
+
const ceiling = container - minTimelineWidth - 1;
|
|
644
|
+
const floor = Math.min(treeConfig.minWidth, Math.max(ceiling, 0));
|
|
645
|
+
return Math.max(Math.min(width, ceiling), Math.min(floor, container - 1));
|
|
646
|
+
};
|
|
647
|
+
const clampedTreeWidth = clampContainer(configuredTreeWidth, containerWidth);
|
|
648
|
+
/** Live width while the splitter is dragging; render reads it so a
|
|
649
|
+
mid-drag re-render can't snap the pane back to stale state. */
|
|
650
|
+
const liveTreeWidthRef = useRef(null);
|
|
651
|
+
useGanttGestureTeardown();
|
|
652
|
+
useEffect(() => {
|
|
653
|
+
cancelActiveGanttGestures();
|
|
654
|
+
}, []);
|
|
655
|
+
const [internalSelected, setInternalSelected] = useState([]);
|
|
656
|
+
const selectedRows = viewConfig.selectedRows ?? internalSelected;
|
|
657
|
+
const selectedSet = useMemo(() => new Set(selectedRows), [selectedRows]);
|
|
658
|
+
const viewConfigRef = useRef(viewConfig);
|
|
659
|
+
viewConfigRef.current = viewConfig;
|
|
660
|
+
const selectedRowsRef = useRef(selectedRows);
|
|
661
|
+
selectedRowsRef.current = selectedRows;
|
|
662
|
+
const toggleRowSelected = useCallback((id, checked) => {
|
|
663
|
+
const current = selectedRowsRef.current;
|
|
664
|
+
const next = checked ? [...current.filter((rowId) => rowId !== id), id] : current.filter((rowId) => rowId !== id);
|
|
665
|
+
if (viewConfigRef.current.selectedRows === void 0) setInternalSelected(next);
|
|
666
|
+
viewConfigRef.current.onSelectedRowsChange?.(next);
|
|
667
|
+
}, []);
|
|
668
|
+
const bodyRef = useRef(null);
|
|
669
|
+
const treePaneRef = useRef(null);
|
|
670
|
+
const timelinePaneRef = useRef(null);
|
|
671
|
+
const treeRowsRef = useRef(null);
|
|
672
|
+
useLayoutEffect(() => {
|
|
673
|
+
const body = bodyRef.current;
|
|
674
|
+
if (!body) return;
|
|
675
|
+
const update = () => setContainerWidth(body.clientWidth);
|
|
676
|
+
update();
|
|
677
|
+
const observer = new ResizeObserver(update);
|
|
678
|
+
observer.observe(body);
|
|
679
|
+
return () => observer.disconnect();
|
|
680
|
+
}, []);
|
|
681
|
+
const beginSplit = (e) => {
|
|
682
|
+
if (e.button !== 0) return;
|
|
683
|
+
e.preventDefault();
|
|
684
|
+
const pointerId = e.pointerId;
|
|
685
|
+
const startX = e.clientX;
|
|
686
|
+
const startWidth = clampedTreeWidth;
|
|
687
|
+
const splitter = e.currentTarget;
|
|
688
|
+
const dir = getComputedStyle(splitter).direction === "rtl" ? -1 : 1;
|
|
689
|
+
splitter.setAttribute("data-resizing", "");
|
|
690
|
+
document.body.style.cursor = "col-resize";
|
|
691
|
+
document.body.style.userSelect = "none";
|
|
692
|
+
let liveWidth = startWidth;
|
|
693
|
+
const onMove = (ev) => {
|
|
694
|
+
if (ev.pointerId !== pointerId) return;
|
|
695
|
+
liveWidth = clampContainer(clampTree(startWidth + (ev.clientX - startX) * dir), bodyRef.current?.clientWidth ?? 0);
|
|
696
|
+
liveTreeWidthRef.current = liveWidth;
|
|
697
|
+
if (treePaneRef.current) treePaneRef.current.style.width = `${liveWidth}px`;
|
|
698
|
+
};
|
|
699
|
+
const finish = (ev) => {
|
|
700
|
+
if (ev && ev.pointerId !== pointerId) return;
|
|
701
|
+
window.removeEventListener("pointermove", onMove);
|
|
702
|
+
window.removeEventListener("pointerup", finish);
|
|
703
|
+
window.removeEventListener("pointercancel", finish);
|
|
704
|
+
splitter.removeAttribute("data-resizing");
|
|
705
|
+
document.body.style.cursor = "";
|
|
706
|
+
document.body.style.userSelect = "";
|
|
707
|
+
liveTreeWidthRef.current = null;
|
|
708
|
+
if (liveWidth !== startWidth) {
|
|
709
|
+
setTreeWidth(liveWidth);
|
|
710
|
+
viewConfigRef.current.treePanel?.onWidthChange?.(liveWidth);
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
window.addEventListener("pointermove", onMove);
|
|
714
|
+
window.addEventListener("pointerup", finish);
|
|
715
|
+
window.addEventListener("pointercancel", finish);
|
|
716
|
+
};
|
|
717
|
+
useEffect(() => {
|
|
718
|
+
const treeViewport = getPaneViewport(treePaneRef.current);
|
|
719
|
+
const timelineViewport = getPaneViewport(timelinePaneRef.current);
|
|
720
|
+
if (!treeViewport || !timelineViewport) return;
|
|
721
|
+
const link = (source, target) => {
|
|
722
|
+
let lastTop = source.scrollTop;
|
|
723
|
+
const onScroll = () => {
|
|
724
|
+
if (source.scrollTop === lastTop) return;
|
|
725
|
+
lastTop = source.scrollTop;
|
|
726
|
+
if (target.scrollTop !== source.scrollTop) target.scrollTop = source.scrollTop;
|
|
727
|
+
};
|
|
728
|
+
source.addEventListener("scroll", onScroll);
|
|
729
|
+
return () => source.removeEventListener("scroll", onScroll);
|
|
730
|
+
};
|
|
731
|
+
const unlinkTree = link(treeViewport, timelineViewport);
|
|
732
|
+
const unlinkTimeline = link(timelineViewport, treeViewport);
|
|
733
|
+
let unforward = null;
|
|
734
|
+
if (treeViewport.hasAttribute("data-gantt-native-scroll")) {
|
|
735
|
+
const onWheel = (e) => {
|
|
736
|
+
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
|
|
737
|
+
const dy = e.deltaMode === 1 ? e.deltaY * 16 : e.deltaY;
|
|
738
|
+
timelineViewport.scrollTop += dy;
|
|
739
|
+
e.preventDefault();
|
|
740
|
+
};
|
|
741
|
+
treeViewport.addEventListener("wheel", onWheel, { passive: false });
|
|
742
|
+
unforward = () => treeViewport.removeEventListener("wheel", onWheel);
|
|
743
|
+
} else {
|
|
744
|
+
const onWheel = (e) => {
|
|
745
|
+
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
|
|
746
|
+
const max = timelineViewport.scrollHeight - timelineViewport.clientHeight;
|
|
747
|
+
if (max <= 0) return;
|
|
748
|
+
const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? timelineViewport.clientHeight : 1;
|
|
749
|
+
const next = Math.max(0, Math.min(max, timelineViewport.scrollTop + e.deltaY * unit));
|
|
750
|
+
e.preventDefault();
|
|
751
|
+
timelineViewport.scrollTop = next;
|
|
752
|
+
treeViewport.scrollTop = next;
|
|
753
|
+
};
|
|
754
|
+
treeViewport.addEventListener("wheel", onWheel, { passive: false });
|
|
755
|
+
timelineViewport.addEventListener("wheel", onWheel, { passive: false });
|
|
756
|
+
unforward = () => {
|
|
757
|
+
treeViewport.removeEventListener("wheel", onWheel);
|
|
758
|
+
timelineViewport.removeEventListener("wheel", onWheel);
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
return () => {
|
|
762
|
+
unlinkTree();
|
|
763
|
+
unlinkTimeline();
|
|
764
|
+
unforward?.();
|
|
765
|
+
};
|
|
766
|
+
}, []);
|
|
767
|
+
useEffect(() => {
|
|
768
|
+
const body = bodyRef.current;
|
|
769
|
+
if (!body) return;
|
|
770
|
+
let current = null;
|
|
771
|
+
const apply = (id) => {
|
|
772
|
+
if (id === current) return;
|
|
773
|
+
if (current) for (const el of body.querySelectorAll(`[data-gantt-row-id="${CSS.escape(current)}"]`)) el.removeAttribute("data-hover");
|
|
774
|
+
if (id) for (const el of body.querySelectorAll(`[data-gantt-row-id="${CSS.escape(id)}"]`)) el.setAttribute("data-hover", "");
|
|
775
|
+
current = id;
|
|
776
|
+
};
|
|
777
|
+
const onOver = (e) => {
|
|
778
|
+
const row = e.target?.closest?.("[data-gantt-row-id]");
|
|
779
|
+
apply(row?.getAttribute("data-gantt-row-id") ?? null);
|
|
780
|
+
};
|
|
781
|
+
const onLeave = () => apply(null);
|
|
782
|
+
body.addEventListener("pointerover", onOver);
|
|
783
|
+
body.addEventListener("pointerleave", onLeave);
|
|
784
|
+
return () => {
|
|
785
|
+
body.removeEventListener("pointerover", onOver);
|
|
786
|
+
body.removeEventListener("pointerleave", onLeave);
|
|
787
|
+
apply(null);
|
|
788
|
+
};
|
|
789
|
+
}, []);
|
|
790
|
+
const anchorMs = useGanttSelector((state) => state.date.getTime());
|
|
791
|
+
const initialCenter = viewConfig.initialCenter instanceof Date ? viewConfig.initialCenter.getTime() : viewConfig.initialCenter;
|
|
792
|
+
const manageRef = useRef({
|
|
793
|
+
key: "",
|
|
794
|
+
buffered: false,
|
|
795
|
+
userTook: false
|
|
796
|
+
});
|
|
797
|
+
useLayoutEffect(() => {
|
|
798
|
+
const key = `${scale}:${anchorMs}:${viewConfig.scrollbars}`;
|
|
799
|
+
if (manageRef.current.key !== key) {
|
|
800
|
+
const slideContinuation = manageRef.current.userTook && instance.internals.didAnchorSlide();
|
|
801
|
+
manageRef.current = slideContinuation ? {
|
|
802
|
+
key,
|
|
803
|
+
buffered: manageRef.current.buffered,
|
|
804
|
+
userTook: true
|
|
805
|
+
} : {
|
|
806
|
+
key,
|
|
807
|
+
buffered: false,
|
|
808
|
+
userTook: false
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
if (manageRef.current.userTook) return;
|
|
812
|
+
let waiter = null;
|
|
813
|
+
const run = () => {
|
|
814
|
+
waiter?.disconnect();
|
|
815
|
+
waiter = null;
|
|
816
|
+
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
817
|
+
const axis = viewport?.querySelector("[data-gantt-axis]");
|
|
818
|
+
if (!viewport || !axis) return;
|
|
819
|
+
if (viewport.clientWidth === 0) {
|
|
820
|
+
waiter = new ResizeObserver(() => {
|
|
821
|
+
if (viewport.clientWidth > 0) run();
|
|
822
|
+
});
|
|
823
|
+
waiter.observe(viewport);
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
if (viewConfig.infiniteScroll && !manageRef.current.buffered) {
|
|
827
|
+
manageRef.current.buffered = true;
|
|
828
|
+
extendLockRef.current = true;
|
|
829
|
+
instance.internals.extendRange("before");
|
|
830
|
+
instance.internals.extendRange("after");
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
extendLockRef.current = false;
|
|
834
|
+
if (viewport.scrollWidth <= viewport.clientWidth) return;
|
|
835
|
+
const active = instance.getState().activeRange;
|
|
836
|
+
let target;
|
|
837
|
+
if (typeof initialCenter === "number") target = initialCenter;
|
|
838
|
+
else if (initialCenter === "anchor") target = anchorMs;
|
|
839
|
+
else {
|
|
840
|
+
const nowMs = Date.now();
|
|
841
|
+
target = nowMs >= active.start.getTime() && nowMs < active.end.getTime() ? nowMs : anchorMs;
|
|
842
|
+
}
|
|
843
|
+
const fraction = Math.min(Math.max((target - rangeStartMs) / (rangeEndMs - rangeStartMs), 0), 1);
|
|
844
|
+
setScrollStart(viewport, Math.max(0, fraction * viewport.scrollWidth - viewport.clientWidth / 2));
|
|
845
|
+
};
|
|
846
|
+
run();
|
|
847
|
+
return () => {
|
|
848
|
+
waiter?.disconnect();
|
|
849
|
+
};
|
|
850
|
+
}, [
|
|
851
|
+
scale,
|
|
852
|
+
anchorMs,
|
|
853
|
+
initialCenter,
|
|
854
|
+
viewConfig.scrollbars,
|
|
855
|
+
viewConfig.infiniteScroll,
|
|
856
|
+
rangeStartMs,
|
|
857
|
+
rangeEndMs,
|
|
858
|
+
instance
|
|
859
|
+
]);
|
|
860
|
+
const pendingRestoreRef = useRef(null);
|
|
861
|
+
const extendLockRef = useRef(false);
|
|
862
|
+
const lastUserScrollRef = useRef(0);
|
|
863
|
+
/** Fine-grained viewport-center instant, for controlled-zoom anchoring. */
|
|
864
|
+
const fineCenterRef = useRef(null);
|
|
865
|
+
const lastZoomRef = useRef(null);
|
|
866
|
+
useEffect(() => {
|
|
867
|
+
const pane = timelinePaneRef.current;
|
|
868
|
+
if (!pane) return;
|
|
869
|
+
const markIntent = () => {
|
|
870
|
+
lastUserScrollRef.current = performance.now();
|
|
871
|
+
};
|
|
872
|
+
const onPointerDown = (e) => {
|
|
873
|
+
if (e.target?.closest("[data-slot=scroll-area-scrollbar], [data-slot=gantt-timeline-header], [data-gantt-native-scroll]")) markIntent();
|
|
874
|
+
};
|
|
875
|
+
pane.addEventListener("wheel", markIntent, { passive: true });
|
|
876
|
+
pane.addEventListener("pointerdown", onPointerDown);
|
|
877
|
+
pane.addEventListener("touchstart", markIntent, { passive: true });
|
|
878
|
+
pane.addEventListener("keydown", markIntent);
|
|
879
|
+
return () => {
|
|
880
|
+
pane.removeEventListener("wheel", markIntent);
|
|
881
|
+
pane.removeEventListener("pointerdown", onPointerDown);
|
|
882
|
+
pane.removeEventListener("touchstart", markIntent);
|
|
883
|
+
pane.removeEventListener("keydown", markIntent);
|
|
884
|
+
};
|
|
885
|
+
}, []);
|
|
886
|
+
useEffect(() => {
|
|
887
|
+
if (!viewConfig.infiniteScroll) return;
|
|
888
|
+
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
889
|
+
if (!viewport) return;
|
|
890
|
+
const tryExtend = (direction) => {
|
|
891
|
+
const axis = viewport.querySelector("[data-gantt-axis]");
|
|
892
|
+
const liveStart = Number(axis?.dataset.ganttRangeStart);
|
|
893
|
+
const liveEnd = Number(axis?.dataset.ganttRangeEnd);
|
|
894
|
+
if (!axis || Number.isNaN(liveStart) || Number.isNaN(liveEnd)) return;
|
|
895
|
+
extendLockRef.current = true;
|
|
896
|
+
manageRef.current.userTook = true;
|
|
897
|
+
pendingRestoreRef.current = {
|
|
898
|
+
ms: liveStart + getScrollStart(viewport) / viewport.scrollWidth * (liveEnd - liveStart),
|
|
899
|
+
align: "start"
|
|
900
|
+
};
|
|
901
|
+
if (!instance.internals.extendRange(direction)) {
|
|
902
|
+
pendingRestoreRef.current = null;
|
|
903
|
+
extendLockRef.current = false;
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
const isRtl = getComputedStyle(viewport).direction === "rtl";
|
|
907
|
+
const onScroll = () => {
|
|
908
|
+
if (extendLockRef.current) return;
|
|
909
|
+
if (performance.now() - lastUserScrollRef.current > 1200) return;
|
|
910
|
+
if (viewport.scrollWidth <= viewport.clientWidth + 8) return;
|
|
911
|
+
const fromStart = getScrollStart(viewport);
|
|
912
|
+
const fromEnd = viewport.scrollWidth - fromStart - viewport.clientWidth;
|
|
913
|
+
const direction = fromStart < infiniteEdgePx ? "before" : fromEnd < infiniteEdgePx ? "after" : null;
|
|
914
|
+
if (!direction) return;
|
|
915
|
+
tryExtend(direction);
|
|
916
|
+
};
|
|
917
|
+
const onWheel = (e) => {
|
|
918
|
+
if (extendLockRef.current || e.deltaX === 0) return;
|
|
919
|
+
if (viewport.scrollWidth <= viewport.clientWidth + 8) return;
|
|
920
|
+
const towardStart = isRtl ? e.deltaX > 0 : e.deltaX < 0;
|
|
921
|
+
if (towardStart && getScrollStart(viewport) <= 0) tryExtend("before");
|
|
922
|
+
else if (!towardStart && getScrollStart(viewport) + viewport.clientWidth >= viewport.scrollWidth - 1) tryExtend("after");
|
|
923
|
+
};
|
|
924
|
+
viewport.addEventListener("scroll", onScroll);
|
|
925
|
+
viewport.addEventListener("wheel", onWheel, { passive: true });
|
|
926
|
+
return () => {
|
|
927
|
+
viewport.removeEventListener("scroll", onScroll);
|
|
928
|
+
viewport.removeEventListener("wheel", onWheel);
|
|
929
|
+
};
|
|
930
|
+
}, [
|
|
931
|
+
instance,
|
|
932
|
+
viewConfig.infiniteScroll,
|
|
933
|
+
infiniteEdgePx
|
|
934
|
+
]);
|
|
935
|
+
useEffect(() => {
|
|
936
|
+
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
937
|
+
if (!viewport) return;
|
|
938
|
+
const keyFmt = scale === "day" ? "yyyy-MM-dd" : scale === "week" ? "RRRR-'W'II" : scale === "month" ? "yyyy-MM" : scale === "quarter" ? "yyyy-qqq" : "yyyy";
|
|
939
|
+
let raf = 0;
|
|
940
|
+
let lastKey = "";
|
|
941
|
+
const measure = () => {
|
|
942
|
+
raf = 0;
|
|
943
|
+
const axis = viewport.querySelector("[data-gantt-axis]");
|
|
944
|
+
const liveStart = Number(axis?.dataset.ganttRangeStart);
|
|
945
|
+
const liveEnd = Number(axis?.dataset.ganttRangeEnd);
|
|
946
|
+
if (!axis || Number.isNaN(liveStart) || Number.isNaN(liveEnd)) return;
|
|
947
|
+
const centerMs = liveStart + (getScrollStart(viewport) + viewport.clientWidth / 2) / Math.max(1, viewport.scrollWidth) * (liveEnd - liveStart);
|
|
948
|
+
fineCenterRef.current = centerMs;
|
|
949
|
+
const center = new Date(centerMs);
|
|
950
|
+
const key = format(toZoned(center, timeZone), keyFmt);
|
|
951
|
+
if (key === lastKey) return;
|
|
952
|
+
lastKey = key;
|
|
953
|
+
instance.internals.setViewportCenter(center);
|
|
954
|
+
};
|
|
955
|
+
const schedule = () => {
|
|
956
|
+
if (!raf) raf = requestAnimationFrame(measure);
|
|
957
|
+
};
|
|
958
|
+
viewport.addEventListener("scroll", schedule);
|
|
959
|
+
schedule();
|
|
960
|
+
return () => {
|
|
961
|
+
viewport.removeEventListener("scroll", schedule);
|
|
962
|
+
if (raf) cancelAnimationFrame(raf);
|
|
963
|
+
};
|
|
964
|
+
}, [
|
|
965
|
+
instance,
|
|
966
|
+
scale,
|
|
967
|
+
timeZone
|
|
968
|
+
]);
|
|
969
|
+
useLayoutEffect(() => {
|
|
970
|
+
if (lastZoomRef.current !== null && lastZoomRef.current !== zoom && !pendingRestoreRef.current && fineCenterRef.current !== null) pendingRestoreRef.current = {
|
|
971
|
+
ms: fineCenterRef.current,
|
|
972
|
+
align: "center"
|
|
973
|
+
};
|
|
974
|
+
lastZoomRef.current = zoom;
|
|
975
|
+
let raf = null;
|
|
976
|
+
let attempts = 0;
|
|
977
|
+
const seat = () => {
|
|
978
|
+
raf = null;
|
|
979
|
+
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
980
|
+
if (viewport && pendingRestoreRef.current) {
|
|
981
|
+
if (viewport.clientWidth === 0 && attempts++ < 20) {
|
|
982
|
+
raf = requestAnimationFrame(seat);
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
const { ms, align } = pendingRestoreRef.current;
|
|
986
|
+
pendingRestoreRef.current = null;
|
|
987
|
+
const fraction = Math.min(Math.max((ms - rangeStartMs) / (rangeEndMs - rangeStartMs), 0), 1);
|
|
988
|
+
const offset = align === "center" ? viewport.clientWidth / 2 : 0;
|
|
989
|
+
setScrollStart(viewport, Math.max(0, fraction * viewport.scrollWidth - offset));
|
|
990
|
+
}
|
|
991
|
+
extendLockRef.current = false;
|
|
992
|
+
};
|
|
993
|
+
seat();
|
|
994
|
+
return () => {
|
|
995
|
+
if (raf !== null) cancelAnimationFrame(raf);
|
|
996
|
+
};
|
|
997
|
+
}, [
|
|
998
|
+
zoom,
|
|
999
|
+
rangeStartMs,
|
|
1000
|
+
rangeEndMs
|
|
1001
|
+
]);
|
|
1002
|
+
/** Keep the view centered on the same instant across a zoom step. */
|
|
1003
|
+
const anchorZoomCenter = () => {
|
|
1004
|
+
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
1005
|
+
const axis = viewport?.querySelector("[data-gantt-axis]");
|
|
1006
|
+
if (!viewport || !axis) return;
|
|
1007
|
+
const liveStart = Number(axis.dataset.ganttRangeStart);
|
|
1008
|
+
const liveEnd = Number(axis.dataset.ganttRangeEnd);
|
|
1009
|
+
if (Number.isNaN(liveStart) || Number.isNaN(liveEnd)) return;
|
|
1010
|
+
pendingRestoreRef.current = {
|
|
1011
|
+
ms: liveStart + (getScrollStart(viewport) + viewport.clientWidth / 2) / viewport.scrollWidth * (liveEnd - liveStart),
|
|
1012
|
+
align: "center"
|
|
1013
|
+
};
|
|
1014
|
+
};
|
|
1015
|
+
const beginHeaderPan = (e) => {
|
|
1016
|
+
if (e.button !== 0) return;
|
|
1017
|
+
const viewport = getPaneViewport(timelinePaneRef.current);
|
|
1018
|
+
if (!viewport) return;
|
|
1019
|
+
const pointerId = e.pointerId;
|
|
1020
|
+
const startX = e.clientX;
|
|
1021
|
+
const startLeft = viewport.scrollLeft;
|
|
1022
|
+
let active = false;
|
|
1023
|
+
const onMove = (ev) => {
|
|
1024
|
+
if (ev.pointerId !== pointerId) return;
|
|
1025
|
+
const dx = ev.clientX - startX;
|
|
1026
|
+
if (!active && Math.abs(dx) < 4) return;
|
|
1027
|
+
if (!active) {
|
|
1028
|
+
markGestureEnd();
|
|
1029
|
+
setIsPanning(true);
|
|
1030
|
+
}
|
|
1031
|
+
active = true;
|
|
1032
|
+
lastUserScrollRef.current = performance.now();
|
|
1033
|
+
document.body.style.cursor = "grabbing";
|
|
1034
|
+
document.body.style.userSelect = "none";
|
|
1035
|
+
viewport.scrollLeft = startLeft - dx;
|
|
1036
|
+
};
|
|
1037
|
+
const finish = (ev) => {
|
|
1038
|
+
if (ev && ev.pointerId !== pointerId) return;
|
|
1039
|
+
window.removeEventListener("pointermove", onMove);
|
|
1040
|
+
window.removeEventListener("pointerup", finish);
|
|
1041
|
+
window.removeEventListener("pointercancel", finish);
|
|
1042
|
+
document.body.style.cursor = "";
|
|
1043
|
+
document.body.style.userSelect = "";
|
|
1044
|
+
if (active) setIsPanning(false);
|
|
1045
|
+
};
|
|
1046
|
+
window.addEventListener("pointermove", onMove);
|
|
1047
|
+
window.addEventListener("pointerup", finish);
|
|
1048
|
+
window.addEventListener("pointercancel", finish);
|
|
1049
|
+
};
|
|
1050
|
+
const [isPanning, setIsPanning] = useState(false);
|
|
1051
|
+
const [reorder, setReorder] = useState(null);
|
|
1052
|
+
const reorderEnabled = !!settings.onResourceReorder;
|
|
1053
|
+
const settingsRef = useRef(settings);
|
|
1054
|
+
settingsRef.current = settings;
|
|
1055
|
+
const rowsRef = useRef(rows);
|
|
1056
|
+
rowsRef.current = rows;
|
|
1057
|
+
const beginRowReorder = useCallback((e, dragRow) => {
|
|
1058
|
+
const settings = settingsRef.current;
|
|
1059
|
+
const rows = rowsRef.current;
|
|
1060
|
+
if (e.button !== 0 || !settings.onResourceReorder) return;
|
|
1061
|
+
e.preventDefault();
|
|
1062
|
+
e.stopPropagation();
|
|
1063
|
+
const container = treeRowsRef.current;
|
|
1064
|
+
const pane = treePaneRef.current;
|
|
1065
|
+
if (!container || !pane) return;
|
|
1066
|
+
const rowEls = Array.from(container.querySelectorAll("[data-slot=gantt-row-group]"));
|
|
1067
|
+
document.body.style.cursor = "grabbing";
|
|
1068
|
+
document.body.style.userSelect = "none";
|
|
1069
|
+
let current = null;
|
|
1070
|
+
let lastBoundary = -1;
|
|
1071
|
+
const pointerId = e.pointerId;
|
|
1072
|
+
const rowEl = e.currentTarget.closest("[data-slot=gantt-row-group]");
|
|
1073
|
+
const overlay = document.createElement("div");
|
|
1074
|
+
overlay.setAttribute("data-slot", "gantt-drag-overlay");
|
|
1075
|
+
overlay.className = "bg-background pointer-events-none fixed overflow-hidden opacity-95";
|
|
1076
|
+
overlay.style.zIndex = "100";
|
|
1077
|
+
const ganttRoot = pane.closest("[data-slot=gantt]");
|
|
1078
|
+
if (ganttRoot) {
|
|
1079
|
+
const rootStyle = getComputedStyle(ganttRoot);
|
|
1080
|
+
overlay.style.fontSize = rootStyle.fontSize;
|
|
1081
|
+
overlay.style.lineHeight = rootStyle.lineHeight;
|
|
1082
|
+
overlay.style.fontFamily = rootStyle.fontFamily;
|
|
1083
|
+
overlay.style.letterSpacing = rootStyle.letterSpacing;
|
|
1084
|
+
overlay.style.direction = rootStyle.direction;
|
|
1085
|
+
}
|
|
1086
|
+
if (rowEl) {
|
|
1087
|
+
const rowRect = rowEl.getBoundingClientRect();
|
|
1088
|
+
overlay.style.width = `${rowRect.width}px`;
|
|
1089
|
+
overlay.style.height = `${rowRect.height}px`;
|
|
1090
|
+
const clone = rowEl.cloneNode(true);
|
|
1091
|
+
clone.removeAttribute("data-gantt-row-id");
|
|
1092
|
+
clone.classList.remove("border-b");
|
|
1093
|
+
clone.style.height = "100%";
|
|
1094
|
+
overlay.appendChild(clone);
|
|
1095
|
+
}
|
|
1096
|
+
document.body.appendChild(overlay);
|
|
1097
|
+
const grabRect = rowEl?.getBoundingClientRect();
|
|
1098
|
+
const grabDY = grabRect ? e.clientY - grabRect.top : 8;
|
|
1099
|
+
const lockedX = grabRect?.left ?? pane.getBoundingClientRect().left;
|
|
1100
|
+
const paneRect = pane.getBoundingClientRect();
|
|
1101
|
+
const rowH = grabRect?.height ?? 40;
|
|
1102
|
+
const rects = rowEls.map((el) => el.getBoundingClientRect());
|
|
1103
|
+
const place = (y) => {
|
|
1104
|
+
const top = Math.min(Math.max(y - grabDY, paneRect.top), paneRect.bottom - rowH);
|
|
1105
|
+
overlay.style.left = `${lockedX}px`;
|
|
1106
|
+
overlay.style.top = `${top}px`;
|
|
1107
|
+
};
|
|
1108
|
+
place(e.clientY);
|
|
1109
|
+
const propose = (boundary) => {
|
|
1110
|
+
const parentId = rows[boundary]?.parentId ?? rows[rows.length - 1]?.parentId ?? null;
|
|
1111
|
+
let index = 0;
|
|
1112
|
+
for (let i = 0; i < boundary; i++) if (rows[i].parentId === parentId && rows[i].resource.id !== dragRow.resource.id) index++;
|
|
1113
|
+
const next = reorderResources(settings.resources, dragRow.resource.id, parentId, index);
|
|
1114
|
+
const proposal = next ? {
|
|
1115
|
+
resourceId: dragRow.resource.id,
|
|
1116
|
+
parentId,
|
|
1117
|
+
index,
|
|
1118
|
+
resources: next
|
|
1119
|
+
} : null;
|
|
1120
|
+
const valid = !!proposal && (settings.canReorderResource?.(proposal) ?? true);
|
|
1121
|
+
const top = boundary < rects.length ? rects[boundary].top - paneRect.top : (rects[rects.length - 1]?.bottom ?? paneRect.top) - paneRect.top;
|
|
1122
|
+
return {
|
|
1123
|
+
resourceId: dragRow.resource.id,
|
|
1124
|
+
top,
|
|
1125
|
+
valid,
|
|
1126
|
+
proposal
|
|
1127
|
+
};
|
|
1128
|
+
};
|
|
1129
|
+
const onMove = (ev) => {
|
|
1130
|
+
if (ev.pointerId !== pointerId) return;
|
|
1131
|
+
place(ev.clientY);
|
|
1132
|
+
let boundary = rects.length;
|
|
1133
|
+
for (let i = 0; i < rects.length; i++) if (ev.clientY < rects[i].top + rects[i].height / 2) {
|
|
1134
|
+
boundary = i;
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1137
|
+
if (boundary === lastBoundary) return;
|
|
1138
|
+
lastBoundary = boundary;
|
|
1139
|
+
const nextState = propose(boundary);
|
|
1140
|
+
if (current && current.top === nextState.top && current.valid === nextState.valid) return;
|
|
1141
|
+
current = nextState;
|
|
1142
|
+
document.body.style.cursor = nextState.valid ? "grabbing" : "not-allowed";
|
|
1143
|
+
setReorder(nextState);
|
|
1144
|
+
};
|
|
1145
|
+
const finish = (commit) => {
|
|
1146
|
+
window.removeEventListener("pointermove", onMove);
|
|
1147
|
+
window.removeEventListener("pointerup", onUp);
|
|
1148
|
+
window.removeEventListener("pointercancel", onCancelEvent);
|
|
1149
|
+
window.removeEventListener("keydown", onKey);
|
|
1150
|
+
overlay.remove();
|
|
1151
|
+
document.body.style.cursor = "";
|
|
1152
|
+
document.body.style.userSelect = "";
|
|
1153
|
+
if (commit && current?.proposal && !current.valid) settings.onResourceReorderReject?.(current.proposal);
|
|
1154
|
+
else if (commit && current?.valid && current.proposal) {
|
|
1155
|
+
settings.onResourceReorder?.(current.proposal);
|
|
1156
|
+
const announcer = pane.closest("[data-slot=gantt]")?.querySelector("[data-slot=gantt-announcer]");
|
|
1157
|
+
if (announcer) announcer.textContent = `${dragRow.resource.title}: ${settings.i18n.labels.reorder}`;
|
|
1158
|
+
}
|
|
1159
|
+
setReorder(null);
|
|
1160
|
+
};
|
|
1161
|
+
const onUp = (ev) => {
|
|
1162
|
+
if (ev.pointerId !== pointerId) return;
|
|
1163
|
+
finish(true);
|
|
1164
|
+
};
|
|
1165
|
+
const onCancelEvent = (ev) => {
|
|
1166
|
+
if (ev.pointerId !== pointerId) return;
|
|
1167
|
+
finish(false);
|
|
1168
|
+
};
|
|
1169
|
+
const onKey = (ev) => {
|
|
1170
|
+
if (ev.key === "Escape") finish(false);
|
|
1171
|
+
};
|
|
1172
|
+
window.addEventListener("pointermove", onMove);
|
|
1173
|
+
window.addEventListener("pointerup", onUp);
|
|
1174
|
+
window.addEventListener("pointercancel", onCancelEvent);
|
|
1175
|
+
window.addEventListener("keydown", onKey);
|
|
1176
|
+
}, []);
|
|
1177
|
+
const collapsedIdsRef = useRef(collapsedIds);
|
|
1178
|
+
collapsedIdsRef.current = collapsedIds;
|
|
1179
|
+
const onToggleRow = useCallback((row) => {
|
|
1180
|
+
const current = collapsedIdsRef.current;
|
|
1181
|
+
const next = current.includes(row.resource.id) ? current.filter((id) => id !== row.resource.id) : [...current, row.resource.id];
|
|
1182
|
+
if (viewConfigRef.current.collapsedGroups === void 0) setInternalCollapsed(next);
|
|
1183
|
+
viewConfigRef.current.onCollapsedGroupsChange?.(next);
|
|
1184
|
+
}, []);
|
|
1185
|
+
const loading = useGanttSelector((state) => state.loading);
|
|
1186
|
+
const customScrollbars = viewConfig.scrollbars !== "native";
|
|
1187
|
+
const gridLines = resolveTimelineLines(viewConfig.timelineLines);
|
|
1188
|
+
const showVerticalLines = gridLines.vertical !== null;
|
|
1189
|
+
const offDayClassName = typeof viewConfig.offDays === "object" && viewConfig.offDays.className || "bg-muted/40";
|
|
1190
|
+
const offDayBodyClassName = typeof viewConfig.offDays === "object" && viewConfig.offDays.className || "bg-muted/25 bg-[repeating-linear-gradient(135deg,transparent,transparent_5px,color-mix(in_oklab,var(--color-border)_35%,transparent)_5px,color-mix(in_oklab,var(--color-border)_35%,transparent)_6px)]";
|
|
1191
|
+
const showUnitLines = !uniform || showVerticalLines;
|
|
1192
|
+
const namePaddingStart = reorderEnabled ? "3.125rem" : "2.25rem";
|
|
1193
|
+
const treeContent = /* @__PURE__ */ jsxs("div", {
|
|
1194
|
+
className: cn("flex min-h-full w-max min-w-full flex-col", customScrollbars && "pb-2.5"),
|
|
1195
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1196
|
+
"data-slot": "gantt-tree-header",
|
|
1197
|
+
className: "sticky top-0 z-30 box-content h-16 shrink-0 border-b border-b-transparent bg-background",
|
|
1198
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1199
|
+
className: "flex h-8 border-b",
|
|
1200
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1201
|
+
className: "flex h-full min-w-0 flex-1",
|
|
1202
|
+
children: [
|
|
1203
|
+
/* @__PURE__ */ jsx("div", {
|
|
1204
|
+
className: "flex h-full shrink-0 items-center",
|
|
1205
|
+
style: {
|
|
1206
|
+
width: treeConfig.nameColumnWidth,
|
|
1207
|
+
paddingInlineStart: namePaddingStart
|
|
1208
|
+
},
|
|
1209
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1210
|
+
className: "truncate font-medium text-muted-foreground",
|
|
1211
|
+
children: settings.i18n.labels.resources
|
|
1212
|
+
})
|
|
1213
|
+
}),
|
|
1214
|
+
columns.map((column) => /* @__PURE__ */ jsx("div", {
|
|
1215
|
+
"data-slot": "gantt-column-header",
|
|
1216
|
+
"data-column": column.id,
|
|
1217
|
+
className: cn("flex h-full shrink-0 items-center px-2 font-medium text-muted-foreground", column.align === "center" && "justify-center", column.align === "end" && "justify-end", column.className),
|
|
1218
|
+
style: { width: column.width ?? DEFAULT_COLUMN_WIDTH },
|
|
1219
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1220
|
+
className: "truncate",
|
|
1221
|
+
children: column.title ?? column.id
|
|
1222
|
+
})
|
|
1223
|
+
}, column.id)),
|
|
1224
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1" })
|
|
1225
|
+
]
|
|
1226
|
+
}), viewConfig.columnsMenu && /* @__PURE__ */ jsx("div", {
|
|
1227
|
+
"data-slot": "gantt-columns-menu",
|
|
1228
|
+
className: "sticky end-0 z-10 flex h-full shrink-0 items-center bg-background ps-1.5 pe-2.5 before:pointer-events-none before:absolute before:inset-y-0 before:-start-5 before:w-5 before:bg-linear-to-l before:from-background before:to-transparent rtl:before:bg-linear-to-r",
|
|
1229
|
+
children: viewConfig.columnsMenu
|
|
1230
|
+
})]
|
|
1231
|
+
})
|
|
1232
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1233
|
+
ref: treeRowsRef,
|
|
1234
|
+
className: "flex flex-col",
|
|
1235
|
+
children: [rows.map((row) => /* @__PURE__ */ jsx(GanttTreeRow, {
|
|
1236
|
+
row,
|
|
1237
|
+
heightRem: rowBars.get(row.resource.id)?.heightRem ?? minRowRem,
|
|
1238
|
+
bandRem: rowBars.get(row.resource.id)?.bandRem ?? minRowRem,
|
|
1239
|
+
columns,
|
|
1240
|
+
nameWidth: treeConfig.nameColumnWidth,
|
|
1241
|
+
dimmed: reorder?.resourceId === row.resource.id,
|
|
1242
|
+
selected: selectedSet.has(row.resource.id),
|
|
1243
|
+
onSelectedChange: row.isGroup ? void 0 : toggleRowSelected,
|
|
1244
|
+
onGripPointerDown: reorderEnabled ? beginRowReorder : void 0,
|
|
1245
|
+
onToggle: onToggleRow
|
|
1246
|
+
}, row.resource.id)), showCreateTask && /* @__PURE__ */ jsx("button", {
|
|
1247
|
+
type: "button",
|
|
1248
|
+
"data-slot": "gantt-create-task",
|
|
1249
|
+
className: "flex h-10 w-full shrink-0 items-center border-b ps-3 pe-3 text-muted-foreground hover:bg-muted/40 hover:text-foreground",
|
|
1250
|
+
onClick: () => settings.onCreateTask?.({
|
|
1251
|
+
parentId: null,
|
|
1252
|
+
index: settings.resources.length
|
|
1253
|
+
}),
|
|
1254
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
1255
|
+
className: "flex h-full w-full items-center",
|
|
1256
|
+
children: [
|
|
1257
|
+
reorderEnabled && /* @__PURE__ */ jsx("span", {
|
|
1258
|
+
"aria-hidden": true,
|
|
1259
|
+
className: "w-3.5 shrink-0"
|
|
1260
|
+
}),
|
|
1261
|
+
/* @__PURE__ */ jsx("span", {
|
|
1262
|
+
className: "me-1 flex w-5 shrink-0 items-center justify-center",
|
|
1263
|
+
children: /* @__PURE__ */ jsx(PlusIcon, {
|
|
1264
|
+
className: "size-3.5",
|
|
1265
|
+
"aria-hidden": "true"
|
|
1266
|
+
})
|
|
1267
|
+
}),
|
|
1268
|
+
/* @__PURE__ */ jsx("span", { children: settings.i18n.labels.addTask })
|
|
1269
|
+
]
|
|
1270
|
+
})
|
|
1271
|
+
})]
|
|
1272
|
+
})]
|
|
1273
|
+
});
|
|
1274
|
+
const timelineContent = /* @__PURE__ */ jsxs("div", {
|
|
1275
|
+
className: cn("flex min-h-full w-max min-w-full grow flex-col", customScrollbars && "pb-2.5"),
|
|
1276
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1277
|
+
"data-slot": "gantt-timeline-header",
|
|
1278
|
+
className: "sticky top-0 z-30 shrink-0 border-b bg-background",
|
|
1279
|
+
style: { minWidth: trackWidth },
|
|
1280
|
+
onPointerDown: beginHeaderPan,
|
|
1281
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1282
|
+
className: "relative h-8 border-b",
|
|
1283
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1284
|
+
className: "flex h-full",
|
|
1285
|
+
children: groups.map((group) => /* @__PURE__ */ jsx("div", {
|
|
1286
|
+
"data-slot": "gantt-axis-group",
|
|
1287
|
+
className: "flex min-w-0 items-center ps-3 pe-2 text-muted-foreground",
|
|
1288
|
+
style: { flex: `${group.span} 0 0px` },
|
|
1289
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1290
|
+
"data-slot": "gantt-axis-group-label",
|
|
1291
|
+
className: "sticky start-3 max-w-full truncate",
|
|
1292
|
+
children: group.label
|
|
1293
|
+
})
|
|
1294
|
+
}, group.key))
|
|
1295
|
+
}), groupBoundaries.map((fraction) => /* @__PURE__ */ jsx("span", {
|
|
1296
|
+
"aria-hidden": true,
|
|
1297
|
+
className: "absolute inset-y-0 w-px bg-border",
|
|
1298
|
+
style: { insetInlineStart: `calc(${fraction * 100}% - 1px)` }
|
|
1299
|
+
}, fraction))]
|
|
1300
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1301
|
+
"data-gantt-axis": "",
|
|
1302
|
+
"data-gantt-range-start": rangeStartMs,
|
|
1303
|
+
"data-gantt-range-end": rangeEndMs,
|
|
1304
|
+
"data-gantt-snap": snapMin,
|
|
1305
|
+
className: "relative h-8",
|
|
1306
|
+
children: [
|
|
1307
|
+
/* @__PURE__ */ jsx("div", {
|
|
1308
|
+
"aria-hidden": true,
|
|
1309
|
+
className: "absolute inset-0",
|
|
1310
|
+
children: unitFractions.map(({ unit, start, width }) => unit.isOff && /* @__PURE__ */ jsx("span", {
|
|
1311
|
+
className: cn("absolute inset-y-0", offDayClassName),
|
|
1312
|
+
style: {
|
|
1313
|
+
insetInlineStart: `${start * 100}%`,
|
|
1314
|
+
width: `${width * 100}%`
|
|
1315
|
+
}
|
|
1316
|
+
}, unit.key))
|
|
1317
|
+
}),
|
|
1318
|
+
/* @__PURE__ */ jsx("div", {
|
|
1319
|
+
className: "flex h-full",
|
|
1320
|
+
children: units.map((unit) => /* @__PURE__ */ jsx("div", {
|
|
1321
|
+
"data-today": unit.isToday || void 0,
|
|
1322
|
+
"data-off": unit.isOff || void 0,
|
|
1323
|
+
className: cn("flex min-w-0 items-center justify-center truncate px-1.5 text-center", "text-muted-foreground", unit.isToday && "font-medium text-primary"),
|
|
1324
|
+
style: { flex: `${unit.weight} 0 0px` },
|
|
1325
|
+
children: unit.isToday ? /* @__PURE__ */ jsx("span", {
|
|
1326
|
+
className: "truncate rounded-full bg-primary/10 px-1.5 py-px",
|
|
1327
|
+
children: unit.label
|
|
1328
|
+
}) : unit.label
|
|
1329
|
+
}, unit.key))
|
|
1330
|
+
}),
|
|
1331
|
+
showUnitLines && unitFractions.slice(1).map(({ unit, start }) => /* @__PURE__ */ jsx("span", {
|
|
1332
|
+
"aria-hidden": true,
|
|
1333
|
+
"data-slot": "gantt-grid-line",
|
|
1334
|
+
"data-axis": "vertical",
|
|
1335
|
+
className: cn("absolute inset-y-0 w-px", gridLines.vertical === "dashed" ? "bg-[repeating-linear-gradient(to_bottom,var(--color-border)_0,var(--color-border)_3px,transparent_3px,transparent_6px)]" : "bg-border"),
|
|
1336
|
+
style: { insetInlineStart: `calc(${start * 100}% - 1px)` }
|
|
1337
|
+
}, unit.key)),
|
|
1338
|
+
viewConfig.nowIndicator && /* @__PURE__ */ jsx(GanttNowDot, {
|
|
1339
|
+
rangeStartMs,
|
|
1340
|
+
rangeEndMs
|
|
1341
|
+
})
|
|
1342
|
+
]
|
|
1343
|
+
})]
|
|
1344
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1345
|
+
className: "relative flex min-h-0 grow flex-col",
|
|
1346
|
+
onPointerDown: beginHeaderPan,
|
|
1347
|
+
children: [
|
|
1348
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1349
|
+
"aria-hidden": true,
|
|
1350
|
+
"data-slot": "gantt-timeline-backdrop",
|
|
1351
|
+
className: "pointer-events-none absolute inset-0",
|
|
1352
|
+
children: [
|
|
1353
|
+
unitFractions.map(({ unit, start, width }) => /* @__PURE__ */ jsxs("span", {
|
|
1354
|
+
className: "contents",
|
|
1355
|
+
children: [unit.isOff && /* @__PURE__ */ jsx("span", {
|
|
1356
|
+
"data-off": "",
|
|
1357
|
+
className: cn("absolute inset-y-0", offDayBodyClassName),
|
|
1358
|
+
style: {
|
|
1359
|
+
insetInlineStart: `${start * 100}%`,
|
|
1360
|
+
width: `${width * 100}%`
|
|
1361
|
+
}
|
|
1362
|
+
}), unit.isToday && scale !== "day" && /* @__PURE__ */ jsx("span", {
|
|
1363
|
+
"data-today": "",
|
|
1364
|
+
className: "absolute inset-y-0 bg-primary/5",
|
|
1365
|
+
style: {
|
|
1366
|
+
insetInlineStart: `${start * 100}%`,
|
|
1367
|
+
width: `${width * 100}%`
|
|
1368
|
+
}
|
|
1369
|
+
})]
|
|
1370
|
+
}, unit.key)),
|
|
1371
|
+
gridLines.vertical !== null && unitFractions.slice(1).map(({ unit, start }) => /* @__PURE__ */ jsx("span", {
|
|
1372
|
+
"data-slot": "gantt-grid-line",
|
|
1373
|
+
"data-axis": "vertical",
|
|
1374
|
+
className: cn("absolute inset-y-0 w-px", gridLines.vertical === "dashed" ? "bg-[repeating-linear-gradient(to_bottom,var(--color-border)_0,var(--color-border)_3px,transparent_3px,transparent_6px)]" : "bg-border"),
|
|
1375
|
+
style: { insetInlineStart: `calc(${start * 100}% - 1px)` }
|
|
1376
|
+
}, `grid-${unit.key}`)),
|
|
1377
|
+
viewConfig.nowIndicator && /* @__PURE__ */ jsx(GanttNowLine, {
|
|
1378
|
+
rangeStartMs,
|
|
1379
|
+
rangeEndMs
|
|
1380
|
+
})
|
|
1381
|
+
]
|
|
1382
|
+
}),
|
|
1383
|
+
rows.map((row, rowIndex) => /* @__PURE__ */ jsx(GanttTimelineRow, {
|
|
1384
|
+
row,
|
|
1385
|
+
rowIndex,
|
|
1386
|
+
bars: rowBars.get(row.resource.id),
|
|
1387
|
+
rangeStartMs,
|
|
1388
|
+
rangeEndMs,
|
|
1389
|
+
trackWidth,
|
|
1390
|
+
trackRemWidth,
|
|
1391
|
+
rowBorder: gridLines.horizontal,
|
|
1392
|
+
selected: selectedSet.has(row.resource.id),
|
|
1393
|
+
resolveHintStop,
|
|
1394
|
+
isPanning,
|
|
1395
|
+
laneHeightRem,
|
|
1396
|
+
laneGapRem,
|
|
1397
|
+
minRowRem
|
|
1398
|
+
}, row.resource.id)),
|
|
1399
|
+
rows.length === 0 && viewConfig.renderNoResources && /* @__PURE__ */ jsx("div", {
|
|
1400
|
+
"data-slot": "gantt-no-resources",
|
|
1401
|
+
className: "flex grow items-center justify-center p-6 text-muted-foreground text-sm",
|
|
1402
|
+
children: viewConfig.renderNoResources()
|
|
1403
|
+
}),
|
|
1404
|
+
showCreateTask && /* @__PURE__ */ jsx("div", {
|
|
1405
|
+
"aria-hidden": true,
|
|
1406
|
+
"data-slot": "gantt-create-task-spacer",
|
|
1407
|
+
className: "h-10 border-b",
|
|
1408
|
+
style: { minWidth: trackWidth }
|
|
1409
|
+
})
|
|
1410
|
+
]
|
|
1411
|
+
})]
|
|
1412
|
+
});
|
|
1413
|
+
const horizontalScrollbar = /* @__PURE__ */ jsx(ScrollBar, {
|
|
1414
|
+
orientation: "horizontal",
|
|
1415
|
+
className: "end-0! z-40 h-4! rounded-none border-t-border! bg-background py-1"
|
|
1416
|
+
});
|
|
1417
|
+
return useRender({
|
|
1418
|
+
defaultTagName: "div",
|
|
1419
|
+
render,
|
|
1420
|
+
props: mergeProps({
|
|
1421
|
+
"data-slot": "gantt-view",
|
|
1422
|
+
"data-scale": scale,
|
|
1423
|
+
"aria-busy": loading || void 0,
|
|
1424
|
+
className: cn("flex min-h-0 flex-1 flex-col overflow-hidden", viewConfig.classNames?.view, className),
|
|
1425
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1426
|
+
ref: bodyRef,
|
|
1427
|
+
className: "relative flex min-h-0 flex-1",
|
|
1428
|
+
children: [
|
|
1429
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1430
|
+
ref: treePaneRef,
|
|
1431
|
+
"data-slot": "gantt-tree-pane",
|
|
1432
|
+
className: "relative h-full shrink-0",
|
|
1433
|
+
style: { width: liveTreeWidthRef.current ?? clampedTreeWidth },
|
|
1434
|
+
children: [
|
|
1435
|
+
customScrollbars ? /* @__PURE__ */ jsxs(ScrollArea$1, {
|
|
1436
|
+
className: "h-full *:data-[orientation=vertical]:hidden",
|
|
1437
|
+
children: [/* @__PURE__ */ jsx(ScrollArea.Content, { children: treeContent }), horizontalScrollbar]
|
|
1438
|
+
}, scale) : /* @__PURE__ */ jsx("div", {
|
|
1439
|
+
"data-slot": "scroll-area-viewport",
|
|
1440
|
+
"data-gantt-native-scroll": "",
|
|
1441
|
+
className: "h-full overflow-x-auto overflow-y-hidden overscroll-contain",
|
|
1442
|
+
children: treeContent
|
|
1443
|
+
}),
|
|
1444
|
+
customScrollbars && /* @__PURE__ */ jsx("div", {
|
|
1445
|
+
"aria-hidden": true,
|
|
1446
|
+
"data-slot": "gantt-tree-scrollbar-rail",
|
|
1447
|
+
className: "pointer-events-none absolute inset-x-0 bottom-0 h-4 border-t border-t-border bg-background"
|
|
1448
|
+
}),
|
|
1449
|
+
reorder && /* @__PURE__ */ jsxs("div", {
|
|
1450
|
+
"data-slot": "gantt-reorder-indicator",
|
|
1451
|
+
"data-invalid": !reorder.valid || void 0,
|
|
1452
|
+
className: "pointer-events-none absolute inset-x-0 flex items-center",
|
|
1453
|
+
style: {
|
|
1454
|
+
top: reorder.top - 4,
|
|
1455
|
+
zIndex: 110
|
|
1456
|
+
},
|
|
1457
|
+
children: [/* @__PURE__ */ jsx("span", { className: cn("ms-0.5 size-0 shrink-0 border-y-4 border-y-transparent border-s-8", reorder.valid ? "border-s-primary" : "border-s-destructive") }), /* @__PURE__ */ jsx("span", { className: cn("h-px min-w-0 flex-1", reorder.valid ? "bg-primary" : "bg-destructive") })]
|
|
1458
|
+
})
|
|
1459
|
+
]
|
|
1460
|
+
}),
|
|
1461
|
+
treeConfig.resizable ? /* @__PURE__ */ jsx("div", {
|
|
1462
|
+
role: "separator",
|
|
1463
|
+
"aria-orientation": "vertical",
|
|
1464
|
+
"aria-label": settings.i18n.labels.resizePanel,
|
|
1465
|
+
"aria-valuenow": Math.round(clampedTreeWidth),
|
|
1466
|
+
"aria-valuemin": Math.round(Math.min(treeConfig.minWidth, clampedTreeWidth)),
|
|
1467
|
+
"aria-valuemax": Math.round(Math.max(treeConfig.maxWidth, clampedTreeWidth)),
|
|
1468
|
+
tabIndex: 0,
|
|
1469
|
+
"data-slot": "gantt-splitter",
|
|
1470
|
+
className: cn("group/gantt-splitter relative z-30 w-px shrink-0 cursor-col-resize touch-none bg-border outline-none hover:bg-primary/60 data-resizing:bg-primary", "focus-visible:ring-2 focus-visible:ring-ring/50", "after:absolute after:inset-y-0 after:-start-1 after:-end-1"),
|
|
1471
|
+
onPointerDown: beginSplit,
|
|
1472
|
+
onDoubleClick: () => {
|
|
1473
|
+
setTreeWidth(treeConfig.width);
|
|
1474
|
+
treeConfig.onWidthChange?.(treeConfig.width);
|
|
1475
|
+
},
|
|
1476
|
+
onKeyDown: (e) => {
|
|
1477
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
1478
|
+
e.preventDefault();
|
|
1479
|
+
const dir = getComputedStyle(e.currentTarget).direction === "rtl" ? -1 : 1;
|
|
1480
|
+
const delta = (e.key === "ArrowLeft" ? -16 : 16) * dir;
|
|
1481
|
+
const next = clampTree(clampedTreeWidth + delta);
|
|
1482
|
+
setTreeWidth(next);
|
|
1483
|
+
treeConfig.onWidthChange?.(next);
|
|
1484
|
+
}
|
|
1485
|
+
},
|
|
1486
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1487
|
+
"aria-hidden": true,
|
|
1488
|
+
"data-slot": "gantt-splitter-grip",
|
|
1489
|
+
className: "absolute top-1/2 left-1/2 h-6 w-0.75 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary/60 opacity-0 transition-opacity duration-150 group-hover/gantt-splitter:opacity-100 group-focus-visible/gantt-splitter:opacity-100 group-data-resizing/gantt-splitter:bg-primary group-data-resizing/gantt-splitter:opacity-100"
|
|
1490
|
+
})
|
|
1491
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
1492
|
+
"aria-hidden": true,
|
|
1493
|
+
className: "w-px shrink-0 bg-border"
|
|
1494
|
+
}),
|
|
1495
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1496
|
+
ref: timelinePaneRef,
|
|
1497
|
+
"data-slot": "gantt-timeline-pane",
|
|
1498
|
+
className: "relative h-full min-w-0 flex-1",
|
|
1499
|
+
children: [
|
|
1500
|
+
viewConfig.zoomControl && /* @__PURE__ */ jsx("div", {
|
|
1501
|
+
"data-slot": "gantt-zoom",
|
|
1502
|
+
className: "absolute end-3 bottom-5 z-40 flex flex-col rounded-md border bg-background shadow-sm",
|
|
1503
|
+
children: /* @__PURE__ */ jsxs(TooltipProvider, {
|
|
1504
|
+
delay: 600,
|
|
1505
|
+
closeDelay: 0,
|
|
1506
|
+
timeout: 300,
|
|
1507
|
+
children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
1508
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
1509
|
+
variant: "ghost",
|
|
1510
|
+
size: "icon-xs",
|
|
1511
|
+
"aria-label": settings.i18n.labels.zoomIn,
|
|
1512
|
+
"aria-disabled": !canZoomIn || void 0,
|
|
1513
|
+
className: "size-5! rounded-b-none text-muted-foreground hover:text-foreground aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent",
|
|
1514
|
+
onClick: () => {
|
|
1515
|
+
if (!canZoomIn) return;
|
|
1516
|
+
if (viewConfig.zoom === void 0) anchorZoomCenter();
|
|
1517
|
+
setZoomValue(+(zoom + (zoomRange.step ?? .25)).toFixed(2));
|
|
1518
|
+
}
|
|
1519
|
+
}),
|
|
1520
|
+
children: /* @__PURE__ */ jsx(PlusIcon, {
|
|
1521
|
+
className: "size-3",
|
|
1522
|
+
"aria-hidden": "true"
|
|
1523
|
+
})
|
|
1524
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
1525
|
+
side: "left",
|
|
1526
|
+
children: settings.i18n.labels.zoomIn
|
|
1527
|
+
})] }), /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
1528
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
1529
|
+
variant: "ghost",
|
|
1530
|
+
size: "icon-xs",
|
|
1531
|
+
"aria-label": settings.i18n.labels.zoomOut,
|
|
1532
|
+
"aria-disabled": !canZoomOut || void 0,
|
|
1533
|
+
className: "size-5! rounded-t-none border-t text-muted-foreground hover:text-foreground aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent",
|
|
1534
|
+
onClick: () => {
|
|
1535
|
+
if (!canZoomOut) return;
|
|
1536
|
+
if (viewConfig.zoom === void 0) anchorZoomCenter();
|
|
1537
|
+
setZoomValue(+(zoom - (zoomRange.step ?? .25)).toFixed(2));
|
|
1538
|
+
}
|
|
1539
|
+
}),
|
|
1540
|
+
children: /* @__PURE__ */ jsx(MinusIcon, {
|
|
1541
|
+
className: "size-3",
|
|
1542
|
+
"aria-hidden": "true"
|
|
1543
|
+
})
|
|
1544
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
1545
|
+
side: "left",
|
|
1546
|
+
children: settings.i18n.labels.zoomOut
|
|
1547
|
+
})] })]
|
|
1548
|
+
})
|
|
1549
|
+
}),
|
|
1550
|
+
customScrollbars ? /* @__PURE__ */ jsxs(ScrollArea$1, {
|
|
1551
|
+
className: "h-full *:data-[orientation=vertical]:top-[65px]! *:data-[orientation=vertical]:bottom-4! *:data-[orientation=vertical]:h-auto!",
|
|
1552
|
+
children: [/* @__PURE__ */ jsx(ScrollArea.Content, {
|
|
1553
|
+
className: "flex min-h-full flex-col",
|
|
1554
|
+
children: timelineContent
|
|
1555
|
+
}), horizontalScrollbar]
|
|
1556
|
+
}, scale) : /* @__PURE__ */ jsx("div", {
|
|
1557
|
+
"data-slot": "scroll-area-viewport",
|
|
1558
|
+
"data-gantt-native-scroll": "",
|
|
1559
|
+
className: "h-full overflow-auto overscroll-contain",
|
|
1560
|
+
children: timelineContent
|
|
1561
|
+
}),
|
|
1562
|
+
customScrollbars && /* @__PURE__ */ jsx("div", {
|
|
1563
|
+
"aria-hidden": true,
|
|
1564
|
+
"data-slot": "gantt-timeline-scrollbar-rail",
|
|
1565
|
+
className: "pointer-events-none absolute inset-x-0 bottom-0 h-4 border-t border-t-border bg-background"
|
|
1566
|
+
}),
|
|
1567
|
+
viewConfig.offscreenIndicators && /* @__PURE__ */ jsx(GanttOffscreenChips, {
|
|
1568
|
+
paneRef: timelinePaneRef,
|
|
1569
|
+
locale: settings.locale,
|
|
1570
|
+
refreshKey: `${scale}:${rangeKey}:${zoom}:${rows.length}:${clampedTreeWidth}:${viewConfig.scrollbars}`
|
|
1571
|
+
})
|
|
1572
|
+
]
|
|
1573
|
+
}),
|
|
1574
|
+
loading && /* @__PURE__ */ jsx("div", {
|
|
1575
|
+
"data-slot": "gantt-loading",
|
|
1576
|
+
className: "absolute inset-0 z-50 flex items-center justify-center bg-background/60",
|
|
1577
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1578
|
+
className: "animate-pulse text-muted-foreground text-sm",
|
|
1579
|
+
children: settings.i18n.labels.loading
|
|
1580
|
+
})
|
|
1581
|
+
}),
|
|
1582
|
+
(viewConfig.renderDragPreview || viewConfig.renderResizeIndicator) && /* @__PURE__ */ jsx(GanttCustomDragLayer, {})
|
|
1583
|
+
]
|
|
1584
|
+
})
|
|
1585
|
+
}, props)
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* The red now-line, self-ticking: only this component re-renders on the 30s
|
|
1590
|
+
* clock, never the grid around it. z-10 keeps it above row content but UNDER
|
|
1591
|
+
* the sticky header (z-30) - vertical scrolling slides it beneath, never over.
|
|
1592
|
+
*/
|
|
1593
|
+
function GanttNowLine({ rangeStartMs, rangeEndMs }) {
|
|
1594
|
+
const ms = useNow().getTime();
|
|
1595
|
+
if (ms < rangeStartMs || ms >= rangeEndMs) return null;
|
|
1596
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1597
|
+
"data-slot": "gantt-now-indicator",
|
|
1598
|
+
className: "absolute inset-y-0 z-10 w-px bg-linear-to-b from-destructive/80 via-destructive/45 to-destructive/15",
|
|
1599
|
+
style: { insetInlineStart: `${(ms - rangeStartMs) / (rangeEndMs - rangeStartMs) * 100}%` }
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* The now-line's dot cap, pinned INSIDE the sticky header at the header/body
|
|
1604
|
+
* boundary: it stays put while the line scrolls beneath the header.
|
|
1605
|
+
*/
|
|
1606
|
+
function GanttNowDot({ rangeStartMs, rangeEndMs }) {
|
|
1607
|
+
const ms = useNow().getTime();
|
|
1608
|
+
if (ms < rangeStartMs || ms >= rangeEndMs) return null;
|
|
1609
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1610
|
+
"aria-hidden": true,
|
|
1611
|
+
"data-slot": "gantt-now-dot",
|
|
1612
|
+
className: "absolute -bottom-0.75 z-10 size-1.5 -translate-x-1/2 rounded-full bg-destructive",
|
|
1613
|
+
style: { insetInlineStart: `${(ms - rangeStartMs) / (rangeEndMs - rangeStartMs) * 100}%` }
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Consumer-owned drag/resize indicators (renderDragPreview /
|
|
1618
|
+
* renderResizeIndicator): content is React and re-renders per snap step from
|
|
1619
|
+
* drag state; the dnd engine adopts this wrapper and writes its
|
|
1620
|
+
* cursor-tracking transform imperatively, flipping visibility on the first
|
|
1621
|
+
* positioned frame so nothing flashes at the viewport origin.
|
|
1622
|
+
*/
|
|
1623
|
+
function GanttCustomDragLayer() {
|
|
1624
|
+
const viewConfig = useGanttViewConfig();
|
|
1625
|
+
const drag = useGanttSelector((state) => state.drag);
|
|
1626
|
+
if (!drag) return null;
|
|
1627
|
+
const render = drag.kind === "move" ? viewConfig.renderDragPreview : viewConfig.renderResizeIndicator;
|
|
1628
|
+
if (!render) return null;
|
|
1629
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1630
|
+
"data-slot": drag.kind === "move" ? "gantt-drag-overlay" : "gantt-resize-indicator",
|
|
1631
|
+
"data-custom": "",
|
|
1632
|
+
className: "pointer-events-none fixed top-0 left-0 z-100 will-change-transform",
|
|
1633
|
+
style: { visibility: "hidden" },
|
|
1634
|
+
children: render({
|
|
1635
|
+
occurrence: drag.occurrence,
|
|
1636
|
+
kind: drag.kind,
|
|
1637
|
+
start: drag.proposedStart,
|
|
1638
|
+
end: drag.proposedEnd,
|
|
1639
|
+
valid: drag.valid
|
|
1640
|
+
})
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
/** Memoized: only rows whose props actually changed re-render. */
|
|
1644
|
+
const GanttTreeRow = memo(function GanttTreeRow({ row, heightRem, bandRem, columns, nameWidth, dimmed, selected, onSelectedChange, onGripPointerDown, onToggle }) {
|
|
1645
|
+
const settings = useGanttSettings();
|
|
1646
|
+
const viewConfig = useGanttViewConfig();
|
|
1647
|
+
const ctx = {
|
|
1648
|
+
resource: row.resource,
|
|
1649
|
+
depth: row.depth,
|
|
1650
|
+
isGroup: row.isGroup,
|
|
1651
|
+
collapsed: row.collapsed
|
|
1652
|
+
};
|
|
1653
|
+
const menu = viewConfig.renderResourceMenu?.(ctx);
|
|
1654
|
+
const alignStart = (viewConfig.rowAlign ?? "start") === "start";
|
|
1655
|
+
const rowNode = /* @__PURE__ */ jsx("div", {
|
|
1656
|
+
"data-slot": "gantt-row-group",
|
|
1657
|
+
"data-gantt-row-id": row.resource.id,
|
|
1658
|
+
"data-selected": selected || void 0,
|
|
1659
|
+
className: cn("group/gantt-row flex border-b data-selected:data-hover:bg-primary/5 data-hover:bg-muted/40 data-selected:bg-primary/5", dimmed && "opacity-50"),
|
|
1660
|
+
style: { height: `${heightRem}rem` },
|
|
1661
|
+
onClick: settings.onResourceClick ? (e) => {
|
|
1662
|
+
if (e.target.closest("button, [role=checkbox]")) return;
|
|
1663
|
+
settings.onResourceClick?.(ctx, e);
|
|
1664
|
+
} : void 0,
|
|
1665
|
+
onDoubleClick: settings.onResourceDoubleClick ? (e) => {
|
|
1666
|
+
if (e.target.closest("button, [role=checkbox]")) return;
|
|
1667
|
+
settings.onResourceDoubleClick?.(ctx, e);
|
|
1668
|
+
} : void 0,
|
|
1669
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1670
|
+
className: "flex h-full w-full min-w-0",
|
|
1671
|
+
children: [
|
|
1672
|
+
/* @__PURE__ */ jsx("div", {
|
|
1673
|
+
"data-slot": "gantt-tree-cell",
|
|
1674
|
+
className: cn("flex shrink-0 ps-3 pe-3", alignStart ? "items-start" : "items-center", row.isGroup && "font-medium"),
|
|
1675
|
+
style: { width: nameWidth },
|
|
1676
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1677
|
+
className: "flex w-full min-w-0 items-center",
|
|
1678
|
+
style: { height: `${bandRem}rem` },
|
|
1679
|
+
children: [
|
|
1680
|
+
onGripPointerDown && /* @__PURE__ */ jsx("button", {
|
|
1681
|
+
type: "button",
|
|
1682
|
+
"data-slot": "gantt-row-grip",
|
|
1683
|
+
"aria-label": settings.i18n.labels.reorder,
|
|
1684
|
+
className: "-ms-1.5 me-1.5 flex w-3.5 shrink-0 cursor-grab touch-none items-center justify-center text-muted-foreground/60 opacity-0 pointer-coarse:opacity-100 hover:text-foreground focus-visible:opacity-100 group-hover/gantt-row:opacity-100 group-data-hover/gantt-row:opacity-100",
|
|
1685
|
+
onPointerDown: (e) => onGripPointerDown(e, row),
|
|
1686
|
+
onClick: (e) => e.stopPropagation(),
|
|
1687
|
+
children: /* @__PURE__ */ jsx(GripVerticalIcon, {
|
|
1688
|
+
className: "size-3",
|
|
1689
|
+
"aria-hidden": "true"
|
|
1690
|
+
})
|
|
1691
|
+
}),
|
|
1692
|
+
/* @__PURE__ */ jsx("span", {
|
|
1693
|
+
"aria-hidden": true,
|
|
1694
|
+
className: "shrink-0",
|
|
1695
|
+
style: { width: `${row.depth * .875}rem` }
|
|
1696
|
+
}),
|
|
1697
|
+
/* @__PURE__ */ jsx("span", {
|
|
1698
|
+
className: "me-1 flex w-5 shrink-0 items-center justify-start",
|
|
1699
|
+
children: row.isGroup ? /* @__PURE__ */ jsx(Button, {
|
|
1700
|
+
variant: "ghost",
|
|
1701
|
+
size: "icon-xs",
|
|
1702
|
+
"aria-expanded": !row.collapsed,
|
|
1703
|
+
"aria-label": row.resource.title,
|
|
1704
|
+
className: cn("size-5! aria-expanded:bg-transparent!", row.collapsed ? "text-foreground" : "text-muted-foreground hover:text-foreground! aria-expanded:text-muted-foreground!"),
|
|
1705
|
+
onClick: () => onToggle(row),
|
|
1706
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
1707
|
+
className: cn("size-3.5 transition-transform", !row.collapsed && "rotate-90"),
|
|
1708
|
+
"aria-hidden": "true"
|
|
1709
|
+
})
|
|
1710
|
+
}) : viewConfig.rowCheckboxes && onSelectedChange && /* @__PURE__ */ jsx(Checkbox, {
|
|
1711
|
+
"data-slot": "gantt-row-checkbox",
|
|
1712
|
+
checked: selected,
|
|
1713
|
+
onCheckedChange: (checked) => onSelectedChange(row.resource.id, checked),
|
|
1714
|
+
"aria-label": row.resource.title,
|
|
1715
|
+
className: cn("size-3.5 opacity-0 transition-opacity focus-visible:opacity-100 group-hover/gantt-row:opacity-100 group-data-hover/gantt-row:opacity-100", selected && "opacity-100")
|
|
1716
|
+
})
|
|
1717
|
+
}),
|
|
1718
|
+
viewConfig.renderResourceLabel?.(ctx) ?? /* @__PURE__ */ jsx("span", {
|
|
1719
|
+
className: "truncate",
|
|
1720
|
+
children: row.resource.title
|
|
1721
|
+
})
|
|
1722
|
+
]
|
|
1723
|
+
})
|
|
1724
|
+
}),
|
|
1725
|
+
columns.map((column) => /* @__PURE__ */ jsx("div", {
|
|
1726
|
+
"data-slot": "gantt-tree-column-cell",
|
|
1727
|
+
"data-column": column.id,
|
|
1728
|
+
className: cn("flex shrink-0 px-2", alignStart ? "items-start" : "items-center", column.className),
|
|
1729
|
+
style: { width: column.width ?? DEFAULT_COLUMN_WIDTH },
|
|
1730
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1731
|
+
className: cn("flex w-full min-w-0 items-center", column.align === "center" && "justify-center", column.align === "end" && "justify-end"),
|
|
1732
|
+
style: { height: `${bandRem}rem` },
|
|
1733
|
+
children: column.render?.(ctx)
|
|
1734
|
+
})
|
|
1735
|
+
}, column.id)),
|
|
1736
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1" })
|
|
1737
|
+
]
|
|
1738
|
+
})
|
|
1739
|
+
});
|
|
1740
|
+
if (!menu) return rowNode;
|
|
1741
|
+
return /* @__PURE__ */ jsxs(ContextMenu, { children: [/* @__PURE__ */ jsx(ContextMenuTrigger, { render: rowNode }), /* @__PURE__ */ jsx(ContextMenuContent, {
|
|
1742
|
+
"data-slot": "gantt-resource-menu",
|
|
1743
|
+
className: "min-w-44",
|
|
1744
|
+
children: menu
|
|
1745
|
+
})] });
|
|
1746
|
+
});
|
|
1747
|
+
const GanttTimelineRow = memo(function GanttTimelineRow({ row, rowIndex, bars, rangeStartMs, rangeEndMs, trackWidth, trackRemWidth, rowBorder, selected, resolveHintStop, isPanning, laneHeightRem, laneGapRem, minRowRem }) {
|
|
1748
|
+
const instance = useGantt();
|
|
1749
|
+
const settings = useGanttSettings();
|
|
1750
|
+
const viewConfig = useGanttViewConfig();
|
|
1751
|
+
const gestures = useGanttGestures();
|
|
1752
|
+
const segments = bars?.segments ?? [];
|
|
1753
|
+
const schedulable = !row.isGroup || viewConfig.parentScheduling;
|
|
1754
|
+
const heightRem = bars?.heightRem ?? minRowRem;
|
|
1755
|
+
const laneCount = bars?.laneCount ?? 1;
|
|
1756
|
+
const singleTrack = resolveScheduleMode(row.resource, viewConfig.scheduleMode) === "single";
|
|
1757
|
+
const laneOffsetRem = bars?.laneOffsetRem ?? (minRowRem - laneHeightRem) / 2;
|
|
1758
|
+
const [hintStop, setHintStop] = useState(null);
|
|
1759
|
+
const hintSuppressed = useGanttSelector((state) => hintStop !== null && (state.drag !== null || state.slotDraft !== null));
|
|
1760
|
+
const canSchedule = useGanttSelector((state) => state.interactions.selectSlot);
|
|
1761
|
+
const hintFreeLane = hintStop ? lowestFreeLane(segments, hintStop.ms, hintStop.endMs) : 0;
|
|
1762
|
+
const hintLane = bars?.scheduleMode === "single" ? 0 : hintFreeLane;
|
|
1763
|
+
const hintTopRem = Math.min(laneOffsetRem + hintLane * (laneHeightRem + laneGapRem) + laneHeightRem / 2, Math.max(heightRem - laneHeightRem / 2, laneHeightRem / 2));
|
|
1764
|
+
const hintVisible = hintStop !== null && hintFreeLane < laneCount && !hintSuppressed && !isPanning;
|
|
1765
|
+
const hintLabel = viewConfig.dragCreate ? settings.i18n.labels.scheduleHintDrag : settings.i18n.labels.scheduleHint;
|
|
1766
|
+
const showHint = viewConfig.displayScheduleHint && schedulable && canSchedule && !isPanning && !!(settings.onSelectSlot || settings.onSlotClick);
|
|
1767
|
+
const fractionOf = (ms) => Math.min(Math.max((ms - rangeStartMs) / (rangeEndMs - rangeStartMs), 0), 1);
|
|
1768
|
+
const dragTarget = useGanttSelector((state) => {
|
|
1769
|
+
const drag = state.drag;
|
|
1770
|
+
if (!drag || drag.proposedResourceId !== row.resource.id) return null;
|
|
1771
|
+
return drag.valid ? "valid" : "invalid";
|
|
1772
|
+
});
|
|
1773
|
+
const ghost = useGanttSelector((state) => {
|
|
1774
|
+
const drag = state.drag;
|
|
1775
|
+
if (!drag || drag.proposedResourceId !== row.resource.id) return null;
|
|
1776
|
+
return {
|
|
1777
|
+
from: fractionOf(drag.proposedStart.getTime()),
|
|
1778
|
+
to: fractionOf(drag.proposedEnd.getTime()),
|
|
1779
|
+
color: drag.occurrence.event.color,
|
|
1780
|
+
valid: drag.valid,
|
|
1781
|
+
title: drag.occurrence.event.title,
|
|
1782
|
+
kind: drag.kind,
|
|
1783
|
+
occurrenceKey: drag.occurrence.key
|
|
1784
|
+
};
|
|
1785
|
+
}, { isEqual: (a, b) => a === b || a !== null && b !== null && a.from === b.from && a.to === b.to && a.valid === b.valid });
|
|
1786
|
+
const draft = useGanttSelector((state) => {
|
|
1787
|
+
const slotDraft = state.slotDraft;
|
|
1788
|
+
if (!slotDraft || slotDraft.resourceId !== row.resource.id) return null;
|
|
1789
|
+
const startMs = slotDraft.start.getTime();
|
|
1790
|
+
const endMs = slotDraft.end.getTime();
|
|
1791
|
+
return {
|
|
1792
|
+
from: fractionOf(startMs),
|
|
1793
|
+
to: fractionOf(endMs),
|
|
1794
|
+
startMs,
|
|
1795
|
+
endMs
|
|
1796
|
+
};
|
|
1797
|
+
}, { isEqual: (a, b) => a === b || a !== null && b !== null && a.startMs === b.startMs && a.endMs === b.endMs && a.from === b.from && a.to === b.to });
|
|
1798
|
+
/**
|
|
1799
|
+
* Where the schedule being painted will land - resolved in the shared layout
|
|
1800
|
+
* memo, which also RESERVES that track, so the row has already grown to hold
|
|
1801
|
+
* it. The clamp is only a backstop for the frame between a draft appearing
|
|
1802
|
+
* and the layout catching up.
|
|
1803
|
+
*/
|
|
1804
|
+
const draftLane = bars?.draftLane ?? 0;
|
|
1805
|
+
const draftTopRem = Math.min(laneOffsetRem + draftLane * (laneHeightRem + laneGapRem), Math.max(heightRem - laneHeightRem, 0));
|
|
1806
|
+
const draftLabel = draft ? settings.i18n.functions.formatEventTime(toZoned(new Date(draft.startMs), settings.timeZone), toZoned(new Date(draft.endMs), settings.timeZone), false, settings.locale) : "";
|
|
1807
|
+
/**
|
|
1808
|
+
* The row's create contract, in one place: onSlotClick if the consumer
|
|
1809
|
+
* wired it, else a ready-made slot draft. Both the hint tile and a plain
|
|
1810
|
+
* click on bare track go through this, so clicking anywhere placeable
|
|
1811
|
+
* behaves the same as clicking the tile.
|
|
1812
|
+
*/
|
|
1813
|
+
const createAt = (stop, e) => {
|
|
1814
|
+
if (settings.onSlotClick) settings.onSlotClick({
|
|
1815
|
+
date: new Date(stop.ms),
|
|
1816
|
+
allDay: false,
|
|
1817
|
+
resourceId: row.resource.id
|
|
1818
|
+
}, e);
|
|
1819
|
+
else settings.onSelectSlot?.({
|
|
1820
|
+
start: new Date(stop.ms),
|
|
1821
|
+
end: new Date(Math.max(stop.endMs, stop.ms + 1)),
|
|
1822
|
+
allDay: false,
|
|
1823
|
+
resourceId: row.resource.id
|
|
1824
|
+
});
|
|
1825
|
+
};
|
|
1826
|
+
const ghostLaneOffsetRem = laneOffsetRem + (ghost ? segments.find((segment) => segment.occurrence.key === ghost.occurrenceKey)?.column ?? 0 : 0) * (laneHeightRem + laneGapRem) + (laneHeightRem - GHOST_HEIGHT_REM) / 2;
|
|
1827
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1828
|
+
"data-gantt-row": "",
|
|
1829
|
+
"data-gantt-resource": row.resource.id,
|
|
1830
|
+
"data-gantt-row-id": row.resource.id,
|
|
1831
|
+
"data-gantt-row-static": !schedulable || void 0,
|
|
1832
|
+
"data-gantt-bar-min": bars?.extent?.from,
|
|
1833
|
+
"data-gantt-bar-max": bars?.extent?.to,
|
|
1834
|
+
"data-gantt-bar-color": bars?.extent?.color,
|
|
1835
|
+
"data-gantt-bar-label": bars?.extent?.label,
|
|
1836
|
+
"data-gantt-bar-start-ms": bars?.extent?.startMs,
|
|
1837
|
+
"data-drop-target": dragTarget ?? void 0,
|
|
1838
|
+
"data-selected": selected || void 0,
|
|
1839
|
+
className: cn("relative w-full min-w-0 data-selected:data-hover:bg-primary/5 data-hover:bg-muted/30 data-selected:bg-primary/5", hintVisible && "cursor-crosshair", rowBorder !== null && "border-b", rowBorder === "dashed" && "border-dashed", dragTarget === "valid" && "bg-muted/40", dragTarget === "invalid" && "bg-destructive/10"),
|
|
1840
|
+
style: {
|
|
1841
|
+
height: `${heightRem}rem`,
|
|
1842
|
+
minWidth: trackWidth
|
|
1843
|
+
},
|
|
1844
|
+
onPointerDown: (e) => {
|
|
1845
|
+
if (viewConfig.dragCreate && e.button === 0 && schedulable && canSchedule && (e.target === e.currentTarget || !!e.target.closest?.("[data-slot=gantt-schedule-hint]")) && settings.onSelectSlot) {
|
|
1846
|
+
const stop = resolveHintStop(trackFraction(e.currentTarget, e.clientX));
|
|
1847
|
+
if (!(stop !== null && (settings.canSelectSlot?.({
|
|
1848
|
+
start: new Date(stop.ms),
|
|
1849
|
+
end: new Date(Math.max(stop.endMs, stop.ms + 1)),
|
|
1850
|
+
allDay: false,
|
|
1851
|
+
resourceId: row.resource.id
|
|
1852
|
+
}) ?? true))) return;
|
|
1853
|
+
e.stopPropagation();
|
|
1854
|
+
gestures.beginCreate(e);
|
|
1855
|
+
}
|
|
1856
|
+
},
|
|
1857
|
+
onPointerMove: (e) => {
|
|
1858
|
+
const interacting = instance.getState().drag !== null || instance.getState().slotDraft !== null;
|
|
1859
|
+
if (!showHint || e.pointerType !== "mouse" || interacting) {
|
|
1860
|
+
if (hintStop) setHintStop(null);
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
if (e.target !== e.currentTarget) {
|
|
1864
|
+
if (hintStop) setHintStop(null);
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
const { fraction, offset } = trackPoint(e.currentTarget, e.clientX);
|
|
1868
|
+
e.currentTarget.style.setProperty("--gantt-hint-x", `${offset}px`);
|
|
1869
|
+
const stop = resolveHintStop(fraction);
|
|
1870
|
+
const next = stop !== null && (settings.canSelectSlot?.({
|
|
1871
|
+
start: new Date(stop.ms),
|
|
1872
|
+
end: new Date(Math.max(stop.endMs, stop.ms + 1)),
|
|
1873
|
+
allDay: false,
|
|
1874
|
+
resourceId: row.resource.id
|
|
1875
|
+
}) ?? true) ? stop : null;
|
|
1876
|
+
if (next?.index !== hintStop?.index) setHintStop(next);
|
|
1877
|
+
},
|
|
1878
|
+
onPointerLeave: () => {
|
|
1879
|
+
if (hintStop) setHintStop(null);
|
|
1880
|
+
},
|
|
1881
|
+
onClick: (e) => {
|
|
1882
|
+
if (!viewConfig.dragCreate || e.target !== e.currentTarget) return;
|
|
1883
|
+
if (!schedulable || !canSchedule) return;
|
|
1884
|
+
if (wasRecentDrag()) return;
|
|
1885
|
+
if (!settings.onSlotClick && !settings.onSelectSlot) return;
|
|
1886
|
+
const stop = resolveHintStop(trackFraction(e.currentTarget, e.clientX));
|
|
1887
|
+
if (!stop) return;
|
|
1888
|
+
if (!(settings.canSelectSlot?.({
|
|
1889
|
+
start: new Date(stop.ms),
|
|
1890
|
+
end: new Date(Math.max(stop.endMs, stop.ms + 1)),
|
|
1891
|
+
allDay: false,
|
|
1892
|
+
resourceId: row.resource.id
|
|
1893
|
+
}) ?? true)) return;
|
|
1894
|
+
createAt(stop, e);
|
|
1895
|
+
setHintStop(null);
|
|
1896
|
+
},
|
|
1897
|
+
children: [
|
|
1898
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1899
|
+
className: "pointer-events-none absolute inset-0",
|
|
1900
|
+
style: { contentVisibility: "auto" },
|
|
1901
|
+
children: [
|
|
1902
|
+
segments.map((segment, segmentIndex) => {
|
|
1903
|
+
const from = fractionOf(rangeStartMs + (segment.startMin ?? 0) * 6e4);
|
|
1904
|
+
const to = fractionOf(rangeStartMs + (segment.endMin ?? 0) * 6e4);
|
|
1905
|
+
if (to <= from) return null;
|
|
1906
|
+
const lane = segment.column ?? 0;
|
|
1907
|
+
const barRemWidth = (to - from) * trackRemWidth;
|
|
1908
|
+
const placement = !(viewConfig.barLabel === "outside" || viewConfig.barLabel === "auto" && barRemWidth < (viewConfig.metrics?.autoLabelMin ?? AUTO_LABEL_MIN_REM)) ? "inside" : to <= .92 ? "after" : from >= .08 ? "before" : "inside";
|
|
1909
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1910
|
+
"data-drag-kind": ghost && ghost.occurrenceKey === segment.occurrence.key ? ghost.kind : void 0,
|
|
1911
|
+
"data-lane": lane,
|
|
1912
|
+
"data-lane-count": laneCount,
|
|
1913
|
+
className: "group/gantt-seg pointer-events-auto absolute px-px data-[drag-kind=move]:opacity-0",
|
|
1914
|
+
style: {
|
|
1915
|
+
insetInlineStart: `${from * 100}%`,
|
|
1916
|
+
width: `${Math.max((to - from) * 100, .5)}%`,
|
|
1917
|
+
top: `${laneOffsetRem + lane * (laneHeightRem + laneGapRem)}rem`,
|
|
1918
|
+
height: `${laneHeightRem}rem`,
|
|
1919
|
+
zIndex: segment.occurrence.event.zIndex ?? 10 + (singleTrack ? segmentIndex : lane)
|
|
1920
|
+
},
|
|
1921
|
+
children: [/* @__PURE__ */ jsx(GanttBar, {
|
|
1922
|
+
segment,
|
|
1923
|
+
labelOutside: placement !== "inside",
|
|
1924
|
+
rowTitle: row.resource.title,
|
|
1925
|
+
className: "h-full"
|
|
1926
|
+
}), placement !== "inside" && /* @__PURE__ */ jsx("span", {
|
|
1927
|
+
"data-slot": "gantt-bar-label",
|
|
1928
|
+
"data-placement": placement,
|
|
1929
|
+
className: cn("pointer-events-none absolute top-1/2 z-10 max-w-60 -translate-y-1/2 truncate font-medium text-foreground", "group-data-[drag-kind^=resize]/gantt-seg:opacity-0", placement === "after" ? "start-full ms-2" : "end-full me-2"),
|
|
1930
|
+
children: segment.occurrence.event.title
|
|
1931
|
+
})]
|
|
1932
|
+
}, segment.occurrence.key);
|
|
1933
|
+
}),
|
|
1934
|
+
bars?.summary && segments.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
1935
|
+
"data-slot": "gantt-summary",
|
|
1936
|
+
"aria-hidden": true,
|
|
1937
|
+
className: "pointer-events-none absolute top-1/2 -translate-y-1/2",
|
|
1938
|
+
style: {
|
|
1939
|
+
insetInlineStart: `${bars.summary.from * 100}%`,
|
|
1940
|
+
width: `${Math.max((bars.summary.to - bars.summary.from) * 100, .5)}%`
|
|
1941
|
+
},
|
|
1942
|
+
children: viewConfig.renderSummary ? viewConfig.renderSummary({
|
|
1943
|
+
resource: row.resource,
|
|
1944
|
+
start: new Date(rangeStartMs + bars.summary.from * (rangeEndMs - rangeStartMs)),
|
|
1945
|
+
end: new Date(rangeStartMs + bars.summary.to * (rangeEndMs - rangeStartMs)),
|
|
1946
|
+
progress: bars.summary.progress
|
|
1947
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1948
|
+
/* @__PURE__ */ jsx("span", {
|
|
1949
|
+
"aria-hidden": true,
|
|
1950
|
+
className: "absolute start-0 top-1/2 h-3 w-0.5 -translate-y-1/2 rounded-full bg-muted-foreground/50"
|
|
1951
|
+
}),
|
|
1952
|
+
/* @__PURE__ */ jsx("span", {
|
|
1953
|
+
"aria-hidden": true,
|
|
1954
|
+
className: "absolute end-0 top-1/2 h-3 w-0.5 -translate-y-1/2 rounded-full bg-muted-foreground/50"
|
|
1955
|
+
}),
|
|
1956
|
+
/* @__PURE__ */ jsx("div", {
|
|
1957
|
+
className: "relative h-1.5 overflow-hidden rounded-full bg-muted-foreground/20",
|
|
1958
|
+
children: bars.summary.progress !== null && /* @__PURE__ */ jsx("div", {
|
|
1959
|
+
"data-slot": "gantt-summary-progress",
|
|
1960
|
+
className: "absolute inset-y-0 start-0 rounded-full bg-muted-foreground/50",
|
|
1961
|
+
style: { width: `${bars.summary.progress}%` }
|
|
1962
|
+
})
|
|
1963
|
+
}),
|
|
1964
|
+
bars.summary.progress !== null && /* @__PURE__ */ jsxs("span", {
|
|
1965
|
+
className: "absolute start-full top-1/2 ms-2 -translate-y-1/2 whitespace-nowrap text-muted-foreground",
|
|
1966
|
+
children: [bars.summary.progress, "%"]
|
|
1967
|
+
})
|
|
1968
|
+
] })
|
|
1969
|
+
}),
|
|
1970
|
+
ghost && /* @__PURE__ */ jsx("div", {
|
|
1971
|
+
"data-slot": "gantt-drag-ghost",
|
|
1972
|
+
"data-kind": ghost.kind,
|
|
1973
|
+
"data-drop-invalid": !ghost.valid || void 0,
|
|
1974
|
+
className: cn("pointer-events-none absolute z-40 h-5 rounded-sm border border-dashed font-medium", !ghost.valid && "border-destructive bg-destructive/10 text-destructive", ghost.valid && ghost.kind === "move" && "border-(--gantt-event-color)/50 bg-(--gantt-event-color)/8", ghost.valid && ghost.kind !== "move" && "border-(--gantt-event-color)/70 bg-(--gantt-event-color)/22 text-foreground"),
|
|
1975
|
+
style: {
|
|
1976
|
+
insetInlineStart: `${ghost.from * 100}%`,
|
|
1977
|
+
width: `${Math.max((ghost.to - ghost.from) * 100, .5)}%`,
|
|
1978
|
+
top: `${ghostLaneOffsetRem}rem`,
|
|
1979
|
+
"--gantt-event-color": ghost.color ?? "var(--color-primary)"
|
|
1980
|
+
},
|
|
1981
|
+
children: ghost.kind !== "move" && /* @__PURE__ */ jsx("span", {
|
|
1982
|
+
className: "pointer-events-none absolute start-full top-1/2 ms-2 max-w-60 -translate-y-1/2 truncate whitespace-nowrap",
|
|
1983
|
+
children: ghost.title
|
|
1984
|
+
})
|
|
1985
|
+
}),
|
|
1986
|
+
draft && /* @__PURE__ */ jsx("div", {
|
|
1987
|
+
"data-slot": "gantt-slot-draft",
|
|
1988
|
+
"data-lane": draftLane,
|
|
1989
|
+
className: "pointer-events-none absolute z-40 overflow-hidden rounded-sm border border-primary border-dashed bg-background",
|
|
1990
|
+
style: {
|
|
1991
|
+
insetInlineStart: `${draft.from * 100}%`,
|
|
1992
|
+
width: `${Math.max((draft.to - draft.from) * 100, .5)}%`,
|
|
1993
|
+
top: `${draftTopRem}rem`,
|
|
1994
|
+
height: `${laneHeightRem}rem`
|
|
1995
|
+
},
|
|
1996
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1997
|
+
"aria-hidden": true,
|
|
1998
|
+
className: "absolute inset-0 bg-primary/15"
|
|
1999
|
+
})
|
|
2000
|
+
})
|
|
2001
|
+
]
|
|
2002
|
+
}),
|
|
2003
|
+
draft && draftLabel && /* @__PURE__ */ jsx("div", {
|
|
2004
|
+
"data-slot": "gantt-slot-draft-label",
|
|
2005
|
+
className: "pointer-events-none absolute z-40",
|
|
2006
|
+
style: {
|
|
2007
|
+
insetInlineStart: `${draft.to * 100}%`,
|
|
2008
|
+
top: `${draftTopRem}rem`,
|
|
2009
|
+
height: `${laneHeightRem}rem`
|
|
2010
|
+
},
|
|
2011
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
2012
|
+
className: "absolute start-full top-1/2 ms-2 inline-flex w-max -translate-y-1/2 items-center whitespace-nowrap rounded-md bg-foreground px-2 py-1 font-medium text-background text-xs",
|
|
2013
|
+
children: [draftLabel, /* @__PURE__ */ jsx("span", {
|
|
2014
|
+
"aria-hidden": true,
|
|
2015
|
+
className: "absolute start-0 top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rotate-45 rounded-[1px] bg-foreground"
|
|
2016
|
+
})]
|
|
2017
|
+
})
|
|
2018
|
+
}),
|
|
2019
|
+
hintVisible && hintStop && /* @__PURE__ */ jsx("div", {
|
|
2020
|
+
"data-slot": "gantt-schedule-hint",
|
|
2021
|
+
className: "pointer-events-none absolute z-30 -translate-x-1/2 -translate-y-1/2 rtl:translate-x-1/2",
|
|
2022
|
+
style: {
|
|
2023
|
+
insetInlineStart: "var(--gantt-hint-x, 50%)",
|
|
2024
|
+
top: `${hintTopRem}rem`
|
|
2025
|
+
},
|
|
2026
|
+
children: viewConfig.renderScheduleHint ? viewConfig.renderScheduleHint({
|
|
2027
|
+
start: new Date(hintStop.ms),
|
|
2028
|
+
end: new Date(Math.max(hintStop.endMs, hintStop.ms + 1)),
|
|
2029
|
+
resource: row.resource
|
|
2030
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
2031
|
+
type: "button",
|
|
2032
|
+
"data-slot": "gantt-schedule-hint-tile",
|
|
2033
|
+
"aria-label": hintLabel,
|
|
2034
|
+
className: "pointer-events-none block size-5 rounded-full border-2 border-primary bg-transparent ring-1 ring-background/80",
|
|
2035
|
+
onPointerDown: (e) => {
|
|
2036
|
+
if (!viewConfig.dragCreate) e.stopPropagation();
|
|
2037
|
+
},
|
|
2038
|
+
onClick: (e) => {
|
|
2039
|
+
e.stopPropagation();
|
|
2040
|
+
if (wasRecentDrag()) return;
|
|
2041
|
+
createAt(hintStop, e);
|
|
2042
|
+
setHintStop(null);
|
|
2043
|
+
}
|
|
2044
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
2045
|
+
"data-slot": "gantt-schedule-hint-bubble",
|
|
2046
|
+
className: cn("absolute start-1/2 inline-flex w-max -translate-x-1/2 items-center whitespace-nowrap rounded-md bg-foreground px-2 py-1 font-medium text-background text-xs", rowIndex === 0 ? "top-full mt-2" : "bottom-full mb-2"),
|
|
2047
|
+
children: [hintLabel, /* @__PURE__ */ jsx("span", {
|
|
2048
|
+
"aria-hidden": true,
|
|
2049
|
+
className: cn("absolute start-1/2 size-2.5 -translate-x-1/2 rotate-45 rounded-[2px] bg-foreground", rowIndex === 0 ? "-top-1" : "-bottom-1")
|
|
2050
|
+
})]
|
|
2051
|
+
})] })
|
|
2052
|
+
})
|
|
2053
|
+
]
|
|
2054
|
+
});
|
|
2055
|
+
});
|
|
2056
|
+
function sameChips(a, b) {
|
|
2057
|
+
return a.length === b.length && a.every((chip, i) => chip.id === b[i].id && chip.side === b[i].side && chip.top === b[i].top && chip.target === b[i].target && chip.insetEnd === b[i].insetEnd);
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* Edge chips for rows whose bars sit entirely outside the visible timeline;
|
|
2061
|
+
* clicking scrolls the bar back into view. Reads geometry straight from the
|
|
2062
|
+
* DOM (row data attributes), so scrolling never re-renders the grid.
|
|
2063
|
+
*/
|
|
2064
|
+
function GanttOffscreenChips({ paneRef, locale, refreshKey }) {
|
|
2065
|
+
const settings = useGanttSettings();
|
|
2066
|
+
const [chips, setChips] = useState([]);
|
|
2067
|
+
useEffect(() => {
|
|
2068
|
+
const pane = paneRef.current;
|
|
2069
|
+
const viewport = getPaneViewport(pane);
|
|
2070
|
+
if (!pane || !viewport) return;
|
|
2071
|
+
let raf = 0;
|
|
2072
|
+
const measure = () => {
|
|
2073
|
+
raf = 0;
|
|
2074
|
+
const paneRect = pane.getBoundingClientRect();
|
|
2075
|
+
const header = viewport.querySelector("[data-slot=gantt-timeline-header]");
|
|
2076
|
+
const headerBottom = header ? header.getBoundingClientRect().bottom - paneRect.top : 0;
|
|
2077
|
+
const trackW = viewport.scrollWidth;
|
|
2078
|
+
const visibleStart = getScrollStart(viewport);
|
|
2079
|
+
const visibleEnd = visibleStart + viewport.clientWidth;
|
|
2080
|
+
const zoomEl = pane.querySelector("[data-slot=gantt-zoom]");
|
|
2081
|
+
const zoom = zoomEl ? {
|
|
2082
|
+
top: zoomEl.getBoundingClientRect().top - paneRect.top - 8,
|
|
2083
|
+
bottom: zoomEl.getBoundingClientRect().bottom - paneRect.top + 8,
|
|
2084
|
+
inset: paneRect.right - zoomEl.getBoundingClientRect().left + 8
|
|
2085
|
+
} : null;
|
|
2086
|
+
const next = [];
|
|
2087
|
+
for (const rowEl of viewport.querySelectorAll("[data-gantt-row]")) {
|
|
2088
|
+
const from = parseFloat(rowEl.dataset.ganttBarMin ?? "");
|
|
2089
|
+
const to = parseFloat(rowEl.dataset.ganttBarMax ?? "");
|
|
2090
|
+
if (Number.isNaN(from) || Number.isNaN(to)) continue;
|
|
2091
|
+
const rect = rowEl.getBoundingClientRect();
|
|
2092
|
+
const top = rect.top - paneRect.top + rect.height / 2;
|
|
2093
|
+
if (top < headerBottom + 10 || top > paneRect.height - 16) continue;
|
|
2094
|
+
const startPx = from * trackW;
|
|
2095
|
+
const endPx = to * trackW;
|
|
2096
|
+
const startMs = parseFloat(rowEl.dataset.ganttBarStartMs ?? "");
|
|
2097
|
+
const base = {
|
|
2098
|
+
id: rowEl.dataset.ganttRowId ?? "",
|
|
2099
|
+
top: Math.round(top),
|
|
2100
|
+
color: rowEl.dataset.ganttBarColor,
|
|
2101
|
+
label: rowEl.dataset.ganttBarLabel ?? "",
|
|
2102
|
+
startMs: Number.isNaN(startMs) ? null : startMs
|
|
2103
|
+
};
|
|
2104
|
+
if (endPx <= visibleStart + 2) next.push({
|
|
2105
|
+
...base,
|
|
2106
|
+
side: "start",
|
|
2107
|
+
target: startPx - 24,
|
|
2108
|
+
insetEnd: 14
|
|
2109
|
+
});
|
|
2110
|
+
else if (startPx >= visibleEnd - 2) {
|
|
2111
|
+
const overlapsZoom = zoom && top >= zoom.top && top <= zoom.bottom;
|
|
2112
|
+
next.push({
|
|
2113
|
+
...base,
|
|
2114
|
+
side: "end",
|
|
2115
|
+
target: endPx - viewport.clientWidth + 24,
|
|
2116
|
+
insetEnd: overlapsZoom ? Math.max(14, zoom.inset) : 14
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
setChips((prev) => sameChips(prev, next) ? prev : next);
|
|
2121
|
+
};
|
|
2122
|
+
const schedule = () => {
|
|
2123
|
+
if (!raf) raf = requestAnimationFrame(measure);
|
|
2124
|
+
};
|
|
2125
|
+
viewport.addEventListener("scroll", schedule);
|
|
2126
|
+
const observer = new ResizeObserver(schedule);
|
|
2127
|
+
observer.observe(viewport);
|
|
2128
|
+
schedule();
|
|
2129
|
+
return () => {
|
|
2130
|
+
viewport.removeEventListener("scroll", schedule);
|
|
2131
|
+
observer.disconnect();
|
|
2132
|
+
if (raf) cancelAnimationFrame(raf);
|
|
2133
|
+
};
|
|
2134
|
+
}, [paneRef, refreshKey]);
|
|
2135
|
+
if (chips.length === 0) return null;
|
|
2136
|
+
const scrollTo = (chip) => {
|
|
2137
|
+
const viewport = getPaneViewport(paneRef.current);
|
|
2138
|
+
if (!viewport) return;
|
|
2139
|
+
const target = Math.max(0, chip.target);
|
|
2140
|
+
viewport.scrollTo({
|
|
2141
|
+
left: getComputedStyle(viewport).direction === "rtl" ? -target : target,
|
|
2142
|
+
behavior: "smooth"
|
|
2143
|
+
});
|
|
2144
|
+
viewport.querySelector(`[data-gantt-row-id="${CSS.escape(chip.id)}"] [data-slot=gantt-bar]`)?.focus({ preventScroll: true });
|
|
2145
|
+
};
|
|
2146
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2147
|
+
"data-slot": "gantt-offscreen-chips",
|
|
2148
|
+
className: "pointer-events-none absolute inset-0 z-30 overflow-hidden",
|
|
2149
|
+
children: /* @__PURE__ */ jsx(TooltipProvider, {
|
|
2150
|
+
delay: 600,
|
|
2151
|
+
closeDelay: 0,
|
|
2152
|
+
timeout: 300,
|
|
2153
|
+
children: chips.map((chip) => /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsxs(TooltipTrigger, {
|
|
2154
|
+
render: /* @__PURE__ */ jsx("button", {
|
|
2155
|
+
type: "button",
|
|
2156
|
+
"data-slot": "gantt-offscreen-chip",
|
|
2157
|
+
"data-side": chip.side,
|
|
2158
|
+
"aria-label": settings.i18n.labels.jumpToBar(chip.label),
|
|
2159
|
+
className: "pointer-events-auto absolute flex size-5 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full border bg-background text-muted-foreground shadow-xs hover:text-foreground",
|
|
2160
|
+
style: {
|
|
2161
|
+
top: chip.top,
|
|
2162
|
+
...chip.side === "start" ? { insetInlineStart: "0.5rem" } : { insetInlineEnd: chip.insetEnd }
|
|
2163
|
+
},
|
|
2164
|
+
onClick: () => scrollTo(chip)
|
|
2165
|
+
}),
|
|
2166
|
+
children: [chip.side === "start" ? /* @__PURE__ */ jsx(ChevronLeftIcon, {
|
|
2167
|
+
className: "size-3",
|
|
2168
|
+
"aria-hidden": "true"
|
|
2169
|
+
}) : /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
2170
|
+
className: "size-3",
|
|
2171
|
+
"aria-hidden": "true"
|
|
2172
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2173
|
+
"aria-hidden": true,
|
|
2174
|
+
className: "absolute -end-px -top-px size-1.5 rounded-full ring-1 ring-background",
|
|
2175
|
+
style: { background: chip.color ?? "var(--color-primary)" }
|
|
2176
|
+
})]
|
|
2177
|
+
}), /* @__PURE__ */ jsxs(TooltipContent, {
|
|
2178
|
+
side: chip.side === "start" ? "right" : "left",
|
|
2179
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2180
|
+
className: "font-medium",
|
|
2181
|
+
children: chip.label
|
|
2182
|
+
}), chip.startMs !== null && /* @__PURE__ */ jsx("div", {
|
|
2183
|
+
className: "opacity-80",
|
|
2184
|
+
children: format(toZoned(new Date(chip.startMs), settings.timeZone), "MMM d, yyyy", { locale })
|
|
2185
|
+
})]
|
|
2186
|
+
})] }, `${chip.id}-${chip.side}`))
|
|
2187
|
+
})
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
//#endregion
|
|
2191
|
+
export { GanttView };
|
|
2192
|
+
|
|
2193
|
+
//# sourceMappingURL=gantt-view.js.map
|