@nice2dev/ui 1.1.6 → 1.1.7
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 +52 -0
- package/README.md +50 -29
- package/css/legacy-bg-text-aliases.css +65 -61
- package/dist/NiceCodeEditor-Bc81wiaN.js +1134 -0
- package/dist/NiceCodeEditor-D6f8KdHN.js +1134 -0
- package/dist/NiceCodeEditor-DE3saxyt.cjs +260 -0
- package/dist/NiceCodeEditor-DZM16My5.cjs +260 -0
- package/dist/NiceCodeEditor-HqmcJjmZ.js +1179 -0
- package/dist/NiceColorPicker-6EqXaDj0.cjs +1 -0
- package/dist/NiceColorPicker-BiEWqWnd.js +596 -0
- package/dist/NiceColorPicker-Cuc6YXqz.cjs +1 -0
- package/dist/NiceColorPicker-DMATcNWG.js +596 -0
- package/dist/NiceColorPicker-R3O1nemp.js +596 -0
- package/dist/NiceConfirmDialog-B0e10fRL.cjs +1 -0
- package/dist/NiceConfirmDialog-BBDgEMHv.js +81 -0
- package/dist/NiceConfirmDialog-C7kdr8jJ.js +81 -0
- package/dist/NiceConfirmDialog-DMHqPfFM.js +81 -0
- package/dist/NiceConfirmDialog-ZJpQLQQS.cjs +1 -0
- package/dist/NiceDataGrid-BzUw4dSu.cjs +10 -0
- package/dist/NiceDataGrid-CPKcVOVz.js +1743 -0
- package/dist/NiceDataGrid-DJr33WMy.cjs +10 -0
- package/dist/NiceDataGrid-D_4gZ1Hu.js +1736 -0
- package/dist/NiceDataGrid-DlUAaXhD.js +1736 -0
- package/dist/NiceDocumentViewer-8ghRVtfO.js +672 -0
- package/dist/NiceDocumentViewer-ChWtA_Ry.cjs +180 -0
- package/dist/NiceDocumentViewer-DwLUV7Tc.js +672 -0
- package/dist/NiceDocumentViewer-goMzF1w3.cjs +180 -0
- package/dist/NiceDocumentViewer-gt1mxzP8.js +672 -0
- package/dist/NiceForm-CHEAHxDw.js +4805 -0
- package/dist/NiceForm-CJUp1CL0.cjs +1 -0
- package/dist/NiceForm-Cp_RH3Yj.js +4805 -0
- package/dist/NiceForm-a6tGr6ss.js +4819 -0
- package/dist/NiceForm-jU89oe2S.cjs +1 -0
- package/dist/NiceGantt-BnQwyTfG.cjs +1 -0
- package/dist/NiceGantt-D8coFAvK.js +328 -0
- package/dist/NiceGantt-DOZfT6r5.js +328 -0
- package/dist/NiceGantt-DQzH1V-R.js +328 -0
- package/dist/NiceGantt-jQ8ZpXko.cjs +1 -0
- package/dist/NiceHtmlEditor-B1nlXJNW.cjs +10 -0
- package/dist/NiceHtmlEditor-Bv3VqJPG.js +862 -0
- package/dist/NiceHtmlEditor-CKsGj-Ei.cjs +10 -0
- package/dist/NiceHtmlEditor-CloMgyzg.js +841 -0
- package/dist/NiceHtmlEditor-DUAHmkWI.js +841 -0
- package/dist/NiceLoginForm-Ce_QLnLf.js +736 -0
- package/dist/NiceLoginForm-DLpNTQlR.cjs +1 -0
- package/dist/NiceLoginForm-Dg0286Cc.js +736 -0
- package/dist/NiceLoginForm-X05Vadeg.js +708 -0
- package/dist/NiceLoginForm-f_dBCnUi.cjs +1 -0
- package/dist/NiceMention-BByI4nFG.js +11120 -0
- package/dist/NiceMention-C2TPiMph.cjs +430 -0
- package/dist/NiceMention-C67vT6m0.js +11145 -0
- package/dist/NiceMention-D1cdy63w.cjs +430 -0
- package/dist/NiceMention-QIuggb9Y.js +11122 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-CHaan9al.js +95 -0
- package/dist/NiceModal-Czq6OEAT.js +95 -0
- package/dist/NiceModal-D-HFwawr.js +95 -0
- package/dist/NiceModal-DOy2XTzc.cjs +1 -0
- package/dist/NiceModal-DkawKzEE.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-1CsP8Zst.js +6997 -0
- package/dist/NiceModuleLifecyclePanel-Bkx4Yg-3.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-C5oYtczk.js +6999 -0
- package/dist/NiceModuleLifecyclePanel-DCcy2yYi.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DqdgW-0s.js +7004 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-7od5KUa3.cjs +1 -0
- package/dist/NicePagination-DMrkR8hH.cjs +1 -0
- package/dist/NicePagination-DQmZpsSQ.js +179 -0
- package/dist/NicePagination-DipQRjPq.js +172 -0
- package/dist/NicePagination-KhlVXYaT.js +172 -0
- package/dist/NicePivotGrid-B-KthuqL.cjs +152 -0
- package/dist/NicePivotGrid-CLCTHkKO.cjs +152 -0
- package/dist/NicePivotGrid-DV54FCsH.js +1174 -0
- package/dist/NicePivotGrid-DoWLUPUs.js +1167 -0
- package/dist/NicePivotGrid-etwpfccz.js +1167 -0
- package/dist/NiceSavedQueryPanel-BABkTNc5.js +5129 -0
- package/dist/NiceSavedQueryPanel-Cfeig83P.cjs +586 -0
- package/dist/NiceSavedQueryPanel-DTWRLseb.cjs +586 -0
- package/dist/NiceSavedQueryPanel-Dy154sxE.js +5129 -0
- package/dist/NiceSavedQueryPanel-v7AffOOe.js +5129 -0
- package/dist/NiceSavedQueryPanel.css +1 -1
- package/dist/NiceScheduler-BEgB7ZgF.cjs +5 -0
- package/dist/NiceScheduler-C9JprsEI.cjs +5 -0
- package/dist/NiceScheduler-DSP-PPh0.js +1645 -0
- package/dist/NiceScheduler-DuPnaA3t.js +1652 -0
- package/dist/NiceScheduler-Oa89YZx9.js +1645 -0
- package/dist/NiceSelect-A336yeLZ.js +433 -0
- package/dist/NiceSelect-B5hTbqi2.js +433 -0
- package/dist/NiceSelect-BYSgDYzq.cjs +1 -0
- package/dist/NiceSelect-Dudf2T5T.js +433 -0
- package/dist/NiceSelect-DwBAIrX7.cjs +1 -0
- package/dist/NiceWindow-B6zjBTl9.cjs +1 -0
- package/dist/NiceWindow-BKQEx7Vf.js +1623 -0
- package/dist/NiceWindow-BnTH7Gy0.js +1623 -0
- package/dist/NiceWindow-CZN9NVZw.cjs +1 -0
- package/dist/NiceWindow-lxtPR7yZ.js +1623 -0
- package/dist/NiceWindow.css +1 -1
- package/dist/charts-B8_V3_nq.cjs +882 -0
- package/dist/charts-BZgyyybE.js +31933 -0
- package/dist/charts-FuDk5-r6.js +31958 -0
- package/dist/charts-INj3yFo5.js +31946 -0
- package/dist/charts-NolNXKUL.cjs +882 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.css +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-A_A6c7an.js +795 -0
- package/dist/core-B2iH2J_X.js +795 -0
- package/dist/core-BmspZEfD.js +795 -0
- package/dist/core-DAfLOet6.cjs +1 -0
- package/dist/core-ZG3bgnBR.cjs +1 -0
- package/dist/data-branching-B3TOqXAO.cjs +1 -0
- package/dist/data-branching-BUGiICDZ.js +6275 -0
- package/dist/data-branching-DMXmcocj.js +6275 -0
- package/dist/data-branching-YE8P9M5P.js +6275 -0
- package/dist/data-branching-t6uhAwIm.cjs +1 -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 +7 -2
- package/dist/data.mjs +3 -3
- package/dist/devops-BhV3OmF7.js +8285 -0
- package/dist/devops-BqUxnbRi.cjs +17 -0
- package/dist/devops-Bx-Qwj9w.cjs +17 -0
- package/dist/devops-DYZatW45.js +8251 -0
- package/dist/devops-R98k2zpd.js +8251 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.d.ts +29 -16
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +35 -20
- package/dist/editors.mjs +7 -7
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +445 -445
- package/dist/index.css +1 -1
- package/dist/index.d.ts +190 -111
- package/dist/index.mjs +16635 -16351
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +31 -18
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +17 -14
- package/dist/navigation.mjs +130 -130
- package/dist/no-code-BPaAS4wW.cjs +332 -0
- package/dist/no-code-CBwUVL1i.js +7447 -0
- package/dist/no-code-CjktkQ50.js +7447 -0
- package/dist/no-code-DW2NrRba.js +7447 -0
- package/dist/no-code-DmFxrZ5T.cjs +332 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +2 -2
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +4 -4
- package/dist/overlays.mjs +2 -2
- package/dist/pickerCommons-C4XWRUvH.cjs +1 -0
- package/dist/pickerCommons-C_BpYs_m.cjs +1 -0
- package/dist/pickerCommons-DAOXH_u5.js +1122 -0
- package/dist/pickerCommons-Dn4wnDco.js +1122 -0
- package/dist/pickerCommons-DskswPS5.js +1122 -0
- package/dist/pickerCommons.css +1 -1
- package/dist/style.css +7 -7
- package/package.json +3 -3
|
@@ -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-INj3yFo5.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(--nice-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(--nice-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(--nice-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-B8_V3_nq.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(--nice-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(--nice-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(--nice-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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),C=require("./charts-NolNXKUL.cjs"),o=require("react"),b=require("./NiceColorPicker-Cuc6YXqz.cjs"),Ze=require("./NiceSelect-BYSgDYzq.cjs");function pe(x){const n=x.trim().toLowerCase();return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/")||n.startsWith("./")||n.startsWith("../")?!0:!(n.startsWith("javascript:")||n.startsWith("vbscript:")||n.startsWith("data:text"))}const et=[{target:".nice-htmleditor",titleKey:"tutorial.htmlEditor.intro.title",title:"Rich text editor",contentKey:"tutorial.htmlEditor.intro.content",content:"Format text with the toolbar, insert links, images and tables, and switch to HTML or Markdown source when you need it.",placement:"auto"}],tt=["bold","italic","underline","strikethrough","h1","h2","h3","ul","ol","blockquote","hr","link","unlink","image","table","code","alignLeft","alignCenter","alignRight","fontSize","fontColor","undo","redo","clear","findReplace","emoji","source","fullscreen","markdown"],l=({d:x,viewBox:n="0 0 24 24"})=>t.jsx("svg",{width:"16",height:"16",viewBox:n,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:x})}),nt={bold:t.jsx("strong",{style:{fontFamily:"serif"},children:"B"}),italic:t.jsx("em",{style:{fontFamily:"serif"},children:"I"}),underline:t.jsx("span",{style:{textDecoration:"underline"},children:"U"}),strikethrough:t.jsx("span",{style:{textDecoration:"line-through"},children:"S"}),h1:"H1",h2:"H2",h3:"H3",ul:t.jsx(l,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:t.jsx(l,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:t.jsx(l,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}),unlink:t.jsx(l,{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07L11 5.78M3 3l18 18M9 15l3-3M14 11l3 3M14 21l-1.72-1.72a5 5 0 0 1-7.07-7.07L7 10.49"}),undo:t.jsx(l,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:t.jsx(l,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:t.jsx(l,{d:"M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),table:t.jsx(l,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:t.jsx(l,{d:"M3 3h18v18H3zM3 16l5-5 4 4 3-3 6 6M9 9a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"}),code:t.jsx(l,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:t.jsx(l,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:t.jsx(l,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:t.jsx(l,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:t.jsx(l,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:t.jsx(l,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:t.jsx(l,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:t.jsx(l,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:t.jsx(l,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:t.jsx(l,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:t.jsx(l,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:t.jsx(l,{d:"M6 9V2h12v7M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2M6 14h12v8H6z"}),source:t.jsx(l,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:t.jsx(l,{d:"M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zM8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01"}),findReplace:t.jsx(l,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:t.jsx(l,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:t.jsx(l,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},rt=[{value:"1",label:"8pt"},{value:"2",label:"10pt"},{value:"3",label:"12pt"},{value:"4",label:"14pt"},{value:"5",label:"18pt"},{value:"6",label:"24pt"},{value:"7",label:"36pt"}],st=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function ot(x){let n=x;return n=n.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
|
|
2
|
+
`),n=n.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
|
|
3
|
+
`),n=n.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
|
|
4
|
+
`),n=n.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),n=n.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),n=n.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),n=n.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),n=n.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),n=n.replace(/<pre[^>]*>(.*?)<\/pre>/gis,"```\n$1\n```\n"),n=n.replace(/<br\s*\/?>/gi,`
|
|
5
|
+
`),n=n.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
|
|
6
|
+
`),n=n.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi,`
|
|
7
|
+
`),n=n.replace(/<[^>]+>/g,""),n=n.replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`),n.trim()}function at(x){let n=x;return n=n.replace(/^### (.+)$/gm,"<h3>$1</h3>"),n=n.replace(/^## (.+)$/gm,"<h2>$1</h2>"),n=n.replace(/^# (.+)$/gm,"<h1>$1</h1>"),n=n.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/\*(.+?)\*/g,"<em>$1</em>"),n=n.replace(/`([^`]+)`/g,"<code>$1</code>"),n=n.replace(/```\n?([\s\S]*?)\n?```/g,"<pre>$1</pre>"),n=n.replace(/^- (.+)$/gm,"<li>$1</li>"),n=n.replace(/(<li>.*<\/li>)/gs,"<ul>$1</ul>"),n=n.replace(/\n/g,"<br>"),n}const it=({value:x,defaultValue:n,onChange:xe,placeholder:be,height:$=200,toolbar:ge=tt,readOnly:h,onImageUpload:H,mentionTrigger:g,mentionSuggestions:Me,onMentionSearch:G,onFileDrop:w,pasteCleanup:Z=!0,maxLength:L=0,showWordCount:ee=!1,templates:D,label:te,error:N,helperText:ne,required:ve,disabled:p,size:Ce="md",id:re,className:ke,style:ye,accessMode:je,tutorial:Se})=>{const E=C.Dc(je,re),He=E==="hidden";E==="disabled"&&(p=!0),E==="readOnly"&&(h=!0);const se=C.bc(re),[u,c]=C.Vu({value:x,defaultValue:n,fallbackValue:"",onChange:xe,componentName:"NiceHtmlEditor"}),d=o.useRef(null),[we]=o.useState(()=>({__html:u})),I=o.useRef(u);I.current=u;const Le=o.useCallback(e=>{d.current=e,e&&e.innerHTML!==I.current&&(e.innerHTML=I.current)},[]);o.useLayoutEffect(()=>{const e=d.current;e&&e.innerHTML!==u&&(e.innerHTML=u)},[u]);const oe=o.useRef(null),Te=o.useRef(null),[k,O]=o.useState(!1),[F,ae]=o.useState(""),[y,W]=o.useState(!1),[B,ie]=o.useState(""),[K,R]=o.useState(!1),[_e,Ne]=o.useState(""),[A,q]=o.useState(0),[V,Re]=o.useState(!1),[le,ze]=o.useState("var(--nice-text, #000000)"),[ce,$e]=o.useState("var(--nice-warning, #ffff00)"),[de,P]=o.useState(0),[De,Ee]=o.useState(0),[Q,U]=o.useState(!1),[m,Ie]=o.useState(""),[T,Oe]=o.useState(""),[X,ue]=o.useState(!1),[me,fe]=o.useState(!1),f=o.useCallback((e,r)=>{if(h||p)return;if(e==="markdown"){k?(c(at(F)),O(!1)):(ae(ot(u)),O(!0),W(!1));return}if(e==="source"){y?(c(B),W(!1)):(ie(u),W(!0),O(!1));return}const a=d.current;if(a){if(e==="fullscreen"){Re(s=>!s);return}if(e==="emoji"){ue(s=>!s);return}if(e==="findReplace"){U(s=>!s);return}if(e==="image"){if(H)oe.current?.click();else{const s=prompt("Image URL:");s&&pe(s)&&(a.focus(),document.execCommand("insertImage",!1,s),c(C.lc(a.innerHTML)))}return}switch(a.focus(),e){case"bold":document.execCommand("bold");break;case"italic":document.execCommand("italic");break;case"underline":document.execCommand("underline");break;case"strikethrough":document.execCommand("strikeThrough");break;case"h1":document.execCommand("formatBlock",!1,"h1");break;case"h2":document.execCommand("formatBlock",!1,"h2");break;case"h3":document.execCommand("formatBlock",!1,"h3");break;case"ul":document.execCommand("insertUnorderedList");break;case"ol":document.execCommand("insertOrderedList");break;case"blockquote":document.execCommand("formatBlock",!1,"blockquote");break;case"hr":document.execCommand("insertHorizontalRule");break;case"subscript":document.execCommand("subscript");break;case"superscript":document.execCommand("superscript");break;case"indent":document.execCommand("indent");break;case"outdent":document.execCommand("outdent");break;case"alignLeft":document.execCommand("justifyLeft");break;case"alignCenter":document.execCommand("justifyCenter");break;case"alignRight":document.execCommand("justifyRight");break;case"alignJustify":document.execCommand("justifyFull");break;case"removeFormat":document.execCommand("removeFormat");break;case"print":window.print();return;case"link":{const s=prompt("URL:");s&&pe(s)&&document.execCommand("createLink",!1,s);break}case"unlink":document.execCommand("unlink");break;case"undo":document.execCommand("undo");break;case"redo":document.execCommand("redo");break;case"clear":document.execCommand("removeFormat");break;case"fontSize":{r&&document.execCommand("fontSize",!1,r);break}case"fontColor":{r&&document.execCommand("foreColor",!1,r);break}case"bgColor":{r&&document.execCommand("hiliteColor",!1,r);break}case"table":{document.execCommand("insertHTML",!1,'<table class="nice-htmleditor__table"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td> </td><td> </td><td> </td></tr><tr><td> </td><td> </td><td> </td></tr></tbody></table><p> </p>');break}case"code":{const i=window.getSelection()?.toString()||"";i.includes(`
|
|
10
|
+
`)||i.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${i||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${i||"code"}</code>`);break}}c(C.lc(a.innerHTML)),P(a.textContent?.length??0)}},[c,h,p,k,F,u,H,y,B]),Fe=o.useCallback(async e=>{const r=e.target.files?.[0];if(!r||!H)return;const a=await H(r),s=d.current;s&&a&&(s.focus(),document.execCommand("insertImage",!1,a),c(s.innerHTML)),e.target.value=""},[H,c]),We=o.useCallback(()=>{const e=d.current;if(!e)return;const r=e.textContent?.length??0;if(L>0&&r>L&&(e.textContent=(e.textContent??"").slice(0,L)),P(r),Ee((e.textContent??"").trim().split(/\s+/).filter(Boolean).length),c(e.innerHTML),g){const a=window.getSelection();if(a&&a.rangeCount>0){const s=a.getRangeAt(0),i=s.startContainer;if(i.nodeType===Node.TEXT_NODE){const M=i.textContent||"",S=s.startOffset,z=M.slice(0,S),v=z.lastIndexOf(g);if(v>=0&&(v===0||/\s/.test(z[v-1]))){const _=z.slice(v+g.length);if(!/\s/.test(_)){R(!0),Ne(_),q(0),G?.(_);return}}}}R(!1)}},[c,g,G]),j=Me?.filter(e=>e.label.toLowerCase().includes(_e.toLowerCase())).slice(0,8)??[],J=o.useCallback(e=>{const r=d.current;if(!r)return;const a=window.getSelection();if(!a||a.rangeCount===0)return;const s=a.getRangeAt(0),i=s.startContainer;if(i.nodeType===Node.TEXT_NODE&&g){const M=i.textContent||"",S=s.startOffset,v=M.slice(0,S).lastIndexOf(g);if(v>=0){const _=M.slice(0,v),Je=M.slice(S),Ye=`<span class="nice-htmleditor__mention" data-mention="${e.key}" contenteditable="false">${g}${e.label}</span> `;i.textContent=_;const Y=document.createRange();Y.setStartAfter(i),Y.collapse(!0);const Ge=Y.createContextualFragment(Ye+Je);i.parentNode?.insertBefore(Ge,i.nextSibling),a.collapseToEnd(),c(r.innerHTML)}}R(!1)},[g,c]),Be=o.useCallback(e=>{if(K&&j.length>0){e.key==="ArrowDown"?(e.preventDefault(),q(r=>Math.min(r+1,j.length-1))):e.key==="ArrowUp"?(e.preventDefault(),q(r=>Math.max(r-1,0))):e.key==="Enter"?(e.preventDefault(),J(j[A])):e.key==="Escape"&&R(!1);return}(e.ctrlKey||e.metaKey)&&e.key==="b"?(e.preventDefault(),f("bold")):(e.ctrlKey||e.metaKey)&&e.key==="i"?(e.preventDefault(),f("italic")):(e.ctrlKey||e.metaKey)&&e.key==="u"?(e.preventDefault(),f("underline")):(e.ctrlKey||e.metaKey)&&e.key==="f"?(e.preventDefault(),U(r=>!r)):(e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey?(e.preventDefault(),f("undo")):(e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey)&&(e.preventDefault(),f("redo"))},[K,j,A,J,f]),Ke=o.useCallback(e=>{if(!Z)return;e.preventDefault();const r=e.clipboardData.getData("text/html"),a=e.clipboardData.getData("text/plain");if(r){const i=r.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<script[\s\S]*?<\/script>/gi,"").replace(/class="[^"]*"/gi,"").replace(/style="[^"]*"/gi,"").replace(/<o:[^>]*>[\s\S]*?<\/o:[^>]*>/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<\/?(?:xml|meta|link|font|span)[^>]*>/gi,"");document.execCommand("insertHTML",!1,i)}else a&&document.execCommand("insertText",!1,a);const s=d.current;s&&(c(s.innerHTML),P(s.textContent?.length??0))},[Z,c]),Ae=o.useCallback(async e=>{if(!w)return;e.preventDefault();const r=Array.from(e.dataTransfer.files);if(r.length===0)return;const a=await w(r),s=d.current;if(s){s.focus();for(const i of a)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(i)||i.startsWith("data:image/"))document.execCommand("insertImage",!1,i);else{const S=`<a href="${i}">${i.split("/").pop()??i}</a>`;document.execCommand("insertHTML",!1,S)}c(s.innerHTML)}},[w,c]),qe=o.useCallback(e=>{w&&e.preventDefault()},[w]),he=o.useCallback(e=>{const r=d.current;if(!r||!m)return;const a=r.textContent??"",s=m.toLowerCase(),i=a.toLowerCase();(e===1?i.indexOf(s):i.lastIndexOf(s))!==-1&&(r.focus(),window.find?.(m))},[m]),Ve=o.useCallback(()=>{const e=d.current;!e||!m||(e.innerHTML=e.innerHTML.split(m).join(T),c(e.innerHTML))},[m,T,c]),Pe=o.useCallback(()=>{if(!m)return;const e=u.split(m).join(T);c(e);const r=d.current;r&&(r.innerHTML=e)},[m,T,u,c]),Qe=o.useCallback(e=>{const r=d.current;r&&(r.focus(),document.execCommand("insertText",!1,e),c(r.innerHTML),ue(!1))},[c]),Ue=o.useCallback(e=>{const r=d.current;r&&(r.focus(),document.execCommand("insertHTML",!1,e),c(r.innerHTML),fe(!1))},[c]),Xe=o.useCallback(e=>{const r=p||h;if(e==="fontSize")return t.jsx(Ze.NiceSelect,{size:"sm",value:"",onChange:s=>f("fontSize",String(s)),disabled:r,placeholder:"Size",options:rt.map(s=>({value:s.value,label:s.label})),style:{minWidth:70,maxWidth:80}},e);if(e==="fontColor")return t.jsx(b.NiceColorPicker,{value:le,onChange:s=>{ze(s),f("fontColor",s)},disabled:r,size:"sm",label:"",title:"Text color"},e);if(e==="bgColor")return t.jsx(b.NiceColorPicker,{value:ce,onChange:s=>{$e(s),f("bgColor",s)},disabled:r,size:"sm",label:"",title:"Highlight color"},e);const a=e==="markdown"&&k||e==="fullscreen"&&V||e==="source"&&y||e==="findReplace"&&Q||e==="emoji"&&X;return t.jsx(b.NiceButton,{size:"sm",variant:a?"primary":"ghost",onClick:()=>f(e),title:e,disabled:r,children:nt[e]||e},e)},[p,h,f,k,V,le,ce,y,Q,X]);return He?null:t.jsxs("div",{className:`nice-field nice-field--${Ce} ${N?"nice-field--error":""} ${ke||""}`,style:ye,children:[te&&t.jsxs("label",{className:"nice-field__label",htmlFor:se,children:[te,ve&&t.jsx("span",{className:"nice-field__required",children:"*"})]}),t.jsxs("div",{ref:Te,className:`nice-htmleditor${V?" nice-htmleditor--fullscreen":""}`,style:{position:"relative"},children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(C.Ql,{steps:C.Yl(Se,et)})}),t.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[ge.map(Xe),D&&D.length>0&&t.jsxs("div",{style:{position:"relative"},children:[t.jsx(b.NiceButton,{size:"sm",variant:me?"primary":"ghost",onClick:()=>fe(e=>!e),title:"Insert template",children:"??"}),me&&t.jsx("ul",{style:{position:"absolute",top:"100%",right:0,zIndex:200,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:160,maxHeight:200,overflow:"auto"},children:D.map((e,r)=>t.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:a=>{a.preventDefault(),Ue(e.html)},children:e.label},r))})]})]}),Q&&t.jsxs("div",{className:"nice-htmleditor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--nice-bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--nice-border-color, #ddd)",fontSize:"0.875em"},children:[t.jsx("input",{type:"text",placeholder:"Find...",value:m,onChange:e=>Ie(e.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--nice-border-color, #ccc)",borderRadius:4,background:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #1f2937)"}}),t.jsx("input",{type:"text",placeholder:"Replace...",value:T,onChange:e=>Oe(e.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--nice-border-color, #ccc)",borderRadius:4,background:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #1f2937)"}}),t.jsx(b.NiceButton,{size:"sm",variant:"ghost",onClick:()=>he(1),title:"Find next",children:"?"}),t.jsx(b.NiceButton,{size:"sm",variant:"ghost",onClick:()=>he(-1),title:"Find previous",children:"?"}),t.jsx(b.NiceButton,{size:"sm",variant:"ghost",onClick:Ve,disabled:p||h,children:"Replace"}),t.jsx(b.NiceButton,{size:"sm",variant:"ghost",onClick:Pe,disabled:p||h,children:"All"}),t.jsx(b.NiceButton,{size:"sm",variant:"ghost",onClick:()=>U(!1),children:"?"})]}),X&&t.jsx("div",{className:"nice-htmleditor__emoji-picker",style:{padding:8,background:"var(--nice-bg-primary, #fff)",borderBottom:"1px solid var(--nice-border-color, #ddd)",maxHeight:180,overflowY:"auto"},children:st.map(e=>t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--nice-text-muted, #999)",padding:"4px 0"},children:e.label}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:e.emojis.map(r=>t.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>Qe(r),title:r,children:r},r))})]},e.label))}),t.jsx("input",{ref:oe,type:"file",accept:"image/*",style:{display:"none"},onChange:Fe}),y?t.jsx("textarea",{className:"nice-htmleditor__source",value:B,onChange:e=>ie(e.target.value),style:{minHeight:$,width:"100%",fontFamily:"monospace",resize:"vertical",whiteSpace:"pre",fontSize:"0.85em",background:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:p||h}):k?t.jsx("textarea",{className:"nice-htmleditor__markdown",value:F,onChange:e=>ae(e.target.value),style:{minHeight:$,width:"100%",fontFamily:"monospace",resize:"vertical",background:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:p||h}):t.jsxs("div",{style:{position:"relative"},children:[t.jsx("div",{ref:Le,id:se,className:"nice-htmleditor__content",contentEditable:!p&&!h,dangerouslySetInnerHTML:we,onInput:We,onKeyDown:Be,onPaste:Ke,onDrop:Ae,onDragOver:qe,style:{minHeight:$},"data-placeholder":be,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),K&&j.length>0&&t.jsx("ul",{className:"nice-htmleditor__mention-list",children:j.map((e,r)=>t.jsx("li",{className:`nice-htmleditor__mention-item ${r===A?"nice-htmleditor__mention-item--active":""}`,onMouseDown:a=>{a.preventDefault(),J(e)},children:e.label},e.key))})]}),t.jsxs("div",{className:"nice-htmleditor__statusbar",style:{display:"flex",gap:12,padding:"2px 8px",fontSize:"0.75em",color:"var(--nice-text-muted, #666)",borderTop:"1px solid var(--nice-border-color, #eee)"},children:[L>0&&t.jsxs("span",{children:[de," / ",L]}),ee&&t.jsxs("span",{children:[De," words"]}),ee&&t.jsxs("span",{children:[de," chars"]}),y&&t.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),k&&t.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),N&&t.jsx("div",{className:"nice-field__error",children:N}),ne&&!N&&t.jsx("div",{className:"nice-field__hint",children:ne})]})};exports.NiceHtmlEditor=it;
|