@nice2dev/ui 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +476 -0
  2. package/dist/NiceButton-CnAIqCbd.js +101 -0
  3. package/dist/NiceButton-DzCqkG5a.cjs +1 -0
  4. package/dist/NiceCodeEditor-C43xFG8v.cjs +260 -0
  5. package/dist/NiceCodeEditor-CK6B54mu.js +1215 -0
  6. package/dist/NiceCodeEditor-CspuYLh6.js +1174 -0
  7. package/dist/NiceCodeEditor-bJReZPDO.cjs +268 -0
  8. package/dist/NiceColorPicker-BV3olE3M.cjs +1 -0
  9. package/dist/NiceColorPicker-CyY-4q89.js +552 -0
  10. package/dist/NiceDataGrid-BQIqitMM.cjs +10 -0
  11. package/dist/NiceDataGrid-C1eI6Pso.js +2267 -0
  12. package/dist/NiceDataGrid-CrD4HPlO.cjs +10 -0
  13. package/dist/NiceDataGrid-Dfg1DVbU.js +2224 -0
  14. package/dist/NiceForm-CISJyzoW.cjs +1 -0
  15. package/dist/NiceForm-CfAPcXdX.cjs +1 -0
  16. package/dist/NiceForm-DfKYNQti.js +5017 -0
  17. package/dist/NiceForm-DmH6k1b_.js +4775 -0
  18. package/dist/NiceGantt-CHnq-n8f.cjs +1 -0
  19. package/dist/NiceGantt-CX3jVNaF.js +330 -0
  20. package/dist/NiceGantt-TEXbAELi.js +333 -0
  21. package/dist/NiceGantt-s2cgt5zD.cjs +1 -0
  22. package/dist/NiceHtmlEditor-CDZeF_zG.cjs +10 -0
  23. package/dist/NiceHtmlEditor-CdWgddg3.js +901 -0
  24. package/dist/NiceHtmlEditor-DeK0Of98.js +883 -0
  25. package/dist/NiceHtmlEditor-DvVxl4Fu.cjs +10 -0
  26. package/dist/NiceLoginForm-CHXbz0eu.js +747 -0
  27. package/dist/NiceLoginForm-DRPldHXa.js +808 -0
  28. package/dist/NiceLoginForm-IGLUCQUE.cjs +1 -0
  29. package/dist/NiceLoginForm-ix6J1adA.cjs +1 -0
  30. package/dist/NiceMention-CgDp0sl9.cjs +430 -0
  31. package/dist/NiceMention-DBvFvx71.js +11653 -0
  32. package/dist/NiceMention-DKhk3xdM.js +11321 -0
  33. package/dist/NiceMention-wp1AJ5oh.cjs +430 -0
  34. package/dist/NiceMention.css +1 -1
  35. package/dist/NiceModal-BbQwiEOp.cjs +1 -0
  36. package/dist/NiceModal-BlYhFDhP.js +80 -0
  37. package/dist/NiceModal-DQEfTcnZ.js +85 -0
  38. package/dist/NiceModal-DmWz2PDM.cjs +1 -0
  39. package/dist/NiceModuleLifecyclePanel-22CEEVbA.cjs +1 -0
  40. package/dist/NiceModuleLifecyclePanel-BCd9Wv5Y.js +6825 -0
  41. package/dist/NiceModuleLifecyclePanel-D8EoXqBy.cjs +1 -0
  42. package/dist/NiceModuleLifecyclePanel-SN6G7t64.js +7189 -0
  43. package/dist/NiceModuleLifecyclePanel.css +1 -1
  44. package/dist/NicePagination-BFGt1v0a.js +165 -0
  45. package/dist/NicePagination-BJS65foT.js +200 -0
  46. package/dist/NicePagination-D_3GfWp5.cjs +1 -0
  47. package/dist/NicePagination-DltL3-Sz.cjs +1 -0
  48. package/dist/NicePivotGrid-BD87Na7P.js +1163 -0
  49. package/dist/NicePivotGrid-BPmnvbPQ.cjs +152 -0
  50. package/dist/NicePivotGrid-D_kRF1Dt.js +1180 -0
  51. package/dist/NicePivotGrid-DqluEkCI.cjs +152 -0
  52. package/dist/NiceSavedQueryPanel-BSTiZvFg.js +5130 -0
  53. package/dist/NiceSavedQueryPanel-C2Tn1cMW.js +5311 -0
  54. package/dist/NiceSavedQueryPanel-DDKtL1AA.cjs +586 -0
  55. package/dist/NiceSavedQueryPanel-DrR3sw4T.cjs +586 -0
  56. package/dist/NiceScheduler-DvxJ8N0I.js +1698 -0
  57. package/dist/NiceScheduler-GJLvkXJ3.cjs +5 -0
  58. package/dist/NiceScheduler-TIksdF0k.cjs +5 -0
  59. package/dist/NiceScheduler-UT49u2Vq.js +1710 -0
  60. package/dist/NiceSelect-CdUHd8rj.cjs +1 -0
  61. package/dist/NiceSelect-fOelG_QB.js +495 -0
  62. package/dist/NiceWindow-CqSsTjrS.cjs +1 -0
  63. package/dist/NiceWindow-DZLPhXbR.js +2223 -0
  64. package/dist/charts-BYQwl_GS.js +4789 -0
  65. package/dist/charts-BpELGDXh.cjs +768 -0
  66. package/dist/charts-C6iOu0H6.cjs +768 -0
  67. package/dist/charts-M6LuVI7F.js +4776 -0
  68. package/dist/charts.cjs +1 -1
  69. package/dist/charts.d.ts +1 -29
  70. package/dist/charts.mjs +1 -1
  71. package/dist/core-lazy-B_laOXNf.cjs +1 -0
  72. package/dist/core-lazy-Ctin_LwS.cjs +1 -0
  73. package/dist/core-lazy-VQEjdz0L.js +351 -0
  74. package/dist/core-lazy-iDiropM6.js +351 -0
  75. package/dist/data-branching-7rpktFJ-.cjs +1 -0
  76. package/dist/data-branching-BS0aFUMu.js +6428 -0
  77. package/dist/data-branching-BgIAw01q.cjs +1 -0
  78. package/dist/data-branching-bvB9K6KS.js +6386 -0
  79. package/dist/data-branching.cjs +1 -1
  80. package/dist/data-branching.mjs +1 -1
  81. package/dist/data.cjs +1 -1
  82. package/dist/data.mjs +3 -3
  83. package/dist/devops-Bp-_aA-9.js +8682 -0
  84. package/dist/devops-CFytAJQr.cjs +18 -0
  85. package/dist/devops-CW8YY_zA.js +9122 -0
  86. package/dist/devops-CXBSjnyX.cjs +17 -0
  87. package/dist/devops.cjs +1 -1
  88. package/dist/devops.css +1 -0
  89. package/dist/devops.mjs +5 -5
  90. package/dist/editors.cjs +1 -1
  91. package/dist/editors.mjs +8 -8
  92. package/dist/feedback.cjs +1 -1
  93. package/dist/feedback.d.ts +21 -16
  94. package/dist/feedback.mjs +3 -3
  95. package/dist/index.cjs +199 -194
  96. package/dist/index.css +1 -1
  97. package/dist/index.d.ts +378 -48
  98. package/dist/index.mjs +23248 -21783
  99. package/dist/lazy.cjs +1 -1
  100. package/dist/lazy.mjs +24 -24
  101. package/dist/navigation.cjs +1 -1
  102. package/dist/navigation.d.ts +31 -0
  103. package/dist/navigation.mjs +404 -354
  104. package/dist/no-code-BNFk_BDO.js +8275 -0
  105. package/dist/no-code-BaAI_sJR.js +8318 -0
  106. package/dist/no-code-CFdTp543.cjs +331 -0
  107. package/dist/no-code-oQTeAtnW.cjs +331 -0
  108. package/dist/no-code.cjs +1 -1
  109. package/dist/no-code.mjs +1 -1
  110. package/dist/overlays.cjs +1 -1
  111. package/dist/overlays.d.ts +5 -0
  112. package/dist/overlays.mjs +1 -1
  113. package/dist/pickerCommons-BQi6IEAt.js +661 -0
  114. package/dist/pickerCommons-CMxFt9SW.js +548 -0
  115. package/dist/pickerCommons-Dc_hlz-e.cjs +1 -0
  116. package/dist/pickerCommons-DvQptSPX.cjs +1 -0
  117. package/dist/style.css +7 -4
  118. package/package.json +4 -3
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),R=require("@nice2dev/ui-core"),l=require("react"),oe=[],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),O=({tasks:u=oe,columns:N,scale:j="day",rowHeight:_=36,dayWidth:P=30,onTaskClick:Q,onTaskUpdate:x,showDependencies:Y=!0,dependencyStyle:F="square",draggable:D,zoomControls:G,className:J,style:k,accessMode:K,id:V})=>{const{t:Z}=R.useNiceTranslation(),H=R.useNiceAccessMode(K,V)==="hidden",{t:le}=R.useNiceTranslation(),[o,C]=l.useState(P),[f,W]=l.useState(null),L=N||[{field:"title",title:Z("gantt.task","Task"),width:200}],T=L.reduce((e,t)=>e+(t.width||120),0),z=l.useRef(null),A=l.useRef(null),E=l.useRef(!1);l.useEffect(()=>{const e=z.current,t=A.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]),B=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 q=l.useCallback((e,t,s)=>{if(!D||!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)})},[D,u,x]),U=l.useCallback(()=>C(e=>Math.min(100,e+5)),[]),ee=l.useCallback(()=>C(e=>Math.max(8,e-5)),[]),te=()=>{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})]})},ne=(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 ${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:()=>Q?.(e),onMouseDown:D?h=>q(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=>q(e.id,"resize",h)})]},e.id)},se=(e,t,s,n,r)=>{const h=e+10,y=s-14,S=(t+n)/2,w=n>=t?1:-1,X=Math.abs(n-t)<1,I=y<=h+4,b=X?t:S,g=I?Math.max(h,e+10):h,v=I?Math.min(y,s-10):y;if(X||!r)return[`M ${e} ${t}`,`L ${g} ${t}`,`L ${g} ${b}`,`L ${v} ${b}`,`L ${v} ${n}`,`L ${s} ${n}`].join(" ");const re=Math.max(0,v-g),ie=Math.abs(n-t),ce=Math.min(ie/2||10,re/2||10),$=Math.max(2,Math.min(10,ce));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(" ")},ae=()=>{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,S=M(m.start,new Date(s.start))*o,w=c*_+_/2;e.push(a.jsx("path",{d:se(h,y,S,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:B,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 H?null:a.jsxs("div",{className:`nice-gantt ${J||""}`,style:k,children:[G&&a.jsxs("div",{className:"nice-gantt__zoom-controls",children:[a.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:ee,children:"−"}),a.jsxs("span",{className:"nice-gantt__zoom-label",children:[o,"px"]}),a.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:U,children:"+"})]}),a.jsxs("div",{className:"nice-gantt__container",children:[a.jsxs("div",{className:"nice-gantt__table",style:{width:T,minWidth:T},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:A,children:[te(),a.jsxs("div",{className:"nice-gantt__chart-body",style:{width:B,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)=>ne(e,t)),ae()]})]})})]})]})};process.env.NODE_ENV!=="production"&&(O.displayName="NiceGantt");exports.NiceGantt=O;
@@ -0,0 +1,330 @@
1
+ import { jsxs as l, jsx as s } from "react/jsx-runtime";
2
+ import { useNiceTranslation as F, useNiceAccessMode as me } from "@nice2dev/ui-core";
3
+ import { useState as J, useRef as R, useEffect as O, useMemo as P, useCallback as z } from "react";
4
+ const ue = [], b = (m, D) => {
5
+ const y = new Date(m);
6
+ return y.setDate(y.getDate() + D), y;
7
+ }, E = (m, D) => Math.ceil((D.getTime() - m.getTime()) / 864e5), _e = ({
8
+ tasks: m = ue,
9
+ columns: D,
10
+ scale: y = "day",
11
+ rowHeight: _ = 36,
12
+ dayWidth: q = 30,
13
+ onTaskClick: G,
14
+ onTaskUpdate: w,
15
+ showDependencies: K = !0,
16
+ dependencyStyle: V = "square",
17
+ draggable: M,
18
+ zoomControls: k,
19
+ className: Z,
20
+ style: H,
21
+ accessMode: U,
22
+ id: ee
23
+ }) => {
24
+ const { t: te } = F(), ne = me(U, ee) === "hidden", { t: ge } = F(), [o, A] = J(q), [f, C] = J(null), x = D || [
25
+ { field: "title", title: te("gantt.task", "Task"), width: 200 }
26
+ ], B = x.reduce((e, t) => e + (t.width || 120), 0), T = R(null), j = R(null), S = R(!1);
27
+ O(() => {
28
+ const e = T.current, t = j.current;
29
+ if (!e || !t)
30
+ return;
31
+ const a = (c, i) => () => {
32
+ S.current || (S.current = !0, i.scrollTop = c.scrollTop, requestAnimationFrame(() => {
33
+ S.current = !1;
34
+ }));
35
+ }, n = a(e, t), r = a(t, e);
36
+ return e.addEventListener("scroll", n, { passive: !0 }), t.addEventListener("scroll", r, { passive: !0 }), () => {
37
+ e.removeEventListener("scroll", n), t.removeEventListener("scroll", r);
38
+ };
39
+ }, []);
40
+ const d = P(() => {
41
+ const e = (t) => m.filter((n) => (n.parentId ?? null) === t).flatMap((n) => [n, ...e(n.id)]);
42
+ return e(null);
43
+ }, [m]), u = P(() => {
44
+ if (d.length === 0)
45
+ return { start: /* @__PURE__ */ new Date(), end: /* @__PURE__ */ new Date(), days: 30 };
46
+ let e = new Date(d[0].start), t = new Date(d[0].end);
47
+ return d.forEach((a) => {
48
+ new Date(a.start) < e && (e = new Date(a.start)), new Date(a.end) > t && (t = new Date(a.end));
49
+ }), e = b(e, -2), t = b(t, 2), { start: e, end: t, days: E(e, t) };
50
+ }, [d]), X = u.days * o;
51
+ O(() => {
52
+ if (!f || !w)
53
+ return;
54
+ const e = (a) => {
55
+ const n = a.clientX - f.startX, r = Math.round(n / o);
56
+ if (r === 0)
57
+ return;
58
+ const c = m.find((i) => i.id === f.taskId);
59
+ if (c)
60
+ if (f.mode === "move")
61
+ w({
62
+ ...c,
63
+ start: b(f.origStart, r),
64
+ end: b(f.origEnd, r)
65
+ });
66
+ else {
67
+ const i = b(f.origEnd, r);
68
+ i > f.origStart && w({ ...c, end: i });
69
+ }
70
+ }, t = () => C(null);
71
+ return document.addEventListener("mousemove", e), document.addEventListener("mouseup", t), () => {
72
+ document.removeEventListener("mousemove", e), document.removeEventListener("mouseup", t);
73
+ };
74
+ }, [f, o, m, w]);
75
+ const I = z(
76
+ (e, t, a) => {
77
+ if (!M || !w)
78
+ return;
79
+ a.stopPropagation();
80
+ const n = m.find((r) => r.id === e);
81
+ n && C({
82
+ taskId: e,
83
+ mode: t,
84
+ startX: a.clientX,
85
+ origStart: new Date(n.start),
86
+ origEnd: new Date(n.end)
87
+ });
88
+ },
89
+ [M, m, w]
90
+ ), ae = z(() => A((e) => Math.min(100, e + 5)), []), re = z(() => A((e) => Math.max(8, e - 5)), []), se = () => {
91
+ const e = [], t = [];
92
+ new Date(u.start);
93
+ const a = [
94
+ "Jan",
95
+ "Feb",
96
+ "Mar",
97
+ "Apr",
98
+ "May",
99
+ "Jun",
100
+ "Jul",
101
+ "Aug",
102
+ "Sep",
103
+ "Oct",
104
+ "Nov",
105
+ "Dec"
106
+ ];
107
+ if (y === "day") {
108
+ let n = -1, r = 0;
109
+ for (let c = 0; c < u.days; c++) {
110
+ const i = b(u.start, c);
111
+ i.getMonth() !== n && (n >= 0 && e.push(
112
+ /* @__PURE__ */ l(
113
+ "div",
114
+ {
115
+ className: "nice-gantt__header-cell",
116
+ style: { width: (c - r) * o },
117
+ children: [
118
+ a[n],
119
+ " ",
120
+ i.getFullYear()
121
+ ]
122
+ },
123
+ `m${n}-${r}`
124
+ )
125
+ ), n = i.getMonth(), r = c);
126
+ const h = i.getDay() === 0 || i.getDay() === 6;
127
+ t.push(
128
+ /* @__PURE__ */ s(
129
+ "div",
130
+ {
131
+ className: `nice-gantt__header-cell nice-gantt__header-cell--sub ${h ? "nice-gantt__header-cell--weekend" : ""}`,
132
+ style: { width: o },
133
+ children: i.getDate()
134
+ },
135
+ c
136
+ )
137
+ );
138
+ }
139
+ n >= 0 && e.push(
140
+ /* @__PURE__ */ s(
141
+ "div",
142
+ {
143
+ className: "nice-gantt__header-cell",
144
+ style: { width: (u.days - r) * o },
145
+ children: a[n]
146
+ },
147
+ `m${n}-last`
148
+ )
149
+ );
150
+ }
151
+ return /* @__PURE__ */ l("div", { className: "nice-gantt__chart-header", children: [
152
+ /* @__PURE__ */ s("div", { className: "nice-gantt__header-row", children: e }),
153
+ /* @__PURE__ */ s("div", { className: "nice-gantt__header-row", children: t })
154
+ ] });
155
+ }, ie = (e, t) => {
156
+ 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;
157
+ return /* @__PURE__ */ l(
158
+ "div",
159
+ {
160
+ className: `nice-gantt__bar ${M ? "nice-gantt__bar--draggable" : ""}`,
161
+ title: `${e.title} (${Math.round(i)}%)`,
162
+ style: {
163
+ left: a,
164
+ top: r,
165
+ width: n,
166
+ height: c,
167
+ backgroundColor: e.color || "var(--nice-color-primary, #3b82f6)"
168
+ },
169
+ onClick: () => G?.(e),
170
+ onMouseDown: M ? (h) => I(e.id, "move", h) : void 0,
171
+ children: [
172
+ i > 0 && /* @__PURE__ */ s("div", { className: "nice-gantt__bar-progress", style: { width: `${i}%` } }),
173
+ /* @__PURE__ */ s("span", { className: "nice-gantt__bar-label", children: e.title }),
174
+ M && /* @__PURE__ */ s(
175
+ "div",
176
+ {
177
+ className: "nice-gantt__bar-resize",
178
+ onMouseDown: (h) => I(e.id, "resize", h)
179
+ }
180
+ )
181
+ ]
182
+ },
183
+ e.id
184
+ );
185
+ }, ce = (e, t, a, n, r) => {
186
+ const h = e + 10, L = a - 14, W = (t + n) / 2, N = n >= t ? 1 : -1, Q = Math.abs(n - t) < 1, Y = L <= h + 4, p = Q ? t : W, g = Y ? Math.max(h, e + 10) : h, v = Y ? Math.min(L, a - 10) : L;
187
+ if (Q || !r)
188
+ return [
189
+ `M ${e} ${t}`,
190
+ `L ${g} ${t}`,
191
+ `L ${g} ${p}`,
192
+ `L ${v} ${p}`,
193
+ `L ${v} ${n}`,
194
+ `L ${a} ${n}`
195
+ ].join(" ");
196
+ const de = Math.max(0, v - g), le = Math.abs(n - t), he = Math.min(le / 2 || 10, de / 2 || 10), $ = Math.max(2, Math.min(10, he));
197
+ return [
198
+ `M ${e} ${t}`,
199
+ `L ${g - $} ${t}`,
200
+ `Q ${g} ${t} ${g} ${t + N * $}`,
201
+ `L ${g} ${p - N * $}`,
202
+ `Q ${g} ${p} ${g + $} ${p}`,
203
+ `L ${v - $} ${p}`,
204
+ `Q ${v} ${p} ${v} ${p + N * $}`,
205
+ `L ${v} ${n - N * $}`,
206
+ `Q ${v} ${n} ${v + $} ${n}`,
207
+ `L ${a} ${n}`
208
+ ].join(" ");
209
+ }, oe = () => {
210
+ if (!K)
211
+ return null;
212
+ const e = [], t = new Map(d.map((a, n) => [a.id, n]));
213
+ return d.forEach((a) => {
214
+ (a.dependencies || []).forEach((n) => {
215
+ const r = t.get(n), c = t.get(a.id);
216
+ if (r == null || c == null)
217
+ return;
218
+ const i = d[r], h = E(u.start, new Date(i.end)) * o, L = r * _ + _ / 2, W = E(u.start, new Date(a.start)) * o, N = c * _ + _ / 2;
219
+ e.push(
220
+ /* @__PURE__ */ s(
221
+ "path",
222
+ {
223
+ d: ce(h, L, W, N, V === "rounded"),
224
+ fill: "none",
225
+ stroke: "var(--nice-text-secondary, #6b7280)",
226
+ strokeWidth: 1.5,
227
+ strokeLinejoin: "round",
228
+ strokeLinecap: "round",
229
+ markerEnd: "url(#arrowhead)"
230
+ },
231
+ `${n}-${a.id}`
232
+ )
233
+ );
234
+ });
235
+ }), /* @__PURE__ */ l(
236
+ "svg",
237
+ {
238
+ className: "nice-gantt__deps",
239
+ width: X,
240
+ height: d.length * _,
241
+ style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" },
242
+ children: [
243
+ /* @__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)" }) }) }),
244
+ e
245
+ ]
246
+ }
247
+ );
248
+ };
249
+ return ne ? null : /* @__PURE__ */ l("div", { className: `nice-gantt ${Z || ""}`, style: H, children: [
250
+ k && /* @__PURE__ */ l("div", { className: "nice-gantt__zoom-controls", children: [
251
+ /* @__PURE__ */ s("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: re, children: "−" }),
252
+ /* @__PURE__ */ l("span", { className: "nice-gantt__zoom-label", children: [
253
+ o,
254
+ "px"
255
+ ] }),
256
+ /* @__PURE__ */ s("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: ae, children: "+" })
257
+ ] }),
258
+ /* @__PURE__ */ l("div", { className: "nice-gantt__container", children: [
259
+ /* @__PURE__ */ l("div", { className: "nice-gantt__table", style: { width: B, minWidth: B }, children: [
260
+ /* @__PURE__ */ l("div", { className: "nice-gantt__table-header", children: [
261
+ /* @__PURE__ */ s(
262
+ "div",
263
+ {
264
+ className: "nice-gantt__table-header-row nice-gantt__table-header-row--main",
265
+ "aria-hidden": "true",
266
+ children: " "
267
+ }
268
+ ),
269
+ /* @__PURE__ */ s("div", { className: "nice-gantt__table-header-row nice-gantt__table-header-row--sub", children: x.map((e, t) => /* @__PURE__ */ s(
270
+ "div",
271
+ {
272
+ className: "nice-gantt__table-header-cell",
273
+ style: { width: e.width || 120 },
274
+ children: e.title
275
+ },
276
+ t
277
+ )) })
278
+ ] }),
279
+ /* @__PURE__ */ s("div", { className: "nice-gantt__table-body", ref: T, children: d.map((e, t) => /* @__PURE__ */ s("div", { className: "nice-gantt__table-row", style: { height: _ }, children: x.map((a, n) => /* @__PURE__ */ s(
280
+ "div",
281
+ {
282
+ className: "nice-gantt__table-cell",
283
+ style: { width: a.width || 120 },
284
+ children: e[a.field]
285
+ },
286
+ n
287
+ )) }, e.id)) })
288
+ ] }),
289
+ /* @__PURE__ */ s("div", { className: "nice-gantt__chart", children: /* @__PURE__ */ l("div", { className: "nice-gantt__chart-body-wrap", ref: j, children: [
290
+ se(),
291
+ /* @__PURE__ */ l(
292
+ "div",
293
+ {
294
+ className: "nice-gantt__chart-body",
295
+ style: {
296
+ width: X,
297
+ height: d.length * _,
298
+ position: "relative"
299
+ },
300
+ children: [
301
+ Array.from({ length: u.days }, (e, t) => {
302
+ const a = b(u.start, t), n = a.getDay() === 0 || a.getDay() === 6;
303
+ return /* @__PURE__ */ s(
304
+ "div",
305
+ {
306
+ className: `nice-gantt__gridline ${n ? "nice-gantt__gridline--weekend" : ""}`,
307
+ style: {
308
+ left: t * o,
309
+ width: o,
310
+ height: "100%",
311
+ position: "absolute",
312
+ top: 0
313
+ }
314
+ },
315
+ t
316
+ );
317
+ }),
318
+ d.map((e, t) => ie(e, t)),
319
+ oe()
320
+ ]
321
+ }
322
+ )
323
+ ] }) })
324
+ ] })
325
+ ] });
326
+ };
327
+ process.env.NODE_ENV !== "production" && (_e.displayName = "NiceGantt");
328
+ export {
329
+ _e as NiceGantt
330
+ };
@@ -0,0 +1,333 @@
1
+ import { jsxs as l, jsx as s } from "react/jsx-runtime";
2
+ import { useNiceTranslation as J, useNiceAccessMode as me, clickOnActivationKey as ue } 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 _e = [], 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), fe = ({
8
+ tasks: m = _e,
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
+ }) => {
24
+ const { t: te } = J(), ne = me(U, ee) === "hidden", { t: ve } = J(), [o, B] = K(q), [f, j] = K(null), S = N || [
25
+ { field: "title", title: te("gantt.task", "Task"), width: 200 }
26
+ ], I = S.reduce((e, t) => e + (t.width || 120), 0), X = A(null), C = A(null), W = A(!1);
27
+ P(() => {
28
+ const e = X.current, t = C.current;
29
+ if (!e || !t)
30
+ return;
31
+ const a = (c, i) => () => {
32
+ W.current || (W.current = !0, i.scrollTop = c.scrollTop, requestAnimationFrame(() => {
33
+ W.current = !1;
34
+ }));
35
+ }, n = a(e, t), r = a(t, e);
36
+ return e.addEventListener("scroll", n, { passive: !0 }), t.addEventListener("scroll", r, { passive: !0 }), () => {
37
+ e.removeEventListener("scroll", n), t.removeEventListener("scroll", r);
38
+ };
39
+ }, []);
40
+ const d = T(() => {
41
+ const e = (t) => m.filter((n) => (n.parentId ?? null) === t).flatMap((n) => [n, ...e(n.id)]);
42
+ return e(null);
43
+ }, [m]), u = T(() => {
44
+ if (d.length === 0)
45
+ return { start: /* @__PURE__ */ new Date(), end: /* @__PURE__ */ new Date(), days: 30 };
46
+ let e = new Date(d[0].start), t = new Date(d[0].end);
47
+ return d.forEach((a) => {
48
+ new Date(a.start) < e && (e = new Date(a.start)), new Date(a.end) > t && (t = new Date(a.end));
49
+ }), e = b(e, -2), t = b(t, 2), { start: e, end: t, days: E(e, t) };
50
+ }, [d]), O = u.days * o;
51
+ P(() => {
52
+ if (!f || !w)
53
+ return;
54
+ const e = (a) => {
55
+ const n = a.clientX - f.startX, r = Math.round(n / o);
56
+ if (r === 0)
57
+ return;
58
+ const c = m.find((i) => i.id === f.taskId);
59
+ if (c)
60
+ if (f.mode === "move")
61
+ w({
62
+ ...c,
63
+ start: b(f.origStart, r),
64
+ end: b(f.origEnd, r)
65
+ });
66
+ else {
67
+ const i = b(f.origEnd, r);
68
+ i > f.origStart && w({ ...c, end: i });
69
+ }
70
+ }, t = () => j(null);
71
+ return document.addEventListener("mousemove", e), document.addEventListener("mouseup", t), () => {
72
+ document.removeEventListener("mousemove", e), document.removeEventListener("mouseup", t);
73
+ };
74
+ }, [f, o, m, w]);
75
+ const Q = z(
76
+ (e, t, a) => {
77
+ if (!M || !w)
78
+ return;
79
+ a.stopPropagation();
80
+ const n = m.find((r) => r.id === e);
81
+ n && j({
82
+ taskId: e,
83
+ mode: t,
84
+ startX: a.clientX,
85
+ origStart: new Date(n.start),
86
+ origEnd: new Date(n.end)
87
+ });
88
+ },
89
+ [M, m, w]
90
+ ), ae = z(() => B((e) => Math.min(100, e + 5)), []), re = z(() => B((e) => Math.max(8, e - 5)), []), se = () => {
91
+ const e = [], t = [];
92
+ new Date(u.start);
93
+ const a = [
94
+ "Jan",
95
+ "Feb",
96
+ "Mar",
97
+ "Apr",
98
+ "May",
99
+ "Jun",
100
+ "Jul",
101
+ "Aug",
102
+ "Sep",
103
+ "Oct",
104
+ "Nov",
105
+ "Dec"
106
+ ];
107
+ if (y === "day") {
108
+ let n = -1, r = 0;
109
+ for (let c = 0; c < u.days; c++) {
110
+ const i = b(u.start, c);
111
+ i.getMonth() !== n && (n >= 0 && e.push(
112
+ /* @__PURE__ */ l(
113
+ "div",
114
+ {
115
+ className: "nice-gantt__header-cell",
116
+ style: { width: (c - r) * o },
117
+ children: [
118
+ a[n],
119
+ " ",
120
+ i.getFullYear()
121
+ ]
122
+ },
123
+ `m${n}-${r}`
124
+ )
125
+ ), n = i.getMonth(), r = c);
126
+ const h = i.getDay() === 0 || i.getDay() === 6;
127
+ t.push(
128
+ /* @__PURE__ */ s(
129
+ "div",
130
+ {
131
+ className: `nice-gantt__header-cell nice-gantt__header-cell--sub ${h ? "nice-gantt__header-cell--weekend" : ""}`,
132
+ style: { width: o },
133
+ children: i.getDate()
134
+ },
135
+ c
136
+ )
137
+ );
138
+ }
139
+ n >= 0 && e.push(
140
+ /* @__PURE__ */ s(
141
+ "div",
142
+ {
143
+ className: "nice-gantt__header-cell",
144
+ style: { width: (u.days - r) * o },
145
+ children: a[n]
146
+ },
147
+ `m${n}-last`
148
+ )
149
+ );
150
+ }
151
+ return /* @__PURE__ */ l("div", { className: "nice-gantt__chart-header", children: [
152
+ /* @__PURE__ */ s("div", { className: "nice-gantt__header-row", children: e }),
153
+ /* @__PURE__ */ s("div", { className: "nice-gantt__header-row", children: t })
154
+ ] });
155
+ }, ie = (e, t) => {
156
+ 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;
157
+ return /* @__PURE__ */ l(
158
+ "div",
159
+ {
160
+ role: x ? "button" : void 0,
161
+ tabIndex: x ? 0 : void 0,
162
+ onKeyDown: x ? ue : void 0,
163
+ className: `nice-gantt__bar ${M ? "nice-gantt__bar--draggable" : ""}`,
164
+ title: `${e.title} (${Math.round(i)}%)`,
165
+ style: {
166
+ left: a,
167
+ top: r,
168
+ width: n,
169
+ height: c,
170
+ backgroundColor: e.color || "var(--nice-color-primary, #3b82f6)"
171
+ },
172
+ onClick: () => x?.(e),
173
+ onMouseDown: M ? (h) => Q(e.id, "move", h) : void 0,
174
+ children: [
175
+ i > 0 && /* @__PURE__ */ s("div", { className: "nice-gantt__bar-progress", style: { width: `${i}%` } }),
176
+ /* @__PURE__ */ s("span", { className: "nice-gantt__bar-label", children: e.title }),
177
+ M && /* @__PURE__ */ s(
178
+ "div",
179
+ {
180
+ className: "nice-gantt__bar-resize",
181
+ onMouseDown: (h) => Q(e.id, "resize", h)
182
+ }
183
+ )
184
+ ]
185
+ },
186
+ e.id
187
+ );
188
+ }, ce = (e, t, a, n, r) => {
189
+ 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;
190
+ if (Y || !r)
191
+ return [
192
+ `M ${e} ${t}`,
193
+ `L ${g} ${t}`,
194
+ `L ${g} ${p}`,
195
+ `L ${v} ${p}`,
196
+ `L ${v} ${n}`,
197
+ `L ${a} ${n}`
198
+ ].join(" ");
199
+ const de = Math.max(0, v - g), le = Math.abs(n - t), he = Math.min(le / 2 || 10, de / 2 || 10), $ = Math.max(2, Math.min(10, he));
200
+ return [
201
+ `M ${e} ${t}`,
202
+ `L ${g - $} ${t}`,
203
+ `Q ${g} ${t} ${g} ${t + D * $}`,
204
+ `L ${g} ${p - D * $}`,
205
+ `Q ${g} ${p} ${g + $} ${p}`,
206
+ `L ${v - $} ${p}`,
207
+ `Q ${v} ${p} ${v} ${p + D * $}`,
208
+ `L ${v} ${n - D * $}`,
209
+ `Q ${v} ${n} ${v + $} ${n}`,
210
+ `L ${a} ${n}`
211
+ ].join(" ");
212
+ }, oe = () => {
213
+ if (!G)
214
+ return null;
215
+ const e = [], t = new Map(d.map((a, n) => [a.id, n]));
216
+ return d.forEach((a) => {
217
+ (a.dependencies || []).forEach((n) => {
218
+ const r = t.get(n), c = t.get(a.id);
219
+ if (r == null || c == null)
220
+ return;
221
+ 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;
222
+ e.push(
223
+ /* @__PURE__ */ s(
224
+ "path",
225
+ {
226
+ d: ce(h, L, R, D, V === "rounded"),
227
+ fill: "none",
228
+ stroke: "var(--nice-text-secondary, #6b7280)",
229
+ strokeWidth: 1.5,
230
+ strokeLinejoin: "round",
231
+ strokeLinecap: "round",
232
+ markerEnd: "url(#arrowhead)"
233
+ },
234
+ `${n}-${a.id}`
235
+ )
236
+ );
237
+ });
238
+ }), /* @__PURE__ */ l(
239
+ "svg",
240
+ {
241
+ className: "nice-gantt__deps",
242
+ width: O,
243
+ height: d.length * _,
244
+ style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" },
245
+ children: [
246
+ /* @__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)" }) }) }),
247
+ e
248
+ ]
249
+ }
250
+ );
251
+ };
252
+ return ne ? null : /* @__PURE__ */ l("div", { className: `nice-gantt ${H || ""}`, style: k, children: [
253
+ Z && /* @__PURE__ */ l("div", { className: "nice-gantt__zoom-controls", children: [
254
+ /* @__PURE__ */ s("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: re, children: "−" }),
255
+ /* @__PURE__ */ l("span", { className: "nice-gantt__zoom-label", children: [
256
+ o,
257
+ "px"
258
+ ] }),
259
+ /* @__PURE__ */ s("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: ae, children: "+" })
260
+ ] }),
261
+ /* @__PURE__ */ l("div", { className: "nice-gantt__container", children: [
262
+ /* @__PURE__ */ l("div", { className: "nice-gantt__table", style: { width: I, minWidth: I }, children: [
263
+ /* @__PURE__ */ l("div", { className: "nice-gantt__table-header", children: [
264
+ /* @__PURE__ */ s(
265
+ "div",
266
+ {
267
+ className: "nice-gantt__table-header-row nice-gantt__table-header-row--main",
268
+ "aria-hidden": "true",
269
+ children: " "
270
+ }
271
+ ),
272
+ /* @__PURE__ */ s("div", { className: "nice-gantt__table-header-row nice-gantt__table-header-row--sub", children: S.map((e, t) => /* @__PURE__ */ s(
273
+ "div",
274
+ {
275
+ className: "nice-gantt__table-header-cell",
276
+ style: { width: e.width || 120 },
277
+ children: e.title
278
+ },
279
+ t
280
+ )) })
281
+ ] }),
282
+ /* @__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(
283
+ "div",
284
+ {
285
+ className: "nice-gantt__table-cell",
286
+ style: { width: a.width || 120 },
287
+ children: e[a.field]
288
+ },
289
+ n
290
+ )) }, e.id)) })
291
+ ] }),
292
+ /* @__PURE__ */ s("div", { className: "nice-gantt__chart", children: /* @__PURE__ */ l("div", { className: "nice-gantt__chart-body-wrap", ref: C, children: [
293
+ se(),
294
+ /* @__PURE__ */ l(
295
+ "div",
296
+ {
297
+ className: "nice-gantt__chart-body",
298
+ style: {
299
+ width: O,
300
+ height: d.length * _,
301
+ position: "relative"
302
+ },
303
+ children: [
304
+ Array.from({ length: u.days }, (e, t) => {
305
+ const a = b(u.start, t), n = a.getDay() === 0 || a.getDay() === 6;
306
+ return /* @__PURE__ */ s(
307
+ "div",
308
+ {
309
+ className: `nice-gantt__gridline ${n ? "nice-gantt__gridline--weekend" : ""}`,
310
+ style: {
311
+ left: t * o,
312
+ width: o,
313
+ height: "100%",
314
+ position: "absolute",
315
+ top: 0
316
+ }
317
+ },
318
+ t
319
+ );
320
+ }),
321
+ d.map((e, t) => ie(e, t)),
322
+ oe()
323
+ ]
324
+ }
325
+ )
326
+ ] }) })
327
+ ] })
328
+ ] });
329
+ };
330
+ process.env.NODE_ENV !== "production" && (fe.displayName = "NiceGantt");
331
+ export {
332
+ fe as NiceGantt
333
+ };