@cpsoft13/z-agent-ui 0.2.1 → 0.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.
- package/bin/lines-baseline.json +1 -15
- package/bin/text-baseline.json +1 -2
- package/dist/build-info.json +2 -2
- package/dist/components/context-menu/ContextMenu.js +7 -7
- package/dist/components/context-menu/ContextMenu.js.map +1 -1
- package/dist/components/date-range/DateRange.js +4 -4
- package/dist/components/date-range/DateRange.js.map +1 -1
- package/dist/components/datepicker/Datepicker.js +207 -332
- package/dist/components/datepicker/Datepicker.js.map +1 -1
- package/dist/components/datepicker/datepicker-keyboard.js +66 -0
- package/dist/components/datepicker/datepicker-keyboard.js.map +1 -0
- package/dist/components/datepicker/datepicker-panel-render.js +78 -0
- package/dist/components/datepicker/datepicker-panel-render.js.map +1 -0
- package/dist/components/form/Form.js +69 -47
- package/dist/components/form/Form.js.map +1 -1
- package/dist/components/form/form-context.js +9 -0
- package/dist/components/form/form-context.js.map +1 -0
- package/dist/components/form.js +2 -0
- package/dist/components/form.js.map +1 -1
- package/dist/components/menu/Menu.js +27 -27
- package/dist/components/menu/Menu.js.map +1 -1
- package/dist/components/popover/Popover.js +1 -1
- package/dist/components/popover/Popover.js.map +1 -1
- package/dist/components/select/Select.js +235 -351
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/select/option-search.js +49 -0
- package/dist/components/select/option-search.js.map +1 -0
- package/dist/components/select/select-render.js +75 -0
- package/dist/components/select/select-render.js.map +1 -0
- package/dist/components/select/selection-strategy.js +151 -0
- package/dist/components/select/selection-strategy.js.map +1 -0
- package/dist/components/time-picker/TimePicker.js +1 -1
- package/dist/components/time-picker/TimePicker.js.map +1 -1
- package/dist/components/tooltip/Tooltip.js +16 -16
- package/dist/components/tooltip/Tooltip.js.map +1 -1
- package/dist/core/BaseElement.js +96 -77
- package/dist/core/BaseElement.js.map +1 -1
- package/dist/core/context.js +68 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/controller.js +2 -0
- package/dist/core/controller.js.map +1 -0
- package/dist/core/public.js +35 -30
- package/dist/core/public.js.map +1 -1
- package/dist/core.js +95 -90
- package/dist/core.js.map +1 -1
- package/dist/doc/doc-template-editor-core.js +12 -11
- package/dist/doc/doc-template-editor-core.js.map +1 -1
- package/dist/doc/doc-template-editor-panel.css.js +202 -0
- package/dist/doc/doc-template-editor-panel.css.js.map +1 -0
- package/dist/doc/doc-template-editor.css.js +1 -200
- package/dist/doc/doc-template-editor.css.js.map +1 -1
- package/dist/flow/Flow.js +104 -195
- package/dist/flow/Flow.js.map +1 -1
- package/dist/flow/flow-keyboard-controller.js +101 -0
- package/dist/flow/flow-keyboard-controller.js.map +1 -0
- package/dist/primitives/overlay/floatingPanel.js +6 -2
- package/dist/primitives/overlay/floatingPanel.js.map +1 -1
- package/dist/report/chart/Chart.js +271 -761
- package/dist/report/chart/Chart.js.map +1 -1
- package/dist/report/chart/chart-brush-controller.js +187 -0
- package/dist/report/chart/chart-brush-controller.js.map +1 -0
- package/dist/report/chart/chart-layout-pipeline.js +158 -0
- package/dist/report/chart/chart-layout-pipeline.js.map +1 -0
- package/dist/report/chart/chart-zoom.js +79 -0
- package/dist/report/chart/chart-zoom.js.map +1 -0
- package/dist/report/chart/geometry/build.js +41 -26
- package/dist/report/chart/geometry/build.js.map +1 -1
- package/dist/report/chart/geometry/extra-flow-dist.js +283 -0
- package/dist/report/chart/geometry/extra-flow-dist.js.map +1 -0
- package/dist/report/chart/geometry/extra-radial-grid.js +280 -0
- package/dist/report/chart/geometry/extra-radial-grid.js.map +1 -0
- package/dist/report/chart/geometry/extra-shared.js +36 -0
- package/dist/report/chart/geometry/extra-shared.js.map +1 -0
- package/dist/report/chart/geometry/extra.js +20 -583
- package/dist/report/chart/geometry/extra.js.map +1 -1
- package/dist/report/chart/geometry/registry.js +20 -0
- package/dist/report/chart/geometry/registry.js.map +1 -0
- package/dist/report/chart.js +12 -6
- package/dist/report/chart.js.map +1 -1
- package/dist/report/gantt/Gantt.js +199 -308
- package/dist/report/gantt/Gantt.js.map +1 -1
- package/dist/report/gantt/gantt-bars.css.js +247 -0
- package/dist/report/gantt/gantt-bars.css.js.map +1 -0
- package/dist/report/gantt/gantt-edit-controller.js +94 -0
- package/dist/report/gantt/gantt-edit-controller.js.map +1 -0
- package/dist/report/gantt/gantt.css.js +0 -272
- package/dist/report/gantt/gantt.css.js.map +1 -1
- package/dist/report/table/ReportTable.js +336 -493
- package/dist/report/table/ReportTable.js.map +1 -1
- package/dist/report/table/report-table-config.css.js +172 -0
- package/dist/report/table/report-table-config.css.js.map +1 -0
- package/dist/report/table/report-table-types.js.map +1 -1
- package/dist/report/table/report-table.css.js +0 -176
- package/dist/report/table/report-table.css.js.map +1 -1
- package/dist/report/table/table-cell-registry.js +29 -0
- package/dist/report/table/table-cell-registry.js.map +1 -0
- package/dist/report/table/table-keyboard-controller.js +96 -0
- package/dist/report/table/table-keyboard-controller.js.map +1 -0
- package/dist/report/table/table-pipeline.js +36 -0
- package/dist/report/table/table-pipeline.js.map +1 -0
- package/dist/report/table/table-render.js +97 -96
- package/dist/report/table/table-render.js.map +1 -1
- package/dist/report/table/table-scroll-controller.js +33 -0
- package/dist/report/table/table-scroll-controller.js.map +1 -0
- package/dist/report/table.js +7 -2
- package/dist/report/table.js.map +1 -1
- package/dist/report.js +39 -28
- package/dist/report.js.map +1 -1
- package/dist/types/components/datepicker/Datepicker.d.ts +1 -109
- package/dist/types/components/datepicker/datepicker-keyboard.d.ts +21 -0
- package/dist/types/components/datepicker/datepicker-panel-render.d.ts +25 -0
- package/dist/types/components/form/Form.d.ts +7 -2
- package/dist/types/components/form/form-context.d.ts +11 -0
- package/dist/types/components/form/index.d.ts +1 -1
- package/dist/types/components/select/Select.d.ts +7 -110
- package/dist/types/components/select/option-search.d.ts +38 -0
- package/dist/types/components/select/select-render.d.ts +39 -0
- package/dist/types/components/select/selection-strategy.d.ts +86 -0
- package/dist/types/core/BaseElement.d.ts +7 -1
- package/dist/types/core/context.d.ts +66 -0
- package/dist/types/core/controller.d.ts +22 -0
- package/dist/types/core/public.d.ts +2 -0
- package/dist/types/flow/Flow.d.ts +3 -76
- package/dist/types/flow/flow-keyboard-controller.d.ts +35 -0
- package/dist/types/primitives/overlay/floatingPanel.d.ts +2 -0
- package/dist/types/report/chart/Chart.d.ts +2 -245
- package/dist/types/report/chart/chart-brush-controller.d.ts +59 -0
- package/dist/types/report/chart/chart-layout-pipeline.d.ts +42 -0
- package/dist/types/report/chart/chart-zoom.d.ts +12 -0
- package/dist/types/report/chart/geometry/build.d.ts +2 -0
- package/dist/types/report/chart/geometry/extra-flow-dist.d.ts +6 -0
- package/dist/types/report/chart/geometry/extra-radial-grid.d.ts +6 -0
- package/dist/types/report/chart/geometry/extra-shared.d.ts +24 -0
- package/dist/types/report/chart/geometry/extra.d.ts +2 -34
- package/dist/types/report/chart/geometry/registry.d.ts +26 -0
- package/dist/types/report/chart/index.d.ts +1 -0
- package/dist/types/report/gantt/Gantt.d.ts +7 -97
- package/dist/types/report/gantt/gantt-edit-controller.d.ts +34 -0
- package/dist/types/report/table/ReportTable.d.ts +9 -180
- package/dist/types/report/table/index.d.ts +1 -0
- package/dist/types/report/table/report-table-types.d.ts +2 -0
- package/dist/types/report/table/table-cell-registry.d.ts +17 -0
- package/dist/types/report/table/table-keyboard-controller.d.ts +30 -0
- package/dist/types/report/table/table-pipeline.d.ts +33 -0
- package/dist/types/report/table/table-scroll-controller.d.ts +25 -0
- package/dist/z-agent-ui.js +35 -30
- package/dist/z-agent-ui.js.map +1 -1
- package/package.json +1 -1
- package/registry/component-manifest.json +39 -7
- package/src/components/context-menu/ContextMenu.ts +1 -1
- package/src/components/date-range/DateRange.ts +1 -1
- package/src/components/datepicker/Datepicker.ts +99 -417
- package/src/components/datepicker/datepicker-keyboard.ts +94 -0
- package/src/components/datepicker/datepicker-panel-render.ts +169 -0
- package/src/components/form/Form.ts +39 -11
- package/src/components/form/form-context.ts +11 -0
- package/src/components/form/index.ts +1 -1
- package/src/components/menu/Menu.ts +1 -1
- package/src/components/popover/Popover.ts +1 -1
- package/src/components/select/Select.ts +140 -525
- package/src/components/select/option-search.ts +114 -0
- package/src/components/select/select-render.ts +161 -0
- package/src/components/select/selection-strategy.ts +245 -0
- package/src/components/time-picker/TimePicker.ts +1 -1
- package/src/components/tooltip/Tooltip.ts +1 -1
|
@@ -1,35 +1,31 @@
|
|
|
1
|
-
import { BaseElement as
|
|
2
|
-
import { property as
|
|
1
|
+
import { BaseElement as p } from "../../core/BaseElement.js";
|
|
2
|
+
import { property as n } from "../../core/decorators.js";
|
|
3
3
|
import "../../core/i18n.js";
|
|
4
4
|
import "../../core/date/presets.js";
|
|
5
|
-
import
|
|
6
|
-
import { defineElement as
|
|
7
|
-
import {
|
|
8
|
-
import { dateCommitFor as w } from "./drag-controller.js";
|
|
9
|
-
import { GANTT_STATUS_ID as k, renderGanttView as v } from "./gantt-view.js";
|
|
5
|
+
import "../../core/copy.js";
|
|
6
|
+
import { defineElement as g } from "../../core/define.js";
|
|
7
|
+
import { renderGanttView as y } from "./gantt-view.js";
|
|
10
8
|
import "../../primitives/portal/Portal.js";
|
|
11
9
|
import "../../primitives/position/Position.js";
|
|
12
|
-
import { LongPressController as
|
|
13
|
-
import { GanttScrollController as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
import { LongPressController as m } from "../../primitives/long-press/LongPressController.js";
|
|
11
|
+
import { GanttScrollController as w } from "./scroll-controller.js";
|
|
12
|
+
import { GanttEditController as f } from "./gantt-edit-controller.js";
|
|
13
|
+
import { eventChain as l, GanttDragSession as k, wheelZoomStep as C, resolvePointerHit as v, handleNavKey as W, ZOOM_STEP as _, clampDayWidth as d, zoomScrollLeft as b, nextRowIndex as I, MIN_DAY_WIDTH as x } from "./gantt-interaction.js";
|
|
14
|
+
import { GanttContextMenu as S, fireContextMenuAt as D } from "./gantt-context-menu.js";
|
|
15
|
+
import { diffDays as T, parseDate as M, todayStart as L } from "./date.js";
|
|
16
|
+
import { getVisibleRange as A, dateToPixels as H } from "./layout.js";
|
|
17
|
+
import { DEFAULT_COLUMNS as P, listTotalWidth as E } from "./left-list.js";
|
|
18
|
+
import { DEFAULT_DAY_WIDTH as B } from "./timeline.js";
|
|
19
|
+
import O from "./gantt.css.js";
|
|
20
|
+
import R from "./gantt-bars.css.js";
|
|
21
|
+
var q = Object.defineProperty, h = (u, e, t, s) => {
|
|
22
|
+
for (var i = void 0, r = u.length - 1, a; r >= 0; r--)
|
|
23
|
+
(a = u[r]) && (i = a(e, t, i) || i);
|
|
24
|
+
return i && q(e, t, i), i;
|
|
25
25
|
};
|
|
26
|
-
const
|
|
27
|
-
function g(d, t) {
|
|
28
|
-
return d.replace(/\{(\w+)\}/g, (e, s) => t[s] ?? "");
|
|
29
|
-
}
|
|
30
|
-
const p = class p extends f {
|
|
26
|
+
const U = ["day", "week", "month", "quarter"], c = class c extends p {
|
|
31
27
|
constructor() {
|
|
32
|
-
super(
|
|
28
|
+
super(), this.data = null, this.columns = [], this.selectedId = null, this.viewMode = "day", this.columnWidth = 0, this.rowHeight = 48, this.headerHeight = 60, this.today = "", this.showWeekends = !0, this.showToday = !0, this.showCriticalPath = !1, this.autoSchedule = !1, this.readonly = !1, this.menuActions = null, this.value = "", this._lastValueRaw = null, this._lastViewMode = null, this._viewChangePending = !1, this._dayWidth = null, this._rowsCache = [], this._treeCache = null, this._rangeCache = null, this._chartOpts = null, this._scroll = new w(() => {
|
|
33
29
|
var t;
|
|
34
30
|
return {
|
|
35
31
|
rowHeight: this.rowHeight,
|
|
@@ -39,19 +35,21 @@ const p = class p extends f {
|
|
|
39
35
|
chartOpts: this._chartOpts,
|
|
40
36
|
selectedId: this.selectedId
|
|
41
37
|
};
|
|
42
|
-
}), this._menu = new
|
|
43
|
-
chain: (t) =>
|
|
38
|
+
}), this._menu = new S({
|
|
39
|
+
chain: (t) => l(t, this),
|
|
44
40
|
taskById: (t) => this.getTaskById(t),
|
|
45
41
|
menuActions: () => this.menuActions,
|
|
46
42
|
liveData: () => this._data(),
|
|
47
43
|
today: () => this._today(),
|
|
48
44
|
dragHost: () => this._host,
|
|
49
|
-
emit: (t,
|
|
45
|
+
emit: (t, s) => this.emit(t, s),
|
|
50
46
|
dispatch: (t) => this.dispatchEvent(t),
|
|
51
47
|
clearSelectionOf: (t) => {
|
|
52
48
|
this.selectedId === t && (this.selectedId = null);
|
|
53
49
|
}
|
|
54
|
-
}), this._lp = new
|
|
50
|
+
}), this._lp = new m({
|
|
51
|
+
onLongPress: (t, s) => D(this.shadowRoot, t, s)
|
|
52
|
+
}), this._dragSession = new k({
|
|
55
53
|
body: () => this._scroll.bodyEl,
|
|
56
54
|
rows: () => this._rowsCache,
|
|
57
55
|
range: () => this._rangeCache,
|
|
@@ -60,33 +58,33 @@ const p = class p extends f {
|
|
|
60
58
|
showWeekends: () => this.showWeekends,
|
|
61
59
|
root: () => this.shadowRoot,
|
|
62
60
|
rect: () => this.getBoundingClientRect(),
|
|
63
|
-
chain: (t) =>
|
|
61
|
+
chain: (t) => l(t, this),
|
|
64
62
|
host: () => this._host,
|
|
65
63
|
requestUpdate: () => this.requestUpdate()
|
|
66
64
|
}), this._onWheel = (t) => {
|
|
67
|
-
const
|
|
68
|
-
|
|
65
|
+
const s = C(t);
|
|
66
|
+
s !== null && (t.preventDefault(), this._scaleDayWidth(s, t.clientX - this.getBoundingClientRect().left));
|
|
69
67
|
}, this._onPointerDown = (t) => {
|
|
70
68
|
t.pointerType === "touch" ? this._lp.arm(t.clientX, t.clientY) : this._lp.cancel();
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
this.toggleExpand(
|
|
69
|
+
const s = v(l(t, this));
|
|
70
|
+
if (s.expandId) {
|
|
71
|
+
this.toggleExpand(s.expandId);
|
|
74
72
|
return;
|
|
75
73
|
}
|
|
76
|
-
if (
|
|
77
|
-
this._lp.cancel(), this._select(
|
|
74
|
+
if (s.modeEl && s.mode && !this.readonly && s.dragTaskId && this._dragSession.begin(t, s.modeEl, s.mode, s.dragTaskId)) {
|
|
75
|
+
this._lp.cancel(), this._select(s.dragTaskId);
|
|
78
76
|
return;
|
|
79
77
|
}
|
|
80
|
-
this._select(
|
|
78
|
+
this._select(s.selectId);
|
|
81
79
|
}, this._onKeyDown = (t) => {
|
|
82
|
-
|
|
83
|
-
select: (
|
|
84
|
-
move: (
|
|
85
|
-
scrollBy: (
|
|
86
|
-
jump: (
|
|
87
|
-
toggle: (
|
|
88
|
-
nudge: (
|
|
89
|
-
nudgeProgress: (
|
|
80
|
+
W(t, {
|
|
81
|
+
select: (s) => this._select(s),
|
|
82
|
+
move: (s) => this._moveSelection(s),
|
|
83
|
+
scrollBy: (s) => this._scroll.nudgeScrollLeft(s),
|
|
84
|
+
jump: (s) => this._jumpSelection(s),
|
|
85
|
+
toggle: (s) => this._toggleCurrent(s),
|
|
86
|
+
nudge: (s, i) => this.nudge(s, i),
|
|
87
|
+
nudgeProgress: (s) => this.nudgeProgress(s),
|
|
90
88
|
toggleLink: () => this.toggleLink(),
|
|
91
89
|
commitLink: () => this.commitLink(),
|
|
92
90
|
cancelLink: () => this.cancelLink()
|
|
@@ -94,65 +92,63 @@ const p = class p extends f {
|
|
|
94
92
|
}, this._onContextMenu = (t) => {
|
|
95
93
|
this._menu.open(t);
|
|
96
94
|
};
|
|
95
|
+
const e = this;
|
|
96
|
+
this._edit = this.addController(
|
|
97
|
+
new f({
|
|
98
|
+
get shadowRoot() {
|
|
99
|
+
return e.shadowRoot;
|
|
100
|
+
},
|
|
101
|
+
get readonly() {
|
|
102
|
+
return e.readonly;
|
|
103
|
+
},
|
|
104
|
+
get selectedId() {
|
|
105
|
+
return e.selectedId;
|
|
106
|
+
},
|
|
107
|
+
get showWeekends() {
|
|
108
|
+
return e.showWeekends;
|
|
109
|
+
},
|
|
110
|
+
getTaskById: (t) => e.getTaskById(t),
|
|
111
|
+
liveData: () => e.liveData(),
|
|
112
|
+
dragHost: () => e._host,
|
|
113
|
+
requestUpdate: () => e.requestUpdate()
|
|
114
|
+
})
|
|
115
|
+
);
|
|
97
116
|
}
|
|
98
|
-
// ── 生命周期 ─────────────────────────────────────────
|
|
99
117
|
connectedCallback() {
|
|
100
|
-
super.connectedCallback(), this.
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
* 焦点转发到真正带角色的那个节点(shadow 内的 tree)。
|
|
104
|
-
*
|
|
105
|
-
* [WHY 需要它] 宿主现在自己不可聚焦(`tabIndex` 会让 Tab 序穿透,但见上一段:
|
|
106
|
-
* 宿主的 shadow 子树在被 `tabindex="-1"` 时整棵消失)。测试与宿主代码里的
|
|
107
|
-
* `gantt.focus()` 仍应表示「把焦点交给这个甘特」,与 `ZRadio.focus()` 同款转发。
|
|
108
|
-
*/
|
|
109
|
-
focus(t) {
|
|
118
|
+
super.connectedCallback(), this.listen(this, "pointerdown", this._onPointerDown), this.listen(this, "keydown", this._onKeyDown), this.listen(this, "wheel", this._onWheel, { passive: !1 }), this.listen(this, "contextmenu", this._onContextMenu);
|
|
119
|
+
}
|
|
120
|
+
focus(e) {
|
|
110
121
|
var s;
|
|
111
|
-
const
|
|
112
|
-
|
|
122
|
+
const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector(".z-gantt__list-body");
|
|
123
|
+
t ? t.focus(e) : super.focus(e);
|
|
113
124
|
}
|
|
114
125
|
disconnectedCallback() {
|
|
115
|
-
this.
|
|
126
|
+
this._scroll.detach(), this._lp.cancel(), this._dragSession.abort(), this._menu.close(), super.disconnectedCallback();
|
|
116
127
|
}
|
|
117
128
|
willUpdate() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (t !== this._lastValueRaw && (this._lastValueRaw = t, t))
|
|
129
|
+
const e = this.value;
|
|
130
|
+
if (e !== this._lastValueRaw && (this._lastValueRaw = e, e))
|
|
121
131
|
try {
|
|
122
|
-
const
|
|
123
|
-
|
|
132
|
+
const t = JSON.parse(e);
|
|
133
|
+
t && Array.isArray(t.tasks) && (this.__zui_prop_data = t);
|
|
124
134
|
} catch {
|
|
125
135
|
}
|
|
126
136
|
this._lastViewMode !== this.viewMode && (this._lastViewMode = this.viewMode, this._dayWidth = null, this._emitViewChange());
|
|
127
137
|
}
|
|
128
138
|
updated() {
|
|
129
|
-
|
|
130
|
-
if (this._scroll.attach(this.shadowRoot), this._syncActiveDescendant(), this._announceMsg != null) {
|
|
131
|
-
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector(`#${k}`);
|
|
132
|
-
e && (e.textContent = this._announceMsg), this._announceMsg = null;
|
|
133
|
-
}
|
|
139
|
+
this._scroll.attach(this.shadowRoot), this._syncActiveDescendant();
|
|
134
140
|
}
|
|
135
|
-
/**
|
|
136
|
-
* 把「当前项」指给读屏:`aria-activedescendant` 写在**与 treeitem 同树的**
|
|
137
|
-
* `.z-gantt__list-body` 上,指向当前渲染出来的那一行。
|
|
138
|
-
*
|
|
139
|
-
* [WHY 必须在 updated() 里做,不能在键按下时做] 行是虚拟滚动的:`_moveSelection`
|
|
140
|
-
* 先改 `selectedId`、再 `ensureRowVisible`,真正那行 DOM 要等这一次渲染才存在。
|
|
141
|
-
* 按键时就写 IDREF,指向的是**还没出生的节点** —— 浏览器对解析不到的 IDREF 是
|
|
142
|
-
* 静默忽略,读屏一个字都不念,而界面上高亮一切正常。
|
|
143
|
-
*/
|
|
144
141
|
_syncActiveDescendant() {
|
|
145
142
|
var i;
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
148
|
-
const s =
|
|
149
|
-
s && s.id ?
|
|
143
|
+
const e = this.selectedId, t = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".z-gantt__list-body");
|
|
144
|
+
if (!t) return;
|
|
145
|
+
const s = e ? Array.from(t.querySelectorAll(".z-gantt__tr")).find((r) => r.dataset.taskId === e) : null;
|
|
146
|
+
s && s.id ? t.setAttribute("aria-activedescendant", s.id) : t.removeAttribute("aria-activedescendant");
|
|
150
147
|
}
|
|
151
|
-
// ── render ───────────────────────────────────────────
|
|
152
148
|
render() {
|
|
153
|
-
var
|
|
149
|
+
var t;
|
|
154
150
|
this._scroll.captureScroll();
|
|
155
|
-
const
|
|
151
|
+
const e = y({
|
|
156
152
|
data: this._data(),
|
|
157
153
|
columns: this._resolvedColumns(),
|
|
158
154
|
today: this._today(),
|
|
@@ -166,305 +162,200 @@ const p = class p extends f {
|
|
|
166
162
|
selectedId: this.selectedId,
|
|
167
163
|
editable: !this.readonly,
|
|
168
164
|
pendingScrollTop: this._scroll.pendingScrollTop ?? 0,
|
|
169
|
-
bodyClientHeight: ((
|
|
170
|
-
windowFor: (s, i,
|
|
165
|
+
bodyClientHeight: ((t = this._scroll.bodyEl) == null ? void 0 : t.clientHeight) ?? 0,
|
|
166
|
+
windowFor: (s, i, r) => this._scroll.windowFor(s, i, r)
|
|
171
167
|
});
|
|
172
|
-
return this._rowsCache =
|
|
168
|
+
return this._rowsCache = e.rows, this._treeCache = e.tree, this._rangeCache = e.range, this._chartOpts = e.chartOpts, this._scroll.setWindow(e.winStart, e.winEnd), e.html;
|
|
173
169
|
}
|
|
174
|
-
// ── Public API ───────────────────────────────────────
|
|
175
|
-
/** px/天(供测试与外部读取当前解析值) */
|
|
176
170
|
get dayWidth() {
|
|
177
171
|
return this._resolveDayWidth();
|
|
178
172
|
}
|
|
179
173
|
zoomIn() {
|
|
180
|
-
this._scaleDayWidth(
|
|
174
|
+
this._scaleDayWidth(_, null);
|
|
181
175
|
}
|
|
182
176
|
zoomOut() {
|
|
183
|
-
this._scaleDayWidth(1 /
|
|
177
|
+
this._scaleDayWidth(1 / _, null);
|
|
184
178
|
}
|
|
185
|
-
/** 缩放至全部任务恰好可见 */
|
|
186
179
|
fit() {
|
|
187
|
-
const
|
|
188
|
-
if (!
|
|
180
|
+
const e = this._data().tasks;
|
|
181
|
+
if (!e.length) {
|
|
189
182
|
this._dayWidth = null, this.requestUpdate();
|
|
190
183
|
return;
|
|
191
184
|
}
|
|
192
|
-
const
|
|
193
|
-
|
|
185
|
+
const t = A(e, this.showToday ? this._today() : null, 2), s = Math.max(T(t.start, t.end), 1), i = this.clientWidth - this._listWidth();
|
|
186
|
+
this._dayWidth = i <= 0 ? d(x) : d(Math.floor((i - 20) / s)), this.requestUpdate();
|
|
194
187
|
}
|
|
195
|
-
getTaskById(
|
|
196
|
-
return this._data().tasks.find((
|
|
188
|
+
getTaskById(e) {
|
|
189
|
+
return this._data().tasks.find((t) => t && t.id === e) ?? null;
|
|
197
190
|
}
|
|
198
|
-
toggleExpand(
|
|
199
|
-
const
|
|
200
|
-
if (!
|
|
201
|
-
const s =
|
|
202
|
-
|
|
191
|
+
toggleExpand(e) {
|
|
192
|
+
const t = this.getTaskById(e);
|
|
193
|
+
if (!t) return;
|
|
194
|
+
const s = t.is_expanded === !1;
|
|
195
|
+
t.is_expanded = s, this.requestUpdate(), this.emit("z-gantt-expand", { id: e, expanded: s });
|
|
203
196
|
}
|
|
204
|
-
expandAll(
|
|
205
|
-
const
|
|
197
|
+
expandAll(e) {
|
|
198
|
+
const t = this._treeCache;
|
|
206
199
|
for (const s of this._data().tasks) {
|
|
207
200
|
if (!s) continue;
|
|
208
|
-
const i =
|
|
209
|
-
i && i.length && (s.is_expanded =
|
|
201
|
+
const i = t == null ? void 0 : t.childrenOf.get(s.id);
|
|
202
|
+
i && i.length && (s.is_expanded = e);
|
|
210
203
|
}
|
|
211
204
|
this.requestUpdate();
|
|
212
205
|
}
|
|
213
|
-
scrollToTask(
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
216
|
-
s.scrollTop = Math.max(0,
|
|
217
|
-
const i =
|
|
206
|
+
scrollToTask(e) {
|
|
207
|
+
const t = this._rowsCache.find((r) => r.task.id === e), s = this._scroll.bodyEl;
|
|
208
|
+
if (!t || !s) return;
|
|
209
|
+
s.scrollTop = Math.max(0, t.index * this.rowHeight - s.clientHeight / 2);
|
|
210
|
+
const i = t.isMilestone ? t.x : t.x + t.width / 2;
|
|
218
211
|
s.scrollLeft = Math.max(0, i - s.clientWidth / 2);
|
|
219
212
|
}
|
|
220
213
|
scrollToToday() {
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
223
|
-
const s =
|
|
224
|
-
|
|
214
|
+
const e = this._scroll.bodyEl, t = this._rangeCache;
|
|
215
|
+
if (!e || !t) return;
|
|
216
|
+
const s = H(this._today(), t.start, this._resolveDayWidth());
|
|
217
|
+
e.scrollLeft = Math.max(0, s - e.clientWidth / 2);
|
|
225
218
|
}
|
|
226
219
|
getData() {
|
|
227
|
-
const
|
|
228
|
-
return { tasks:
|
|
220
|
+
const e = this._data();
|
|
221
|
+
return { tasks: e.tasks, dependencies: e.dependencies ? [...e.dependencies] : [] };
|
|
229
222
|
}
|
|
230
|
-
setData(
|
|
231
|
-
this.value = "", this._lastValueRaw = "", this.data = { tasks:
|
|
223
|
+
setData(e) {
|
|
224
|
+
this.value = "", this._lastValueRaw = "", this.data = { tasks: e.tasks, dependencies: e.dependencies ?? [] };
|
|
232
225
|
}
|
|
233
226
|
refresh() {
|
|
234
227
|
this.requestUpdate();
|
|
235
228
|
}
|
|
236
|
-
/** drag-apply 宿主接口:暴露活模型(getData 会拷贝 dependencies 数组,写回丢失) */
|
|
237
229
|
liveData() {
|
|
238
230
|
return this._data();
|
|
239
231
|
}
|
|
240
|
-
|
|
232
|
+
nudge(e, t) {
|
|
233
|
+
return this._edit.nudge(e, t);
|
|
234
|
+
}
|
|
235
|
+
nudgeProgress(e) {
|
|
236
|
+
return this._edit.nudgeProgress(e);
|
|
237
|
+
}
|
|
238
|
+
toggleLink() {
|
|
239
|
+
this._edit.toggleLink();
|
|
240
|
+
}
|
|
241
|
+
commitLink() {
|
|
242
|
+
return this._edit.commitLink();
|
|
243
|
+
}
|
|
244
|
+
cancelLink() {
|
|
245
|
+
return this._edit.cancelLink();
|
|
246
|
+
}
|
|
241
247
|
_data() {
|
|
242
|
-
const
|
|
243
|
-
return
|
|
248
|
+
const e = this.data;
|
|
249
|
+
return e && Array.isArray(e.tasks) ? e : { tasks: [], dependencies: [] };
|
|
244
250
|
}
|
|
245
251
|
_today() {
|
|
246
|
-
return
|
|
252
|
+
return M(this.today) ?? L();
|
|
247
253
|
}
|
|
248
254
|
_resolvedColumns() {
|
|
249
|
-
return this.columns.length ? this.columns :
|
|
255
|
+
return this.columns.length ? this.columns : P;
|
|
250
256
|
}
|
|
251
257
|
_listWidth() {
|
|
252
|
-
return
|
|
258
|
+
return E(this._resolvedColumns());
|
|
253
259
|
}
|
|
254
260
|
_resolveDayWidth() {
|
|
255
|
-
const
|
|
261
|
+
const e = U.includes(this.viewMode) ? this.viewMode : "day";
|
|
256
262
|
if (this._dayWidth != null) return this._dayWidth;
|
|
257
263
|
if (this.columnWidth > 0) {
|
|
258
|
-
if (
|
|
259
|
-
if (
|
|
264
|
+
if (e === "day") return this.columnWidth;
|
|
265
|
+
if (e === "week") return this.columnWidth / 7;
|
|
260
266
|
}
|
|
261
|
-
return
|
|
267
|
+
return B[e];
|
|
262
268
|
}
|
|
263
|
-
/** drag-apply 宿主接口注入(ZGantt 结构化满足 DragApplyHost) */
|
|
264
269
|
get _host() {
|
|
265
270
|
return this;
|
|
266
271
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const s = this._resolveDayWidth(), i = _(s * t);
|
|
272
|
+
_scaleDayWidth(e, t) {
|
|
273
|
+
const s = this._resolveDayWidth(), i = d(s * e);
|
|
270
274
|
if (i === s) return;
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
const
|
|
274
|
-
this._scroll.queueScrollLeft(
|
|
275
|
+
const r = this._scroll.bodyEl;
|
|
276
|
+
if (r) {
|
|
277
|
+
const a = t != null ? t - this._listWidth() : r.clientWidth / 2;
|
|
278
|
+
this._scroll.queueScrollLeft(b(a, r.scrollLeft, s, i));
|
|
275
279
|
}
|
|
276
280
|
this._dayWidth = i, this.requestUpdate();
|
|
277
281
|
}
|
|
278
|
-
_select(
|
|
279
|
-
if (this.selectedId !==
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
+
_select(e) {
|
|
283
|
+
if (this.selectedId !== e && (this.selectedId = e, e != null)) {
|
|
284
|
+
const t = this.getTaskById(e);
|
|
285
|
+
t && this.emit("z-gantt-select", { id: e, task: t });
|
|
282
286
|
}
|
|
283
287
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
*
|
|
287
|
-
* [WHY 复用 `dateCommitFor` + `applyCommit`,不另写一套改日期的代码]
|
|
288
|
-
* 拖拽那条路已经把「像素 → 天数 → 吸附工作日 → 按原工期推终点 → 落模型 →
|
|
289
|
-
* 级联顺延 → 发 z-gantt-change」整条链跑顺了。键盘若自己 `task.start_date = …`
|
|
290
|
-
* 再 `emit`,立刻就有第二个定义:周末吸附规则、跨周末工期、auto-schedule 级联
|
|
291
|
-
* 只要有一处漏掉,鼠标和键盘做同一件事会得到不同结果 —— 而且**界面上都正常**。
|
|
292
|
-
*
|
|
293
|
-
* @returns false = 这条任务不能这么调(没有日期 / 里程碑不能缩放 / 已经到边界)
|
|
294
|
-
*/
|
|
295
|
-
nudge(t, e) {
|
|
296
|
-
if (this.readonly || !e) return !1;
|
|
297
|
-
const s = this.selectedId, i = s ? this.getTaskById(s) : null;
|
|
298
|
-
if (!i) return !1;
|
|
299
|
-
const n = w(
|
|
300
|
-
{
|
|
301
|
-
mode: t,
|
|
302
|
-
taskId: i.id,
|
|
303
|
-
startDate: i.start_date != null ? String(i.start_date) : null,
|
|
304
|
-
endDate: i.end_date != null ? String(i.end_date) : null,
|
|
305
|
-
isMilestone: i.is_milestone === !0,
|
|
306
|
-
// 键盘微调只作用于计划条;实际条(real_*)是另一组字段,键位留给后续
|
|
307
|
-
isReal: !1,
|
|
308
|
-
snapWeekends: !this.showWeekends
|
|
309
|
-
},
|
|
310
|
-
e
|
|
311
|
-
);
|
|
312
|
-
return n ? (c(n, this), !0) : !1;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* 键盘改进度(`Alt + ↑/↓`,每次 5%)。
|
|
316
|
-
*
|
|
317
|
-
* [WHY 同样走 applyCommit] 进度条拖拽的最后一步就是 `mode="progress"` 的
|
|
318
|
-
* `DragCommit`;这里直接造同一个载荷,进度钳制与事件全部沿用。
|
|
319
|
-
*/
|
|
320
|
-
nudgeProgress(t) {
|
|
321
|
-
if (this.readonly || !t) return !1;
|
|
322
|
-
const e = this.selectedId, s = e ? this.getTaskById(e) : null;
|
|
323
|
-
if (!s) return !1;
|
|
324
|
-
const i = Number.isFinite(Number(s.progress)) ? Number(s.progress) : 0, n = Math.min(100, Math.max(0, Math.round(i + t)));
|
|
325
|
-
return n === i ? !1 : (c({ mode: "progress", taskId: s.id, progress: n }, this), !0);
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* `Alt + Enter`:把当前项设为连线起点(前置任务)。再按一次(同一项)= 取消。
|
|
329
|
-
*
|
|
330
|
-
* [WHY 不在这里就建依赖] 一条依赖有起点也有终点,一次按键只能确定一端。硬做成
|
|
331
|
-
* 「Alt+Enter 建到上一条/下一条」等于替用户猜目标,猜错了他还得先删掉再重来 ——
|
|
332
|
-
* 而删依赖同样只有鼠标路径。两段式(记住起点 → 上下键选目标 → 回车)没有猜的成分。
|
|
333
|
-
*/
|
|
334
|
-
toggleLink() {
|
|
335
|
-
if (this.readonly) return;
|
|
288
|
+
_toggleCurrent(e) {
|
|
289
|
+
var a;
|
|
336
290
|
const t = this.selectedId;
|
|
337
|
-
if (!t)
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
this.
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
* `z-gantt-connect` 事件 + 去重 + auto-schedule 级联 + `z-gantt-change`」。
|
|
352
|
-
* 键盘自己 push 的话,宿主 `preventDefault()` 拦不住、重复连线会叠两条、
|
|
353
|
-
* 顺延也不触发 —— 三处都只在特定数据下才看得出来。
|
|
354
|
-
*
|
|
355
|
-
* @returns false = 此刻不在连线模式(调用方据此不吞回车)
|
|
356
|
-
*/
|
|
357
|
-
commitLink() {
|
|
358
|
-
const t = this._linkSource;
|
|
359
|
-
if (!t) return !1;
|
|
360
|
-
const e = this.selectedId;
|
|
361
|
-
if (!e)
|
|
362
|
-
return this._announce(h.ganttLinkNoSelection), !0;
|
|
363
|
-
if (e === t)
|
|
364
|
-
return this._announce(h.ganttLinkRejectedSelf), !0;
|
|
365
|
-
if (!this.getTaskById(t))
|
|
366
|
-
return this._linkSource = null, this._announce(h.ganttLinkCancelled), !0;
|
|
367
|
-
if ((this.liveData().dependencies ?? []).some((n) => n.predecessor_id === t && n.successor_id === e))
|
|
368
|
-
return this._linkSource = null, this._announce(h.ganttLinkRejectedDuplicate), !0;
|
|
369
|
-
const i = { from: this._taskName(t), to: this._taskName(e) };
|
|
370
|
-
return this._linkSource = null, c(
|
|
371
|
-
{ mode: "connect", taskId: t, predecessorId: t, successorId: e, connectType: "FS" },
|
|
372
|
-
this
|
|
373
|
-
), this._announce(g(h.ganttLinkDone, i)), !0;
|
|
374
|
-
}
|
|
375
|
-
/** `Esc`:退出连线模式。`false` = 本来就没在连线(调用方据此退回「取消选中」)。 */
|
|
376
|
-
cancelLink() {
|
|
377
|
-
return this._linkSource ? (this._linkSource = null, this._announce(h.ganttLinkCancelled), !0) : !1;
|
|
378
|
-
}
|
|
379
|
-
/** 排队一条播报;渲染后由 `updated()` 写进 live region。 */
|
|
380
|
-
_announce(t) {
|
|
381
|
-
this._announceMsg = t, this.requestUpdate();
|
|
382
|
-
}
|
|
383
|
-
_taskName(t) {
|
|
384
|
-
const e = this.getTaskById(t);
|
|
385
|
-
return String((e == null ? void 0 : e.name) ?? "").trim() || t;
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* ← / → :收起 / 展开当前项。返回 `false` 表示「当前项没有子节点」,由调用方
|
|
389
|
-
* 退回横向滚动(见 `handleNavKey`)。
|
|
390
|
-
*
|
|
391
|
-
* [WHY 走 `toggleExpand` 而不是自己改 `is_expanded`] 那条路径已经处理了「叶子
|
|
392
|
-
* 上写 is_expanded 是噪声字段」「增删行后行高/滚动位置重算」两件事,复制一份
|
|
393
|
-
* 就等于留下两份会漂移的定义。
|
|
394
|
-
*/
|
|
395
|
-
_toggleCurrent(t) {
|
|
396
|
-
var l;
|
|
397
|
-
const e = this.selectedId;
|
|
398
|
-
if (e == null || !(((l = this._treeCache) == null ? void 0 : l.childrenOf.get(e)) ?? []).length) return !1;
|
|
399
|
-
const i = this.getTaskById(e);
|
|
400
|
-
return (i == null ? void 0 : i.is_expanded) !== !1 !== t && this.toggleExpand(e), !0;
|
|
401
|
-
}
|
|
402
|
-
/** Home / End:跳到首行 / 末行(`_moveSelection` 只走相对位移,跳不到)。 */
|
|
403
|
-
_jumpSelection(t) {
|
|
404
|
-
const e = this._rowsCache;
|
|
405
|
-
if (!e.length) return;
|
|
406
|
-
const s = t === "first" ? 0 : e.length - 1;
|
|
407
|
-
e[s].task.id !== this.selectedId && (this._select(e[s].task.id), this._scroll.ensureRowVisible(s));
|
|
408
|
-
}
|
|
409
|
-
_moveSelection(t) {
|
|
410
|
-
const e = M(this._rowsCache, this.selectedId, t);
|
|
411
|
-
e !== -1 && (this._select(this._rowsCache[e].task.id), this._scroll.ensureRowVisible(e));
|
|
412
|
-
}
|
|
413
|
-
// ── 事件 ─────────────────────────────────────────────
|
|
291
|
+
if (t == null || !(((a = this._treeCache) == null ? void 0 : a.childrenOf.get(t)) ?? []).length) return !1;
|
|
292
|
+
const i = this.getTaskById(t);
|
|
293
|
+
return (i == null ? void 0 : i.is_expanded) !== !1 !== e && this.toggleExpand(t), !0;
|
|
294
|
+
}
|
|
295
|
+
_jumpSelection(e) {
|
|
296
|
+
const t = this._rowsCache;
|
|
297
|
+
if (!t.length) return;
|
|
298
|
+
const s = e === "first" ? 0 : t.length - 1;
|
|
299
|
+
t[s].task.id !== this.selectedId && (this._select(t[s].task.id), this._scroll.ensureRowVisible(s));
|
|
300
|
+
}
|
|
301
|
+
_moveSelection(e) {
|
|
302
|
+
const t = I(this._rowsCache, this.selectedId, e);
|
|
303
|
+
t !== -1 && (this._select(this._rowsCache[t].task.id), this._scroll.ensureRowVisible(t));
|
|
304
|
+
}
|
|
414
305
|
_emitViewChange() {
|
|
415
306
|
this._viewChangePending || (this._viewChangePending = !0, queueMicrotask(() => {
|
|
416
307
|
this._viewChangePending = !1, this.isConnected && this.emit("z-gantt-view-change", { mode: this.viewMode });
|
|
417
308
|
}));
|
|
418
309
|
}
|
|
419
310
|
};
|
|
420
|
-
|
|
421
|
-
let o =
|
|
422
|
-
|
|
423
|
-
|
|
311
|
+
c.styles = O + R;
|
|
312
|
+
let o = c;
|
|
313
|
+
h([
|
|
314
|
+
n({ type: Object, attribute: !1 })
|
|
424
315
|
], o.prototype, "data");
|
|
425
|
-
|
|
426
|
-
|
|
316
|
+
h([
|
|
317
|
+
n({ type: Array, attribute: !1 })
|
|
427
318
|
], o.prototype, "columns");
|
|
428
|
-
|
|
429
|
-
|
|
319
|
+
h([
|
|
320
|
+
n({ type: String, attribute: !1 })
|
|
430
321
|
], o.prototype, "selectedId");
|
|
431
|
-
|
|
432
|
-
|
|
322
|
+
h([
|
|
323
|
+
n({ type: String, attribute: "view-mode" })
|
|
433
324
|
], o.prototype, "viewMode");
|
|
434
|
-
|
|
435
|
-
|
|
325
|
+
h([
|
|
326
|
+
n({ type: Boolean, attribute: "column-width" })
|
|
436
327
|
], o.prototype, "columnWidth");
|
|
437
|
-
|
|
438
|
-
|
|
328
|
+
h([
|
|
329
|
+
n({ type: Number, attribute: "row-height" })
|
|
439
330
|
], o.prototype, "rowHeight");
|
|
440
|
-
|
|
441
|
-
|
|
331
|
+
h([
|
|
332
|
+
n({ type: Number, attribute: "header-height" })
|
|
442
333
|
], o.prototype, "headerHeight");
|
|
443
|
-
|
|
444
|
-
|
|
334
|
+
h([
|
|
335
|
+
n({ type: String })
|
|
445
336
|
], o.prototype, "today");
|
|
446
|
-
|
|
447
|
-
|
|
337
|
+
h([
|
|
338
|
+
n({ type: Boolean, attribute: "show-weekends" })
|
|
448
339
|
], o.prototype, "showWeekends");
|
|
449
|
-
|
|
450
|
-
|
|
340
|
+
h([
|
|
341
|
+
n({ type: Boolean, attribute: "show-today" })
|
|
451
342
|
], o.prototype, "showToday");
|
|
452
|
-
|
|
453
|
-
|
|
343
|
+
h([
|
|
344
|
+
n({ type: Boolean, attribute: "show-critical-path" })
|
|
454
345
|
], o.prototype, "showCriticalPath");
|
|
455
|
-
|
|
456
|
-
|
|
346
|
+
h([
|
|
347
|
+
n({ type: Boolean, attribute: "auto-schedule" })
|
|
457
348
|
], o.prototype, "autoSchedule");
|
|
458
|
-
|
|
459
|
-
|
|
349
|
+
h([
|
|
350
|
+
n({ type: Boolean })
|
|
460
351
|
], o.prototype, "readonly");
|
|
461
|
-
|
|
462
|
-
|
|
352
|
+
h([
|
|
353
|
+
n({ type: Array, attribute: !1 })
|
|
463
354
|
], o.prototype, "menuActions");
|
|
464
|
-
|
|
465
|
-
|
|
355
|
+
h([
|
|
356
|
+
n({ type: String })
|
|
466
357
|
], o.prototype, "value");
|
|
467
|
-
|
|
358
|
+
g("z-gantt", o);
|
|
468
359
|
export {
|
|
469
360
|
o as ZGantt
|
|
470
361
|
};
|