@nice2dev/ui 1.0.31 → 1.1.6
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 +403 -0
- package/dist/NiceCodeEditor-BVUwp9yX.js +1134 -0
- package/dist/NiceCodeEditor-cIqUSk3j.cjs +260 -0
- package/dist/NiceColorPicker-C8NZZcXE.js +596 -0
- package/dist/NiceColorPicker-CKVbjicN.cjs +1 -0
- package/dist/NiceConfirmDialog-DmBX1Iea.js +81 -0
- package/dist/NiceConfirmDialog-oSxVpsCs.cjs +1 -0
- package/dist/NiceDataGrid-3AIf2D3t.cjs +10 -0
- package/dist/NiceDataGrid-CXCUAkRb.js +1736 -0
- package/dist/NiceDocumentViewer-B-uEPZAf.js +672 -0
- package/dist/NiceDocumentViewer-BE0gKBlw.cjs +180 -0
- package/dist/NiceForm-C6F0HvrX.cjs +1 -0
- package/dist/NiceForm-CCyfWgIs.js +4805 -0
- package/dist/NiceGantt-CSFLZD2y.js +328 -0
- package/dist/NiceGantt-_ysNSVYR.cjs +1 -0
- package/dist/NiceHtmlEditor-B8B8AcSC.js +841 -0
- package/dist/NiceHtmlEditor-D8RQcBNp.cjs +10 -0
- package/dist/NiceLoginForm-Bai7aN8V.js +708 -0
- package/dist/NiceLoginForm-BrvIc-wq.cjs +1 -0
- package/dist/NiceMention-BjeLN4Jx.cjs +430 -0
- package/dist/NiceMention-CWoLD0SE.js +11082 -0
- package/dist/NiceMention-J1lUDLhg.cjs +430 -0
- package/dist/NiceMention-OaCi-GNO.js +11094 -0
- package/dist/NiceMention.css +1 -0
- package/dist/NiceModal-0UxviEYE.cjs +1 -0
- package/dist/NiceModal-D-iOonog.js +95 -0
- package/dist/NiceModuleLifecyclePanel-4hzDw6it.js +6999 -0
- package/dist/NiceModuleLifecyclePanel-Df_1k5qW.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-CPn-Q1h_.js +172 -0
- package/dist/NicePagination-EEQ6o1dF.cjs +1 -0
- package/dist/NicePivotGrid-Cmiolup9.cjs +152 -0
- package/dist/NicePivotGrid-DX_iUj2X.js +1167 -0
- package/dist/NiceSavedQueryPanel-BhjFJBvn.cjs +586 -0
- package/dist/NiceSavedQueryPanel-KvyXTnFx.js +5129 -0
- package/dist/NiceScheduler-DuxPzQQZ.js +1645 -0
- package/dist/NiceScheduler-nW7fMzKL.cjs +5 -0
- package/dist/NiceSelect-BVoqtfYN.cjs +1 -0
- package/dist/NiceSelect-DHowflmX.js +433 -0
- package/dist/NiceWindow-DdD9k4nc.cjs +1 -0
- package/dist/NiceWindow-xnTSHdHv.js +1623 -0
- package/dist/charts-B-sl1V9y.cjs +882 -0
- package/dist/charts-DO2z6Ziu.js +31920 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +7 -7
- package/dist/core-C2KhqEaU.cjs +1 -0
- package/dist/core-K2DIxXLn.js +795 -0
- package/dist/data-branching-DC6hcBQN.cjs +1 -0
- package/dist/data-branching-DykdTpjJ.js +6255 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +29 -7
- package/dist/data.mjs +18 -16
- package/dist/devops-CU0sOVEA.cjs +17 -0
- package/dist/devops-CXyEwQeM.js +8165 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +97 -9
- package/dist/editors.mjs +58 -54
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +5137 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +139 -21
- package/dist/index.mjs +66371 -992
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +6 -0
- package/dist/navigation.mjs +4 -4
- package/dist/no-code-C58g8_fb.cjs +332 -0
- package/dist/no-code-Cj4xJ3w9.js +7425 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +2 -0
- package/dist/overlays.mjs +2 -2
- package/dist/pickerCommons-B-wOzHFh.cjs +1 -0
- package/dist/pickerCommons-COiSUiP2.js +1122 -0
- package/dist/pickerCommons.css +1 -1
- package/dist/style.css +7 -7
- package/dist/vendor-BPVpdtPp.js +271 -0
- package/dist/vendor-Bo2Q64AF.cjs +1 -0
- package/package.json +17 -17
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { jsxs as l, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { D as le, G as he } from "./charts-DO2z6Ziu.js";
|
|
3
|
+
import { useState as J, useRef as S, useEffect as T, useMemo as Y, useCallback as z } from "react";
|
|
4
|
+
const b = (m, N) => {
|
|
5
|
+
const y = new Date(m);
|
|
6
|
+
return y.setDate(y.getDate() + N), y;
|
|
7
|
+
}, E = (m, N) => Math.ceil((N.getTime() - m.getTime()) / 864e5), me = ({
|
|
8
|
+
tasks: m,
|
|
9
|
+
columns: N,
|
|
10
|
+
scale: y = "day",
|
|
11
|
+
rowHeight: _ = 36,
|
|
12
|
+
dayWidth: q = 30,
|
|
13
|
+
onTaskClick: O,
|
|
14
|
+
onTaskUpdate: w,
|
|
15
|
+
showDependencies: P = !0,
|
|
16
|
+
dependencyStyle: K = "square",
|
|
17
|
+
draggable: M,
|
|
18
|
+
zoomControls: V,
|
|
19
|
+
className: Z,
|
|
20
|
+
style: k,
|
|
21
|
+
accessMode: H,
|
|
22
|
+
id: U
|
|
23
|
+
}) => {
|
|
24
|
+
const ee = le(H, U) === "hidden", { t: _e } = he(), [o, C] = J(q), [f, B] = J(null), x = N || [{ field: "title", title: "Task", width: 200 }], j = x.reduce((e, t) => e + (t.width || 120), 0), A = S(null), X = S(null), W = S(!1);
|
|
25
|
+
T(() => {
|
|
26
|
+
const e = A.current, t = X.current;
|
|
27
|
+
if (!e || !t)
|
|
28
|
+
return;
|
|
29
|
+
const a = (c, i) => () => {
|
|
30
|
+
W.current || (W.current = !0, i.scrollTop = c.scrollTop, requestAnimationFrame(() => {
|
|
31
|
+
W.current = !1;
|
|
32
|
+
}));
|
|
33
|
+
}, n = a(e, t), r = a(t, e);
|
|
34
|
+
return e.addEventListener("scroll", n, { passive: !0 }), t.addEventListener("scroll", r, { passive: !0 }), () => {
|
|
35
|
+
e.removeEventListener("scroll", n), t.removeEventListener("scroll", r);
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
const d = Y(() => {
|
|
39
|
+
const e = (t) => m.filter((n) => (n.parentId ?? null) === t).flatMap((n) => [n, ...e(n.id)]);
|
|
40
|
+
return e(null);
|
|
41
|
+
}, [m]), u = Y(() => {
|
|
42
|
+
if (d.length === 0)
|
|
43
|
+
return { start: /* @__PURE__ */ new Date(), end: /* @__PURE__ */ new Date(), days: 30 };
|
|
44
|
+
let e = new Date(d[0].start), t = new Date(d[0].end);
|
|
45
|
+
return d.forEach((a) => {
|
|
46
|
+
new Date(a.start) < e && (e = new Date(a.start)), new Date(a.end) > t && (t = new Date(a.end));
|
|
47
|
+
}), e = b(e, -2), t = b(t, 2), { start: e, end: t, days: E(e, t) };
|
|
48
|
+
}, [d]), G = u.days * o;
|
|
49
|
+
T(() => {
|
|
50
|
+
if (!f || !w)
|
|
51
|
+
return;
|
|
52
|
+
const e = (a) => {
|
|
53
|
+
const n = a.clientX - f.startX, r = Math.round(n / o);
|
|
54
|
+
if (r === 0)
|
|
55
|
+
return;
|
|
56
|
+
const c = m.find((i) => i.id === f.taskId);
|
|
57
|
+
if (c)
|
|
58
|
+
if (f.mode === "move")
|
|
59
|
+
w({
|
|
60
|
+
...c,
|
|
61
|
+
start: b(f.origStart, r),
|
|
62
|
+
end: b(f.origEnd, r)
|
|
63
|
+
});
|
|
64
|
+
else {
|
|
65
|
+
const i = b(f.origEnd, r);
|
|
66
|
+
i > f.origStart && w({ ...c, end: i });
|
|
67
|
+
}
|
|
68
|
+
}, t = () => B(null);
|
|
69
|
+
return document.addEventListener("mousemove", e), document.addEventListener("mouseup", t), () => {
|
|
70
|
+
document.removeEventListener("mousemove", e), document.removeEventListener("mouseup", t);
|
|
71
|
+
};
|
|
72
|
+
}, [f, o, m, w]);
|
|
73
|
+
const I = z(
|
|
74
|
+
(e, t, a) => {
|
|
75
|
+
if (!M || !w)
|
|
76
|
+
return;
|
|
77
|
+
a.stopPropagation();
|
|
78
|
+
const n = m.find((r) => r.id === e);
|
|
79
|
+
n && B({
|
|
80
|
+
taskId: e,
|
|
81
|
+
mode: t,
|
|
82
|
+
startX: a.clientX,
|
|
83
|
+
origStart: new Date(n.start),
|
|
84
|
+
origEnd: new Date(n.end)
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
[M, m, w]
|
|
88
|
+
), te = z(() => C((e) => Math.min(100, e + 5)), []), ne = z(() => C((e) => Math.max(8, e - 5)), []), ae = () => {
|
|
89
|
+
const e = [], t = [];
|
|
90
|
+
new Date(u.start);
|
|
91
|
+
const a = [
|
|
92
|
+
"Jan",
|
|
93
|
+
"Feb",
|
|
94
|
+
"Mar",
|
|
95
|
+
"Apr",
|
|
96
|
+
"May",
|
|
97
|
+
"Jun",
|
|
98
|
+
"Jul",
|
|
99
|
+
"Aug",
|
|
100
|
+
"Sep",
|
|
101
|
+
"Oct",
|
|
102
|
+
"Nov",
|
|
103
|
+
"Dec"
|
|
104
|
+
];
|
|
105
|
+
if (y === "day") {
|
|
106
|
+
let n = -1, r = 0;
|
|
107
|
+
for (let c = 0; c < u.days; c++) {
|
|
108
|
+
const i = b(u.start, c);
|
|
109
|
+
i.getMonth() !== n && (n >= 0 && e.push(
|
|
110
|
+
/* @__PURE__ */ l(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
className: "nice-gantt__header-cell",
|
|
114
|
+
style: { width: (c - r) * o },
|
|
115
|
+
children: [
|
|
116
|
+
a[n],
|
|
117
|
+
" ",
|
|
118
|
+
i.getFullYear()
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
`m${n}-${r}`
|
|
122
|
+
)
|
|
123
|
+
), n = i.getMonth(), r = c);
|
|
124
|
+
const h = i.getDay() === 0 || i.getDay() === 6;
|
|
125
|
+
t.push(
|
|
126
|
+
/* @__PURE__ */ s(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
className: `nice-gantt__header-cell nice-gantt__header-cell--sub ${h ? "nice-gantt__header-cell--weekend" : ""}`,
|
|
130
|
+
style: { width: o },
|
|
131
|
+
children: i.getDate()
|
|
132
|
+
},
|
|
133
|
+
c
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
n >= 0 && e.push(
|
|
138
|
+
/* @__PURE__ */ s(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
className: "nice-gantt__header-cell",
|
|
142
|
+
style: { width: (u.days - r) * o },
|
|
143
|
+
children: a[n]
|
|
144
|
+
},
|
|
145
|
+
`m${n}-last`
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
return /* @__PURE__ */ l("div", { className: "nice-gantt__chart-header", children: [
|
|
150
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__header-row", children: e }),
|
|
151
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__header-row", children: t })
|
|
152
|
+
] });
|
|
153
|
+
}, re = (e, t) => {
|
|
154
|
+
const a = E(u.start, new Date(e.start)) * o, n = Math.max(E(new Date(e.start), new Date(e.end)) * o, o), r = t * _ + 4, c = _ - 8, i = e.progress ?? 0;
|
|
155
|
+
return /* @__PURE__ */ l(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: `nice-gantt__bar ${M ? "nice-gantt__bar--draggable" : ""}`,
|
|
159
|
+
title: `${e.title} (${Math.round(i)}%)`,
|
|
160
|
+
style: {
|
|
161
|
+
left: a,
|
|
162
|
+
top: r,
|
|
163
|
+
width: n,
|
|
164
|
+
height: c,
|
|
165
|
+
backgroundColor: e.color || "var(--color-primary, #3b82f6)"
|
|
166
|
+
},
|
|
167
|
+
onClick: () => O?.(e),
|
|
168
|
+
onMouseDown: M ? (h) => I(e.id, "move", h) : void 0,
|
|
169
|
+
children: [
|
|
170
|
+
i > 0 && /* @__PURE__ */ s("div", { className: "nice-gantt__bar-progress", style: { width: `${i}%` } }),
|
|
171
|
+
/* @__PURE__ */ s("span", { className: "nice-gantt__bar-label", children: e.title }),
|
|
172
|
+
M && /* @__PURE__ */ s(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
className: "nice-gantt__bar-resize",
|
|
176
|
+
onMouseDown: (h) => I(e.id, "resize", h)
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
e.id
|
|
182
|
+
);
|
|
183
|
+
}, se = (e, t, a, n, r) => {
|
|
184
|
+
const h = e + 10, L = a - 14, R = (t + n) / 2, D = n >= t ? 1 : -1, Q = Math.abs(n - t) < 1, F = L <= h + 4, $ = Q ? t : R, g = F ? Math.max(h, e + 10) : h, v = F ? Math.min(L, a - 10) : L;
|
|
185
|
+
if (Q || !r)
|
|
186
|
+
return [
|
|
187
|
+
`M ${e} ${t}`,
|
|
188
|
+
`L ${g} ${t}`,
|
|
189
|
+
`L ${g} ${$}`,
|
|
190
|
+
`L ${v} ${$}`,
|
|
191
|
+
`L ${v} ${n}`,
|
|
192
|
+
`L ${a} ${n}`
|
|
193
|
+
].join(" ");
|
|
194
|
+
const ce = Math.max(0, v - g), oe = Math.abs(n - t), de = Math.min(oe / 2 || 10, ce / 2 || 10), p = Math.max(2, Math.min(10, de));
|
|
195
|
+
return [
|
|
196
|
+
`M ${e} ${t}`,
|
|
197
|
+
`L ${g - p} ${t}`,
|
|
198
|
+
`Q ${g} ${t} ${g} ${t + D * p}`,
|
|
199
|
+
`L ${g} ${$ - D * p}`,
|
|
200
|
+
`Q ${g} ${$} ${g + p} ${$}`,
|
|
201
|
+
`L ${v - p} ${$}`,
|
|
202
|
+
`Q ${v} ${$} ${v} ${$ + D * p}`,
|
|
203
|
+
`L ${v} ${n - D * p}`,
|
|
204
|
+
`Q ${v} ${n} ${v + p} ${n}`,
|
|
205
|
+
`L ${a} ${n}`
|
|
206
|
+
].join(" ");
|
|
207
|
+
}, ie = () => {
|
|
208
|
+
if (!P)
|
|
209
|
+
return null;
|
|
210
|
+
const e = [], t = new Map(d.map((a, n) => [a.id, n]));
|
|
211
|
+
return d.forEach((a) => {
|
|
212
|
+
(a.dependencies || []).forEach((n) => {
|
|
213
|
+
const r = t.get(n), c = t.get(a.id);
|
|
214
|
+
if (r == null || c == null)
|
|
215
|
+
return;
|
|
216
|
+
const i = d[r], h = E(u.start, new Date(i.end)) * o, L = r * _ + _ / 2, R = E(u.start, new Date(a.start)) * o, D = c * _ + _ / 2;
|
|
217
|
+
e.push(
|
|
218
|
+
/* @__PURE__ */ s(
|
|
219
|
+
"path",
|
|
220
|
+
{
|
|
221
|
+
d: se(h, L, R, D, K === "rounded"),
|
|
222
|
+
fill: "none",
|
|
223
|
+
stroke: "var(--text-secondary, #6b7280)",
|
|
224
|
+
strokeWidth: 1.5,
|
|
225
|
+
strokeLinejoin: "round",
|
|
226
|
+
strokeLinecap: "round",
|
|
227
|
+
markerEnd: "url(#arrowhead)"
|
|
228
|
+
},
|
|
229
|
+
`${n}-${a.id}`
|
|
230
|
+
)
|
|
231
|
+
);
|
|
232
|
+
});
|
|
233
|
+
}), /* @__PURE__ */ l(
|
|
234
|
+
"svg",
|
|
235
|
+
{
|
|
236
|
+
className: "nice-gantt__deps",
|
|
237
|
+
width: G,
|
|
238
|
+
height: d.length * _,
|
|
239
|
+
style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" },
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ s("defs", { children: /* @__PURE__ */ s("marker", { id: "arrowhead", markerWidth: "6", markerHeight: "4", refX: "5", refY: "2", orient: "auto", children: /* @__PURE__ */ s("polygon", { points: "0 0, 6 2, 0 4", fill: "var(--text-secondary, #6b7280)" }) }) }),
|
|
242
|
+
e
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
return ee ? null : /* @__PURE__ */ l("div", { className: `nice-gantt ${Z || ""}`, style: k, children: [
|
|
248
|
+
V && /* @__PURE__ */ l("div", { className: "nice-gantt__zoom-controls", children: [
|
|
249
|
+
/* @__PURE__ */ s("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: ne, children: "−" }),
|
|
250
|
+
/* @__PURE__ */ l("span", { className: "nice-gantt__zoom-label", children: [
|
|
251
|
+
o,
|
|
252
|
+
"px"
|
|
253
|
+
] }),
|
|
254
|
+
/* @__PURE__ */ s("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: te, children: "+" })
|
|
255
|
+
] }),
|
|
256
|
+
/* @__PURE__ */ l("div", { className: "nice-gantt__container", children: [
|
|
257
|
+
/* @__PURE__ */ l("div", { className: "nice-gantt__table", style: { width: j, minWidth: j }, children: [
|
|
258
|
+
/* @__PURE__ */ l("div", { className: "nice-gantt__table-header", children: [
|
|
259
|
+
/* @__PURE__ */ s(
|
|
260
|
+
"div",
|
|
261
|
+
{
|
|
262
|
+
className: "nice-gantt__table-header-row nice-gantt__table-header-row--main",
|
|
263
|
+
"aria-hidden": "true",
|
|
264
|
+
children: " "
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__table-header-row nice-gantt__table-header-row--sub", children: x.map((e, t) => /* @__PURE__ */ s(
|
|
268
|
+
"div",
|
|
269
|
+
{
|
|
270
|
+
className: "nice-gantt__table-header-cell",
|
|
271
|
+
style: { width: e.width || 120 },
|
|
272
|
+
children: e.title
|
|
273
|
+
},
|
|
274
|
+
t
|
|
275
|
+
)) })
|
|
276
|
+
] }),
|
|
277
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__table-body", ref: A, children: d.map((e, t) => /* @__PURE__ */ s("div", { className: "nice-gantt__table-row", style: { height: _ }, children: x.map((a, n) => /* @__PURE__ */ s(
|
|
278
|
+
"div",
|
|
279
|
+
{
|
|
280
|
+
className: "nice-gantt__table-cell",
|
|
281
|
+
style: { width: a.width || 120 },
|
|
282
|
+
children: e[a.field]
|
|
283
|
+
},
|
|
284
|
+
n
|
|
285
|
+
)) }, e.id)) })
|
|
286
|
+
] }),
|
|
287
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__chart", children: /* @__PURE__ */ l("div", { className: "nice-gantt__chart-body-wrap", ref: X, children: [
|
|
288
|
+
ae(),
|
|
289
|
+
/* @__PURE__ */ l(
|
|
290
|
+
"div",
|
|
291
|
+
{
|
|
292
|
+
className: "nice-gantt__chart-body",
|
|
293
|
+
style: {
|
|
294
|
+
width: G,
|
|
295
|
+
height: d.length * _,
|
|
296
|
+
position: "relative"
|
|
297
|
+
},
|
|
298
|
+
children: [
|
|
299
|
+
Array.from({ length: u.days }, (e, t) => {
|
|
300
|
+
const a = b(u.start, t), n = a.getDay() === 0 || a.getDay() === 6;
|
|
301
|
+
return /* @__PURE__ */ s(
|
|
302
|
+
"div",
|
|
303
|
+
{
|
|
304
|
+
className: `nice-gantt__gridline ${n ? "nice-gantt__gridline--weekend" : ""}`,
|
|
305
|
+
style: {
|
|
306
|
+
left: t * o,
|
|
307
|
+
width: o,
|
|
308
|
+
height: "100%",
|
|
309
|
+
position: "absolute",
|
|
310
|
+
top: 0
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
t
|
|
314
|
+
);
|
|
315
|
+
}),
|
|
316
|
+
d.map((e, t) => re(e, t)),
|
|
317
|
+
ie()
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
] }) })
|
|
322
|
+
] })
|
|
323
|
+
] });
|
|
324
|
+
};
|
|
325
|
+
me.displayName = "NiceGantt";
|
|
326
|
+
export {
|
|
327
|
+
me as NiceGantt
|
|
328
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),I=require("./charts-B-sl1V9y.cjs"),l=require("react"),p=(u,j)=>{const D=new Date(u);return D.setDate(D.getDate()+j),D},M=(u,j)=>Math.ceil((j.getTime()-u.getTime())/864e5),Q=({tasks:u,columns:j,scale:D="day",rowHeight:_=36,dayWidth:T=30,onTaskClick:F,onTaskUpdate:x,showDependencies:J=!0,dependencyStyle:O="square",draggable:y,zoomControls:P,className:Y,style:k,accessMode:K,id:V})=>{const Z=I.Dc(K,V)==="hidden",{t:oe}=I.Gt(),[o,S]=l.useState(T),[f,W]=l.useState(null),L=j||[{field:"title",title:"Task",width:200}],C=L.reduce((e,t)=>e+(t.width||120),0),z=l.useRef(null),B=l.useRef(null),E=l.useRef(!1);l.useEffect(()=>{const e=z.current,t=B.current;if(!e||!t)return;const s=(c,i)=>()=>{E.current||(E.current=!0,i.scrollTop=c.scrollTop,requestAnimationFrame(()=>{E.current=!1}))},n=s(e,t),r=s(t,e);return e.addEventListener("scroll",n,{passive:!0}),t.addEventListener("scroll",r,{passive:!0}),()=>{e.removeEventListener("scroll",n),t.removeEventListener("scroll",r)}},[]);const d=l.useMemo(()=>{const e=t=>u.filter(n=>(n.parentId??null)===t).flatMap(n=>[n,...e(n.id)]);return e(null)},[u]),m=l.useMemo(()=>{if(d.length===0)return{start:new Date,end:new Date,days:30};let e=new Date(d[0].start),t=new Date(d[0].end);return d.forEach(s=>{new Date(s.start)<e&&(e=new Date(s.start)),new Date(s.end)>t&&(t=new Date(s.end))}),e=p(e,-2),t=p(t,2),{start:e,end:t,days:M(e,t)}},[d]),q=m.days*o;l.useEffect(()=>{if(!f||!x)return;const e=s=>{const n=s.clientX-f.startX,r=Math.round(n/o);if(r===0)return;const c=u.find(i=>i.id===f.taskId);if(c)if(f.mode==="move")x({...c,start:p(f.origStart,r),end:p(f.origEnd,r)});else{const i=p(f.origEnd,r);i>f.origStart&&x({...c,end:i})}},t=()=>W(null);return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[f,o,u,x]);const A=l.useCallback((e,t,s)=>{if(!y||!x)return;s.stopPropagation();const n=u.find(r=>r.id===e);n&&W({taskId:e,mode:t,startX:s.clientX,origStart:new Date(n.start),origEnd:new Date(n.end)})},[y,u,x]),H=l.useCallback(()=>S(e=>Math.min(100,e+5)),[]),U=l.useCallback(()=>S(e=>Math.max(8,e-5)),[]),ee=()=>{const e=[],t=[];new Date(m.start);const s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];if(D==="day"){let n=-1,r=0;for(let c=0;c<m.days;c++){const i=p(m.start,c);i.getMonth()!==n&&(n>=0&&e.push(a.jsxs("div",{className:"nice-gantt__header-cell",style:{width:(c-r)*o},children:[s[n]," ",i.getFullYear()]},`m${n}-${r}`)),n=i.getMonth(),r=c);const h=i.getDay()===0||i.getDay()===6;t.push(a.jsx("div",{className:`nice-gantt__header-cell nice-gantt__header-cell--sub ${h?"nice-gantt__header-cell--weekend":""}`,style:{width:o},children:i.getDate()},c))}n>=0&&e.push(a.jsx("div",{className:"nice-gantt__header-cell",style:{width:(m.days-r)*o},children:s[n]},`m${n}-last`))}return a.jsxs("div",{className:"nice-gantt__chart-header",children:[a.jsx("div",{className:"nice-gantt__header-row",children:e}),a.jsx("div",{className:"nice-gantt__header-row",children:t})]})},te=(e,t)=>{const s=M(m.start,new Date(e.start))*o,n=Math.max(M(new Date(e.start),new Date(e.end))*o,o),r=t*_+4,c=_-8,i=e.progress??0;return a.jsxs("div",{className:`nice-gantt__bar ${y?"nice-gantt__bar--draggable":""}`,title:`${e.title} (${Math.round(i)}%)`,style:{left:s,top:r,width:n,height:c,backgroundColor:e.color||"var(--color-primary, #3b82f6)"},onClick:()=>F?.(e),onMouseDown:y?h=>A(e.id,"move",h):void 0,children:[i>0&&a.jsx("div",{className:"nice-gantt__bar-progress",style:{width:`${i}%`}}),a.jsx("span",{className:"nice-gantt__bar-label",children:e.title}),y&&a.jsx("div",{className:"nice-gantt__bar-resize",onMouseDown:h=>A(e.id,"resize",h)})]},e.id)},ne=(e,t,s,n,r)=>{const h=e+10,N=s-14,R=(t+n)/2,w=n>=t?1:-1,X=Math.abs(n-t)<1,G=N<=h+4,b=X?t:R,g=G?Math.max(h,e+10):h,v=G?Math.min(N,s-10):N;if(X||!r)return[`M ${e} ${t}`,`L ${g} ${t}`,`L ${g} ${b}`,`L ${v} ${b}`,`L ${v} ${n}`,`L ${s} ${n}`].join(" ");const ae=Math.max(0,v-g),re=Math.abs(n-t),ie=Math.min(re/2||10,ae/2||10),$=Math.max(2,Math.min(10,ie));return[`M ${e} ${t}`,`L ${g-$} ${t}`,`Q ${g} ${t} ${g} ${t+w*$}`,`L ${g} ${b-w*$}`,`Q ${g} ${b} ${g+$} ${b}`,`L ${v-$} ${b}`,`Q ${v} ${b} ${v} ${b+w*$}`,`L ${v} ${n-w*$}`,`Q ${v} ${n} ${v+$} ${n}`,`L ${s} ${n}`].join(" ")},se=()=>{if(!J)return null;const e=[],t=new Map(d.map((s,n)=>[s.id,n]));return d.forEach(s=>{(s.dependencies||[]).forEach(n=>{const r=t.get(n),c=t.get(s.id);if(r==null||c==null)return;const i=d[r],h=M(m.start,new Date(i.end))*o,N=r*_+_/2,R=M(m.start,new Date(s.start))*o,w=c*_+_/2;e.push(a.jsx("path",{d:ne(h,N,R,w,O==="rounded"),fill:"none",stroke:"var(--text-secondary, #6b7280)",strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",markerEnd:"url(#arrowhead)"},`${n}-${s.id}`))})}),a.jsxs("svg",{className:"nice-gantt__deps",width:q,height:d.length*_,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[a.jsx("defs",{children:a.jsx("marker",{id:"arrowhead",markerWidth:"6",markerHeight:"4",refX:"5",refY:"2",orient:"auto",children:a.jsx("polygon",{points:"0 0, 6 2, 0 4",fill:"var(--text-secondary, #6b7280)"})})}),e]})};return Z?null:a.jsxs("div",{className:`nice-gantt ${Y||""}`,style:k,children:[P&&a.jsxs("div",{className:"nice-gantt__zoom-controls",children:[a.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:U,children:"−"}),a.jsxs("span",{className:"nice-gantt__zoom-label",children:[o,"px"]}),a.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:H,children:"+"})]}),a.jsxs("div",{className:"nice-gantt__container",children:[a.jsxs("div",{className:"nice-gantt__table",style:{width:C,minWidth:C},children:[a.jsxs("div",{className:"nice-gantt__table-header",children:[a.jsx("div",{className:"nice-gantt__table-header-row nice-gantt__table-header-row--main","aria-hidden":"true",children:" "}),a.jsx("div",{className:"nice-gantt__table-header-row nice-gantt__table-header-row--sub",children:L.map((e,t)=>a.jsx("div",{className:"nice-gantt__table-header-cell",style:{width:e.width||120},children:e.title},t))})]}),a.jsx("div",{className:"nice-gantt__table-body",ref:z,children:d.map((e,t)=>a.jsx("div",{className:"nice-gantt__table-row",style:{height:_},children:L.map((s,n)=>a.jsx("div",{className:"nice-gantt__table-cell",style:{width:s.width||120},children:e[s.field]},n))},e.id))})]}),a.jsx("div",{className:"nice-gantt__chart",children:a.jsxs("div",{className:"nice-gantt__chart-body-wrap",ref:B,children:[ee(),a.jsxs("div",{className:"nice-gantt__chart-body",style:{width:q,height:d.length*_,position:"relative"},children:[Array.from({length:m.days},(e,t)=>{const s=p(m.start,t),n=s.getDay()===0||s.getDay()===6;return a.jsx("div",{className:`nice-gantt__gridline ${n?"nice-gantt__gridline--weekend":""}`,style:{left:t*o,width:o,height:"100%",position:"absolute",top:0}},t)}),d.map((e,t)=>te(e,t)),se()]})]})})]})]})};Q.displayName="NiceGantt";exports.NiceGantt=Q;
|