@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
package/dist/report.js CHANGED
@@ -1,41 +1,52 @@
1
- import { ZReportCard as t } from "./report/elements/report-card.js";
1
+ import { ZReportCard as a } from "./report/elements/report-card.js";
2
2
  import { ZReportGroupTable as p } from "./report/elements/report-group-table.js";
3
- import { ZChart as x } from "./report/chart/Chart.js";
4
- import { ZChartSeries as T } from "./report/chart/ChartSeries.js";
5
- import { ZChartAxis as l } from "./report/chart/ChartAxis.js";
6
- import { ZGantt as A } from "./report/gantt/Gantt.js";
7
- import { DEFAULT_DAY_WIDTH as L, generateTimelineHeaderData as R } from "./report/gantt/timeline.js";
8
- import { BAR_HEIGHT as c, REAL_HEIGHT as d, buildTree as h, computeTaskLayouts as u, dateToPixels as D, getVisibleRange as _, pixelsToDate as E } from "./report/gantt/layout.js";
9
- import { DEFAULT_COLUMNS as I, listTotalWidth as b } from "./report/gantt/left-list.js";
10
- import { computeArrowPaths as G } from "./report/gantt/arrows.js";
3
+ import { ZChart as i } from "./report/chart/Chart.js";
4
+ import { ZChartSeries as x } from "./report/chart/ChartSeries.js";
5
+ import { ZChartAxis as f } from "./report/chart/ChartAxis.js";
6
+ import "./report/chart/geometry/build.js";
7
+ import { ZGantt as R } from "./report/gantt/Gantt.js";
8
+ import { DEFAULT_DAY_WIDTH as h, generateTimelineHeaderData as n } from "./report/gantt/timeline.js";
9
+ import { BAR_HEIGHT as g, REAL_HEIGHT as u, buildTree as b, computeTaskLayouts as G, dateToPixels as L, getVisibleRange as Z, pixelsToDate as c } from "./report/gantt/layout.js";
10
+ import { DEFAULT_COLUMNS as _, listTotalWidth as E } from "./report/gantt/left-list.js";
11
+ import { computeArrowPaths as I } from "./report/gantt/arrows.js";
11
12
  import { cascadeSchedule as F } from "./report/gantt/schedule.js";
12
13
  import { NEAR_CRITICAL_FLOAT as S, computeCriticalPath as U } from "./report/gantt/critical-path.js";
13
14
  import "./components/tooltip/Tooltip.js";
14
15
  import { ZReportTable as O } from "./report/table/ReportTable.js";
15
- import { ZDataList as k } from "./report/data-list/DataList.js";
16
+ import { getTableCellRenderer as k, listTableCellRenderers as w, registerTableCellRenderer as B, unregisterTableCellRenderer as M } from "./report/table/table-cell-registry.js";
17
+ import { ZDataList as Y } from "./report/data-list/DataList.js";
18
+ import { getChartGeometry as q, listChartGeometries as v, registerChartGeometry as z, unregisterChartGeometry as J } from "./report/chart/geometry/registry.js";
16
19
  export {
17
- c as BAR_HEIGHT,
18
- I as DEFAULT_COLUMNS,
19
- L as DEFAULT_DAY_WIDTH,
20
+ g as BAR_HEIGHT,
21
+ _ as DEFAULT_COLUMNS,
22
+ h as DEFAULT_DAY_WIDTH,
20
23
  S as NEAR_CRITICAL_FLOAT,
21
- d as REAL_HEIGHT,
22
- x as ZChart,
23
- l as ZChartAxis,
24
- T as ZChartSeries,
25
- k as ZDataList,
26
- A as ZGantt,
27
- t as ZReportCard,
24
+ u as REAL_HEIGHT,
25
+ i as ZChart,
26
+ f as ZChartAxis,
27
+ x as ZChartSeries,
28
+ Y as ZDataList,
29
+ R as ZGantt,
30
+ a as ZReportCard,
28
31
  p as ZReportGroupTable,
29
32
  O as ZReportTable,
30
- h as buildTree,
33
+ b as buildTree,
31
34
  F as cascadeSchedule,
32
- G as computeArrowPaths,
35
+ I as computeArrowPaths,
33
36
  U as computeCriticalPath,
34
- u as computeTaskLayouts,
35
- D as dateToPixels,
36
- R as generateTimelineHeaderData,
37
- _ as getVisibleRange,
38
- b as listTotalWidth,
39
- E as pixelsToDate
37
+ G as computeTaskLayouts,
38
+ L as dateToPixels,
39
+ n as generateTimelineHeaderData,
40
+ q as getChartGeometry,
41
+ k as getTableCellRenderer,
42
+ Z as getVisibleRange,
43
+ v as listChartGeometries,
44
+ w as listTableCellRenderers,
45
+ E as listTotalWidth,
46
+ c as pixelsToDate,
47
+ z as registerChartGeometry,
48
+ B as registerTableCellRenderer,
49
+ J as unregisterChartGeometry,
50
+ M as unregisterTableCellRenderer
40
51
  };
41
52
  //# sourceMappingURL=report.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"report.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"report.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
@@ -11,32 +11,8 @@ export declare class ZDatepicker extends BaseElement {
11
11
  max: string;
12
12
  locale: string;
13
13
  open: boolean;
14
- /**
15
- * 精度:`day` 只到日(缺省),`minute` 到分(issue IKWNI3)。
16
- *
17
- * [WHY 是属性而不是「加一个 time 开关」] 它是**同一个值的精度**:选了日期还选不选时间,
18
- * 是这件事本身的属性,不是两件东西的组合。开关式(`time`)下一步就要长成
19
- * `time=yes step=15 withSeconds=no` —— 那是把格式串塞进属性表。
20
- *
21
- * [WHY 缺省 day] 存量用法一个像素都不变。见 `page/data/date-precision.ts`。
22
- */
23
14
  precision: DatepickerPrecision;
24
- /**
25
- * 有值时在框内右侧显示清除入口。
26
- *
27
- * [WHY 缺省关闭] 表单里的「生日」「入职日期」是必填项,清空只会制造一个非法态;
28
- * 只有筛选场景需要「选了能退回不筛」。缺省关 = 现有用法一个像素都不变。
29
- */
30
15
  clearable: boolean;
31
- /**
32
- * 快捷区间(issue IKUE1G):逗号分隔的预设名,如 `近7天,近30天,本月`。
33
- *
34
- * 只在 `mode="range"` 生效 —— 单选日历没有「区间」可快选。
35
- * 点一下 = 写入 start / end 并 emit `z-change`(与手选走同一条出口),然后关面板:
36
- * 快捷键的价值就是「一次点击结束」,选完还留着一个开着的日历等于让人再点一下。
37
- *
38
- * 名字不认识就**不画那个按钮**(与 `actions=` 的口径一致),不猜同义词。
39
- */
40
16
  presets: string;
41
17
  prevMonthLabel: string;
42
18
  nextMonthLabel: string;
@@ -46,24 +22,12 @@ export declare class ZDatepicker extends BaseElement {
46
22
  private _focusISO;
47
23
  private _hoverISO;
48
24
  private _pendingStart;
49
- /**
50
- * `precision="minute"` 时,用户**先填时间、后选日期**的那一段暂存。
51
- *
52
- * [WHY 需要暂存] 时间行的位置在日历下面,但用户完全可能先点时间框再点日期
53
- * (他上一屏刚看过「09:00 的班次」)。没有暂存的话,那次输入会被下一次重画面板
54
- * 抹掉 —— 而界面看起来一切正常,只是他填的分没了。
55
- *
56
- * 只活在面板开着的时候:值里已经有时间时永远优先取值里的(见 `_timeOr`)。
57
- */
58
25
  private _pendingTime;
59
26
  private _pendingTimeEnd;
60
27
  private _lastPanelProps;
61
- /**
62
- * `aria-haspopup` / `aria-expanded` 要落在**槽里那个可聚焦件**上。
63
- * 写在下面的 `<span>` 容器上无障碍树不承认(2026-11-16 CDP 实测)。
64
- */
65
28
  private _triggerAria;
66
29
  private get _locale();
30
+ private get _timed();
67
31
  render(): string;
68
32
  connectedCallback(): void;
69
33
  disconnectedCallback(): void;
@@ -72,29 +36,8 @@ export declare class ZDatepicker extends BaseElement {
72
36
  close(): void;
73
37
  toggle(): void;
74
38
  private _onTriggerClick;
75
- /** 清除钮:挂在 shadowRoot 上(见 connectedCallback 的注释),命中就清值并拦住宿主的 toggle。 */
76
39
  private _onClearClick;
77
- /**
78
- * 触发器上的 `Delete`:清空当前值。
79
- *
80
- * [WHY 需要一条键盘路径] 清除钮是 `tabindex="-1"` 的(它不该占一个 Tab 停靠点 ——
81
- * 触发器本身已经是停靠点),于是**键盘用户没有任何办法清空这个字段**:
82
- * 日期不是能选中再删掉的文本,`z-input` 那套「全选 + 删除」在这里不成立。
83
- *
84
- * [WHY 用 Delete 而不是 Escape] 面板开着时 Esc 是「关面板」,那是更靠前的语义;
85
- * 而 `Delete` 在原生 `<select>`(多选)与各类标签输入里就是「删掉这个值」。
86
- *
87
- * [WHY 还要判可编辑焦点] 槽里塞的可能是 `<z-input>`。若它是可编辑的,Delete 归它
88
- * (删字符),抢过来就等于把一个能打字的输入框弄坏。
89
- */
90
40
  private _onHostKey;
91
- /**
92
- * 清空当前值并通知宿主。
93
- *
94
- * 与 `z-select` 走同一条出口(`z-change` + 空值),不再发明 `z-clear`:
95
- * 消费方(PageView)已经按「值变化」处理,多一个事件名就多一处要记得接的地方。
96
- * 清空后立刻关面板:面板还开着、框里已经没值,用户会以为没点中。
97
- */
98
41
  private _clearValue;
99
42
  private _getTriggerEl;
100
43
  private _resolveSeedISO;
@@ -104,67 +47,16 @@ export declare class ZDatepicker extends BaseElement {
104
47
  private _panelPropsCurrent;
105
48
  private _renderPanelTo;
106
49
  private _focusCell;
107
- /**
108
- * 重渲染打开中的面板。
109
- *
110
- * [WHY] 修复 Gitee IKRAOS:宿主常在 `z-change` 里同步 `close()`("选完立刻收起"),
111
- * 而 `floatingPanel.close()` 会把内部 `_panel` 置 null。此时 `this._floating.panel!`
112
- * 的非空断言只骗过 TS —— 运行时就是 `null.innerHTML`。
113
- * 面板已经关掉就无需重渲染,直接跳过;这里统一收口,避免每处各写一遍判断。
114
- */
115
50
  private _repaintPanel;
116
- private _renderPanel;
117
- /** 时间行的 HTML(渲染在 `time-row.ts`,这里只补上当前值)。 */
118
- private _timeHTML;
119
- /** 某一端当前的时间:值里带的 → 暂存的 → 缺省。 */
120
- private _timeOf;
121
- /**
122
- * 快捷区间那一排 chip(issue IKUE1G)。
123
- *
124
- * 三条规则写在这里,别处不要再算:
125
- * ① 只认 `presets=` 里写到的名字,拼错的不画按钮(不猜同义词);
126
- * ② 区间被 `min` / `max` 夹完为空 ⇒ 按钮置灰(点下去也不会有反应的东西不该可点);
127
- * ③ 只有**完全等于**某个预设时才高亮 —— 手选的自定义区间不许点亮预设,
128
- * 否则用户点它想复位时值没变化 ⇒ 组件不发事件 ⇒ 看着像按钮坏了。
129
- */
130
- private _presetsHTML;
131
- /**
132
- * 点一个预设:写入两端、emit、关面板。
133
- *
134
- * [WHY 与手选走同一条出口] 值的分发只有 `z-change {start,end}` 这一条(PageView 的
135
- * `applyFilters` 也只认它)。预设另发一个事件名的话,宿主得接两套 —— 而漏接的那一套
136
- * 表现为「点了按钮日期变了、数据没变」。
137
- */
138
51
  private _applyPreset;
139
- /** 这台控件要不要时间(`precision="minute"`)。 */
140
- private get _timed();
141
- private _cellHTML;
142
52
  private _onPanelClick;
143
53
  private _selectISO;
144
- /**
145
- * 时间输入变化(失焦 / 回车)。
146
- *
147
- * [WHY 用 `change` 不用 `input`] 边打边提交会把中间的「2」当成 02:00 发出去一次查询,
148
- * 而用户正要打「23」。筛选是**改一项发一次**的链路,那一次查询会真的打到后端。
149
- */
150
54
  private _onPanelChange;
151
- /**
152
- * 读时间框、写回值、发事件。
153
- *
154
- * 三条口径:
155
- * ① **非法值不写入**(`25` / 空)—— 只标红。写一个非法值进去,它会被当成参数下推,
156
- * 后端把不认识的值当没写 ⇒ 查询静默退回全量;
157
- * ② **没有日期时只暂存**:时间单独存在没有意义,等选了日期才拼成一个值;
158
- * ③ **提交后不重画面板**:重画会重建输入框,用户正在里面打字,焦点与光标一起丢。
159
- * 快照同步一次即可(见 `_lastPanelProps` 那行的注释)。
160
- */
161
55
  private _commitTime;
162
56
  private _onPanelMouseOver;
163
57
  private _onPanelMouseLeave;
164
58
  private _onPanelKey;
165
- private _isSelectable;
166
59
  private _moveFocus;
167
- private _moveFocusToWeekBoundary;
168
60
  private _navMonth;
169
61
  private _navYear;
170
62
  }
@@ -0,0 +1,21 @@
1
+ import { type ISOString } from "../../core/index.js";
2
+ export interface DatepickerKeyHost {
3
+ getFocusISO(): ISOString | null;
4
+ getLocale(): string;
5
+ isSelectable(iso: ISOString): boolean;
6
+ moveFocus(iso: ISOString | null, delta: number): void;
7
+ navMonth(dir: number, keepFocus: boolean): void;
8
+ navYear(dir: number): void;
9
+ selectISO(iso: ISOString): void;
10
+ closePanel(): void;
11
+ }
12
+ /** 计算焦点移动后的日期与年月;非法日期返回 null。 */
13
+ export declare function computeShiftedFocus(iso: ISOString | null, delta: number): {
14
+ iso: ISOString;
15
+ year: number;
16
+ month: number;
17
+ } | null;
18
+ /** 计算焦点移动到本周起点或终点的天数偏移。 */
19
+ export declare function computeWeekBoundaryDelta(iso: ISOString | null, locale: string, toEnd: boolean): number | null;
20
+ /** 分发日历面板内键盘导航事件。 */
21
+ export declare function handleDatepickerPanelKey(e: Event, host: DatepickerKeyHost): void;
@@ -0,0 +1,25 @@
1
+ import { type CalendarCell, type ISOString } from "../../core/index.js";
2
+ export interface DatepickerPanelRenderState {
3
+ mode: "single" | "range";
4
+ precision: "day" | "minute";
5
+ value: string;
6
+ start: string;
7
+ end: string;
8
+ min: string;
9
+ max: string;
10
+ locale: string;
11
+ presets: string;
12
+ prevMonthLabel: string;
13
+ nextMonthLabel: string;
14
+ viewYear: number;
15
+ viewMonth: number;
16
+ focusISO: ISOString | null;
17
+ hoverISO: ISOString | null;
18
+ pendingStart: ISOString | null;
19
+ pendingTime: string;
20
+ pendingTimeEnd: string;
21
+ }
22
+ export declare function resolveTimePart(raw: string, pending: string, fallback: string): string;
23
+ export declare function renderDatepickerPresets(s: DatepickerPanelRenderState): string;
24
+ export declare function renderDatepickerCell(s: DatepickerPanelRenderState, cell: CalendarCell, today: ISOString): string;
25
+ export declare function renderDatepickerPanel(s: DatepickerPanelRenderState): string;
@@ -1,13 +1,18 @@
1
1
  import "../form-item/FormItem.js";
2
- import { BaseElement } from "../../core/index.js";
2
+ import { BaseElement, type ControlSize } from "../../core/index.js";
3
+ export { FORM_CONTEXT, type FormContextValue } from "./form-context.js";
3
4
  export declare class ZForm extends BaseElement {
4
5
  static styles: string;
5
6
  /** 外部值快照(只读语义);程序化设值用 setValues() */
6
7
  values: Record<string, unknown>;
7
8
  validateOnChange: boolean;
8
9
  validateOnSubmit: boolean;
10
+ disabled: boolean;
11
+ readonly: boolean;
12
+ controlSize: ControlSize;
13
+ private _ctx;
14
+ protected willUpdate(): void;
9
15
  connectedCallback(): void;
10
- disconnectedCallback(): void;
11
16
  render(): string;
12
17
  /** 实时聚合全部 form-item 值(无名 item 跳过) */
13
18
  getValues(): Record<string, unknown>;
@@ -0,0 +1,11 @@
1
+ import { type ControlSize } from "../../core/index.js";
2
+ /** `<z-form>` 通过 W3C Context Protocol 向后代控件下发的共享表单状态。 */
3
+ export interface FormContextValue {
4
+ disabled: boolean;
5
+ readonly: boolean;
6
+ controlSize: ControlSize;
7
+ }
8
+ /** 表单上下文键:任意深度的子孙组件(含 Shadow DOM 内)均可用 `ContextConsumer` 订阅。 */
9
+ export declare const FORM_CONTEXT: {
10
+ readonly __contextType?: FormContextValue | undefined;
11
+ };
@@ -1,2 +1,2 @@
1
1
  import "./Form.js";
2
- export { ZForm } from "./Form.js";
2
+ export { ZForm, FORM_CONTEXT, type FormContextValue } from "./Form.js";
@@ -1,14 +1,9 @@
1
1
  import { BaseElement, type ControlSize } from "../../core/index.js";
2
- export interface ZSelectOptionSpec {
3
- value: string;
4
- label: string;
5
- disabled?: boolean;
6
- }
7
- export type ZSelectSearchMode = "frontend" | "backend";
2
+ import { type RemoteSearchMethod, type ZSelectSearchMode } from "./option-search.js";
3
+ export type { ZSelectOptionSpec, ZSelectSearchMode } from "./option-search.js";
8
4
  export declare class ZSelect extends BaseElement {
9
5
  static styles: string;
10
6
  size: ControlSize;
11
- protected willUpdate(): void;
12
7
  value: string;
13
8
  placeholder: string;
14
9
  disabled: boolean;
@@ -20,140 +15,42 @@ export declare class ZSelect extends BaseElement {
20
15
  searchPlaceholder: string;
21
16
  loading: boolean;
22
17
  multiple: boolean;
23
- /**
24
- * 有值时是否显示整框「清除」钮。
25
- *
26
- * [WHY 缺省 false] 这是纯增量能力:存量调用方(表单里的普通下拉)外观一个字都不变。
27
- * 筛选场景由渲染层显式打开 —— 那里的「能选不能退」是真问题,下拉本体的默认值不该跟着变。
28
- */
29
18
  clearable: boolean;
30
- /**
31
- * 多选「先勾选、点确定才提交」。
32
- *
33
- * [WHY 需要这个开关 2026-11-02] 筛选栏里的多选是**取数触发器**:每勾一项就发一次
34
- * `z-change`,宿主立刻发一次查询并整页重渲染。勾 5 项 = 5 次查询,中途还会看到半成品
35
- * 结果(只筛了第一项)—— 而且大表查询本身要几百毫秒,用户勾到第三项时第一项的响应才回来,
36
- * 界面在几批数据之间来回跳。筛选场景要的是「选完再查」,这也是主流后台(Ant Design Pro /
37
- * Fusion / SAP Fiori)的形态:下拉里勾,底部「重置 / 确定」。
38
- *
39
- * [WHY 做成 opt-in 而不是改多选的默认行为] 表单里的多选没有「提交」这一步,勾了就该有值。
40
- * 若默认暂存,表单会**静默丢勾选**(用户以为选了,提交却是空)—— 那是比多几次查询严重得多
41
- * 的问题。所以只在筛选渲染层显式打开(`render.ts` 的 multi 控件)。
42
- *
43
- * 关闭面板(点外部 / Esc / Tab)= 丢弃草稿、不发事件,即「没点确定就不生效」。
44
- * 代价是勾完忘了点确定会白选一次,用面板底部的「已选 N 项」提示。
45
- */
46
19
  commitOnConfirm: boolean;
47
- /**
48
- * 多选标签最多展开几个,其余折叠成 `+N`;`0` = 不折叠。
49
- *
50
- * [WHY 缺省是 2 而不是 3] 筛选栏一格定宽 168px(`--zpg-filter` 的窄档),三个中文标签
51
- * 会被压成单字(实测「原料」只剩「原」)。2 个标签 + `+N` 是这个宽度下的实际上限;
52
- * 宽容器要更多就显式写 `max-tags=`。
53
- */
54
20
  maxTags: number;
55
- remoteMethod: ((query: string) => void | ZSelectOptionSpec[] | Promise<ZSelectOptionSpec[]>) | null;
21
+ remoteMethod: RemoteSearchMethod | null;
56
22
  private _floating;
23
+ private _search;
24
+ private _strategy;
57
25
  private _focusTrap;
58
26
  private _activeIndex;
59
- private _query;
60
- /**
61
- * 暂存中的多选值(只在 `commit-on-confirm` 下非 null)。
62
- *
63
- * 与 `value` 分开是为了让「面板里勾了什么」与「控件对外是什么」互不干扰:
64
- * 勾选期间 `value` 一个字都不变(所以 trigger 上的标签、宿主的取数都不会动),
65
- * 只有点「确定」才把草稿一次性写成 `value` 并发一次 `z-change`。
66
- */
67
- /**
68
- * 本实例的 id 前缀。
69
- *
70
- * [WHY 需要它] 选项要有 id 才能被 `aria-activedescendant` 指到,而同一个页面里
71
- * 筛选行常常并排三个 `z-select` —— id 不带实例前缀就会互相指错,读屏念的是隔壁下拉的选项。
72
- */
73
27
  private _uid;
74
- private _draft;
75
- private _searchTimer;
76
- private _optionsObserver;
28
+ protected willUpdate(): void;
77
29
  render(): string;
78
30
  connectedCallback(): void;
79
31
  disconnectedCallback(): void;
80
32
  updated(): void;
33
+ private _syncStrategy;
81
34
  private _getOptions;
82
35
  private _getSelectedOption;
83
- /** 多选当前值。非多选返回 [](多选分支不参与单选逻辑)。 */
84
- private _selectedValues;
85
- /** 是否处于「暂存 + 确认」模式(只有多选才有意义)。 */
86
- private _staging;
87
- /**
88
- * 面板里该显示成「已勾选」的一组值。
89
- *
90
- * 暂存模式下取草稿、否则取已提交值 —— 渲染勾选态与计数都走这一个入口,
91
- * 免得某一处忘了切档(症状是「勾了看不到勾」或「没确定却已经显示为选中」)。
92
- */
93
- private _draftValues;
94
- /**
95
- * 多选标签列表:每个已选值一个标签,标签自带 ×。
96
- *
97
- * [WHY 从「已选 N 项」改成标签] 折叠成计数之后,取消某一项只能重新打开下拉、在长列表里
98
- * 找回那一行再点一次 —— 「当前筛了什么」和「怎么去掉它」被拆到两个坐标上。标签把它们合回一处。
99
- * 超过 `maxTags` 折叠成 `+N`:筛选栏一格约 168px,三个中文标签就撑破。
100
- *
101
- * 选项文案来自数据源,进属性一律 `escapeAttr` / `escapeHtml`(`"` 不转义可闭合 title 注入)。
102
- */
103
- private _renderTags;
104
36
  private _optionByValue;
105
- /** 作者显式写的占位文案(没写 = 空串,与组件默认值区分开)。 */
106
37
  private _authoredPlaceholder;
107
38
  private _getFilteredOptions;
108
39
  private _onTriggerClick;
109
- /**
110
- * 多选去掉一项(标签 ×)。
111
- *
112
- * 值与 `_selectOption` 同一条出口(逗号串 + `z-change`),否则「从标签删」和
113
- * 「从下拉取消勾选」会走出两种状态。面板开着时要同步勾选态:标签没了、下拉里还打着勾,
114
- * 用户会以为没删掉。
115
- */
116
40
  private _removeValue;
117
- /**
118
- * 整框清除。空串 = 不限,与点「value='' 的空值选项」同义。
119
- *
120
- * [WHY 也发 `z-change` 而不是单独的 `z-clear`] 消费方(PageView)已经按「值变化」处理
121
- * 取数与重渲染;再造一个事件就多一条必须被同时监听的路径,漏一个就是「清空后不重新取数」。
122
- */
123
41
  private _clearValue;
124
42
  private _onTriggerKey;
125
43
  private _openDropdown;
126
44
  private _closeDropdown;
127
45
  private _selectOption;
128
- /**
129
- * 提交草稿(暂存模式的「确定」)。
130
- *
131
- * 顺序是**先关面板、再改值、最后发事件**:宿主收到 `z-change` 会重渲染整个筛选栏,
132
- * 这个元素(连同浮层)可能在事件处理里被摘掉 —— 那时再去拆面板就是对已脱离文档的节点
133
- * 做操作,轻则报错重则浮层残留。先把自己收拾干净再交出去。
134
- *
135
- * 值没变就不发事件(否则「打开 → 直接点确定」也会触发一次全量查询)。
136
- */
137
46
  private _commitDraft;
138
- /** 草稿清空(暂存模式的「清空」)。只清草稿,仍需点「确定」才生效。 */
139
47
  private _resetDraft;
140
- /** 底部计数的文案与「清空」的可用态(打开面板、每次勾选都会刷新)。 */
141
48
  private _updateFooter;
142
49
  private _onSearchInput;
143
- private _clearSearchTimer;
144
- private _scheduleRemoteSearch;
145
- private _runRemoteSearch;
146
50
  private _applyRemoteOptions;
147
- private _observeOptions;
148
51
  private _renderOptionList;
149
52
  private _buildOptionsHTML;
150
53
  private _setActiveByElement;
151
- /**
152
- * 面板里「持有键盘焦点、并且能承载 activedescendant」的那个元素。
153
- *
154
- * 搜索模式是输入框(combobox),非搜索模式是 listbox 自身。两者都在 body 这棵树里,
155
- * 与选项同树 —— 这是 IDREF 能解析的前提,不是风格选择。
156
- */
157
54
  private _focusOwner;
158
55
  private _updateActive;
159
56
  private _onDropdownKey;
@@ -0,0 +1,38 @@
1
+ import type { ReactiveController } from "../../core/index.js";
2
+ import type { ZOption } from "../option/Option.js";
3
+ export interface ZSelectOptionSpec {
4
+ value: string;
5
+ label: string;
6
+ disabled?: boolean;
7
+ }
8
+ export type ZSelectSearchMode = "frontend" | "backend";
9
+ export type RemoteSearchMethod = (query: string) => void | ZSelectOptionSpec[] | Promise<ZSelectOptionSpec[]>;
10
+ export interface SearchInputContext {
11
+ searchMode: ZSelectSearchMode;
12
+ remoteMethod: RemoteSearchMethod | null;
13
+ isOpen: () => boolean;
14
+ setLoading: (loading: boolean) => void;
15
+ applySpecs: (specs: ZSelectOptionSpec[]) => void;
16
+ onLocalFilter: () => void;
17
+ onSearchEmit: (query: string) => void;
18
+ }
19
+ /**
20
+ * `<z-select>` 搜索与选项变更观察控制器(ReactiveController)。
21
+ *
22
+ * 托管查询词、远程防抖定时器与子节点 MutationObserver,宿主断开时自动清理,
23
+ * 避免定时器泄漏或悬空观察者。
24
+ */
25
+ export declare class OptionSearchController implements ReactiveController {
26
+ private _query;
27
+ private _timer;
28
+ private _observer;
29
+ get query(): string;
30
+ hostDisconnected(): void;
31
+ reset(): void;
32
+ clearTimer(): void;
33
+ filter(options: ZOption[], searchable: boolean): ZOption[];
34
+ handleInput(value: string, ctx: SearchInputContext): void;
35
+ observeHost(host: HTMLElement, onChange: () => void): void;
36
+ stopObserving(): void;
37
+ private _runRemoteSearch;
38
+ }
@@ -0,0 +1,39 @@
1
+ import type { ZOption } from "../option/Option.js";
2
+ export interface SelectTriggerRenderState {
3
+ open: boolean;
4
+ disabled: boolean;
5
+ invalid: boolean;
6
+ multiple: boolean;
7
+ clearable: boolean;
8
+ maxTags: number;
9
+ placeholder: string;
10
+ authoredPlaceholder: string;
11
+ emptyLabel: string;
12
+ selectedOption: ZOption | undefined;
13
+ selectedValues: string[];
14
+ labelOf: (value: string) => string;
15
+ }
16
+ export interface SelectShellRenderState {
17
+ uid: string;
18
+ searchable: boolean;
19
+ searchPlaceholder: string;
20
+ staging: boolean;
21
+ listName: string;
22
+ }
23
+ export interface SelectOptionsRenderState {
24
+ uid: string;
25
+ options: ZOption[];
26
+ multiple: boolean;
27
+ searchable: boolean;
28
+ query: string;
29
+ activeIndex: number;
30
+ isSelected: (optionValue: string) => boolean;
31
+ }
32
+ /** 渲染多选标签列表(超出 maxTags 折叠为 +N)。 */
33
+ export declare function renderSelectTags(values: string[], maxTags: number, labelOf: (value: string) => string): string;
34
+ /** 渲染 `<z-select>` 触发按钮模板。 */
35
+ export declare function renderSelectTrigger(s: SelectTriggerRenderState): string;
36
+ /** 构建浮层面板外壳(搜索栏 + listbox 容器 + 可选底部确认条)。 */
37
+ export declare function buildSelectDropdownShell(s: SelectShellRenderState): string;
38
+ /** 构建选项列表 HTML。 */
39
+ export declare function buildSelectOptionsHTML(s: SelectOptionsRenderState): string;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * `<z-select>` 选择策略(无头状态机,零 DOM 依赖)。
3
+ *
4
+ * 将「单选 / 多选 / 多选暂存确认(commit-on-confirm)」三种模式从组件类中剥离为
5
+ * 可替换的策略对象,消除宿主内 `multiple && commitOnConfirm` 的组合分支爆炸。
6
+ */
7
+ export type SelectionMode = "single" | "multi" | "draft-multi";
8
+ export interface SelectChangeDetail {
9
+ value: string;
10
+ values?: string[];
11
+ }
12
+ export interface SelectPickResult {
13
+ nextValue?: string;
14
+ closeDropdown: boolean;
15
+ rerenderList: boolean;
16
+ changeDetail?: SelectChangeDetail;
17
+ }
18
+ export interface SelectMutationResult {
19
+ nextValue: string;
20
+ changeDetail: SelectChangeDetail;
21
+ }
22
+ export interface SelectionStrategy {
23
+ readonly mode: SelectionMode;
24
+ readonly isStaging: boolean;
25
+ getCommittedValues(rawValue: string): string[];
26
+ getActiveValues(rawValue: string): string[];
27
+ isSelected(optionValue: string, rawValue: string): boolean;
28
+ onOpen(rawValue: string): void;
29
+ onClose(): void;
30
+ pick(optionValue: string, rawValue: string): SelectPickResult;
31
+ removeValue(value: string, rawValue: string): SelectMutationResult | null;
32
+ clear(rawValue: string): SelectMutationResult | null;
33
+ commit(rawValue: string): SelectMutationResult | null;
34
+ resetDraft(): boolean;
35
+ draftCount(): number;
36
+ }
37
+ /** 解析逗号分隔的多选值(空串返回 [])。 */
38
+ export declare function parseMultiValues(rawValue: string): string[];
39
+ export declare class SingleSelectionStrategy implements SelectionStrategy {
40
+ readonly mode: SelectionMode;
41
+ readonly isStaging = false;
42
+ getCommittedValues(): string[];
43
+ getActiveValues(): string[];
44
+ isSelected(optionValue: string, rawValue: string): boolean;
45
+ onOpen(): void;
46
+ onClose(): void;
47
+ pick(optionValue: string, rawValue: string): SelectPickResult;
48
+ removeValue(): SelectMutationResult | null;
49
+ clear(rawValue: string): SelectMutationResult | null;
50
+ commit(): SelectMutationResult | null;
51
+ resetDraft(): boolean;
52
+ draftCount(): number;
53
+ }
54
+ export declare class MultiSelectionStrategy implements SelectionStrategy {
55
+ readonly mode: SelectionMode;
56
+ readonly isStaging = false;
57
+ getCommittedValues(rawValue: string): string[];
58
+ getActiveValues(rawValue: string): string[];
59
+ isSelected(optionValue: string, rawValue: string): boolean;
60
+ onOpen(): void;
61
+ onClose(): void;
62
+ pick(optionValue: string, rawValue: string): SelectPickResult;
63
+ removeValue(value: string, rawValue: string): SelectMutationResult | null;
64
+ clear(rawValue: string): SelectMutationResult | null;
65
+ commit(): SelectMutationResult | null;
66
+ resetDraft(): boolean;
67
+ draftCount(): number;
68
+ }
69
+ export declare class DraftMultiSelectionStrategy implements SelectionStrategy {
70
+ readonly mode: SelectionMode;
71
+ readonly isStaging = true;
72
+ private _draft;
73
+ getCommittedValues(rawValue: string): string[];
74
+ getActiveValues(rawValue: string): string[];
75
+ isSelected(optionValue: string, rawValue: string): boolean;
76
+ onOpen(rawValue: string): void;
77
+ onClose(): void;
78
+ pick(optionValue: string, rawValue: string): SelectPickResult;
79
+ removeValue(value: string, rawValue: string): SelectMutationResult | null;
80
+ clear(rawValue: string): SelectMutationResult | null;
81
+ commit(rawValue: string): SelectMutationResult | null;
82
+ resetDraft(): boolean;
83
+ draftCount(): number;
84
+ }
85
+ /** 按开关解析对应策略;若当前策略模式未变则直接复用以保留草稿态。 */
86
+ export declare function resolveSelectionStrategy(multiple: boolean, commitOnConfirm: boolean, current?: SelectionStrategy): SelectionStrategy;