@ollap/gantt-vue3 0.1.2

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.
@@ -0,0 +1 @@
1
+ /*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports ((-webkit-hyphens:none) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0}}}:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--color-orange-400:oklch(75% .183 55.934);--color-slate-50:oklch(98.4% .003 247.858);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wider:.05em;--radius-md:.375rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1)}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:calc(var(--spacing)*0)}.-top-1{top:calc(var(--spacing)*-1)}.top-0{top:calc(var(--spacing)*0)}.top-2{top:calc(var(--spacing)*2)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-2{bottom:calc(var(--spacing)*2)}.-left-\[6px\]{left:-6px}.left-2{left:calc(var(--spacing)*2)}.z-10{z-index:10}.z-20{z-index:20}.mr-2{margin-right:calc(var(--spacing)*2)}.flex{display:flex}.h-0{height:calc(var(--spacing)*0)}.h-4{height:calc(var(--spacing)*4)}.h-full{height:100%}.w-0{width:calc(var(--spacing)*0)}.w-4{width:calc(var(--spacing)*4)}.w-64{width:calc(var(--spacing)*64)}.min-w-0{min-width:calc(var(--spacing)*0)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.rotate-90{rotate:90deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-hidden{overflow-y:hidden}.rounded{border-radius:.25rem}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-\[\#e8e8e8\]{border-color:#e8e8e8}.border-orange-400{border-color:var(--color-orange-400)}.border-slate-50{border-color:var(--color-slate-50)}.border-slate-100{border-color:var(--color-slate-100)}.border-slate-100\/50{border-color:#f1f5f980}@supports (color:color-mix(in lab,red,red)){.border-slate-100\/50{border-color:color-mix(in oklab,var(--color-slate-100)50%,transparent)}}.border-slate-200{border-color:var(--color-slate-200)}.border-t-orange-400{border-top-color:var(--color-orange-400)}.border-r-transparent{border-right-color:#0000}.border-l-transparent{border-left-color:#0000}.bg-orange-400{background-color:var(--color-orange-400)}.bg-slate-50{background-color:var(--color-slate-50)}.bg-slate-50\/30{background-color:#f8fafc4d}@supports (color:color-mix(in lab,red,red)){.bg-slate-50\/30{background-color:color-mix(in oklab,var(--color-slate-50)30%,transparent)}}.bg-slate-50\/50{background-color:#f8fafc80}@supports (color:color-mix(in lab,red,red)){.bg-slate-50\/50{background-color:color-mix(in oklab,var(--color-slate-50)50%,transparent)}}.bg-slate-400{background-color:var(--color-slate-400)}.bg-white{background-color:var(--color-white)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-4{padding-block:calc(var(--spacing)*4)}.pr-4{padding-right:calc(var(--spacing)*4)}.pl-12{padding-left:calc(var(--spacing)*12)}.font-sans{font-family:var(--font-sans)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.whitespace-nowrap{white-space:nowrap}.text-slate-400{color:var(--color-slate-400)}.text-slate-600{color:var(--color-slate-600)}.text-slate-700{color:var(--color-slate-700)}.text-white{color:var(--color-white)}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.opacity-80{opacity:.8}.shadow-\[10px_0_15px_-3px_rgba\(0\,0\,0\,0\.1\)\]{--tw-shadow:10px 0 15px -3px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}@media(hover:hover){.hover\:-translate-y-0\.5:hover{--tw-translate-y:calc(var(--spacing)*-.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.hover\:bg-slate-50:hover{background-color:var(--color-slate-50)}.hover\:bg-white:hover{background-color:var(--color-white)}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}.overflow-auto[data-v-815cd186]::-webkit-scrollbar{width:6px;height:6px}.overflow-auto[data-v-815cd186]::-webkit-scrollbar-track{background:transparent}.overflow-auto[data-v-815cd186]::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:10px}.overflow-auto[data-v-815cd186]::-webkit-scrollbar-thumb:hover{background:#94a3b8}
@@ -0,0 +1,25 @@
1
+ import { CSSProperties } from 'vue';
2
+ import { default as GanttChart } from './components/GanttChart.vue';
3
+
4
+ export declare const GANTT_VERSION = "0.1.0";
5
+
6
+ export { GanttChart }
7
+
8
+ export declare type GanttItem = {
9
+ id: string | number;
10
+ name: string;
11
+ tasks: Task[];
12
+ expanded?: boolean;
13
+ };
14
+
15
+ export declare const setupGantt: () => void;
16
+
17
+ export declare type Task = {
18
+ id: string | number;
19
+ name: string;
20
+ startDate: string;
21
+ endDate: string;
22
+ color?: CSSProperties['color'];
23
+ };
24
+
25
+ export { }
@@ -0,0 +1,250 @@
1
+ import { defineComponent as j, ref as m, computed as k, onMounted as W, createElementBlock as l, openBlock as r, createElementVNode as o, renderSlot as b, createTextVNode as J, normalizeStyle as i, Fragment as p, renderList as h, toDisplayString as v, createCommentVNode as S, withDirectives as G, normalizeClass as A, vShow as L } from "vue";
2
+ const F = { class: "flex flex-col h-full bg-slate-50 font-sans antialiased select-none" }, q = { class: "bg-white border border-slate-200 overflow-hidden flex-1 flex flex-col" }, K = { class: "flex border-b border-slate-200 bg-slate-50/50" }, Q = { class: "w-64 shrink-0 px-6 py-4 border-r border-slate-200 font-bold text-slate-700 relative z-20 shadow-[10px_0_15px_-3px_rgba(0,0,0,0.1)]" }, U = { class: "text-[10px] tracking-wider text-slate-400" }, X = { class: "text-xs font-semibold text-slate-400" }, Y = { class: "flex flex-1 overflow-hidden" }, Z = ["onClick"], ee = { class: "mr-2 w-4 h-4" }, te = { class: "min-w-0" }, se = { class: "text-sm font-semibold text-slate-700 truncate" }, oe = {
3
+ key: 0,
4
+ class: "bg-slate-50/30"
5
+ }, ne = { class: "text-xs truncate" }, le = { class: "truncate" }, a = 60, x = 52, re = /* @__PURE__ */ j({
6
+ __name: "GanttChart",
7
+ props: {
8
+ list: {},
9
+ dateRange: {},
10
+ showToday: { type: Boolean }
11
+ },
12
+ emits: ["update:list", "toggle"],
13
+ setup(g, { emit: O }) {
14
+ const f = g, $ = O, d = m([]), y = m(JSON.parse(JSON.stringify(f.list))), _ = k(() => d.value.length * a), P = k(() => ({
15
+ backgroundImage: `linear-gradient(to right, transparent ${a - 1}px, #e8e8e8 ${a - 1}px, #e8e8e8 ${a}px)`,
16
+ // backgroundImage: `linear-gradient(to right, #e8e8e8 1px, transparent 1px)`,
17
+ backgroundSize: `${a}px 100%`,
18
+ // backgroundRepeat: 'repeat-y',
19
+ // backgroundPosition: `${CELL_WIDTH}px 0`,
20
+ width: _.value + "px"
21
+ })), V = k(() => {
22
+ const s = {};
23
+ return y.value.forEach((e) => {
24
+ s[e.id] = {}, e.tasks.forEach((t) => {
25
+ let n = new Date(t.startDate);
26
+ const c = new Date(t.endDate);
27
+ for (; n <= c; ) {
28
+ const u = n.toISOString().split("T")[0];
29
+ s[e.id][u] = (s[e.id][u] || 0) + 1, n.setDate(n.getDate() + 1);
30
+ }
31
+ });
32
+ }), s;
33
+ }), B = () => {
34
+ const s = [];
35
+ let e = new Date(f.dateRange[0]);
36
+ const t = new Date(f.dateRange[1]);
37
+ for (; e <= t; )
38
+ s.push(e.toISOString().split("T")[0]), e.setDate(e.getDate() + 1);
39
+ d.value = s;
40
+ }, C = (s) => {
41
+ const e = new Date(s), t = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
42
+ return {
43
+ monthDay: `${String(e.getMonth() + 1).padStart(2, "0")}/${e.getDate()}`,
44
+ weekday: t[e.getDay()]
45
+ };
46
+ }, R = (s) => {
47
+ const e = d.value.indexOf(s);
48
+ return e > -1 ? e * a : -999;
49
+ }, w = (s) => {
50
+ const e = new Date(s.startDate), t = new Date(s.endDate), n = new Date(d.value[0]), c = new Date(d.value[d.value.length - 1]);
51
+ if (e < n && t > c)
52
+ return {
53
+ left: -4,
54
+ width: _.value + 8
55
+ };
56
+ let u = d.value.indexOf(s.startDate), D = d.value.indexOf(s.endDate), z = 4, N = -8;
57
+ return u === -1 && D === -1 ? null : (u === -1 && (u = 0, z = -4), D === -1 && (D = d.value.length - 1, N = 4), {
58
+ left: u * a + z,
59
+ width: (D - u + 1) * a + N
60
+ });
61
+ }, I = m(), T = m(), H = (s) => {
62
+ const e = s.target;
63
+ I.value && (I.value.scrollTop = e.scrollTop), T.value && (T.value.scrollLeft = e.scrollLeft);
64
+ }, M = (s) => {
65
+ const e = y.value.find((t) => t.id === s);
66
+ e && (e.expanded = !e.expanded), $("toggle", s);
67
+ }, E = k(() => {
68
+ const s = (/* @__PURE__ */ new Date()).toISOString().split("T")[0], e = d.value.indexOf(s);
69
+ return e === -1 ? null : e * a;
70
+ });
71
+ return W(() => {
72
+ B();
73
+ }), (s, e) => (r(), l("div", F, [
74
+ o("div", q, [
75
+ o("div", K, [
76
+ o("div", Q, [
77
+ b(s.$slots, "leftPanelHeader", {}, () => [
78
+ e[0] || (e[0] = J("项目成员 / 任务状态", -1))
79
+ ], !0)
80
+ ]),
81
+ o("div", {
82
+ ref_key: "headerRef",
83
+ ref: T,
84
+ class: "flex-1 overflow-hidden pointer-events-none"
85
+ }, [
86
+ o("div", {
87
+ class: "flex h-full",
88
+ style: i({ width: _.value + "px" })
89
+ }, [
90
+ (r(!0), l(p, null, h(d.value, (t) => (r(), l("div", {
91
+ key: t,
92
+ class: "shrink-0 flex flex-col items-center justify-center border-r border-slate-100 py-2 transition-colors",
93
+ style: i({ width: a + "px" })
94
+ }, [
95
+ b(s.$slots, "headerCell", { date: t }, () => [
96
+ o("span", U, v(C(t).weekday), 1),
97
+ o("span", X, v(C(t).monthDay), 1)
98
+ ], !0)
99
+ ], 4))), 128))
100
+ ], 4)
101
+ ], 512)
102
+ ]),
103
+ o("div", Y, [
104
+ o("div", {
105
+ ref_key: "leftPanelRef",
106
+ ref: I,
107
+ class: "w-64 shrink-0 border-r border-slate-200 overflow-y-hidden relative z-10 shadow-[10px_0_15px_-3px_rgba(0,0,0,0.1)] bg-white"
108
+ }, [
109
+ (r(!0), l(p, null, h(y.value, (t) => (r(), l("div", {
110
+ key: t.id
111
+ }, [
112
+ o("div", {
113
+ class: "flex items-center px-4 hover:bg-slate-50 cursor-pointer border-b border-slate-50 transition-colors",
114
+ style: i({ height: x + "px" }),
115
+ onClick: (n) => M(t.id)
116
+ }, [
117
+ G(o("span", {
118
+ class: A(["transform transition-transform duration-200 mr-2", t.expanded ? "rotate-90" : ""])
119
+ }, [...e[1] || (e[1] = [
120
+ o("svg", {
121
+ class: "w-4 h-4 text-slate-400",
122
+ fill: "none",
123
+ stroke: "currentColor",
124
+ viewBox: "0 0 24 24"
125
+ }, [
126
+ o("path", {
127
+ "stroke-linecap": "round",
128
+ "stroke-linejoin": "round",
129
+ "stroke-width": "2",
130
+ d: "M9 5l7 7-7 7"
131
+ })
132
+ ], -1)
133
+ ])], 2), [
134
+ [L, t.tasks.length > 0]
135
+ ]),
136
+ G(o("span", ee, null, 512), [
137
+ [L, !t.tasks.length]
138
+ ]),
139
+ o("div", te, [
140
+ b(s.$slots, "leftPanelItem", { item: t }, () => [
141
+ o("div", se, v(t.name), 1)
142
+ ], !0)
143
+ ])
144
+ ], 12, Z),
145
+ t.expanded ? (r(), l("div", oe, [
146
+ (r(!0), l(p, null, h(t.tasks, (n) => (r(), l("div", {
147
+ key: n.id,
148
+ class: "flex items-center pl-12 pr-4 border-b border-slate-100/50 text-slate-600 hover:bg-white transition-colors",
149
+ style: i({ height: x + "px" })
150
+ }, [
151
+ o("div", ne, v(n.name), 1)
152
+ ], 4))), 128))
153
+ ])) : S("", !0)
154
+ ]))), 128))
155
+ ], 512),
156
+ o("div", {
157
+ onScroll: H,
158
+ class: "flex-1 overflow-auto relative select-none"
159
+ }, [
160
+ E.value !== null && g.showToday ? (r(), l("div", {
161
+ key: 0,
162
+ class: "absolute top-0 bottom-0 z-10 pointer-events-none border-l-2 border-orange-400",
163
+ style: i({ left: E.value + "px", width: a + "px" })
164
+ }, [...e[2] || (e[2] = [
165
+ o("div", { class: "absolute -top-1 -left-[6px] w-0 h-0 border-l-[5px] border-l-transparent border-r-[5px] border-r-transparent border-t-[6px] border-t-orange-400" }, null, -1),
166
+ o("div", { class: "absolute top-2 left-2 px-1.5 py-0.5 bg-orange-400 text-[10px] text-white rounded shadow-sm opacity-80 whitespace-nowrap" }, " 今天 ", -1)
167
+ ])], 4)) : S("", !0),
168
+ o("div", {
169
+ class: "absolute inset-0 pointer-events-none",
170
+ style: i(P.value)
171
+ }, null, 4),
172
+ o("div", {
173
+ style: i({ width: _.value + "px" })
174
+ }, [
175
+ (r(!0), l(p, null, h(y.value, (t) => (r(), l(p, {
176
+ key: t.id
177
+ }, [
178
+ o("div", {
179
+ class: "relative border-b border-[#e8e8e8]",
180
+ style: i({ height: x + "px" })
181
+ }, [
182
+ (r(!0), l(p, null, h(V.value[t.id], (n, c) => b(s.$slots, "count", {
183
+ key: c,
184
+ item: t,
185
+ date: c,
186
+ count: n,
187
+ style: i({
188
+ left: R(c) + "px",
189
+ width: a + "px",
190
+ height: x + "px"
191
+ })
192
+ }, () => [
193
+ o("div", {
194
+ class: "absolute top-0 flex items-center justify-center text-sm",
195
+ style: i({
196
+ left: R(c) + "px",
197
+ width: a + "px",
198
+ height: x + "px",
199
+ contentVisibility: "auto",
200
+ containIntrinsicSize: `${a}px ${x}px`
201
+ })
202
+ }, v(n), 5)
203
+ ], !0)), 128))
204
+ ], 4),
205
+ t.expanded ? (r(!0), l(p, { key: 0 }, h(t.tasks, (n) => (r(), l("div", {
206
+ key: n.id,
207
+ class: "relative border-b border-[#e8e8e8] overflow-hidden",
208
+ style: i({ height: x + "px" })
209
+ }, [
210
+ w(n) ? b(s.$slots, "task", {
211
+ key: 0,
212
+ style: i({
213
+ left: w(n).left + "px",
214
+ width: w(n).width + "px",
215
+ position: "absolute"
216
+ }),
217
+ task: n
218
+ }, () => [
219
+ o("div", {
220
+ class: "absolute bg-slate-400 top-2 bottom-2 rounded-md shadow-sm flex items-center px-3 text-[11px] text-white font-medium cursor-pointer hover:shadow-lg hover:-translate-y-0.5 transition-all duration-200",
221
+ style: i({
222
+ left: w(n).left + "px",
223
+ width: w(n).width + "px",
224
+ backgroundColor: n.color
225
+ })
226
+ }, [
227
+ o("span", le, v(n.name), 1)
228
+ ], 4)
229
+ ], !0) : S("", !0)
230
+ ], 4))), 128)) : S("", !0)
231
+ ], 64))), 128))
232
+ ], 4)
233
+ ], 32)
234
+ ])
235
+ ])
236
+ ]));
237
+ }
238
+ }), ae = (g, O) => {
239
+ const f = g.__vccOpts || g;
240
+ for (const [$, d] of O)
241
+ f[$] = d;
242
+ return f;
243
+ }, ie = /* @__PURE__ */ ae(re, [["__scopeId", "data-v-815cd186"]]), ce = "0.1.0", ue = () => {
244
+ console.log("Gantt Core Initialized");
245
+ };
246
+ export {
247
+ ce as GANTT_VERSION,
248
+ ie as GanttChart,
249
+ ue as setupGantt
250
+ };
@@ -0,0 +1 @@
1
+ (function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.GanttVue3={},s.Vue))})(this,(function(s,e){"use strict";const V={class:"flex flex-col h-full bg-slate-50 font-sans antialiased select-none"},B={class:"bg-white border border-slate-200 overflow-hidden flex-1 flex flex-col"},z={class:"flex border-b border-slate-200 bg-slate-50/50"},O={class:"w-64 shrink-0 px-6 py-4 border-r border-slate-200 font-bold text-slate-700 relative z-20 shadow-[10px_0_15px_-3px_rgba(0,0,0,0.1)]"},T={class:"text-[10px] tracking-wider text-slate-400"},C={class:"text-xs font-semibold text-slate-400"},u={class:"flex flex-1 overflow-hidden"},I=["onClick"],$={class:"mr-2 w-4 h-4"},R={class:"min-w-0"},G={class:"text-sm font-semibold text-slate-700 truncate"},L={key:0,class:"bg-slate-50/30"},F={class:"text-xs truncate"},P={class:"truncate"},r=60,c=52,j=((f,y)=>{const p=f.__vccOpts||f;for(const[w,a]of y)p[w]=a;return p})(e.defineComponent({__name:"GanttChart",props:{list:{},dateRange:{},showToday:{type:Boolean}},emits:["update:list","toggle"],setup(f,{emit:y}){const p=f,w=y,a=e.ref([]),h=e.ref(JSON.parse(JSON.stringify(p.list))),x=e.computed(()=>a.value.length*r),W=e.computed(()=>({backgroundImage:`linear-gradient(to right, transparent ${r-1}px, #e8e8e8 ${r-1}px, #e8e8e8 ${r}px)`,backgroundSize:`${r}px 100%`,width:x.value+"px"})),A=e.computed(()=>{const n={};return h.value.forEach(t=>{n[t.id]={},t.tasks.forEach(o=>{let l=new Date(o.startDate);const d=new Date(o.endDate);for(;l<=d;){const i=l.toISOString().split("T")[0];n[t.id][i]=(n[t.id][i]||0)+1,l.setDate(l.getDate()+1)}})}),n}),J=()=>{const n=[];let t=new Date(p.dateRange[0]);const o=new Date(p.dateRange[1]);for(;t<=o;)n.push(t.toISOString().split("T")[0]),t.setDate(t.getDate()+1);a.value=n},E=n=>{const t=new Date(n),o=["周日","周一","周二","周三","周四","周五","周六"];return{monthDay:`${String(t.getMonth()+1).padStart(2,"0")}/${t.getDate()}`,weekday:o[t.getDay()]}},S=n=>{const t=a.value.indexOf(n);return t>-1?t*r:-999},m=n=>{const t=new Date(n.startDate),o=new Date(n.endDate),l=new Date(a.value[0]),d=new Date(a.value[a.value.length-1]);if(t<l&&o>d)return{left:-4,width:x.value+8};let i=a.value.indexOf(n.startDate),g=a.value.indexOf(n.endDate),D=4,N=-8;return i===-1&&g===-1?null:(i===-1&&(i=0,D=-4),g===-1&&(g=a.value.length-1,N=4),{left:i*r+D,width:(g-i+1)*r+N})},b=e.ref(),k=e.ref(),q=n=>{const t=n.target;b.value&&(b.value.scrollTop=t.scrollTop),k.value&&(k.value.scrollLeft=t.scrollLeft)},K=n=>{const t=h.value.find(o=>o.id===n);t&&(t.expanded=!t.expanded),w("toggle",n)},_=e.computed(()=>{const n=new Date().toISOString().split("T")[0],t=a.value.indexOf(n);return t===-1?null:t*r});return e.onMounted(()=>{J()}),(n,t)=>(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",B,[e.createElementVNode("div",z,[e.createElementVNode("div",O,[e.renderSlot(n.$slots,"leftPanelHeader",{},()=>[t[0]||(t[0]=e.createTextVNode("项目成员 / 任务状态",-1))],!0)]),e.createElementVNode("div",{ref_key:"headerRef",ref:k,class:"flex-1 overflow-hidden pointer-events-none"},[e.createElementVNode("div",{class:"flex h-full",style:e.normalizeStyle({width:x.value+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o,class:"shrink-0 flex flex-col items-center justify-center border-r border-slate-100 py-2 transition-colors",style:e.normalizeStyle({width:r+"px"})},[e.renderSlot(n.$slots,"headerCell",{date:o},()=>[e.createElementVNode("span",T,e.toDisplayString(E(o).weekday),1),e.createElementVNode("span",C,e.toDisplayString(E(o).monthDay),1)],!0)],4))),128))],4)],512)]),e.createElementVNode("div",u,[e.createElementVNode("div",{ref_key:"leftPanelRef",ref:b,class:"w-64 shrink-0 border-r border-slate-200 overflow-y-hidden relative z-10 shadow-[10px_0_15px_-3px_rgba(0,0,0,0.1)] bg-white"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.id},[e.createElementVNode("div",{class:"flex items-center px-4 hover:bg-slate-50 cursor-pointer border-b border-slate-50 transition-colors",style:e.normalizeStyle({height:c+"px"}),onClick:l=>K(o.id)},[e.withDirectives(e.createElementVNode("span",{class:e.normalizeClass(["transform transition-transform duration-200 mr-2",o.expanded?"rotate-90":""])},[...t[1]||(t[1]=[e.createElementVNode("svg",{class:"w-4 h-4 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})],-1)])],2),[[e.vShow,o.tasks.length>0]]),e.withDirectives(e.createElementVNode("span",$,null,512),[[e.vShow,!o.tasks.length]]),e.createElementVNode("div",R,[e.renderSlot(n.$slots,"leftPanelItem",{item:o},()=>[e.createElementVNode("div",G,e.toDisplayString(o.name),1)],!0)])],12,I),o.expanded?(e.openBlock(),e.createElementBlock("div",L,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.tasks,l=>(e.openBlock(),e.createElementBlock("div",{key:l.id,class:"flex items-center pl-12 pr-4 border-b border-slate-100/50 text-slate-600 hover:bg-white transition-colors",style:e.normalizeStyle({height:c+"px"})},[e.createElementVNode("div",F,e.toDisplayString(l.name),1)],4))),128))])):e.createCommentVNode("",!0)]))),128))],512),e.createElementVNode("div",{onScroll:q,class:"flex-1 overflow-auto relative select-none"},[_.value!==null&&f.showToday?(e.openBlock(),e.createElementBlock("div",{key:0,class:"absolute top-0 bottom-0 z-10 pointer-events-none border-l-2 border-orange-400",style:e.normalizeStyle({left:_.value+"px",width:r+"px"})},[...t[2]||(t[2]=[e.createElementVNode("div",{class:"absolute -top-1 -left-[6px] w-0 h-0 border-l-[5px] border-l-transparent border-r-[5px] border-r-transparent border-t-[6px] border-t-orange-400"},null,-1),e.createElementVNode("div",{class:"absolute top-2 left-2 px-1.5 py-0.5 bg-orange-400 text-[10px] text-white rounded shadow-sm opacity-80 whitespace-nowrap"}," 今天 ",-1)])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"absolute inset-0 pointer-events-none",style:e.normalizeStyle(W.value)},null,4),e.createElementVNode("div",{style:e.normalizeStyle({width:x.value+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.id},[e.createElementVNode("div",{class:"relative border-b border-[#e8e8e8]",style:e.normalizeStyle({height:c+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A.value[o.id],(l,d)=>e.renderSlot(n.$slots,"count",{key:d,item:o,date:d,count:l,style:e.normalizeStyle({left:S(d)+"px",width:r+"px",height:c+"px"})},()=>[e.createElementVNode("div",{class:"absolute top-0 flex items-center justify-center text-sm",style:e.normalizeStyle({left:S(d)+"px",width:r+"px",height:c+"px",contentVisibility:"auto",containIntrinsicSize:`${r}px ${c}px`})},e.toDisplayString(l),5)],!0)),128))],4),o.expanded?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(o.tasks,l=>(e.openBlock(),e.createElementBlock("div",{key:l.id,class:"relative border-b border-[#e8e8e8] overflow-hidden",style:e.normalizeStyle({height:c+"px"})},[m(l)?e.renderSlot(n.$slots,"task",{key:0,style:e.normalizeStyle({left:m(l).left+"px",width:m(l).width+"px",position:"absolute"}),task:l},()=>[e.createElementVNode("div",{class:"absolute bg-slate-400 top-2 bottom-2 rounded-md shadow-sm flex items-center px-3 text-[11px] text-white font-medium cursor-pointer hover:shadow-lg hover:-translate-y-0.5 transition-all duration-200",style:e.normalizeStyle({left:m(l).left+"px",width:m(l).width+"px",backgroundColor:l.color})},[e.createElementVNode("span",P,e.toDisplayString(l.name),1)],4)],!0):e.createCommentVNode("",!0)],4))),128)):e.createCommentVNode("",!0)],64))),128))],4)],32)])])]))}}),[["__scopeId","data-v-815cd186"]]),M="0.1.0",H=()=>{console.log("Gantt Core Initialized")};s.GANTT_VERSION=M,s.GanttChart=j,s.setupGantt=H,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@ollap/gantt-vue3",
3
+ "version": "0.1.2",
4
+ "type": "module",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "main": "./dist/gantt-vue3.umd.cjs",
9
+ "module": "./dist/gantt-vue3.js",
10
+ "types": "./dist/gantt-vue3.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/gantt-vue3.d.ts",
14
+ "import": "./dist/gantt-vue3.js",
15
+ "require": "./dist/gantt-vue3.umd.cjs"
16
+ },
17
+ "./dist/gantt-vue3.css": "./dist/gantt-vue3.css"
18
+ },
19
+ "scripts": {
20
+ "dev": "vite build --watch",
21
+ "build": "vite build",
22
+ "type-check": "vue-tsc --build"
23
+ },
24
+ "peerDependencies": {
25
+ "vue": "^3.5.26"
26
+ },
27
+ "devDependencies": {
28
+ "@vitejs/plugin-vue": "^6.0.3",
29
+ "@vitejs/plugin-vue-jsx": "^5.1.3",
30
+ "typescript": "~5.9.3",
31
+ "vite": "^6.0.0",
32
+ "vite-plugin-dts": "^4.5.4",
33
+ "vue": "^3.5.26",
34
+ "vue-tsc": "^3.2.1"
35
+ }
36
+ }