dishui 0.0.66 → 0.0.68

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 (49) hide show
  1. package/dist/calendar.js +5 -0
  2. package/dist/components/Accordion/index.d.ts +39 -0
  3. package/dist/components/Accordion/index.js +70 -0
  4. package/dist/components/Accordion/index.js.map +1 -0
  5. package/dist/components/Avatar/index.d.ts +48 -0
  6. package/dist/components/Avatar/index.js +71 -0
  7. package/dist/components/Avatar/index.js.map +1 -0
  8. package/dist/components/Card/index.d.ts +66 -0
  9. package/dist/components/Card/index.js +193 -3
  10. package/dist/components/Card/index.js.map +1 -1
  11. package/dist/components/Demo/index.js +76 -80
  12. package/dist/components/Demo/index.js.map +1 -1
  13. package/dist/components/Icon/index.d.ts +3 -1
  14. package/dist/components/Icon/index.js +9 -8
  15. package/dist/components/Icon/index.js.map +1 -1
  16. package/dist/components/Page/index.d.ts +1 -1
  17. package/dist/components/Page/index.js.map +1 -1
  18. package/dist/components/pro/Calendar/Calendar.js +576 -0
  19. package/dist/components/pro/Calendar/Calendar.js.map +1 -0
  20. package/dist/components/pro/Calendar/hooks/useCalendarDrag.js +104 -0
  21. package/dist/components/pro/Calendar/hooks/useCalendarDrag.js.map +1 -0
  22. package/dist/components/pro/Calendar/hooks/useCalendarState.js +187 -0
  23. package/dist/components/pro/Calendar/hooks/useCalendarState.js.map +1 -0
  24. package/dist/components/pro/Calendar/utils.js +193 -0
  25. package/dist/components/pro/Calendar/utils.js.map +1 -0
  26. package/dist/components/pro/Gantt/Gantt.js +868 -0
  27. package/dist/components/pro/Gantt/Gantt.js.map +1 -0
  28. package/dist/components/pro/Gantt/hooks/useGanttDrag.js +99 -0
  29. package/dist/components/pro/Gantt/hooks/useGanttDrag.js.map +1 -0
  30. package/dist/components/pro/Gantt/hooks/useGanttState.js +95 -0
  31. package/dist/components/pro/Gantt/hooks/useGanttState.js.map +1 -0
  32. package/dist/components/pro/Gantt/utils.js +236 -0
  33. package/dist/components/pro/Gantt/utils.js.map +1 -0
  34. package/dist/dishui.css +1 -1
  35. package/dist/gantt.js +5 -0
  36. package/dist/hooks/useCopyToClipboard.d.ts +2 -1
  37. package/dist/hooks/useCopyToClipboard.js +17 -9
  38. package/dist/hooks/useCopyToClipboard.js.map +1 -1
  39. package/dist/index.d.ts +9 -3
  40. package/dist/index.js +103 -94
  41. package/dist/utils/i18n.js +58 -8
  42. package/dist/utils/i18n.js.map +1 -1
  43. package/package.json +12 -1
  44. package/dist/components/StatCard/index.d.ts +0 -52
  45. package/dist/components/StatCard/index.js +0 -193
  46. package/dist/components/StatCard/index.js.map +0 -1
  47. package/dist/pages/components/Gantt/index.d.ts +0 -3
  48. package/dist/pages/components/Gantt/index.en.d.ts +0 -3
  49. package/dist/pages/components/Gantt/index.zh.d.ts +0 -3
@@ -0,0 +1,868 @@
1
+ import { DEFAULT_SCALE_CONFIGS as e, formatDate as t, isNonWorkingDay as n, isSameDay as r, isWeekend as i } from "./utils.js";
2
+ import { useGanttState as a } from "./hooks/useGanttState.js";
3
+ import { useGanttDrag as o } from "./hooks/useGanttDrag.js";
4
+ /* empty css */
5
+ import s, { forwardRef as c, useCallback as l, useEffect as u, useImperativeHandle as d, useMemo as f, useRef as p, useState as m } from "react";
6
+ import { Fragment as ee, jsx as h, jsxs as g } from "react/jsx-runtime";
7
+ //#region src/components/pro/Gantt/Gantt.tsx
8
+ function _(e, t) {
9
+ if (!t) return !1;
10
+ if (t.isNonWorkingDay) return t.isNonWorkingDay(e);
11
+ let n = `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`, r = t.entries?.find((e) => e.date === n);
12
+ return !(!r || r.isWorkday);
13
+ }
14
+ var v = {
15
+ showCellBorders: !0,
16
+ cellBorderColor: "",
17
+ weekendColor: "",
18
+ holidayColor: "#fff0f3",
19
+ todayColor: "",
20
+ showRowLines: !1
21
+ }, te = {
22
+ treePanelTitle: "Tasks",
23
+ searchPlaceholder: "Search...",
24
+ expandAll: "Expand All",
25
+ collapseAll: "Collapse All",
26
+ today: "Today",
27
+ zoomIn: "Zoom In",
28
+ zoomOut: "Zoom Out",
29
+ noData: "No data",
30
+ workingDays: "Working days",
31
+ calendarDays: "Calendar days",
32
+ weekDays: [
33
+ "Sun",
34
+ "Mon",
35
+ "Tue",
36
+ "Wed",
37
+ "Thu",
38
+ "Fri",
39
+ "Sat"
40
+ ],
41
+ monthNames: [
42
+ "Jan",
43
+ "Feb",
44
+ "Mar",
45
+ "Apr",
46
+ "May",
47
+ "Jun",
48
+ "Jul",
49
+ "Aug",
50
+ "Sep",
51
+ "Oct",
52
+ "Nov",
53
+ "Dec"
54
+ ],
55
+ add: "Add",
56
+ delete: "Delete",
57
+ edit: "Edit",
58
+ link: "Open link"
59
+ }, ne = c(function(c, ne) {
60
+ let { data: y, categories: re = {}, holidays: b, timeWindow: ie, columns: ae, defaultScale: oe = "day", availableScales: se, scaleConfigs: ce, treePanelWidth: le = 300, treePanelMinWidth: ue = 200, treePanelMaxWidth: de = 600, treePanelResizable: fe = !0, rowHeight: x = 36, draggable: pe = !1, resizable: me = !1, readOnly: S = !1, defaultExpandedIds: he, defaultExpandAll: ge = !0, todayMarker: C = {
61
+ visible: !0,
62
+ autoScroll: !0
63
+ }, tooltip: w = { enabled: !0 }, labels: _e, showSearch: T = !1, highlightNonWorkingDays: E = !0, grid: ve, dependencyLinks: ye = [], className: be, width: xe = "100%", height: Se = "100%", onBarChange: Ce, onNodeClick: we, onNodeDoubleClick: Te, onContextMenu: D, onNodeToggle: Ee, onViewChange: De, onScaleChange: Oe, onNodeLabelEdit: O, onNodeAdd: k, onNodeAddChild: ke, onNodeDelete: Ae, onNodeLinkClick: je, onDependencyCreate: A, onDependencyClick: Me, onDependencyDelete: Ne, renderTreeNode: Pe, renderToolbar: Fe, renderTimelineHeader: Ie } = c, j = f(() => ({
64
+ ...te,
65
+ ..._e
66
+ }), [_e]), M = f(() => ({
67
+ ...v,
68
+ ...ve
69
+ }), [ve]), { scale: N, setScale: Le, scales: Re, currentScaleConfig: P, flatNodes: F, dates: I, headerGroups: ze, dateRange: L, today: R, todayX: Be, totalTimelineWidth: z, selectedNodeId: Ve, setSelectedNodeId: B, toggleNode: He, expandAll: Ue, collapseAll: We, scrollToDate: Ge, scrollToToday: Ke, scrollToNode: qe, treeBodyRef: Je, timelineBodyRef: V, timelineHeaderRef: Ye, syncScrollVertical: Xe, syncScrollHorizontal: Ze } = a({
70
+ data: y,
71
+ defaultScale: oe,
72
+ defaultExpandedIds: he,
73
+ defaultExpandAll: ge,
74
+ scaleConfigs: ce,
75
+ categories: re,
76
+ holidays: b,
77
+ timeWindow: ie,
78
+ availableScales: se,
79
+ onScaleChange: Oe,
80
+ onNodeToggle: Ee,
81
+ onViewChange: De
82
+ }), H = o({
83
+ scaleConfig: P,
84
+ timelineStart: L.start,
85
+ onBarChange: S ? void 0 : Ce,
86
+ calendar: b
87
+ }), [Qe, $e] = m(le), U = p(!1), et = p({
88
+ x: 0,
89
+ width: 0
90
+ }), tt = l((e) => {
91
+ if (!fe) return;
92
+ e.preventDefault(), U.current = !0, et.current = {
93
+ x: e.clientX,
94
+ width: Qe
95
+ };
96
+ let t = (e) => {
97
+ U.current && $e(Math.max(ue, Math.min(de, et.current.width + e.clientX - et.current.x)));
98
+ }, n = () => {
99
+ U.current = !1, window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", n);
100
+ };
101
+ window.addEventListener("mousemove", t), window.addEventListener("mouseup", n);
102
+ }, [
103
+ fe,
104
+ Qe,
105
+ ue,
106
+ de
107
+ ]), [W, nt] = m(""), G = f(() => {
108
+ if (!W.trim()) return F;
109
+ let e = W.toLowerCase();
110
+ return F.filter((t) => t.node.label.toLowerCase().includes(e));
111
+ }, [F, W]), [K, q] = m(""), [rt, it] = m(!1), [J, at] = m(null), ot = p(null), st = l((e) => {
112
+ !S && O && (at(e), q(e.label), it(!0));
113
+ }, [S, O]), ct = l(() => {
114
+ if (!J) return;
115
+ let e = K.trim();
116
+ e && O && e !== J.label && O(J, e), it(!1), at(null), q("");
117
+ }, [
118
+ J,
119
+ K,
120
+ O
121
+ ]), Y = l(() => {
122
+ it(!1), at(null), q("");
123
+ }, []), [X, lt] = m(null), ut = p(X);
124
+ ut.current = X;
125
+ let dt = p(null), Z = l((e, t) => {
126
+ if (S || !A) return;
127
+ e.preventDefault(), e.stopPropagation();
128
+ let n = V.current;
129
+ if (!n) return;
130
+ let r = n.getBoundingClientRect(), i = (T ? G : F).find((e) => e.node.id === t), a, o;
131
+ i ? (a = e.clientX - r.left + n.scrollLeft < i.barLeft + i.barWidth / 2 ? i.barLeft : i.barLeft + i.barWidth, o = i.visibleIndex * x + x / 2) : (a = e.clientX - r.left + n.scrollLeft, o = e.clientY - r.top + n.scrollTop), lt({
132
+ fromId: t,
133
+ startX: a,
134
+ startY: o,
135
+ curX: a,
136
+ curY: o
137
+ });
138
+ }, [
139
+ S,
140
+ A,
141
+ V,
142
+ F,
143
+ G,
144
+ T,
145
+ x
146
+ ]);
147
+ u(() => {
148
+ if (!X) return;
149
+ let e = V.current;
150
+ if (!e) return;
151
+ let t = (t) => {
152
+ let n = e.getBoundingClientRect(), r = t.clientX - n.left + e.scrollLeft, i = t.clientY - n.top + e.scrollTop;
153
+ lt((e) => e ? {
154
+ ...e,
155
+ curX: r,
156
+ curY: i
157
+ } : null);
158
+ }, n = (t) => {
159
+ let n = ut.current;
160
+ if (n && A) {
161
+ let r = e.getBoundingClientRect(), i = t.clientY - r.top + e.scrollTop, a = Math.floor(i / x), o = (T ? G : F)[a];
162
+ o && o.node.id !== n.fromId && A(n.fromId, o.node.id);
163
+ }
164
+ lt(null);
165
+ };
166
+ return window.addEventListener("mousemove", t), window.addEventListener("mouseup", n), () => {
167
+ window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", n);
168
+ };
169
+ }, [X?.fromId]), u(() => {
170
+ if (C.autoScroll !== !1) {
171
+ let e = setTimeout(Ke, 100);
172
+ return () => clearTimeout(e);
173
+ }
174
+ }, []), d(ne, () => ({
175
+ scrollToDate: Ge,
176
+ scrollToToday: Ke,
177
+ scrollToNode: qe,
178
+ getVisibleRange: () => ({
179
+ start: L.start,
180
+ end: L.end
181
+ }),
182
+ setScale: Le,
183
+ expandAll: Ue,
184
+ collapseAll: We,
185
+ toggleNode: He
186
+ }));
187
+ let ft = l((e) => {
188
+ B(e.id), we?.(e);
189
+ let t = F.find((t) => t.node.id === e.id);
190
+ if (t?.resolvedStartDate && V.current) {
191
+ let e = t.barLeft - V.current.clientWidth / 3;
192
+ V.current.scrollTo({
193
+ left: Math.max(0, e),
194
+ behavior: "smooth"
195
+ });
196
+ }
197
+ }, [
198
+ F,
199
+ B,
200
+ we,
201
+ V
202
+ ]), pt = l((e) => {
203
+ if (!D) return;
204
+ e.preventDefault();
205
+ let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left + (V.current?.scrollLeft || 0), r = new Date(L.start);
206
+ r.setDate(r.getDate() + Math.floor(n / (P.cellWidth * P.slotsPerDay))), D({
207
+ node: null,
208
+ position: {
209
+ x: e.clientX,
210
+ y: e.clientY
211
+ },
212
+ date: r
213
+ });
214
+ }, [
215
+ D,
216
+ L,
217
+ P,
218
+ V
219
+ ]), mt = l((e, t, n) => {
220
+ for (let r of t) {
221
+ if (r.id === e) return n;
222
+ if (r.children) {
223
+ let t = mt(e, r.children, r);
224
+ if (t !== void 0) return t;
225
+ }
226
+ }
227
+ return null;
228
+ }, []), ht = /* @__PURE__ */ g("div", {
229
+ className: "gantt-toolbar",
230
+ children: [
231
+ /* @__PURE__ */ h("div", {
232
+ className: "gantt-toolbar-group",
233
+ children: Re.map((t) => /* @__PURE__ */ h("button", {
234
+ className: `gantt-scale-btn ${t === N ? "gantt-scale-btn--active" : ""}`,
235
+ onClick: () => Le(t),
236
+ title: e[t].label,
237
+ children: e[t].label
238
+ }, t))
239
+ }),
240
+ /* @__PURE__ */ h("div", { className: "gantt-toolbar-divider" }),
241
+ /* @__PURE__ */ h("button", {
242
+ className: "gantt-icon-btn",
243
+ onClick: Ke,
244
+ title: j.today,
245
+ children: "◉"
246
+ }),
247
+ /* @__PURE__ */ h("button", {
248
+ className: "gantt-icon-btn",
249
+ onClick: Ue,
250
+ title: j.expandAll,
251
+ children: "⊞"
252
+ }),
253
+ /* @__PURE__ */ h("button", {
254
+ className: "gantt-icon-btn",
255
+ onClick: We,
256
+ title: j.collapseAll,
257
+ children: "⊟"
258
+ }),
259
+ /* @__PURE__ */ h("div", { className: "gantt-toolbar-spacer" }),
260
+ /* @__PURE__ */ g("span", {
261
+ style: {
262
+ fontSize: 11,
263
+ color: "oklch(var(--bc) / 0.4)"
264
+ },
265
+ children: [F.length, " items"]
266
+ })
267
+ ]
268
+ }), gt = Fe ? Fe(ht) : ht, _t = (e) => {
269
+ let { node: t, depth: n, expanded: r, hasChildren: i } = e, a = Ve === t.id;
270
+ return Pe ? /* @__PURE__ */ h("div", {
271
+ className: `gantt-tree-row ${a ? "gantt-tree-row--selected" : ""}`,
272
+ style: { height: x },
273
+ onClick: () => ft(t),
274
+ onDoubleClick: () => {
275
+ Te?.(t), st(t);
276
+ },
277
+ children: Pe(t, n, r, () => He(t.id))
278
+ }, t.id) : /* @__PURE__ */ g("div", {
279
+ className: `gantt-tree-row ${a ? "gantt-tree-row--selected" : ""}`,
280
+ style: { height: x },
281
+ onClick: () => ft(t),
282
+ onDoubleClick: () => {
283
+ Te?.(t), st(t);
284
+ },
285
+ children: [
286
+ /* @__PURE__ */ h("div", {
287
+ className: "gantt-tree-indent",
288
+ style: { width: n * 20 }
289
+ }),
290
+ /* @__PURE__ */ h("div", {
291
+ className: `gantt-tree-toggle ${i ? r ? "gantt-tree-toggle--expanded" : "" : "gantt-tree-toggle--placeholder"}`,
292
+ onClick: (e) => {
293
+ e.stopPropagation(), i && He(t.id);
294
+ },
295
+ children: i && "▶"
296
+ }),
297
+ /* @__PURE__ */ h("div", {
298
+ className: "gantt-tree-label",
299
+ title: t.label,
300
+ children: t.label
301
+ }),
302
+ t.link && /* @__PURE__ */ h("button", {
303
+ className: "gantt-tree-action-btn",
304
+ title: j.link,
305
+ onClick: (e) => {
306
+ e.stopPropagation(), je ? je(t, t.link) : window.open(t.link, "_blank");
307
+ },
308
+ children: /* @__PURE__ */ g("svg", {
309
+ width: "12",
310
+ height: "12",
311
+ viewBox: "0 0 24 24",
312
+ fill: "none",
313
+ stroke: "currentColor",
314
+ strokeWidth: "2",
315
+ children: [/* @__PURE__ */ h("path", { d: "M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71" }), /* @__PURE__ */ h("path", { d: "M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71" })]
316
+ })
317
+ }),
318
+ ae?.map((e) => /* @__PURE__ */ h("div", {
319
+ className: "gantt-tree-cell",
320
+ style: {
321
+ width: e.width || 80,
322
+ textAlign: e.align || "left"
323
+ },
324
+ children: e.render ? e.render(t, e) : t.meta?.[e.key] ?? ""
325
+ }, e.key)),
326
+ !S && (k || ke || Ae) && /* @__PURE__ */ g("div", {
327
+ className: "gantt-tree-actions gantt-tree-actions--pinned",
328
+ children: [
329
+ k && /* @__PURE__ */ h("button", {
330
+ className: "gantt-tree-action-btn",
331
+ title: j.add,
332
+ onClick: (e) => {
333
+ e.stopPropagation(), k(mt(t.id, y, null), t);
334
+ },
335
+ children: /* @__PURE__ */ g("svg", {
336
+ width: "14",
337
+ height: "14",
338
+ viewBox: "0 0 24 24",
339
+ fill: "none",
340
+ stroke: "currentColor",
341
+ strokeWidth: "2",
342
+ children: [/* @__PURE__ */ h("line", {
343
+ x1: "12",
344
+ y1: "5",
345
+ x2: "12",
346
+ y2: "19"
347
+ }), /* @__PURE__ */ h("line", {
348
+ x1: "5",
349
+ y1: "12",
350
+ x2: "19",
351
+ y2: "12"
352
+ })]
353
+ })
354
+ }),
355
+ ke && /* @__PURE__ */ h("button", {
356
+ className: "gantt-tree-action-btn",
357
+ title: "Add child",
358
+ onClick: (e) => {
359
+ e.stopPropagation(), ke(t);
360
+ },
361
+ children: "⊞"
362
+ }),
363
+ Ae && /* @__PURE__ */ h("button", {
364
+ className: "gantt-tree-action-btn gantt-tree-action-btn--danger",
365
+ title: j.delete,
366
+ onClick: (e) => {
367
+ e.stopPropagation(), Ae(t);
368
+ },
369
+ children: "×"
370
+ })
371
+ ]
372
+ })
373
+ ]
374
+ }, t.id);
375
+ }, vt = () => /* @__PURE__ */ g("div", {
376
+ className: "gantt-timeline-header",
377
+ ref: Ye,
378
+ children: [/* @__PURE__ */ h("div", {
379
+ className: "gantt-timeline-header-row",
380
+ style: { width: z },
381
+ children: ze.map((e, t) => /* @__PURE__ */ h("div", {
382
+ className: "gantt-timeline-header-group",
383
+ style: { width: e.span * P.cellWidth * P.slotsPerDay },
384
+ children: e.label
385
+ }, t))
386
+ }), /* @__PURE__ */ h("div", {
387
+ className: "gantt-timeline-header-row",
388
+ style: { width: z },
389
+ children: N === "halfday" ? I.map((e, t) => {
390
+ let i = r(e, R), a = n(e, b), o = `gantt-timeline-header-cell ${i ? "gantt-timeline-header-cell--today" : ""} ${a ? "gantt-timeline-header-cell--weekend" : ""}`;
391
+ return /* @__PURE__ */ g(s.Fragment, { children: [/* @__PURE__ */ h("div", {
392
+ className: o,
393
+ style: { width: P.cellWidth },
394
+ children: "上午"
395
+ }), /* @__PURE__ */ h("div", {
396
+ className: o,
397
+ style: { width: P.cellWidth },
398
+ children: "下午"
399
+ })] }, t);
400
+ }) : N === "hour" ? I.map((e, t) => {
401
+ let i = r(e, R), a = n(e, b), o = `gantt-timeline-header-cell ${i ? "gantt-timeline-header-cell--today" : ""} ${a ? "gantt-timeline-header-cell--weekend" : ""}`;
402
+ return /* @__PURE__ */ h(s.Fragment, { children: Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ h("div", {
403
+ className: o,
404
+ style: { width: P.cellWidth },
405
+ children: t
406
+ }, t)) }, t);
407
+ }) : I.map((e, t) => {
408
+ let i = r(e, R), a = n(e, b);
409
+ return /* @__PURE__ */ h("div", {
410
+ className: `gantt-timeline-header-cell ${i ? "gantt-timeline-header-cell--today" : ""} ${a ? "gantt-timeline-header-cell--weekend" : ""}`,
411
+ style: { width: P.cellWidth * P.slotsPerDay },
412
+ children: e.getDate()
413
+ }, t);
414
+ })
415
+ })]
416
+ }), yt = () => {
417
+ if (N === "halfday" || N === "hour") {
418
+ let e = P.slotsPerDay, t = P.cellWidth, n = [];
419
+ return I.forEach((a, o) => {
420
+ let s = r(a, R), c = _(a, b), l = i(a) && b?.weekendsOff !== !1, u = M.showCellBorders;
421
+ for (let r = 0; r < e; r++) {
422
+ let i = o * e + r, a = ["gantt-timeline-col"];
423
+ u && a.push("gantt-timeline-col--border"), E && l && a.push("gantt-timeline-col--weekend"), E && c && a.push("gantt-timeline-col--holiday"), s && a.push("gantt-timeline-col--today");
424
+ let d = {
425
+ left: i * t,
426
+ width: t
427
+ };
428
+ M.cellBorderColor && u && (d.borderRightColor = M.cellBorderColor), l && M.weekendColor && (d.background = M.weekendColor), c && M.holidayColor && (d.background = M.holidayColor), s && M.todayColor && (d.background = M.todayColor), n.push(/* @__PURE__ */ h("div", {
429
+ className: a.join(" "),
430
+ style: d
431
+ }, `${o}-${r}`));
432
+ }
433
+ }), n;
434
+ }
435
+ return I.map((e, t) => {
436
+ let n = r(e, R), a = _(e, b), o = i(e) && b?.weekendsOff !== !1, s = M.showCellBorders, c = ["gantt-timeline-col"];
437
+ s && c.push("gantt-timeline-col--border"), E && o && c.push("gantt-timeline-col--weekend"), E && a && c.push("gantt-timeline-col--holiday"), n && c.push("gantt-timeline-col--today");
438
+ let l = {
439
+ left: t * P.cellWidth * P.slotsPerDay,
440
+ width: P.cellWidth * P.slotsPerDay
441
+ };
442
+ return M.cellBorderColor && s && (l.borderRightColor = M.cellBorderColor), o && M.weekendColor && (l.background = M.weekendColor), a && M.holidayColor && (l.background = M.holidayColor), n && M.todayColor && (l.background = M.todayColor), /* @__PURE__ */ h("div", {
443
+ className: c.join(" "),
444
+ style: l
445
+ }, t);
446
+ });
447
+ }, bt = (e) => {
448
+ let { node: n, barLeft: r, barWidth: i, isRenderable: a, categoryConfig: o } = e;
449
+ if (!a || i <= 0) return null;
450
+ let c = !S && (o.draggable ?? pe), l = !S && (o.resizable ?? me), u = H.draggingNodeId === n.id, d = Ve === n.id, { left: f, width: p } = H.getAdjustedBar(n.id, r, i), m = n.barColor || o.color || "#3b82f6", _ = n.barColor || o.backgroundColor || m, v = x * (o.barHeight || .6), te = (x - v) / 2, ne = o.borderRadius ?? 4, y = o.renderStyle || "bar", re = !S && !!A, b = re && /* @__PURE__ */ g(ee, { children: [/* @__PURE__ */ h("div", {
451
+ className: `gantt-bar-connector gantt-bar-connector--left ${X?.fromId === n.id ? "gantt-bar-connector--active" : ""}`,
452
+ onMouseDown: (e) => Z(e, n.id)
453
+ }), /* @__PURE__ */ h("div", {
454
+ className: `gantt-bar-connector gantt-bar-connector--right ${X?.fromId === n.id ? "gantt-bar-connector--active" : ""}`,
455
+ onMouseDown: (e) => Z(e, n.id)
456
+ })] });
457
+ return y === "line" ? /* @__PURE__ */ h("div", {
458
+ className: `gantt-bar gantt-bar--line ${d ? "gantt-bar--selected" : ""} ${u ? "gantt-bar--dragging" : ""}`,
459
+ style: {
460
+ left: f,
461
+ width: p,
462
+ background: m,
463
+ top: x / 2 - 1.5,
464
+ height: 3,
465
+ borderRadius: 1
466
+ },
467
+ children: b
468
+ }, n.id) : n.milestone ? /* @__PURE__ */ g(s.Fragment, { children: [/* @__PURE__ */ h("div", {
469
+ className: `gantt-milestone ${u ? "gantt-bar--dragging" : ""}`,
470
+ style: {
471
+ left: f + p / 2 - 7,
472
+ top: x / 2 - 7,
473
+ background: m,
474
+ transition: u ? "none" : "left 0.25s cubic-bezier(0.4,0,0.2,1)"
475
+ }
476
+ }), re && /* @__PURE__ */ g("div", {
477
+ style: {
478
+ position: "absolute",
479
+ left: f + p / 2 - 7,
480
+ top: x / 2 - 7,
481
+ width: 14,
482
+ height: 14
483
+ },
484
+ children: [/* @__PURE__ */ h("div", {
485
+ className: `gantt-bar-connector gantt-bar-connector--left ${X?.fromId === n.id ? "gantt-bar-connector--active" : ""}`,
486
+ style: {
487
+ left: -5,
488
+ top: 2
489
+ },
490
+ onMouseDown: (e) => Z(e, n.id)
491
+ }), /* @__PURE__ */ h("div", {
492
+ className: `gantt-bar-connector gantt-bar-connector--right ${X?.fromId === n.id ? "gantt-bar-connector--active" : ""}`,
493
+ style: {
494
+ right: -5,
495
+ top: 2
496
+ },
497
+ onMouseDown: (e) => Z(e, n.id)
498
+ })]
499
+ })] }, n.id) : /* @__PURE__ */ g("div", {
500
+ className: `gantt-bar ${c ? "gantt-bar--draggable" : ""} ${u ? "gantt-bar--dragging" : ""} ${d ? "gantt-bar--selected" : ""}`,
501
+ style: {
502
+ left: f,
503
+ top: te,
504
+ width: p,
505
+ height: v,
506
+ background: _,
507
+ borderRadius: ne
508
+ },
509
+ onMouseDown: c ? (e) => {
510
+ e.target.classList.contains("gantt-bar-connector") || H.startDrag(e, n, "move", r, i);
511
+ } : void 0,
512
+ onClick: (e) => {
513
+ e.stopPropagation(), B(n.id), we?.(n);
514
+ },
515
+ onContextMenu: (e) => {
516
+ D && (e.preventDefault(), e.stopPropagation(), D({
517
+ node: n,
518
+ position: {
519
+ x: e.clientX,
520
+ y: e.clientY
521
+ },
522
+ date: /* @__PURE__ */ new Date()
523
+ }));
524
+ },
525
+ children: [
526
+ o.showProgress && n.progress != null && /* @__PURE__ */ h("div", {
527
+ className: "gantt-bar-fill",
528
+ style: {
529
+ width: `${n.progress}%`,
530
+ background: m
531
+ }
532
+ }),
533
+ o.renderBar ? o.renderBar(n, {
534
+ node: n,
535
+ width: p,
536
+ height: v,
537
+ isDragging: u,
538
+ isSelected: d,
539
+ startDateFormatted: e.resolvedStartDate ? t(e.resolvedStartDate) : "",
540
+ endDateFormatted: e.resolvedEndDate ? t(e.resolvedEndDate) : "",
541
+ durationText: n.workingDays ? `${n.workingDays}d` : ""
542
+ }) : /* @__PURE__ */ h("span", {
543
+ className: "gantt-bar-label",
544
+ children: p > 60 ? n.label : n.workingDays ? `${n.workingDays}d` : ""
545
+ }),
546
+ l && /* @__PURE__ */ g(ee, { children: [/* @__PURE__ */ h("div", {
547
+ className: "gantt-bar-resize-handle gantt-bar-resize-handle--left",
548
+ onMouseDown: (e) => H.startDrag(e, n, "resize-start", r, i)
549
+ }), /* @__PURE__ */ h("div", {
550
+ className: "gantt-bar-resize-handle gantt-bar-resize-handle--right",
551
+ onMouseDown: (e) => H.startDrag(e, n, "resize-end", r, i)
552
+ })] }),
553
+ b
554
+ ]
555
+ }, n.id);
556
+ }, xt = () => {
557
+ if (ye.length === 0 && !X) return null;
558
+ let e = T ? G : F, t = new Map(e.map((e) => [e.node.id, e])), n = e.length * x;
559
+ return /* @__PURE__ */ g("svg", {
560
+ className: "gantt-dependency-svg",
561
+ style: {
562
+ width: z,
563
+ height: n
564
+ },
565
+ children: [ye.map((e, n) => {
566
+ let r = t.get(e.fromId), i = t.get(e.toId);
567
+ if (!r || !i) return null;
568
+ let a = r.barLeft + r.barWidth, o = r.visibleIndex * x + x / 2, s = i.barLeft, c = i.visibleIndex * x + x / 2, l = a + 12, u = `M${a},${o} H${l} V${c} H${s}`, d = e.lineStyle === "dashed" ? "gantt-dependency-path--dashed" : e.lineStyle === "dotted" ? "gantt-dependency-path--dotted" : "gantt-dependency-path--solid", f = e.color || void 0, p = e.lineWidth || 1.5, m = e.showArrow !== !1, ee = !S && !!Ne, _ = l, v = (o + c) / 2;
569
+ return /* @__PURE__ */ g("g", {
570
+ className: "gantt-dependency-group",
571
+ onClick: () => Me?.(e),
572
+ children: [
573
+ /* @__PURE__ */ h("path", {
574
+ className: `gantt-dependency-path ${d}`,
575
+ d: u,
576
+ style: {
577
+ stroke: f,
578
+ strokeWidth: p
579
+ }
580
+ }),
581
+ m && /* @__PURE__ */ h("polygon", {
582
+ className: "gantt-dependency-arrow",
583
+ points: `${s},${c} ${s - 6},${c - 4} ${s - 6},${c + 4}`,
584
+ style: { fill: f }
585
+ }),
586
+ ee && /* @__PURE__ */ h("foreignObject", {
587
+ x: _ - 8,
588
+ y: v - 8,
589
+ width: 16,
590
+ height: 16,
591
+ className: "gantt-dependency-delete-fo",
592
+ children: /* @__PURE__ */ h("button", {
593
+ className: "gantt-dependency-delete-btn",
594
+ onClick: (t) => {
595
+ t.stopPropagation(), Ne(e);
596
+ },
597
+ title: "删除连线",
598
+ children: "×"
599
+ })
600
+ })
601
+ ]
602
+ }, n);
603
+ }), X && (() => {
604
+ let { startX: e, startY: t, curX: n, curY: r } = X, i = n - e, a = Math.min(Math.abs(i) * .5, 60), o = `M${e},${t} C${e + a},${t} ${n - a},${r} ${n},${r}`;
605
+ return /* @__PURE__ */ h("path", {
606
+ className: "gantt-dep-drag-line",
607
+ d: o
608
+ });
609
+ })()]
610
+ });
611
+ }, St = () => C.visible ? /* @__PURE__ */ h("div", {
612
+ className: "gantt-today-marker",
613
+ style: {
614
+ left: Be,
615
+ ...C.color ? { background: C.color } : {}
616
+ }
617
+ }) : null, [Q, Ct] = m(null), wt = l((e, t) => {
618
+ w.enabled && !H.isDragging && Ct({
619
+ node: t,
620
+ x: e.clientX + 12,
621
+ y: e.clientY + 12
622
+ });
623
+ }, [w.enabled, H.isDragging]), Tt = l(() => Ct(null), []), Et = () => {
624
+ if (!Q) return null;
625
+ if (w.render) return /* @__PURE__ */ h("div", {
626
+ className: "gantt-tooltip",
627
+ style: {
628
+ left: Q.x,
629
+ top: Q.y
630
+ },
631
+ children: w.render(Q.node)
632
+ });
633
+ let e = Q.node;
634
+ return /* @__PURE__ */ g("div", {
635
+ className: "gantt-tooltip",
636
+ style: {
637
+ left: Q.x,
638
+ top: Q.y
639
+ },
640
+ children: [
641
+ /* @__PURE__ */ h("div", {
642
+ className: "gantt-tooltip-title",
643
+ children: e.label
644
+ }),
645
+ e.startDate && /* @__PURE__ */ g("div", {
646
+ className: "gantt-tooltip-row",
647
+ children: [/* @__PURE__ */ h("span", {
648
+ className: "gantt-tooltip-label",
649
+ children: "Start:"
650
+ }), typeof e.startDate == "string" ? e.startDate : t(e.startDate)]
651
+ }),
652
+ e.endDate && /* @__PURE__ */ g("div", {
653
+ className: "gantt-tooltip-row",
654
+ children: [/* @__PURE__ */ h("span", {
655
+ className: "gantt-tooltip-label",
656
+ children: "End:"
657
+ }), typeof e.endDate == "string" ? e.endDate : t(e.endDate)]
658
+ }),
659
+ e.workingDays != null && /* @__PURE__ */ g("div", {
660
+ className: "gantt-tooltip-row",
661
+ children: [/* @__PURE__ */ g("span", {
662
+ className: "gantt-tooltip-label",
663
+ children: [j.workingDays, ":"]
664
+ }), e.workingDays]
665
+ }),
666
+ e.assignee && /* @__PURE__ */ g("div", {
667
+ className: "gantt-tooltip-row",
668
+ children: [/* @__PURE__ */ h("span", {
669
+ className: "gantt-tooltip-label",
670
+ children: "Assignee:"
671
+ }), e.assignee]
672
+ }),
673
+ e.progress != null && /* @__PURE__ */ g("div", {
674
+ className: "gantt-tooltip-row",
675
+ children: [
676
+ /* @__PURE__ */ h("span", {
677
+ className: "gantt-tooltip-label",
678
+ children: "Progress:"
679
+ }),
680
+ e.progress,
681
+ "%"
682
+ ]
683
+ }),
684
+ e.link && /* @__PURE__ */ g("div", {
685
+ className: "gantt-tooltip-row",
686
+ children: [/* @__PURE__ */ h("span", {
687
+ className: "gantt-tooltip-label",
688
+ children: "Link:"
689
+ }), /* @__PURE__ */ h("span", {
690
+ className: "gantt-tooltip-link",
691
+ children: e.link
692
+ })]
693
+ })
694
+ ]
695
+ });
696
+ };
697
+ if (!y || y.length === 0) return /* @__PURE__ */ g("div", {
698
+ className: `gantt-container ${be || ""}`,
699
+ style: {
700
+ width: xe,
701
+ height: Se
702
+ },
703
+ children: [gt, /* @__PURE__ */ h("div", {
704
+ className: "gantt-empty",
705
+ children: j.noData
706
+ })]
707
+ });
708
+ let $ = T ? G : F, Dt = $.length * x;
709
+ return /* @__PURE__ */ g("div", {
710
+ className: `gantt-container ${be || ""}`,
711
+ style: {
712
+ width: xe,
713
+ height: Se
714
+ },
715
+ children: [
716
+ gt,
717
+ /* @__PURE__ */ g("div", {
718
+ className: "gantt-body",
719
+ children: [
720
+ /* @__PURE__ */ g("div", {
721
+ className: "gantt-tree-panel",
722
+ style: { width: Qe },
723
+ children: [
724
+ T && /* @__PURE__ */ g("div", {
725
+ className: "gantt-search",
726
+ children: [/* @__PURE__ */ g("svg", {
727
+ width: "14",
728
+ height: "14",
729
+ viewBox: "0 0 24 24",
730
+ fill: "none",
731
+ stroke: "currentColor",
732
+ strokeWidth: "2",
733
+ children: [/* @__PURE__ */ h("circle", {
734
+ cx: "11",
735
+ cy: "11",
736
+ r: "8"
737
+ }), /* @__PURE__ */ h("path", { d: "m21 21-4.3-4.3" })]
738
+ }), /* @__PURE__ */ h("input", {
739
+ className: "gantt-search-input",
740
+ placeholder: j.searchPlaceholder,
741
+ value: W,
742
+ onChange: (e) => nt(e.target.value)
743
+ })]
744
+ }),
745
+ /* @__PURE__ */ g("div", {
746
+ className: "gantt-tree-header",
747
+ children: [/* @__PURE__ */ h("div", {
748
+ className: "gantt-tree-header-cell",
749
+ style: { flex: 1 },
750
+ children: j.treePanelTitle
751
+ }), ae?.map((e) => /* @__PURE__ */ h("div", {
752
+ className: "gantt-tree-header-cell",
753
+ style: {
754
+ width: e.width || 80,
755
+ textAlign: e.align || "left"
756
+ },
757
+ children: e.title
758
+ }, e.key))]
759
+ }),
760
+ /* @__PURE__ */ h("div", {
761
+ className: "gantt-tree-body",
762
+ ref: Je,
763
+ onScroll: () => Xe("tree"),
764
+ children: $.map(_t)
765
+ })
766
+ ]
767
+ }),
768
+ fe && /* @__PURE__ */ h("div", {
769
+ className: `gantt-resize-handle ${U.current ? "gantt-resize-handle--active" : ""}`,
770
+ onMouseDown: tt
771
+ }),
772
+ /* @__PURE__ */ g("div", {
773
+ className: "gantt-timeline-panel",
774
+ ref: dt,
775
+ children: [Ie ? Ie(I, N) : vt(), /* @__PURE__ */ g("div", {
776
+ className: "gantt-timeline-body",
777
+ ref: V,
778
+ onScroll: () => {
779
+ Xe("timeline"), Ze();
780
+ },
781
+ onContextMenu: pt,
782
+ children: [
783
+ /* @__PURE__ */ g("div", {
784
+ className: "gantt-timeline-grid",
785
+ style: {
786
+ width: z,
787
+ height: Dt
788
+ },
789
+ children: [yt(), St()]
790
+ }),
791
+ /* @__PURE__ */ h("div", {
792
+ className: "gantt-timeline-rows",
793
+ style: {
794
+ width: z,
795
+ height: Dt
796
+ },
797
+ children: $.map((e) => /* @__PURE__ */ h("div", {
798
+ className: `gantt-bar-row ${M.showRowLines ? "gantt-bar-row--lined" : ""}`,
799
+ style: { height: x },
800
+ onMouseEnter: (t) => wt(t, e.node),
801
+ onMouseLeave: Tt,
802
+ children: bt(e)
803
+ }, e.node.id))
804
+ }),
805
+ xt()
806
+ ]
807
+ })]
808
+ })
809
+ ]
810
+ }),
811
+ Et(),
812
+ rt && J && /* @__PURE__ */ h("div", {
813
+ className: "gantt-edit-dialog-overlay",
814
+ onClick: Y,
815
+ children: /* @__PURE__ */ g("div", {
816
+ className: "gantt-edit-dialog",
817
+ onClick: (e) => e.stopPropagation(),
818
+ children: [
819
+ /* @__PURE__ */ g("div", {
820
+ className: "gantt-edit-dialog__header",
821
+ children: [/* @__PURE__ */ h("span", {
822
+ className: "gantt-edit-dialog__title",
823
+ children: j.edit
824
+ }), /* @__PURE__ */ h("button", {
825
+ type: "button",
826
+ className: "gantt-edit-dialog__close",
827
+ onClick: Y,
828
+ children: "\\u00D7"
829
+ })]
830
+ }),
831
+ /* @__PURE__ */ h("div", {
832
+ className: "gantt-edit-dialog__body",
833
+ children: /* @__PURE__ */ h("input", {
834
+ ref: ot,
835
+ className: "gantt-edit-dialog__input",
836
+ value: K,
837
+ onChange: (e) => q(e.target.value),
838
+ onKeyDown: (e) => {
839
+ e.key === "Enter" && ct(), e.key === "Escape" && Y();
840
+ },
841
+ autoFocus: !0
842
+ })
843
+ }),
844
+ /* @__PURE__ */ g("div", {
845
+ className: "gantt-edit-dialog__footer",
846
+ children: [/* @__PURE__ */ h("button", {
847
+ type: "button",
848
+ className: "gantt-edit-dialog__btn gantt-edit-dialog__btn--cancel",
849
+ onClick: Y,
850
+ children: "Cancel"
851
+ }), /* @__PURE__ */ h("button", {
852
+ type: "button",
853
+ className: "gantt-edit-dialog__btn gantt-edit-dialog__btn--submit",
854
+ onClick: ct,
855
+ disabled: !K.trim(),
856
+ children: "OK"
857
+ })]
858
+ })
859
+ ]
860
+ })
861
+ })
862
+ ]
863
+ });
864
+ });
865
+ //#endregion
866
+ export { ne as default };
867
+
868
+ //# sourceMappingURL=Gantt.js.map