@nice2dev/ui 1.3.9 → 1.3.11
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 +88 -0
- package/README.md +16 -18
- package/dist/NiceColorPicker-BLwYNSXJ.cjs +1 -0
- package/dist/NiceColorPicker-DS59tNkP.js +552 -0
- package/dist/NiceDataGrid-CL2_7fS7.cjs +10 -0
- package/dist/NiceDataGrid-CpJrRN_H.js +2269 -0
- package/dist/NiceForm-BQj-K7p7.cjs +1 -0
- package/dist/NiceForm-HQ4h7hX_.js +5023 -0
- package/dist/NiceGantt-BygumlaY.cjs +1 -0
- package/dist/NiceGantt-DTC7OH-v.js +334 -0
- package/dist/NiceHtmlEditor-BtpuaLln.js +901 -0
- package/dist/NiceHtmlEditor-C1OVtLQ6.cjs +10 -0
- package/dist/NiceMention-CVxxCVtQ.js +11668 -0
- package/dist/NiceMention-Te66Oid1.cjs +430 -0
- package/dist/NiceModuleLifecyclePanel-DCrFyUH8.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-Mt80MdET.js +7441 -0
- package/dist/NicePagination-CKsAP38Q.cjs +1 -0
- package/dist/NicePagination-zOed5QxG.js +202 -0
- package/dist/NicePivotGrid-Clue9FM5.js +1184 -0
- package/dist/NicePivotGrid-Cnkr9WkC.cjs +152 -0
- package/dist/NicePropertyGrid.doc-BWNyWrWq.cjs +7 -0
- package/dist/NicePropertyGrid.doc-C_I3F4w8.js +31 -0
- package/dist/NiceSavedQueryPanel-NgG58w6i.js +6226 -0
- package/dist/NiceSavedQueryPanel-lTWY2plm.cjs +587 -0
- package/dist/NiceScheduler-BWwqFKEc.js +1712 -0
- package/dist/NiceScheduler-DqWEJU7g.cjs +5 -0
- package/dist/NiceSelect-BNPXs6FQ.cjs +1 -0
- package/dist/NiceSelect-DEruWHan.js +495 -0
- package/dist/NiceWindow-D3V7A69Q.js +2247 -0
- package/dist/NiceWindow-pgR4c-kQ.cjs +1 -0
- package/dist/core-lazy-Bjdu111n.js +351 -0
- package/dist/core-lazy-Bx_8BOlG.cjs +1 -0
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +47 -6
- package/dist/data.mjs +3 -3
- package/dist/devops-CqhA0rjL.js +9130 -0
- package/dist/devops-cgRBnZVX.cjs +18 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +7 -7
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +1 -1
- package/dist/index.cjs +137 -151
- package/dist/index.css +1 -1
- package/dist/index.d.ts +113 -50
- package/dist/index.mjs +16556 -16423
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +15 -15
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +2 -0
- package/dist/navigation.mjs +3 -3
- package/dist/no-code-BQqK8mvU.cjs +331 -0
- package/dist/no-code-Cppb-xz3.js +8320 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +1 -1
- package/dist/pickerCommons-BA3-D5RC.js +663 -0
- package/dist/pickerCommons-KrBqCBDn.cjs +1 -0
- package/dist/style.css +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),E=require("@nice2dev/ui-core"),l=require("react"),de=[],p=(u,N)=>{const j=new Date(u);return j.setDate(j.getDate()+N),j},M=(u,N)=>Math.ceil((N.getTime()-u.getTime())/864e5),P=({tasks:u=de,columns:N,scale:j="day",rowHeight:_=36,dayWidth:Q=30,onTaskClick:L,onTaskUpdate:x,showDependencies:Y=!0,dependencyStyle:F="square",draggable:D,zoomControls:G,className:J,style:K,accessMode:V,id:Z,"data-testid":k})=>{const{t:H}=E.useNiceTranslation(),U=E.useNiceAccessMode(V,Z)==="hidden",{t:he}=E.useNiceTranslation(),[o,A]=l.useState(Q),[f,z]=l.useState(null),S=N||[{field:"title",title:H("gantt.task","Task"),width:200}],C=S.reduce((e,t)=>e+(t.width||120),0),B=l.useRef(null),q=l.useRef(null),R=l.useRef(!1);l.useEffect(()=>{const e=B.current,t=q.current;if(!e||!t)return;const s=(c,i)=>()=>{R.current||(R.current=!0,i.scrollTop=c.scrollTop,requestAnimationFrame(()=>{R.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]),I=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=()=>z(null);return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[f,o,u,x]);const O=l.useCallback((e,t,s)=>{if(!D||!x)return;s.stopPropagation();const n=u.find(r=>r.id===e);n&&z({taskId:e,mode:t,startX:s.clientX,origStart:new Date(n.start),origEnd:new Date(n.end)})},[D,u,x]),ee=l.useCallback(()=>A(e=>Math.min(100,e+5)),[]),te=l.useCallback(()=>A(e=>Math.max(8,e-5)),[]),ne=()=>{const e=[],t=[];new Date(m.start);const s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];if(j==="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})]})},se=(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",{role:L?"button":void 0,tabIndex:L?0:void 0,onKeyDown:L?E.clickOnActivationKey:void 0,className:`nice-gantt__bar ${D?"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:()=>L?.(e),onMouseDown:D?h=>O(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}),D&&a.jsx("div",{className:"nice-gantt__bar-resize",onMouseDown:h=>O(e.id,"resize",h)})]},e.id)},ae=(e,t,s,n,r)=>{const h=e+10,y=s-14,W=(t+n)/2,w=n>=t?1:-1,T=Math.abs(n-t)<1,X=y<=h+4,b=T?t:W,g=X?Math.max(h,e+10):h,v=X?Math.min(y,s-10):y;if(T||!r)return[`M ${e} ${t}`,`L ${g} ${t}`,`L ${g} ${b}`,`L ${v} ${b}`,`L ${v} ${n}`,`L ${s} ${n}`].join(" ");const ie=Math.max(0,v-g),ce=Math.abs(n-t),oe=Math.min(ce/2||10,ie/2||10),$=Math.max(2,Math.min(10,oe));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(" ")},re=()=>{if(!Y)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,y=r*_+_/2,W=M(m.start,new Date(s.start))*o,w=c*_+_/2;e.push(a.jsx("path",{d:ae(h,y,W,w,F==="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:I,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 U?null:a.jsxs("div",{className:`nice-gantt ${J||""}`,style:K,"data-testid":k,children:[G&&a.jsxs("div",{className:"nice-gantt__zoom-controls",children:[a.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:te,children:"−"}),a.jsxs("span",{className:"nice-gantt__zoom-label",children:[o,"px"]}),a.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:ee,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:S.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:B,children:d.map((e,t)=>a.jsx("div",{className:"nice-gantt__table-row",style:{height:_},children:S.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:q,children:[ne(),a.jsxs("div",{className:"nice-gantt__chart-body",style:{width:I,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)=>se(e,t)),re()]})]})})]})]})};process.env.NODE_ENV!=="production"&&(P.displayName="NiceGantt");exports.NiceGantt=P;
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { jsxs as l, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as J, useNiceAccessMode as ue, clickOnActivationKey as _e } from "@nice2dev/ui-core";
|
|
3
|
+
import { useState as K, useRef as A, useEffect as P, useMemo as T, useCallback as z } from "react";
|
|
4
|
+
const fe = [], 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), ge = ({
|
|
8
|
+
tasks: m = fe,
|
|
9
|
+
columns: N,
|
|
10
|
+
scale: y = "day",
|
|
11
|
+
rowHeight: _ = 36,
|
|
12
|
+
dayWidth: q = 30,
|
|
13
|
+
onTaskClick: x,
|
|
14
|
+
onTaskUpdate: w,
|
|
15
|
+
showDependencies: G = !0,
|
|
16
|
+
dependencyStyle: V = "square",
|
|
17
|
+
draggable: M,
|
|
18
|
+
zoomControls: Z,
|
|
19
|
+
className: H,
|
|
20
|
+
style: k,
|
|
21
|
+
accessMode: U,
|
|
22
|
+
id: ee,
|
|
23
|
+
"data-testid": te
|
|
24
|
+
}) => {
|
|
25
|
+
const { t: ne } = J(), ae = ue(U, ee) === "hidden", { t: pe } = J(), [o, B] = K(q), [f, j] = K(null), S = N || [
|
|
26
|
+
{ field: "title", title: ne("gantt.task", "Task"), width: 200 }
|
|
27
|
+
], I = S.reduce((e, t) => e + (t.width || 120), 0), X = A(null), C = A(null), W = A(!1);
|
|
28
|
+
P(() => {
|
|
29
|
+
const e = X.current, t = C.current;
|
|
30
|
+
if (!e || !t)
|
|
31
|
+
return;
|
|
32
|
+
const a = (c, i) => () => {
|
|
33
|
+
W.current || (W.current = !0, i.scrollTop = c.scrollTop, requestAnimationFrame(() => {
|
|
34
|
+
W.current = !1;
|
|
35
|
+
}));
|
|
36
|
+
}, n = a(e, t), r = a(t, e);
|
|
37
|
+
return e.addEventListener("scroll", n, { passive: !0 }), t.addEventListener("scroll", r, { passive: !0 }), () => {
|
|
38
|
+
e.removeEventListener("scroll", n), t.removeEventListener("scroll", r);
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
const d = T(() => {
|
|
42
|
+
const e = (t) => m.filter((n) => (n.parentId ?? null) === t).flatMap((n) => [n, ...e(n.id)]);
|
|
43
|
+
return e(null);
|
|
44
|
+
}, [m]), u = T(() => {
|
|
45
|
+
if (d.length === 0)
|
|
46
|
+
return { start: /* @__PURE__ */ new Date(), end: /* @__PURE__ */ new Date(), days: 30 };
|
|
47
|
+
let e = new Date(d[0].start), t = new Date(d[0].end);
|
|
48
|
+
return d.forEach((a) => {
|
|
49
|
+
new Date(a.start) < e && (e = new Date(a.start)), new Date(a.end) > t && (t = new Date(a.end));
|
|
50
|
+
}), e = b(e, -2), t = b(t, 2), { start: e, end: t, days: E(e, t) };
|
|
51
|
+
}, [d]), O = u.days * o;
|
|
52
|
+
P(() => {
|
|
53
|
+
if (!f || !w)
|
|
54
|
+
return;
|
|
55
|
+
const e = (a) => {
|
|
56
|
+
const n = a.clientX - f.startX, r = Math.round(n / o);
|
|
57
|
+
if (r === 0)
|
|
58
|
+
return;
|
|
59
|
+
const c = m.find((i) => i.id === f.taskId);
|
|
60
|
+
if (c)
|
|
61
|
+
if (f.mode === "move")
|
|
62
|
+
w({
|
|
63
|
+
...c,
|
|
64
|
+
start: b(f.origStart, r),
|
|
65
|
+
end: b(f.origEnd, r)
|
|
66
|
+
});
|
|
67
|
+
else {
|
|
68
|
+
const i = b(f.origEnd, r);
|
|
69
|
+
i > f.origStart && w({ ...c, end: i });
|
|
70
|
+
}
|
|
71
|
+
}, t = () => j(null);
|
|
72
|
+
return document.addEventListener("mousemove", e), document.addEventListener("mouseup", t), () => {
|
|
73
|
+
document.removeEventListener("mousemove", e), document.removeEventListener("mouseup", t);
|
|
74
|
+
};
|
|
75
|
+
}, [f, o, m, w]);
|
|
76
|
+
const Q = z(
|
|
77
|
+
(e, t, a) => {
|
|
78
|
+
if (!M || !w)
|
|
79
|
+
return;
|
|
80
|
+
a.stopPropagation();
|
|
81
|
+
const n = m.find((r) => r.id === e);
|
|
82
|
+
n && j({
|
|
83
|
+
taskId: e,
|
|
84
|
+
mode: t,
|
|
85
|
+
startX: a.clientX,
|
|
86
|
+
origStart: new Date(n.start),
|
|
87
|
+
origEnd: new Date(n.end)
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
[M, m, w]
|
|
91
|
+
), re = z(() => B((e) => Math.min(100, e + 5)), []), se = z(() => B((e) => Math.max(8, e - 5)), []), ie = () => {
|
|
92
|
+
const e = [], t = [];
|
|
93
|
+
new Date(u.start);
|
|
94
|
+
const a = [
|
|
95
|
+
"Jan",
|
|
96
|
+
"Feb",
|
|
97
|
+
"Mar",
|
|
98
|
+
"Apr",
|
|
99
|
+
"May",
|
|
100
|
+
"Jun",
|
|
101
|
+
"Jul",
|
|
102
|
+
"Aug",
|
|
103
|
+
"Sep",
|
|
104
|
+
"Oct",
|
|
105
|
+
"Nov",
|
|
106
|
+
"Dec"
|
|
107
|
+
];
|
|
108
|
+
if (y === "day") {
|
|
109
|
+
let n = -1, r = 0;
|
|
110
|
+
for (let c = 0; c < u.days; c++) {
|
|
111
|
+
const i = b(u.start, c);
|
|
112
|
+
i.getMonth() !== n && (n >= 0 && e.push(
|
|
113
|
+
/* @__PURE__ */ l(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
className: "nice-gantt__header-cell",
|
|
117
|
+
style: { width: (c - r) * o },
|
|
118
|
+
children: [
|
|
119
|
+
a[n],
|
|
120
|
+
" ",
|
|
121
|
+
i.getFullYear()
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
`m${n}-${r}`
|
|
125
|
+
)
|
|
126
|
+
), n = i.getMonth(), r = c);
|
|
127
|
+
const h = i.getDay() === 0 || i.getDay() === 6;
|
|
128
|
+
t.push(
|
|
129
|
+
/* @__PURE__ */ s(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
className: `nice-gantt__header-cell nice-gantt__header-cell--sub ${h ? "nice-gantt__header-cell--weekend" : ""}`,
|
|
133
|
+
style: { width: o },
|
|
134
|
+
children: i.getDate()
|
|
135
|
+
},
|
|
136
|
+
c
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
n >= 0 && e.push(
|
|
141
|
+
/* @__PURE__ */ s(
|
|
142
|
+
"div",
|
|
143
|
+
{
|
|
144
|
+
className: "nice-gantt__header-cell",
|
|
145
|
+
style: { width: (u.days - r) * o },
|
|
146
|
+
children: a[n]
|
|
147
|
+
},
|
|
148
|
+
`m${n}-last`
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return /* @__PURE__ */ l("div", { className: "nice-gantt__chart-header", children: [
|
|
153
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__header-row", children: e }),
|
|
154
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__header-row", children: t })
|
|
155
|
+
] });
|
|
156
|
+
}, ce = (e, t) => {
|
|
157
|
+
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;
|
|
158
|
+
return /* @__PURE__ */ l(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
role: x ? "button" : void 0,
|
|
162
|
+
tabIndex: x ? 0 : void 0,
|
|
163
|
+
onKeyDown: x ? _e : void 0,
|
|
164
|
+
className: `nice-gantt__bar ${M ? "nice-gantt__bar--draggable" : ""}`,
|
|
165
|
+
title: `${e.title} (${Math.round(i)}%)`,
|
|
166
|
+
style: {
|
|
167
|
+
left: a,
|
|
168
|
+
top: r,
|
|
169
|
+
width: n,
|
|
170
|
+
height: c,
|
|
171
|
+
backgroundColor: e.color || "var(--nice-color-primary, #3b82f6)"
|
|
172
|
+
},
|
|
173
|
+
onClick: () => x?.(e),
|
|
174
|
+
onMouseDown: M ? (h) => Q(e.id, "move", h) : void 0,
|
|
175
|
+
children: [
|
|
176
|
+
i > 0 && /* @__PURE__ */ s("div", { className: "nice-gantt__bar-progress", style: { width: `${i}%` } }),
|
|
177
|
+
/* @__PURE__ */ s("span", { className: "nice-gantt__bar-label", children: e.title }),
|
|
178
|
+
M && /* @__PURE__ */ s(
|
|
179
|
+
"div",
|
|
180
|
+
{
|
|
181
|
+
className: "nice-gantt__bar-resize",
|
|
182
|
+
onMouseDown: (h) => Q(e.id, "resize", h)
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
e.id
|
|
188
|
+
);
|
|
189
|
+
}, oe = (e, t, a, n, r) => {
|
|
190
|
+
const h = e + 10, L = a - 14, R = (t + n) / 2, D = n >= t ? 1 : -1, Y = Math.abs(n - t) < 1, F = L <= h + 4, p = Y ? t : R, g = F ? Math.max(h, e + 10) : h, v = F ? Math.min(L, a - 10) : L;
|
|
191
|
+
if (Y || !r)
|
|
192
|
+
return [
|
|
193
|
+
`M ${e} ${t}`,
|
|
194
|
+
`L ${g} ${t}`,
|
|
195
|
+
`L ${g} ${p}`,
|
|
196
|
+
`L ${v} ${p}`,
|
|
197
|
+
`L ${v} ${n}`,
|
|
198
|
+
`L ${a} ${n}`
|
|
199
|
+
].join(" ");
|
|
200
|
+
const le = Math.max(0, v - g), he = Math.abs(n - t), me = Math.min(he / 2 || 10, le / 2 || 10), $ = Math.max(2, Math.min(10, me));
|
|
201
|
+
return [
|
|
202
|
+
`M ${e} ${t}`,
|
|
203
|
+
`L ${g - $} ${t}`,
|
|
204
|
+
`Q ${g} ${t} ${g} ${t + D * $}`,
|
|
205
|
+
`L ${g} ${p - D * $}`,
|
|
206
|
+
`Q ${g} ${p} ${g + $} ${p}`,
|
|
207
|
+
`L ${v - $} ${p}`,
|
|
208
|
+
`Q ${v} ${p} ${v} ${p + D * $}`,
|
|
209
|
+
`L ${v} ${n - D * $}`,
|
|
210
|
+
`Q ${v} ${n} ${v + $} ${n}`,
|
|
211
|
+
`L ${a} ${n}`
|
|
212
|
+
].join(" ");
|
|
213
|
+
}, de = () => {
|
|
214
|
+
if (!G)
|
|
215
|
+
return null;
|
|
216
|
+
const e = [], t = new Map(d.map((a, n) => [a.id, n]));
|
|
217
|
+
return d.forEach((a) => {
|
|
218
|
+
(a.dependencies || []).forEach((n) => {
|
|
219
|
+
const r = t.get(n), c = t.get(a.id);
|
|
220
|
+
if (r == null || c == null)
|
|
221
|
+
return;
|
|
222
|
+
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;
|
|
223
|
+
e.push(
|
|
224
|
+
/* @__PURE__ */ s(
|
|
225
|
+
"path",
|
|
226
|
+
{
|
|
227
|
+
d: oe(h, L, R, D, V === "rounded"),
|
|
228
|
+
fill: "none",
|
|
229
|
+
stroke: "var(--nice-text-secondary, #6b7280)",
|
|
230
|
+
strokeWidth: 1.5,
|
|
231
|
+
strokeLinejoin: "round",
|
|
232
|
+
strokeLinecap: "round",
|
|
233
|
+
markerEnd: "url(#arrowhead)"
|
|
234
|
+
},
|
|
235
|
+
`${n}-${a.id}`
|
|
236
|
+
)
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
}), /* @__PURE__ */ l(
|
|
240
|
+
"svg",
|
|
241
|
+
{
|
|
242
|
+
className: "nice-gantt__deps",
|
|
243
|
+
width: O,
|
|
244
|
+
height: d.length * _,
|
|
245
|
+
style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" },
|
|
246
|
+
children: [
|
|
247
|
+
/* @__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)" }) }) }),
|
|
248
|
+
e
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
};
|
|
253
|
+
return ae ? null : /* @__PURE__ */ l("div", { className: `nice-gantt ${H || ""}`, style: k, "data-testid": te, children: [
|
|
254
|
+
Z && /* @__PURE__ */ l("div", { className: "nice-gantt__zoom-controls", children: [
|
|
255
|
+
/* @__PURE__ */ s("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: se, children: "−" }),
|
|
256
|
+
/* @__PURE__ */ l("span", { className: "nice-gantt__zoom-label", children: [
|
|
257
|
+
o,
|
|
258
|
+
"px"
|
|
259
|
+
] }),
|
|
260
|
+
/* @__PURE__ */ s("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: re, children: "+" })
|
|
261
|
+
] }),
|
|
262
|
+
/* @__PURE__ */ l("div", { className: "nice-gantt__container", children: [
|
|
263
|
+
/* @__PURE__ */ l("div", { className: "nice-gantt__table", style: { width: I, minWidth: I }, children: [
|
|
264
|
+
/* @__PURE__ */ l("div", { className: "nice-gantt__table-header", children: [
|
|
265
|
+
/* @__PURE__ */ s(
|
|
266
|
+
"div",
|
|
267
|
+
{
|
|
268
|
+
className: "nice-gantt__table-header-row nice-gantt__table-header-row--main",
|
|
269
|
+
"aria-hidden": "true",
|
|
270
|
+
children: " "
|
|
271
|
+
}
|
|
272
|
+
),
|
|
273
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__table-header-row nice-gantt__table-header-row--sub", children: S.map((e, t) => /* @__PURE__ */ s(
|
|
274
|
+
"div",
|
|
275
|
+
{
|
|
276
|
+
className: "nice-gantt__table-header-cell",
|
|
277
|
+
style: { width: e.width || 120 },
|
|
278
|
+
children: e.title
|
|
279
|
+
},
|
|
280
|
+
t
|
|
281
|
+
)) })
|
|
282
|
+
] }),
|
|
283
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__table-body", ref: X, children: d.map((e, t) => /* @__PURE__ */ s("div", { className: "nice-gantt__table-row", style: { height: _ }, children: S.map((a, n) => /* @__PURE__ */ s(
|
|
284
|
+
"div",
|
|
285
|
+
{
|
|
286
|
+
className: "nice-gantt__table-cell",
|
|
287
|
+
style: { width: a.width || 120 },
|
|
288
|
+
children: e[a.field]
|
|
289
|
+
},
|
|
290
|
+
n
|
|
291
|
+
)) }, e.id)) })
|
|
292
|
+
] }),
|
|
293
|
+
/* @__PURE__ */ s("div", { className: "nice-gantt__chart", children: /* @__PURE__ */ l("div", { className: "nice-gantt__chart-body-wrap", ref: C, children: [
|
|
294
|
+
ie(),
|
|
295
|
+
/* @__PURE__ */ l(
|
|
296
|
+
"div",
|
|
297
|
+
{
|
|
298
|
+
className: "nice-gantt__chart-body",
|
|
299
|
+
style: {
|
|
300
|
+
width: O,
|
|
301
|
+
height: d.length * _,
|
|
302
|
+
position: "relative"
|
|
303
|
+
},
|
|
304
|
+
children: [
|
|
305
|
+
Array.from({ length: u.days }, (e, t) => {
|
|
306
|
+
const a = b(u.start, t), n = a.getDay() === 0 || a.getDay() === 6;
|
|
307
|
+
return /* @__PURE__ */ s(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
className: `nice-gantt__gridline ${n ? "nice-gantt__gridline--weekend" : ""}`,
|
|
311
|
+
style: {
|
|
312
|
+
left: t * o,
|
|
313
|
+
width: o,
|
|
314
|
+
height: "100%",
|
|
315
|
+
position: "absolute",
|
|
316
|
+
top: 0
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
t
|
|
320
|
+
);
|
|
321
|
+
}),
|
|
322
|
+
d.map((e, t) => ce(e, t)),
|
|
323
|
+
de()
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
)
|
|
327
|
+
] }) })
|
|
328
|
+
] })
|
|
329
|
+
] });
|
|
330
|
+
};
|
|
331
|
+
process.env.NODE_ENV !== "production" && (ge.displayName = "NiceGantt");
|
|
332
|
+
export {
|
|
333
|
+
ge as NiceGantt
|
|
334
|
+
};
|