@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,150 +1,124 @@
1
- import { BaseElement as x } from "../../core/BaseElement.js";
2
- import { property as h } from "../../core/decorators.js";
3
- import { html as v, escapeAttr as u, escapeHtml as D } from "../../core/template.js";
4
- import { injectGlobalStyles as $ } from "../../core/styleInjection.js";
5
- import { t as b } from "../../core/i18n.js";
6
- import { isISOInRange as g, parseISO as p, dayOf as o, todayISO as T, formatISO as w, getFirstDayOfWeek as O, buildGrid as Y, timeOf as F, composeDateTime as _, compareISO as m } from "../../core/date/calendar.js";
7
- import { presetRangeOf as M, clampPresetRange as C, presetIsActive as H } from "../../core/date/presets.js";
8
- import { COPY as P } from "../../core/copy.js";
9
- import { defineElement as R } from "../../core/define.js";
10
- import { bindTriggerAria as A, isEditableElement as B, ariaBool as K } from "../../core/a11y.js";
1
+ import { BaseElement as S } from "../../core/BaseElement.js";
2
+ import { property as o } from "../../core/decorators.js";
3
+ import { html as y } from "../../core/template.js";
4
+ import { injectGlobalStyles as O } from "../../core/styleInjection.js";
5
+ import "../../core/i18n.js";
6
+ import { isISOInRange as v, parseISO as _, dayOf as l, todayISO as k, formatISO as C, composeDateTime as c, compareISO as T } from "../../core/date/calendar.js";
7
+ import { presetRangeOf as w, clampPresetRange as M } from "../../core/date/presets.js";
8
+ import { COPY as m } from "../../core/copy.js";
9
+ import { defineElement as I } from "../../core/define.js";
10
+ import { bindTriggerAria as E, isEditableElement as b } from "../../core/a11y.js";
11
11
  import "../../primitives/portal/Portal.js";
12
12
  import "../../primitives/position/Position.js";
13
- import { FloatingPanelController as j } from "../../primitives/overlay/floatingPanel.js";
14
- import q from "./datepicker.css.js";
15
- import { DATEPICKER_PANEL_CSS as V } from "./panel-styles.js";
16
- import { timeRowHtml as L, readTimeSide as W } from "./time-row.js";
17
- import { getMonthLabel as G, renderGridTable as U } from "./calendar.js";
18
- var N = Object.defineProperty, c = (S, e, i, t) => {
19
- for (var s = void 0, n = S.length - 1, r; n >= 0; n--)
20
- (r = S[n]) && (s = r(e, i, s) || s);
21
- return s && N(e, i, s), s;
13
+ import { FloatingPanelController as L } from "../../primitives/overlay/floatingPanel.js";
14
+ import x from "./datepicker.css.js";
15
+ import { DATEPICKER_PANEL_CSS as z } from "./panel-styles.js";
16
+ import { readTimeSide as Y } from "./time-row.js";
17
+ import { renderDatepickerPanel as D, resolveTimePart as d } from "./datepicker-panel-render.js";
18
+ import { handleDatepickerPanelKey as R, computeShiftedFocus as F } from "./datepicker-keyboard.js";
19
+ var K = Object.defineProperty, h = (f, t, e, i) => {
20
+ for (var s = void 0, n = f.length - 1, r; n >= 0; n--)
21
+ (r = f[n]) && (s = r(t, e, s) || s);
22
+ return s && K(t, e, s), s;
22
23
  };
23
- function z() {
24
- $("z-datepicker", V);
24
+ function P() {
25
+ O("z-datepicker", z);
25
26
  }
26
- const k = class k extends x {
27
+ const g = class g extends S {
27
28
  constructor() {
28
- super(...arguments), this.mode = "single", this.value = "", this.start = "", this.end = "", this.min = "", this.max = "", this.locale = "", this.open = !1, this.precision = "day", this.clearable = !1, this.presets = "", this.prevMonthLabel = P.prevMonth, this.nextMonthLabel = P.nextMonth, this._floating = new j(this), this._viewYear = 0, this._viewMonth = 0, this._focusISO = null, this._hoverISO = null, this._pendingStart = null, this._pendingTime = "", this._pendingTimeEnd = "", this._lastPanelProps = "", this._triggerAria = A(
29
+ super(...arguments), this.mode = "single", this.value = "", this.start = "", this.end = "", this.min = "", this.max = "", this.locale = "", this.open = !1, this.precision = "day", this.clearable = !1, this.presets = "", this.prevMonthLabel = m.prevMonth, this.nextMonthLabel = m.nextMonth, this._floating = this.addController(new L(this)), this._viewYear = 0, this._viewMonth = 0, this._focusISO = null, this._hoverISO = null, this._pendingStart = null, this._pendingTime = "", this._pendingTimeEnd = "", this._lastPanelProps = "", this._triggerAria = E(
29
30
  () => {
30
- var e;
31
- return ((e = this.shadowRoot) == null ? void 0 : e.querySelector('slot[name="trigger"]')) ?? null;
31
+ var t;
32
+ return ((t = this.shadowRoot) == null ? void 0 : t.querySelector('slot[name="trigger"]')) ?? null;
32
33
  },
33
34
  () => ({ hasPopup: "dialog", expanded: this.open })
34
35
  ), this._onTriggerClick = () => {
35
36
  this.toggle();
36
- }, this._onClearClick = (e) => {
37
- var t, s;
38
- const i = ((t = e.composedPath) == null ? void 0 : t.call(e)[0]) ?? e.target;
39
- (s = i == null ? void 0 : i.closest) != null && s.call(i, ".z-datepicker__clear") && (e.preventDefault(), e.stopPropagation(), this._clearValue());
40
- }, this._onHostKey = (e) => {
37
+ }, this._onClearClick = (t) => {
38
+ var i, s;
39
+ const e = ((i = t.composedPath) == null ? void 0 : i.call(t)[0]) ?? t.target;
40
+ (s = e == null ? void 0 : e.closest) != null && s.call(e, ".z-datepicker__clear") && (t.preventDefault(), t.stopPropagation(), this._clearValue());
41
+ }, this._onHostKey = (t) => {
41
42
  var n;
42
- const i = e;
43
- if (i.key !== "Delete" || this.open || !this.clearable || !(this.mode === "range" ? !!(this.start || this.end) : !!this.value)) return;
44
- const s = ((n = e.composedPath) == null ? void 0 : n.call(e)[0]) ?? e.target;
45
- B(s) || (i.preventDefault(), this._clearValue());
46
- }, this._onPanelClick = (e) => {
47
- const i = e.target, t = i.closest("[data-preset]");
48
- if (t) {
49
- if (e.preventDefault(), t.disabled) return;
50
- this._applyPreset(t.dataset.preset ?? "");
43
+ const e = t;
44
+ if (e.key !== "Delete" || this.open || !this.clearable || !(this.mode === "range" ? !!(this.start || this.end) : !!this.value)) return;
45
+ const s = ((n = t.composedPath) == null ? void 0 : n.call(t)[0]) ?? t.target;
46
+ b(s) || (e.preventDefault(), this._clearValue());
47
+ }, this._onPanelClick = (t) => {
48
+ const e = t.target, i = e.closest("[data-preset]");
49
+ if (i) {
50
+ if (t.preventDefault(), i.disabled) return;
51
+ this._applyPreset(i.dataset.preset ?? "");
51
52
  return;
52
53
  }
53
- const s = i.closest("[data-nav]");
54
+ const s = e.closest("[data-nav]");
54
55
  if (s) {
55
- e.preventDefault(), this._navMonth(s.dataset.nav === "next" ? 1 : -1, !1);
56
+ t.preventDefault(), this._navMonth(s.dataset.nav === "next" ? 1 : -1, !1);
56
57
  return;
57
58
  }
58
- if (i.closest("[data-time-done]")) {
59
- e.preventDefault(), this._commitTime(), this._closePanel();
59
+ if (e.closest("[data-time-done]")) {
60
+ t.preventDefault(), this._commitTime(), this._closePanel();
60
61
  return;
61
62
  }
62
- if (i.closest("[data-time-part]")) return;
63
- const n = i.closest("[data-iso]");
63
+ if (e.closest("[data-time-part]")) return;
64
+ const n = e.closest("[data-iso]");
64
65
  if (!n) return;
65
66
  const r = n.dataset.iso;
66
- if (g(r, this.min, this.max)) {
67
+ if (v(r, this.min, this.max)) {
67
68
  if (n.classList.contains("z-datepicker__cell--out")) {
68
- const a = p(r);
69
- a && (this._viewYear = a.getFullYear(), this._viewMonth = a.getMonth());
69
+ const p = _(r);
70
+ p && (this._viewYear = p.getFullYear(), this._viewMonth = p.getMonth());
70
71
  }
71
72
  this._selectISO(r);
72
73
  }
73
- }, this._onPanelChange = (e) => {
74
- var t, s;
75
- (s = (t = e.target) == null ? void 0 : t.closest) != null && s.call(t, "[data-time-part]") && this._commitTime();
76
- }, this._onPanelMouseOver = (e) => {
74
+ }, this._onPanelChange = (t) => {
75
+ var i, s;
76
+ (s = (i = t.target) == null ? void 0 : i.closest) != null && s.call(i, "[data-time-part]") && this._commitTime();
77
+ }, this._onPanelMouseOver = (t) => {
77
78
  if (this.mode !== "range" || !this._pendingStart) return;
78
- const i = e.target.closest("[data-iso]");
79
- if (!i) return;
80
- const t = i.dataset.iso;
81
- t !== this._hoverISO && (this._hoverISO = t, this._repaintPanel());
79
+ const e = t.target.closest("[data-iso]");
80
+ if (!e) return;
81
+ const i = e.dataset.iso;
82
+ i !== this._hoverISO && (this._hoverISO = i, this._repaintPanel());
82
83
  }, this._onPanelMouseLeave = () => {
83
84
  this._hoverISO && (this._hoverISO = null, this._repaintPanel());
84
- }, this._onPanelKey = (e) => {
85
- const i = e, t = this._focusISO;
86
- switch (i.key) {
87
- case "ArrowLeft":
88
- e.preventDefault(), this._moveFocus(t, -1);
89
- break;
90
- case "ArrowRight":
91
- e.preventDefault(), this._moveFocus(t, 1);
92
- break;
93
- case "ArrowUp":
94
- e.preventDefault(), this._moveFocus(t, -7);
95
- break;
96
- case "ArrowDown":
97
- e.preventDefault(), this._moveFocus(t, 7);
98
- break;
99
- case "Home":
100
- e.preventDefault(), this._moveFocusToWeekBoundary(t, !1);
101
- break;
102
- case "End":
103
- e.preventDefault(), this._moveFocusToWeekBoundary(t, !0);
104
- break;
105
- case "PageUp":
106
- e.preventDefault(), i.shiftKey ? this._navYear(-1) : this._navMonth(-1, !0);
107
- break;
108
- case "PageDown":
109
- e.preventDefault(), i.shiftKey ? this._navYear(1) : this._navMonth(1, !0);
110
- break;
111
- case "Enter":
112
- case " ":
113
- e.preventDefault(), t && this._isSelectable(t) && this._selectISO(t);
114
- break;
115
- case "Escape":
116
- e.preventDefault(), this._closePanel();
117
- break;
118
- case "Tab":
119
- this._closePanel();
120
- break;
121
- }
85
+ }, this._onPanelKey = (t) => {
86
+ R(t, {
87
+ getFocusISO: () => this._focusISO,
88
+ getLocale: () => this._locale,
89
+ isSelectable: (e) => _(e) !== null && v(e, this.min, this.max),
90
+ moveFocus: (e, i) => this._moveFocus(e, i),
91
+ navMonth: (e, i) => this._navMonth(e, i),
92
+ navYear: (e) => this._navYear(e),
93
+ selectISO: (e) => this._selectISO(e),
94
+ closePanel: () => this._closePanel()
95
+ });
122
96
  };
123
97
  }
124
98
  get _locale() {
125
99
  return this.locale || navigator.language || "en-US";
126
100
  }
101
+ get _timed() {
102
+ return this.precision === "minute";
103
+ }
127
104
  render() {
128
- const e = this.mode === "range" ? !!(this.start || this.end) : !!this.value, i = this.clearable && e ? `<span class="z-datepicker__clear" part="clear" role="button" tabindex="-1" aria-label="${P.clear}"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" aria-hidden="true"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg></span>` : "";
129
- return v`
105
+ const t = this.mode === "range" ? !!(this.start || this.end) : !!this.value, e = this.clearable && t ? `<span class="z-datepicker__clear" part="clear" role="button" tabindex="-1" aria-label="${m.clear}"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" aria-hidden="true"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg></span>` : "";
106
+ return y`
130
107
  <span
131
108
  class="z-datepicker__trigger ${this.open ? "z-datepicker__trigger--open" : ""}"
132
109
  part="trigger"
133
110
  >
134
111
  <slot name="trigger"></slot>
135
- ${i}
112
+ ${e}
136
113
  </span>
137
114
  `;
138
115
  }
139
116
  connectedCallback() {
140
- var e;
141
- super.connectedCallback(), z(), (e = this.shadowRoot) == null || e.addEventListener("click", this._onClearClick), this.addEventListener("click", this._onTriggerClick), this.addEventListener("keydown", this._onHostKey);
117
+ super.connectedCallback(), P(), this.shadowRoot && this.listen(this.shadowRoot, "click", this._onClearClick), this.listen(this, "click", this._onTriggerClick), this.listen(this, "keydown", this._onHostKey);
142
118
  }
143
119
  disconnectedCallback() {
144
- var e;
145
- this._closePanel(), this._triggerAria.dispose(), (e = this.shadowRoot) == null || e.removeEventListener("click", this._onClearClick), this.removeEventListener("click", this._onTriggerClick), this.removeEventListener("keydown", this._onHostKey), super.disconnectedCallback();
120
+ this._closePanel(), this._triggerAria.dispose(), super.disconnectedCallback();
146
121
  }
147
- // 外部属性变更(min/max/mode/locale/value/start/end)时重渲染打开中的面板
148
122
  updated() {
149
123
  this._triggerAria.sync(), this.open && this._floating.panel && !this._panelPropsCurrent() && (this._renderPanelTo(this._floating.panel), this._focusCell());
150
124
  }
@@ -157,13 +131,6 @@ const k = class k extends x {
157
131
  toggle() {
158
132
  this.open ? this._closePanel() : this._openPanel();
159
133
  }
160
- /**
161
- * 清空当前值并通知宿主。
162
- *
163
- * 与 `z-select` 走同一条出口(`z-change` + 空值),不再发明 `z-clear`:
164
- * 消费方(PageView)已经按「值变化」处理,多一个事件名就多一处要记得接的地方。
165
- * 清空后立刻关面板:面板还开着、框里已经没值,用户会以为没点中。
166
- */
167
134
  _clearValue() {
168
135
  if (this.mode === "range") {
169
136
  if (!this.start && !this.end) return;
@@ -173,275 +140,183 @@ const k = class k extends x {
173
140
  this.value && (this.value = "", this._pendingTime = "", this._closePanel(), this.emit("z-change", { value: "" }));
174
141
  }
175
142
  _getTriggerEl() {
176
- const e = this.shadowRoot.querySelector('slot[name="trigger"]'), i = e == null ? void 0 : e.assignedElements();
177
- return i && i[0] || null;
143
+ const t = this.shadowRoot.querySelector('slot[name="trigger"]'), e = t == null ? void 0 : t.assignedElements();
144
+ return e && e[0] || null;
178
145
  }
179
146
  _resolveSeedISO() {
180
- return this.value && p(o(this.value)) ? o(this.value) : this.start && p(o(this.start)) ? o(this.start) : this.end && p(o(this.end)) ? o(this.end) : T();
147
+ return this.value && _(l(this.value)) ? l(this.value) : this.start && _(l(this.start)) ? l(this.start) : this.end && _(l(this.end)) ? l(this.end) : k();
181
148
  }
182
149
  _openPanel() {
183
150
  if (this.open) return;
184
- z();
185
- const e = p(this._resolveSeedISO()) ?? /* @__PURE__ */ new Date();
186
- this._viewYear = e.getFullYear(), this._viewMonth = e.getMonth(), this._focusISO = w(e), this._pendingStart = this.mode === "range" && this.start && !this.end ? o(this.start) : null, this._hoverISO = null, this._pendingTime = "", this._pendingTimeEnd = "";
187
- const i = this._floating.open({
188
- panelClass: "z-datepicker__panel",
189
- hidingClass: "z-datepicker__panel--hiding",
190
- ariaLabel: "Datepicker",
191
- // [WHY] anchor 用 getter:open 触发重渲染替换 shadow 内 trigger,持旧引用滚动时定位读全 0(2026-09-10)
192
- // See: wiki/bugs/bug-20260910-select-dropdown-scroll-anchor.md
193
- anchor: () => this.shadowRoot.querySelector(".z-datepicker__trigger"),
194
- onOutsideClose: () => this._closePanel()
195
- }, (t) => this._renderPanelTo(t));
196
- i.addEventListener("click", this._onPanelClick), i.addEventListener("mouseover", this._onPanelMouseOver), i.addEventListener("mouseleave", this._onPanelMouseLeave), i.addEventListener("keydown", this._onPanelKey), i.addEventListener("change", this._onPanelChange), this.open = !0, this._focusCell(), this.emit("z-datepicker-open");
151
+ P();
152
+ const t = _(this._resolveSeedISO()) ?? /* @__PURE__ */ new Date();
153
+ this._viewYear = t.getFullYear(), this._viewMonth = t.getMonth(), this._focusISO = C(t), this._pendingStart = this.mode === "range" && this.start && !this.end ? l(this.start) : null, this._hoverISO = null, this._pendingTime = "", this._pendingTimeEnd = "";
154
+ const e = this._floating.open(
155
+ {
156
+ panelClass: "z-datepicker__panel",
157
+ hidingClass: "z-datepicker__panel--hiding",
158
+ ariaLabel: "Datepicker",
159
+ anchor: () => this.shadowRoot.querySelector(".z-datepicker__trigger"),
160
+ onOutsideClose: () => this._closePanel()
161
+ },
162
+ (i) => this._renderPanelTo(i)
163
+ );
164
+ e.addEventListener("click", this._onPanelClick), e.addEventListener("mouseover", this._onPanelMouseOver), e.addEventListener("mouseleave", this._onPanelMouseLeave), e.addEventListener("keydown", this._onPanelKey), e.addEventListener("change", this._onPanelChange), this.open = !0, this._focusCell(), this.emit("z-datepicker-open");
197
165
  }
198
166
  _closePanel() {
199
- var i;
167
+ var e;
200
168
  if (!this.open) return;
201
- const e = this._floating.panel;
202
- e == null || e.removeEventListener("click", this._onPanelClick), e == null || e.removeEventListener("mouseover", this._onPanelMouseOver), e == null || e.removeEventListener("mouseleave", this._onPanelMouseLeave), e == null || e.removeEventListener("keydown", this._onPanelKey), e == null || e.removeEventListener("change", this._onPanelChange), this._floating.close(), this.open = !1, this._hoverISO = null, this._pendingStart = null, this._pendingTime = "", this._pendingTimeEnd = "", this._focusISO = null, (i = this._getTriggerEl()) == null || i.focus(), this.emit("z-datepicker-close");
169
+ const t = this._floating.panel;
170
+ t == null || t.removeEventListener("click", this._onPanelClick), t == null || t.removeEventListener("mouseover", this._onPanelMouseOver), t == null || t.removeEventListener("mouseleave", this._onPanelMouseLeave), t == null || t.removeEventListener("keydown", this._onPanelKey), t == null || t.removeEventListener("change", this._onPanelChange), this._floating.close(), this.open = !1, this._hoverISO = null, this._pendingStart = null, this._pendingTime = "", this._pendingTimeEnd = "", this._focusISO = null, (e = this._getTriggerEl()) == null || e.focus(), this.emit("z-datepicker-close");
203
171
  }
204
172
  _panelPropsSnapshot() {
205
- return [this.mode, this.value, this.start, this.end, this.min, this.max, this._locale, this.presets, this.precision].join("|");
173
+ return [
174
+ this.mode,
175
+ this.value,
176
+ this.start,
177
+ this.end,
178
+ this.min,
179
+ this.max,
180
+ this._locale,
181
+ this.presets,
182
+ this.precision
183
+ ].join("|");
206
184
  }
207
185
  _panelPropsCurrent() {
208
186
  return this._panelPropsSnapshot() === this._lastPanelProps;
209
187
  }
210
- _renderPanelTo(e) {
211
- e.innerHTML = this._renderPanel(), this._lastPanelProps = this._panelPropsSnapshot();
188
+ _renderPanelTo(t) {
189
+ t.innerHTML = D({
190
+ mode: this.mode,
191
+ precision: this.precision,
192
+ value: this.value,
193
+ start: this.start,
194
+ end: this.end,
195
+ min: this.min,
196
+ max: this.max,
197
+ locale: this._locale,
198
+ presets: this.presets,
199
+ prevMonthLabel: this.prevMonthLabel,
200
+ nextMonthLabel: this.nextMonthLabel,
201
+ viewYear: this._viewYear,
202
+ viewMonth: this._viewMonth,
203
+ focusISO: this._focusISO,
204
+ hoverISO: this._hoverISO,
205
+ pendingStart: this._pendingStart,
206
+ pendingTime: this._pendingTime,
207
+ pendingTimeEnd: this._pendingTimeEnd
208
+ }), this._lastPanelProps = this._panelPropsSnapshot();
212
209
  }
213
210
  _focusCell() {
214
- var i;
215
- const e = (i = this._floating.panel) == null ? void 0 : i.querySelector(".z-datepicker__cell--focus");
216
- e == null || e.focus();
211
+ var e;
212
+ const t = (e = this._floating.panel) == null ? void 0 : e.querySelector(".z-datepicker__cell--focus");
213
+ t == null || t.focus();
217
214
  }
218
- /**
219
- * 重渲染打开中的面板。
220
- *
221
- * [WHY] 修复 Gitee IKRAOS:宿主常在 `z-change` 里同步 `close()`("选完立刻收起"),
222
- * 而 `floatingPanel.close()` 会把内部 `_panel` 置 null。此时 `this._floating.panel!`
223
- * 的非空断言只骗过 TS —— 运行时就是 `null.innerHTML`。
224
- * 面板已经关掉就无需重渲染,直接跳过;这里统一收口,避免每处各写一遍判断。
225
- */
226
215
  _repaintPanel() {
227
- const e = this._floating.panel;
228
- e && this._renderPanelTo(e);
229
- }
230
- _renderPanel() {
231
- const e = this._locale, i = O(e), t = Y(this._viewYear, this._viewMonth, i), s = T(), n = G(e, this._viewYear, this._viewMonth);
232
- return v`
233
- ${this._presetsHTML()}
234
- <div class="z-datepicker__header" part="header">
235
- <button type="button" class="z-datepicker__nav" data-nav="prev" part="nav-prev" aria-label="${u(this.prevMonthLabel)}">‹</button>
236
- <div class="z-datepicker__label" part="label">${n}</div>
237
- <button type="button" class="z-datepicker__nav" data-nav="next" part="nav-next" aria-label="${u(this.nextMonthLabel)}">›</button>
238
- </div>
239
- ${U({
240
- prefix: "z-datepicker",
241
- locale: e,
242
- weekStart: i,
243
- cells: t,
244
- today: s,
245
- ariaLabel: n,
246
- cellHTML: (r, a) => this._cellHTML(r, a)
247
- })}
248
- ${this._timeHTML()}
249
- `;
250
- }
251
- /** 时间行的 HTML(渲染在 `time-row.ts`,这里只补上当前值)。 */
252
- _timeHTML() {
253
- return this._timed ? this.mode === "range" ? L({
254
- mode: "range",
255
- time: this._timeOf(this.start, this._pendingTime, "00:00"),
256
- timeTo: this._timeOf(this.end, this._pendingTimeEnd, "23:59")
257
- }) : L({
258
- mode: "single",
259
- time: this._timeOf(this.value, this._pendingTime, "00:00"),
260
- timeTo: ""
261
- }) : "";
216
+ const t = this._floating.panel;
217
+ t && this._renderPanelTo(t);
262
218
  }
263
- /** 某一端当前的时间:值里带的 → 暂存的 → 缺省。 */
264
- _timeOf(e, i, t) {
265
- return F(e) || i || t;
266
- }
267
- /**
268
- * 快捷区间那一排 chip(issue IKUE1G)。
269
- *
270
- * 三条规则写在这里,别处不要再算:
271
- * ① 只认 `presets=` 里写到的名字,拼错的不画按钮(不猜同义词);
272
- * ② 区间被 `min` / `max` 夹完为空 ⇒ 按钮置灰(点下去也不会有反应的东西不该可点);
273
- * ③ 只有**完全等于**某个预设时才高亮 —— 手选的自定义区间不许点亮预设,
274
- * 否则用户点它想复位时值没变化 ⇒ 组件不发事件 ⇒ 看着像按钮坏了。
275
- */
276
- _presetsHTML() {
277
- if (this.mode !== "range" || !this.presets.trim()) return "";
278
- const e = /* @__PURE__ */ new Date(), i = this.presets.split(/[,,]/).map((t) => t.trim()).filter(Boolean).map((t) => {
279
- const s = M(t, e);
280
- if (!s) return "";
281
- const n = C(s, this.min, this.max) !== null, r = H(t, o(this.start), o(this.end), e, this.min, this.max);
282
- return `<button type="button" class="z-datepicker__preset${r ? " is-active" : ""}" data-preset="${u(t)}" aria-pressed="${r ? "true" : "false"}"` + (n ? "" : ` disabled aria-disabled="true" title="${u(b("dateOutOfRange"))}"`) + `>${D(t)}</button>`;
283
- }).filter(Boolean).join("");
284
- return i ? `<div class="z-datepicker__presets" part="presets" role="group" aria-label="${u(b("quickRanges"))}">${i}</div>` : "";
285
- }
286
- /**
287
- * 点一个预设:写入两端、emit、关面板。
288
- *
289
- * [WHY 与手选走同一条出口] 值的分发只有 `z-change {start,end}` 这一条(PageView 的
290
- * `applyFilters` 也只认它)。预设另发一个事件名的话,宿主得接两套 —— 而漏接的那一套
291
- * 表现为「点了按钮日期变了、数据没变」。
292
- */
293
- _applyPreset(e) {
294
- const t = M(e, /* @__PURE__ */ new Date());
295
- if (!t) return;
296
- const s = C(t, this.min, this.max);
219
+ _applyPreset(t) {
220
+ const i = w(t, /* @__PURE__ */ new Date());
221
+ if (!i) return;
222
+ const s = M(i, this.min, this.max);
297
223
  if (!s) return;
298
- const n = this._timed ? _(s.start, "00:00") : s.start, r = this._timed ? _(s.end, "23:59") : s.end;
224
+ const n = this._timed ? c(s.start, "00:00") : s.start, r = this._timed ? c(s.end, "23:59") : s.end;
299
225
  this.start = n, this.end = r, this._pendingStart = null, this._focusISO = s.start, this._hoverISO = null, this.emit("z-change", { start: n, end: r }), this._closePanel();
300
226
  }
301
- /** 这台控件要不要时间(`precision="minute"`)。 */
302
- get _timed() {
303
- return this.precision === "minute";
304
- }
305
- _cellHTML(e, i) {
306
- const { iso: t, day: s, inMonth: n } = e, r = this.mode === "range", a = ["z-datepicker__cell"], d = !n || !g(t, this.min, this.max);
307
- n ? g(t, this.min, this.max) || a.push("z-datepicker__cell--disabled") : a.push("z-datepicker__cell--out"), t === i && a.push("z-datepicker__cell--today");
308
- let f = "false";
309
- if (r) {
310
- this.start && t === o(this.start) && (a.push("z-datepicker__cell--range-start"), f = "true"), this.end && t === o(this.end) && (a.push("z-datepicker__cell--range-end"), f = "true");
311
- const E = !!(this.start && this.end && m(t, o(this.start)) > 0 && m(t, o(this.end)) < 0), I = !!(this._pendingStart && this._hoverISO && m(t, this._pendingStart) >= 0 && m(t, this._hoverISO) <= 0);
312
- (E || I) && a.push("z-datepicker__cell--range-in");
313
- } else
314
- this.value && t === o(this.value) && (a.push("z-datepicker__cell--selected"), f = "true");
315
- const y = t === this._focusISO;
316
- return y && a.push("z-datepicker__cell--focus"), v`<td
317
- class="${a.join(" ")}"
318
- role="gridcell"
319
- data-iso="${t}"
320
- tabindex="${y ? 0 : -1}"
321
- aria-selected="${f}"
322
- aria-disabled="${K(d)}"
323
- ${t === i ? 'aria-current="date"' : ""}
324
- part="cell"
325
- >${s}</td>`;
326
- }
327
- _selectISO(e) {
328
- if (this._focusISO = e, this.mode === "single") {
329
- const i = this._timed ? _(e, this._timeOf(this.value, this._pendingTime, "00:00")) : e;
330
- if (this.value !== i && (this.value = i), this.emit("z-change", { value: i }), !this._timed) {
227
+ _selectISO(t) {
228
+ if (this._focusISO = t, this.mode === "single") {
229
+ const e = this._timed ? c(t, d(this.value, this._pendingTime, "00:00")) : t;
230
+ if (this.value !== e && (this.value = e), this.emit("z-change", { value: e }), !this._timed) {
331
231
  this._closePanel();
332
232
  return;
333
233
  }
334
234
  this._repaintPanel(), this._focusCell();
335
235
  return;
336
236
  }
337
- !this.start || this.end ? (this.start = this._timed ? _(e, this._timeOf("", this._pendingTime, "00:00")) : e, this.end = "", this._pendingStart = e, this._repaintPanel()) : m(e, o(this.start)) >= 0 ? (this.end = this._timed ? _(e, this._timeOf("", this._pendingTimeEnd, "23:59")) : e, this._pendingStart = null, this.emit("z-change", { start: this.start, end: this.end }), this._repaintPanel()) : (this.start = this._timed ? _(e, this._timeOf("", this._pendingTime, "00:00")) : e, this._pendingStart = e, this._repaintPanel()), this._focusCell();
237
+ !this.start || this.end ? (this.start = this._timed ? c(t, d("", this._pendingTime, "00:00")) : t, this.end = "", this._pendingStart = t, this._repaintPanel()) : T(t, l(this.start)) >= 0 ? (this.end = this._timed ? c(t, d("", this._pendingTimeEnd, "23:59")) : t, this._pendingStart = null, this.emit("z-change", { start: this.start, end: this.end }), this._repaintPanel()) : (this.start = this._timed ? c(t, d("", this._pendingTime, "00:00")) : t, this._pendingStart = t, this._repaintPanel()), this._focusCell();
338
238
  }
339
- /**
340
- * 读时间框、写回值、发事件。
341
- *
342
- * 三条口径:
343
- * ① **非法值不写入**(`25` / 空)—— 只标红。写一个非法值进去,它会被当成参数下推,
344
- * 后端把不认识的值当没写 ⇒ 查询静默退回全量;
345
- * ② **没有日期时只暂存**:时间单独存在没有意义,等选了日期才拼成一个值;
346
- * ③ **提交后不重画面板**:重画会重建输入框,用户正在里面打字,焦点与光标一起丢。
347
- * 快照同步一次即可(见 `_lastPanelProps` 那行的注释)。
348
- */
349
239
  _commitTime() {
350
- const e = this._floating.panel;
351
- if (!e) return;
352
- const i = (n) => W(e, n);
240
+ const t = this._floating.panel;
241
+ if (!t) return;
242
+ const e = (n) => Y(t, n);
353
243
  if (this.mode === "range") {
354
- const n = i("start"), r = i("end");
244
+ const n = e("start"), r = e("end");
355
245
  if (n === null || r === null || (this._pendingTime = n, this._pendingTimeEnd = r, !this.start || !this.end)) return;
356
- const a = _(o(this.start), n), d = _(o(this.end), r);
357
- if (a === this.start && d === this.end) return;
358
- this.start = a, this.end = d, this._lastPanelProps = this._panelPropsSnapshot(), this.emit("z-change", { start: a, end: d });
246
+ const p = c(l(this.start), n), u = c(l(this.end), r);
247
+ if (p === this.start && u === this.end) return;
248
+ this.start = p, this.end = u, this._lastPanelProps = this._panelPropsSnapshot(), this.emit("z-change", { start: p, end: u });
359
249
  return;
360
250
  }
361
- const t = i("value");
362
- if (t === null || (this._pendingTime = t, !o(this.value))) return;
363
- const s = _(o(this.value), t);
251
+ const i = e("value");
252
+ if (i === null || (this._pendingTime = i, !l(this.value))) return;
253
+ const s = c(l(this.value), i);
364
254
  s !== this.value && (this.value = s, this._lastPanelProps = this._panelPropsSnapshot(), this.emit("z-change", { value: s }));
365
255
  }
366
- _isSelectable(e) {
367
- return p(e) !== null && g(e, this.min, this.max);
368
- }
369
- _moveFocus(e, i) {
370
- if (!e) return;
371
- const t = p(e);
372
- if (!t) return;
373
- const s = new Date(t);
374
- s.setDate(s.getDate() + i);
375
- const n = w(s);
376
- p(n) !== null && ((s.getFullYear() !== this._viewYear || s.getMonth() !== this._viewMonth) && (this._viewYear = s.getFullYear(), this._viewMonth = s.getMonth()), this._focusISO = n, this._renderPanelTo(this._floating.panel), this._focusCell());
377
- }
378
- _moveFocusToWeekBoundary(e, i) {
379
- if (!e) return;
380
- const t = p(e);
381
- if (!t) return;
382
- const s = O(this._locale), n = (t.getDay() - s + 7) % 7;
383
- this._moveFocus(e, i ? 6 - n : -n);
256
+ _moveFocus(t, e) {
257
+ const i = F(t, e);
258
+ i && ((i.year !== this._viewYear || i.month !== this._viewMonth) && (this._viewYear = i.year, this._viewMonth = i.month), this._focusISO = i.iso, this._repaintPanel(), this._focusCell());
384
259
  }
385
- _navMonth(e, i) {
260
+ _navMonth(t, e) {
386
261
  var r;
387
- let t = this._viewMonth + e, s = this._viewYear;
388
- t < 0 && (t = 11, s -= 1), t > 11 && (t = 0, s += 1), this._viewMonth = t, this._viewYear = s, this._repaintPanel();
262
+ let i = this._viewMonth + t, s = this._viewYear;
263
+ i < 0 && (i = 11, s -= 1), i > 11 && (i = 0, s += 1), this._viewMonth = i, this._viewYear = s, this._repaintPanel();
389
264
  const n = this._floating.panel;
390
265
  if (n)
391
- if (i)
266
+ if (e)
392
267
  this._focusCell();
393
268
  else {
394
- const a = e === 1 ? '[data-nav="next"]' : '[data-nav="prev"]';
395
- (r = n.querySelector(a)) == null || r.focus();
269
+ const p = t === 1 ? '[data-nav="next"]' : '[data-nav="prev"]';
270
+ (r = n.querySelector(p)) == null || r.focus();
396
271
  }
397
272
  }
398
- _navYear(e) {
399
- this._viewYear += e, this._repaintPanel(), this._focusCell();
273
+ _navYear(t) {
274
+ this._viewYear += t, this._repaintPanel(), this._focusCell();
400
275
  }
401
276
  };
402
- k.styles = q;
403
- let l = k;
404
- c([
405
- h({ type: String })
406
- ], l.prototype, "mode");
407
- c([
408
- h({ type: String })
409
- ], l.prototype, "value");
410
- c([
411
- h({ type: String })
412
- ], l.prototype, "start");
413
- c([
414
- h({ type: String })
415
- ], l.prototype, "end");
416
- c([
417
- h({ type: String })
418
- ], l.prototype, "min");
419
- c([
420
- h({ type: String })
421
- ], l.prototype, "max");
422
- c([
423
- h({ type: String })
424
- ], l.prototype, "locale");
425
- c([
426
- h({ type: Boolean })
427
- ], l.prototype, "open");
428
- c([
429
- h({ type: String })
430
- ], l.prototype, "precision");
431
- c([
432
- h({ type: Boolean })
433
- ], l.prototype, "clearable");
434
- c([
435
- h({ type: String })
436
- ], l.prototype, "presets");
437
- c([
438
- h({ type: String })
439
- ], l.prototype, "prevMonthLabel");
440
- c([
441
- h({ type: String })
442
- ], l.prototype, "nextMonthLabel");
443
- R("z-datepicker", l);
277
+ g.styles = x;
278
+ let a = g;
279
+ h([
280
+ o({ type: String })
281
+ ], a.prototype, "mode");
282
+ h([
283
+ o({ type: String })
284
+ ], a.prototype, "value");
285
+ h([
286
+ o({ type: String })
287
+ ], a.prototype, "start");
288
+ h([
289
+ o({ type: String })
290
+ ], a.prototype, "end");
291
+ h([
292
+ o({ type: String })
293
+ ], a.prototype, "min");
294
+ h([
295
+ o({ type: String })
296
+ ], a.prototype, "max");
297
+ h([
298
+ o({ type: String })
299
+ ], a.prototype, "locale");
300
+ h([
301
+ o({ type: Boolean })
302
+ ], a.prototype, "open");
303
+ h([
304
+ o({ type: String })
305
+ ], a.prototype, "precision");
306
+ h([
307
+ o({ type: Boolean })
308
+ ], a.prototype, "clearable");
309
+ h([
310
+ o({ type: String })
311
+ ], a.prototype, "presets");
312
+ h([
313
+ o({ type: String })
314
+ ], a.prototype, "prevMonthLabel");
315
+ h([
316
+ o({ type: String })
317
+ ], a.prototype, "nextMonthLabel");
318
+ I("z-datepicker", a);
444
319
  export {
445
- l as ZDatepicker
320
+ a as ZDatepicker
446
321
  };
447
322
  //# sourceMappingURL=Datepicker.js.map