@thebuoyant-tsdev/mui-ts-library 3.2.1 → 3.4.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.
- package/README.de.md +15 -0
- package/README.md +15 -0
- package/dist/components/chord-chart/ChordChart.js +284 -0
- package/dist/components/chord-chart/ChordChart.types.js +4 -0
- package/dist/components/circle-packing-chart/CirclePackingChart.js +382 -0
- package/dist/components/circle-packing-chart/CirclePackingChart.types.js +4 -0
- package/dist/components/gantt-chart/GanttBarRow.js +202 -0
- package/dist/components/gantt-chart/GanttChart.constants.js +14 -0
- package/dist/components/gantt-chart/GanttChart.js +258 -0
- package/dist/components/gantt-chart/GanttChart.store.js +119 -0
- package/dist/components/gantt-chart/GanttChart.types.js +47 -0
- package/dist/components/gantt-chart/GanttDeleteDialog.js +30 -0
- package/dist/components/gantt-chart/GanttDependencyArrows.js +54 -0
- package/dist/components/gantt-chart/GanttStatusContextMenu.js +36 -0
- package/dist/components/gantt-chart/GanttTaskDialog.js +324 -0
- package/dist/components/gantt-chart/GanttTaskPanel.js +415 -0
- package/dist/components/gantt-chart/GanttTimeline.js +223 -0
- package/dist/components/gantt-chart/GanttTimelineHeader.js +90 -0
- package/dist/components/gantt-chart/GanttToolbar.js +157 -0
- package/dist/components/gantt-chart/GanttWeekendStrips.js +29 -0
- package/dist/components/gantt-chart/hooks/useGanttDrag.js +104 -0
- package/dist/components/gantt-chart/util/gantt-chart.util.js +150 -0
- package/dist/components/horizontal-tree-chart/HorizontalTreeChart.js +488 -0
- package/dist/components/horizontal-tree-chart/HorizontalTreeChart.types.js +8 -0
- package/dist/components/json-editor/JsonEditor.js +102 -0
- package/dist/components/json-editor/JsonEditor.types.js +21 -0
- package/dist/components/json-editor/JsonEditorContent.js +185 -0
- package/dist/components/json-editor/JsonEditorFooter.js +55 -0
- package/dist/components/json-editor/JsonEditorToolbar.js +148 -0
- package/dist/components/password-strength-meter/PasswordStrengthBar.js +66 -0
- package/dist/components/password-strength-meter/PasswordStrengthMeter.js +272 -0
- package/dist/components/password-strength-meter/PasswordStrengthMeter.types.js +27 -0
- package/dist/components/password-strength-meter/util/password-strength.util.js +38 -0
- package/dist/components/radial-tree-chart/RadialTreeChart.js +447 -0
- package/dist/components/radial-tree-chart/RadialTreeChart.types.js +8 -0
- package/dist/components/rich-text-editor/RichTextEditor.js +135 -0
- package/dist/components/rich-text-editor/RichTextEditor.types.js +74 -0
- package/dist/components/rich-text-editor/RichTextEditorColorPicker.js +185 -0
- package/dist/components/rich-text-editor/RichTextEditorContent.js +129 -0
- package/dist/components/rich-text-editor/RichTextEditorEmojiPicker.js +110 -0
- package/dist/components/rich-text-editor/RichTextEditorFooter.js +33 -0
- package/dist/components/rich-text-editor/RichTextEditorImageDialog.js +74 -0
- package/dist/components/rich-text-editor/RichTextEditorLinkDialog.js +70 -0
- package/dist/components/rich-text-editor/RichTextEditorTableMenu.js +97 -0
- package/dist/components/rich-text-editor/RichTextEditorToolbar.js +362 -0
- package/dist/components/rich-text-editor/util/emojis.js +739 -0
- package/dist/components/shared/ToolbarButton.js +22 -0
- package/dist/components/shared/normalizeSize.js +6 -0
- package/dist/components/sql-editor/SqlEditor.js +100 -0
- package/dist/components/sql-editor/SqlEditor.types.js +20 -0
- package/dist/components/sql-editor/SqlEditorContent.js +248 -0
- package/dist/components/sql-editor/SqlEditorFooter.js +45 -0
- package/dist/components/sql-editor/SqlEditorToolbar.js +151 -0
- package/dist/components/sunburst-chart/SunburstChart.js +292 -0
- package/dist/components/sunburst-chart/SunburstChart.types.js +4 -0
- package/dist/components/tag-selection/TagSelection.js +102 -0
- package/dist/components/tag-selection/TagSelection.store.js +40 -0
- package/dist/components/tag-selection/TagSelection.types.d.ts +2 -0
- package/dist/components/tag-selection/TagSelection.types.js +18 -0
- package/dist/components/tag-selection/TagSelectionAutocomplete.js +382 -0
- package/dist/components/tag-selection/TagSelectionChip.js +30 -0
- package/dist/components/tag-selection/TagSelectionSelectedTags.js +73 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +23 -8035
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Box as e, Chip as t, Tooltip as n, Typography as r, useTheme as i } from "@mui/material";
|
|
2
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/gantt-chart/GanttTimelineHeader.tsx
|
|
4
|
+
function s({ items: t }) {
|
|
5
|
+
return /* @__PURE__ */ a(e, {
|
|
6
|
+
sx: { display: "flex" },
|
|
7
|
+
children: t.map((t) => /* @__PURE__ */ a(e, {
|
|
8
|
+
sx: {
|
|
9
|
+
width: t.width,
|
|
10
|
+
flexShrink: 0,
|
|
11
|
+
height: 40,
|
|
12
|
+
display: "flex",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
borderRight: "1px solid",
|
|
16
|
+
borderColor: "divider",
|
|
17
|
+
bgcolor: t.isWeekend ? "action.hover" : "transparent"
|
|
18
|
+
},
|
|
19
|
+
children: /* @__PURE__ */ a(r, {
|
|
20
|
+
variant: "caption",
|
|
21
|
+
color: t.isWeekend ? "text.disabled" : "text.secondary",
|
|
22
|
+
children: t.label
|
|
23
|
+
})
|
|
24
|
+
}, t.key))
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function c({ columns: r, groups: c, todayX: l, todayLabel: u, todayTooltip: d, todayColor: f }) {
|
|
28
|
+
let p = i(), m = c ? 80 : 40, h = f || p.palette.primary.main, g = p.palette.getContrastText(h);
|
|
29
|
+
return /* @__PURE__ */ o(e, {
|
|
30
|
+
sx: {
|
|
31
|
+
position: "sticky",
|
|
32
|
+
top: 0,
|
|
33
|
+
bgcolor: "background.paper",
|
|
34
|
+
zIndex: 1,
|
|
35
|
+
borderBottom: "1px solid",
|
|
36
|
+
borderColor: "divider",
|
|
37
|
+
height: m,
|
|
38
|
+
overflow: "visible"
|
|
39
|
+
},
|
|
40
|
+
children: [
|
|
41
|
+
c && /* @__PURE__ */ a(e, {
|
|
42
|
+
sx: {
|
|
43
|
+
height: 40,
|
|
44
|
+
borderBottom: "1px solid",
|
|
45
|
+
borderColor: "divider",
|
|
46
|
+
overflow: "visible"
|
|
47
|
+
},
|
|
48
|
+
children: /* @__PURE__ */ a(s, { items: c })
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ a(s, { items: r }),
|
|
51
|
+
l != null && u && /* @__PURE__ */ a(n, {
|
|
52
|
+
title: d ?? "",
|
|
53
|
+
placement: "top",
|
|
54
|
+
arrow: !0,
|
|
55
|
+
children: /* @__PURE__ */ a(t, {
|
|
56
|
+
"data-testid": "gantt-today-chip",
|
|
57
|
+
size: "small",
|
|
58
|
+
label: u,
|
|
59
|
+
sx: {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
bottom: 0,
|
|
62
|
+
left: l,
|
|
63
|
+
transform: "translateX(-50%) translateY(50%)",
|
|
64
|
+
zIndex: 3,
|
|
65
|
+
height: 20,
|
|
66
|
+
fontSize: "0.65rem",
|
|
67
|
+
fontWeight: 700,
|
|
68
|
+
letterSpacing: "0.03em",
|
|
69
|
+
backgroundColor: h,
|
|
70
|
+
color: g,
|
|
71
|
+
border: `1.5px solid ${h}`,
|
|
72
|
+
boxShadow: p.shadows[2],
|
|
73
|
+
cursor: "default",
|
|
74
|
+
userSelect: "none",
|
|
75
|
+
"& .MuiChip-label": {
|
|
76
|
+
px: "6px",
|
|
77
|
+
py: 0
|
|
78
|
+
},
|
|
79
|
+
"&:hover": {
|
|
80
|
+
backgroundColor: h,
|
|
81
|
+
opacity: .9
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { c as GanttTimelineHeader };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { useGanttChartStore as e, useGanttTranslations as t } from "./GanttChart.js";
|
|
2
|
+
import { useMemo as n } from "react";
|
|
3
|
+
import { Box as r, IconButton as i, TextField as a, ToggleButton as o, ToggleButtonGroup as s, Tooltip as c } from "@mui/material";
|
|
4
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
5
|
+
import f from "@mui/icons-material/Download";
|
|
6
|
+
import p from "@mui/icons-material/RestartAlt";
|
|
7
|
+
import m from "@mui/icons-material/Restore";
|
|
8
|
+
import h from "@mui/icons-material/Today";
|
|
9
|
+
import g from "@mui/icons-material/UnfoldLess";
|
|
10
|
+
import _ from "@mui/icons-material/UnfoldMore";
|
|
11
|
+
//#region src/components/gantt-chart/GanttToolbar.tsx
|
|
12
|
+
function v(e) {
|
|
13
|
+
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
14
|
+
}
|
|
15
|
+
function y(e) {
|
|
16
|
+
let [t, n, r] = e.split("-").map(Number);
|
|
17
|
+
return !t || !n || !r ? null : new Date(t, n - 1, r, 0, 0, 0, 0);
|
|
18
|
+
}
|
|
19
|
+
function b({ onScrollToToday: b, config: x, onExportCSV: S }) {
|
|
20
|
+
let C = t(), w = e((e) => e.timeScale), T = e((e) => e.defaultTimeScale), E = e((e) => e.setTimeScale), D = e((e) => e.timelineRange), O = e((e) => e.isRangeCustomized), k = e((e) => e.isExpandedCustomized), A = e((e) => e.setTimelineRange), j = e((e) => e.resetTimelineRange), M = e((e) => e.resetView), N = e((e) => e.tasks), P = e((e) => e.expandedIds), F = e((e) => e.expandAll), I = e((e) => e.collapseAll), L = N.length > 0 && N.every((e) => P.has(e.id)), R = w !== T || O || k, z = n(() => Date.now(), []), B = z >= D.start.getTime() && z <= D.end.getTime(), V = {
|
|
21
|
+
days: C.scaleDays,
|
|
22
|
+
weeks: C.scaleWeeks,
|
|
23
|
+
months: C.scaleMonths,
|
|
24
|
+
quarters: C.scaleQuarters
|
|
25
|
+
}, H = {
|
|
26
|
+
days: x.showScaleDays,
|
|
27
|
+
weeks: x.showScaleWeeks,
|
|
28
|
+
months: x.showScaleMonths,
|
|
29
|
+
quarters: x.showScaleQuarters
|
|
30
|
+
}, U = Object.keys(V).filter((e) => H[e]);
|
|
31
|
+
return /* @__PURE__ */ d(r, {
|
|
32
|
+
"data-testid": "gantt-toolbar",
|
|
33
|
+
sx: {
|
|
34
|
+
display: "flex",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
flexWrap: "wrap",
|
|
37
|
+
gap: 1,
|
|
38
|
+
px: 1.5,
|
|
39
|
+
py: .75,
|
|
40
|
+
borderBottom: "1px solid",
|
|
41
|
+
borderColor: "divider",
|
|
42
|
+
bgcolor: "background.paper"
|
|
43
|
+
},
|
|
44
|
+
children: [U.length > 0 && /* @__PURE__ */ u(s, {
|
|
45
|
+
value: w,
|
|
46
|
+
exclusive: !0,
|
|
47
|
+
onChange: (e, t) => {
|
|
48
|
+
t && E(t);
|
|
49
|
+
},
|
|
50
|
+
size: "small",
|
|
51
|
+
"aria-label": C.scaleMonths,
|
|
52
|
+
children: U.map((e) => /* @__PURE__ */ u(o, {
|
|
53
|
+
value: e,
|
|
54
|
+
"data-testid": `gantt-scale-${e}`,
|
|
55
|
+
children: V[e]
|
|
56
|
+
}, e))
|
|
57
|
+
}), /* @__PURE__ */ d(r, {
|
|
58
|
+
sx: {
|
|
59
|
+
ml: "auto",
|
|
60
|
+
display: "flex",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
gap: 1
|
|
63
|
+
},
|
|
64
|
+
children: [
|
|
65
|
+
x.showExpandCollapseAll && /* @__PURE__ */ u(c, {
|
|
66
|
+
title: L ? C.collapseAllTooltip : C.expandAllTooltip,
|
|
67
|
+
children: /* @__PURE__ */ u(i, {
|
|
68
|
+
size: "small",
|
|
69
|
+
onClick: L ? I : F,
|
|
70
|
+
"aria-label": L ? C.collapseAllTooltip : C.expandAllTooltip,
|
|
71
|
+
"data-testid": "gantt-expand-collapse-all",
|
|
72
|
+
children: u(L ? g : _, { fontSize: "small" })
|
|
73
|
+
})
|
|
74
|
+
}),
|
|
75
|
+
x.showScrollToToday && b && /* @__PURE__ */ u(c, {
|
|
76
|
+
title: C.scrollToTodayTooltip,
|
|
77
|
+
children: /* @__PURE__ */ u("span", { children: /* @__PURE__ */ u(i, {
|
|
78
|
+
size: "small",
|
|
79
|
+
onClick: b,
|
|
80
|
+
disabled: !B,
|
|
81
|
+
"aria-label": C.scrollToTodayTooltip,
|
|
82
|
+
"data-testid": "gantt-scroll-to-today",
|
|
83
|
+
children: /* @__PURE__ */ u(h, { fontSize: "small" })
|
|
84
|
+
}) })
|
|
85
|
+
}),
|
|
86
|
+
x.showDateRange && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(a, {
|
|
87
|
+
type: "date",
|
|
88
|
+
size: "small",
|
|
89
|
+
label: C.rangeFrom,
|
|
90
|
+
value: v(D.start),
|
|
91
|
+
onChange: (e) => {
|
|
92
|
+
let t = y(e.target.value);
|
|
93
|
+
t && A({
|
|
94
|
+
start: t,
|
|
95
|
+
end: D.end
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
slotProps: {
|
|
99
|
+
inputLabel: { shrink: !0 },
|
|
100
|
+
htmlInput: { "data-testid": "gantt-range-start" }
|
|
101
|
+
},
|
|
102
|
+
sx: { width: 148 }
|
|
103
|
+
}), /* @__PURE__ */ u(a, {
|
|
104
|
+
type: "date",
|
|
105
|
+
size: "small",
|
|
106
|
+
label: C.rangeTo,
|
|
107
|
+
value: v(D.end),
|
|
108
|
+
onChange: (e) => {
|
|
109
|
+
let t = y(e.target.value);
|
|
110
|
+
t && A({
|
|
111
|
+
start: D.start,
|
|
112
|
+
end: t
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
slotProps: {
|
|
116
|
+
inputLabel: { shrink: !0 },
|
|
117
|
+
htmlInput: { "data-testid": "gantt-range-end" }
|
|
118
|
+
},
|
|
119
|
+
sx: { width: 148 }
|
|
120
|
+
})] }),
|
|
121
|
+
x.showRangeReset && O && /* @__PURE__ */ u(c, {
|
|
122
|
+
title: C.rangeResetTooltip,
|
|
123
|
+
children: /* @__PURE__ */ u(i, {
|
|
124
|
+
size: "small",
|
|
125
|
+
onClick: j,
|
|
126
|
+
"aria-label": C.rangeResetTooltip,
|
|
127
|
+
"data-testid": "gantt-range-reset",
|
|
128
|
+
children: /* @__PURE__ */ u(m, { fontSize: "small" })
|
|
129
|
+
})
|
|
130
|
+
}),
|
|
131
|
+
x.showExportCSV && S && /* @__PURE__ */ u(c, {
|
|
132
|
+
title: C.exportCsvTooltip,
|
|
133
|
+
children: /* @__PURE__ */ u(i, {
|
|
134
|
+
size: "small",
|
|
135
|
+
onClick: S,
|
|
136
|
+
"aria-label": C.exportCsvTooltip,
|
|
137
|
+
"data-testid": "gantt-export-csv",
|
|
138
|
+
children: /* @__PURE__ */ u(f, { fontSize: "small" })
|
|
139
|
+
})
|
|
140
|
+
}),
|
|
141
|
+
x.showResetView && /* @__PURE__ */ u(c, {
|
|
142
|
+
title: C.resetViewTooltip,
|
|
143
|
+
children: /* @__PURE__ */ u("span", { children: /* @__PURE__ */ u(i, {
|
|
144
|
+
size: "small",
|
|
145
|
+
onClick: M,
|
|
146
|
+
disabled: !R,
|
|
147
|
+
"aria-label": C.resetViewTooltip,
|
|
148
|
+
"data-testid": "gantt-reset-view",
|
|
149
|
+
children: /* @__PURE__ */ u(p, { fontSize: "small" })
|
|
150
|
+
}) })
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
})]
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { b as GanttToolbar };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useGanttTheme as e } from "./GanttChart.js";
|
|
2
|
+
import { Box as t } from "@mui/material";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/gantt-chart/GanttWeekendStrips.tsx
|
|
5
|
+
function r({ strips: r, totalWidth: i, height: a, top: o }) {
|
|
6
|
+
let { weekendColor: s } = e();
|
|
7
|
+
return r.length === 0 ? null : /* @__PURE__ */ n(t, {
|
|
8
|
+
"aria-hidden": !0,
|
|
9
|
+
"data-testid": "gantt-weekend-strips",
|
|
10
|
+
sx: {
|
|
11
|
+
position: "absolute",
|
|
12
|
+
top: o,
|
|
13
|
+
left: 0,
|
|
14
|
+
width: i,
|
|
15
|
+
height: a,
|
|
16
|
+
pointerEvents: "none"
|
|
17
|
+
},
|
|
18
|
+
children: r.map((e) => /* @__PURE__ */ n(t, { sx: {
|
|
19
|
+
position: "absolute",
|
|
20
|
+
left: e.left,
|
|
21
|
+
width: 20,
|
|
22
|
+
top: 0,
|
|
23
|
+
height: "100%",
|
|
24
|
+
bgcolor: s || "action.hover"
|
|
25
|
+
} }, e.key))
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { r as GanttWeekendStrips };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { addDays as e } from "../util/gantt-chart.util.js";
|
|
2
|
+
import { useGanttChartStore as t, useGanttTranslations as n, useRawGanttChartStore as r } from "../GanttChart.js";
|
|
3
|
+
import { useLayoutEffect as i, useRef as a, useState as o } from "react";
|
|
4
|
+
//#region src/components/gantt-chart/hooks/useGanttDrag.ts
|
|
5
|
+
var s = 864e5;
|
|
6
|
+
function c({ totalWidth: c, displayRange: l, onTaskMoved: u, onTaskResized: d, onTasksChange: f }) {
|
|
7
|
+
let p = t((e) => e.updateTask), m = r(), h = n(), g = a(1), _ = a(u), v = a(d), y = a(f);
|
|
8
|
+
i(() => {
|
|
9
|
+
g.current = c > 0 ? c / ((l.end.getTime() - l.start.getTime()) / s) : 1, _.current = u, v.current = d, y.current = f;
|
|
10
|
+
});
|
|
11
|
+
let b = a(null), x = a(null), [S, C] = o(null), w = a(!1);
|
|
12
|
+
return {
|
|
13
|
+
activeDrag: S,
|
|
14
|
+
suppressClickRef: w,
|
|
15
|
+
handleBarMouseDown: (t, n, r) => {
|
|
16
|
+
t.stopPropagation(), w.current = !1, b.current = {
|
|
17
|
+
type: r,
|
|
18
|
+
taskId: n.id,
|
|
19
|
+
startX: t.clientX,
|
|
20
|
+
originalStart: n.startDate,
|
|
21
|
+
originalEnd: n.endDate
|
|
22
|
+
}, document.body.style.cursor = r === "resize" ? "ew-resize" : "grabbing";
|
|
23
|
+
let i = (e) => {
|
|
24
|
+
let t = b.current;
|
|
25
|
+
if (!t || t.type === "progress") return;
|
|
26
|
+
let n = e.clientX - t.startX, r = Math.round(n / g.current);
|
|
27
|
+
Math.abs(n) >= 5 && (w.current = !0);
|
|
28
|
+
let i = {
|
|
29
|
+
taskId: t.taskId,
|
|
30
|
+
type: t.type,
|
|
31
|
+
deltaDays: r
|
|
32
|
+
};
|
|
33
|
+
x.current = i, C(i);
|
|
34
|
+
}, a = () => {
|
|
35
|
+
document.body.style.cursor = "";
|
|
36
|
+
let t = b.current, n = x.current;
|
|
37
|
+
if (t && n && w.current && n.deltaDays !== 0) {
|
|
38
|
+
let r = m.getState().tasks.find((e) => e.id === t.taskId);
|
|
39
|
+
if (r) {
|
|
40
|
+
if (n.type === "move") {
|
|
41
|
+
let i = e(t.originalStart, n.deltaDays), a = e(t.originalEnd, n.deltaDays);
|
|
42
|
+
p({
|
|
43
|
+
...r,
|
|
44
|
+
startDate: i,
|
|
45
|
+
endDate: a
|
|
46
|
+
}), _.current?.(r, i, a);
|
|
47
|
+
} else {
|
|
48
|
+
let i = e(t.originalEnd, n.deltaDays), a = i > t.originalStart ? i : e(t.originalStart, 1);
|
|
49
|
+
p({
|
|
50
|
+
...r,
|
|
51
|
+
endDate: a
|
|
52
|
+
}), v.current?.(r, a);
|
|
53
|
+
}
|
|
54
|
+
y.current?.(m.getState().tasks);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
b.current = null, x.current = null, C(null), document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", a);
|
|
58
|
+
};
|
|
59
|
+
document.addEventListener("mousemove", i), document.addEventListener("mouseup", a);
|
|
60
|
+
},
|
|
61
|
+
handleProgressMouseDown: (e, t, n, r) => {
|
|
62
|
+
e.stopPropagation(), w.current = !1, b.current = {
|
|
63
|
+
type: "progress",
|
|
64
|
+
taskId: t.id,
|
|
65
|
+
startX: e.clientX,
|
|
66
|
+
originalStart: t.startDate,
|
|
67
|
+
originalEnd: t.endDate,
|
|
68
|
+
initialProgress: n,
|
|
69
|
+
barWidthPx: r
|
|
70
|
+
}, document.body.style.cursor = "ew-resize";
|
|
71
|
+
let i = (e) => {
|
|
72
|
+
let t = b.current;
|
|
73
|
+
if (!t || t.type !== "progress") return;
|
|
74
|
+
let n = e.clientX - t.startX;
|
|
75
|
+
Math.abs(n) >= 5 && (w.current = !0);
|
|
76
|
+
let r = n / (t.barWidthPx ?? 1) * 100, i = Math.round(Math.max(0, Math.min(100, (t.initialProgress ?? 0) + r))), a = {
|
|
77
|
+
taskId: t.taskId,
|
|
78
|
+
type: "progress",
|
|
79
|
+
deltaDays: 0,
|
|
80
|
+
newProgress: i
|
|
81
|
+
};
|
|
82
|
+
x.current = a, C(a);
|
|
83
|
+
}, a = () => {
|
|
84
|
+
document.body.style.cursor = "";
|
|
85
|
+
let e = b.current, t = x.current;
|
|
86
|
+
if (e && t && t.type === "progress" && t.newProgress !== void 0 && w.current) {
|
|
87
|
+
let n = m.getState().tasks.find((t) => t.id === e.taskId);
|
|
88
|
+
n && (p({
|
|
89
|
+
...n,
|
|
90
|
+
progress: t.newProgress
|
|
91
|
+
}), y.current?.(m.getState().tasks));
|
|
92
|
+
}
|
|
93
|
+
b.current = null, x.current = null, C(null), document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", a);
|
|
94
|
+
};
|
|
95
|
+
document.addEventListener("mousemove", i), document.addEventListener("mouseup", a);
|
|
96
|
+
},
|
|
97
|
+
formatDragDate: (e) => e.toLocaleDateString(h.dateLocale, {
|
|
98
|
+
day: "2-digit",
|
|
99
|
+
month: "short"
|
|
100
|
+
})
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { c as useGanttDrag };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
//#region src/components/gantt-chart/util/gantt-chart.util.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = /* @__PURE__ */ new Date(), n = g(t), r = _(t);
|
|
4
|
+
if (e.length === 0) return {
|
|
5
|
+
start: n,
|
|
6
|
+
end: r
|
|
7
|
+
};
|
|
8
|
+
let i = e.map((e) => e.startDate.getTime()), a = e.map((e) => e.endDate.getTime()), l = o(c(new Date(Math.min(...i)), -1)), u = s(c(new Date(Math.max(...a)), 1));
|
|
9
|
+
return {
|
|
10
|
+
start: l < n ? l : n,
|
|
11
|
+
end: u > r ? u : r
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function t(e, t) {
|
|
15
|
+
return t === "weeks" ? {
|
|
16
|
+
start: f(e.start),
|
|
17
|
+
end: e.end
|
|
18
|
+
} : t === "quarters" ? {
|
|
19
|
+
start: g(e.start),
|
|
20
|
+
end: _(e.end)
|
|
21
|
+
} : e;
|
|
22
|
+
}
|
|
23
|
+
function n(e, t) {
|
|
24
|
+
let n = t.end.getTime() - t.start.getTime();
|
|
25
|
+
if (n <= 0) return {
|
|
26
|
+
left: 0,
|
|
27
|
+
width: 0
|
|
28
|
+
};
|
|
29
|
+
let r = (e.startDate.getTime() - t.start.getTime()) / n * 100, i = (e.endDate.getTime() - e.startDate.getTime()) / n * 100;
|
|
30
|
+
return {
|
|
31
|
+
left: Math.max(0, r),
|
|
32
|
+
width: Math.max(0, i)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function r(e) {
|
|
36
|
+
let t = /* @__PURE__ */ new Map();
|
|
37
|
+
for (let n of e) t.set(n.id, {
|
|
38
|
+
...n,
|
|
39
|
+
children: [],
|
|
40
|
+
depth: 0
|
|
41
|
+
});
|
|
42
|
+
let n = [];
|
|
43
|
+
for (let e of t.values()) e.parentId && t.has(e.parentId) ? t.get(e.parentId).children.push(e) : n.push(e);
|
|
44
|
+
return i(n, 0), n;
|
|
45
|
+
}
|
|
46
|
+
function i(e, t) {
|
|
47
|
+
for (let n of e) n.depth = t, i(n.children, t + 1);
|
|
48
|
+
}
|
|
49
|
+
function a(e, t) {
|
|
50
|
+
let n = [];
|
|
51
|
+
function r(e) {
|
|
52
|
+
for (let i of e) n.push(i), i.children.length > 0 && t.has(i.id) && r(i.children);
|
|
53
|
+
}
|
|
54
|
+
return r(e), n;
|
|
55
|
+
}
|
|
56
|
+
function o(e) {
|
|
57
|
+
return new Date(e.getFullYear(), e.getMonth(), 1, 0, 0, 0, 0);
|
|
58
|
+
}
|
|
59
|
+
function s(e) {
|
|
60
|
+
return new Date(e.getFullYear(), e.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
61
|
+
}
|
|
62
|
+
function c(e, t) {
|
|
63
|
+
return new Date(e.getFullYear(), e.getMonth() + t, e.getDate());
|
|
64
|
+
}
|
|
65
|
+
function l(e, t) {
|
|
66
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate() + t, 0, 0, 0, 0);
|
|
67
|
+
}
|
|
68
|
+
function u(e, t, n) {
|
|
69
|
+
if (n === 0) return e;
|
|
70
|
+
let r = /* @__PURE__ */ new Map();
|
|
71
|
+
for (let t of e) for (let e of t.dependencies ?? []) r.has(e) || r.set(e, []), r.get(e).push(t.id);
|
|
72
|
+
let i = new Map(e.map((e) => [e.id, e])), a = [...r.get(t) ?? []], o = /* @__PURE__ */ new Set();
|
|
73
|
+
for (; a.length > 0;) {
|
|
74
|
+
let e = a.shift();
|
|
75
|
+
if (o.has(e)) continue;
|
|
76
|
+
o.add(e);
|
|
77
|
+
let t = i.get(e);
|
|
78
|
+
i.set(e, {
|
|
79
|
+
...t,
|
|
80
|
+
startDate: new Date(t.startDate.getTime() + n),
|
|
81
|
+
endDate: new Date(t.endDate.getTime() + n)
|
|
82
|
+
}), a.push(...r.get(e) ?? []);
|
|
83
|
+
}
|
|
84
|
+
return e.map((e) => i.get(e.id));
|
|
85
|
+
}
|
|
86
|
+
function d(e) {
|
|
87
|
+
let t = [], n = o(e.start);
|
|
88
|
+
for (; n <= e.end;) t.push(n), n = c(n, 1);
|
|
89
|
+
return t;
|
|
90
|
+
}
|
|
91
|
+
function f(e) {
|
|
92
|
+
let t = new Date(e), n = t.getDay(), r = n === 0 ? -6 : 1 - n;
|
|
93
|
+
return t.setDate(t.getDate() + r), t.setHours(0, 0, 0, 0), t;
|
|
94
|
+
}
|
|
95
|
+
function p(e) {
|
|
96
|
+
let t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())), n = t.getUTCDay() || 7;
|
|
97
|
+
t.setUTCDate(t.getUTCDate() + 4 - n);
|
|
98
|
+
let r = new Date(Date.UTC(t.getUTCFullYear(), 0, 1));
|
|
99
|
+
return Math.ceil(((t.getTime() - r.getTime()) / 864e5 + 1) / 7);
|
|
100
|
+
}
|
|
101
|
+
function m(e) {
|
|
102
|
+
let t = [], n = f(e.start);
|
|
103
|
+
for (; n <= e.end;) t.push(new Date(n)), n = new Date(n.getFullYear(), n.getMonth(), n.getDate() + 7);
|
|
104
|
+
return t;
|
|
105
|
+
}
|
|
106
|
+
function h(e) {
|
|
107
|
+
let t = [], n = new Date(e.start.getFullYear(), e.start.getMonth(), e.start.getDate(), 0, 0, 0, 0), r = new Date(e.end.getFullYear(), e.end.getMonth(), e.end.getDate(), 0, 0, 0, 0).getTime();
|
|
108
|
+
for (; n.getTime() <= r;) t.push(new Date(n)), n = new Date(n.getFullYear(), n.getMonth(), n.getDate() + 1, 0, 0, 0, 0);
|
|
109
|
+
return t;
|
|
110
|
+
}
|
|
111
|
+
function g(e) {
|
|
112
|
+
let t = Math.floor(e.getMonth() / 3) * 3;
|
|
113
|
+
return new Date(e.getFullYear(), t, 1, 0, 0, 0, 0);
|
|
114
|
+
}
|
|
115
|
+
function _(e) {
|
|
116
|
+
let t = Math.floor(e.getMonth() / 3) * 3 + 2;
|
|
117
|
+
return s(new Date(e.getFullYear(), t, 1));
|
|
118
|
+
}
|
|
119
|
+
function v(e) {
|
|
120
|
+
let t = [], n = g(e.start);
|
|
121
|
+
for (; n <= e.end;) {
|
|
122
|
+
let e = Math.floor(n.getMonth() / 3) + 1;
|
|
123
|
+
t.push({
|
|
124
|
+
key: `${n.getFullYear()}-Q${e}`,
|
|
125
|
+
label: `Q${e} ${n.getFullYear()}`,
|
|
126
|
+
start: new Date(n)
|
|
127
|
+
}), n = new Date(n.getFullYear(), n.getMonth() + 3, 1);
|
|
128
|
+
}
|
|
129
|
+
return t;
|
|
130
|
+
}
|
|
131
|
+
function y(e) {
|
|
132
|
+
if (e.length === 0) return /* @__PURE__ */ new Set();
|
|
133
|
+
let t = /* @__PURE__ */ new Map();
|
|
134
|
+
for (let n of e) for (let e of n.dependencies ?? []) t.has(e) || t.set(e, []), t.get(e).push(n.id);
|
|
135
|
+
let n = new Map(e.map((e) => [e.id, e])), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
136
|
+
function a(e) {
|
|
137
|
+
if (r.has(e)) return r.get(e);
|
|
138
|
+
if (i.has(e)) return n.get(e)?.endDate.getTime() ?? 0;
|
|
139
|
+
i.add(e);
|
|
140
|
+
let o = n.get(e)?.endDate.getTime() ?? 0;
|
|
141
|
+
for (let n of t.get(e) ?? []) o = Math.max(o, a(n));
|
|
142
|
+
return i.delete(e), r.set(e, o), o;
|
|
143
|
+
}
|
|
144
|
+
for (let t of e) a(t.id);
|
|
145
|
+
let o = Math.max(...r.values()), s = /* @__PURE__ */ new Set();
|
|
146
|
+
for (let t of e) a(t.id) === o && s.add(t.id);
|
|
147
|
+
return s;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { l as addDays, c as addMonths, r as buildTaskTree, n as calculateTaskPosition, u as cascadeDateUpdate, y as computeCriticalPath, s as endOfMonth, h as getDaysInRange, t as getDisplayRange, p as getISOWeekNumber, d as getMonthsInRange, v as getQuartersInRange, e as getTimelineRange, a as getVisibleTasks, m as getWeeksInRange, o as startOfMonth };
|