@cpsoft13/z-agent-ui 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lines-baseline.json +1 -15
- package/bin/text-baseline.json +1 -2
- package/dist/build-info.json +2 -2
- package/dist/components/context-menu/ContextMenu.js +7 -7
- package/dist/components/context-menu/ContextMenu.js.map +1 -1
- package/dist/components/date-range/DateRange.js +4 -4
- package/dist/components/date-range/DateRange.js.map +1 -1
- package/dist/components/datepicker/Datepicker.js +207 -332
- package/dist/components/datepicker/Datepicker.js.map +1 -1
- package/dist/components/datepicker/datepicker-keyboard.js +66 -0
- package/dist/components/datepicker/datepicker-keyboard.js.map +1 -0
- package/dist/components/datepicker/datepicker-panel-render.js +78 -0
- package/dist/components/datepicker/datepicker-panel-render.js.map +1 -0
- package/dist/components/form/Form.js +69 -47
- package/dist/components/form/Form.js.map +1 -1
- package/dist/components/form/form-context.js +9 -0
- package/dist/components/form/form-context.js.map +1 -0
- package/dist/components/form.js +2 -0
- package/dist/components/form.js.map +1 -1
- package/dist/components/menu/Menu.js +27 -27
- package/dist/components/menu/Menu.js.map +1 -1
- package/dist/components/popover/Popover.js +1 -1
- package/dist/components/popover/Popover.js.map +1 -1
- package/dist/components/select/Select.js +235 -351
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/select/option-search.js +49 -0
- package/dist/components/select/option-search.js.map +1 -0
- package/dist/components/select/select-render.js +75 -0
- package/dist/components/select/select-render.js.map +1 -0
- package/dist/components/select/selection-strategy.js +151 -0
- package/dist/components/select/selection-strategy.js.map +1 -0
- package/dist/components/time-picker/TimePicker.js +1 -1
- package/dist/components/time-picker/TimePicker.js.map +1 -1
- package/dist/components/tooltip/Tooltip.js +16 -16
- package/dist/components/tooltip/Tooltip.js.map +1 -1
- package/dist/core/BaseElement.js +96 -77
- package/dist/core/BaseElement.js.map +1 -1
- package/dist/core/context.js +68 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/controller.js +2 -0
- package/dist/core/controller.js.map +1 -0
- package/dist/core/public.js +35 -30
- package/dist/core/public.js.map +1 -1
- package/dist/core.js +95 -90
- package/dist/core.js.map +1 -1
- package/dist/doc/doc-template-editor-core.js +12 -11
- package/dist/doc/doc-template-editor-core.js.map +1 -1
- package/dist/doc/doc-template-editor-panel.css.js +202 -0
- package/dist/doc/doc-template-editor-panel.css.js.map +1 -0
- package/dist/doc/doc-template-editor.css.js +1 -200
- package/dist/doc/doc-template-editor.css.js.map +1 -1
- package/dist/flow/Flow.js +104 -195
- package/dist/flow/Flow.js.map +1 -1
- package/dist/flow/flow-keyboard-controller.js +101 -0
- package/dist/flow/flow-keyboard-controller.js.map +1 -0
- package/dist/primitives/overlay/floatingPanel.js +6 -2
- package/dist/primitives/overlay/floatingPanel.js.map +1 -1
- package/dist/report/chart/Chart.js +271 -761
- package/dist/report/chart/Chart.js.map +1 -1
- package/dist/report/chart/chart-brush-controller.js +187 -0
- package/dist/report/chart/chart-brush-controller.js.map +1 -0
- package/dist/report/chart/chart-layout-pipeline.js +158 -0
- package/dist/report/chart/chart-layout-pipeline.js.map +1 -0
- package/dist/report/chart/chart-zoom.js +79 -0
- package/dist/report/chart/chart-zoom.js.map +1 -0
- package/dist/report/chart/geometry/build.js +41 -26
- package/dist/report/chart/geometry/build.js.map +1 -1
- package/dist/report/chart/geometry/extra-flow-dist.js +283 -0
- package/dist/report/chart/geometry/extra-flow-dist.js.map +1 -0
- package/dist/report/chart/geometry/extra-radial-grid.js +280 -0
- package/dist/report/chart/geometry/extra-radial-grid.js.map +1 -0
- package/dist/report/chart/geometry/extra-shared.js +36 -0
- package/dist/report/chart/geometry/extra-shared.js.map +1 -0
- package/dist/report/chart/geometry/extra.js +20 -583
- package/dist/report/chart/geometry/extra.js.map +1 -1
- package/dist/report/chart/geometry/registry.js +20 -0
- package/dist/report/chart/geometry/registry.js.map +1 -0
- package/dist/report/chart.js +12 -6
- package/dist/report/chart.js.map +1 -1
- package/dist/report/gantt/Gantt.js +199 -308
- package/dist/report/gantt/Gantt.js.map +1 -1
- package/dist/report/gantt/gantt-bars.css.js +247 -0
- package/dist/report/gantt/gantt-bars.css.js.map +1 -0
- package/dist/report/gantt/gantt-edit-controller.js +94 -0
- package/dist/report/gantt/gantt-edit-controller.js.map +1 -0
- package/dist/report/gantt/gantt.css.js +0 -272
- package/dist/report/gantt/gantt.css.js.map +1 -1
- package/dist/report/table/ReportTable.js +336 -493
- package/dist/report/table/ReportTable.js.map +1 -1
- package/dist/report/table/report-table-config.css.js +172 -0
- package/dist/report/table/report-table-config.css.js.map +1 -0
- package/dist/report/table/report-table-types.js.map +1 -1
- package/dist/report/table/report-table.css.js +0 -176
- package/dist/report/table/report-table.css.js.map +1 -1
- package/dist/report/table/table-cell-registry.js +29 -0
- package/dist/report/table/table-cell-registry.js.map +1 -0
- package/dist/report/table/table-keyboard-controller.js +96 -0
- package/dist/report/table/table-keyboard-controller.js.map +1 -0
- package/dist/report/table/table-pipeline.js +36 -0
- package/dist/report/table/table-pipeline.js.map +1 -0
- package/dist/report/table/table-render.js +97 -96
- package/dist/report/table/table-render.js.map +1 -1
- package/dist/report/table/table-scroll-controller.js +33 -0
- package/dist/report/table/table-scroll-controller.js.map +1 -0
- package/dist/report/table.js +7 -2
- package/dist/report/table.js.map +1 -1
- package/dist/report.js +39 -28
- package/dist/report.js.map +1 -1
- package/dist/types/components/datepicker/Datepicker.d.ts +1 -109
- package/dist/types/components/datepicker/datepicker-keyboard.d.ts +21 -0
- package/dist/types/components/datepicker/datepicker-panel-render.d.ts +25 -0
- package/dist/types/components/form/Form.d.ts +7 -2
- package/dist/types/components/form/form-context.d.ts +11 -0
- package/dist/types/components/form/index.d.ts +1 -1
- package/dist/types/components/select/Select.d.ts +7 -110
- package/dist/types/components/select/option-search.d.ts +38 -0
- package/dist/types/components/select/select-render.d.ts +39 -0
- package/dist/types/components/select/selection-strategy.d.ts +86 -0
- package/dist/types/core/BaseElement.d.ts +7 -1
- package/dist/types/core/context.d.ts +66 -0
- package/dist/types/core/controller.d.ts +22 -0
- package/dist/types/core/public.d.ts +2 -0
- package/dist/types/flow/Flow.d.ts +3 -76
- package/dist/types/flow/flow-keyboard-controller.d.ts +35 -0
- package/dist/types/primitives/overlay/floatingPanel.d.ts +2 -0
- package/dist/types/report/chart/Chart.d.ts +2 -245
- package/dist/types/report/chart/chart-brush-controller.d.ts +59 -0
- package/dist/types/report/chart/chart-layout-pipeline.d.ts +42 -0
- package/dist/types/report/chart/chart-zoom.d.ts +12 -0
- package/dist/types/report/chart/geometry/build.d.ts +2 -0
- package/dist/types/report/chart/geometry/extra-flow-dist.d.ts +6 -0
- package/dist/types/report/chart/geometry/extra-radial-grid.d.ts +6 -0
- package/dist/types/report/chart/geometry/extra-shared.d.ts +24 -0
- package/dist/types/report/chart/geometry/extra.d.ts +2 -34
- package/dist/types/report/chart/geometry/registry.d.ts +26 -0
- package/dist/types/report/chart/index.d.ts +1 -0
- package/dist/types/report/gantt/Gantt.d.ts +7 -97
- package/dist/types/report/gantt/gantt-edit-controller.d.ts +34 -0
- package/dist/types/report/table/ReportTable.d.ts +9 -180
- package/dist/types/report/table/index.d.ts +1 -0
- package/dist/types/report/table/report-table-types.d.ts +2 -0
- package/dist/types/report/table/table-cell-registry.d.ts +17 -0
- package/dist/types/report/table/table-keyboard-controller.d.ts +30 -0
- package/dist/types/report/table/table-pipeline.d.ts +33 -0
- package/dist/types/report/table/table-scroll-controller.d.ts +25 -0
- package/dist/z-agent-ui.js +35 -30
- package/dist/z-agent-ui.js.map +1 -1
- package/package.json +1 -1
- package/registry/component-manifest.json +39 -7
- package/src/components/context-menu/ContextMenu.ts +1 -1
- package/src/components/date-range/DateRange.ts +1 -1
- package/src/components/datepicker/Datepicker.ts +99 -417
- package/src/components/datepicker/datepicker-keyboard.ts +94 -0
- package/src/components/datepicker/datepicker-panel-render.ts +169 -0
- package/src/components/form/Form.ts +39 -11
- package/src/components/form/form-context.ts +11 -0
- package/src/components/form/index.ts +1 -1
- package/src/components/menu/Menu.ts +1 -1
- package/src/components/popover/Popover.ts +1 -1
- package/src/components/select/Select.ts +140 -525
- package/src/components/select/option-search.ts +114 -0
- package/src/components/select/select-render.ts +161 -0
- package/src/components/select/selection-strategy.ts +245 -0
- package/src/components/time-picker/TimePicker.ts +1 -1
- package/src/components/tooltip/Tooltip.ts +1 -1
|
@@ -1,188 +1,143 @@
|
|
|
1
|
-
import { BaseElement as
|
|
2
|
-
import { property as
|
|
3
|
-
import { html as
|
|
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
|
|
7
|
-
import { COPY as
|
|
8
|
-
import { defineElement as
|
|
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
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import "
|
|
20
|
-
import "
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
var
|
|
29
|
-
for (var n = void 0,
|
|
30
|
-
(h =
|
|
31
|
-
return 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
|
|
33
|
+
const b = 32, ut = 24, ft = 2e3, c = class c extends T {
|
|
34
34
|
constructor() {
|
|
35
|
-
super(
|
|
36
|
-
var
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
75
|
-
|
|
76
|
-
}, this._onColumnSelectorOpenEvent = (
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
79
|
-
const
|
|
80
|
-
this.columnSelectorOpen !==
|
|
81
|
-
}, this._onTableChange = (
|
|
82
|
-
this._onPagerSizeChange(
|
|
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
|
|
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
|
|
149
|
-
const e = (h = (
|
|
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
|
|
152
|
-
return n ? this._collapsed.add(
|
|
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,
|
|
157
|
-
const e = (
|
|
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
|
|
160
|
-
return this.
|
|
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,
|
|
165
|
-
const e = (
|
|
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
|
|
168
|
-
return !Number.isFinite(
|
|
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(),
|
|
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
|
-
|
|
133
|
+
(t = this._unbindColDrag) == null || t.call(this), this._unbindColDrag = null, super.disconnectedCallback();
|
|
177
134
|
}
|
|
178
|
-
|
|
179
|
-
/** 兼容读:`variant="lines"` → `lines`,`variant="default"` → 关掉。 */
|
|
180
|
-
attributeChangedCallback(t, e, s) {
|
|
135
|
+
attributeChangedCallback(t, e, r) {
|
|
181
136
|
if (t === "variant") {
|
|
182
|
-
|
|
137
|
+
r === "lines" ? this.lines = !0 : r === "default" && (this.lines = !1);
|
|
183
138
|
return;
|
|
184
139
|
}
|
|
185
|
-
super.attributeChangedCallback(t, e,
|
|
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,
|
|
196
|
-
this._leftOffsets =
|
|
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(" "),
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
},
|
|
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.
|
|
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
|
-
},
|
|
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
|
-
},
|
|
247
|
-
${this.selectable ?
|
|
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
|
|
250
|
-
return
|
|
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 ?
|
|
212
|
+
${e ? d`<col style="width:${b}px">` : ""}
|
|
253
213
|
</colgroup>` : "";
|
|
254
|
-
return
|
|
255
|
-
${
|
|
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
|
-
${
|
|
260
|
-
<thead class="z-rpt__head" part="head">${
|
|
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 ?
|
|
263
|
-
${this._paged.total ?
|
|
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 ?
|
|
225
|
+
${this.showFooter && t.length > 0 ? Y(C) : ""}
|
|
266
226
|
</table>
|
|
267
|
-
${this.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">${
|
|
229
|
+
<span class="z-rpt__loading-text">${z(this.loadingText)}</span>
|
|
270
230
|
</div>` : ""}
|
|
271
231
|
</div>
|
|
272
|
-
${
|
|
232
|
+
${W(this._paged, this)}
|
|
273
233
|
`;
|
|
274
234
|
}
|
|
275
235
|
_ensureSelectorEl() {
|
|
276
|
-
this._selectorEl =
|
|
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,
|
|
283
|
-
this._bindEvents()
|
|
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
|
-
),
|
|
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
|
|
292
|
-
n.checked =
|
|
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
|
-
(
|
|
252
|
+
(r = this._selectorEl) == null || r.reposition();
|
|
296
253
|
}
|
|
297
|
-
// ── Config snapshot (external persistence) ─────────────
|
|
298
254
|
getConfig() {
|
|
299
|
-
return
|
|
255
|
+
return q(this, this._columnWidths);
|
|
300
256
|
}
|
|
301
257
|
applyConfig(t) {
|
|
302
|
-
|
|
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 [
|
|
320
|
-
const
|
|
321
|
-
!Number.isFinite(
|
|
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() }),
|
|
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) =>
|
|
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((
|
|
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((
|
|
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((
|
|
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((
|
|
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 =
|
|
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
|
-
|
|
524
|
-
let
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
],
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
],
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
],
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
],
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
],
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
],
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
],
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
],
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
],
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
],
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
],
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
],
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
],
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
],
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
],
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
],
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
],
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
],
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
],
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
],
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
],
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
],
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
],
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
],
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
],
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
],
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
],
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
],
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
],
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
],
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
],
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
],
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
],
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
],
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
],
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
],
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
],
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
],
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
],
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
],
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
],
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
],
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
],
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
],
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
],
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
],
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
],
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
],
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
],
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
],
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
],
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
],
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
],
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
],
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
],
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
],
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
],
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
],
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
],
|
|
702
|
-
|
|
703
|
-
|
|
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
|
-
|
|
548
|
+
s as ZReportTable
|
|
706
549
|
};
|
|
707
550
|
//# sourceMappingURL=ReportTable.js.map
|