x-next 1.1.0 → 1.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 (206) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/_hooks/use-form-item.d.ts +5 -0
  3. package/dist/_hooks/use-picker-focus.d.ts +17 -0
  4. package/dist/components/_components/feedback-icon/index.vue.d.ts +4 -4
  5. package/dist/components/_components/picker/input-range.vue.d.ts +10 -6
  6. package/dist/components/_components/picker/input.vue.d.ts +9 -5
  7. package/dist/components/alert/Alert.vue.d.ts +5 -5
  8. package/dist/components/alert/index.d.ts +10 -10
  9. package/dist/components/date-picker/DatePanel.vue.d.ts +5 -0
  10. package/dist/components/date-picker/DatePicker.vue.d.ts +36 -16
  11. package/dist/components/date-picker/index.d.ts +77 -33
  12. package/dist/components/dialog/Dialog.d.ts +1 -1
  13. package/dist/components/dialog/index.d.ts +3 -3
  14. package/dist/components/drawer/index.d.ts +3 -3
  15. package/dist/components/drawer/src/Drawer.vue.d.ts +1 -1
  16. package/dist/components/dropdown/Dropdown.vue.d.ts +30 -4
  17. package/dist/components/dropdown/DropdownButton.vue.d.ts +31 -5
  18. package/dist/components/dropdown/DropdownOption.vue.d.ts +2 -0
  19. package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +162 -5
  20. package/dist/components/dropdown/context.d.ts +14 -1
  21. package/dist/components/dropdown/dropdown-panel.vue.d.ts +7 -1
  22. package/dist/components/dropdown/index.d.ts +610 -28
  23. package/dist/components/dropdown/use-keyboard.d.ts +10 -0
  24. package/dist/components/form/FormItem.vue.d.ts +12 -4
  25. package/dist/components/form/context.d.ts +6 -0
  26. package/dist/components/form/form-item-label.vue.d.ts +4 -4
  27. package/dist/components/form/form-item-message.vue.d.ts +2 -0
  28. package/dist/components/form/index.d.ts +30 -8
  29. package/dist/components/form/interface.d.ts +2 -2
  30. package/dist/components/form-input/InputPassword.vue.d.ts +20 -2
  31. package/dist/components/form-input/index.d.ts +22 -4
  32. package/dist/components/form-select/Select.d.ts +3 -3
  33. package/dist/components/form-select/hooks/use-select.d.ts +2 -1
  34. package/dist/components/form-select/index.d.ts +6 -6
  35. package/dist/components/form-slider/Slider.vue.d.ts +10 -3
  36. package/dist/components/form-slider/index.d.ts +26 -6
  37. package/dist/components/form-slider/slider-button.vue.d.ts +4 -3
  38. package/dist/components/form-switch/Switch.vue.d.ts +2 -1
  39. package/dist/components/form-switch/index.d.ts +5 -2
  40. package/dist/components/form-textarea/Textarea.vue.d.ts +2 -2
  41. package/dist/components/form-textarea/index.d.ts +5 -5
  42. package/dist/components/image/Image.vue.d.ts +10 -9
  43. package/dist/components/image/ImagePreview.vue.d.ts +8 -7
  44. package/dist/components/image/ImagePreviewAction.d.ts +3 -3
  45. package/dist/components/image/ImagePreviewGroup.vue.d.ts +8 -7
  46. package/dist/components/image/index.d.ts +59 -52
  47. package/dist/components/image/preview-arrow.vue.d.ts +2 -2
  48. package/dist/components/image/preview-toolbar.vue.d.ts +3 -3
  49. package/dist/components/layout/LayoutSidebar.vue.d.ts +2 -2
  50. package/dist/components/layout/index.d.ts +4 -4
  51. package/dist/components/link/Link.vue.d.ts +2 -2
  52. package/dist/components/link/index.d.ts +4 -4
  53. package/dist/components/menu/Menu.d.ts +2 -2
  54. package/dist/components/menu/base-menu.vue.d.ts +2 -2
  55. package/dist/components/menu/index.d.ts +4 -4
  56. package/dist/components/menu/sub-menu-pop.vue.d.ts +5 -5
  57. package/dist/components/message/index.d.ts +17 -17
  58. package/dist/components/message/message.vue.d.ts +8 -8
  59. package/dist/components/notification/Notification.d.ts +1 -1
  60. package/dist/components/notification/index.d.ts +3 -3
  61. package/dist/components/pagination/page-item-ellipsis.vue.d.ts +1 -1
  62. package/dist/components/pagination/page-item-step.vue.d.ts +2 -2
  63. package/dist/components/pagination/page-options.vue.d.ts +6 -6
  64. package/dist/components/popconfirm/src/popup.vue.d.ts +1 -1
  65. package/dist/components/popover/Popover.d.ts +1 -1
  66. package/dist/components/popover/index.d.ts +3 -3
  67. package/dist/components/popup/Popup.d.ts +1 -1
  68. package/dist/components/popup/index.d.ts +3 -3
  69. package/dist/components/progress/Progress.vue.d.ts +4 -4
  70. package/dist/components/progress/circle.vue.d.ts +2 -2
  71. package/dist/components/progress/index.d.ts +8 -8
  72. package/dist/components/progress/line.vue.d.ts +1 -1
  73. package/dist/components/progress/steps.vue.d.ts +1 -1
  74. package/dist/components/steps/Step.vue.d.ts +2 -2
  75. package/dist/components/steps/index.d.ts +4 -4
  76. package/dist/components/tabs/Tabs.d.ts +1 -1
  77. package/dist/components/tabs/index.d.ts +3 -3
  78. package/dist/components/tabs/tabs-tab.vue.d.ts +1 -1
  79. package/dist/components/tag/Tag.vue.d.ts +2 -2
  80. package/dist/components/tag/index.d.ts +4 -4
  81. package/dist/components/time-picker/TimeColumn.vue.d.ts +3 -0
  82. package/dist/components/time-picker/TimePanel.vue.d.ts +3 -0
  83. package/dist/components/time-picker/TimePicker.vue.d.ts +33 -17
  84. package/dist/components/time-picker/index.d.ts +73 -36
  85. package/dist/components/time-range-selector/TimeRangeSelector.vue.d.ts +8 -0
  86. package/dist/components/time-range-selector/index.d.ts +22 -0
  87. package/dist/components/tooltip/Tooltip.vue.d.ts +1 -1
  88. package/dist/components/tooltip/index.d.ts +3 -3
  89. package/dist/components/trigger/Trigger.d.ts +1 -1
  90. package/dist/components/trigger/index.d.ts +3 -3
  91. package/dist/es/_hooks/use-form-item.js +36 -10
  92. package/dist/es/_hooks/use-overflow.js +45 -40
  93. package/dist/es/_hooks/use-picker-focus.js +57 -0
  94. package/dist/es/_utils/constant.js +17 -5
  95. package/dist/es/components/_components/picker/input-range.vue.js +45 -55
  96. package/dist/es/components/_components/picker/input-range.vue2.js +105 -70
  97. package/dist/es/components/_components/picker/input.vue.js +22 -25
  98. package/dist/es/components/_components/picker/input.vue2.js +58 -43
  99. package/dist/es/components/_components/select-view/select-view.js +61 -66
  100. package/dist/es/components/date-picker/DatePanel.vue.js +102 -94
  101. package/dist/es/components/date-picker/DatePanel.vue2.js +97 -44
  102. package/dist/es/components/date-picker/DatePicker.vue.js +71 -58
  103. package/dist/es/components/date-picker/DatePicker.vue2.js +285 -231
  104. package/dist/es/components/dialog/Dialog.js +159 -128
  105. package/dist/es/components/dropdown/Dropdown.vue.js +18 -15
  106. package/dist/es/components/dropdown/Dropdown.vue2.js +52 -31
  107. package/dist/es/components/dropdown/DropdownOption.vue.js +22 -21
  108. package/dist/es/components/dropdown/DropdownOption.vue2.js +23 -19
  109. package/dist/es/components/dropdown/DropdownSubmenu.vue.js +49 -36
  110. package/dist/es/components/dropdown/DropdownSubmenu.vue2.js +45 -24
  111. package/dist/es/components/dropdown/context.js +3 -2
  112. package/dist/es/components/dropdown/dropdown-panel.vue.js +24 -21
  113. package/dist/es/components/dropdown/dropdown-panel.vue2.js +83 -31
  114. package/dist/es/components/dropdown/use-keyboard.js +45 -0
  115. package/dist/es/components/form/Form.vue2.js +113 -101
  116. package/dist/es/components/form/FormItem.vue.js +26 -22
  117. package/dist/es/components/form/FormItem.vue2.js +162 -125
  118. package/dist/es/components/form/form-item-message.vue.js +31 -24
  119. package/dist/es/components/form/form-item-message.vue2.js +4 -2
  120. package/dist/es/components/form-checkbox/Checkbox.js +80 -76
  121. package/dist/es/components/form-checkbox/CheckboxGroup.js +43 -38
  122. package/dist/es/components/form-input/Input.js +83 -79
  123. package/dist/es/components/form-input/InputPassword.vue.js +19 -16
  124. package/dist/es/components/form-input/InputPassword.vue2.js +39 -29
  125. package/dist/es/components/form-input/InputSearch.js +47 -37
  126. package/dist/es/components/form-input-number/InputNumber.js +134 -133
  127. package/dist/es/components/form-input-tag/InputTag.js +173 -162
  128. package/dist/es/components/form-radio/Radio.js +74 -71
  129. package/dist/es/components/form-radio/RadioGroup.js +55 -49
  130. package/dist/es/components/form-select/Select.js +116 -114
  131. package/dist/es/components/form-select/hooks/use-select.js +128 -128
  132. package/dist/es/components/form-slider/Slider.vue.js +28 -28
  133. package/dist/es/components/form-slider/Slider.vue2.js +139 -132
  134. package/dist/es/components/form-slider/slider-button.vue.js +6 -6
  135. package/dist/es/components/form-slider/slider-button.vue2.js +39 -34
  136. package/dist/es/components/form-switch/Switch.vue.js +9 -9
  137. package/dist/es/components/form-switch/Switch.vue2.js +81 -74
  138. package/dist/es/components/form-textarea/Textarea.vue2.js +123 -108
  139. package/dist/es/components/image/Image.vue2.js +77 -76
  140. package/dist/es/components/image/ImagePreview.vue.js +13 -12
  141. package/dist/es/components/image/ImagePreview.vue2.js +141 -136
  142. package/dist/es/components/image/ImagePreviewGroup.vue.js +1 -1
  143. package/dist/es/components/image/ImagePreviewGroup.vue2.js +82 -83
  144. package/dist/es/components/rate/Rate.js +106 -103
  145. package/dist/es/components/time-picker/TimeColumn.vue.js +34 -23
  146. package/dist/es/components/time-picker/TimeColumn.vue2.js +37 -28
  147. package/dist/es/components/time-picker/TimePicker.vue.js +83 -64
  148. package/dist/es/components/time-picker/TimePicker.vue2.js +192 -156
  149. package/dist/es/components/time-range-selector/TimeRangeSelector.vue.js +327 -193
  150. package/dist/es/locale/en-US.js +6 -0
  151. package/dist/es/locale/zh-CN.js +6 -0
  152. package/dist/es/style.css +1 -1
  153. package/dist/icons/_self/down.d.ts +1 -1
  154. package/dist/icons/_self/dropdown/more.d.ts +1 -1
  155. package/dist/icons/_self/empty-better.d.ts +1 -1
  156. package/dist/icons/_self/empty.d.ts +1 -1
  157. package/dist/icons/_self/eye-invisible.d.ts +1 -1
  158. package/dist/icons/_self/eye.d.ts +1 -1
  159. package/dist/icons/_self/full-screen.d.ts +1 -1
  160. package/dist/icons/_self/left.d.ts +1 -1
  161. package/dist/icons/_self/menu/down.d.ts +1 -1
  162. package/dist/icons/_self/minus.d.ts +1 -1
  163. package/dist/icons/_self/more-dot.d.ts +1 -1
  164. package/dist/icons/_self/next.d.ts +1 -1
  165. package/dist/icons/_self/original-size.d.ts +1 -1
  166. package/dist/icons/_self/plus.d.ts +1 -1
  167. package/dist/icons/_self/prev.d.ts +1 -1
  168. package/dist/icons/_self/question-message.d.ts +1 -1
  169. package/dist/icons/_self/right.d.ts +1 -1
  170. package/dist/icons/_self/rotate-left.d.ts +1 -1
  171. package/dist/icons/_self/rotate-right.d.ts +1 -1
  172. package/dist/icons/_self/search.d.ts +1 -1
  173. package/dist/icons/_self/up.d.ts +1 -1
  174. package/dist/icons/_self/zoom-in.d.ts +1 -1
  175. package/dist/icons/_self/zoom-out.d.ts +1 -1
  176. package/dist/icons/_ui/alone-left.d.ts +1 -1
  177. package/dist/icons/_ui/alone-margin-left.d.ts +1 -1
  178. package/dist/icons/_ui/alone-margin-right.d.ts +1 -1
  179. package/dist/icons/_ui/alone-right.d.ts +1 -1
  180. package/dist/icons/_ui/calendar.d.ts +1 -1
  181. package/dist/icons/_ui/time.d.ts +1 -1
  182. package/dist/icons/animation/animation-loading.d.ts +1 -1
  183. package/dist/icons/default/check-circle-fill.d.ts +1 -1
  184. package/dist/icons/default/check.d.ts +1 -1
  185. package/dist/icons/default/close-circle-fill.d.ts +1 -1
  186. package/dist/icons/default/close.d.ts +1 -1
  187. package/dist/icons/default/exclamation-circle-fill.d.ts +1 -1
  188. package/dist/icons/default/exclamation.d.ts +1 -1
  189. package/dist/icons/default/filter.d.ts +1 -1
  190. package/dist/icons/default/info-circle-fill.d.ts +1 -1
  191. package/dist/icons/default/link.d.ts +1 -1
  192. package/dist/icons/default/logo-simple.d.ts +1 -1
  193. package/dist/icons/default/minus-circle-fill.d.ts +1 -1
  194. package/dist/icons/icon.d.ts +2 -2
  195. package/dist/icons/index.d.ts +3 -3
  196. package/dist/index.cjs +4 -4
  197. package/dist/index.d.ts +1 -1
  198. package/dist/index.umd.js +4 -4
  199. package/dist/locale/interface.d.ts +6 -0
  200. package/dist/style/base.css +1 -1
  201. package/dist/style/date-picker.css +1 -1
  202. package/dist/style/form.css +1 -1
  203. package/dist/style/image.css +1 -1
  204. package/dist/style/time-range-selector.css +1 -1
  205. package/dist/style.css +1 -1
  206. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
- import { defineComponent as r, ref as u, computed as c, inject as f } from "vue";
2
- import { dropdownInjectionKey as b } from "./context.js";
3
- import { getClassNameMixin as p } from "../../_utils/config.js";
4
- const C = r({
1
+ import { defineComponent as y, ref as j, computed as a, inject as m, onBeforeUnmount as p } from "vue";
2
+ import { dropdownInjectionKey as I, dropdownMenuInjectionKey as g } from "./context.js";
3
+ import { getClassNameMixin as w } from "../../_utils/config.js";
4
+ const K = y({
5
5
  name: "DropdownOption",
6
6
  props: {
7
7
  /**
@@ -36,30 +36,34 @@ const C = r({
36
36
  * @en Icon
37
37
  * @slot icon
38
38
  */
39
- setup(t, { emit: l }) {
40
- const n = p("dropdown--option"), i = u(), d = c(() => {
39
+ setup(t, { emit: r }) {
40
+ const o = w("dropdown--option"), i = j(), u = a(() => {
41
41
  var e;
42
42
  return t.value ?? ((e = i.value) == null ? void 0 : e.textContent) ?? void 0;
43
- }), o = t.uninjectContext ? void 0 : f(b, void 0), a = (e) => {
44
- t.disabled || (l("click", e), o == null || o.onOptionClick(d.value, e));
45
- }, s = (e) => {
46
- t.disabled || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), a(e));
47
- }, m = c(() => [
48
- n.block,
43
+ }), d = t.uninjectContext ? void 0 : m(I, void 0), n = m(g, void 0), c = { element: i, disabled: a(() => t.disabled) }, l = n == null ? void 0 : n.registerItem(c);
44
+ p(() => l == null ? void 0 : l());
45
+ const f = a(() => t.disabled ? -1 : !n || n.activeItem.value === c ? 0 : -1), b = () => n == null ? void 0 : n.setActiveItem(c), s = (e) => {
46
+ t.disabled || (r("click", e), d == null || d.onOptionClick(u.value, e));
47
+ }, v = (e) => {
48
+ t.disabled || e.defaultPrevented || e.isComposing || e.target !== i.value || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), s(e));
49
+ }, k = a(() => [
50
+ o.block,
49
51
  {
50
- [n.modifier("disabled")]: t.disabled,
51
- [n.modifier("active")]: t.active
52
+ [o.modifier("disabled")]: t.disabled,
53
+ [o.modifier("active")]: t.active
52
54
  }
53
55
  ]);
54
56
  return {
55
- className: n,
56
- cls: m,
57
+ className: o,
58
+ cls: k,
57
59
  liRef: i,
58
- handleClick: a,
59
- handleKeydown: s
60
+ tabIndex: f,
61
+ handleFocus: b,
62
+ handleClick: s,
63
+ handleKeydown: v
60
64
  };
61
65
  }
62
66
  });
63
67
  export {
64
- C as default
68
+ K as default
65
69
  };
@@ -1,20 +1,24 @@
1
- import d from "./DropdownSubmenu.vue2.js";
2
- import { resolveComponent as s, openBlock as c, createBlock as f, withCtx as e, createVNode as i, mergeProps as u, createSlots as p, renderSlot as n, normalizeClass as m } from "vue";
3
- import g from "../../_virtual/_plugin-vue_export-helper.js";
4
- function b(o, $, h, v, P, _) {
5
- const t = s("IconRight"), r = s("dropdown-option"), l = s("dropdown-panel"), a = s("Trigger");
6
- return c(), f(a, {
1
+ import u from "./DropdownSubmenu.vue2.js";
2
+ import { resolveComponent as s, openBlock as f, createBlock as c, withCtx as e, createVNode as p, mergeProps as g, createSlots as r, renderSlot as n, normalizeClass as m } from "vue";
3
+ import b from "../../_virtual/_plugin-vue_export-helper.js";
4
+ function h(o, C, w, $, P, v) {
5
+ const a = s("IconRight"), t = s("dropdown-option"), l = s("dropdown-panel"), d = s("Trigger");
6
+ return f(), c(d, {
7
7
  "popup-visible": o.computedPopupVisible,
8
8
  trigger: o.trigger,
9
9
  position: o.position,
10
10
  disabled: o.disabled,
11
11
  "popup-offset": 4,
12
- onPopupVisibleChange: o.handlePopupVisibleChange
12
+ onPopupVisibleChange: o.handlePopupVisibleChange,
13
+ onShow: o.handleShow
13
14
  }, {
14
15
  content: e(() => [
15
- i(l, {
16
- class: m(o.className.block)
17
- }, p({
16
+ p(l, {
17
+ ref: "panelRef",
18
+ class: m(o.className.block),
19
+ "close-on-arrow-left": "",
20
+ onClose: o.handleClose
21
+ }, r({
18
22
  default: e(() => [
19
23
  n(o.$slots, "content")
20
24
  ]),
@@ -27,36 +31,45 @@ function b(o, $, h, v, P, _) {
27
31
  ]),
28
32
  key: "0"
29
33
  } : void 0
30
- ]), 1032, ["class"])
34
+ ]), 1032, ["class", "onClose"])
31
35
  ]),
32
- default: e(() => [
33
- i(r, u(o.optionProps, {
34
- active: o.computedPopupVisible,
35
- "uninject-context": ""
36
- }), p({
37
- suffix: e(() => [
38
- n(o.$slots, "suffix", {}, () => [
39
- i(t)
40
- ])
41
- ]),
42
- default: e(() => [
43
- n(o.$slots, "default")
44
- ]),
45
- _: 2
46
- }, [
47
- o.$slots.icon ? {
48
- name: "icon",
49
- fn: e(() => [
50
- n(o.$slots, "icon")
36
+ default: e(() => {
37
+ var i;
38
+ return [
39
+ p(t, g({ ref: "optionRef" }, o.optionProps, {
40
+ disabled: o.disabled || ((i = o.optionProps) == null ? void 0 : i.disabled),
41
+ active: o.computedPopupVisible,
42
+ "uninject-context": "",
43
+ "aria-haspopup": "menu",
44
+ "aria-expanded": o.computedPopupVisible,
45
+ onKeydownCapture: o.handleTriggerKeydown,
46
+ onFocusinCapture: o.handleTriggerFocus,
47
+ onFocusoutCapture: o.handleTriggerFocus
48
+ }), r({
49
+ suffix: e(() => [
50
+ n(o.$slots, "suffix", {}, () => [
51
+ p(a)
52
+ ])
51
53
  ]),
52
- key: "0"
53
- } : void 0
54
- ]), 1040, ["active"])
55
- ]),
54
+ default: e(() => [
55
+ n(o.$slots, "default")
56
+ ]),
57
+ _: 2
58
+ }, [
59
+ o.$slots.icon ? {
60
+ name: "icon",
61
+ fn: e(() => [
62
+ n(o.$slots, "icon")
63
+ ]),
64
+ key: "0"
65
+ } : void 0
66
+ ]), 1040, ["disabled", "active", "aria-expanded", "onKeydownCapture", "onFocusinCapture", "onFocusoutCapture"])
67
+ ];
68
+ }),
56
69
  _: 3
57
- }, 8, ["popup-visible", "trigger", "position", "disabled", "onPopupVisibleChange"]);
70
+ }, 8, ["popup-visible", "trigger", "position", "disabled", "onPopupVisibleChange", "onShow"]);
58
71
  }
59
- const k = /* @__PURE__ */ g(d, [["render", b]]);
72
+ const k = /* @__PURE__ */ b(u, [["render", h]]);
60
73
  export {
61
74
  k as default
62
75
  };
@@ -1,17 +1,18 @@
1
- import { defineComponent as s, toRefs as l } from "vue";
2
- import { Trigger as u } from "../trigger/index.js";
3
- import a from "./dropdown-panel.vue.js";
4
- import m from "./DropdownOption.vue.js";
5
- import d from "../../icons/_self/dropdown/more.js";
6
- import { useTrigger as f } from "../../_hooks/use-trigger.js";
7
- import { getClassNameMixin as b } from "../../_utils/config.js";
8
- const v = s({
1
+ import { defineComponent as u, toRefs as m, ref as f, computed as g } from "vue";
2
+ import { Trigger as b } from "../trigger/index.js";
3
+ import c from "./dropdown-panel.vue.js";
4
+ import y from "./DropdownOption.vue.js";
5
+ import w from "../../icons/_self/dropdown/more.js";
6
+ import { useTrigger as V } from "../../_hooks/use-trigger.js";
7
+ import { getClassNameMixin as P } from "../../_utils/config.js";
8
+ import { useDropdownKeyboard as h } from "./use-keyboard.js";
9
+ const K = u({
9
10
  name: "DropdownSubmenu",
10
11
  components: {
11
- Trigger: u,
12
- DropdownPanel: a,
13
- DropdownOption: m,
14
- IconRight: d
12
+ Trigger: b,
13
+ DropdownPanel: c,
14
+ DropdownOption: y,
15
+ IconRight: w
15
16
  },
16
17
  props: {
17
18
  /**
@@ -77,13 +78,13 @@ const v = s({
77
78
  }
78
79
  },
79
80
  emits: {
80
- "update:popupVisible": (e) => !0,
81
+ "update:popupVisible": (o) => !0,
81
82
  /**
82
83
  * @zh 下拉框显示状态发生改变时触发
83
84
  * @en Triggered when the display status of the drop-down box changes
84
85
  * @property {boolean} visible
85
86
  */
86
- popupVisibleChange: (e) => !0
87
+ popupVisibleChange: (o) => !0
87
88
  },
88
89
  /**
89
90
  * @zh 子菜单内容
@@ -102,19 +103,39 @@ const v = s({
102
103
  * @slot icon
103
104
  * @version 2.29.0
104
105
  */
105
- setup(e, { emit: o }) {
106
- const { defaultPopupVisible: p, popupVisible: t } = l(e), i = b("dropdown--submenu"), { computedPopupVisible: r, handlePopupVisibleChange: n } = f({
107
- defaultPopupVisible: p,
108
- popupVisible: t,
109
- emit: o
110
- });
106
+ setup(o, { emit: n }) {
107
+ const { defaultPopupVisible: l, popupVisible: s } = m(o), a = P("dropdown--submenu"), { computedPopupVisible: t, handlePopupVisibleChange: i } = V({
108
+ defaultPopupVisible: l,
109
+ popupVisible: s,
110
+ emit: n
111
+ }), p = f(), d = g({
112
+ get: () => {
113
+ var e;
114
+ return (e = p.value) == null ? void 0 : e.$el;
115
+ },
116
+ set: () => {
117
+ }
118
+ }), r = h(
119
+ t,
120
+ i,
121
+ d,
122
+ () => {
123
+ var e;
124
+ return o.disabled || !!((e = o.optionProps) != null && e.disabled);
125
+ }
126
+ );
111
127
  return {
112
- className: i,
113
- computedPopupVisible: r,
114
- handlePopupVisibleChange: n
128
+ ...r,
129
+ optionRef: p,
130
+ className: a,
131
+ computedPopupVisible: t,
132
+ handlePopupVisibleChange: i,
133
+ handleTriggerKeydown: (e) => {
134
+ e.key !== "ArrowDown" && e.key !== "ArrowUp" && r.handleTriggerKeydown(e);
135
+ }
115
136
  };
116
137
  }
117
138
  });
118
139
  export {
119
- v as default
140
+ K as default
120
141
  };
@@ -1,4 +1,5 @@
1
- const o = Symbol("ArcoDropdown");
1
+ const o = Symbol("ArcoDropdown"), n = Symbol("DropdownMenu");
2
2
  export {
3
- o as dropdownInjectionKey
3
+ o as dropdownInjectionKey,
4
+ n as dropdownMenuInjectionKey
4
5
  };
@@ -1,49 +1,52 @@
1
1
  import c from "./dropdown-panel.vue2.js";
2
- import { resolveComponent as s, openBlock as o, createElementBlock as a, normalizeClass as l, createBlock as t, renderSlot as n, createVNode as i, normalizeStyle as d, withCtx as f, createElementVNode as y, createCommentVNode as u } from "vue";
3
- import k from "../../_virtual/_plugin-vue_export-helper.js";
4
- function N(e, $, S, g, v, w) {
5
- const r = s("spin"), m = s("empty"), p = s("Scrollbar");
6
- return o(), a("div", {
7
- class: l(e.cls)
2
+ import { resolveComponent as s, openBlock as o, createElementBlock as n, normalizeClass as l, createBlock as t, renderSlot as a, createVNode as y, normalizeStyle as f, withCtx as u, createElementVNode as k, createCommentVNode as N } from "vue";
3
+ import $ from "../../_virtual/_plugin-vue_export-helper.js";
4
+ function w(e, r, S, E, b, g) {
5
+ const m = s("spin"), p = s("empty"), d = s("Scrollbar");
6
+ return o(), n("div", {
7
+ ref: "panelElement",
8
+ class: l(e.cls),
9
+ tabindex: "-1",
10
+ onKeydown: r[0] || (r[0] = (...i) => e.handleKeydown && e.handleKeydown(...i))
8
11
  }, [
9
- e.loading ? (o(), t(r, {
12
+ e.loading ? (o(), t(m, {
10
13
  key: 0,
11
14
  class: l(e.className.element("loading")),
12
15
  display: "block",
13
16
  tip: e.t("common.loading")
14
- }, null, 8, ["class", "tip"])) : e.isEmpty ? (o(), a("div", {
17
+ }, null, 8, ["class", "tip"])) : e.isEmpty ? (o(), n("div", {
15
18
  key: 1,
16
19
  class: l(e.className.element("empty"))
17
20
  }, [
18
- n(e.$slots, "empty", {}, () => [
19
- i(m)
21
+ a(e.$slots, "empty", {}, () => [
22
+ y(p)
20
23
  ])
21
- ], 2)) : (o(), t(p, {
24
+ ], 2)) : (o(), t(d, {
22
25
  key: 2,
23
26
  ref: "wrapperRef",
24
27
  class: l(e.className.element("list--wrapper")),
25
- style: d(e.style),
28
+ style: f(e.style),
26
29
  onScroll: e.handleScroll
27
30
  }, {
28
- default: f(() => [
29
- y("ul", {
31
+ default: u(() => [
32
+ k("ul", {
30
33
  class: l(e.className.element("list")),
31
34
  role: "menu"
32
35
  }, [
33
- n(e.$slots, "default")
36
+ a(e.$slots, "default")
34
37
  ], 2)
35
38
  ]),
36
39
  _: 3
37
40
  }, 8, ["class", "style", "onScroll"])),
38
- e.$slots.footer && !e.loading && !e.isEmpty ? (o(), a("div", {
41
+ e.$slots.footer && !e.loading && !e.isEmpty ? (o(), n("div", {
39
42
  key: 3,
40
43
  class: l(e.className.element("footer"))
41
44
  }, [
42
- n(e.$slots, "footer")
43
- ], 2)) : u("", !0)
44
- ], 2);
45
+ a(e.$slots, "footer")
46
+ ], 2)) : N("", !0)
47
+ ], 34);
45
48
  }
46
- const h = /* @__PURE__ */ k(c, [["render", N]]);
49
+ const B = /* @__PURE__ */ $(c, [["render", w]]);
47
50
  export {
48
- h as default
51
+ B as default
49
52
  };
@@ -1,19 +1,21 @@
1
- import { defineComponent as h, inject as y, ref as g, computed as n } from "vue";
2
- import { Empty as x } from "../empty/index.js";
3
- import { dropdownInjectionKey as b } from "./context.js";
4
- import { isNumber as H } from "../../_utils/is.js";
5
- import { Scrollbar as w } from "../scrollbar-v2/index.js";
6
- import { Spin as B } from "../spin/index.js";
7
- import { getClassNameMixin as M } from "../../_utils/config.js";
8
- import { useLocale as N } from "../../locale/index.js";
9
- const _ = h({
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";
5
+ import { Scrollbar as L } from "../scrollbar-v2/index.js";
6
+ import { Spin as S } from "../spin/index.js";
7
+ import { getClassNameMixin as _ } from "../../_utils/config.js";
8
+ import { useLocale as T } from "../../locale/index.js";
9
+ const q = A({
10
10
  name: "DropdownPanel",
11
11
  components: {
12
- Scrollbar: w,
13
- Empty: x,
14
- Spin: B
12
+ Scrollbar: L,
13
+ Empty: k,
14
+ Spin: S
15
15
  },
16
16
  props: {
17
+ // private: only submenu panels return to their parent on ArrowLeft.
18
+ closeOnArrowLeft: Boolean,
17
19
  loading: {
18
20
  type: Boolean,
19
21
  default: !1
@@ -33,37 +35,87 @@ const _ = h({
33
35
  type: [Function, Array]
34
36
  }
35
37
  },
36
- emits: ["scroll", "reachBottom"],
37
- setup(p, { emit: r, slots: m }) {
38
- const o = M("dropdown"), { t: s } = N(), t = y(b, {}), a = g(), i = (e) => {
39
- const { scrollTop: f, scrollHeight: d, offsetHeight: u } = e.target;
40
- d - (f + u) <= p.bottomOffset && r("reachBottom", e), r("scroll", e);
41
- }, l = n(() => {
42
- if (H(t.popupMaxHeight))
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) => {
41
+ var o;
42
+ return !e.disabled.value && ((o = e.element.value) == null ? void 0 : o.isConnected);
43
+ }).sort((e, o) => {
44
+ const t = e.element.value.compareDocumentPosition(o.element.value);
45
+ return t & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : t & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
46
+ }), I = (e) => {
47
+ e.disabled.value || (n.value = e);
48
+ }, a = (e) => {
49
+ n.value = e;
50
+ const o = (e == null ? void 0 : e.element.value) ?? f.value;
51
+ return o == null || o.focus(), !!(o && document.activeElement === o);
52
+ };
53
+ y({ focus: (e = "first") => {
54
+ const o = p();
55
+ return a(e === "last" ? o.at(-1) : o[0]);
56
+ } }), H(C, {
57
+ activeItem: n,
58
+ setActiveItem: I,
59
+ registerItem: (e) => (r.value = [...r.value, e], () => {
60
+ r.value = r.value.filter((o) => o !== e);
61
+ })
62
+ }), P(() => {
63
+ var o;
64
+ const e = p();
65
+ if (!n.value || !e.includes(n.value)) {
66
+ const t = ((o = n.value) == null ? void 0 : o.element.value) === document.activeElement;
67
+ n.value = e[0], t && a(n.value);
68
+ }
69
+ });
70
+ const E = (e) => {
71
+ if (e.defaultPrevented || e.isComposing) return;
72
+ if (e.key === "Escape" || m.closeOnArrowLeft && e.key === "ArrowLeft") {
73
+ e.preventDefault(), e.stopPropagation(), c("close");
74
+ return;
75
+ }
76
+ 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))
79
+ return;
80
+ e.preventDefault(), e.stopPropagation();
81
+ const s = o.findIndex((l) => l.element.value === t);
82
+ if (e.key === "Home") a(o[0]);
83
+ else if (e.key === "End") a(o.at(-1));
84
+ 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]);
87
+ }
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))
43
93
  return {
44
- maxHeight: `${t.popupMaxHeight}px`
94
+ maxHeight: `${i.popupMaxHeight}px`
45
95
  };
46
- if (!t.popupMaxHeight)
96
+ if (!i.popupMaxHeight)
47
97
  return {
48
98
  maxHeight: "none",
49
99
  overflowY: "hidden"
50
100
  };
51
- }), c = n(() => [
52
- o.block,
101
+ }), O = v(() => [
102
+ u.block,
53
103
  {
54
- [o.modifier("has-footer")]: !!m.footer
104
+ [u.modifier("has-footer")]: !!g.footer
55
105
  }
56
106
  ]);
57
107
  return {
58
- className: o,
59
- cls: c,
60
- style: l,
61
- wrapperRef: a,
62
- handleScroll: i,
63
- t: s
108
+ className: u,
109
+ cls: O,
110
+ style: N,
111
+ wrapperRef: b,
112
+ panelElement: f,
113
+ handleKeydown: E,
114
+ handleScroll: x,
115
+ t: w
64
116
  };
65
117
  }
66
118
  });
67
119
  export {
68
- _ as default
120
+ q as default
69
121
  };
@@ -0,0 +1,45 @@
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;
11
+ const a = e.currentTarget;
12
+ if (!a.matches(':disabled, [aria-disabled="true"]')) {
13
+ if (e.key === "Escape" && n.value)
14
+ d();
15
+ else if (["Enter", " ", "ArrowDown", "ArrowUp", "ArrowRight"].includes(e.key)) {
16
+ if (e.preventDefault(), e.repeat) return;
17
+ i.value = a, r = !1, t = e.key === "ArrowUp" ? "last" : "first", f(!0), u(l);
18
+ } else
19
+ return;
20
+ e.preventDefault(), e.stopImmediatePropagation();
21
+ }
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();
28
+ };
29
+ return y(n, (e) => {
30
+ e ? u(l) : (t = void 0, r && (r = !1, u(() => {
31
+ var a;
32
+ o = !0, (a = i.value) == null || a.focus(), o = !1;
33
+ })));
34
+ }), {
35
+ panelRef: s,
36
+ handleShow: p,
37
+ handleTriggerKeydown: m,
38
+ handleTriggerFocus: w,
39
+ handleClose: d,
40
+ handleKeyboardSelect: g
41
+ };
42
+ };
43
+ export {
44
+ v as useDropdownKeyboard
45
+ };