@katlux/toolkit 0.1.0-beta.5 → 0.1.0-beta.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/dist/compiled/composables/usePresetComponent.mjs +21 -16
  2. package/dist/module.cjs +52 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +52 -0
  5. package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
  6. package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +11 -12
  7. package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +11 -12
  8. package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +1 -0
  9. package/dist/runtime/components/KCalendar/KCalendar.logic.js +25 -10
  10. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +21 -0
  11. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue +3 -1
  12. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +21 -0
  13. package/dist/runtime/components/KCheckbox/KCheckbox.logic.d.ts +11 -0
  14. package/dist/runtime/components/KCheckbox/KCheckbox.logic.js +9 -0
  15. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +48 -10
  16. package/dist/runtime/components/KCombobox/KCombobox.global.vue +9 -2
  17. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +48 -10
  18. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +94 -0
  19. package/dist/runtime/components/KCombobox/KCombobox.logic.js +60 -9
  20. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +169 -0
  21. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue +46 -0
  22. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +169 -0
  23. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +127 -0
  24. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.js +160 -0
  25. package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +20 -0
  26. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +12 -0
  27. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +77 -8
  28. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +25 -3
  29. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +77 -8
  30. package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +33 -1
  31. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +98 -7
  32. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +75 -8
  33. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue +25 -3
  34. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +75 -8
  35. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.d.ts +33 -1
  36. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +157 -7
  37. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +18 -0
  38. package/dist/runtime/components/KDropdown/KDropdown.global.vue +13 -4
  39. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +18 -0
  40. package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +28 -1
  41. package/dist/runtime/components/KDropdown/KDropdown.logic.js +85 -4
  42. package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +7 -56
  43. package/dist/runtime/components/KGrid/KGrid.global.vue +9 -2
  44. package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +7 -56
  45. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +41 -0
  46. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue +27 -12
  47. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +41 -0
  48. package/dist/runtime/components/KHourPicker/KHourPicker.logic.d.ts +26 -3
  49. package/dist/runtime/components/KHourPicker/KHourPicker.logic.js +34 -10
  50. package/dist/runtime/components/KHourSelect/KHourSelect.logic.js +4 -1
  51. package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +1 -1
  52. package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +1 -1
  53. package/dist/runtime/components/KIcon/KIcon.logic.d.ts +1 -1
  54. package/dist/runtime/components/KIcon/KIcon.logic.js +13 -8
  55. package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +3 -3
  56. package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +3 -3
  57. package/dist/runtime/components/KLoader/KLoader.logic.d.ts +8 -1
  58. package/dist/runtime/components/KLoader/KLoader.logic.js +1 -0
  59. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +21 -0
  60. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue +4 -2
  61. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +21 -0
  62. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.logic.d.ts +11 -0
  63. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.logic.js +9 -0
  64. package/dist/runtime/components/KModal/KModal.global.vue +4 -1
  65. package/dist/runtime/components/KModal/KModal.logic.d.ts +3 -1
  66. package/dist/runtime/components/KModal/KModal.logic.js +6 -2
  67. package/dist/runtime/components/KPanel/KPanel.global.d.vue.ts +5 -28
  68. package/dist/runtime/components/KPanel/KPanel.global.vue +12 -4
  69. package/dist/runtime/components/KPanel/KPanel.global.vue.d.ts +5 -28
  70. package/dist/runtime/components/KPanel/KPanel.logic.d.ts +10 -0
  71. package/dist/runtime/components/KPanel/KPanel.logic.js +8 -0
  72. package/dist/runtime/components/KRadiobox/KRadiobox.global.d.vue.ts +21 -0
  73. package/dist/runtime/components/KRadiobox/KRadiobox.global.vue +3 -1
  74. package/dist/runtime/components/KRadiobox/KRadiobox.global.vue.d.ts +21 -0
  75. package/dist/runtime/components/KRadiobox/KRadiobox.logic.d.ts +11 -0
  76. package/dist/runtime/components/KRadiobox/KRadiobox.logic.js +9 -0
  77. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +21 -0
  78. package/dist/runtime/components/KTextarea/KTextarea.global.vue +3 -1
  79. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +21 -0
  80. package/dist/runtime/components/KTextarea/KTextarea.logic.d.ts +11 -0
  81. package/dist/runtime/components/KTextarea/KTextarea.logic.js +9 -0
  82. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +35 -2
  83. package/dist/runtime/components/KTextbox/KTextbox.global.vue +7 -4
  84. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +35 -2
  85. package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +21 -4
  86. package/dist/runtime/components/KTextbox/KTextbox.logic.js +21 -5
  87. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +36 -7
  88. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +4 -1
  89. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +36 -7
  90. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +94 -0
  91. package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +18 -1
  92. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +3 -3
  93. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +3 -3
  94. package/dist/runtime/composables/usePresetComponent.d.ts +16 -0
  95. package/dist/runtime/composables/usePresetComponent.js +21 -16
  96. package/dist/runtime/presets/default/assets/scss/css-variables.css +64 -13
  97. package/dist/runtime/presets/default/assets/scss/css-variables.scss +286 -0
  98. package/dist/runtime/presets/default/assets/scss/docs.scss +52 -0
  99. package/dist/runtime/presets/default/assets/scss/index.css +99 -13
  100. package/dist/runtime/presets/default/assets/scss/index.scss +42 -0
  101. package/dist/runtime/presets/default/assets/scss/mixins.scss +94 -0
  102. package/dist/runtime/presets/default/assets/scss/reset.scss +16 -0
  103. package/dist/runtime/presets/default/components/KAccordion/KAccordion.vue +5 -2
  104. package/dist/runtime/presets/default/components/KAccordion/KAccordionItem.vue +40 -37
  105. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +29 -22
  106. package/dist/runtime/presets/default/components/KButton/KButton.vue +147 -428
  107. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +57 -53
  108. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +189 -161
  109. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +2 -0
  110. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +56 -42
  111. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +2 -0
  112. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +5 -0
  113. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +111 -87
  114. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +5 -0
  115. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +78 -60
  116. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.d.vue.ts +29 -0
  117. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue +202 -0
  118. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue.d.ts +29 -0
  119. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +40 -31
  120. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +110 -92
  121. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +5 -0
  122. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +56 -25
  123. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +5 -0
  124. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.d.vue.ts +5 -0
  125. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue +79 -52
  126. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue.d.ts +5 -0
  127. package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +8 -0
  128. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +46 -25
  129. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +8 -0
  130. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +337 -241
  131. package/dist/runtime/presets/default/components/KGantt/KGanttRuler.vue +40 -35
  132. package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +170 -140
  133. package/dist/runtime/presets/default/components/KGrid/KGrid.vue +62 -60
  134. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.d.vue.ts +8 -2
  135. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue +48 -28
  136. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue.d.ts +8 -2
  137. package/dist/runtime/presets/default/components/KHourSelect/KHourSelect.vue +34 -28
  138. package/dist/runtime/presets/default/components/KIcon/KIcon.d.vue.ts +1 -1
  139. package/dist/runtime/presets/default/components/KIcon/KIcon.vue +31 -22
  140. package/dist/runtime/presets/default/components/KIcon/KIcon.vue.d.ts +1 -1
  141. package/dist/runtime/presets/default/components/KLoader/KLoader.vue +65 -48
  142. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.d.vue.ts +2 -0
  143. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +117 -84
  144. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue.d.ts +2 -0
  145. package/dist/runtime/presets/default/components/KModal/KModal.d.vue.ts +1 -0
  146. package/dist/runtime/presets/default/components/KModal/KModal.vue +64 -35
  147. package/dist/runtime/presets/default/components/KModal/KModal.vue.d.ts +1 -0
  148. package/dist/runtime/presets/default/components/KPagination/KPagination.vue +42 -40
  149. package/dist/runtime/presets/default/components/KPanel/KPanel.d.vue.ts +3 -0
  150. package/dist/runtime/presets/default/components/KPanel/KPanel.vue +95 -34
  151. package/dist/runtime/presets/default/components/KPanel/KPanel.vue.d.ts +3 -0
  152. package/dist/runtime/presets/default/components/KRadiobox/KRadiobox.d.vue.ts +2 -0
  153. package/dist/runtime/presets/default/components/KRadiobox/KRadiobox.vue +40 -35
  154. package/dist/runtime/presets/default/components/KRadiobox/KRadiobox.vue.d.ts +2 -0
  155. package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +158 -125
  156. package/dist/runtime/presets/default/components/KSlider/KSlider.vue +123 -100
  157. package/dist/runtime/presets/default/components/KTabs/KTabItem.vue +40 -37
  158. package/dist/runtime/presets/default/components/KTabs/KTabs.vue +9 -6
  159. package/dist/runtime/presets/default/components/KTextarea/KTextarea.d.vue.ts +2 -0
  160. package/dist/runtime/presets/default/components/KTextarea/KTextarea.vue +28 -21
  161. package/dist/runtime/presets/default/components/KTextarea/KTextarea.vue.d.ts +2 -0
  162. package/dist/runtime/presets/default/components/KTextbox/KTextbox.d.vue.ts +4 -1
  163. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +53 -36
  164. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue.d.ts +4 -1
  165. package/dist/runtime/presets/default/components/KTree/KTree.vue +102 -80
  166. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.d.vue.ts +2 -0
  167. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue +59 -34
  168. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue.d.ts +2 -0
  169. package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +31 -30
  170. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +34 -27
  171. package/package.json +5 -5
@@ -24,7 +24,7 @@
24
24
  KButton(
25
25
  v-for="rowAction in rowActions"
26
26
  :key="rowAction.label"
27
- :type="rowAction.type || 'secondary'"
27
+ :type="rowAction.type || 'default'"
28
28
  size="small"
29
29
  @click="rowAction.action(row)"
30
30
  ) {{ rowAction.label }}
@@ -53,252 +53,348 @@
53
53
  )
54
54
  </template>
55
55
 
56
- <script setup>
57
- import { computed, ref } from "vue";
58
- import KGanttRuler from "./KGanttRuler.vue";
59
- import KGanttTimeline from "./KGanttTimeline.vue";
60
- import { getSnapMs, isTaskOverlapping, calculateGanttMinWidth } from "#toolkit/components/KGantt/KGantt.logic";
61
- const props = defineProps({
62
- dataProvider: { type: null, required: true },
63
- columns: { type: Array, required: true },
64
- treeColumnIndex: { type: Number, required: false },
65
- bulkActions: { type: Array, required: false },
66
- rowActions: { type: Array, required: false },
67
- globalDateRange: { type: Object, required: true },
68
- totalDuration: { type: Number, required: true },
69
- resolvedMapping: { type: null, required: true },
70
- getTasksForRow: { type: Function, required: true },
71
- getTaskStyle: { type: Function, required: true },
72
- editable: { type: Boolean, required: false },
73
- snapTo: { type: String, required: false },
74
- resourceTypeField: { type: String, required: false },
75
- taskTypeField: { type: String, required: false },
76
- selectedRows: { type: Array, required: false },
77
- selectAll: { type: Boolean, required: false },
78
- cellSlots: { type: null, required: false },
79
- headerSlots: { type: null, required: false },
80
- endingPoint: { type: [Date, String, Number], required: false },
81
- mode: { type: String, required: false },
82
- moveTime: { type: Function, required: false },
83
- zoom: { type: Function, required: false }
84
- });
85
- const emit = defineEmits(["update:task", "update:selectedRows", "update:selectAll"]);
86
- const activeDragState = ref(null);
87
- const scrollContainer = ref(null);
88
- const isDraggingGantt = ref(false);
89
- let ganttDragStartX = 0;
90
- const onMouseDown = (e) => {
91
- if (e.button !== 0) return;
92
- const target = e.target;
93
- if (target.closest(".gantt-bar")) return;
94
- if (!target.closest('[data-field="ganttTimeline"]')) return;
95
- isDraggingGantt.value = true;
96
- ganttDragStartX = e.clientX;
97
- window.addEventListener("mousemove", onGanttMouseMove);
98
- window.addEventListener("mouseup", onGanttMouseUp);
99
- };
100
- const onGanttMouseMove = (e) => {
101
- if (!isDraggingGantt.value) return;
102
- e.preventDefault();
103
- const deltaX = e.clientX - ganttDragStartX;
104
- ganttDragStartX = e.clientX;
105
- if (scrollContainer.value) {
106
- const wrapperWidth = scrollContainer.value.clientWidth || 1e3;
107
- const viewportDuration = props.globalDateRange.end - props.globalDateRange.start;
108
- const msPerPx = viewportDuration / wrapperWidth;
109
- props.moveTime?.(-deltaX * msPerPx);
110
- }
111
- };
56
+ <script lang="ts" setup>
57
+ import { computed, ref } from 'vue'
58
+ import KGanttRuler from './KGanttRuler.vue'
59
+ import KGanttTimeline from './KGanttTimeline.vue'
60
+ import type { ITreeViewColumn, IRowAction } from '#toolkit/components/KTreeView/KTreeView.logic'
61
+ import type { IKDatatableAction } from '@katlux/providers'
62
+ import type { IGanttTask } from '#toolkit/components/KGantt/KGantt.logic'
63
+ import { getSnapMs, isTaskOverlapping, calculateGanttMinWidth } from '#toolkit/components/KGantt/KGantt.logic'
64
+
65
+ const props = defineProps<{
66
+ dataProvider: any
67
+ columns: ITreeViewColumn[]
68
+ treeColumnIndex?: number
69
+ bulkActions?: IKDatatableAction[]
70
+ rowActions?: IRowAction[]
71
+
72
+ globalDateRange: { start: number, end: number }
73
+ totalDuration: number
74
+ resolvedMapping: any
75
+ getTasksForRow: (row: any) => IGanttTask[]
76
+ getTaskStyle: (task: any) => any
77
+
78
+ editable?: boolean
79
+ snapTo?: string
80
+ resourceTypeField?: string
81
+ taskTypeField?: string
82
+
83
+ selectedRows?: any[]
84
+ selectAll?: boolean
85
+ cellSlots?: any
86
+ headerSlots?: any
87
+
88
+ endingPoint?: Date | string | number
89
+ mode?: 'date' | 'numeric'
90
+
91
+ moveTime?: (amount: number) => void
92
+ zoom?: (factor: number) => void
93
+ }>()
94
+
95
+ const emit = defineEmits<{
96
+ (e: 'update:task', payload: { task: IGanttTask; sourceRow: any; targetRow?: any }): void
97
+ (e: 'update:selectedRows', value: any[]): void
98
+ (e: 'update:selectAll', value: boolean): void
99
+ }>()
100
+
101
+ // ── Drag state (owned here so all rows can share it) ─────────────
102
+ interface ActiveDrag {
103
+ taskId: string | number
104
+ task: IGanttTask
105
+ sourceRow: any
106
+ sourceRowId: string | number
107
+ currentHoverRow: any
108
+ mode: 'move' | 'resize-left' | 'resize-right'
109
+ startX: number
110
+ wrapperWidth: number
111
+ originalStartMs: number
112
+ originalEndMs: number
113
+ currentStartMs: number
114
+ currentEndMs: number
115
+ }
116
+
117
+ const activeDragState = ref<ActiveDrag | null>(null)
118
+ const scrollContainer = ref<HTMLElement | null>(null)
119
+
120
+ // ── Drag to pan state ─────────────
121
+ const isDraggingGantt = ref(false)
122
+ let ganttDragStartX = 0
123
+
124
+ const onMouseDown = (e: MouseEvent) => {
125
+ // Only initiate drag if left button and target is not a task bar or its resize handles
126
+ if (e.button !== 0) return
127
+ const target = e.target as HTMLElement
128
+ if (target.closest('.gantt-bar')) return
129
+
130
+ // MUST be inside the timeline cell to start panning
131
+ if (!target.closest('[data-field="ganttTimeline"]')) return
132
+
133
+ isDraggingGantt.value = true
134
+ ganttDragStartX = e.clientX
135
+
136
+ window.addEventListener('mousemove', onGanttMouseMove)
137
+ window.addEventListener('mouseup', onGanttMouseUp)
138
+ }
139
+
140
+ const onGanttMouseMove = (e: MouseEvent) => {
141
+ if (!isDraggingGantt.value) return
142
+ e.preventDefault()
143
+
144
+ const deltaX = e.clientX - ganttDragStartX
145
+ ganttDragStartX = e.clientX
146
+
147
+ if (scrollContainer.value) {
148
+ const wrapperWidth = scrollContainer.value.clientWidth || 1000
149
+ const viewportDuration = props.globalDateRange.end - props.globalDateRange.start
150
+ const msPerPx = viewportDuration / wrapperWidth
151
+
152
+ // If we drag mouse left (deltaX < 0), time moves forward (moveTime > 0)
153
+ props.moveTime?.(-deltaX * msPerPx)
154
+ }
155
+ }
156
+
112
157
  const onGanttMouseUp = () => {
113
- isDraggingGantt.value = false;
114
- window.removeEventListener("mousemove", onGanttMouseMove);
115
- window.removeEventListener("mouseup", onGanttMouseUp);
116
- };
117
- const onWheel = (e) => {
118
- const viewportDuration = props.globalDateRange.end - props.globalDateRange.start;
119
- if (e.ctrlKey) {
120
- e.preventDefault();
121
- const factor = e.deltaY > 0 ? -0.1 : 0.1;
122
- props.zoom?.(factor);
123
- } else if (e.shiftKey) {
124
- e.preventDefault();
125
- const direction = e.deltaY > 0 ? 1 : -1;
126
- const delta = viewportDuration * 0.1 * direction;
127
- props.moveTime?.(delta);
128
- }
129
- };
130
- const onTaskDragStart = ({ event, task, rowId, mode, wrapperEl }, row) => {
131
- console.log("[KGantt] onTaskDragStart called", { editable: props.editable, mode, taskId: task.id, wrapperElFound: !!wrapperEl });
132
- if (!props.editable) {
133
- console.warn("[KGantt] ABORT: not editable");
134
- return;
135
- }
136
- event.preventDefault();
137
- const wrapperRect = wrapperEl?.getBoundingClientRect();
138
- const wrapperWidth = wrapperRect?.width ?? 1e3;
139
- const startField = props.resolvedMapping?.startDate ?? "startDate";
140
- const endField = props.resolvedMapping?.endDate ?? "endDate";
141
- const originalStartMs = new Date(task[startField]).getTime();
142
- const originalEndMs = new Date(task[endField]).getTime();
143
- activeDragState.value = {
144
- taskId: task.id,
145
- task,
146
- sourceRow: row,
147
- sourceRowId: row?.id,
148
- currentHoverRow: row,
149
- mode,
150
- startX: event.clientX,
151
- wrapperWidth,
152
- originalStartMs,
153
- originalEndMs,
154
- currentStartMs: originalStartMs,
155
- currentEndMs: originalEndMs
156
- };
157
- window.addEventListener("mousemove", onMouseMove);
158
- window.addEventListener("mouseup", onMouseUp);
159
- };
160
- const onCellMouseEnter = (rowId, row) => {
161
- if (!activeDragState.value) return;
162
- if (activeDragState.value.mode === "move") {
163
- activeDragState.value.currentHoverRow = row;
164
- }
165
- };
166
- const onMouseMove = (e) => {
167
- if (!activeDragState.value) return;
168
- const state = activeDragState.value;
169
- const msPerPx = (props.globalDateRange.end - props.globalDateRange.start) / state.wrapperWidth;
170
- const deltaX = e.clientX - state.startX;
171
- const deltaMs = deltaX * msPerPx;
172
- const snapMs = getSnapMs(props.snapTo || "day");
173
- let newStart = state.originalStartMs;
174
- let newEnd = state.originalEndMs;
175
- if (state.mode === "move") {
176
- const snappedDelta = Math.round(deltaMs / snapMs) * snapMs;
177
- newStart = state.originalStartMs + snappedDelta;
178
- newEnd = state.originalEndMs + snappedDelta;
179
- } else if (state.mode === "resize-left") {
180
- const snappedDelta = Math.round(deltaMs / snapMs) * snapMs;
181
- newStart = Math.min(state.originalStartMs + snappedDelta, state.originalEndMs - snapMs);
182
- } else if (state.mode === "resize-right") {
183
- const snappedDelta = Math.round(deltaMs / snapMs) * snapMs;
184
- newEnd = Math.max(state.originalEndMs + snappedDelta, state.originalStartMs + snapMs);
185
- }
186
- state.currentStartMs = newStart;
187
- state.currentEndMs = newEnd;
188
- };
189
- const onMouseUp = () => {
190
- window.removeEventListener("mousemove", onMouseMove);
191
- window.removeEventListener("mouseup", onMouseUp);
192
- if (!activeDragState.value) {
193
- console.warn("[KGantt] onMouseUp: no activeDragState");
194
- return;
195
- }
196
- const state = activeDragState.value;
197
- const startField = props.resolvedMapping?.startDate ?? "startDate";
198
- const endField = props.resolvedMapping?.endDate ?? "endDate";
199
- const tasksField = props.resolvedMapping?.tasksField ?? "tasks";
200
- const updatedTask = {
201
- ...state.task,
202
- [startField]: state.currentStartMs,
203
- [endField]: state.currentEndMs
204
- };
205
- console.log("[KGantt] onMouseUp", {
206
- mode: state.mode,
207
- originalStart: new Date(state.originalStartMs).toISOString(),
208
- currentStart: new Date(state.currentStartMs).toISOString(),
209
- sameTime: state.currentStartMs === state.originalStartMs,
210
- wrapperWidth: state.wrapperWidth
211
- });
212
- let targetRow = state.sourceRow;
213
- if (state.mode === "move" && state.currentHoverRow !== state.sourceRow) {
214
- const hoverRow = state.currentHoverRow;
215
- const resourceTypeField = props.resourceTypeField || "type";
216
- const taskTypeField = props.resolvedMapping?.taskTypeField || "type";
217
- const taskType = state.task[taskTypeField];
218
- if (resourceTypeField) {
219
- const myType = state.sourceRow?.[resourceTypeField];
220
- const theirType = hoverRow?.[resourceTypeField];
221
- console.log("[KGantt] cross-row check", { myType, theirType, taskType, taskTypeField });
222
- if (taskType && theirType && taskType !== theirType) {
223
- console.warn("[KGantt] CANCEL: task type mismatch with target resource");
224
- activeDragState.value = null;
225
- return;
226
- }
227
- if (myType && theirType && myType !== theirType) {
228
- console.warn("[KGantt] CANCEL: resource type mismatch");
229
- activeDragState.value = null;
230
- return;
231
- }
232
- }
233
- targetRow = hoverRow;
234
- }
235
- const targetTasks = targetRow === state.sourceRow ? props.getTasksForRow(targetRow) : targetRow?.[tasksField] || [];
236
- const overlapping = isTaskOverlapping(updatedTask, targetTasks, startField, endField);
237
- console.log("[KGantt] overlap check", {
238
- updatedTask: { id: updatedTask.id, start: updatedTask[startField], end: updatedTask[endField] },
239
- targetTaskCount: targetTasks.length,
240
- overlapping
241
- });
242
- if (overlapping) {
243
- console.warn("[KGantt] CANCEL: overlap detected");
244
- activeDragState.value = null;
245
- return;
246
- }
247
- console.log("[KGantt] COMMIT: emitting update:task");
248
- emit("update:task", {
249
- task: updatedTask,
250
- sourceRow: state.sourceRow,
251
- targetRow: targetRow !== state.sourceRow ? targetRow : void 0
252
- });
253
- activeDragState.value = null;
254
- };
255
- const ganttColumns = computed(() => {
256
- const cols = props.columns.map((col) => ({ ...col, width: col.width ?? "1%" }));
257
- cols.push({
258
- field: "ganttTimeline",
259
- header: "Timeline",
260
- width: calculateGanttMinWidth(props.globalDateRange.start, props.globalDateRange.end, 80, props.mode)
261
- });
262
- if (props.rowActions && props.rowActions.length > 0) {
263
- cols.push({
264
- field: "_ganttActions",
265
- header: "Actions",
266
- width: "1%"
267
- });
268
- }
269
- return cols;
270
- });
271
- </script>
158
+ isDraggingGantt.value = false
159
+ window.removeEventListener('mousemove', onGanttMouseMove)
160
+ window.removeEventListener('mouseup', onGanttMouseUp)
161
+ }
272
162
 
273
- <style scoped>
274
- .KGantt {
275
- width: 100%;
276
- height: 100%;
277
- overflow: hidden;
278
- display: flex;
279
- flex-direction: column;
163
+ const onWheel = (e: WheelEvent) => {
164
+ const viewportDuration = props.globalDateRange.end - props.globalDateRange.start
165
+
166
+ if (e.ctrlKey) {
167
+ // Ctrl + Scroll = Zoom
168
+ e.preventDefault()
169
+ const factor = e.deltaY > 0 ? -0.1 : 0.1
170
+ props.zoom?.(factor)
171
+ } else if (e.shiftKey) {
172
+ // Shift + Scroll = Horizontal Move
173
+ e.preventDefault()
174
+ const direction = e.deltaY > 0 ? 1 : -1
175
+ const delta = viewportDuration * 0.1 * direction
176
+ props.moveTime?.(delta)
177
+ }
178
+ // Let normal scroll through for vertical scrolling
280
179
  }
281
- .KGantt__scroll-container {
282
- flex: 1;
283
- width: 100%;
284
- overflow-x: auto;
285
- overflow-y: auto;
286
- cursor: grab;
180
+
181
+ const onTaskDragStart = (
182
+ { event, task, rowId, mode, wrapperEl }: { event: MouseEvent; task: IGanttTask; rowId: any; mode: string; wrapperEl: HTMLElement | null },
183
+ row: any
184
+ ) => {
185
+ console.log('[KGantt] onTaskDragStart called', { editable: props.editable, mode, taskId: task.id, wrapperElFound: !!wrapperEl })
186
+ if (!props.editable) { console.warn('[KGantt] ABORT: not editable'); return }
187
+ event.preventDefault()
188
+
189
+ const wrapperRect = wrapperEl?.getBoundingClientRect()
190
+ const wrapperWidth = wrapperRect?.width ?? 1000
191
+
192
+ const startField = props.resolvedMapping?.startDate ?? 'startDate'
193
+ const endField = props.resolvedMapping?.endDate ?? 'endDate'
194
+ const originalStartMs = new Date(task[startField]).getTime()
195
+ const originalEndMs = new Date(task[endField]).getTime()
196
+
197
+ activeDragState.value = {
198
+ taskId: task.id,
199
+ task,
200
+ sourceRow: row,
201
+ sourceRowId: row?.id,
202
+ currentHoverRow: row,
203
+ mode: mode as ActiveDrag['mode'],
204
+ startX: event.clientX,
205
+ wrapperWidth,
206
+ originalStartMs,
207
+ originalEndMs,
208
+ currentStartMs: originalStartMs,
209
+ currentEndMs: originalEndMs
210
+ }
211
+
212
+ window.addEventListener('mousemove', onMouseMove)
213
+ window.addEventListener('mouseup', onMouseUp)
287
214
  }
288
- .KGantt__scroll-container:active {
289
- cursor: grabbing;
215
+
216
+ const onCellMouseEnter = (rowId: any, row: any) => {
217
+ if (!activeDragState.value) return
218
+ // Track which row the mouse is hovering over during a move drag
219
+ if (activeDragState.value.mode === 'move') {
220
+ activeDragState.value.currentHoverRow = row
221
+ }
290
222
  }
291
- .KGantt__inner {
292
- min-width: 100%;
223
+
224
+ const onMouseMove = (e: MouseEvent) => {
225
+ if (!activeDragState.value) return
226
+
227
+ const state = activeDragState.value
228
+ const msPerPx = (props.globalDateRange.end - props.globalDateRange.start) / state.wrapperWidth
229
+ const deltaX = e.clientX - state.startX
230
+ const deltaMs = deltaX * msPerPx
231
+ const snapMs = getSnapMs(props.snapTo || 'day')
232
+
233
+ let newStart = state.originalStartMs
234
+ let newEnd = state.originalEndMs
235
+
236
+ if (state.mode === 'move') {
237
+ const snappedDelta = Math.round(deltaMs / snapMs) * snapMs
238
+ newStart = state.originalStartMs + snappedDelta
239
+ newEnd = state.originalEndMs + snappedDelta
240
+ } else if (state.mode === 'resize-left') {
241
+ const snappedDelta = Math.round(deltaMs / snapMs) * snapMs
242
+ newStart = Math.min(state.originalStartMs + snappedDelta, state.originalEndMs - snapMs)
243
+ } else if (state.mode === 'resize-right') {
244
+ const snappedDelta = Math.round(deltaMs / snapMs) * snapMs
245
+ newEnd = Math.max(state.originalEndMs + snappedDelta, state.originalStartMs + snapMs)
246
+ }
247
+
248
+ state.currentStartMs = newStart
249
+ state.currentEndMs = newEnd
293
250
  }
294
- .KGantt :deep(th[data-field="ganttTimeline"]),
295
- .KGantt :deep(td[data-field="ganttTimeline"]) {
296
- padding: 0;
251
+
252
+ const onMouseUp = () => {
253
+ window.removeEventListener('mousemove', onMouseMove)
254
+ window.removeEventListener('mouseup', onMouseUp)
255
+
256
+ if (!activeDragState.value) { console.warn('[KGantt] onMouseUp: no activeDragState'); return }
257
+
258
+ const state = activeDragState.value
259
+ const startField = props.resolvedMapping?.startDate ?? 'startDate'
260
+ const endField = props.resolvedMapping?.endDate ?? 'endDate'
261
+ const tasksField = props.resolvedMapping?.tasksField ?? 'tasks'
262
+
263
+ const updatedTask = {
264
+ ...state.task,
265
+ [startField]: state.currentStartMs,
266
+ [endField]: state.currentEndMs
267
+ }
268
+
269
+ console.log('[KGantt] onMouseUp', {
270
+ mode: state.mode,
271
+ originalStart: new Date(state.originalStartMs).toISOString(),
272
+ currentStart: new Date(state.currentStartMs).toISOString(),
273
+ sameTime: state.currentStartMs === state.originalStartMs,
274
+ wrapperWidth: state.wrapperWidth
275
+ })
276
+
277
+ let targetRow = state.sourceRow
278
+
279
+ // Check if the task was moved to a different row
280
+ if (state.mode === 'move' && state.currentHoverRow !== state.sourceRow) {
281
+ const hoverRow = state.currentHoverRow
282
+
283
+ // Enforce resource type compatibility
284
+ const resourceTypeField = props.resourceTypeField || 'type'
285
+ const taskTypeField = props.resolvedMapping?.taskTypeField || 'type'
286
+ const taskType = state.task[taskTypeField]
287
+
288
+ if (resourceTypeField) {
289
+ const myType = state.sourceRow?.[resourceTypeField]
290
+ const theirType = hoverRow?.[resourceTypeField]
291
+ console.log('[KGantt] cross-row check', { myType, theirType, taskType, taskTypeField })
292
+
293
+ // If task has a specific type, it MUST match the target resource type
294
+ if (taskType && theirType && taskType !== theirType) {
295
+ console.warn('[KGantt] CANCEL: task type mismatch with target resource')
296
+ activeDragState.value = null
297
+ return
298
+ }
299
+
300
+ // Original logic: if source resource has a type, target must match (if resourceTypeField is set)
301
+ // This covers the case where the task doesn't have a type, but we still want to keep it within the same resource group
302
+ if (myType && theirType && myType !== theirType) {
303
+ console.warn('[KGantt] CANCEL: resource type mismatch')
304
+ activeDragState.value = null
305
+ return
306
+ }
307
+ }
308
+
309
+ targetRow = hoverRow
310
+ }
311
+
312
+ // Overlap check on target row (excluding the task itself)
313
+ const targetTasks: IGanttTask[] = targetRow === state.sourceRow
314
+ ? props.getTasksForRow(targetRow)
315
+ : (targetRow?.[tasksField] || [])
316
+
317
+ const overlapping = isTaskOverlapping(updatedTask, targetTasks, startField, endField)
318
+ console.log('[KGantt] overlap check', {
319
+ updatedTask: { id: updatedTask.id, start: updatedTask[startField], end: updatedTask[endField] },
320
+ targetTaskCount: targetTasks.length,
321
+ overlapping
322
+ })
323
+
324
+ if (overlapping) {
325
+ console.warn('[KGantt] CANCEL: overlap detected')
326
+ activeDragState.value = null
327
+ return
328
+ }
329
+
330
+ console.log('[KGantt] COMMIT: emitting update:task')
331
+ emit('update:task', {
332
+
333
+ task: updatedTask,
334
+ sourceRow: state.sourceRow,
335
+ targetRow: targetRow !== state.sourceRow ? targetRow : undefined
336
+ })
337
+
338
+ activeDragState.value = null
297
339
  }
298
- .KGantt .gantt-actions {
299
- display: flex;
300
- gap: 8px;
301
- justify-content: flex-end;
302
- white-space: nowrap;
340
+
341
+ // User columns shrink to content; timeline fills remaining space
342
+ const ganttColumns = computed(() => {
343
+ const cols = props.columns.map(col => ({ ...col, width: col.width ?? '1%' }))
344
+
345
+ cols.push({
346
+ field: 'ganttTimeline',
347
+ header: 'Timeline',
348
+ width: calculateGanttMinWidth(props.globalDateRange.start, props.globalDateRange.end, 80, props.mode)
349
+ })
350
+
351
+ if (props.rowActions && props.rowActions.length > 0) {
352
+ cols.push({
353
+ field: '_ganttActions',
354
+ header: 'Actions',
355
+ width: '1%'
356
+ })
357
+ }
358
+
359
+ return cols
360
+ })
361
+
362
+ </script>
363
+
364
+ <style lang="scss" scoped>
365
+ .KGantt {
366
+ width: 100%;
367
+ height: 100%;
368
+ overflow: hidden;
369
+ display: flex;
370
+ flex-direction: column;
371
+
372
+ &__scroll-container {
373
+ flex: 1;
374
+ width: 100%;
375
+ overflow-x: auto;
376
+ overflow-y: auto;
377
+ cursor: grab;
378
+
379
+ &:active {
380
+ cursor: grabbing;
381
+ }
382
+ }
383
+
384
+ &__inner {
385
+ min-width: 100%;
386
+ }
387
+
388
+ :deep(th[data-field="ganttTimeline"]),
389
+ :deep(td[data-field="ganttTimeline"]) {
390
+ padding: 0;
391
+ }
392
+
393
+ .gantt-actions {
394
+ display: flex;
395
+ gap: 8px;
396
+ justify-content: flex-end;
397
+ white-space: nowrap;
398
+ }
303
399
  }
304
400
  </style>
@@ -9,43 +9,48 @@
9
9
  .gantt-ruler__line
10
10
  </template>
11
11
 
12
- <script setup>
13
- import { computed } from "vue";
14
- import { getGanttMarkers } from "#toolkit/components/KGantt/KGantt.logic";
15
- const props = defineProps({
16
- startMs: { type: Number, required: true },
17
- endMs: { type: Number, required: true },
18
- mode: { type: String, required: false }
19
- });
20
- const markers = computed(() => getGanttMarkers(props.startMs, props.endMs, props.mode));
12
+ <script lang="ts" setup>
13
+ import { computed } from 'vue'
14
+ import { getGanttMarkers } from '#toolkit/components/KGantt/KGantt.logic'
15
+
16
+ const props = defineProps<{
17
+ startMs: number
18
+ endMs: number
19
+ mode?: 'date' | 'numeric'
20
+ }>()
21
+
22
+ const markers = computed(() => getGanttMarkers(props.startMs, props.endMs, props.mode))
21
23
  </script>
22
24
 
23
- <style scoped>
25
+ <style lang="scss" scoped>
24
26
  .gantt-ruler {
25
- position: relative;
26
- width: 100%;
27
- height: 32px;
28
- overflow: hidden;
29
- }
30
- .gantt-ruler__marker {
31
- position: absolute;
32
- top: 0;
33
- bottom: 0;
34
- display: flex;
35
- flex-direction: column;
36
- align-items: flex-start;
37
- }
38
- .gantt-ruler__label {
39
- font-size: 0.68rem;
40
- font-weight: 600;
41
- color: var(--text-color-secondary, #64748b);
42
- padding: 4px 4px 0;
43
- white-space: nowrap;
44
- line-height: 1;
45
- }
46
- .gantt-ruler__line {
47
- flex: 1;
48
- width: 1px;
49
- background: var(--border-color, #cbd5e1);
27
+ position: relative;
28
+ width: 100%;
29
+ height: 32px;
30
+ overflow: hidden;
31
+
32
+ &__marker {
33
+ position: absolute;
34
+ top: 0;
35
+ bottom: 0;
36
+ display: flex;
37
+ flex-direction: column;
38
+ align-items: flex-start;
39
+ }
40
+
41
+ &__label {
42
+ font-size: 0.68rem;
43
+ font-weight: 600;
44
+ color: var(--text-color-secondary, #64748b);
45
+ padding: 4px 4px 0;
46
+ white-space: nowrap;
47
+ line-height: 1;
48
+ }
49
+
50
+ &__line {
51
+ flex: 1;
52
+ width: 1px;
53
+ background: var(--border-color, #cbd5e1);
54
+ }
50
55
  }
51
56
  </style>