@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,188 +1,143 @@
1
- import { BaseElement as O } from "../../core/BaseElement.js";
2
- import { property as i } from "../../core/decorators.js";
3
- import { html as u, escapeAttr as M } from "../../core/template.js";
1
+ import { BaseElement as T } from "../../core/BaseElement.js";
2
+ import { property as o } from "../../core/decorators.js";
3
+ import { html as d, escapeAttr as z } from "../../core/template.js";
4
4
  import "../../core/i18n.js";
5
5
  import "../../core/date/presets.js";
6
- import { observeLegacyAttribute as K } from "../../core/legacyAttr.js";
7
- import { COPY as a } from "../../core/copy.js";
8
- import { defineElement as k } from "../../core/define.js";
6
+ import { observeLegacyAttribute as O } from "../../core/legacyAttr.js";
7
+ import { COPY as l } from "../../core/copy.js";
8
+ import { defineElement as R } from "../../core/define.js";
9
9
  import "../column-selector/ColumnSelector.js";
10
- import L from "./report-table.css.js";
11
- import H from "./report-table-grouped.css.js";
12
- import E from "./cell-semantic.css.js";
13
- import P from "./report-table-body.css.js";
14
- import B from "./report-table-fixed.css.js";
15
- import { handleColumnConfigClick as q } from "./column-config-panel.js";
16
- import { takeConfigSnapshot as W, applyConfigSnapshot as A, writePersistedColumnView as $, readPersistedColumnView as F, applyPersistedColumnView as D, reorderColumnsByKeys as U } from "./report-table-config.js";
17
- import { renderPager as I } from "./report-table-pager.js";
18
- import { ensureToolsSelector as N, syncToolsSelector as j } from "./report-table-tools.js";
19
- import "../../primitives/portal/Portal.js";
20
- import "../../primitives/position/Position.js";
21
- import { roveByKey as V, gridIntent as G, resolveCell as X, sameCell as Y, roveTo as b } from "../../primitives/roving/roving.js";
22
- import { rowKeyOf as J } from "./report-table-types.js";
23
- import { dataViewRows as Q, groupViewRows as Z, paginateViewRows as tt } from "./table-view-rows.js";
24
- import { sortRows as v, computeFixedOffsets as et, renderHeadRows as st, renderHeaderTipDefs as ot, renderEmptyRow as it, renderBodyRows as rt, renderFooter as nt } from "./table-render.js";
25
- import { mountTableCells as lt } from "./table-cell-mount.js";
26
- import { handleVirtualScroll as at, renderTableBody as ht } from "./table-virtual.js";
27
- import { handleHeadMouseDown as pt, handleResizeMouseMove as ct, handleResizeMouseUp as dt, handleHeadClick as ut, handleCellClick as gt, handleRowClick as ft, handleTableChange as yt, countSelected as _t, bindColumnReorder as mt } from "./table-interactions.js";
28
- var wt = Object.defineProperty, r = (x, t, e, s) => {
29
- for (var n = void 0, l = x.length - 1, h; l >= 0; l--)
30
- (h = x[l]) && (n = h(t, e, n) || n);
31
- return n && wt(t, e, n), n;
10
+ import v from "./report-table.css.js";
11
+ import K from "./report-table-config.css.js";
12
+ import M from "./report-table-grouped.css.js";
13
+ import k from "./cell-semantic.css.js";
14
+ import H from "./report-table-body.css.js";
15
+ import P from "./report-table-fixed.css.js";
16
+ import { handleColumnConfigClick as L } from "./column-config-panel.js";
17
+ import { readPersistedColumnView as B, applyPersistedColumnView as E, takeConfigSnapshot as q, applyConfigSnapshot as $, writePersistedColumnView as F, reorderColumnsByKeys as U } from "./report-table-config.js";
18
+ import { renderPager as W } from "./report-table-pager.js";
19
+ import { syncToolsSelector as D, ensureToolsSelector as A } from "./report-table-tools.js";
20
+ import { rowKeyOf as _ } from "./report-table-types.js";
21
+ import { sortRows as I, computeFixedOffsets as N, renderHeadRows as j, renderHeaderTipDefs as G, renderEmptyRow as V, renderBodyRows as X, renderFooter as Y } from "./table-render.js";
22
+ import { mountTableCells as J } from "./table-cell-mount.js";
23
+ import { renderTableBody as Q } from "./table-virtual.js";
24
+ import { handleHeadMouseDown as Z, handleResizeMouseMove as tt, handleResizeMouseUp as et, handleHeadClick as st, handleCellClick as ot, handleRowClick as it, handleTableChange as rt, countSelected as nt, bindColumnReorder as at } from "./table-interactions.js";
25
+ import { buildTableViewRows as lt, runTablePipeline as ht, matchesSelectedRowId as pt } from "./table-pipeline.js";
26
+ import { TableKeyboardController as dt } from "./table-keyboard-controller.js";
27
+ import { TableScrollController as gt } from "./table-scroll-controller.js";
28
+ var ct = Object.defineProperty, i = (u, t, e, r) => {
29
+ for (var n = void 0, a = u.length - 1, h; a >= 0; a--)
30
+ (h = u[a]) && (n = h(t, e, n) || n);
31
+ return n && ct(t, e, n), n;
32
32
  };
33
- const R = 32, St = 24, bt = 2e3, C = class C extends O {
33
+ const b = 32, ut = 24, ft = 2e3, c = class c extends T {
34
34
  constructor() {
35
- super(...arguments), this.selectedRowId = "", this.rowClass = null, this.columns = [], this.data = [], this.sortState = [], this.selectedKeys = [], this.selectable = !1, this.editable = !1, this.resizable = !1, this.showColumnSelector = !0, this.persistKey = "", this.rowClickable = !0, this.sortMode = "client", this.rowKey = "", this.draftMode = !1, this.showFooter = !1, this.striped = !1, this.bordered = !1, this.virtual = !1, this.rowHeight = 36, this.lines = !1, this.size = "md", this.loading = !1, this.maxHeight = "", this.emptyText = a.empty, this.loadingText = a.loading, this.footerLabel = a.total, this.requiredColumnText = a.requiredField, this.reorderColumnText = a.reorderColumn, this.footerToggleText = a.total, this.columnSettingsText = a.columnSettings, this.alignLeftText = a.alignLeft, this.alignCenterText = a.alignCenter, this.alignRightText = a.alignRight, this.pinNoneText = a.pinNone, this.pinLeftText = a.pinLeft, this.pinRightText = a.pinRight, this.columnsText = a.columns, this.colFormats = {}, this.formatTypeText = a.formatLabel, this.numberText = a.numberFormat, this.percentText = a.percentFormat, this.decimalPlacesText = a.decimalPlaces, this.thousandsText = a.thousandsSep, this.autoText = a.autoOption, this.columnSelectorOpen = !1, this._configOpen = null, this.group = null, this.tree = null, this.pageSize = 0, this.page = 1, this.pageMode = "client", this.totalRecords = 0, this.pagerTotalText = a.pagerTotal, this.pagerPageText = a.pagerPage, this.prevPageText = a.prevPage, this.nextPageText = a.nextPage, this.pageSizeOptions = "", this.pagerSizeText = a.pagerSize, this.pagerSizeLabel = a.pagerSizeLabel, this._collapsed = /* @__PURE__ */ new Set(), this._vState = { scrollTop: 0, viewportH: 0, start: 0, end: 0 }, this._cursor = null, this._refocusThKey = null, this._refocusSelector = null, this._paged = { rows: [], total: null, page: 1, pageCount: 1, totalRows: 0 }, this._columnWidths = /* @__PURE__ */ new Map(), this._resizeInfo = null, this._leftOffsets = /* @__PURE__ */ new Map(), this._rightOffsets = /* @__PURE__ */ new Map(), this._eventsBound = !1, this._scrollWrapper = null, this._dragKey = null, this._sortedRows = [], this._selectorEl = null, this._onHeadMouseDown = (t) => pt(t, this._interactionHost), this._onResizeMouseMove = (t) => ct(t, this._interactionHost), this._onResizeMouseUp = () => dt(this._interactionHost), this._unbindColDrag = null, this._onHeadClick = (t) => ut(t, this._interactionHost), this._onShadowKeydown = (t) => {
36
- var m, S, w, p;
37
- if (t.key === "Escape" && (this.columnSelectorOpen || this._configOpen)) {
38
- this.columnSelectorOpen = !1, this._configOpen = null, this.requestUpdate();
39
- return;
40
- }
41
- const e = (S = (m = t.target).closest) == null ? void 0 : S.call(m, ".z-rpt__th--sortable");
42
- if (e) {
43
- if (t.key === "Enter" || t.key === " ") {
44
- t.preventDefault(), e.click();
45
- return;
46
- }
47
- V(this._sortableThs(), e, t.key, { wrap: !1, axis: "horizontal" }) && t.preventDefault();
48
- return;
49
- }
50
- const s = (p = (w = t.target).closest) == null ? void 0 : p.call(w, ".z-rpt__td");
51
- if (!s) return;
52
- const n = G(t.key, t);
53
- if (!n) return;
54
- const l = s.parentElement, h = this._gridRows(), c = l ? h.indexOf(l) : -1, d = l ? Array.from(l.children).indexOf(s) : -1;
55
- if (c < 0 || d < 0) return;
56
- const g = { row: c, col: d }, y = this._gridBounds(h), f = X(g, n, y);
57
- if (t.preventDefault(), Y(f, g)) return;
58
- const _ = this._cellAt(h, f);
59
- _ && (this._cursor = f, b(_, this._allCells(h)));
60
- }, this._refreshScrollState = () => {
35
+ super(), this.selectedRowId = "", this.rowClass = null, this.columns = [], this.data = [], this.sortState = [], this.selectedKeys = [], this.selectable = !1, this.editable = !1, this.resizable = !1, this.showColumnSelector = !0, this.persistKey = "", this.rowClickable = !0, this.sortMode = "client", this.rowKey = "", this.draftMode = !1, this.showFooter = !1, this.striped = !1, this.bordered = !1, this.virtual = !1, this.rowHeight = 36, this.lines = !1, this.size = "md", this.loading = !1, this.maxHeight = "", this.emptyText = l.empty, this.loadingText = l.loading, this.footerLabel = l.total, this.requiredColumnText = l.requiredField, this.reorderColumnText = l.reorderColumn, this.footerToggleText = l.total, this.columnSettingsText = l.columnSettings, this.alignLeftText = l.alignLeft, this.alignCenterText = l.alignCenter, this.alignRightText = l.alignRight, this.pinNoneText = l.pinNone, this.pinLeftText = l.pinLeft, this.pinRightText = l.pinRight, this.columnsText = l.columns, this.colFormats = {}, this.formatTypeText = l.formatLabel, this.numberText = l.numberFormat, this.percentText = l.percentFormat, this.decimalPlacesText = l.decimalPlaces, this.thousandsText = l.thousandsSep, this.autoText = l.autoOption, this.columnSelectorOpen = !1, this.group = null, this.tree = null, this.pageSize = 0, this.page = 1, this.pageMode = "client", this.totalRecords = 0, this.pagerTotalText = l.pagerTotal, this.pagerPageText = l.pagerPage, this.prevPageText = l.prevPage, this.nextPageText = l.nextPage, this.pageSizeOptions = "", this.pagerSizeText = l.pagerSize, this.pagerSizeLabel = l.pagerSizeLabel, this._configOpen = null, this._collapsed = /* @__PURE__ */ new Set(), this._paged = { rows: [], total: null, page: 1, pageCount: 1, totalRows: 0 }, this._columnWidths = /* @__PURE__ */ new Map(), this._resizeInfo = null, this._leftOffsets = /* @__PURE__ */ new Map(), this._rightOffsets = /* @__PURE__ */ new Map(), this._eventsBound = !1, this._dragKey = null, this._sortedRows = [], this._selectorEl = null, this._unbindColDrag = null, this._onHeadMouseDown = (e) => Z(e, this._interactionHost), this._onResizeMouseMove = (e) => tt(e, this._interactionHost), this._onResizeMouseUp = () => et(this._interactionHost), this._onHeadClick = (e) => st(e, this._interactionHost), this._onShadowKeydown = (e) => this._keyboard.handleKeydown(e), this._onShadowClick = (e) => {
36
+ var n, a, h, g;
37
+ if (this._onGroupToggle(e) || this._onPagerClick(e) || ot(e, this._interactionHost) || it(e, this._interactionHost) || L(e.target, this._panelHost)) return;
38
+ const r = (a = (n = e.target) == null ? void 0 : n.closest) == null ? void 0 : a.call(n, ".z-rpt__th--sortable");
39
+ r && !((g = (h = e.target) == null ? void 0 : h.closest) != null && g.call(h, ".z-rpt__resize-handle")) && this._keyboard.scheduleRefocusTh(r.dataset.key ?? null), this._onHeadClick(e);
40
+ }, this._onGlobalMouseDown = (e) => {
61
41
  var n;
62
- const t = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".z-rpt__wrapper");
63
- if (!t) return;
64
- const e = t.scrollLeft > 0, s = t.scrollLeft + t.clientWidth < t.scrollWidth - 1;
65
- t.classList.toggle("z-rpt__wrapper--scrolled-left", e), t.classList.toggle("z-rpt__wrapper--scrolled-right", s), this.virtual && at(t, this._paged.rows.length, this.rowHeight, this.maxHeight, this._vState) && this.requestUpdate();
66
- }, this._onShadowClick = (t) => {
67
- var s, n, l, h;
68
- if (this._onGroupToggle(t) || this._onPagerClick(t) || gt(t, this._interactionHost) || ft(t, this._interactionHost) || q(t.target, this._panelHost)) return;
69
- const e = (n = (s = t.target) == null ? void 0 : s.closest) == null ? void 0 : n.call(s, ".z-rpt__th--sortable");
70
- e && !((h = (l = t.target) == null ? void 0 : l.closest) != null && h.call(l, ".z-rpt__resize-handle")) && (this._refocusThKey = e.dataset.key ?? null), this._onHeadClick(t);
71
- }, this._onGlobalMouseDown = (t) => {
72
- var s;
73
42
  if (!this._configOpen) return;
74
- const e = (s = this.shadowRoot) == null ? void 0 : s.host;
75
- e && (t.composedPath().includes(e) || (this._configOpen = null, this.requestUpdate()));
76
- }, this._onColumnSelectorOpenEvent = (t) => {
77
- const e = t.target;
78
- if (!e || e.tagName !== "Z-COLUMN-SELECTOR") return;
79
- const s = t.type === "z-column-selector-open";
80
- this.columnSelectorOpen !== s && (this.columnSelectorOpen = s);
81
- }, this._onTableChange = (t) => {
82
- this._onPagerSizeChange(t) || yt(t, this._interactionHost);
43
+ const r = (n = this.shadowRoot) == null ? void 0 : n.host;
44
+ r && (e.composedPath().includes(r) || (this._configOpen = null, this.requestUpdate()));
45
+ }, this._onColumnSelectorOpenEvent = (e) => {
46
+ const r = e.target;
47
+ if (!r || r.tagName !== "Z-COLUMN-SELECTOR") return;
48
+ const n = e.type === "z-column-selector-open";
49
+ this.columnSelectorOpen !== n && (this.columnSelectorOpen = n);
50
+ }, this._onTableChange = (e) => {
51
+ this._onPagerSizeChange(e) || rt(e, this._interactionHost);
83
52
  };
53
+ const t = this;
54
+ this._keyboard = this.addController(
55
+ new dt({
56
+ get shadowRoot() {
57
+ return t.shadowRoot;
58
+ },
59
+ hasOpenPopover: () => t.columnSelectorOpen || t._configOpen !== null,
60
+ closePopovers: () => {
61
+ t.columnSelectorOpen = !1, t._configOpen = null, t.requestUpdate();
62
+ }
63
+ })
64
+ ), this._scroll = this.addController(
65
+ new gt({
66
+ get shadowRoot() {
67
+ return t.shadowRoot;
68
+ },
69
+ get virtual() {
70
+ return t.virtual;
71
+ },
72
+ get rowHeight() {
73
+ return t.rowHeight;
74
+ },
75
+ get maxHeight() {
76
+ return t.maxHeight;
77
+ },
78
+ getPagedRowCount: () => t._paged.rows.length,
79
+ requestUpdate: () => t.requestUpdate()
80
+ })
81
+ );
84
82
  }
85
- // ── Visible columns ────────────────────────────────────
86
83
  get _visible() {
87
84
  return this.columns.filter((t) => !t.hidden || t.required);
88
85
  }
89
- /**
90
- * 屏幕上真实可见的列(`hidden` 且非 `required` 的不出现)。
91
- *
92
- * [WHY 公开出去] CSV 导出必须与屏幕同源。拿 `columns` 导出会把被列选择器勾掉的列
93
- * (价格 / 成本族)也写进文件 —— 那份文件是要转发出去的,用户收起它正是因为这个。
94
- * 判据与 `_visible` 同一条,不另写第二个版本。
95
- */
96
86
  get shownColumns() {
97
87
  return this._visible;
98
88
  }
99
- // ── 视图行 / 分页 ───────────────────────────────────────
100
- /** 数据行(已排序)→ 视图行。有 `group` 走分组,否则一条数据一条。 */
101
- _viewRows(t) {
102
- return !this.group || !this.group.dims.length ? Q(t, this.rowKey) : Z(this.group, t, this._collapsed);
103
- }
104
- /**
105
- * 当前表格实际渲染的行(含小计/总计,**不分页**)。
106
- *
107
- * 导出 CSV 必须走这个出口:屏幕与导出各算一份的后果是「页面上 4800、导出 4300」,
108
- * 没有任何断言会红,只有对账时才发现。
109
- */
110
89
  renderRows() {
111
- return this._viewRows(v(this.data, this.sortState, this.sortMode));
90
+ return lt(
91
+ I(this.data, this.sortState, this.sortMode),
92
+ this.rowKey,
93
+ this.group,
94
+ this._collapsed
95
+ );
112
96
  }
113
- /** 当前生效的页码总数(不分页时恒为 1)。 */
114
97
  get pageCount() {
115
98
  return this._paged.pageCount;
116
99
  }
117
- /**
118
- * 换页。
119
- *
120
- * [WHY server 模式也改 page] 宿主从 `z-page-change` 里拿到页码后把 `page` 属性设回来是
121
- * 标准用法,但「忘了设回来」这个错误在客户端毫无痕迹(数据没变、页码不动)。
122
- * 组件自己先改,宿主设回同一个值是无操作 —— 两种写法都能用。
123
- */
124
100
  _setPage(t) {
125
101
  const e = Math.min(Math.max(1, Math.trunc(t) || 1), Math.max(1, this._paged.pageCount));
126
102
  e !== this._paged.page && (this.page = e, this.emit("z-page-change", { page: e, pageSize: this.pageSize }), this.requestUpdate());
127
103
  }
128
- /**
129
- * 换每页行数。
130
- *
131
- * [WHY 页码必须归 1] 行数变了,原来第 3 页对应的「第 41-60 行」已经不存在:
132
- * 20 行/页翻到第 3 页时切 50 行/页,还停在第 3 页就是「第 101-150 行」——
133
- * 越界会被 clamp 成最后一页,用户看到的是「换了行数,内容跳走了」。
134
- * 归 1 是唯一可解释的行为,也是所有表格库的既有习惯。
135
- *
136
- * [WHY 照旧 emit `z-page-change`] server 模式下一律由宿主重取:行数变了等于换了
137
- * 一份数据(取数键里有 pageSize)。事件里同时带 `page` 与 `pageSize`,宿主不需要
138
- * 再读一次属性才知道两者都变了。
139
- */
140
104
  _setPageSize(t) {
141
105
  t !== this.pageSize && (this.pageSize = t, this.page = 1, this.emit("z-page-change", { page: 1, pageSize: t }), this.requestUpdate());
142
106
  }
143
- _renderPager(t) {
144
- return I(t, this);
145
- }
146
- /** 折叠按钮点击。返回 true = 已消费(不再走行点击)。 */
147
107
  _onGroupToggle(t) {
148
- var l, h;
149
- const e = (h = (l = t.target) == null ? void 0 : l.closest) == null ? void 0 : h.call(l, "[data-toggle]");
108
+ var a, h;
109
+ const e = (h = (a = t.target) == null ? void 0 : a.closest) == null ? void 0 : h.call(a, "[data-toggle]");
150
110
  if (!e) return !1;
151
- const s = e.getAttribute("data-toggle") ?? "", n = !this._collapsed.has(s);
152
- return n ? this._collapsed.add(s) : this._collapsed.delete(s), this.emit("z-group-toggle", { groupKey: s, collapsed: n }), this.requestUpdate(), !0;
111
+ const r = e.getAttribute("data-toggle") ?? "", n = !this._collapsed.has(r);
112
+ return n ? this._collapsed.add(r) : this._collapsed.delete(r), this.emit("z-group-toggle", { groupKey: r, collapsed: n }), this.requestUpdate(), !0;
153
113
  }
154
- /** 分页按钮点击。返回 true = 已消费。 */
155
114
  _onPagerClick(t) {
156
- var n, l;
157
- const e = (l = (n = t.target) == null ? void 0 : n.closest) == null ? void 0 : l.call(n, "[data-page-go]");
115
+ var n, a;
116
+ const e = (a = (n = t.target) == null ? void 0 : n.closest) == null ? void 0 : a.call(n, "[data-page-go]");
158
117
  if (!e || e.hasAttribute("disabled")) return !1;
159
- const s = e.getAttribute("data-page-go");
160
- return this._refocusSelector = `[data-page-go="${s}"]`, this._setPage(s === "next" ? this._paged.page + 1 : this._paged.page - 1), !0;
118
+ const r = e.getAttribute("data-page-go");
119
+ return this._keyboard.scheduleRefocusSelector(`[data-page-go="${r}"]`), this._setPage(r === "next" ? this._paged.page + 1 : this._paged.page - 1), !0;
161
120
  }
162
- /** 分页器「每页行数」下拉变更。返回 true = 已消费。 */
163
121
  _onPagerSizeChange(t) {
164
- var n, l;
165
- const e = (l = (n = t.target) == null ? void 0 : n.closest) == null ? void 0 : l.call(n, "[data-page-size]");
122
+ var n, a;
123
+ const e = (a = (n = t.target) == null ? void 0 : n.closest) == null ? void 0 : a.call(n, "[data-page-size]");
166
124
  if (!e) return !1;
167
- const s = Math.trunc(Number(e.value));
168
- return !Number.isFinite(s) || s <= 0 ? !1 : (this._refocusSelector = "[data-page-size]", this._setPageSize(s), !0);
125
+ const r = Math.trunc(Number(e.value));
126
+ return !Number.isFinite(r) || r <= 0 ? !1 : (this._keyboard.scheduleRefocusSelector("[data-page-size]"), this._setPageSize(r), !0);
169
127
  }
170
- // ── Lifecycle ──────────────────────────────────────────
171
128
  connectedCallback() {
172
- super.connectedCallback(), document.addEventListener("mousemove", this._onResizeMouseMove), document.addEventListener("mouseup", this._onResizeMouseUp), document.addEventListener("mousedown", this._onGlobalMouseDown), this._ensureSelectorEl();
129
+ super.connectedCallback(), this.listen(document, "mousemove", this._onResizeMouseMove), this.listen(document, "mouseup", this._onResizeMouseUp), this.listen(document, "mousedown", this._onGlobalMouseDown), this._ensureSelectorEl();
173
130
  }
174
131
  disconnectedCallback() {
175
132
  var t;
176
- document.removeEventListener("mousemove", this._onResizeMouseMove), document.removeEventListener("mouseup", this._onResizeMouseUp), document.removeEventListener("mousedown", this._onGlobalMouseDown), (t = this._unbindColDrag) == null || t.call(this), this._unbindColDrag = null, super.disconnectedCallback();
133
+ (t = this._unbindColDrag) == null || t.call(this), this._unbindColDrag = null, super.disconnectedCallback();
177
134
  }
178
- // ── Render ─────────────────────────────────────────────
179
- /** 兼容读:`variant="lines"` → `lines`,`variant="default"` → 关掉。 */
180
- attributeChangedCallback(t, e, s) {
135
+ attributeChangedCallback(t, e, r) {
181
136
  if (t === "variant") {
182
- s === "lines" ? this.lines = !0 : s === "default" && (this.lines = !1);
137
+ r === "lines" ? this.lines = !0 : r === "default" && (this.lines = !1);
183
138
  return;
184
139
  }
185
- super.attributeChangedCallback(t, e, s);
140
+ super.attributeChangedCallback(t, e, r);
186
141
  }
187
142
  /** @deprecated 旧名 `variant` 的 JS 属性兼容层。 */
188
143
  get variant() {
@@ -191,9 +146,13 @@ const R = 32, St = 24, bt = 2e3, C = class C extends O {
191
146
  set variant(t) {
192
147
  this.lines = t === "lines";
193
148
  }
149
+ willUpdate() {
150
+ const t = B(this.persistKey);
151
+ t && E(this, t), D(this._selectorEl, this);
152
+ }
194
153
  render() {
195
- const t = this._visible, e = this.showColumnSelector, s = et(t, this.selectable, this._columnWidths, e ? R : 0);
196
- this._leftOffsets = s.left, this._rightOffsets = s.right;
154
+ const t = this._visible, e = this.showColumnSelector, r = N(t, this.selectable, this._columnWidths, e ? b : 0);
155
+ this._leftOffsets = r.left, this._rightOffsets = r.right;
197
156
  const n = [
198
157
  "z-rpt",
199
158
  this.striped ? "z-rpt--striped" : "",
@@ -202,21 +161,23 @@ const R = 32, St = 24, bt = 2e3, C = class C extends O {
202
161
  `z-rpt--${this.size}`,
203
162
  this.loading ? "z-rpt--loading" : "",
204
163
  this.selectable ? "z-rpt--selectable" : "",
205
- // 两行表头(`col group=`):CSS 靠这个类给第二行算 sticky 的 top
206
164
  t.some((p) => !!p.group) ? "z-rpt--grouped" : ""
207
- ].filter(Boolean).join(" "), l = v(this.data, this.sortState, this.sortMode);
208
- this._sortedRows = l;
209
- const h = this._viewRows(l), c = tt(h, this.pageMode === "server" ? 0 : this.pageSize, this.page);
210
- this._paged = this.pageMode === "server" && this.pageSize > 0 ? {
211
- ...c,
212
- page: Math.max(1, this.page),
213
- pageCount: Math.max(1, Math.ceil(Math.max(0, this.totalRecords) / this.pageSize) || 1),
214
- totalRows: this.totalRecords > 0 ? this.totalRecords : c.totalRows
215
- } : c;
216
- const d = t.length + (this.selectable ? 1 : 0) + (e ? 1 : 0), g = {
165
+ ].filter(Boolean).join(" "), a = ht({
166
+ data: this.data,
167
+ sortState: this.sortState,
168
+ sortMode: this.sortMode,
169
+ rowKey: this.rowKey,
170
+ group: this.group,
171
+ collapsed: this._collapsed,
172
+ pageSize: this.pageSize,
173
+ page: this.page,
174
+ pageMode: this.pageMode,
175
+ totalRecords: this.totalRecords
176
+ });
177
+ this._sortedRows = a.sortedRows, this._paged = a.paged;
178
+ const h = t.length + (this.selectable ? 1 : 0) + (e ? 1 : 0), g = {
217
179
  sortState: this.sortState,
218
180
  editable: this.editable,
219
- // 编辑态全开;查看态由 resizable 单独开"只拖宽"(见属性注释与 [[REQ-021-page-column-width]])
220
181
  resizable: this.resizable || this.editable,
221
182
  columnWidths: this._columnWidths,
222
183
  leftOffsets: this._leftOffsets,
@@ -224,18 +185,17 @@ const R = 32, St = 24, bt = 2e3, C = class C extends O {
224
185
  configOpen: this._configOpen,
225
186
  colFormats: this.colFormats,
226
187
  texts: this
227
- }, y = {
188
+ }, f = {
228
189
  selectable: this.selectable,
229
190
  selectedKeys: this.selectedKeys,
230
191
  visible: t,
231
192
  leftOffsets: this._leftOffsets,
232
193
  rightOffsets: this._rightOffsets,
233
- isSelectedById: (p) => this._selectedById(p),
194
+ isSelectedById: (p) => pt(p, this.selectedRowId),
234
195
  rowClass: this.rowClass,
235
- // 分组上下文:缩进与折叠按钮都要知道「哪些列是维度、哪些组已折叠」
236
196
  group: this.group ? { dims: this.group.dims, collapsed: this._collapsed } : null,
237
197
  tools: e
238
- }, f = {
198
+ }, C = {
239
199
  visible: t,
240
200
  data: this.data,
241
201
  footerLabel: this.footerLabel,
@@ -243,130 +203,103 @@ const R = 32, St = 24, bt = 2e3, C = class C extends O {
243
203
  leftOffsets: this._leftOffsets,
244
204
  rightOffsets: this._rightOffsets,
245
205
  tools: e
246
- }, _ = e ? u`<slot name="tools"></slot>` : "", m = st({ vis: t, ctx: g, selectable: this.selectable, tools: _ }), w = t.some((p) => (p.group ?? "").trim() !== "") ? u`<colgroup>
247
- ${this.selectable ? u`<col style="width:40px">` : ""}
206
+ }, S = e ? d`<slot name="tools"></slot>` : "", w = j({ vis: t, ctx: g, selectable: this.selectable, tools: S }), x = t.some((p) => (p.group ?? "").trim() !== "") ? d`<colgroup>
207
+ ${this.selectable ? d`<col style="width:40px">` : ""}
248
208
  ${t.map((p) => {
249
- const z = this._columnWidths.get(p.key), T = z != null ? `${z}px` : p.width || "";
250
- return T ? u`<col style="width:${T}">` : u`<col>`;
209
+ const y = this._columnWidths.get(p.key), m = y != null ? `${y}px` : p.width || "";
210
+ return m ? d`<col style="width:${m}">` : d`<col>`;
251
211
  })}
252
- ${e ? u`<col style="width:${R}px">` : ""}
212
+ ${e ? d`<col style="width:${b}px">` : ""}
253
213
  </colgroup>` : "";
254
- return u`
255
- ${ot(t)}
214
+ return d`
215
+ ${G(t)}
256
216
  <div class="z-rpt__wrapper" part="wrapper"
257
217
  ${this.maxHeight ? `style="max-height:${this.maxHeight};overflow-y:auto"` : ""}>
258
218
  <table class="${n}" part="table">
259
- ${w}
260
- <thead class="z-rpt__head" part="head">${m}</thead>
219
+ ${x}
220
+ <thead class="z-rpt__head" part="head">${w}</thead>
261
221
  <tbody class="z-rpt__body" part="body">
262
- ${this._paged.rows.length === 0 ? it(d, this.emptyText) : ht(this._paged.rows, y, d, this.virtual, this.rowHeight, this.maxHeight, this._vState)}
263
- ${this._paged.total ? rt([this._paged.total], y) : ""}
222
+ ${this._paged.rows.length === 0 ? V(h, this.emptyText) : Q(this._paged.rows, f, h, this.virtual, this.rowHeight, this.maxHeight, this._scroll.virtualState)}
223
+ ${this._paged.total ? X([this._paged.total], f) : ""}
264
224
  </tbody>
265
- ${this.showFooter && t.length > 0 ? nt(f) : ""}
225
+ ${this.showFooter && t.length > 0 ? Y(C) : ""}
266
226
  </table>
267
- ${this.loading ? u`<div class="z-rpt__loading-overlay" part="loading">
227
+ ${this.loading ? d`<div class="z-rpt__loading-overlay" part="loading">
268
228
  <span class="z-rpt__spinner" part="spinner"></span>
269
- <span class="z-rpt__loading-text">${M(this.loadingText)}</span>
229
+ <span class="z-rpt__loading-text">${z(this.loadingText)}</span>
270
230
  </div>` : ""}
271
231
  </div>
272
- ${this._renderPager(this._paged)}
232
+ ${W(this._paged, this)}
273
233
  `;
274
234
  }
275
235
  _ensureSelectorEl() {
276
- this._selectorEl = N(this, this._selectorEl, this._onColumnSelectorOpenEvent);
277
- }
278
- _syncSelectorProps() {
279
- j(this._selectorEl, this);
236
+ this._selectorEl = A(this, this._selectorEl, this._onColumnSelectorOpenEvent);
280
237
  }
281
238
  updated() {
282
- var e, s;
283
- this._bindEvents(), this._bindWrapperScroll(), this._refreshScrollState();
239
+ var e, r;
240
+ this._bindEvents();
284
241
  const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".z-rpt__foot");
285
242
  if (this.style.setProperty(
286
243
  "--z-rpt-foot-h",
287
244
  t ? `${Math.round(t.getBoundingClientRect().height)}px` : "0px"
288
- ), this._applyCursor(), this._restoreFocus(), lt(this.shadowRoot, this._visible, this._sortedRows), this.selectable) {
245
+ ), J(this.shadowRoot, this._visible, this._sortedRows), this.selectable) {
289
246
  const n = this.shadowRoot.querySelector(".z-rpt__select-all");
290
247
  if (n) {
291
- const l = this.data.length, h = _t(this.data, this.rowKey, this.selectedKeys);
292
- n.checked = l > 0 && h === l, n.indeterminate = h > 0 && h < l;
248
+ const a = this.data.length, h = nt(this.data, this.rowKey, this.selectedKeys);
249
+ n.checked = a > 0 && h === a, n.indeterminate = h > 0 && h < a;
293
250
  }
294
251
  }
295
- (s = this._selectorEl) == null || s.reposition();
252
+ (r = this._selectorEl) == null || r.reposition();
296
253
  }
297
- // ── Config snapshot (external persistence) ─────────────
298
254
  getConfig() {
299
- return W(this, this._columnWidths);
255
+ return q(this, this._columnWidths);
300
256
  }
301
257
  applyConfig(t) {
302
- A(this, this._columnWidths, t);
303
- }
304
- // ── Column widths (external persistence) ───────────────
305
- /**
306
- * 回灌列宽覆盖(**只碰宽度**,不动隐藏/顺序/对齐/冻结)。
307
- *
308
- * [WHY 不用 `applyConfig`] 配置快照是**全量权威**:只带 width 的最小快照会把
309
- * `hidden` / `fixed` / `align` 一起写成 undefined —— 脚本里 `col x fixed=left`
310
- * 声明的冻结会被静默抹掉。查看页的「本机记住列宽」只需要宽度这一条通道。
311
- * 见 [[REQ-021-page-column-width]]。
312
- *
313
- * 非法值(非数字 / 越界)直接丢弃:这份数据来自 localStorage,可能是上一版本的格式
314
- * 或被手工改坏。放行一个 `NaN` 会让整列宽度塌成 0,而且没有任何报错。
315
- */
258
+ $(this, this._columnWidths, t);
259
+ }
316
260
  setColumnWidths(t) {
317
261
  if (!t || typeof t != "object") return;
318
262
  let e = !1;
319
- for (const [s, n] of Object.entries(t)) {
320
- const l = Math.round(Number(n));
321
- !Number.isFinite(l) || l < St || l > bt || this._columnWidths.get(s) !== l && (this._columnWidths.set(s, l), e = !0);
263
+ for (const [r, n] of Object.entries(t)) {
264
+ const a = Math.round(Number(n));
265
+ !Number.isFinite(a) || a < ut || a > ft || this._columnWidths.get(r) !== a && (this._columnWidths.set(r, a), e = !0);
322
266
  }
323
267
  e && this.requestUpdate();
324
268
  }
325
- /** 当前生效的列宽覆盖(只含用户拖过的列),供宿主持久化。 */
326
269
  getColumnWidths() {
327
270
  return Object.fromEntries(this._columnWidths);
328
271
  }
329
272
  _emitConfigChange() {
330
273
  var t;
331
- this.emit("z-config-change", { config: this.getConfig() }), $(this.persistKey, this), (t = this._selectorEl) == null || t.syncColumnState();
274
+ this.emit("z-config-change", { config: this.getConfig() }), F(this.persistKey, this), (t = this._selectorEl) == null || t.syncColumnState();
332
275
  }
333
- /** 渲染前叠上本机记住的顺序/显隐(放在 updated 会先画一帧默认顺序再跳)。 */
334
- willUpdate() {
335
- const t = F(this.persistKey);
336
- t && D(this, t), this._syncSelectorProps();
337
- }
338
- // ── Public helpers ─────────────────────────────────────
339
276
  clearSelection() {
340
277
  this.selectedKeys = [], this.emit("z-selection-change", { selectedKeys: [], rows: [] });
341
278
  }
342
279
  selectAll() {
343
- this.selectedKeys = this.data.map((t, e) => this._getRowKey(t, e)), this.emit("z-selection-change", { selectedKeys: [...this.selectedKeys], rows: [...this.data] });
280
+ this.selectedKeys = this.data.map((t, e) => _(t, e, this.rowKey)), this.emit("z-selection-change", { selectedKeys: [...this.selectedKeys], rows: [...this.data] });
344
281
  }
345
- /** 勾选键 → 行对象(顺序按 `data`)。整表编辑态的「待删行」靠它。 */
346
282
  rowsOfKeys(t) {
347
283
  if (!t.length) return [];
348
284
  const e = new Set(t);
349
- return this.data.filter((s, n) => e.has(this._getRowKey(s, n)));
285
+ return this.data.filter((r, n) => e.has(_(r, n, this.rowKey)));
350
286
  }
351
287
  showColumn(t) {
352
- const e = this.columns.find((s) => s.key === t);
288
+ const e = this.columns.find((r) => r.key === t);
353
289
  e && e.hidden && (e.hidden = !1, this.requestUpdate(), this._emitConfigChange());
354
290
  }
355
291
  hideColumn(t) {
356
- const e = this.columns.find((s) => s.key === t);
292
+ const e = this.columns.find((r) => r.key === t);
357
293
  e && !e.required && !e.hidden && (e.hidden = !0, this.requestUpdate(), this._emitConfigChange());
358
294
  }
359
295
  toggleColumn(t) {
360
- const e = this.columns.find((s) => s.key === t);
296
+ const e = this.columns.find((r) => r.key === t);
361
297
  e && !e.required && (e.hidden = !e.hidden, this.requestUpdate(), this._emitConfigChange());
362
298
  }
363
- /** 按给定 key 顺序重排列(列选择器拖拽 / Alt+↑↓ 的落点)。 */
364
299
  reorderColumns(t) {
365
300
  const e = U(this, t);
366
301
  e && (this.requestUpdate(), this.emit("z-column-order-change", { keys: e }), this._emitConfigChange());
367
302
  }
368
- // ── Hosts for extracted modules ────────────────────────
369
- // [WHY] 拆出的面板/交互模块不持有元素引用, 私有状态经这层闭包回写(见对应文件头)
370
303
  get _panelHost() {
371
304
  return {
372
305
  columns: this.columns,
@@ -427,281 +360,191 @@ const R = 32, St = 24, bt = 2e3, C = class C extends O {
427
360
  _bindEvents() {
428
361
  if (this._eventsBound) return;
429
362
  const t = this.shadowRoot;
430
- t && (t.addEventListener("mousedown", this._onHeadMouseDown), t.addEventListener("click", this._onShadowClick), t.addEventListener("change", this._onTableChange), t.addEventListener("keydown", this._onShadowKeydown), this._ensureSelectorEl(), this._unbindColDrag = mt(this.shadowRoot, this._interactionHost, () => this.editable), this._eventsBound = !0);
431
- }
432
- // ── 键盘:网格导航与焦点恢复 ────────────────────────────
433
- /** 表体数据行(不含空态行)。DOM 顺序即行号。 */
434
- _gridRows() {
435
- var t;
436
- return Array.from(((t = this.shadowRoot) == null ? void 0 : t.querySelectorAll("tbody .z-rpt__row")) ?? []);
437
- }
438
- _gridBounds(t) {
439
- let e = 0;
440
- for (const s of t) e = Math.max(e, s.children.length);
441
- return { rows: t.length, cols: e };
442
- }
443
- _cellAt(t, e) {
444
- var s;
445
- return ((s = t[e.row]) == null ? void 0 : s.children[e.col]) ?? null;
446
- }
447
- _allCells(t) {
448
- return t.flatMap((e) => Array.from(e.children));
449
- }
450
- /**
451
- * 把 roving 停靠点放回游标处(**不**抢焦点)。
452
- *
453
- * [WHY 不 focus] 这个方法是「重渲染之后重挂」用的,触发者可能是排序、换页,
454
- * 也可能是宿主动了个数据字段。后者不该把用户的焦点从别处抢回表格里。
455
- * 只有明确由用户操作引发的位置变化才恢复焦点(见 `_restoreFocus`)。
456
- */
457
- _applyCursor() {
458
- const t = this._gridRows();
459
- if (!t.length) return;
460
- const e = this._gridBounds(t), s = this._cursor, n = s && s.row < e.rows && s.col < e.cols ? s : { row: 0, col: 0 }, l = this._cellAt(t, n);
461
- l && b(l, this._allCells(t), { focus: !1 });
462
- }
463
- /**
464
- * 重渲染后把焦点送回用户刚才所在的位置。
465
- *
466
- * [WHY 需要它] 排序 / 换页 / 改每页行数都会触发整体重渲染,**节点被整个换掉**,
467
- * 焦点掉到 `<body>`。鼠标用户无感(手还在原位),键盘用户每操作一次就得重新 Tab
468
- * 回来 —— 而「连续切几列排序」「连翻几页」正是这些控件的用法。
469
- * 同类缺陷 2026-11-16 已在 `z-column-selector`(勾一列)与 `z-table`(排序)上修过。
470
- */
471
- _restoreFocus() {
472
- var h, c, d;
473
- const t = this._refocusThKey, e = this._refocusSelector;
474
- if (this._refocusThKey = null, this._refocusSelector = null, t) {
475
- const g = (h = this.shadowRoot) == null ? void 0 : h.querySelector(`.z-rpt__th[data-key="${t}"]`);
476
- if (g) {
477
- b(g, this._sortableThs());
478
- return;
479
- }
480
- }
481
- if (!e) return;
482
- const s = (c = this.shadowRoot) == null ? void 0 : c.querySelector(e);
483
- if (s && !s.disabled) {
484
- s.focus();
485
- return;
486
- }
487
- const n = /data-page-go="prev"/.test(e) ? '[data-page-go="next"]' : /data-page-go="next"/.test(e) ? '[data-page-go="prev"]' : null, l = n ? (d = this.shadowRoot) == null ? void 0 : d.querySelector(n) : null;
488
- l && !l.disabled && l.focus();
489
- }
490
- _sortableThs() {
491
- var t;
492
- return Array.from(((t = this.shadowRoot) == null ? void 0 : t.querySelectorAll(".z-rpt__th--sortable")) ?? []);
493
- }
494
- // [WHY] 自然交互: 固定列阴影仅在滚动到边缘时显示, 见滚动感知阴影 CSS
495
- // BaseElement 每次渲染整体替换 innerHTML, wrapper 节点会重建, 须按节点引用重新绑定
496
- _bindWrapperScroll() {
497
- var e;
498
- const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".z-rpt__wrapper");
499
- !t || t === this._scrollWrapper || (this._scrollWrapper = t, this.virtual && this._vState.scrollTop > 0 && (t.scrollTop = this._vState.scrollTop), t.addEventListener("scroll", this._refreshScrollState, { passive: !0 }));
500
- }
501
- // ── Selection ──────────────────────────────────────────
502
- // [WHY] 勾选变更/配置合计开关的统一分发见 table-interactions#handleTableChange
503
- _getRowKey(t, e) {
504
- return J(t, e, this.rowKey);
505
- }
506
- /**
507
- * 解析 `selectedRowId`(`id:10` 或 `code:a,b`,逗号分隔多组)判断本行是否命中。
508
- * 口径:冒号后为空 ⇒ 不命中(防 `id:` 命中一切);值逐字比较,除 trim 外不做转换。
509
- */
510
- _selectedById(t) {
511
- const e = this.selectedRowId.trim();
512
- if (!e) return !1;
513
- for (const s of e.split(",")) {
514
- const n = s.indexOf(":");
515
- if (n < 0) continue;
516
- const l = s.slice(0, n).trim(), h = s.slice(n + 1).trim();
517
- if (!(!l || !h) && String(t[l] ?? "") === h)
518
- return !0;
519
- }
520
- return !1;
363
+ t && (t.addEventListener("mousedown", this._onHeadMouseDown), t.addEventListener("click", this._onShadowClick), t.addEventListener("change", this._onTableChange), t.addEventListener("keydown", this._onShadowKeydown), this._ensureSelectorEl(), this._unbindColDrag = at(this.shadowRoot, this._interactionHost, () => this.editable), this._eventsBound = !0);
521
364
  }
522
365
  };
523
- C.styles = L + H + P + B + E;
524
- let o = C;
525
- r([
526
- i({ type: String, attribute: "selected-row-id" })
527
- ], o.prototype, "selectedRowId");
528
- r([
529
- i({ attribute: !1 })
530
- ], o.prototype, "rowClass");
531
- r([
532
- i({ type: Array, attribute: !1 })
533
- ], o.prototype, "columns");
534
- r([
535
- i({ type: Array, attribute: !1 })
536
- ], o.prototype, "data");
537
- r([
538
- i({ type: Array, attribute: !1 })
539
- ], o.prototype, "sortState");
540
- r([
541
- i({ type: Array, attribute: !1 })
542
- ], o.prototype, "selectedKeys");
543
- r([
544
- i({ type: Boolean })
545
- ], o.prototype, "selectable");
546
- r([
547
- i({ type: Boolean })
548
- ], o.prototype, "editable");
549
- r([
550
- i({ type: Boolean })
551
- ], o.prototype, "resizable");
552
- r([
553
- i({ type: Boolean })
554
- ], o.prototype, "showColumnSelector");
555
- r([
556
- i({ type: String })
557
- ], o.prototype, "persistKey");
558
- r([
559
- i({ type: Boolean })
560
- ], o.prototype, "rowClickable");
561
- r([
562
- i({ type: String })
563
- ], o.prototype, "sortMode");
564
- r([
565
- i({ type: String })
566
- ], o.prototype, "rowKey");
567
- r([
568
- i({ type: Boolean })
569
- ], o.prototype, "draftMode");
570
- r([
571
- i({ type: Boolean })
572
- ], o.prototype, "showFooter");
573
- r([
574
- i({ type: Boolean })
575
- ], o.prototype, "striped");
576
- r([
577
- i({ type: Boolean })
578
- ], o.prototype, "bordered");
579
- r([
580
- i({ type: Boolean })
581
- ], o.prototype, "virtual");
582
- r([
583
- i({ type: Number, attribute: "row-height" })
584
- ], o.prototype, "rowHeight");
585
- r([
586
- i({ type: Boolean })
587
- ], o.prototype, "lines");
588
- r([
589
- i({ type: String })
590
- ], o.prototype, "size");
591
- r([
592
- i({ type: Boolean })
593
- ], o.prototype, "loading");
594
- r([
595
- i({ type: String })
596
- ], o.prototype, "maxHeight");
597
- r([
598
- i({ type: String })
599
- ], o.prototype, "emptyText");
600
- r([
601
- i({ type: String })
602
- ], o.prototype, "loadingText");
603
- r([
604
- i({ type: String })
605
- ], o.prototype, "footerLabel");
606
- r([
607
- i({ type: String })
608
- ], o.prototype, "requiredColumnText");
609
- r([
610
- i({ type: String })
611
- ], o.prototype, "reorderColumnText");
612
- r([
613
- i({ type: String })
614
- ], o.prototype, "footerToggleText");
615
- r([
616
- i({ type: String })
617
- ], o.prototype, "columnSettingsText");
618
- r([
619
- i({ type: String })
620
- ], o.prototype, "alignLeftText");
621
- r([
622
- i({ type: String })
623
- ], o.prototype, "alignCenterText");
624
- r([
625
- i({ type: String })
626
- ], o.prototype, "alignRightText");
627
- r([
628
- i({ type: String })
629
- ], o.prototype, "pinNoneText");
630
- r([
631
- i({ type: String })
632
- ], o.prototype, "pinLeftText");
633
- r([
634
- i({ type: String })
635
- ], o.prototype, "pinRightText");
636
- r([
637
- i({ type: String })
638
- ], o.prototype, "columnsText");
639
- r([
640
- i({ type: Object, attribute: !1 })
641
- ], o.prototype, "colFormats");
642
- r([
643
- i({ type: String })
644
- ], o.prototype, "formatTypeText");
645
- r([
646
- i({ type: String })
647
- ], o.prototype, "numberText");
648
- r([
649
- i({ type: String })
650
- ], o.prototype, "percentText");
651
- r([
652
- i({ type: String })
653
- ], o.prototype, "decimalPlacesText");
654
- r([
655
- i({ type: String })
656
- ], o.prototype, "thousandsText");
657
- r([
658
- i({ type: String })
659
- ], o.prototype, "autoText");
660
- r([
661
- i({ type: Boolean })
662
- ], o.prototype, "columnSelectorOpen");
663
- r([
664
- i({ type: Object, attribute: !1 })
665
- ], o.prototype, "group");
666
- r([
667
- i({ type: Boolean, attribute: "tree" })
668
- ], o.prototype, "tree");
669
- r([
670
- i({ type: Number, attribute: "page-size" })
671
- ], o.prototype, "pageSize");
672
- r([
673
- i({ type: Number })
674
- ], o.prototype, "page");
675
- r([
676
- i({ type: String, attribute: "page-mode" })
677
- ], o.prototype, "pageMode");
678
- r([
679
- i({ type: Number, attribute: "total-records" })
680
- ], o.prototype, "totalRecords");
681
- r([
682
- i({ type: String, attribute: "pager-total-text" })
683
- ], o.prototype, "pagerTotalText");
684
- r([
685
- i({ type: String, attribute: "pager-page-text" })
686
- ], o.prototype, "pagerPageText");
687
- r([
688
- i({ type: String, attribute: "prev-page-text" })
689
- ], o.prototype, "prevPageText");
690
- r([
691
- i({ type: String, attribute: "next-page-text" })
692
- ], o.prototype, "nextPageText");
693
- r([
694
- i({ type: String, attribute: "page-size-options" })
695
- ], o.prototype, "pageSizeOptions");
696
- r([
697
- i({ type: String, attribute: "pager-size-text" })
698
- ], o.prototype, "pagerSizeText");
699
- r([
700
- i({ type: String, attribute: "pager-size-label" })
701
- ], o.prototype, "pagerSizeLabel");
702
- K(o, "variant");
703
- k("z-report-table", o);
366
+ c.styles = v + K + M + H + P + k;
367
+ let s = c;
368
+ i([
369
+ o({ type: String, attribute: "selected-row-id" })
370
+ ], s.prototype, "selectedRowId");
371
+ i([
372
+ o({ attribute: !1 })
373
+ ], s.prototype, "rowClass");
374
+ i([
375
+ o({ type: Array, attribute: !1 })
376
+ ], s.prototype, "columns");
377
+ i([
378
+ o({ type: Array, attribute: !1 })
379
+ ], s.prototype, "data");
380
+ i([
381
+ o({ type: Array, attribute: !1 })
382
+ ], s.prototype, "sortState");
383
+ i([
384
+ o({ type: Array, attribute: !1 })
385
+ ], s.prototype, "selectedKeys");
386
+ i([
387
+ o({ type: Boolean })
388
+ ], s.prototype, "selectable");
389
+ i([
390
+ o({ type: Boolean })
391
+ ], s.prototype, "editable");
392
+ i([
393
+ o({ type: Boolean })
394
+ ], s.prototype, "resizable");
395
+ i([
396
+ o({ type: Boolean })
397
+ ], s.prototype, "showColumnSelector");
398
+ i([
399
+ o({ type: String })
400
+ ], s.prototype, "persistKey");
401
+ i([
402
+ o({ type: Boolean })
403
+ ], s.prototype, "rowClickable");
404
+ i([
405
+ o({ type: String })
406
+ ], s.prototype, "sortMode");
407
+ i([
408
+ o({ type: String })
409
+ ], s.prototype, "rowKey");
410
+ i([
411
+ o({ type: Boolean })
412
+ ], s.prototype, "draftMode");
413
+ i([
414
+ o({ type: Boolean })
415
+ ], s.prototype, "showFooter");
416
+ i([
417
+ o({ type: Boolean })
418
+ ], s.prototype, "striped");
419
+ i([
420
+ o({ type: Boolean })
421
+ ], s.prototype, "bordered");
422
+ i([
423
+ o({ type: Boolean })
424
+ ], s.prototype, "virtual");
425
+ i([
426
+ o({ type: Number, attribute: "row-height" })
427
+ ], s.prototype, "rowHeight");
428
+ i([
429
+ o({ type: Boolean })
430
+ ], s.prototype, "lines");
431
+ i([
432
+ o({ type: String })
433
+ ], s.prototype, "size");
434
+ i([
435
+ o({ type: Boolean })
436
+ ], s.prototype, "loading");
437
+ i([
438
+ o({ type: String })
439
+ ], s.prototype, "maxHeight");
440
+ i([
441
+ o({ type: String })
442
+ ], s.prototype, "emptyText");
443
+ i([
444
+ o({ type: String })
445
+ ], s.prototype, "loadingText");
446
+ i([
447
+ o({ type: String })
448
+ ], s.prototype, "footerLabel");
449
+ i([
450
+ o({ type: String })
451
+ ], s.prototype, "requiredColumnText");
452
+ i([
453
+ o({ type: String })
454
+ ], s.prototype, "reorderColumnText");
455
+ i([
456
+ o({ type: String })
457
+ ], s.prototype, "footerToggleText");
458
+ i([
459
+ o({ type: String })
460
+ ], s.prototype, "columnSettingsText");
461
+ i([
462
+ o({ type: String })
463
+ ], s.prototype, "alignLeftText");
464
+ i([
465
+ o({ type: String })
466
+ ], s.prototype, "alignCenterText");
467
+ i([
468
+ o({ type: String })
469
+ ], s.prototype, "alignRightText");
470
+ i([
471
+ o({ type: String })
472
+ ], s.prototype, "pinNoneText");
473
+ i([
474
+ o({ type: String })
475
+ ], s.prototype, "pinLeftText");
476
+ i([
477
+ o({ type: String })
478
+ ], s.prototype, "pinRightText");
479
+ i([
480
+ o({ type: String })
481
+ ], s.prototype, "columnsText");
482
+ i([
483
+ o({ type: Object, attribute: !1 })
484
+ ], s.prototype, "colFormats");
485
+ i([
486
+ o({ type: String })
487
+ ], s.prototype, "formatTypeText");
488
+ i([
489
+ o({ type: String })
490
+ ], s.prototype, "numberText");
491
+ i([
492
+ o({ type: String })
493
+ ], s.prototype, "percentText");
494
+ i([
495
+ o({ type: String })
496
+ ], s.prototype, "decimalPlacesText");
497
+ i([
498
+ o({ type: String })
499
+ ], s.prototype, "thousandsText");
500
+ i([
501
+ o({ type: String })
502
+ ], s.prototype, "autoText");
503
+ i([
504
+ o({ type: Boolean })
505
+ ], s.prototype, "columnSelectorOpen");
506
+ i([
507
+ o({ type: Object, attribute: !1 })
508
+ ], s.prototype, "group");
509
+ i([
510
+ o({ type: Boolean, attribute: "tree" })
511
+ ], s.prototype, "tree");
512
+ i([
513
+ o({ type: Number, attribute: "page-size" })
514
+ ], s.prototype, "pageSize");
515
+ i([
516
+ o({ type: Number })
517
+ ], s.prototype, "page");
518
+ i([
519
+ o({ type: String, attribute: "page-mode" })
520
+ ], s.prototype, "pageMode");
521
+ i([
522
+ o({ type: Number, attribute: "total-records" })
523
+ ], s.prototype, "totalRecords");
524
+ i([
525
+ o({ type: String, attribute: "pager-total-text" })
526
+ ], s.prototype, "pagerTotalText");
527
+ i([
528
+ o({ type: String, attribute: "pager-page-text" })
529
+ ], s.prototype, "pagerPageText");
530
+ i([
531
+ o({ type: String, attribute: "prev-page-text" })
532
+ ], s.prototype, "prevPageText");
533
+ i([
534
+ o({ type: String, attribute: "next-page-text" })
535
+ ], s.prototype, "nextPageText");
536
+ i([
537
+ o({ type: String, attribute: "page-size-options" })
538
+ ], s.prototype, "pageSizeOptions");
539
+ i([
540
+ o({ type: String, attribute: "pager-size-text" })
541
+ ], s.prototype, "pagerSizeText");
542
+ i([
543
+ o({ type: String, attribute: "pager-size-label" })
544
+ ], s.prototype, "pagerSizeLabel");
545
+ O(s, "variant");
546
+ R("z-report-table", s);
704
547
  export {
705
- o as ZReportTable
548
+ s as ZReportTable
706
549
  };
707
550
  //# sourceMappingURL=ReportTable.js.map