@object-ui/plugin-gantt 4.0.7 → 4.0.9
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.md +22 -0
- package/README.md +62 -0
- package/dist/index.js +460 -269
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/plugin-gantt/src/GanttView.d.ts +12 -2
- package/dist/packages/plugin-gantt/src/GanttView.d.ts.map +1 -1
- package/dist/packages/plugin-gantt/src/ObjectGantt.d.ts.map +1 -1
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -1,35 +1,99 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { ComponentRegistry as
|
|
4
|
-
import { useNavigationOverlay as
|
|
5
|
-
import { GanttConfigSchema as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { useCallback as t, useEffect as n, useMemo as r, useState as i } from "react";
|
|
3
|
+
import { ComponentRegistry as a, buildExpandFields as o, extractRecords as s } from "@object-ui/core";
|
|
4
|
+
import { useNavigationOverlay as c, useSchemaContext as l } from "@object-ui/react";
|
|
5
|
+
import { GanttConfigSchema as u } from "@objectstack/spec/ui";
|
|
6
|
+
import { RecordDetailDrawer as d, deriveRecordPageHref as f } from "@object-ui/plugin-detail";
|
|
7
|
+
import { AlertDialog as p, AlertDialogAction as m, AlertDialogCancel as h, AlertDialogContent as ee, AlertDialogDescription as g, AlertDialogFooter as _, AlertDialogHeader as v, AlertDialogTitle as y, Button as b, cn as x, useResizeObserver as S } from "@object-ui/components";
|
|
8
|
+
import { getSemanticColorName as C, getSemanticHex as w } from "@object-ui/fields";
|
|
9
|
+
import { CalendarDays as T, ChevronLeft as E, ChevronRight as D, PanelLeft as O, PanelLeftClose as te, ZoomIn as k, ZoomOut as ne } from "lucide-react";
|
|
10
|
+
import { Fragment as A, jsx as j, jsxs as M } from "react/jsx-runtime";
|
|
9
11
|
//#region src/GanttView.tsx
|
|
10
|
-
function
|
|
12
|
+
function N(e) {
|
|
11
13
|
return e < 640 ? 35 : e < 1024 ? 50 : 60;
|
|
12
14
|
}
|
|
13
|
-
function
|
|
14
|
-
return e < 640 ?
|
|
15
|
+
function P(e) {
|
|
16
|
+
return e < 640 ? 140 : e < 1024 ? 220 : 320;
|
|
17
|
+
}
|
|
18
|
+
function F(e) {
|
|
19
|
+
return e >= 280;
|
|
15
20
|
}
|
|
16
|
-
function
|
|
21
|
+
function I(e) {
|
|
17
22
|
return e < 640 ? 32 : 40;
|
|
18
23
|
}
|
|
19
|
-
function
|
|
20
|
-
let [
|
|
24
|
+
function L({ tasks: t, startDate: n, endDate: r, onTaskClick: i, onTaskUpdate: a, className: o, inlineEdit: s = !1 }) {
|
|
25
|
+
let [c, l] = e.useState(/* @__PURE__ */ new Date()), u = e.useRef(null), { width: d } = S(u), f = d || (typeof window < "u" ? window.innerWidth : 1024), p = f < 640, m = I(f), h = N(f), [ee, g] = e.useState(null), _ = ee ?? h, [v, y] = e.useState(!1), C = e.useRef(!1);
|
|
26
|
+
e.useEffect(() => {
|
|
27
|
+
!C.current && p && (y(!0), C.current = !0);
|
|
28
|
+
}, [p]);
|
|
29
|
+
let w = v ? 0 : P(f), L = F(w), [re, R] = e.useState(null), [z, B] = e.useState({}), [V, H] = e.useState(null), U = e.useRef(null);
|
|
21
30
|
e.useEffect(() => {
|
|
22
|
-
|
|
23
|
-
}, [
|
|
24
|
-
let
|
|
25
|
-
let
|
|
26
|
-
return
|
|
31
|
+
U.current = V;
|
|
32
|
+
}, [V]);
|
|
33
|
+
let W = e.useRef(!1), G = e.useCallback((e) => {
|
|
34
|
+
let t = 1e3 * 60 * 60 * 24, n = t, r = e.dayDelta * t, i = new Date(e.originStart), a = new Date(e.originEnd);
|
|
35
|
+
return e.mode === "move" ? (i = new Date(e.originStart.getTime() + r), a = new Date(e.originEnd.getTime() + r)) : e.mode === "resize-left" ? (i = new Date(e.originStart.getTime() + r), a.getTime() - i.getTime() < n && (i = new Date(a.getTime() - n))) : e.mode === "resize-right" && (a = new Date(e.originEnd.getTime() + r), a.getTime() - i.getTime() < n && (a = new Date(i.getTime() + n))), {
|
|
36
|
+
start: i,
|
|
37
|
+
end: a
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
e.useEffect(() => {
|
|
41
|
+
if (!V) return;
|
|
42
|
+
let e = (e) => {
|
|
43
|
+
let t = U.current;
|
|
44
|
+
if (!t) return;
|
|
45
|
+
let n = Math.round((e.clientX - t.originClientX) / Math.max(_, 1));
|
|
46
|
+
n !== t.dayDelta && H({
|
|
47
|
+
...t,
|
|
48
|
+
dayDelta: n
|
|
49
|
+
});
|
|
50
|
+
}, n = () => {
|
|
51
|
+
let e = U.current;
|
|
52
|
+
if (e) {
|
|
53
|
+
if (e.dayDelta !== 0) {
|
|
54
|
+
let n = t.find((t) => t.id === e.taskId);
|
|
55
|
+
if (n && a) {
|
|
56
|
+
let { start: t, end: r } = G(e);
|
|
57
|
+
a(n, {
|
|
58
|
+
start: t,
|
|
59
|
+
end: r
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
W.current = !0, window.setTimeout(() => {
|
|
63
|
+
W.current = !1;
|
|
64
|
+
}, 0);
|
|
65
|
+
}
|
|
66
|
+
H(null);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return window.addEventListener("pointermove", e), window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n), () => {
|
|
70
|
+
window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
71
|
+
};
|
|
72
|
+
}, [
|
|
73
|
+
V,
|
|
74
|
+
_,
|
|
75
|
+
t,
|
|
76
|
+
a,
|
|
77
|
+
G
|
|
78
|
+
]);
|
|
79
|
+
let K = e.useCallback((e, t, n) => {
|
|
80
|
+
a && (n.stopPropagation(), n.preventDefault(), H({
|
|
81
|
+
taskId: e.id,
|
|
82
|
+
mode: t,
|
|
83
|
+
originStart: new Date(e.start),
|
|
84
|
+
originEnd: new Date(e.end),
|
|
85
|
+
originClientX: n.clientX,
|
|
86
|
+
dayDelta: 0
|
|
87
|
+
}));
|
|
88
|
+
}, [a]), q = e.useMemo(() => {
|
|
89
|
+
let e = n ? new Date(n) : /* @__PURE__ */ new Date(), i = r ? new Date(r) : /* @__PURE__ */ new Date();
|
|
90
|
+
return !n && t.length > 0 && (e = new Date(Math.min(...t.map((e) => e.start.getTime()))), e.setDate(e.getDate() - 7)), !r && t.length > 0 && (i = new Date(Math.max(...t.map((e) => e.end.getTime()))), i.setDate(i.getDate() + 14)), e.setHours(0, 0, 0, 0), i.setHours(23, 59, 59, 999), {
|
|
27
91
|
start: e,
|
|
28
|
-
end:
|
|
92
|
+
end: i
|
|
29
93
|
};
|
|
30
94
|
}, [
|
|
95
|
+
n,
|
|
31
96
|
r,
|
|
32
|
-
i,
|
|
33
97
|
t
|
|
34
98
|
]), J = e.useMemo(() => {
|
|
35
99
|
let e = [], t = new Date(q.start);
|
|
@@ -44,21 +108,21 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
44
108
|
let t = e.touches[0].clientX - e.touches[1].clientX, n = e.touches[0].clientY - e.touches[1].clientY;
|
|
45
109
|
Q.current = {
|
|
46
110
|
baseDistance: Math.max(1, Math.sqrt(t * t + n * n)),
|
|
47
|
-
baseColumn:
|
|
111
|
+
baseColumn: _
|
|
48
112
|
};
|
|
49
113
|
}
|
|
50
|
-
}, [
|
|
114
|
+
}, [_]), oe = e.useCallback((e) => {
|
|
51
115
|
if (e.touches.length !== 2 || !Q.current) return;
|
|
52
116
|
let t = e.touches[0].clientX - e.touches[1].clientX, n = e.touches[0].clientY - e.touches[1].clientY, r = Math.max(1, Math.sqrt(t * t + n * n)) / Q.current.baseDistance;
|
|
53
|
-
|
|
117
|
+
g(Math.max(15, Math.min(120, Math.round(Q.current.baseColumn * r))));
|
|
54
118
|
}, []), se = e.useCallback(() => {
|
|
55
119
|
Q.current = null;
|
|
56
120
|
}, []), $ = e.useMemo(() => {
|
|
57
121
|
let e = /* @__PURE__ */ new Date();
|
|
58
122
|
if (e < q.start || e > q.end) return null;
|
|
59
123
|
let t = (e.getTime() - q.start.getTime()) / (1440 * 60 * 1e3);
|
|
60
|
-
return Math.round(t *
|
|
61
|
-
}, [q,
|
|
124
|
+
return Math.round(t * _);
|
|
125
|
+
}, [q, _]), ce = e.useCallback(() => {
|
|
62
126
|
if ($ == null || !Z.current) return;
|
|
63
127
|
let e = Math.max(0, $ - Z.current.clientWidth / 2);
|
|
64
128
|
Z.current.scrollTo({
|
|
@@ -69,53 +133,35 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
69
133
|
Y.current && (Y.current.scrollLeft = e.currentTarget.scrollLeft), X.current && (X.current.scrollTop = e.currentTarget.scrollTop);
|
|
70
134
|
}, ue = (e) => {
|
|
71
135
|
q.end.getTime() - q.start.getTime();
|
|
72
|
-
let t =
|
|
136
|
+
let t = _, n = 1e3 * 60 * 60 * 24, r = e.start.getTime() - q.start.getTime(), i = e.end.getTime() - e.start.getTime();
|
|
73
137
|
return {
|
|
74
138
|
left: r / n * t,
|
|
75
139
|
width: Math.max(i / n * t, t)
|
|
76
140
|
};
|
|
77
141
|
};
|
|
78
|
-
return /* @__PURE__ */
|
|
79
|
-
ref:
|
|
80
|
-
className:
|
|
81
|
-
children: [/* @__PURE__ */
|
|
142
|
+
return /* @__PURE__ */ M("div", {
|
|
143
|
+
ref: u,
|
|
144
|
+
className: x("flex flex-col h-full bg-background overflow-hidden min-w-0", o),
|
|
145
|
+
children: [/* @__PURE__ */ M("div", {
|
|
82
146
|
className: "flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card",
|
|
83
|
-
children: [/* @__PURE__ */
|
|
147
|
+
children: [/* @__PURE__ */ M("div", {
|
|
84
148
|
className: "flex items-center gap-2",
|
|
85
149
|
children: [
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
variant: "outline",
|
|
88
|
-
size: "sm",
|
|
89
|
-
onClick: () => c?.(),
|
|
90
|
-
"aria-label": "Create new task",
|
|
91
|
-
children: [
|
|
92
|
-
/* @__PURE__ */ D(w, { className: "h-4 w-4 mr-1 sm:mr-2" }),
|
|
93
|
-
/* @__PURE__ */ D("span", {
|
|
94
|
-
className: "hidden sm:inline",
|
|
95
|
-
children: "New Task"
|
|
96
|
-
}),
|
|
97
|
-
/* @__PURE__ */ D("span", {
|
|
98
|
-
className: "sm:hidden",
|
|
99
|
-
children: "New"
|
|
100
|
-
})
|
|
101
|
-
]
|
|
102
|
-
}),
|
|
103
|
-
/* @__PURE__ */ D("div", { className: "h-4 w-px bg-border mx-1 sm:mx-2" }),
|
|
104
|
-
/* @__PURE__ */ D(u, {
|
|
150
|
+
/* @__PURE__ */ j(b, {
|
|
105
151
|
variant: "ghost",
|
|
106
152
|
size: "icon",
|
|
107
153
|
className: "h-8 w-8",
|
|
108
154
|
"aria-label": "Previous period",
|
|
109
|
-
children: /* @__PURE__ */
|
|
155
|
+
children: /* @__PURE__ */ j(E, { className: "h-4 w-4" })
|
|
110
156
|
}),
|
|
111
|
-
/* @__PURE__ */
|
|
157
|
+
/* @__PURE__ */ j(b, {
|
|
112
158
|
variant: "ghost",
|
|
113
159
|
size: "icon",
|
|
114
160
|
className: "h-8 w-8",
|
|
115
161
|
"aria-label": "Next period",
|
|
116
|
-
children: /* @__PURE__ */ D
|
|
162
|
+
children: /* @__PURE__ */ j(D, { className: "h-4 w-4" })
|
|
117
163
|
}),
|
|
118
|
-
/* @__PURE__ */
|
|
164
|
+
/* @__PURE__ */ j("span", {
|
|
119
165
|
className: "font-semibold text-xs sm:text-sm",
|
|
120
166
|
children: q.start.toLocaleDateString(void 0, {
|
|
121
167
|
month: "long",
|
|
@@ -123,63 +169,38 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
123
169
|
})
|
|
124
170
|
})
|
|
125
171
|
]
|
|
126
|
-
}), /* @__PURE__ */
|
|
172
|
+
}), /* @__PURE__ */ M("div", {
|
|
127
173
|
className: "flex items-center gap-2",
|
|
128
174
|
children: [
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
value: n,
|
|
131
|
-
onValueChange: (e) => s?.(e),
|
|
132
|
-
children: [/* @__PURE__ */ D(h, {
|
|
133
|
-
className: "w-[100px] sm:w-[120px] h-8",
|
|
134
|
-
children: /* @__PURE__ */ D(g, {})
|
|
135
|
-
}), /* @__PURE__ */ O(p, { children: [
|
|
136
|
-
/* @__PURE__ */ D(m, {
|
|
137
|
-
value: "day",
|
|
138
|
-
children: "Day View"
|
|
139
|
-
}),
|
|
140
|
-
/* @__PURE__ */ D(m, {
|
|
141
|
-
value: "week",
|
|
142
|
-
children: "Week View"
|
|
143
|
-
}),
|
|
144
|
-
/* @__PURE__ */ D(m, {
|
|
145
|
-
value: "month",
|
|
146
|
-
children: "Month View"
|
|
147
|
-
}),
|
|
148
|
-
/* @__PURE__ */ D(m, {
|
|
149
|
-
value: "quarter",
|
|
150
|
-
children: "Quarter View"
|
|
151
|
-
})
|
|
152
|
-
] })]
|
|
153
|
-
}),
|
|
154
|
-
/* @__PURE__ */ O("div", {
|
|
175
|
+
/* @__PURE__ */ M("div", {
|
|
155
176
|
className: "flex bg-muted rounded-md p-1",
|
|
156
|
-
children: [/* @__PURE__ */
|
|
177
|
+
children: [/* @__PURE__ */ j(b, {
|
|
157
178
|
variant: "ghost",
|
|
158
179
|
size: "icon",
|
|
159
180
|
className: "h-6 w-6",
|
|
160
|
-
onClick: () =>
|
|
181
|
+
onClick: () => g(Math.max(15, _ - 10)),
|
|
161
182
|
"aria-label": "Zoom out",
|
|
162
|
-
children: /* @__PURE__ */
|
|
163
|
-
}), /* @__PURE__ */
|
|
183
|
+
children: /* @__PURE__ */ j(ne, { className: "h-3 w-3" })
|
|
184
|
+
}), /* @__PURE__ */ j(b, {
|
|
164
185
|
variant: "ghost",
|
|
165
186
|
size: "icon",
|
|
166
187
|
className: "h-6 w-6",
|
|
167
|
-
onClick: () =>
|
|
188
|
+
onClick: () => g(Math.min(120, _ + 10)),
|
|
168
189
|
"aria-label": "Zoom in",
|
|
169
|
-
children: /* @__PURE__ */
|
|
190
|
+
children: /* @__PURE__ */ j(k, { className: "h-3 w-3" })
|
|
170
191
|
})]
|
|
171
192
|
}),
|
|
172
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ j(b, {
|
|
173
194
|
variant: "ghost",
|
|
174
195
|
size: "icon",
|
|
175
196
|
className: "h-8 w-8",
|
|
176
|
-
onClick: () =>
|
|
177
|
-
"aria-label":
|
|
178
|
-
"aria-pressed":
|
|
197
|
+
onClick: () => y((e) => !e),
|
|
198
|
+
"aria-label": v ? "Show task list" : "Hide task list",
|
|
199
|
+
"aria-pressed": v,
|
|
179
200
|
"data-testid": "gantt-toggle-task-list",
|
|
180
|
-
children:
|
|
201
|
+
children: j(v ? O : te, { className: "h-4 w-4" })
|
|
181
202
|
}),
|
|
182
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ j(b, {
|
|
183
204
|
variant: "ghost",
|
|
184
205
|
size: "icon",
|
|
185
206
|
className: "h-8 w-8",
|
|
@@ -187,73 +208,69 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
187
208
|
disabled: $ == null,
|
|
188
209
|
"aria-label": "Jump to today",
|
|
189
210
|
"data-testid": "gantt-jump-today",
|
|
190
|
-
children: /* @__PURE__ */
|
|
211
|
+
children: /* @__PURE__ */ j(T, { className: "h-4 w-4" })
|
|
191
212
|
})
|
|
192
213
|
]
|
|
193
214
|
})]
|
|
194
|
-
}), /* @__PURE__ */
|
|
215
|
+
}), /* @__PURE__ */ M("div", {
|
|
195
216
|
className: "flex flex-col flex-1 overflow-hidden",
|
|
196
|
-
children: [/* @__PURE__ */
|
|
217
|
+
children: [/* @__PURE__ */ M("div", {
|
|
197
218
|
className: "flex border-b bg-muted/30 shrink-0 h-10 sm:h-[50px]",
|
|
198
|
-
children: [/* @__PURE__ */
|
|
219
|
+
children: [/* @__PURE__ */ M("div", {
|
|
199
220
|
className: "flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm",
|
|
200
221
|
style: {
|
|
201
|
-
width:
|
|
202
|
-
minWidth:
|
|
222
|
+
width: w,
|
|
223
|
+
minWidth: w
|
|
203
224
|
},
|
|
204
|
-
children: [
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
children: "End"
|
|
216
|
-
})
|
|
217
|
-
]
|
|
218
|
-
}), /* @__PURE__ */ D("div", {
|
|
225
|
+
children: [/* @__PURE__ */ j("div", {
|
|
226
|
+
className: "flex-1 truncate",
|
|
227
|
+
children: "Task Name"
|
|
228
|
+
}), L && /* @__PURE__ */ M(A, { children: [/* @__PURE__ */ j("div", {
|
|
229
|
+
className: "w-16 sm:w-20 text-right",
|
|
230
|
+
children: "Start"
|
|
231
|
+
}), /* @__PURE__ */ j("div", {
|
|
232
|
+
className: "w-16 sm:w-20 text-right",
|
|
233
|
+
children: "End"
|
|
234
|
+
})] })]
|
|
235
|
+
}), /* @__PURE__ */ j("div", {
|
|
219
236
|
className: "flex-1 overflow-hidden",
|
|
220
237
|
ref: Y,
|
|
221
|
-
children: /* @__PURE__ */
|
|
238
|
+
children: /* @__PURE__ */ j("div", {
|
|
222
239
|
className: "flex h-full",
|
|
223
|
-
style: { width: J.length *
|
|
224
|
-
children: J.map((e, t) => /* @__PURE__ */
|
|
225
|
-
className:
|
|
240
|
+
style: { width: J.length * _ },
|
|
241
|
+
children: J.map((e, t) => /* @__PURE__ */ M("div", {
|
|
242
|
+
className: x("flex flex-col items-center justify-center border-r text-xs text-muted-foreground h-full", e.isWeekend && "bg-muted/50"),
|
|
226
243
|
style: {
|
|
227
|
-
width:
|
|
228
|
-
minWidth:
|
|
244
|
+
width: _,
|
|
245
|
+
minWidth: _
|
|
229
246
|
},
|
|
230
|
-
children: [/* @__PURE__ */
|
|
247
|
+
children: [/* @__PURE__ */ j("span", {
|
|
231
248
|
className: "font-medium text-foreground",
|
|
232
249
|
children: e.label
|
|
233
|
-
}), /* @__PURE__ */
|
|
250
|
+
}), /* @__PURE__ */ j("span", {
|
|
234
251
|
className: "text-[10px] opacity-70",
|
|
235
252
|
children: e.date.toLocaleDateString(void 0, { weekday: "narrow" })
|
|
236
253
|
})]
|
|
237
254
|
}, t))
|
|
238
255
|
})
|
|
239
256
|
})]
|
|
240
|
-
}), /* @__PURE__ */
|
|
257
|
+
}), /* @__PURE__ */ M("div", {
|
|
241
258
|
className: "flex flex-1 overflow-hidden",
|
|
242
|
-
children: [/* @__PURE__ */
|
|
259
|
+
children: [/* @__PURE__ */ j("div", {
|
|
243
260
|
className: "overflow-hidden border-r bg-card z-10 shadow-sm",
|
|
244
261
|
ref: X,
|
|
245
262
|
style: {
|
|
246
|
-
width:
|
|
247
|
-
minWidth:
|
|
263
|
+
width: w,
|
|
264
|
+
minWidth: w
|
|
248
265
|
},
|
|
249
266
|
children: t.map((e) => {
|
|
250
|
-
let t =
|
|
251
|
-
return /* @__PURE__ */
|
|
252
|
-
className: "flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",
|
|
253
|
-
style: { height:
|
|
254
|
-
onClick: () => !t &&
|
|
267
|
+
let t = s && re === e.id;
|
|
268
|
+
return /* @__PURE__ */ M("div", {
|
|
269
|
+
className: "group/task-row flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",
|
|
270
|
+
style: { height: m },
|
|
271
|
+
onClick: () => !t && i?.(e),
|
|
255
272
|
onDoubleClick: () => {
|
|
256
|
-
|
|
273
|
+
s && a && (R(e.id), B({
|
|
257
274
|
title: e.title,
|
|
258
275
|
start: e.start.toLocaleDateString("en-CA"),
|
|
259
276
|
end: e.end.toLocaleDateString("en-CA"),
|
|
@@ -261,34 +278,34 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
261
278
|
}));
|
|
262
279
|
},
|
|
263
280
|
children: [
|
|
264
|
-
/* @__PURE__ */
|
|
281
|
+
/* @__PURE__ */ M("div", {
|
|
265
282
|
className: "flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2",
|
|
266
|
-
children: [/* @__PURE__ */
|
|
283
|
+
children: [/* @__PURE__ */ j("div", {
|
|
267
284
|
className: "w-2 h-2 rounded-full shrink-0",
|
|
268
285
|
style: { backgroundColor: e.color || "#3b82f6" }
|
|
269
|
-
}), t ? /* @__PURE__ */
|
|
286
|
+
}), t ? /* @__PURE__ */ j("input", {
|
|
270
287
|
className: "border rounded px-1 py-0.5 text-xs w-full bg-background",
|
|
271
|
-
value:
|
|
272
|
-
onChange: (e) =>
|
|
288
|
+
value: z.title || "",
|
|
289
|
+
onChange: (e) => B((t) => ({
|
|
273
290
|
...t,
|
|
274
291
|
title: e.target.value
|
|
275
292
|
})),
|
|
276
293
|
onKeyDown: (t) => {
|
|
277
|
-
t.key === "Enter" ? (
|
|
278
|
-
title:
|
|
279
|
-
start: new Date(
|
|
280
|
-
end: new Date(
|
|
281
|
-
progress: Number(
|
|
282
|
-
}),
|
|
294
|
+
t.key === "Enter" ? (a?.(e, {
|
|
295
|
+
title: z.title,
|
|
296
|
+
start: new Date(z.start),
|
|
297
|
+
end: new Date(z.end),
|
|
298
|
+
progress: Number(z.progress) || 0
|
|
299
|
+
}), R(null)) : t.key === "Escape" && R(null);
|
|
283
300
|
},
|
|
284
301
|
onClick: (e) => e.stopPropagation(),
|
|
285
302
|
autoFocus: !0
|
|
286
|
-
}) : /* @__PURE__ */
|
|
303
|
+
}) : /* @__PURE__ */ M("span", {
|
|
287
304
|
className: "flex flex-col min-w-0",
|
|
288
|
-
children: [/* @__PURE__ */
|
|
305
|
+
children: [/* @__PURE__ */ j("span", {
|
|
289
306
|
className: "truncate",
|
|
290
307
|
children: e.title
|
|
291
|
-
}), /* @__PURE__ */
|
|
308
|
+
}), /* @__PURE__ */ M("span", {
|
|
292
309
|
className: "text-[10px] text-muted-foreground sm:hidden",
|
|
293
310
|
children: [
|
|
294
311
|
e.start.toLocaleDateString(void 0, {
|
|
@@ -304,13 +321,15 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
304
321
|
})]
|
|
305
322
|
})]
|
|
306
323
|
}),
|
|
307
|
-
/* @__PURE__ */
|
|
324
|
+
/* @__PURE__ */ j("div", {
|
|
308
325
|
className: "w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block",
|
|
309
|
-
|
|
326
|
+
hidden: !L,
|
|
327
|
+
style: L ? void 0 : { display: "none" },
|
|
328
|
+
children: t ? /* @__PURE__ */ j("input", {
|
|
310
329
|
type: "date",
|
|
311
330
|
className: "border rounded px-1 py-0.5 text-xs w-full bg-background",
|
|
312
|
-
value:
|
|
313
|
-
onChange: (e) =>
|
|
331
|
+
value: z.start || "",
|
|
332
|
+
onChange: (e) => B((t) => ({
|
|
314
333
|
...t,
|
|
315
334
|
start: e.target.value
|
|
316
335
|
})),
|
|
@@ -320,13 +339,15 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
320
339
|
day: "numeric"
|
|
321
340
|
})
|
|
322
341
|
}),
|
|
323
|
-
/* @__PURE__ */
|
|
342
|
+
/* @__PURE__ */ j("div", {
|
|
324
343
|
className: "w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block",
|
|
325
|
-
|
|
344
|
+
hidden: !L,
|
|
345
|
+
style: L ? void 0 : { display: "none" },
|
|
346
|
+
children: t ? /* @__PURE__ */ j("input", {
|
|
326
347
|
type: "date",
|
|
327
348
|
className: "border rounded px-1 py-0.5 text-xs w-full bg-background",
|
|
328
|
-
value:
|
|
329
|
-
onChange: (e) =>
|
|
349
|
+
value: z.end || "",
|
|
350
|
+
onChange: (e) => B((t) => ({
|
|
330
351
|
...t,
|
|
331
352
|
end: e.target.value
|
|
332
353
|
})),
|
|
@@ -339,7 +360,7 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
339
360
|
]
|
|
340
361
|
}, e.id);
|
|
341
362
|
})
|
|
342
|
-
}), /* @__PURE__ */
|
|
363
|
+
}), /* @__PURE__ */ j("div", {
|
|
343
364
|
className: "flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]",
|
|
344
365
|
ref: (e) => {
|
|
345
366
|
ie.current = e, Z.current = e;
|
|
@@ -349,58 +370,105 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
349
370
|
onTouchMove: oe,
|
|
350
371
|
onTouchEnd: se,
|
|
351
372
|
"data-testid": "gantt-timeline",
|
|
352
|
-
children: /* @__PURE__ */
|
|
373
|
+
children: /* @__PURE__ */ M("div", {
|
|
353
374
|
className: "relative",
|
|
354
|
-
style: { width: J.length *
|
|
355
|
-
children: [$ != null && /* @__PURE__ */
|
|
375
|
+
style: { width: J.length * _ },
|
|
376
|
+
children: [$ != null && /* @__PURE__ */ j("div", {
|
|
356
377
|
className: "absolute top-0 bottom-0 w-px bg-red-500/80 z-20 pointer-events-none",
|
|
357
378
|
style: { left: $ },
|
|
358
379
|
"data-testid": "gantt-today-marker",
|
|
359
380
|
"aria-label": "Today",
|
|
360
|
-
children: /* @__PURE__ */
|
|
381
|
+
children: /* @__PURE__ */ j("div", {
|
|
361
382
|
className: "absolute -top-2 -translate-x-1/2 left-0 text-[10px] font-semibold text-white bg-red-500 rounded-sm px-1 py-0.5 whitespace-nowrap",
|
|
362
383
|
children: "Today"
|
|
363
384
|
})
|
|
364
|
-
}), /* @__PURE__ */
|
|
385
|
+
}), /* @__PURE__ */ M("div", {
|
|
365
386
|
className: "relative",
|
|
366
387
|
children: [
|
|
367
|
-
/* @__PURE__ */
|
|
388
|
+
/* @__PURE__ */ j("div", {
|
|
368
389
|
className: "absolute inset-0 flex pointer-events-none z-0",
|
|
369
|
-
children: J.map((e, t) => /* @__PURE__ */
|
|
370
|
-
className:
|
|
390
|
+
children: J.map((e, t) => /* @__PURE__ */ j("div", {
|
|
391
|
+
className: x("border-r h-full", e.isWeekend && "bg-muted/20"),
|
|
371
392
|
style: {
|
|
372
|
-
width:
|
|
373
|
-
minWidth:
|
|
393
|
+
width: _,
|
|
394
|
+
minWidth: _
|
|
374
395
|
}
|
|
375
396
|
}, t))
|
|
376
397
|
}),
|
|
377
398
|
t.map((e) => {
|
|
378
|
-
let t = ue(e);
|
|
379
|
-
|
|
399
|
+
let t = ue(e), n = V?.taskId === e.id, r = t;
|
|
400
|
+
if (n && V) {
|
|
401
|
+
let t = G(V);
|
|
402
|
+
r = ue({
|
|
403
|
+
...e,
|
|
404
|
+
start: t.start,
|
|
405
|
+
end: t.end
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
let o = !!a;
|
|
409
|
+
return /* @__PURE__ */ M("div", {
|
|
380
410
|
className: "relative border-b hover:bg-black/5",
|
|
381
|
-
style: { height:
|
|
382
|
-
children: /* @__PURE__ */
|
|
383
|
-
className: "absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm
|
|
411
|
+
style: { height: m },
|
|
412
|
+
children: [n && /* @__PURE__ */ j("div", {
|
|
413
|
+
className: "absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm border border-dashed border-primary/60 pointer-events-none",
|
|
384
414
|
style: {
|
|
385
415
|
left: t.left,
|
|
386
416
|
width: t.width,
|
|
417
|
+
opacity: .35
|
|
418
|
+
},
|
|
419
|
+
"aria-hidden": "true"
|
|
420
|
+
}), /* @__PURE__ */ M("div", {
|
|
421
|
+
className: x("absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm bg-primary border border-primary-foreground/20 shadow-sm hover:brightness-110 flex items-center px-2 group select-none", o ? "cursor-grab active:cursor-grabbing" : "cursor-pointer", n && "ring-2 ring-primary/60 brightness-110 z-10"),
|
|
422
|
+
style: {
|
|
423
|
+
left: r.left,
|
|
424
|
+
width: r.width,
|
|
387
425
|
backgroundColor: e.color || "#3b82f6"
|
|
388
426
|
},
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
427
|
+
"data-testid": `gantt-task-bar-${e.id}`,
|
|
428
|
+
onClick: () => {
|
|
429
|
+
W.current || i?.(e);
|
|
430
|
+
},
|
|
431
|
+
onPointerDown: o ? (t) => {
|
|
432
|
+
t.button === 0 && K(e, "move", t);
|
|
433
|
+
} : void 0,
|
|
434
|
+
children: [
|
|
435
|
+
o && r.width >= 14 && /* @__PURE__ */ M(A, { children: [/* @__PURE__ */ j("div", {
|
|
436
|
+
className: "absolute left-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-white/40",
|
|
437
|
+
"data-testid": `gantt-task-resize-left-${e.id}`,
|
|
438
|
+
onPointerDown: (t) => {
|
|
439
|
+
t.button === 0 && K(e, "resize-left", t);
|
|
440
|
+
},
|
|
441
|
+
onClick: (e) => e.stopPropagation()
|
|
442
|
+
}), /* @__PURE__ */ j("div", {
|
|
443
|
+
className: "absolute right-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-white/40",
|
|
444
|
+
"data-testid": `gantt-task-resize-right-${e.id}`,
|
|
445
|
+
onPointerDown: (t) => {
|
|
446
|
+
t.button === 0 && K(e, "resize-right", t);
|
|
447
|
+
},
|
|
448
|
+
onClick: (e) => e.stopPropagation()
|
|
449
|
+
})] }),
|
|
450
|
+
e.progress > 0 && /* @__PURE__ */ j("div", {
|
|
451
|
+
className: "absolute left-0 top-0 bottom-0 bg-black/20 rounded-l-sm pointer-events-none",
|
|
452
|
+
style: { width: `${e.progress}%` }
|
|
453
|
+
}),
|
|
454
|
+
/* @__PURE__ */ j("span", {
|
|
455
|
+
className: "text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none",
|
|
456
|
+
children: n ? `${G(V).start.toLocaleDateString(void 0, {
|
|
457
|
+
month: "numeric",
|
|
458
|
+
day: "numeric"
|
|
459
|
+
})} → ${G(V).end.toLocaleDateString(void 0, {
|
|
460
|
+
month: "numeric",
|
|
461
|
+
day: "numeric"
|
|
462
|
+
})}` : `${Math.round(e.progress)}%`
|
|
463
|
+
})
|
|
464
|
+
]
|
|
465
|
+
})]
|
|
398
466
|
}, e.id);
|
|
399
467
|
}),
|
|
400
|
-
/* @__PURE__ */
|
|
468
|
+
/* @__PURE__ */ j("div", {
|
|
401
469
|
className: "absolute top-0 bottom-0 w-px bg-red-500 z-20 pointer-events-none",
|
|
402
|
-
style: { left: ((/* @__PURE__ */ new Date()).getTime() - q.start.getTime()) / (1e3 * 60 * 60 * 24) *
|
|
403
|
-
children: /* @__PURE__ */
|
|
470
|
+
style: { left: ((/* @__PURE__ */ new Date()).getTime() - q.start.getTime()) / (1e3 * 60 * 60 * 24) * _ },
|
|
471
|
+
children: /* @__PURE__ */ j("div", { className: "w-2 h-2 rounded-full bg-red-500 -ml-[3px]" })
|
|
404
472
|
})
|
|
405
473
|
]
|
|
406
474
|
})]
|
|
@@ -412,7 +480,7 @@ function A({ tasks: t, viewMode: n = "month", startDate: r, endDate: i, onTaskCl
|
|
|
412
480
|
}
|
|
413
481
|
//#endregion
|
|
414
482
|
//#region src/ObjectGantt.tsx
|
|
415
|
-
function
|
|
483
|
+
function re(e) {
|
|
416
484
|
return e.data ? e.data : e.staticData ? {
|
|
417
485
|
provider: "value",
|
|
418
486
|
items: e.staticData
|
|
@@ -421,7 +489,7 @@ function j(e) {
|
|
|
421
489
|
object: e.objectName
|
|
422
490
|
} : null;
|
|
423
491
|
}
|
|
424
|
-
function
|
|
492
|
+
function R(e) {
|
|
425
493
|
if (e) {
|
|
426
494
|
if (typeof e == "string") {
|
|
427
495
|
let t = e.split(" "), n = t[0], r = t[1]?.toLowerCase() === "desc" ? "desc" : "asc";
|
|
@@ -430,7 +498,7 @@ function M(e) {
|
|
|
430
498
|
if (Array.isArray(e)) return e.reduce((e, t) => (t.field && t.order && (e[t.field] = t.order), e), {});
|
|
431
499
|
}
|
|
432
500
|
}
|
|
433
|
-
function
|
|
501
|
+
function z(e) {
|
|
434
502
|
let t = null;
|
|
435
503
|
if (e.startDateField && e.endDateField) return t = {
|
|
436
504
|
startDateField: e.startDateField,
|
|
@@ -441,147 +509,270 @@ function N(e) {
|
|
|
441
509
|
colorField: e.colorField
|
|
442
510
|
}, t;
|
|
443
511
|
if (e.gantt && (t = e.gantt), t) {
|
|
444
|
-
let e =
|
|
512
|
+
let e = u.safeParse(t);
|
|
445
513
|
return e.success || console.warn("[ObjectGantt] Invalid gantt configuration:", e.error.format()), t;
|
|
446
514
|
}
|
|
447
515
|
return null;
|
|
448
516
|
}
|
|
449
|
-
var
|
|
450
|
-
let [
|
|
451
|
-
|
|
517
|
+
var B = ({ schema: e, dataSource: a, className: l, onTaskClick: u, onRowClick: b, ...x }) => {
|
|
518
|
+
let [S, T] = i([]), [E, D] = i(!0), [O, te] = i(null), [k, ne] = i(null), N = re(e), P = r(() => N, [JSON.stringify(N)]), F = z(e), I = P?.provider === "value";
|
|
519
|
+
n(() => {
|
|
452
520
|
(async () => {
|
|
453
521
|
try {
|
|
454
|
-
if (
|
|
455
|
-
|
|
522
|
+
if (D(!0), x.data && Array.isArray(x.data)) {
|
|
523
|
+
T(x.data), D(!1);
|
|
456
524
|
return;
|
|
457
525
|
}
|
|
458
|
-
if (
|
|
459
|
-
|
|
526
|
+
if (I && P?.provider === "value") {
|
|
527
|
+
T(P.items), D(!1);
|
|
460
528
|
return;
|
|
461
529
|
}
|
|
462
|
-
if (!
|
|
463
|
-
if (
|
|
464
|
-
let t =
|
|
465
|
-
|
|
530
|
+
if (!a || typeof a.find != "function") throw Error("DataSource required for object/api providers");
|
|
531
|
+
if (P?.provider === "object") {
|
|
532
|
+
let t = P.object, n = o(k?.fields);
|
|
533
|
+
T(s(await a.find(t, {
|
|
466
534
|
$filter: e.filter,
|
|
467
|
-
$orderby:
|
|
535
|
+
$orderby: R(e.sort),
|
|
468
536
|
...n.length > 0 ? { $expand: n } : {}
|
|
469
537
|
})));
|
|
470
|
-
} else
|
|
471
|
-
|
|
538
|
+
} else P?.provider === "api" && (console.warn("API provider not yet implemented for ObjectGantt"), T([]));
|
|
539
|
+
D(!1);
|
|
472
540
|
} catch (e) {
|
|
473
|
-
|
|
541
|
+
te(e), D(!1);
|
|
474
542
|
}
|
|
475
543
|
})();
|
|
476
544
|
}, [
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
545
|
+
P,
|
|
546
|
+
a,
|
|
547
|
+
I,
|
|
480
548
|
e.filter,
|
|
481
549
|
e.sort,
|
|
482
|
-
|
|
483
|
-
]),
|
|
484
|
-
!
|
|
550
|
+
k
|
|
551
|
+
]), n(() => {
|
|
552
|
+
!I && a && (async () => {
|
|
485
553
|
try {
|
|
486
|
-
if (!
|
|
487
|
-
let t =
|
|
554
|
+
if (!a) return;
|
|
555
|
+
let t = P?.provider === "object" ? P.object : e.objectName;
|
|
488
556
|
if (!t) return;
|
|
489
|
-
|
|
557
|
+
ne(await a.getObjectSchema(t));
|
|
490
558
|
} catch (e) {
|
|
491
559
|
console.error("Failed to fetch object schema:", e);
|
|
492
560
|
}
|
|
493
561
|
})();
|
|
494
562
|
}, [
|
|
495
563
|
e.objectName,
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
564
|
+
a,
|
|
565
|
+
I,
|
|
566
|
+
P
|
|
499
567
|
]);
|
|
500
|
-
let
|
|
501
|
-
if (!
|
|
502
|
-
let { startDateField: e, endDateField: t, titleField: n, progressField: r, dependenciesField: i, colorField: a } =
|
|
503
|
-
|
|
504
|
-
let
|
|
568
|
+
let B = r(() => {
|
|
569
|
+
if (!F || !S.length) return [];
|
|
570
|
+
let { startDateField: e, endDateField: t, titleField: n, progressField: r, dependenciesField: i, colorField: a } = F, o = (e, t) => {
|
|
571
|
+
if (!t) return;
|
|
572
|
+
let n = t.split("."), r = e;
|
|
573
|
+
for (let e of n) {
|
|
574
|
+
if (r == null) return;
|
|
575
|
+
r = r[e];
|
|
576
|
+
}
|
|
577
|
+
return r;
|
|
578
|
+
}, s = (e) => {
|
|
579
|
+
let t = [
|
|
580
|
+
o(e, n),
|
|
581
|
+
e?.name,
|
|
582
|
+
e?.title,
|
|
583
|
+
e?.subject,
|
|
584
|
+
e?.label,
|
|
585
|
+
e?.account?.name,
|
|
586
|
+
e?.opportunity?.name,
|
|
587
|
+
e?.contact && [e.contact.first_name, e.contact.last_name].filter(Boolean).join(" "),
|
|
588
|
+
e?.id,
|
|
589
|
+
e?._id
|
|
590
|
+
];
|
|
591
|
+
for (let e of t) if (e != null && String(e).trim() !== "") return String(e);
|
|
592
|
+
return "Untitled";
|
|
593
|
+
};
|
|
594
|
+
return S.map((n, o) => {
|
|
595
|
+
let c = n[e], l = n[t], u = s(n), d = r ? n[r] : 0, f = i ? n[i] : [], p = a ? n[a] : void 0;
|
|
596
|
+
if (!p) {
|
|
597
|
+
let e = n.status ?? n.state ?? n.priority ?? n.severity;
|
|
598
|
+
if (e != null && e !== "") {
|
|
599
|
+
let t = C(void 0, e);
|
|
600
|
+
t && (p = w(t));
|
|
601
|
+
}
|
|
602
|
+
}
|
|
505
603
|
return {
|
|
506
|
-
id:
|
|
604
|
+
id: n.id || n._id || `task-${o}`,
|
|
507
605
|
title: u,
|
|
508
606
|
start: c ? new Date(c) : /* @__PURE__ */ new Date(),
|
|
509
607
|
end: l ? new Date(l) : /* @__PURE__ */ new Date(),
|
|
510
608
|
progress: Math.min(100, Math.max(0, d || 0)),
|
|
511
609
|
dependencies: Array.isArray(f) ? f : [],
|
|
512
610
|
color: p,
|
|
513
|
-
data:
|
|
611
|
+
data: n
|
|
514
612
|
};
|
|
515
613
|
}).filter((e) => !isNaN(e.start.getTime()) && !isNaN(e.end.getTime()));
|
|
516
|
-
}, [
|
|
517
|
-
|
|
614
|
+
}, [S, F]), V = e.navigation ?? {
|
|
615
|
+
mode: "drawer",
|
|
616
|
+
width: "min(960px, 60vw)"
|
|
617
|
+
}, H = V.mode === "drawer" || V.mode === "modal" || V.mode === "split" || V.mode === "popover", U = c({
|
|
618
|
+
navigation: V,
|
|
518
619
|
objectName: e.objectName,
|
|
519
|
-
onRowClick:
|
|
520
|
-
})
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
620
|
+
onRowClick: H ? void 0 : b
|
|
621
|
+
}), W = t(async (t, n) => {
|
|
622
|
+
if (!F) return;
|
|
623
|
+
let r = P?.provider === "object" ? P.object : e.objectName;
|
|
624
|
+
if (!r || !a || typeof a.update != "function") return;
|
|
625
|
+
let { startDateField: i, endDateField: o, titleField: s, progressField: c } = F, l = {};
|
|
626
|
+
if (n.start instanceof Date && (l[i] = n.start.toISOString()), n.end instanceof Date && (l[o] = n.end.toISOString()), typeof n.title == "string" && s && (l[s] = n.title), typeof n.progress == "number" && c && (l[c] = n.progress), Object.keys(l).length === 0) return;
|
|
627
|
+
let u = t.data?.id ?? t.data?._id ?? t.id;
|
|
628
|
+
if (u == null) return;
|
|
629
|
+
let d = S;
|
|
630
|
+
T((e) => e.map((e) => String(e.id ?? e._id) === String(u) ? {
|
|
631
|
+
...e,
|
|
632
|
+
...l
|
|
633
|
+
} : e));
|
|
634
|
+
try {
|
|
635
|
+
await a.update(r, String(u), l);
|
|
636
|
+
} catch (e) {
|
|
637
|
+
console.error("[ObjectGantt] Failed to persist task update:", e), T(d);
|
|
638
|
+
}
|
|
639
|
+
}, [
|
|
640
|
+
F,
|
|
641
|
+
P,
|
|
642
|
+
a,
|
|
643
|
+
e.objectName,
|
|
644
|
+
S
|
|
645
|
+
]), [G, K] = i(null), [q, J] = i(!1), Y = t((e) => {
|
|
646
|
+
K(e);
|
|
647
|
+
}, []), X = t(async () => {
|
|
648
|
+
if (!G) return;
|
|
649
|
+
let t = P?.provider === "object" ? P.object : e.objectName;
|
|
650
|
+
if (!t || !a?.delete) {
|
|
651
|
+
K(null);
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
let n = G.data?.id ?? G.data?._id ?? G.id;
|
|
655
|
+
if (n == null) {
|
|
656
|
+
K(null);
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
J(!0);
|
|
660
|
+
let r = S;
|
|
661
|
+
T((e) => e.filter((e) => String(e.id ?? e._id) !== String(n)));
|
|
662
|
+
try {
|
|
663
|
+
await a.delete(t, String(n)), K(null);
|
|
664
|
+
} catch (e) {
|
|
665
|
+
console.error("[ObjectGantt] Failed to delete:", e), T(r), K(null);
|
|
666
|
+
} finally {
|
|
667
|
+
J(!1);
|
|
668
|
+
}
|
|
669
|
+
}, [
|
|
670
|
+
G,
|
|
671
|
+
P,
|
|
672
|
+
a,
|
|
673
|
+
e.objectName,
|
|
674
|
+
S
|
|
675
|
+
]);
|
|
676
|
+
return E ? /* @__PURE__ */ j("div", {
|
|
677
|
+
className: l,
|
|
678
|
+
children: /* @__PURE__ */ j("div", {
|
|
524
679
|
className: "flex items-center justify-center h-96",
|
|
525
|
-
children: /* @__PURE__ */
|
|
680
|
+
children: /* @__PURE__ */ j("div", {
|
|
526
681
|
className: "text-muted-foreground",
|
|
527
682
|
children: "Loading Gantt chart..."
|
|
528
683
|
})
|
|
529
684
|
})
|
|
530
|
-
}) :
|
|
531
|
-
className:
|
|
532
|
-
children: /* @__PURE__ */
|
|
685
|
+
}) : O ? /* @__PURE__ */ j("div", {
|
|
686
|
+
className: l,
|
|
687
|
+
children: /* @__PURE__ */ j("div", {
|
|
533
688
|
className: "flex items-center justify-center h-96",
|
|
534
|
-
children: /* @__PURE__ */
|
|
689
|
+
children: /* @__PURE__ */ M("div", {
|
|
535
690
|
className: "text-destructive",
|
|
536
|
-
children: ["Error: ",
|
|
691
|
+
children: ["Error: ", O.message]
|
|
537
692
|
})
|
|
538
693
|
})
|
|
539
|
-
}) :
|
|
540
|
-
className:
|
|
541
|
-
children: [
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
694
|
+
}) : F ? /* @__PURE__ */ M("div", {
|
|
695
|
+
className: l,
|
|
696
|
+
children: [
|
|
697
|
+
/* @__PURE__ */ j("div", {
|
|
698
|
+
className: "h-[calc(100vh-200px)] min-h-[600px]",
|
|
699
|
+
children: /* @__PURE__ */ j(L, {
|
|
700
|
+
tasks: B,
|
|
701
|
+
onTaskClick: (e) => {
|
|
702
|
+
U.handleClick(e.data), u?.(e.data);
|
|
703
|
+
},
|
|
704
|
+
onTaskUpdate: W,
|
|
705
|
+
onTaskDelete: Y,
|
|
706
|
+
inlineEdit: !0
|
|
707
|
+
})
|
|
708
|
+
}),
|
|
709
|
+
U.isOverlay && U.isOpen && U.selectedRecord && (() => {
|
|
710
|
+
let t = P?.provider === "object" ? P.object : e.objectName, n = U.selectedRecord, r = n.id ?? n._id;
|
|
711
|
+
if (!t || r == null) return null;
|
|
712
|
+
let i = F?.titleField ? String(n[F.titleField] ?? "Task Details") : "Task Details";
|
|
713
|
+
return /* @__PURE__ */ j(d, {
|
|
714
|
+
open: !0,
|
|
715
|
+
onClose: U.close,
|
|
716
|
+
title: i,
|
|
717
|
+
record: n,
|
|
718
|
+
objectName: t,
|
|
719
|
+
recordId: r,
|
|
720
|
+
dataSource: a,
|
|
721
|
+
objectSchema: k,
|
|
722
|
+
width: U.width,
|
|
723
|
+
fullPageHref: f(t, r) ?? void 0,
|
|
724
|
+
onFieldSave: async (e, n) => {
|
|
725
|
+
a?.update && (await a.update(t, String(r), { [e]: n }), T((t) => t.map((t) => String(t.id ?? t._id) === String(r) ? {
|
|
726
|
+
...t,
|
|
727
|
+
[e]: n
|
|
728
|
+
} : t)));
|
|
729
|
+
},
|
|
730
|
+
onDelete: async () => {
|
|
731
|
+
a?.delete && (await a.delete(t, String(r)), T((e) => e.filter((e) => String(e.id ?? e._id) !== String(r))));
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
})(),
|
|
735
|
+
/* @__PURE__ */ j(p, {
|
|
736
|
+
open: !!G,
|
|
737
|
+
onOpenChange: (e) => {
|
|
738
|
+
!e && !q && K(null);
|
|
547
739
|
},
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}, e))
|
|
740
|
+
children: /* @__PURE__ */ M(ee, { children: [/* @__PURE__ */ M(v, { children: [/* @__PURE__ */ j(y, { children: "Delete this task?" }), /* @__PURE__ */ j(g, { children: G ? /* @__PURE__ */ M(A, { children: [
|
|
741
|
+
"\"",
|
|
742
|
+
G.title,
|
|
743
|
+
"\" will be permanently removed. This action cannot be undone."
|
|
744
|
+
] }) : null })] }), /* @__PURE__ */ M(_, { children: [/* @__PURE__ */ j(h, {
|
|
745
|
+
disabled: q,
|
|
746
|
+
children: "Cancel"
|
|
747
|
+
}), /* @__PURE__ */ j(m, {
|
|
748
|
+
onClick: (e) => {
|
|
749
|
+
e.preventDefault(), X();
|
|
750
|
+
},
|
|
751
|
+
disabled: q,
|
|
752
|
+
"data-testid": "gantt-delete-confirm",
|
|
753
|
+
className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
754
|
+
children: q ? "Deleting…" : "Delete"
|
|
755
|
+
})] })] })
|
|
565
756
|
})
|
|
566
|
-
|
|
567
|
-
}) : /* @__PURE__ */
|
|
568
|
-
className:
|
|
569
|
-
children: /* @__PURE__ */
|
|
757
|
+
]
|
|
758
|
+
}) : /* @__PURE__ */ j("div", {
|
|
759
|
+
className: l,
|
|
760
|
+
children: /* @__PURE__ */ j("div", {
|
|
570
761
|
className: "flex items-center justify-center h-96",
|
|
571
|
-
children: /* @__PURE__ */
|
|
762
|
+
children: /* @__PURE__ */ j("div", {
|
|
572
763
|
className: "text-muted-foreground",
|
|
573
764
|
children: "Gantt configuration required. Please specify startDateField, endDateField, and titleField."
|
|
574
765
|
})
|
|
575
766
|
})
|
|
576
767
|
});
|
|
577
|
-
},
|
|
578
|
-
let { dataSource: t } =
|
|
579
|
-
return /* @__PURE__ */
|
|
768
|
+
}, V = ({ schema: e }) => {
|
|
769
|
+
let { dataSource: t } = l() || {};
|
|
770
|
+
return /* @__PURE__ */ j(B, {
|
|
580
771
|
schema: e,
|
|
581
772
|
dataSource: t
|
|
582
773
|
});
|
|
583
774
|
};
|
|
584
|
-
|
|
775
|
+
a.register("object-gantt", V, {
|
|
585
776
|
namespace: "plugin-gantt",
|
|
586
777
|
label: "Object Gantt",
|
|
587
778
|
category: "view",
|
|
@@ -596,7 +787,7 @@ i.register("object-gantt", F, {
|
|
|
596
787
|
label: "Gantt Config",
|
|
597
788
|
description: "startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField"
|
|
598
789
|
}]
|
|
599
|
-
}),
|
|
790
|
+
}), a.register("gantt", V, {
|
|
600
791
|
namespace: "view",
|
|
601
792
|
label: "Gantt View",
|
|
602
793
|
category: "view",
|
|
@@ -613,4 +804,4 @@ i.register("object-gantt", F, {
|
|
|
613
804
|
}]
|
|
614
805
|
});
|
|
615
806
|
//#endregion
|
|
616
|
-
export {
|
|
807
|
+
export { L as GanttView, B as ObjectGantt, V as ObjectGanttRenderer };
|