@mogura/moguchart-core 1.3.0 → 1.3.1

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/CHANGELOG.ja.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.1] - 2026-10-01
9
+
10
+ ### Fixed
11
+
12
+ - **読み取り専用モードにおける進捗率リサイズの制御を修正**:
13
+ - `readOnly: true` が有効な場合でも、タスク単位で `progressResizable: true` が指定されている場合に、進捗率のリサイズ・変更操作が反映されるよう修正
14
+ - `task.progressResizable === false` が明示指定されたタスクについて、進捗率の変更操作が確実に無効化されるガード処理を追加
15
+
16
+ ---
17
+
8
18
  ## [1.3.0] - 2026-09-27
9
19
 
10
20
  ### Added
package/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.1] - 2026-10-01
9
+
10
+ ### Fixed
11
+
12
+ - **Fix Task Progress Resize Control in Read-Only Mode**:
13
+ - Allowed task progress changes when `task.progressResizable` is explicitly set to `true`, even if `readOnly` mode is enabled.
14
+ - Added a guard to prevent progress changes if `task.progressResizable` is explicitly `false`.
15
+
16
+ ---
17
+
8
18
  ## [1.3.0] - 2026-09-27
9
19
 
10
20
  ### Added
@@ -5175,9 +5175,9 @@ var $ = class extends e {
5175
5175
  }, this.handleTaskUpdate = (e) => {
5176
5176
  this._taskDragController.handleTaskUpdate(e);
5177
5177
  }, this.handleTaskProgressChange = (e) => {
5178
- if (this.option.readOnly || e.detail.cancelled) return;
5178
+ if (e.detail.cancelled) return;
5179
5179
  let { task: t, progress: n, originalProgress: r } = e.detail;
5180
- if ((r ?? 0) === n) return;
5180
+ if (this.option.readOnly && !t.progressResizable || t.progressResizable === !1 || (r ?? 0) === n) return;
5181
5181
  let i = !1, a = this.rows, o = this.rows.map((e) => {
5182
5182
  let r = e.tasks.findIndex((e) => e.id === t.id);
5183
5183
  if (r === -1) return e;
@@ -1721,7 +1721,7 @@
1721
1721
  ${w}
1722
1722
  </g>
1723
1723
  </svg>
1724
- `}var $=class extends t.LitElement{constructor(...e){super(...e),this.rows=[],this.theme=`light`,this.selectedRowIds=[],this.selectedTaskIds=[],this.externalDraggingTask=null,this.selectedRows=new Set,this.selectedTasks=new Set,this.lastClickedRowId=null,this.virtualScrollTop=0,this.currentScrollLeft=0,this.currentScrollTop=0,this.viewportWidth=800,this.viewportHeight=400,this.calendarHeight=0,this.currentTime=new Date,this.currentRowHeaderWidth=150,this.isResizingHeader=!1,this.hoveredMilestoneId=null,this.cursorLineX=null,this.baseRowHeaderWidth=150,this._systemThemeMediaQuery=null,this._pluginManager=new Y(this),this._zoomController=new me(this),this._marqueeController=new he(this),this._tooltipController=new ge(this),this._keyboardController=new _e(this),this._dependencyController=new ve(this),this._taskDragController=new ye(this),this._rowReorderController=new Ce(this),this._treeController=new Te(this),this._dragDropControllerInstance=null,this._historyManager=new W({onChange:e=>{this.dispatchEvent(new CustomEvent(`history-change`,{detail:e,bubbles:!0,composed:!0}))}}),this.isExporting=!1,this._layoutCache=null,this.resizeObserver=null,this._cachedSelectedTaskIds=[],this._cachedSelectedTasksSize=-1,this._cachedCurrentOption=null,this._lastOptionRef=null,this._lastLabelWidth=-1,this._lastZoomPercent=null,this._lastZoomPxPerDay=null,this._lastZoomPxPerMonth=null,this._scrollContainer=null,this._handlePointerDownFocus=e=>{let t=e.composedPath()[0];t?.tagName&&[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.tagName)||document.activeElement!==this&&this.focus()},this._handleGlobalDragEnd=()=>{this._draggingRowId=null;let e=this.shadowRoot?.querySelector(`.scroll-container`);e&&e.classList.remove(`drag-active-valid`,`drag-active-invalid`)},this.handleSystemThemeChange=e=>{(this.option?.theme===`system`||this.option?.theme!==`light`&&this.option?.theme!==`dark`)&&(this.theme=e.matches?`dark`:`light`)},this.handleScroll=e=>{let t=e.target;this.currentScrollLeft=t.scrollLeft,this.currentScrollTop=t.scrollTop,this.updateScrollTop(t.scrollTop),this._tooltipController.hideTooltip()},this.handleMinimapScroll=e=>{let t=this.shadowRoot?.querySelector(`.scroll-container`);t&&(t.scrollLeft=e.detail.scrollLeft,t.scrollTop=e.detail.scrollTop,this.currentScrollLeft=e.detail.scrollLeft,this.currentScrollTop=e.detail.scrollTop,this.virtualScrollTop=e.detail.scrollTop)},this.updateScrollTop=(0,a.throttle)(e=>{this.virtualScrollTop=e},100),this.handleContainerMouseMove=e=>{if(!this.option.calendar.showCursorLine)return;let t=this.shadowRoot?.querySelector(`.scroll-container`);if(!t)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left+t.scrollLeft;if(r<this.currentRowHeaderWidth){this.cursorLineX=null;return}this.cursorLineX=r},this.handleContainerMouseLeave=()=>{this.cursorLineX=null},this.handleTaskUpdate=e=>{this._taskDragController.handleTaskUpdate(e)},this.handleTaskProgressChange=e=>{if(this.option.readOnly||e.detail.cancelled)return;let{task:t,progress:n,originalProgress:r}=e.detail;if((r??0)===n)return;let i=!1,a=this.rows,o=this.rows.map(e=>{let r=e.tasks.findIndex(e=>e.id===t.id);if(r===-1)return e;i=!0;let a=[...e.tasks];return a[r]={...a[r],progress:n},{...e,tasks:a}});i&&this.applyRowsChangeWithCommand(a,o,{type:`task-progress`,description:`進捗率の変更 (${n}%)`})},this.handleContainerDragOver=e=>{this._rowReorderController.handleContainerDragOver(e)},this.handleRowDragStart=e=>{this._rowReorderController.handleRowDragStart(e)},this.handleRowDragEnd=()=>{this._rowReorderController.handleRowDragEnd()},this.handleContainerDragLeave=e=>{this._rowReorderController.handleContainerDragLeave(e)},this.handleContainerDrop=e=>{this._rowReorderController.handleContainerDrop(e)},this.handleContainerPointerDown=e=>{this._marqueeController.handlePointerDown(e)},this.handleWheel=e=>{this._zoomController.handleWheel(e,this._scrollContainer)},this.handleKeyDown=e=>{this._keyboardController.handleKeyDown(e)},this.handleConnectorDragStart=e=>{this._dependencyController.handleConnectorDragStart(e)},this.handleConnectorDragMove=e=>{this._dependencyController.handleConnectorDragMove(e)},this.handleConnectorDragEnd=e=>{this._dependencyController.handleConnectorDragEnd(e)},this.handleDependencyLineClick=(e,t,n)=>{this._dependencyController.handleDependencyLineClick(e,t,n)}}get selectedDependency(){return this._dependencyController?.selectedDependency??null}set selectedDependency(e){this._dependencyController&&(this._dependencyController.selectedDependency=e)}get tooltip(){return this._tooltipController?.tooltip??null}set tooltip(e){this._tooltipController&&(this._tooltipController.tooltip=e)}get connectorDrag(){return this._dependencyController?.connectorDrag??null}set connectorDrag(e){this._dependencyController&&(this._dependencyController.connectorDrag=e)}get draggingTask(){return this._dragDropController?.draggingTask??null}set draggingTask(e){this._dragDropController&&(this._dragDropController.draggingTask=e)}get draggingTaskIds(){return this._dragDropController?.draggingTaskIds??[]}set draggingTaskIds(e){this._dragDropController&&(this._dragDropController.draggingTaskIds=e)}get multiDragDx(){return this._taskDragController?.multiDragDx??0}set multiDragDx(e){this._taskDragController&&(this._taskDragController.multiDragDx=e)}get multiDragDy(){return this._taskDragController?.multiDragDy??0}set multiDragDy(e){this._taskDragController&&(this._taskDragController.multiDragDy=e)}get multiDragSameRow(){return this._taskDragController?.multiDragSameRow??!1}set multiDragSameRow(e){this._taskDragController&&(this._taskDragController.multiDragSameRow=e)}get dragTargetRowIndex(){return this._taskDragController?.dragTargetRowIndex??null}set dragTargetRowIndex(e){this._taskDragController&&(this._taskDragController.dragTargetRowIndex=e)}get dragOverlayInfo(){return this._taskDragController?.dragOverlayInfo??null}set dragOverlayInfo(e){this._taskDragController&&(this._taskDragController.dragOverlayInfo=e)}get dragOverRowId(){return this._rowReorderController?.dragOverRowId??null}set dragOverRowId(e){this._rowReorderController&&(this._rowReorderController.dragOverRowId=e)}get dragOverPosition(){return this._rowReorderController?.dragOverPosition??null}set dragOverPosition(e){this._rowReorderController&&(this._rowReorderController.dragOverPosition=e)}get dragPreview(){return this._taskDragController?.dragPreview??null}set dragPreview(e){this._taskDragController&&(this._taskDragController.dragPreview=e)}get _draggingRowId(){return this._rowReorderController?._draggingRowId??null}set _draggingRowId(e){this._rowReorderController&&(this._rowReorderController._draggingRowId=e)}get focusedTaskId(){return this._keyboardController?.focusedTaskId??null}set focusedTaskId(e){this._keyboardController&&(this._keyboardController.focusedTaskId=e)}get focusedRowId(){return this._keyboardController?.focusedRowId??null}set focusedRowId(e){this._keyboardController&&(this._keyboardController.focusedRowId=e)}get zoomPercent(){return this._zoomController?.zoomPercent??100}set zoomPercent(e){this._zoomController&&(this._zoomController.zoomPercent=e)}get zoomPxPerDay(){return this._zoomController?.zoomPxPerDay??null}set zoomPxPerDay(e){this._zoomController&&(this._zoomController.zoomPxPerDay=e)}get zoomPxPerMonth(){return this._zoomController?.zoomPxPerMonth??null}set zoomPxPerMonth(e){this._zoomController&&(this._zoomController.zoomPxPerMonth=e)}get marqueeSelection(){return this._marqueeController?.marqueeSelection??null}set marqueeSelection(e){this._marqueeController&&(this._marqueeController.marqueeSelection=e)}get _dragDropController(){return this._dragDropControllerInstance||=new we(this),this._dragDropControllerInstance}get _collapsedRowIds(){return this._treeController.collapsedRowIds}set _collapsedRowIds(e){this._treeController.collapsedRowIds=e}invalidateLayoutCache(){this._layoutCache=null}clearTooltip(){this._tooltipController.clearTooltip()}get displayRows(){return this._treeController.getDisplayRows()}get zoomOption(){return this._zoomController.zoomOption}get effectiveZoomScale(){return this._zoomController.effectiveZoomScale}get isScaleCalendarEnabled(){return this._zoomController.isScaleCalendarEnabled}get isScaleRowHeaderEnabled(){return this._zoomController.isScaleRowHeaderEnabled}get isScaleBarHeightEnabled(){return this._zoomController.isScaleBarHeightEnabled}get isScaleFontEnabled(){return this._zoomController.isScaleFontEnabled}get effectivePxPerDay(){return this._zoomController.effectivePxPerDay}get effectivePxPerMonth(){return this._zoomController.effectivePxPerMonth}get effectiveRowHeaderWidth(){return this._zoomController.effectiveRowHeaderWidth}get effectiveBarHeight(){return this._zoomController.effectiveBarHeight}get effectiveFontScale(){return this._zoomController.effectiveFontScale}static{this.styles=fe}firstUpdated(){this.setupCurrentTimeTimer();let e=this.shadowRoot?.getElementById(`calendar`);this.resizeObserver=new ResizeObserver(t=>{for(let n of t)n.target===this?(this.viewportHeight=n.contentRect.height,this.viewportWidth=n.contentRect.width):n.target===e&&(this.calendarHeight=n.target.offsetHeight)}),this.resizeObserver.observe(this),e&&this.resizeObserver.observe(e),this._scrollContainer=this.shadowRoot?.querySelector(`.scroll-container`),this._scrollContainer&&(this.currentScrollLeft=this._scrollContainer.scrollLeft,this.currentScrollTop=this._scrollContainer.scrollTop),this._scrollContainer?.addEventListener(`wheel`,this.handleWheel,{passive:!1})}connectedCallback(){if(super.connectedCallback(),this._systemThemeMediaQuery=window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null,this._systemThemeMediaQuery?.addEventListener(`change`,this.handleSystemThemeChange),this.hasAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`),this.setAttribute(`role`,`grid`),this.setAttribute(`aria-label`,`Gantt Chart`),this.addEventListener(`keydown`,this.handleKeyDown),this.addEventListener(`pointerdown`,this._handlePointerDownFocus,!0),this.addEventListener(`task-progress-change`,this.handleTaskProgressChange),this.addEventListener(`wheel`,this.handleWheel,{passive:!1}),this.theme=this.option?.theme===`system`||this.option?.theme!==`light`&&this.option?.theme!==`dark`?this._systemThemeMediaQuery?.matches?`dark`:`light`:this.option.theme,window.addEventListener(`dragend`,this._handleGlobalDragEnd),this.option?.plugins)for(let e of this.option.plugins)this.use(e);this.option?.history&&this._historyManager.updateOptions({enabled:this.option.history.enabled,maxDepth:this.option.history.maxDepth,onUndo:this.option.history.onUndo,onRedo:this.option.history.onRedo})}disconnectedCallback(){super.disconnectedCallback(),this._pluginManager.destroy(),window.removeEventListener(`dragend`,this._handleGlobalDragEnd),this.resizeObserver?.disconnect(),this.stopCurrentTimeTimer(),this._systemThemeMediaQuery?.removeEventListener(`change`,this.handleSystemThemeChange),this.removeEventListener(`keydown`,this.handleKeyDown),this.removeEventListener(`pointerdown`,this._handlePointerDownFocus,!0),this.removeEventListener(`task-progress-change`,this.handleTaskProgressChange),this.removeEventListener(`wheel`,this.handleWheel),this._scrollContainer?.removeEventListener(`wheel`,this.handleWheel),this._scrollContainer=null}willUpdate(e){if(e.has(`option`)&&(this.option?.theme===`light`||this.option?.theme===`dark`?this.theme=this.option.theme:this._systemThemeMediaQuery&&(this.theme=this._systemThemeMediaQuery.matches?`dark`:`light`)),e.has(`option`)&&(this.setupCurrentTimeTimer(),this.isResizingHeader||(this.baseRowHeaderWidth=this.option.rowHeader?.width??150,this.currentRowHeaderWidth=this.effectiveRowHeaderWidth),this._zoomController.syncWithOption(),this.option?.history&&this._historyManager.updateOptions({enabled:this.option.history.enabled,maxDepth:this.option.history.maxDepth,onUndo:this.option.history.onUndo,onRedo:this.option.history.onRedo})),(e.has(`rows`)||e.has(`option`)||e.has(`currentRowHeaderWidth`)||e.has(`zoomPercent`)||e.has(`zoomPxPerDay`)||e.has(`zoomPxPerMonth`))&&(this._layoutCache=null),e.has(`rows`)){let{rows:e,hasChanges:t}=this._treeController.syncCollapsedWithRows(this.rows);t&&(this.rows=e)}if(e.has(`selectedRowIds`)){let e=new Set(this.selectedRowIds);(e.size!==this.selectedRows.size||![...e].every(e=>this.selectedRows.has(e)))&&(this.selectedRows=e)}if(e.has(`selectedTaskIds`)){let e=new Set(this.selectedTaskIds);(e.size!==this.selectedTasks.size||![...e].every(e=>this.selectedTasks.has(e)))&&(this.selectedTasks=e)}(e.has(`selectedTasks`)||this._cachedSelectedTasksSize!==this.selectedTasks.size)&&(this._cachedSelectedTaskIds=[...this.selectedTasks],this._cachedSelectedTasksSize=this.selectedTasks.size)}updated(e){if(super.updated(e),e.has(`option`)&&this.option?.plugins)for(let e of this.option.plugins)this.use(e);this._tooltipController.updateTooltipDOM(),this._pluginManager.executeAfterRender()}updateDragOverlay(){this._taskDragController.updateDragOverlay()}hideDragOverlay(){this._taskDragController.hideDragOverlay()}setupCurrentTimeTimer(){this.stopCurrentTimeTimer();let e=this.option.calendar.currentTimeUpdateInterval;e&&e>0&&(this.currentTimeTimer=window.setInterval(()=>{this.currentTime=new Date},e))}stopCurrentTimeTimer(){this.currentTimeTimer!==void 0&&(window.clearInterval(this.currentTimeTimer),this.currentTimeTimer=void 0)}handleHeaderResizeStart(e){e.preventDefault(),e.stopPropagation(),this.isResizingHeader=!0;let t=e.clientX,n=this.currentRowHeaderWidth,r=e.target;r.setPointerCapture(e.pointerId);let i=this.option.rowHeader?.minWidth??50,a=this.option.rowHeader?.maxWidth??2**53-1,o=e=>{let r=e.clientX-t,o=n+r;this.currentRowHeaderWidth=Math.max(i,Math.min(a,o))},s=()=>{this.isResizingHeader=!1,r.releasePointerCapture(e.pointerId),r.removeEventListener(`pointermove`,o),r.removeEventListener(`pointerup`,s);let t=Math.round(this.currentRowHeaderWidth);this.currentRowHeaderWidth=t,this.baseRowHeaderWidth=this.isScaleRowHeaderEnabled?Math.max(60,Math.round(t/this.effectiveZoomScale)):t,this.dispatchEvent(new CustomEvent(`row-header-resize`,{detail:{width:t},bubbles:!0,composed:!0}))};r.addEventListener(`pointermove`,o),r.addEventListener(`pointerup`,s)}getDateX(e){return j(e,this.option.calendar.start,this.effectivePxPerDay,this.effectivePxPerMonth)}calculateLayout(){if(this._layoutCache)return this._layoutCache;let e=0,t=this.currentRowHeaderWidth,n=new Map,r={layouts:this.displayRows.map(r=>{let{tasksWithLanes:i,laneCount:a}=N(r.tasks),o=this.effectiveBarHeight,s=this.option.bar?.margin??4;i.forEach(r=>{let i=this.getDateX(r.start)+t,a=this.getDateX(r.end)+t-i,c=e+r.lane*(o+s)+s;n.set(r.id,{x:i,y:c,width:a,height:o,dependencies:r.dependencies,isSummary:r.type===`summary`})});let c=a*(o+s)+s,l={top:e,height:c};return e+=c,l}),taskCoords:n,totalHeight:e};return this._layoutCache=r,r}isMultiDrag(e){return this._taskDragController.isMultiDrag(e)}isMultiDragSameRow(){return this._taskDragController.isMultiDragSameRow()}handleBarMouseEnter(e){this._tooltipController.handleBarMouseEnter(e.detail)}handleBarMouseLeave(){this._tooltipController.handleBarMouseLeave()}async reorderRows(e,t,n){return this._rowReorderController.reorderRows(e,t,n)}handleExternalTaskDrop(e,t){this._taskDragController.handleExternalTaskDrop(e,t)}handleRowClicked(e){let{rowId:t,event:n}=e.detail,{shiftKey:r,ctrlKey:i,metaKey:a}=n;this.selectedDependency&&this.clearDependencySelection();let o=new Set(this.selectedRows);if(r&&this.lastClickedRowId){let e=this.rows.findIndex(e=>e.id===this.lastClickedRowId),n=this.rows.findIndex(e=>e.id===t);if(e!==-1&&n!==-1){let t=Math.min(e,n),r=Math.max(e,n);for(let e=t;e<=r;e++)o.add(this.rows[e].id)}}else if(i||a)o.has(t)?o.delete(t):o.add(t),this.lastClickedRowId=t;else{if(o.has(t)){this.lastClickedRowId=t;return}o.clear(),o.add(t),this.lastClickedRowId=t}this.selectedRows=o,this.dispatchEvent(new CustomEvent(`row-selection-change`,{detail:{selectedIds:Array.from(this.selectedRows)},bubbles:!0,composed:!0}))}handleRowContextMenu(e){this.selectedRows.has(e.detail.rowId)||this.handleRowClicked(e)}stopMarqueeAutoScroll(){this._marqueeController.stopMarqueeAutoScroll()}handleContainerClick(e){if(this._marqueeController.justFinishedMarquee){this._marqueeController.justFinishedMarquee=!1;return}e.defaultPrevented||this.clearSelection()}handleContainerContextMenu(e){if(e.defaultPrevented)return;e.preventDefault();let t=this.shadowRoot?.querySelector(`.scroll-container`);if(!t)return;let n=t.getBoundingClientRect(),r=t.scrollLeft,i=t.scrollTop,a=this.currentRowHeaderWidth,o=e.clientY-n.top+i-this.calendarHeight,{layouts:s}=this.calculateLayout(),c;for(let e=0;e<s.length;e++){let t=s[e];if(o>=t.top&&o<t.top+t.height){c=this.displayRows[e].id;break}}if(c){let t=e.clientX-n.left+r-a,i=this.effectivePxPerDay,o=this.effectivePxPerMonth,s=M(t,this.option.calendar.start,i,o);this.dispatchEvent(new CustomEvent(`chart-contextmenu`,{detail:{event:e,date:s,rowId:c},bubbles:!0,composed:!0}))}this.clearSelection()}hitTest(e,t){let n=this.shadowRoot?.querySelector(`.scroll-container`);if(!n)return null;let r=n.getBoundingClientRect(),i=n.scrollLeft,a=n.scrollTop,o=this.currentRowHeaderWidth,s=t-r.top+a-this.calendarHeight,{layouts:c}=this.calculateLayout(),l;for(let e=0;e<c.length;e++){let t=c[e];if(s>=t.top&&s<t.top+t.height){l=this.displayRows[e].id;break}}if(!l)return null;let u=e-r.left+i-o,d=this.effectivePxPerDay,f=this.effectivePxPerMonth,p=M(u,this.option.calendar.start,d,f);return{rowId:l,date:p}}getRowPositions(){let{layouts:e}=this.calculateLayout();return e.map(e=>({top:e.top,height:e.height,bottom:e.top+e.height}))}use(e,t){return this._pluginManager.use(e,t),this}get historyManager(){return this._historyManager}get canUndo(){return this._historyManager.canUndo}get canRedo(){return this._historyManager.canRedo}async undo(){return this._historyManager.undo()}async redo(){return this._historyManager.redo()}clearHistory(){this._historyManager.clear()}recordCommand(e){this.option?.history?.enabled!==!1&&(this._historyManager.execute(e),this.dispatchEvent(new CustomEvent(`command`,{detail:{command:e},bubbles:!0,composed:!0})))}applyRowsChangeWithCommand(e,t,n){document.activeElement!==this&&this.focus(),this.rows=t,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}));let r={id:`cmd-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:n.type,description:n.description,timestamp:Date.now(),before:e,after:t,undo:()=>{this.clearDependencySelection(),this.rows=e,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))},redo:()=>{this.clearDependencySelection(),this.rows=t,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))}};this.recordCommand(r)}get pluginManager(){return this._pluginManager}async exportImage(e=`png`,t={}){throw Error(`[Moguchart] chart.exportImage() requires "@mogura/moguchart-plugin-export". Please install "@mogura/moguchart-plugin-export" and register it: chart.use(exportPlugin())`)}zoomToPercent(e){this._zoomController.zoomToPercent(e)}zoomToScale(e){this._zoomController.zoomToScale(e)}zoomIn(e){this._zoomController.zoomIn(e)}zoomOut(e){this._zoomController.zoomOut(e)}getZoomPercent(){return this._zoomController.getZoomPercent()}getZoomScale(){return this._zoomController.getZoomScale()}zoomTo(e){this._zoomController.zoomTo(e)}zoomToFit(){this._zoomController.zoomToFit()}resetZoom(){this._zoomController.resetZoom()}clearDependencySelection(){this._dependencyController.clearDependencySelection()}selectDependency(e,t){this._dependencyController.selectDependency(e,t)}triggerDependencyDelete(e,t,n){this._dependencyController.triggerDependencyDelete(e,t,n)}clearSelection(){(this.selectedRows.size!==0||this.selectedTasks.size!==0||this.selectedDependency)&&(this.selectedRows.size>0&&(this.selectedRows=new Set,this.dispatchEvent(new CustomEvent(`row-selection-change`,{detail:{selectedIds:[]},bubbles:!0,composed:!0}))),this.selectedTasks.size>0&&(this.selectedTasks=new Set,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[]},bubbles:!0,composed:!0}))),this.selectedDependency&&this.clearDependencySelection())}handleBarClick(e){e.stopPropagation();let{task:t,isMultiSelect:n}=e.detail;this.draggingTask=null,this.dragTargetRowIndex=null,this.dragOverlayInfo&&(this.dragOverlayInfo={...this.dragOverlayInfo,visible:!1},this.hideDragOverlay()),this.selectedDependency&&this.clearDependencySelection();let r;n?(r=new Set(this.selectedTasks),r.has(t.id)?r.delete(t.id):r.add(t.id)):r=new Set([t.id]),this.selectedTasks=r,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[...r]},bubbles:!0,composed:!0}))}handleBarContextMenu(e){let{task:t}=e.detail;this.selectedTasks.has(t.id)||(this.selectedTasks=new Set([t.id]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[t.id]},bubbles:!0,composed:!0})))}selectTask(e){let t=!1;for(let n of this.displayRows)if(n.tasks.some(t=>t.id===e)){t=!0;break}return t?(this.selectedTasks=new Set([e]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[e]},bubbles:!0,composed:!0})),this.scrollToTask(e),!0):!1}handleRowToggleCollapse(e){this._treeController.handleRowToggleCollapse(e)}toggleRowCollapse(e,t){return this._treeController.toggleRowCollapse(e,t)}collapseAll(){this._treeController.collapseAll()}expandAll(){this._treeController.expandAll()}resetScroll(){let e=this._scrollContainer??this.shadowRoot?.querySelector(`.scroll-container`);e&&(e.scrollLeft=0,e.scrollTop=0),this.currentScrollLeft=0,this.currentScrollTop=0,this.virtualScrollTop=0,this.requestUpdate()}scrollToPosition(e){let t=this._scrollContainer??this.shadowRoot?.querySelector(`.scroll-container`);t&&(t.scrollTo({left:e.left,top:e.top,behavior:e.behavior??`auto`}),e.left!==void 0&&(this.currentScrollLeft=e.left),e.top!==void 0&&(this.currentScrollTop=e.top,this.virtualScrollTop=e.top),this.requestUpdate())}scrollToTask(e){let{taskCoords:t}=this.calculateLayout(),n=t.get(e);if(!n)return;let r=this.shadowRoot?.querySelector(`.scroll-container`);if(!r)return;let i=this.currentRowHeaderWidth,a=n.y+this.calendarHeight,o=a+n.height,s=r.scrollTop,c=r.scrollTop+r.clientHeight;if(a<s||o>c){let e=a-r.clientHeight/2+n.height/2;r.scrollTo({top:Math.max(0,e),behavior:`smooth`})}let l=n.x,u=n.x+n.width,d=r.scrollLeft+i,f=r.scrollLeft+r.clientWidth;if(l<d||u>f){let e=l-i-20;r.scrollTo({left:Math.max(0,e),behavior:`smooth`})}}render(){let e=P(this.theme,this.option.customTheme),{layouts:n,taskCoords:r,totalHeight:a}=this.calculateLayout(),o=this.currentRowHeaderWidth;(this._lastOptionRef!==this.option||this._lastLabelWidth!==o||this._lastZoomPercent!==this.zoomPercent||this._lastZoomPxPerDay!==this.zoomPxPerDay||this._lastZoomPxPerMonth!==this.zoomPxPerMonth)&&(this._cachedCurrentOption={...this.option,rowHeader:{...this.option.rowHeader,width:o},calendar:{...this.option.calendar,pxPerDay:this.effectivePxPerDay,pxPerMonth:this.effectivePxPerMonth},bar:{...this.option.bar,height:this.effectiveBarHeight}},this._lastOptionRef=this.option,this._lastLabelWidth=o,this._lastZoomPercent=this.zoomPercent,this._lastZoomPxPerDay=this.zoomPxPerDay,this._lastZoomPxPerMonth=this.zoomPxPerMonth);let s=this._cachedCurrentOption,c=0,l=this.displayRows.length-1;if(!this.isExporting){for(let e=0;e<n.length;e++)if(n[e].top+n[e].height>this.virtualScrollTop){c=Math.max(0,e-5);break}for(let e=c;e<n.length;e++)if(n[e].top>this.virtualScrollTop+this.viewportHeight){l=Math.min(this.displayRows.length-1,e+5);break}}let u=this.displayRows.slice(c,l+1),d=X(this.rows),f=be(this.rows),p=new Set;for(let e of this.rows)e.parentId&&p.add(e.parentId);let m=this.isExporting?0:n[c]?n[c].top:0,h=n[l],g=h?h.top+h.height:0,_=Math.max(0,a-g),v=a>this.viewportHeight,y=this.option.dependency?.showCriticalPath===!0,b=y?G(this.displayRows):new Set;return t.html`
1724
+ `}var $=class extends t.LitElement{constructor(...e){super(...e),this.rows=[],this.theme=`light`,this.selectedRowIds=[],this.selectedTaskIds=[],this.externalDraggingTask=null,this.selectedRows=new Set,this.selectedTasks=new Set,this.lastClickedRowId=null,this.virtualScrollTop=0,this.currentScrollLeft=0,this.currentScrollTop=0,this.viewportWidth=800,this.viewportHeight=400,this.calendarHeight=0,this.currentTime=new Date,this.currentRowHeaderWidth=150,this.isResizingHeader=!1,this.hoveredMilestoneId=null,this.cursorLineX=null,this.baseRowHeaderWidth=150,this._systemThemeMediaQuery=null,this._pluginManager=new Y(this),this._zoomController=new me(this),this._marqueeController=new he(this),this._tooltipController=new ge(this),this._keyboardController=new _e(this),this._dependencyController=new ve(this),this._taskDragController=new ye(this),this._rowReorderController=new Ce(this),this._treeController=new Te(this),this._dragDropControllerInstance=null,this._historyManager=new W({onChange:e=>{this.dispatchEvent(new CustomEvent(`history-change`,{detail:e,bubbles:!0,composed:!0}))}}),this.isExporting=!1,this._layoutCache=null,this.resizeObserver=null,this._cachedSelectedTaskIds=[],this._cachedSelectedTasksSize=-1,this._cachedCurrentOption=null,this._lastOptionRef=null,this._lastLabelWidth=-1,this._lastZoomPercent=null,this._lastZoomPxPerDay=null,this._lastZoomPxPerMonth=null,this._scrollContainer=null,this._handlePointerDownFocus=e=>{let t=e.composedPath()[0];t?.tagName&&[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.tagName)||document.activeElement!==this&&this.focus()},this._handleGlobalDragEnd=()=>{this._draggingRowId=null;let e=this.shadowRoot?.querySelector(`.scroll-container`);e&&e.classList.remove(`drag-active-valid`,`drag-active-invalid`)},this.handleSystemThemeChange=e=>{(this.option?.theme===`system`||this.option?.theme!==`light`&&this.option?.theme!==`dark`)&&(this.theme=e.matches?`dark`:`light`)},this.handleScroll=e=>{let t=e.target;this.currentScrollLeft=t.scrollLeft,this.currentScrollTop=t.scrollTop,this.updateScrollTop(t.scrollTop),this._tooltipController.hideTooltip()},this.handleMinimapScroll=e=>{let t=this.shadowRoot?.querySelector(`.scroll-container`);t&&(t.scrollLeft=e.detail.scrollLeft,t.scrollTop=e.detail.scrollTop,this.currentScrollLeft=e.detail.scrollLeft,this.currentScrollTop=e.detail.scrollTop,this.virtualScrollTop=e.detail.scrollTop)},this.updateScrollTop=(0,a.throttle)(e=>{this.virtualScrollTop=e},100),this.handleContainerMouseMove=e=>{if(!this.option.calendar.showCursorLine)return;let t=this.shadowRoot?.querySelector(`.scroll-container`);if(!t)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left+t.scrollLeft;if(r<this.currentRowHeaderWidth){this.cursorLineX=null;return}this.cursorLineX=r},this.handleContainerMouseLeave=()=>{this.cursorLineX=null},this.handleTaskUpdate=e=>{this._taskDragController.handleTaskUpdate(e)},this.handleTaskProgressChange=e=>{if(e.detail.cancelled)return;let{task:t,progress:n,originalProgress:r}=e.detail;if(this.option.readOnly&&!t.progressResizable||t.progressResizable===!1||(r??0)===n)return;let i=!1,a=this.rows,o=this.rows.map(e=>{let r=e.tasks.findIndex(e=>e.id===t.id);if(r===-1)return e;i=!0;let a=[...e.tasks];return a[r]={...a[r],progress:n},{...e,tasks:a}});i&&this.applyRowsChangeWithCommand(a,o,{type:`task-progress`,description:`進捗率の変更 (${n}%)`})},this.handleContainerDragOver=e=>{this._rowReorderController.handleContainerDragOver(e)},this.handleRowDragStart=e=>{this._rowReorderController.handleRowDragStart(e)},this.handleRowDragEnd=()=>{this._rowReorderController.handleRowDragEnd()},this.handleContainerDragLeave=e=>{this._rowReorderController.handleContainerDragLeave(e)},this.handleContainerDrop=e=>{this._rowReorderController.handleContainerDrop(e)},this.handleContainerPointerDown=e=>{this._marqueeController.handlePointerDown(e)},this.handleWheel=e=>{this._zoomController.handleWheel(e,this._scrollContainer)},this.handleKeyDown=e=>{this._keyboardController.handleKeyDown(e)},this.handleConnectorDragStart=e=>{this._dependencyController.handleConnectorDragStart(e)},this.handleConnectorDragMove=e=>{this._dependencyController.handleConnectorDragMove(e)},this.handleConnectorDragEnd=e=>{this._dependencyController.handleConnectorDragEnd(e)},this.handleDependencyLineClick=(e,t,n)=>{this._dependencyController.handleDependencyLineClick(e,t,n)}}get selectedDependency(){return this._dependencyController?.selectedDependency??null}set selectedDependency(e){this._dependencyController&&(this._dependencyController.selectedDependency=e)}get tooltip(){return this._tooltipController?.tooltip??null}set tooltip(e){this._tooltipController&&(this._tooltipController.tooltip=e)}get connectorDrag(){return this._dependencyController?.connectorDrag??null}set connectorDrag(e){this._dependencyController&&(this._dependencyController.connectorDrag=e)}get draggingTask(){return this._dragDropController?.draggingTask??null}set draggingTask(e){this._dragDropController&&(this._dragDropController.draggingTask=e)}get draggingTaskIds(){return this._dragDropController?.draggingTaskIds??[]}set draggingTaskIds(e){this._dragDropController&&(this._dragDropController.draggingTaskIds=e)}get multiDragDx(){return this._taskDragController?.multiDragDx??0}set multiDragDx(e){this._taskDragController&&(this._taskDragController.multiDragDx=e)}get multiDragDy(){return this._taskDragController?.multiDragDy??0}set multiDragDy(e){this._taskDragController&&(this._taskDragController.multiDragDy=e)}get multiDragSameRow(){return this._taskDragController?.multiDragSameRow??!1}set multiDragSameRow(e){this._taskDragController&&(this._taskDragController.multiDragSameRow=e)}get dragTargetRowIndex(){return this._taskDragController?.dragTargetRowIndex??null}set dragTargetRowIndex(e){this._taskDragController&&(this._taskDragController.dragTargetRowIndex=e)}get dragOverlayInfo(){return this._taskDragController?.dragOverlayInfo??null}set dragOverlayInfo(e){this._taskDragController&&(this._taskDragController.dragOverlayInfo=e)}get dragOverRowId(){return this._rowReorderController?.dragOverRowId??null}set dragOverRowId(e){this._rowReorderController&&(this._rowReorderController.dragOverRowId=e)}get dragOverPosition(){return this._rowReorderController?.dragOverPosition??null}set dragOverPosition(e){this._rowReorderController&&(this._rowReorderController.dragOverPosition=e)}get dragPreview(){return this._taskDragController?.dragPreview??null}set dragPreview(e){this._taskDragController&&(this._taskDragController.dragPreview=e)}get _draggingRowId(){return this._rowReorderController?._draggingRowId??null}set _draggingRowId(e){this._rowReorderController&&(this._rowReorderController._draggingRowId=e)}get focusedTaskId(){return this._keyboardController?.focusedTaskId??null}set focusedTaskId(e){this._keyboardController&&(this._keyboardController.focusedTaskId=e)}get focusedRowId(){return this._keyboardController?.focusedRowId??null}set focusedRowId(e){this._keyboardController&&(this._keyboardController.focusedRowId=e)}get zoomPercent(){return this._zoomController?.zoomPercent??100}set zoomPercent(e){this._zoomController&&(this._zoomController.zoomPercent=e)}get zoomPxPerDay(){return this._zoomController?.zoomPxPerDay??null}set zoomPxPerDay(e){this._zoomController&&(this._zoomController.zoomPxPerDay=e)}get zoomPxPerMonth(){return this._zoomController?.zoomPxPerMonth??null}set zoomPxPerMonth(e){this._zoomController&&(this._zoomController.zoomPxPerMonth=e)}get marqueeSelection(){return this._marqueeController?.marqueeSelection??null}set marqueeSelection(e){this._marqueeController&&(this._marqueeController.marqueeSelection=e)}get _dragDropController(){return this._dragDropControllerInstance||=new we(this),this._dragDropControllerInstance}get _collapsedRowIds(){return this._treeController.collapsedRowIds}set _collapsedRowIds(e){this._treeController.collapsedRowIds=e}invalidateLayoutCache(){this._layoutCache=null}clearTooltip(){this._tooltipController.clearTooltip()}get displayRows(){return this._treeController.getDisplayRows()}get zoomOption(){return this._zoomController.zoomOption}get effectiveZoomScale(){return this._zoomController.effectiveZoomScale}get isScaleCalendarEnabled(){return this._zoomController.isScaleCalendarEnabled}get isScaleRowHeaderEnabled(){return this._zoomController.isScaleRowHeaderEnabled}get isScaleBarHeightEnabled(){return this._zoomController.isScaleBarHeightEnabled}get isScaleFontEnabled(){return this._zoomController.isScaleFontEnabled}get effectivePxPerDay(){return this._zoomController.effectivePxPerDay}get effectivePxPerMonth(){return this._zoomController.effectivePxPerMonth}get effectiveRowHeaderWidth(){return this._zoomController.effectiveRowHeaderWidth}get effectiveBarHeight(){return this._zoomController.effectiveBarHeight}get effectiveFontScale(){return this._zoomController.effectiveFontScale}static{this.styles=fe}firstUpdated(){this.setupCurrentTimeTimer();let e=this.shadowRoot?.getElementById(`calendar`);this.resizeObserver=new ResizeObserver(t=>{for(let n of t)n.target===this?(this.viewportHeight=n.contentRect.height,this.viewportWidth=n.contentRect.width):n.target===e&&(this.calendarHeight=n.target.offsetHeight)}),this.resizeObserver.observe(this),e&&this.resizeObserver.observe(e),this._scrollContainer=this.shadowRoot?.querySelector(`.scroll-container`),this._scrollContainer&&(this.currentScrollLeft=this._scrollContainer.scrollLeft,this.currentScrollTop=this._scrollContainer.scrollTop),this._scrollContainer?.addEventListener(`wheel`,this.handleWheel,{passive:!1})}connectedCallback(){if(super.connectedCallback(),this._systemThemeMediaQuery=window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null,this._systemThemeMediaQuery?.addEventListener(`change`,this.handleSystemThemeChange),this.hasAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`),this.setAttribute(`role`,`grid`),this.setAttribute(`aria-label`,`Gantt Chart`),this.addEventListener(`keydown`,this.handleKeyDown),this.addEventListener(`pointerdown`,this._handlePointerDownFocus,!0),this.addEventListener(`task-progress-change`,this.handleTaskProgressChange),this.addEventListener(`wheel`,this.handleWheel,{passive:!1}),this.theme=this.option?.theme===`system`||this.option?.theme!==`light`&&this.option?.theme!==`dark`?this._systemThemeMediaQuery?.matches?`dark`:`light`:this.option.theme,window.addEventListener(`dragend`,this._handleGlobalDragEnd),this.option?.plugins)for(let e of this.option.plugins)this.use(e);this.option?.history&&this._historyManager.updateOptions({enabled:this.option.history.enabled,maxDepth:this.option.history.maxDepth,onUndo:this.option.history.onUndo,onRedo:this.option.history.onRedo})}disconnectedCallback(){super.disconnectedCallback(),this._pluginManager.destroy(),window.removeEventListener(`dragend`,this._handleGlobalDragEnd),this.resizeObserver?.disconnect(),this.stopCurrentTimeTimer(),this._systemThemeMediaQuery?.removeEventListener(`change`,this.handleSystemThemeChange),this.removeEventListener(`keydown`,this.handleKeyDown),this.removeEventListener(`pointerdown`,this._handlePointerDownFocus,!0),this.removeEventListener(`task-progress-change`,this.handleTaskProgressChange),this.removeEventListener(`wheel`,this.handleWheel),this._scrollContainer?.removeEventListener(`wheel`,this.handleWheel),this._scrollContainer=null}willUpdate(e){if(e.has(`option`)&&(this.option?.theme===`light`||this.option?.theme===`dark`?this.theme=this.option.theme:this._systemThemeMediaQuery&&(this.theme=this._systemThemeMediaQuery.matches?`dark`:`light`)),e.has(`option`)&&(this.setupCurrentTimeTimer(),this.isResizingHeader||(this.baseRowHeaderWidth=this.option.rowHeader?.width??150,this.currentRowHeaderWidth=this.effectiveRowHeaderWidth),this._zoomController.syncWithOption(),this.option?.history&&this._historyManager.updateOptions({enabled:this.option.history.enabled,maxDepth:this.option.history.maxDepth,onUndo:this.option.history.onUndo,onRedo:this.option.history.onRedo})),(e.has(`rows`)||e.has(`option`)||e.has(`currentRowHeaderWidth`)||e.has(`zoomPercent`)||e.has(`zoomPxPerDay`)||e.has(`zoomPxPerMonth`))&&(this._layoutCache=null),e.has(`rows`)){let{rows:e,hasChanges:t}=this._treeController.syncCollapsedWithRows(this.rows);t&&(this.rows=e)}if(e.has(`selectedRowIds`)){let e=new Set(this.selectedRowIds);(e.size!==this.selectedRows.size||![...e].every(e=>this.selectedRows.has(e)))&&(this.selectedRows=e)}if(e.has(`selectedTaskIds`)){let e=new Set(this.selectedTaskIds);(e.size!==this.selectedTasks.size||![...e].every(e=>this.selectedTasks.has(e)))&&(this.selectedTasks=e)}(e.has(`selectedTasks`)||this._cachedSelectedTasksSize!==this.selectedTasks.size)&&(this._cachedSelectedTaskIds=[...this.selectedTasks],this._cachedSelectedTasksSize=this.selectedTasks.size)}updated(e){if(super.updated(e),e.has(`option`)&&this.option?.plugins)for(let e of this.option.plugins)this.use(e);this._tooltipController.updateTooltipDOM(),this._pluginManager.executeAfterRender()}updateDragOverlay(){this._taskDragController.updateDragOverlay()}hideDragOverlay(){this._taskDragController.hideDragOverlay()}setupCurrentTimeTimer(){this.stopCurrentTimeTimer();let e=this.option.calendar.currentTimeUpdateInterval;e&&e>0&&(this.currentTimeTimer=window.setInterval(()=>{this.currentTime=new Date},e))}stopCurrentTimeTimer(){this.currentTimeTimer!==void 0&&(window.clearInterval(this.currentTimeTimer),this.currentTimeTimer=void 0)}handleHeaderResizeStart(e){e.preventDefault(),e.stopPropagation(),this.isResizingHeader=!0;let t=e.clientX,n=this.currentRowHeaderWidth,r=e.target;r.setPointerCapture(e.pointerId);let i=this.option.rowHeader?.minWidth??50,a=this.option.rowHeader?.maxWidth??2**53-1,o=e=>{let r=e.clientX-t,o=n+r;this.currentRowHeaderWidth=Math.max(i,Math.min(a,o))},s=()=>{this.isResizingHeader=!1,r.releasePointerCapture(e.pointerId),r.removeEventListener(`pointermove`,o),r.removeEventListener(`pointerup`,s);let t=Math.round(this.currentRowHeaderWidth);this.currentRowHeaderWidth=t,this.baseRowHeaderWidth=this.isScaleRowHeaderEnabled?Math.max(60,Math.round(t/this.effectiveZoomScale)):t,this.dispatchEvent(new CustomEvent(`row-header-resize`,{detail:{width:t},bubbles:!0,composed:!0}))};r.addEventListener(`pointermove`,o),r.addEventListener(`pointerup`,s)}getDateX(e){return j(e,this.option.calendar.start,this.effectivePxPerDay,this.effectivePxPerMonth)}calculateLayout(){if(this._layoutCache)return this._layoutCache;let e=0,t=this.currentRowHeaderWidth,n=new Map,r={layouts:this.displayRows.map(r=>{let{tasksWithLanes:i,laneCount:a}=N(r.tasks),o=this.effectiveBarHeight,s=this.option.bar?.margin??4;i.forEach(r=>{let i=this.getDateX(r.start)+t,a=this.getDateX(r.end)+t-i,c=e+r.lane*(o+s)+s;n.set(r.id,{x:i,y:c,width:a,height:o,dependencies:r.dependencies,isSummary:r.type===`summary`})});let c=a*(o+s)+s,l={top:e,height:c};return e+=c,l}),taskCoords:n,totalHeight:e};return this._layoutCache=r,r}isMultiDrag(e){return this._taskDragController.isMultiDrag(e)}isMultiDragSameRow(){return this._taskDragController.isMultiDragSameRow()}handleBarMouseEnter(e){this._tooltipController.handleBarMouseEnter(e.detail)}handleBarMouseLeave(){this._tooltipController.handleBarMouseLeave()}async reorderRows(e,t,n){return this._rowReorderController.reorderRows(e,t,n)}handleExternalTaskDrop(e,t){this._taskDragController.handleExternalTaskDrop(e,t)}handleRowClicked(e){let{rowId:t,event:n}=e.detail,{shiftKey:r,ctrlKey:i,metaKey:a}=n;this.selectedDependency&&this.clearDependencySelection();let o=new Set(this.selectedRows);if(r&&this.lastClickedRowId){let e=this.rows.findIndex(e=>e.id===this.lastClickedRowId),n=this.rows.findIndex(e=>e.id===t);if(e!==-1&&n!==-1){let t=Math.min(e,n),r=Math.max(e,n);for(let e=t;e<=r;e++)o.add(this.rows[e].id)}}else if(i||a)o.has(t)?o.delete(t):o.add(t),this.lastClickedRowId=t;else{if(o.has(t)){this.lastClickedRowId=t;return}o.clear(),o.add(t),this.lastClickedRowId=t}this.selectedRows=o,this.dispatchEvent(new CustomEvent(`row-selection-change`,{detail:{selectedIds:Array.from(this.selectedRows)},bubbles:!0,composed:!0}))}handleRowContextMenu(e){this.selectedRows.has(e.detail.rowId)||this.handleRowClicked(e)}stopMarqueeAutoScroll(){this._marqueeController.stopMarqueeAutoScroll()}handleContainerClick(e){if(this._marqueeController.justFinishedMarquee){this._marqueeController.justFinishedMarquee=!1;return}e.defaultPrevented||this.clearSelection()}handleContainerContextMenu(e){if(e.defaultPrevented)return;e.preventDefault();let t=this.shadowRoot?.querySelector(`.scroll-container`);if(!t)return;let n=t.getBoundingClientRect(),r=t.scrollLeft,i=t.scrollTop,a=this.currentRowHeaderWidth,o=e.clientY-n.top+i-this.calendarHeight,{layouts:s}=this.calculateLayout(),c;for(let e=0;e<s.length;e++){let t=s[e];if(o>=t.top&&o<t.top+t.height){c=this.displayRows[e].id;break}}if(c){let t=e.clientX-n.left+r-a,i=this.effectivePxPerDay,o=this.effectivePxPerMonth,s=M(t,this.option.calendar.start,i,o);this.dispatchEvent(new CustomEvent(`chart-contextmenu`,{detail:{event:e,date:s,rowId:c},bubbles:!0,composed:!0}))}this.clearSelection()}hitTest(e,t){let n=this.shadowRoot?.querySelector(`.scroll-container`);if(!n)return null;let r=n.getBoundingClientRect(),i=n.scrollLeft,a=n.scrollTop,o=this.currentRowHeaderWidth,s=t-r.top+a-this.calendarHeight,{layouts:c}=this.calculateLayout(),l;for(let e=0;e<c.length;e++){let t=c[e];if(s>=t.top&&s<t.top+t.height){l=this.displayRows[e].id;break}}if(!l)return null;let u=e-r.left+i-o,d=this.effectivePxPerDay,f=this.effectivePxPerMonth,p=M(u,this.option.calendar.start,d,f);return{rowId:l,date:p}}getRowPositions(){let{layouts:e}=this.calculateLayout();return e.map(e=>({top:e.top,height:e.height,bottom:e.top+e.height}))}use(e,t){return this._pluginManager.use(e,t),this}get historyManager(){return this._historyManager}get canUndo(){return this._historyManager.canUndo}get canRedo(){return this._historyManager.canRedo}async undo(){return this._historyManager.undo()}async redo(){return this._historyManager.redo()}clearHistory(){this._historyManager.clear()}recordCommand(e){this.option?.history?.enabled!==!1&&(this._historyManager.execute(e),this.dispatchEvent(new CustomEvent(`command`,{detail:{command:e},bubbles:!0,composed:!0})))}applyRowsChangeWithCommand(e,t,n){document.activeElement!==this&&this.focus(),this.rows=t,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}));let r={id:`cmd-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:n.type,description:n.description,timestamp:Date.now(),before:e,after:t,undo:()=>{this.clearDependencySelection(),this.rows=e,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))},redo:()=>{this.clearDependencySelection(),this.rows=t,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))}};this.recordCommand(r)}get pluginManager(){return this._pluginManager}async exportImage(e=`png`,t={}){throw Error(`[Moguchart] chart.exportImage() requires "@mogura/moguchart-plugin-export". Please install "@mogura/moguchart-plugin-export" and register it: chart.use(exportPlugin())`)}zoomToPercent(e){this._zoomController.zoomToPercent(e)}zoomToScale(e){this._zoomController.zoomToScale(e)}zoomIn(e){this._zoomController.zoomIn(e)}zoomOut(e){this._zoomController.zoomOut(e)}getZoomPercent(){return this._zoomController.getZoomPercent()}getZoomScale(){return this._zoomController.getZoomScale()}zoomTo(e){this._zoomController.zoomTo(e)}zoomToFit(){this._zoomController.zoomToFit()}resetZoom(){this._zoomController.resetZoom()}clearDependencySelection(){this._dependencyController.clearDependencySelection()}selectDependency(e,t){this._dependencyController.selectDependency(e,t)}triggerDependencyDelete(e,t,n){this._dependencyController.triggerDependencyDelete(e,t,n)}clearSelection(){(this.selectedRows.size!==0||this.selectedTasks.size!==0||this.selectedDependency)&&(this.selectedRows.size>0&&(this.selectedRows=new Set,this.dispatchEvent(new CustomEvent(`row-selection-change`,{detail:{selectedIds:[]},bubbles:!0,composed:!0}))),this.selectedTasks.size>0&&(this.selectedTasks=new Set,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[]},bubbles:!0,composed:!0}))),this.selectedDependency&&this.clearDependencySelection())}handleBarClick(e){e.stopPropagation();let{task:t,isMultiSelect:n}=e.detail;this.draggingTask=null,this.dragTargetRowIndex=null,this.dragOverlayInfo&&(this.dragOverlayInfo={...this.dragOverlayInfo,visible:!1},this.hideDragOverlay()),this.selectedDependency&&this.clearDependencySelection();let r;n?(r=new Set(this.selectedTasks),r.has(t.id)?r.delete(t.id):r.add(t.id)):r=new Set([t.id]),this.selectedTasks=r,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[...r]},bubbles:!0,composed:!0}))}handleBarContextMenu(e){let{task:t}=e.detail;this.selectedTasks.has(t.id)||(this.selectedTasks=new Set([t.id]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[t.id]},bubbles:!0,composed:!0})))}selectTask(e){let t=!1;for(let n of this.displayRows)if(n.tasks.some(t=>t.id===e)){t=!0;break}return t?(this.selectedTasks=new Set([e]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[e]},bubbles:!0,composed:!0})),this.scrollToTask(e),!0):!1}handleRowToggleCollapse(e){this._treeController.handleRowToggleCollapse(e)}toggleRowCollapse(e,t){return this._treeController.toggleRowCollapse(e,t)}collapseAll(){this._treeController.collapseAll()}expandAll(){this._treeController.expandAll()}resetScroll(){let e=this._scrollContainer??this.shadowRoot?.querySelector(`.scroll-container`);e&&(e.scrollLeft=0,e.scrollTop=0),this.currentScrollLeft=0,this.currentScrollTop=0,this.virtualScrollTop=0,this.requestUpdate()}scrollToPosition(e){let t=this._scrollContainer??this.shadowRoot?.querySelector(`.scroll-container`);t&&(t.scrollTo({left:e.left,top:e.top,behavior:e.behavior??`auto`}),e.left!==void 0&&(this.currentScrollLeft=e.left),e.top!==void 0&&(this.currentScrollTop=e.top,this.virtualScrollTop=e.top),this.requestUpdate())}scrollToTask(e){let{taskCoords:t}=this.calculateLayout(),n=t.get(e);if(!n)return;let r=this.shadowRoot?.querySelector(`.scroll-container`);if(!r)return;let i=this.currentRowHeaderWidth,a=n.y+this.calendarHeight,o=a+n.height,s=r.scrollTop,c=r.scrollTop+r.clientHeight;if(a<s||o>c){let e=a-r.clientHeight/2+n.height/2;r.scrollTo({top:Math.max(0,e),behavior:`smooth`})}let l=n.x,u=n.x+n.width,d=r.scrollLeft+i,f=r.scrollLeft+r.clientWidth;if(l<d||u>f){let e=l-i-20;r.scrollTo({left:Math.max(0,e),behavior:`smooth`})}}render(){let e=P(this.theme,this.option.customTheme),{layouts:n,taskCoords:r,totalHeight:a}=this.calculateLayout(),o=this.currentRowHeaderWidth;(this._lastOptionRef!==this.option||this._lastLabelWidth!==o||this._lastZoomPercent!==this.zoomPercent||this._lastZoomPxPerDay!==this.zoomPxPerDay||this._lastZoomPxPerMonth!==this.zoomPxPerMonth)&&(this._cachedCurrentOption={...this.option,rowHeader:{...this.option.rowHeader,width:o},calendar:{...this.option.calendar,pxPerDay:this.effectivePxPerDay,pxPerMonth:this.effectivePxPerMonth},bar:{...this.option.bar,height:this.effectiveBarHeight}},this._lastOptionRef=this.option,this._lastLabelWidth=o,this._lastZoomPercent=this.zoomPercent,this._lastZoomPxPerDay=this.zoomPxPerDay,this._lastZoomPxPerMonth=this.zoomPxPerMonth);let s=this._cachedCurrentOption,c=0,l=this.displayRows.length-1;if(!this.isExporting){for(let e=0;e<n.length;e++)if(n[e].top+n[e].height>this.virtualScrollTop){c=Math.max(0,e-5);break}for(let e=c;e<n.length;e++)if(n[e].top>this.virtualScrollTop+this.viewportHeight){l=Math.min(this.displayRows.length-1,e+5);break}}let u=this.displayRows.slice(c,l+1),d=X(this.rows),f=be(this.rows),p=new Set;for(let e of this.rows)e.parentId&&p.add(e.parentId);let m=this.isExporting?0:n[c]?n[c].top:0,h=n[l],g=h?h.top+h.height:0,_=Math.max(0,a-g),v=a>this.viewportHeight,y=this.option.dependency?.showCriticalPath===!0,b=y?G(this.displayRows):new Set;return t.html`
1725
1725
  <style>${pe(this.theme,this.option.customTheme)}
1726
1726
  :host {
1727
1727
  --critical-path-color: ${e.criticalPath??`rgba(220, 38, 38, 0.85)`};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mogura/moguchart-core",
3
3
  "type": "module",
4
- "version": "1.3.0",
4
+ "version": "1.3.1",
5
5
  "description": "軽量でフレームワーク非依存のWeb Components製ガントチャートコンポーネント (Lit)。A lightweight, framework-agnostic Gantt chart Web Component for Vue, React, Angular, and Svelte.",
6
6
  "license": "MIT",
7
7
  "author": "Murakami Hiroyuki",
@@ -60,8 +60,8 @@
60
60
  "typescript": "^5.9.3",
61
61
  "vite": "^8.0.0",
62
62
  "vitest": "^4.0.16",
63
- "@mogura/moguchart-plugin-excel": "1.3.0",
64
- "@mogura/moguchart-plugin-export": "1.3.0"
63
+ "@mogura/moguchart-plugin-excel": "1.3.1",
64
+ "@mogura/moguchart-plugin-export": "1.3.1"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "lit": "^3.0.0"