@cpsoft13/z-agent-ui 0.2.0 → 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.
Files changed (165) hide show
  1. package/bin/lines-baseline.json +1 -15
  2. package/bin/text-baseline.json +1 -2
  3. package/dist/build-info.json +2 -2
  4. package/dist/components/context-menu/ContextMenu.js +7 -7
  5. package/dist/components/context-menu/ContextMenu.js.map +1 -1
  6. package/dist/components/date-range/DateRange.js +4 -4
  7. package/dist/components/date-range/DateRange.js.map +1 -1
  8. package/dist/components/datepicker/Datepicker.js +207 -332
  9. package/dist/components/datepicker/Datepicker.js.map +1 -1
  10. package/dist/components/datepicker/datepicker-keyboard.js +66 -0
  11. package/dist/components/datepicker/datepicker-keyboard.js.map +1 -0
  12. package/dist/components/datepicker/datepicker-panel-render.js +78 -0
  13. package/dist/components/datepicker/datepicker-panel-render.js.map +1 -0
  14. package/dist/components/form/Form.js +69 -47
  15. package/dist/components/form/Form.js.map +1 -1
  16. package/dist/components/form/form-context.js +9 -0
  17. package/dist/components/form/form-context.js.map +1 -0
  18. package/dist/components/form.js +2 -0
  19. package/dist/components/form.js.map +1 -1
  20. package/dist/components/menu/Menu.js +27 -27
  21. package/dist/components/menu/Menu.js.map +1 -1
  22. package/dist/components/popover/Popover.js +1 -1
  23. package/dist/components/popover/Popover.js.map +1 -1
  24. package/dist/components/select/Select.js +235 -351
  25. package/dist/components/select/Select.js.map +1 -1
  26. package/dist/components/select/option-search.js +49 -0
  27. package/dist/components/select/option-search.js.map +1 -0
  28. package/dist/components/select/select-render.js +75 -0
  29. package/dist/components/select/select-render.js.map +1 -0
  30. package/dist/components/select/selection-strategy.js +151 -0
  31. package/dist/components/select/selection-strategy.js.map +1 -0
  32. package/dist/components/time-picker/TimePicker.js +1 -1
  33. package/dist/components/time-picker/TimePicker.js.map +1 -1
  34. package/dist/components/tooltip/Tooltip.js +16 -16
  35. package/dist/components/tooltip/Tooltip.js.map +1 -1
  36. package/dist/core/BaseElement.js +96 -77
  37. package/dist/core/BaseElement.js.map +1 -1
  38. package/dist/core/context.js +68 -0
  39. package/dist/core/context.js.map +1 -0
  40. package/dist/core/controller.js +2 -0
  41. package/dist/core/controller.js.map +1 -0
  42. package/dist/core/public.js +35 -30
  43. package/dist/core/public.js.map +1 -1
  44. package/dist/core.js +95 -90
  45. package/dist/core.js.map +1 -1
  46. package/dist/doc/doc-template-editor-core.js +12 -11
  47. package/dist/doc/doc-template-editor-core.js.map +1 -1
  48. package/dist/doc/doc-template-editor-panel.css.js +202 -0
  49. package/dist/doc/doc-template-editor-panel.css.js.map +1 -0
  50. package/dist/doc/doc-template-editor.css.js +1 -200
  51. package/dist/doc/doc-template-editor.css.js.map +1 -1
  52. package/dist/flow/Flow.js +104 -195
  53. package/dist/flow/Flow.js.map +1 -1
  54. package/dist/flow/flow-keyboard-controller.js +101 -0
  55. package/dist/flow/flow-keyboard-controller.js.map +1 -0
  56. package/dist/primitives/overlay/floatingPanel.js +6 -2
  57. package/dist/primitives/overlay/floatingPanel.js.map +1 -1
  58. package/dist/report/chart/Chart.js +271 -761
  59. package/dist/report/chart/Chart.js.map +1 -1
  60. package/dist/report/chart/chart-brush-controller.js +187 -0
  61. package/dist/report/chart/chart-brush-controller.js.map +1 -0
  62. package/dist/report/chart/chart-layout-pipeline.js +158 -0
  63. package/dist/report/chart/chart-layout-pipeline.js.map +1 -0
  64. package/dist/report/chart/chart-zoom.js +79 -0
  65. package/dist/report/chart/chart-zoom.js.map +1 -0
  66. package/dist/report/chart/geometry/build.js +41 -26
  67. package/dist/report/chart/geometry/build.js.map +1 -1
  68. package/dist/report/chart/geometry/extra-flow-dist.js +283 -0
  69. package/dist/report/chart/geometry/extra-flow-dist.js.map +1 -0
  70. package/dist/report/chart/geometry/extra-radial-grid.js +280 -0
  71. package/dist/report/chart/geometry/extra-radial-grid.js.map +1 -0
  72. package/dist/report/chart/geometry/extra-shared.js +36 -0
  73. package/dist/report/chart/geometry/extra-shared.js.map +1 -0
  74. package/dist/report/chart/geometry/extra.js +20 -583
  75. package/dist/report/chart/geometry/extra.js.map +1 -1
  76. package/dist/report/chart/geometry/registry.js +20 -0
  77. package/dist/report/chart/geometry/registry.js.map +1 -0
  78. package/dist/report/chart.js +12 -6
  79. package/dist/report/chart.js.map +1 -1
  80. package/dist/report/gantt/Gantt.js +199 -308
  81. package/dist/report/gantt/Gantt.js.map +1 -1
  82. package/dist/report/gantt/gantt-bars.css.js +247 -0
  83. package/dist/report/gantt/gantt-bars.css.js.map +1 -0
  84. package/dist/report/gantt/gantt-edit-controller.js +94 -0
  85. package/dist/report/gantt/gantt-edit-controller.js.map +1 -0
  86. package/dist/report/gantt/gantt.css.js +0 -272
  87. package/dist/report/gantt/gantt.css.js.map +1 -1
  88. package/dist/report/table/ReportTable.js +336 -493
  89. package/dist/report/table/ReportTable.js.map +1 -1
  90. package/dist/report/table/report-table-config.css.js +172 -0
  91. package/dist/report/table/report-table-config.css.js.map +1 -0
  92. package/dist/report/table/report-table-types.js.map +1 -1
  93. package/dist/report/table/report-table.css.js +0 -176
  94. package/dist/report/table/report-table.css.js.map +1 -1
  95. package/dist/report/table/table-cell-registry.js +29 -0
  96. package/dist/report/table/table-cell-registry.js.map +1 -0
  97. package/dist/report/table/table-keyboard-controller.js +96 -0
  98. package/dist/report/table/table-keyboard-controller.js.map +1 -0
  99. package/dist/report/table/table-pipeline.js +36 -0
  100. package/dist/report/table/table-pipeline.js.map +1 -0
  101. package/dist/report/table/table-render.js +97 -96
  102. package/dist/report/table/table-render.js.map +1 -1
  103. package/dist/report/table/table-scroll-controller.js +33 -0
  104. package/dist/report/table/table-scroll-controller.js.map +1 -0
  105. package/dist/report/table.js +7 -2
  106. package/dist/report/table.js.map +1 -1
  107. package/dist/report.js +39 -28
  108. package/dist/report.js.map +1 -1
  109. package/dist/types/components/datepicker/Datepicker.d.ts +1 -109
  110. package/dist/types/components/datepicker/datepicker-keyboard.d.ts +21 -0
  111. package/dist/types/components/datepicker/datepicker-panel-render.d.ts +25 -0
  112. package/dist/types/components/form/Form.d.ts +7 -2
  113. package/dist/types/components/form/form-context.d.ts +11 -0
  114. package/dist/types/components/form/index.d.ts +1 -1
  115. package/dist/types/components/select/Select.d.ts +7 -110
  116. package/dist/types/components/select/option-search.d.ts +38 -0
  117. package/dist/types/components/select/select-render.d.ts +39 -0
  118. package/dist/types/components/select/selection-strategy.d.ts +86 -0
  119. package/dist/types/core/BaseElement.d.ts +7 -1
  120. package/dist/types/core/context.d.ts +66 -0
  121. package/dist/types/core/controller.d.ts +22 -0
  122. package/dist/types/core/public.d.ts +2 -0
  123. package/dist/types/flow/Flow.d.ts +3 -76
  124. package/dist/types/flow/flow-keyboard-controller.d.ts +35 -0
  125. package/dist/types/primitives/overlay/floatingPanel.d.ts +2 -0
  126. package/dist/types/report/chart/Chart.d.ts +2 -245
  127. package/dist/types/report/chart/chart-brush-controller.d.ts +59 -0
  128. package/dist/types/report/chart/chart-layout-pipeline.d.ts +42 -0
  129. package/dist/types/report/chart/chart-zoom.d.ts +12 -0
  130. package/dist/types/report/chart/geometry/build.d.ts +2 -0
  131. package/dist/types/report/chart/geometry/extra-flow-dist.d.ts +6 -0
  132. package/dist/types/report/chart/geometry/extra-radial-grid.d.ts +6 -0
  133. package/dist/types/report/chart/geometry/extra-shared.d.ts +24 -0
  134. package/dist/types/report/chart/geometry/extra.d.ts +2 -34
  135. package/dist/types/report/chart/geometry/registry.d.ts +26 -0
  136. package/dist/types/report/chart/index.d.ts +1 -0
  137. package/dist/types/report/gantt/Gantt.d.ts +7 -97
  138. package/dist/types/report/gantt/gantt-edit-controller.d.ts +34 -0
  139. package/dist/types/report/table/ReportTable.d.ts +9 -180
  140. package/dist/types/report/table/index.d.ts +1 -0
  141. package/dist/types/report/table/report-table-types.d.ts +2 -0
  142. package/dist/types/report/table/table-cell-registry.d.ts +17 -0
  143. package/dist/types/report/table/table-keyboard-controller.d.ts +30 -0
  144. package/dist/types/report/table/table-pipeline.d.ts +33 -0
  145. package/dist/types/report/table/table-scroll-controller.d.ts +25 -0
  146. package/dist/z-agent-ui.js +35 -30
  147. package/dist/z-agent-ui.js.map +1 -1
  148. package/package.json +1 -1
  149. package/registry/component-manifest.json +39 -7
  150. package/src/components/context-menu/ContextMenu.ts +1 -1
  151. package/src/components/date-range/DateRange.ts +1 -1
  152. package/src/components/datepicker/Datepicker.ts +99 -417
  153. package/src/components/datepicker/datepicker-keyboard.ts +94 -0
  154. package/src/components/datepicker/datepicker-panel-render.ts +169 -0
  155. package/src/components/form/Form.ts +39 -11
  156. package/src/components/form/form-context.ts +11 -0
  157. package/src/components/form/index.ts +1 -1
  158. package/src/components/menu/Menu.ts +1 -1
  159. package/src/components/popover/Popover.ts +1 -1
  160. package/src/components/select/Select.ts +140 -525
  161. package/src/components/select/option-search.ts +114 -0
  162. package/src/components/select/select-render.ts +161 -0
  163. package/src/components/select/selection-strategy.ts +245 -0
  164. package/src/components/time-picker/TimePicker.ts +1 -1
  165. package/src/components/tooltip/Tooltip.ts +1 -1
@@ -1,35 +1,31 @@
1
- import { BaseElement as f } from "../../core/BaseElement.js";
2
- import { property as r } from "../../core/decorators.js";
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 { COPY as h } from "../../core/copy.js";
6
- import { defineElement as y } from "../../core/define.js";
7
- import { applyCommit as c } from "./drag-apply.js";
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 C } from "../../primitives/long-press/LongPressController.js";
13
- import { GanttScrollController as S } from "./scroll-controller.js";
14
- import { eventChain as u, GanttDragSession as W, wheelZoomStep as I, resolvePointerHit as b, handleNavKey as x, ZOOM_STEP as m, clampDayWidth as _, zoomScrollLeft as D, nextRowIndex as M, MIN_DAY_WIDTH as L } from "./gantt-interaction.js";
15
- import { GanttContextMenu as T, fireContextMenuAt as E } from "./gantt-context-menu.js";
16
- import { diffDays as A, parseDate as P, todayStart as B } from "./date.js";
17
- import { getVisibleRange as H, dateToPixels as O } from "./layout.js";
18
- import { DEFAULT_COLUMNS as R, listTotalWidth as q } from "./left-list.js";
19
- import { DEFAULT_DAY_WIDTH as N } from "./timeline.js";
20
- import U from "./gantt.css.js";
21
- var V = Object.defineProperty, a = (d, t, e, s) => {
22
- for (var i = void 0, n = d.length - 1, l; n >= 0; n--)
23
- (l = d[n]) && (i = l(t, e, i) || i);
24
- return i && V(t, e, i), i;
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 z = ["day", "week", "month", "quarter"];
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(...arguments), 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._linkSource = null, this._announceMsg = null, this._rangeCache = null, this._chartOpts = null, this._scroll = new S(() => {
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 T({
43
- chain: (t) => u(t, this),
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, e) => this.emit(t, e),
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 C({ onLongPress: (t, e) => E(this.shadowRoot, t, e) }), this._dragSession = new W({
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) => u(t, this),
61
+ chain: (t) => l(t, this),
64
62
  host: () => this._host,
65
63
  requestUpdate: () => this.requestUpdate()
66
64
  }), this._onWheel = (t) => {
67
- const e = I(t);
68
- e !== null && (t.preventDefault(), this._scaleDayWidth(e, t.clientX - this.getBoundingClientRect().left));
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 e = b(u(t, this));
72
- if (e.expandId) {
73
- this.toggleExpand(e.expandId);
69
+ const s = v(l(t, this));
70
+ if (s.expandId) {
71
+ this.toggleExpand(s.expandId);
74
72
  return;
75
73
  }
76
- if (e.modeEl && e.mode && !this.readonly && e.dragTaskId && this._dragSession.begin(t, e.modeEl, e.mode, e.dragTaskId)) {
77
- this._lp.cancel(), this._select(e.dragTaskId);
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(e.selectId);
78
+ this._select(s.selectId);
81
79
  }, this._onKeyDown = (t) => {
82
- x(t, {
83
- select: (e) => this._select(e),
84
- move: (e) => this._moveSelection(e),
85
- scrollBy: (e) => this._scroll.nudgeScrollLeft(e),
86
- jump: (e) => this._jumpSelection(e),
87
- toggle: (e) => this._toggleCurrent(e),
88
- nudge: (e, s) => this.nudge(e, s),
89
- nudgeProgress: (e) => this.nudgeProgress(e),
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.addEventListener("pointerdown", this._onPointerDown), this.addEventListener("keydown", this._onKeyDown), this.addEventListener("wheel", this._onWheel, { passive: !1 }), this.addEventListener("contextmenu", this._onContextMenu);
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 e = (s = this.shadowRoot) == null ? void 0 : s.querySelector(".z-gantt__list-body");
112
- e ? e.focus(t) : super.focus(t);
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.removeEventListener("pointerdown", this._onPointerDown), this.removeEventListener("keydown", this._onKeyDown), this.removeEventListener("wheel", this._onWheel), this.removeEventListener("contextmenu", this._onContextMenu), this._scroll.detach(), this._lp.cancel(), this._dragSession.abort(), this._menu.close(), super.disconnectedCallback();
126
+ this._scroll.detach(), this._lp.cancel(), this._dragSession.abort(), this._menu.close(), super.disconnectedCallback();
116
127
  }
117
128
  willUpdate() {
118
- this.readonly && this._linkSource && (this._linkSource = null);
119
- const t = this.value;
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 e = JSON.parse(t);
123
- e && Array.isArray(e.tasks) && (this.__zui_prop_data = e);
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
- var t;
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 t = this.selectedId, e = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".z-gantt__list-body");
147
- if (!e) return;
148
- const s = t ? Array.from(e.querySelectorAll(".z-gantt__tr")).find((n) => n.dataset.taskId === t) : null;
149
- s && s.id ? e.setAttribute("aria-activedescendant", s.id) : e.removeAttribute("aria-activedescendant");
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 e;
149
+ var t;
154
150
  this._scroll.captureScroll();
155
- const t = v({
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: ((e = this._scroll.bodyEl) == null ? void 0 : e.clientHeight) ?? 0,
170
- windowFor: (s, i, n) => this._scroll.windowFor(s, i, n)
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 = t.rows, this._treeCache = t.tree, this._rangeCache = t.range, this._chartOpts = t.chartOpts, this._scroll.setWindow(t.winStart, t.winEnd), t.html;
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(m, null);
174
+ this._scaleDayWidth(_, null);
181
175
  }
182
176
  zoomOut() {
183
- this._scaleDayWidth(1 / m, null);
177
+ this._scaleDayWidth(1 / _, null);
184
178
  }
185
- /** 缩放至全部任务恰好可见 */
186
179
  fit() {
187
- const t = this._data().tasks;
188
- if (!t.length) {
180
+ const e = this._data().tasks;
181
+ if (!e.length) {
189
182
  this._dayWidth = null, this.requestUpdate();
190
183
  return;
191
184
  }
192
- const e = H(t, this.showToday ? this._today() : null, 2), s = Math.max(A(e.start, e.end), 1), i = this.clientWidth - this._listWidth();
193
- i <= 0 ? this._dayWidth = _(i > 0 ? i / s : L) : this._dayWidth = _(Math.floor((i - 20) / s)), this.requestUpdate();
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(t) {
196
- return this._data().tasks.find((e) => e && e.id === t) ?? null;
188
+ getTaskById(e) {
189
+ return this._data().tasks.find((t) => t && t.id === e) ?? null;
197
190
  }
198
- toggleExpand(t) {
199
- const e = this.getTaskById(t);
200
- if (!e) return;
201
- const s = e.is_expanded === !1;
202
- e.is_expanded = s, this.requestUpdate(), this.emit("z-gantt-expand", { id: t, expanded: s });
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(t) {
205
- const e = this._treeCache;
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 = e == null ? void 0 : e.childrenOf.get(s.id);
209
- i && i.length && (s.is_expanded = t);
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(t) {
214
- const e = this._rowsCache.find((n) => n.task.id === t), s = this._scroll.bodyEl;
215
- if (!e || !s) return;
216
- s.scrollTop = Math.max(0, e.index * this.rowHeight - s.clientHeight / 2);
217
- const i = e.isMilestone ? e.x : e.x + e.width / 2;
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 t = this._scroll.bodyEl, e = this._rangeCache;
222
- if (!t || !e) return;
223
- const s = O(this._today(), e.start, this._resolveDayWidth());
224
- t.scrollLeft = Math.max(0, s - t.clientWidth / 2);
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 t = this._data();
228
- return { tasks: t.tasks, dependencies: t.dependencies ? [...t.dependencies] : [] };
220
+ const e = this._data();
221
+ return { tasks: e.tasks, dependencies: e.dependencies ? [...e.dependencies] : [] };
229
222
  }
230
- setData(t) {
231
- this.value = "", this._lastValueRaw = "", this.data = { tasks: t.tasks, dependencies: t.dependencies ?? [] };
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 t = this.data;
243
- return t && Array.isArray(t.tasks) ? t : { tasks: [], dependencies: [] };
248
+ const e = this.data;
249
+ return e && Array.isArray(e.tasks) ? e : { tasks: [], dependencies: [] };
244
250
  }
245
251
  _today() {
246
- return P(this.today) ?? B();
252
+ return M(this.today) ?? L();
247
253
  }
248
254
  _resolvedColumns() {
249
- return this.columns.length ? this.columns : R;
255
+ return this.columns.length ? this.columns : P;
250
256
  }
251
257
  _listWidth() {
252
- return q(this._resolvedColumns());
258
+ return E(this._resolvedColumns());
253
259
  }
254
260
  _resolveDayWidth() {
255
- const t = z.includes(this.viewMode) ? this.viewMode : "day";
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 (t === "day") return this.columnWidth;
259
- if (t === "week") return this.columnWidth / 7;
264
+ if (e === "day") return this.columnWidth;
265
+ if (e === "week") return this.columnWidth / 7;
260
266
  }
261
- return N[t];
267
+ return B[e];
262
268
  }
263
- /** drag-apply 宿主接口注入(ZGantt 结构化满足 DragApplyHost) */
264
269
  get _host() {
265
270
  return this;
266
271
  }
267
- /** factor 缩放;anchorX 为主元素坐标系下的光标 x(null = 以视口中心为锚) */
268
- _scaleDayWidth(t, e) {
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 n = this._scroll.bodyEl;
272
- if (n) {
273
- const l = e != null ? e - this._listWidth() : n.clientWidth / 2;
274
- this._scroll.queueScrollLeft(D(l, n.scrollLeft, s, i));
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(t) {
279
- if (this.selectedId !== t && (this.selectedId = t, t != null)) {
280
- const e = this.getTaskById(t);
281
- e && this.emit("z-gantt-select", { id: t, task: e });
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
- * 键盘微调:平移 / 改结束日期(`Alt + 方向键`,见 `handleNavKey`)。
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
- this._announce(h.ganttLinkNoSelection);
339
- return;
340
- }
341
- if (this._linkSource === t) {
342
- this.cancelLink();
343
- return;
344
- }
345
- this._linkSource = t, this._announce(g(h.ganttLinkArmed, { task: this._taskName(t) }));
346
- }
347
- /**
348
- * 回车:在当前选中项与连线起点之间建立依赖(默认 FS = 完成后开始)。
349
- *
350
- * [WHY 走 `applyCommit` 而不是自己 push 到 dependencies] 那条路已经有「可取消的
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
- p.styles = U;
421
- let o = p;
422
- a([
423
- r({ type: Object, attribute: !1 })
311
+ c.styles = O + R;
312
+ let o = c;
313
+ h([
314
+ n({ type: Object, attribute: !1 })
424
315
  ], o.prototype, "data");
425
- a([
426
- r({ type: Array, attribute: !1 })
316
+ h([
317
+ n({ type: Array, attribute: !1 })
427
318
  ], o.prototype, "columns");
428
- a([
429
- r({ type: String, attribute: !1 })
319
+ h([
320
+ n({ type: String, attribute: !1 })
430
321
  ], o.prototype, "selectedId");
431
- a([
432
- r({ type: String, attribute: "view-mode" })
322
+ h([
323
+ n({ type: String, attribute: "view-mode" })
433
324
  ], o.prototype, "viewMode");
434
- a([
435
- r({ type: Boolean, attribute: "column-width" })
325
+ h([
326
+ n({ type: Boolean, attribute: "column-width" })
436
327
  ], o.prototype, "columnWidth");
437
- a([
438
- r({ type: Number, attribute: "row-height" })
328
+ h([
329
+ n({ type: Number, attribute: "row-height" })
439
330
  ], o.prototype, "rowHeight");
440
- a([
441
- r({ type: Number, attribute: "header-height" })
331
+ h([
332
+ n({ type: Number, attribute: "header-height" })
442
333
  ], o.prototype, "headerHeight");
443
- a([
444
- r({ type: String })
334
+ h([
335
+ n({ type: String })
445
336
  ], o.prototype, "today");
446
- a([
447
- r({ type: Boolean, attribute: "show-weekends" })
337
+ h([
338
+ n({ type: Boolean, attribute: "show-weekends" })
448
339
  ], o.prototype, "showWeekends");
449
- a([
450
- r({ type: Boolean, attribute: "show-today" })
340
+ h([
341
+ n({ type: Boolean, attribute: "show-today" })
451
342
  ], o.prototype, "showToday");
452
- a([
453
- r({ type: Boolean, attribute: "show-critical-path" })
343
+ h([
344
+ n({ type: Boolean, attribute: "show-critical-path" })
454
345
  ], o.prototype, "showCriticalPath");
455
- a([
456
- r({ type: Boolean, attribute: "auto-schedule" })
346
+ h([
347
+ n({ type: Boolean, attribute: "auto-schedule" })
457
348
  ], o.prototype, "autoSchedule");
458
- a([
459
- r({ type: Boolean })
349
+ h([
350
+ n({ type: Boolean })
460
351
  ], o.prototype, "readonly");
461
- a([
462
- r({ type: Array, attribute: !1 })
352
+ h([
353
+ n({ type: Array, attribute: !1 })
463
354
  ], o.prototype, "menuActions");
464
- a([
465
- r({ type: String })
355
+ h([
356
+ n({ type: String })
466
357
  ], o.prototype, "value");
467
- y("z-gantt", o);
358
+ g("z-gantt", o);
468
359
  export {
469
360
  o as ZGantt
470
361
  };