x-next 1.18.0 → 1.18.2

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 (170) hide show
  1. package/AI_USAGE/catalog.md +1 -1
  2. package/AI_USAGE/components/alert-api.md +1 -1
  3. package/AI_USAGE/components/alert.md +1 -1
  4. package/AI_USAGE/components/bar-chart-api.md +1 -1
  5. package/AI_USAGE/components/bar-chart.md +1 -1
  6. package/AI_USAGE/components/boxicons.md +1 -1
  7. package/AI_USAGE/components/button-api.md +1 -1
  8. package/AI_USAGE/components/button.md +4 -4
  9. package/AI_USAGE/components/charts.md +1 -1
  10. package/AI_USAGE/components/checkbox-api.md +1 -1
  11. package/AI_USAGE/components/checkbox.md +1 -1
  12. package/AI_USAGE/components/color-picker-api.md +1 -1
  13. package/AI_USAGE/components/color-picker.md +1 -1
  14. package/AI_USAGE/components/config-provider-api.md +1 -1
  15. package/AI_USAGE/components/config-provider.md +1 -1
  16. package/AI_USAGE/components/date-picker-api.md +44 -26
  17. package/AI_USAGE/components/date-picker.md +78 -3
  18. package/AI_USAGE/components/dialog-api.md +2 -2
  19. package/AI_USAGE/components/dialog.md +5 -1
  20. package/AI_USAGE/components/draggable-api.md +1 -1
  21. package/AI_USAGE/components/draggable.md +1 -1
  22. package/AI_USAGE/components/drawer-api.md +1 -1
  23. package/AI_USAGE/components/drawer.md +1 -1
  24. package/AI_USAGE/components/dropdown-api.md +6 -1
  25. package/AI_USAGE/components/dropdown.md +2 -2
  26. package/AI_USAGE/components/empty-api.md +1 -1
  27. package/AI_USAGE/components/empty.md +1 -1
  28. package/AI_USAGE/components/finicon.md +1 -1
  29. package/AI_USAGE/components/form-api.md +1 -1
  30. package/AI_USAGE/components/form.md +1 -1
  31. package/AI_USAGE/components/grid-api.md +1 -1
  32. package/AI_USAGE/components/grid.md +1 -1
  33. package/AI_USAGE/components/heatmap-api.md +1 -1
  34. package/AI_USAGE/components/heatmap.md +1 -1
  35. package/AI_USAGE/components/icon-api.md +1 -1
  36. package/AI_USAGE/components/icon.md +1 -1
  37. package/AI_USAGE/components/image-api.md +1 -1
  38. package/AI_USAGE/components/image.md +1 -1
  39. package/AI_USAGE/components/input-api.md +1 -1
  40. package/AI_USAGE/components/input-number-api.md +1 -1
  41. package/AI_USAGE/components/input-number.md +1 -1
  42. package/AI_USAGE/components/input-tag-api.md +1 -1
  43. package/AI_USAGE/components/input-tag.md +1 -1
  44. package/AI_USAGE/components/input.md +1 -1
  45. package/AI_USAGE/components/layout-api.md +1 -1
  46. package/AI_USAGE/components/layout.md +1 -1
  47. package/AI_USAGE/components/line-chart-api.md +1 -1
  48. package/AI_USAGE/components/line-chart.md +1 -1
  49. package/AI_USAGE/components/link-api.md +1 -1
  50. package/AI_USAGE/components/link.md +1 -1
  51. package/AI_USAGE/components/menu-api.md +1 -1
  52. package/AI_USAGE/components/menu.md +1 -1
  53. package/AI_USAGE/components/message-api.md +1 -1
  54. package/AI_USAGE/components/message-box-api.md +1 -1
  55. package/AI_USAGE/components/message-box.md +1 -1
  56. package/AI_USAGE/components/message.md +1 -1
  57. package/AI_USAGE/components/network-api.md +1 -1
  58. package/AI_USAGE/components/network.md +1 -1
  59. package/AI_USAGE/components/notification-api.md +1 -1
  60. package/AI_USAGE/components/notification.md +1 -1
  61. package/AI_USAGE/components/pagination-api.md +1 -1
  62. package/AI_USAGE/components/pagination.md +1 -1
  63. package/AI_USAGE/components/pie-chart-api.md +1 -1
  64. package/AI_USAGE/components/pie-chart.md +1 -1
  65. package/AI_USAGE/components/popconfirm-api.md +1 -1
  66. package/AI_USAGE/components/popconfirm.md +1 -1
  67. package/AI_USAGE/components/popover-api.md +1 -1
  68. package/AI_USAGE/components/popover.md +3 -1
  69. package/AI_USAGE/components/popup-api.md +1 -1
  70. package/AI_USAGE/components/popup.md +1 -1
  71. package/AI_USAGE/components/progress-api.md +1 -1
  72. package/AI_USAGE/components/progress.md +1 -1
  73. package/AI_USAGE/components/radio-api.md +1 -1
  74. package/AI_USAGE/components/radio.md +1 -1
  75. package/AI_USAGE/components/rate-api.md +1 -1
  76. package/AI_USAGE/components/rate.md +1 -1
  77. package/AI_USAGE/components/resize-box-api.md +1 -1
  78. package/AI_USAGE/components/resize-box.md +1 -1
  79. package/AI_USAGE/components/scrollbar-api.md +1 -1
  80. package/AI_USAGE/components/scrollbar.md +1 -1
  81. package/AI_USAGE/components/select-api.md +1 -1
  82. package/AI_USAGE/components/select.md +1 -1
  83. package/AI_USAGE/components/skeleton-api.md +1 -1
  84. package/AI_USAGE/components/skeleton.md +1 -1
  85. package/AI_USAGE/components/slider-api.md +1 -1
  86. package/AI_USAGE/components/slider.md +1 -1
  87. package/AI_USAGE/components/space-api.md +1 -1
  88. package/AI_USAGE/components/space.md +1 -1
  89. package/AI_USAGE/components/spin-api.md +1 -1
  90. package/AI_USAGE/components/spin.md +1 -1
  91. package/AI_USAGE/components/steps-api.md +1 -1
  92. package/AI_USAGE/components/steps.md +1 -1
  93. package/AI_USAGE/components/switch-api.md +1 -1
  94. package/AI_USAGE/components/switch.md +1 -1
  95. package/AI_USAGE/components/table-api.md +1 -1
  96. package/AI_USAGE/components/table.md +1 -1
  97. package/AI_USAGE/components/tabs-api.md +1 -1
  98. package/AI_USAGE/components/tabs.md +1 -1
  99. package/AI_USAGE/components/tag-api.md +1 -1
  100. package/AI_USAGE/components/tag.md +1 -1
  101. package/AI_USAGE/components/textarea-api.md +1 -1
  102. package/AI_USAGE/components/textarea.md +1 -1
  103. package/AI_USAGE/components/time-picker-api.md +1 -1
  104. package/AI_USAGE/components/time-picker.md +1 -1
  105. package/AI_USAGE/components/time-range-selector-api.md +1 -1
  106. package/AI_USAGE/components/time-range-selector.md +1 -1
  107. package/AI_USAGE/components/timeline-api.md +1 -1
  108. package/AI_USAGE/components/timeline.md +1 -1
  109. package/AI_USAGE/components/tooltip-api.md +1 -1
  110. package/AI_USAGE/components/tooltip.md +1 -1
  111. package/AI_USAGE/components/transfer-api.md +1 -1
  112. package/AI_USAGE/components/transfer.md +1 -1
  113. package/AI_USAGE/components/tree-select-api.md +1 -1
  114. package/AI_USAGE/components/tree-select.md +1 -1
  115. package/AI_USAGE/components/trend-chart-api.md +1 -1
  116. package/AI_USAGE/components/trend-chart.md +1 -1
  117. package/AI_USAGE/components/trigger-api.md +1 -1
  118. package/AI_USAGE/components/trigger.md +1 -1
  119. package/AI_USAGE/components/upload-api.md +1 -1
  120. package/AI_USAGE/components/upload.md +1 -1
  121. package/AI_USAGE/components/watermark-api.md +1 -1
  122. package/AI_USAGE/components/watermark.md +1 -1
  123. package/AI_USAGE/core.md +1 -1
  124. package/AI_USAGE/index.md +1 -1
  125. package/AI_USAGE/recipes/form-on-demand.md +1 -1
  126. package/AI_USAGE.md +138 -34
  127. package/CHANGELOG.md +28 -0
  128. package/README.md +108 -212
  129. package/dist/_container/render-function.d.ts +2 -2
  130. package/dist/components/_components/picker/input-range.vue.d.ts +1 -1
  131. package/dist/components/date-picker/DatePanel.vue.d.ts +10 -1
  132. package/dist/components/date-picker/DatePicker.vue.d.ts +22 -10
  133. package/dist/components/date-picker/index.d.ts +156 -54
  134. package/dist/components/date-picker/utils.d.ts +4 -4
  135. package/dist/components/dropdown/Dropdown.vue.d.ts +1 -0
  136. package/dist/components/dropdown/DropdownButton.vue.d.ts +1 -0
  137. package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +1 -0
  138. package/dist/components/dropdown/context.d.ts +1 -0
  139. package/dist/components/dropdown/index.d.ts +8 -0
  140. package/dist/components/dropdown/use-keyboard.d.ts +1 -0
  141. package/dist/components/menu/MenuItem.d.ts +2 -2
  142. package/dist/components/menu/context.d.ts +3 -3
  143. package/dist/components/menu/index.d.ts +6 -6
  144. package/dist/components/menu/sub-menu-pop.vue.d.ts +2 -2
  145. package/dist/components/time-picker/TimePicker.vue.d.ts +1 -1
  146. package/dist/components/time-picker/index.d.ts +2 -2
  147. package/dist/es/components/_components/picker/input-range.vue.js +12 -12
  148. package/dist/es/components/_components/picker/input-range.vue2.js +45 -45
  149. package/dist/es/components/_components/picker/input.vue2.js +24 -24
  150. package/dist/es/components/date-picker/DatePanel.vue.js +47 -47
  151. package/dist/es/components/date-picker/DatePanel.vue2.js +68 -59
  152. package/dist/es/components/date-picker/DatePicker.vue.js +65 -59
  153. package/dist/es/components/date-picker/DatePicker.vue2.js +387 -284
  154. package/dist/es/components/date-picker/index.js +57 -36
  155. package/dist/es/components/date-picker/utils.js +132 -122
  156. package/dist/es/components/dialog/Dialog.js +43 -40
  157. package/dist/es/components/dialog/props.js +1 -1
  158. package/dist/es/components/dropdown/Dropdown.vue2.js +66 -50
  159. package/dist/es/components/dropdown/dropdown-panel.vue2.js +48 -43
  160. package/dist/es/components/dropdown/use-keyboard.js +36 -28
  161. package/dist/es/components/popover/Popover.js +72 -32
  162. package/dist/es/style.css +1 -1
  163. package/dist/index.cjs +3 -3
  164. package/dist/index.umd.js +3 -3
  165. package/dist/style/button.css +1 -1
  166. package/dist/style/date-picker.css +1 -1
  167. package/dist/style/dialog.css +1 -1
  168. package/dist/style/message-box.css +1 -1
  169. package/dist/style.css +1 -1
  170. package/package.json +2 -1
@@ -1,19 +1,19 @@
1
- import { defineComponent as v, toRefs as B, provide as C, reactive as w } from "vue";
2
- import { Trigger as V } from "../trigger/index.js";
1
+ import { defineComponent as O, toRefs as T, watch as P, onBeforeUnmount as S, provide as v, reactive as V } from "vue";
2
+ import { Trigger as E } from "../trigger/index.js";
3
3
  import F from "./dropdown-panel.vue.js";
4
- import { useTrigger as S } from "../../_hooks/use-trigger.js";
5
- import { dropdownInjectionKey as O } from "./context.js";
6
- import { getClassNameMixin as P } from "../../_utils/config.js";
7
- import T from "../../_container/render-function.js";
8
- import { useFirstElement as k } from "../../_hooks/use-first-element.js";
9
- import { mergeFirstChild as x } from "../../_utils/vue-eco.js";
10
- import { useDropdownKeyboard as K } from "./use-keyboard.js";
11
- const q = v({
4
+ import { useTrigger as K } from "../../_hooks/use-trigger.js";
5
+ import { dropdownInjectionKey as D } from "./context.js";
6
+ import { getClassNameMixin as x } from "../../_utils/config.js";
7
+ import N from "../../_container/render-function.js";
8
+ import { useFirstElement as R } from "../../_hooks/use-first-element.js";
9
+ import { mergeFirstChild as A } from "../../_utils/vue-eco.js";
10
+ import { useDropdownKeyboard as M } from "./use-keyboard.js";
11
+ const l = /* @__PURE__ */ new Set(), Q = O({
12
12
  name: "Dropdown",
13
13
  components: {
14
- Trigger: V,
14
+ Trigger: E,
15
15
  DropdownPanel: F,
16
- RenderFunction: T
16
+ RenderFunction: N
17
17
  },
18
18
  props: {
19
19
  /**
@@ -105,32 +105,32 @@ const q = v({
105
105
  }
106
106
  },
107
107
  emits: {
108
- "update:popupVisible": (e) => !0,
108
+ "update:popupVisible": (r) => !0,
109
109
  /**
110
110
  * @zh 下拉框显示状态发生改变时触发
111
111
  * @en Triggered when the display status of the drop-down box changes
112
112
  * @param {boolean} visible
113
113
  */
114
- popupVisibleChange: (e) => !0,
114
+ popupVisibleChange: (r) => !0,
115
115
  /**
116
116
  * @zh 用户选择时触发
117
117
  * @en Triggered when the user selects
118
118
  * @param {string | number | Record<string, any> | undefined } value
119
119
  * @param {Event} ev
120
120
  */
121
- select: (e, t) => !0,
121
+ select: (r, n) => !0,
122
122
  /**
123
123
  * @zh 下拉菜单滚动时触发
124
124
  * @en Triggered when the dropdown scrolls
125
125
  * @param {Event} ev
126
126
  */
127
- scroll: (e) => !0,
127
+ scroll: (r) => !0,
128
128
  /**
129
129
  * @zh 下拉菜单滚动到底部时触发
130
130
  * @en Triggered when the dropdown reaches bottom
131
131
  * @param {Event} ev
132
132
  */
133
- reachBottom: (e) => !0
133
+ reachBottom: (r) => !0
134
134
  },
135
135
  /**
136
136
  * @zh 内容
@@ -148,19 +148,34 @@ const q = v({
148
148
  * @en Empty content
149
149
  * @slot empty
150
150
  */
151
- setup(e, { emit: t, slots: n }) {
152
- const { defaultPopupVisible: d, popupVisible: s, popupMaxHeight: c } = B(e), f = P("dropdown"), { computedPopupVisible: a, handlePopupVisibleChange: p } = S({
153
- defaultPopupVisible: d,
154
- popupVisible: s,
155
- emit: t
156
- }), { children: l, firstElement: m } = k(), r = K(
151
+ setup(r, { emit: n, slots: i }) {
152
+ const { defaultPopupVisible: y, popupVisible: g, popupMaxHeight: b } = T(r), h = x("dropdown"), { computedPopupVisible: a, handlePopupVisibleChange: p } = K({
153
+ defaultPopupVisible: y,
154
+ popupVisible: g,
155
+ emit: n
156
+ }), { children: u, firstElement: s } = R(), o = M(
157
157
  a,
158
158
  p,
159
- m
160
- ), g = (o) => {
161
- var i;
162
- return l.value = ((i = n.default) == null ? void 0 : i.call(n)) ?? [], x(l.value, {
163
- ...o,
159
+ s
160
+ ), d = Symbol("dropdown"), m = (e) => {
161
+ var t;
162
+ if (!(e.isComposing || e.keyCode === 229 || e.defaultPrevented || Array.from(l).at(-1) !== d)) {
163
+ if (e.key === "Escape" && (e.target === document.body || e.target === document.documentElement || (t = s.value) != null && t.contains(e.target))) {
164
+ o.handleClose(), e.preventDefault(), e.stopPropagation();
165
+ return;
166
+ }
167
+ e.key === "Tab" && (o.handleTabOut(), e.stopPropagation());
168
+ }
169
+ }, c = () => {
170
+ l.delete(d), typeof document < "u" && document.removeEventListener("keydown", m, !0);
171
+ };
172
+ P(a, (e) => {
173
+ c(), e && typeof document < "u" && (l.add(d), document.addEventListener("keydown", m, !0));
174
+ }, { immediate: !0 }), S(c);
175
+ const w = (e) => {
176
+ var t;
177
+ return u.value = ((t = i.default) == null ? void 0 : t.call(i)) ?? [], A(u.value, {
178
+ ...e,
164
179
  /*
165
180
  * 根触发器补菜单语义。子菜单的触发器已在 DropdownSubmenu 上声明
166
181
  * aria-haspopup/aria-expanded,根触发器此前没有,读屏无法得知
@@ -168,36 +183,37 @@ const q = v({
168
183
  */
169
184
  "aria-haspopup": "menu",
170
185
  "aria-expanded": a.value ? "true" : "false",
171
- onKeydown: (u) => {
172
- u.key !== "ArrowRight" && r.handleTriggerKeydown(u);
186
+ onKeydown: (f) => {
187
+ f.key !== "ArrowRight" && o.handleTriggerKeydown(f);
173
188
  },
174
- onFocusinCapture: r.handleTriggerFocus,
175
- onFocusoutCapture: r.handleTriggerFocus
176
- }), l.value;
177
- }, h = (o, i) => {
178
- t("select", o, i), e.hideOnSelect && (r.handleKeyboardSelect(i), p(!1));
179
- }, y = (o) => {
180
- t("scroll", o);
181
- }, b = (o) => {
182
- t("reachBottom", o);
189
+ onFocusinCapture: o.handleTriggerFocus,
190
+ onFocusoutCapture: o.handleTriggerFocus
191
+ }), u.value;
192
+ }, C = (e, t) => {
193
+ n("select", e, t), r.hideOnSelect && (o.handleKeyboardSelect(t), p(!1));
194
+ }, k = (e) => {
195
+ n("scroll", e);
196
+ }, B = (e) => {
197
+ n("reachBottom", e);
183
198
  };
184
- return C(
185
- O,
186
- w({
187
- popupMaxHeight: c,
188
- onOptionClick: h
199
+ return v(
200
+ D,
201
+ V({
202
+ popupMaxHeight: b,
203
+ onTabOut: o.handleTabOut,
204
+ onOptionClick: C
189
205
  })
190
206
  ), {
191
- ...r,
192
- renderTrigger: g,
193
- className: f,
207
+ ...o,
208
+ renderTrigger: w,
209
+ className: h,
194
210
  computedPopupVisible: a,
195
211
  handlePopupVisibleChange: p,
196
- handleScroll: y,
197
- handleReachBottom: b
212
+ handleScroll: k,
213
+ handleReachBottom: B
198
214
  };
199
215
  }
200
216
  });
201
217
  export {
202
- q as default
218
+ Q as default
203
219
  };
@@ -1,16 +1,16 @@
1
- import { defineComponent as A, inject as D, ref as d, shallowRef as h, provide as H, watchPostEffect as P, computed as v } from "vue";
2
- import { Empty as k } from "../empty/index.js";
3
- import { dropdownInjectionKey as B, dropdownMenuInjectionKey as C } from "./context.js";
4
- import { isNumber as M } from "../../_utils/is.js";
1
+ import { defineComponent as k, inject as D, ref as h, shallowRef as y, provide as H, watchPostEffect as P, computed as g } from "vue";
2
+ import { Empty as B } from "../empty/index.js";
3
+ import { dropdownInjectionKey as M, dropdownMenuInjectionKey as T } from "./context.js";
4
+ import { isNumber as C } from "../../_utils/is.js";
5
5
  import { Scrollbar as L } from "../scrollbar-v2/index.js";
6
6
  import { Spin as S } from "../spin/index.js";
7
7
  import { getClassNameMixin as _ } from "../../_utils/config.js";
8
- import { useLocale as T } from "../../locale/index.js";
9
- const q = A({
8
+ import { useLocale as F } from "../../locale/index.js";
9
+ const z = k({
10
10
  name: "DropdownPanel",
11
11
  components: {
12
12
  Scrollbar: L,
13
- Empty: k,
13
+ Empty: B,
14
14
  Spin: S
15
15
  },
16
16
  props: {
@@ -36,86 +36,91 @@ const q = A({
36
36
  }
37
37
  },
38
38
  emits: ["scroll", "reachBottom", "close"],
39
- setup(m, { emit: c, slots: g, expose: y }) {
40
- const u = _("dropdown"), { t: w } = T(), i = D(B, {}), b = d(), f = d(), r = h([]), n = h(), p = () => r.value.filter((e) => {
39
+ setup(d, { emit: u, slots: v, expose: w }) {
40
+ const i = _("dropdown"), { t: b } = F(), r = D(M, {}), I = h(), f = h(), l = y([]), n = y(), m = () => l.value.filter((e) => {
41
41
  var o;
42
42
  return !e.disabled.value && ((o = e.element.value) == null ? void 0 : o.isConnected);
43
43
  }).sort((e, o) => {
44
44
  const t = e.element.value.compareDocumentPosition(o.element.value);
45
45
  return t & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : t & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
46
- }), I = (e) => {
46
+ }), E = (e) => {
47
47
  e.disabled.value || (n.value = e);
48
48
  }, a = (e) => {
49
49
  n.value = e;
50
50
  const o = (e == null ? void 0 : e.element.value) ?? f.value;
51
51
  return o == null || o.focus(), !!(o && document.activeElement === o);
52
52
  };
53
- y({ focus: (e = "first") => {
54
- const o = p();
53
+ w({ focus: (e = "first") => {
54
+ const o = m();
55
55
  return a(e === "last" ? o.at(-1) : o[0]);
56
- } }), H(C, {
56
+ } }), H(T, {
57
57
  activeItem: n,
58
- setActiveItem: I,
59
- registerItem: (e) => (r.value = [...r.value, e], () => {
60
- r.value = r.value.filter((o) => o !== e);
58
+ setActiveItem: E,
59
+ registerItem: (e) => (l.value = [...l.value, e], () => {
60
+ l.value = l.value.filter((o) => o !== e);
61
61
  })
62
62
  }), P(() => {
63
63
  var o;
64
- const e = p();
64
+ const e = m();
65
65
  if (!n.value || !e.includes(n.value)) {
66
66
  const t = ((o = n.value) == null ? void 0 : o.element.value) === document.activeElement;
67
67
  n.value = e[0], t && a(n.value);
68
68
  }
69
69
  });
70
- const E = (e) => {
70
+ const O = (e) => {
71
+ var p;
71
72
  if (e.defaultPrevented || e.isComposing) return;
72
- if (e.key === "Escape" || m.closeOnArrowLeft && e.key === "ArrowLeft") {
73
- e.preventDefault(), e.stopPropagation(), c("close");
73
+ if (e.key === "Tab") {
74
+ (p = r.onTabOut) == null || p.call(r);
75
+ return;
76
+ }
77
+ if (e.key === "Escape" || d.closeOnArrowLeft && e.key === "ArrowLeft") {
78
+ e.preventDefault(), e.stopPropagation(), u("close");
74
79
  return;
75
80
  }
76
81
  if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) return;
77
- const o = p(), t = e.target;
78
- if (t !== f.value && !r.value.some((l) => l.element.value === t))
82
+ const o = m(), t = e.target;
83
+ if (t !== f.value && !l.value.some((s) => s.element.value === t))
79
84
  return;
80
85
  e.preventDefault(), e.stopPropagation();
81
- const s = o.findIndex((l) => l.element.value === t);
86
+ const c = o.findIndex((s) => s.element.value === t);
82
87
  if (e.key === "Home") a(o[0]);
83
88
  else if (e.key === "End") a(o.at(-1));
84
89
  else if (o.length) {
85
- const l = s < 0 ? e.key === "ArrowUp" ? o.length - 1 : 0 : (s + (e.key === "ArrowDown" ? 1 : -1) + o.length) % o.length;
86
- a(o[l]);
90
+ const s = c < 0 ? e.key === "ArrowUp" ? o.length - 1 : 0 : (c + (e.key === "ArrowDown" ? 1 : -1) + o.length) % o.length;
91
+ a(o[s]);
87
92
  }
88
- }, x = (e) => {
89
- const { scrollTop: o, scrollHeight: t, offsetHeight: s } = e.target;
90
- t - (o + s) <= m.bottomOffset && c("reachBottom", e), c("scroll", e);
91
- }, N = v(() => {
92
- if (M(i.popupMaxHeight))
93
+ }, N = (e) => {
94
+ const { scrollTop: o, scrollHeight: t, offsetHeight: c } = e.target;
95
+ t - (o + c) <= d.bottomOffset && u("reachBottom", e), u("scroll", e);
96
+ }, x = g(() => {
97
+ if (C(r.popupMaxHeight))
93
98
  return {
94
- maxHeight: `${i.popupMaxHeight}px`
99
+ maxHeight: `${r.popupMaxHeight}px`
95
100
  };
96
- if (!i.popupMaxHeight)
101
+ if (!r.popupMaxHeight)
97
102
  return {
98
103
  maxHeight: "none",
99
104
  overflowY: "hidden"
100
105
  };
101
- }), O = v(() => [
102
- u.block,
106
+ }), A = g(() => [
107
+ i.block,
103
108
  {
104
- [u.modifier("has-footer")]: !!g.footer
109
+ [i.modifier("has-footer")]: !!v.footer
105
110
  }
106
111
  ]);
107
112
  return {
108
- className: u,
109
- cls: O,
110
- style: N,
111
- wrapperRef: b,
113
+ className: i,
114
+ cls: A,
115
+ style: x,
116
+ wrapperRef: I,
112
117
  panelElement: f,
113
- handleKeydown: E,
114
- handleScroll: x,
115
- t: w
118
+ handleKeydown: O,
119
+ handleScroll: N,
120
+ t: b
116
121
  };
117
122
  }
118
123
  });
119
124
  export {
120
- q as default
125
+ z as default
121
126
  };
@@ -1,45 +1,53 @@
1
- import { ref as h, watch as y, nextTick as u } from "vue";
2
- const v = (n, f, i, c = () => !1) => {
3
- const s = h();
4
- let t, r = !1, o = !1;
5
- const l = () => {
6
- !n.value || !t || !s.value || (o = !0, s.value.focus(t) && (t = void 0), o = !1);
7
- }, p = () => {
8
- l(), t = void 0;
9
- }, m = (e) => {
10
- if (c() || e.defaultPrevented || e.isComposing) return;
1
+ import { ref as g, watch as v, nextTick as d } from "vue";
2
+ const k = (n, s, u, p = () => !1) => {
3
+ const l = g();
4
+ let t, o = !1, r = !1;
5
+ const f = () => {
6
+ !n.value || !t || !l.value || (r = !0, l.value.focus(t) && (t = void 0), r = !1);
7
+ }, m = () => {
8
+ f(), t = void 0;
9
+ }, w = (e) => {
10
+ if (p() || e.defaultPrevented || e.isComposing) return;
11
11
  const a = e.currentTarget;
12
12
  if (!a.matches(':disabled, [aria-disabled="true"]')) {
13
+ if (e.key === "Tab" && n.value) {
14
+ i();
15
+ return;
16
+ }
13
17
  if (e.key === "Escape" && n.value)
14
- d();
18
+ c();
15
19
  else if (["Enter", " ", "ArrowDown", "ArrowUp", "ArrowRight"].includes(e.key)) {
16
20
  if (e.preventDefault(), e.repeat) return;
17
- i.value = a, r = !1, t = e.key === "ArrowUp" ? "last" : "first", f(!0), u(l);
21
+ u.value = a, o = !1, t = e.key === "ArrowUp" ? "last" : "first", s(!0), d(f);
18
22
  } else
19
23
  return;
20
24
  e.preventDefault(), e.stopImmediatePropagation();
21
25
  }
22
- }, d = () => {
23
- t = void 0, r = !0, f(!1);
24
- }, g = (e) => {
25
- e instanceof KeyboardEvent && (r = !0);
26
- }, w = (e) => {
27
- o && e.stopImmediatePropagation();
26
+ }, c = () => {
27
+ t = void 0, o = !0, s(!1);
28
+ }, i = () => {
29
+ var e;
30
+ t = void 0, o = !1, s(!1), r = !0, (e = u.value) == null || e.focus({ preventScroll: !0 }), r = !1;
31
+ }, h = (e) => {
32
+ e instanceof KeyboardEvent && (o = !0);
33
+ }, y = (e) => {
34
+ r && e.stopImmediatePropagation();
28
35
  };
29
- return y(n, (e) => {
30
- e ? u(l) : (t = void 0, r && (r = !1, u(() => {
36
+ return v(n, (e) => {
37
+ e ? d(f) : (t = void 0, o && (o = !1, d(() => {
31
38
  var a;
32
- o = !0, (a = i.value) == null || a.focus(), o = !1;
39
+ r = !0, (a = u.value) == null || a.focus(), r = !1;
33
40
  })));
34
41
  }), {
35
- panelRef: s,
36
- handleShow: p,
37
- handleTriggerKeydown: m,
38
- handleTriggerFocus: w,
39
- handleClose: d,
40
- handleKeyboardSelect: g
42
+ panelRef: l,
43
+ handleShow: m,
44
+ handleTriggerKeydown: w,
45
+ handleTriggerFocus: y,
46
+ handleClose: c,
47
+ handleTabOut: i,
48
+ handleKeyboardSelect: h
41
49
  };
42
50
  };
43
51
  export {
44
- v as useDropdownKeyboard
52
+ k as useDropdownKeyboard
45
53
  };
@@ -1,11 +1,14 @@
1
- import { defineComponent as P, ref as b, computed as i, createVNode as l, mergeProps as p, Fragment as y } from "vue";
2
- import { Trigger as T } from "../trigger/index.js";
3
- import { getComponentPrefix as g, getClassNameMixin as w } from "../../_utils/config.js";
4
- import { popoverProps as F } from "./props.js";
5
- const k = /* @__PURE__ */ P({
6
- name: g("Popover"),
1
+ import { defineComponent as x, ref as F, computed as u, watch as A, onBeforeUnmount as B, createVNode as l, mergeProps as K, nextTick as N } from "vue";
2
+ import { Trigger as L } from "../trigger/index.js";
3
+ import { getComponentPrefix as W, getClassNameMixin as H } from "../../_utils/config.js";
4
+ import { popoverProps as M } from "./props.js";
5
+ import { useFirstElement as I } from "../../_hooks/use-first-element.js";
6
+ import { mergeFirstChild as j } from "../../_utils/vue-eco.js";
7
+ import R from "../../_container/render-function.js";
8
+ const p = /* @__PURE__ */ new Set(), Y = /* @__PURE__ */ x({
9
+ name: W("Popover"),
7
10
  inheritAttrs: !1,
8
- props: F,
11
+ props: M,
9
12
  slots: Object,
10
13
  emits: {
11
14
  "update:popupVisible": (e) => !0,
@@ -14,23 +17,58 @@ const k = /* @__PURE__ */ P({
14
17
  hide: () => !0
15
18
  },
16
19
  setup(e, {
17
- emit: a,
20
+ emit: r,
18
21
  slots: o,
19
- attrs: u
22
+ attrs: y
20
23
  }) {
21
- const n = w("popover"), c = b(e.defaultPopupVisible), d = i(() => e.popupVisible ?? c.value), r = i(() => !!(o.title || e.title !== void 0)), s = i(() => !!(o.content || e.content !== void 0)), m = i(() => [n.element("content"), {
22
- [n.element("content-has-title")]: r.value
23
- }, e.contentClass]), C = i(() => [n.element("arrow"), e.arrowClass]), f = (t) => {
24
- c.value = t, a("update:popupVisible", t), a("popupVisibleChange", t);
25
- }, h = () => {
24
+ const i = H("popover"), C = F(e.defaultPopupVisible), d = u(() => e.popupVisible ?? C.value), {
25
+ children: s,
26
+ firstElement: v
27
+ } = I(), g = F(), m = Symbol("popover");
28
+ let c = !1;
29
+ const h = u(() => !!(o.title || e.title !== void 0)), S = u(() => !!(o.content || e.content !== void 0)), V = u(() => [i.element("content"), {
30
+ [i.element("content-has-title")]: h.value
31
+ }, e.contentClass]), k = u(() => [i.element("arrow"), e.arrowClass]), P = (t) => {
32
+ C.value = t, r("update:popupVisible", t), r("popupVisibleChange", t);
33
+ }, D = () => {
26
34
  var t;
27
35
  return ((t = o.title) == null ? void 0 : t.call(o)) ?? e.title;
28
- }, v = () => {
36
+ }, E = () => {
29
37
  var t;
30
38
  return ((t = o.content) == null ? void 0 : t.call(o)) ?? e.content;
39
+ }, f = (t) => {
40
+ !d.value || t.defaultPrevented || t.isComposing || t.keyCode === 229 || t.key !== "Escape" || (t.preventDefault(), t.stopPropagation(), P(!1), N(() => {
41
+ var n;
42
+ c = !0, (n = v.value) == null || n.focus({
43
+ preventScroll: !0
44
+ }), c = !1;
45
+ }));
46
+ }, O = (t) => {
47
+ var n;
48
+ return s.value = ((n = o.default) == null ? void 0 : n.call(o)) ?? [], j(s.value, {
49
+ ...t,
50
+ onKeydown: f,
51
+ onFocusinCapture: (a) => {
52
+ c && a.stopImmediatePropagation();
53
+ },
54
+ onFocusoutCapture: (a) => {
55
+ c && a.stopImmediatePropagation();
56
+ }
57
+ }), s.value;
58
+ }, b = (t) => {
59
+ var a, T;
60
+ if (Array.from(p).at(-1) !== m) return;
61
+ const n = t.target;
62
+ n !== document.body && n !== document.documentElement && !((a = v.value) != null && a.contains(n)) && !((T = g.value) != null && T.contains(n)) || f(t);
63
+ }, w = () => {
64
+ p.delete(m), typeof document < "u" && document.removeEventListener("keydown", b, !0);
31
65
  };
32
- return () => l(T, p(u, {
33
- class: [n.block, u.class],
66
+ return A(d, (t) => {
67
+ w(), t && typeof document < "u" && (p.add(m), document.addEventListener("keydown", b, !0));
68
+ }, {
69
+ immediate: !0
70
+ }), B(w), () => l(L, K(y, {
71
+ class: [i.block, y.class],
34
72
  popupVisible: d.value,
35
73
  trigger: e.trigger,
36
74
  position: e.position,
@@ -44,9 +82,9 @@ const k = /* @__PURE__ */ P({
44
82
  clickToClose: e.clickToClose,
45
83
  clickOutsideToClose: e.clickOutsideToClose,
46
84
  unmountOnClose: e.unmountOnClose,
47
- contentClass: m.value,
85
+ contentClass: V.value,
48
86
  contentStyle: e.contentStyle,
49
- arrowClass: C.value,
87
+ arrowClass: k.value,
50
88
  arrowStyle: e.arrowStyle,
51
89
  popupStyle: e.popupStyle,
52
90
  animationName: e.animationName,
@@ -65,22 +103,24 @@ const k = /* @__PURE__ */ P({
65
103
  scrollToClose: e.scrollToClose,
66
104
  scrollToCloseDistance: e.scrollToCloseDistance,
67
105
  autoFitTransformOrigin: !0,
68
- onPopupVisibleChange: f,
69
- onShow: () => a("show"),
70
- onHide: () => a("hide")
106
+ onPopupVisibleChange: P,
107
+ onShow: () => r("show"),
108
+ onHide: () => r("hide")
71
109
  }), {
72
- default: () => {
73
- var t;
74
- return (t = o.default) == null ? void 0 : t.call(o);
75
- },
76
- content: () => l(y, null, [r.value && l("div", {
77
- class: n.element("title")
78
- }, [h()]), s.value && l("div", {
79
- class: n.element("body")
80
- }, [v()])])
110
+ default: () => l(R, {
111
+ renderFunc: O
112
+ }, null),
113
+ content: () => l("div", {
114
+ ref: g,
115
+ onKeydown: f
116
+ }, [h.value && l("div", {
117
+ class: i.element("title")
118
+ }, [D()]), S.value && l("div", {
119
+ class: i.element("body")
120
+ }, [E()])])
81
121
  });
82
122
  }
83
123
  });
84
124
  export {
85
- k as default
125
+ Y as default
86
126
  };