@element-plus/nightly 0.0.20241113 → 0.0.20241114

Sign up to get free protection for your applications and to get access to all the features.
Files changed (408) hide show
  1. package/dist/index.full.js +129 -111
  2. package/dist/index.full.min.js +11 -11
  3. package/dist/index.full.min.js.map +1 -1
  4. package/dist/index.full.min.mjs +11 -11
  5. package/dist/index.full.min.mjs.map +1 -1
  6. package/dist/index.full.mjs +129 -111
  7. package/dist/locale/af.js +1 -1
  8. package/dist/locale/af.min.js +1 -1
  9. package/dist/locale/af.min.mjs +1 -1
  10. package/dist/locale/af.mjs +1 -1
  11. package/dist/locale/ar-eg.js +1 -1
  12. package/dist/locale/ar-eg.min.js +1 -1
  13. package/dist/locale/ar-eg.min.mjs +1 -1
  14. package/dist/locale/ar-eg.mjs +1 -1
  15. package/dist/locale/ar.js +1 -1
  16. package/dist/locale/ar.min.js +1 -1
  17. package/dist/locale/ar.min.mjs +1 -1
  18. package/dist/locale/ar.mjs +1 -1
  19. package/dist/locale/az.js +1 -1
  20. package/dist/locale/az.min.js +1 -1
  21. package/dist/locale/az.min.mjs +1 -1
  22. package/dist/locale/az.mjs +1 -1
  23. package/dist/locale/bg.js +1 -1
  24. package/dist/locale/bg.min.js +1 -1
  25. package/dist/locale/bg.min.mjs +1 -1
  26. package/dist/locale/bg.mjs +1 -1
  27. package/dist/locale/bn.js +1 -1
  28. package/dist/locale/bn.min.js +1 -1
  29. package/dist/locale/bn.min.mjs +1 -1
  30. package/dist/locale/bn.mjs +1 -1
  31. package/dist/locale/ca.js +1 -1
  32. package/dist/locale/ca.min.js +1 -1
  33. package/dist/locale/ca.min.mjs +1 -1
  34. package/dist/locale/ca.mjs +1 -1
  35. package/dist/locale/ckb.js +1 -1
  36. package/dist/locale/ckb.min.js +1 -1
  37. package/dist/locale/ckb.min.mjs +1 -1
  38. package/dist/locale/ckb.mjs +1 -1
  39. package/dist/locale/cs.js +1 -1
  40. package/dist/locale/cs.min.js +1 -1
  41. package/dist/locale/cs.min.mjs +1 -1
  42. package/dist/locale/cs.mjs +1 -1
  43. package/dist/locale/da.js +1 -1
  44. package/dist/locale/da.min.js +1 -1
  45. package/dist/locale/da.min.mjs +1 -1
  46. package/dist/locale/da.mjs +1 -1
  47. package/dist/locale/de.js +1 -1
  48. package/dist/locale/de.min.js +1 -1
  49. package/dist/locale/de.min.mjs +1 -1
  50. package/dist/locale/de.mjs +1 -1
  51. package/dist/locale/el.js +1 -1
  52. package/dist/locale/el.min.js +1 -1
  53. package/dist/locale/el.min.mjs +1 -1
  54. package/dist/locale/el.mjs +1 -1
  55. package/dist/locale/en.js +1 -1
  56. package/dist/locale/en.min.js +1 -1
  57. package/dist/locale/en.min.mjs +1 -1
  58. package/dist/locale/en.mjs +1 -1
  59. package/dist/locale/eo.js +1 -1
  60. package/dist/locale/eo.min.js +1 -1
  61. package/dist/locale/eo.min.mjs +1 -1
  62. package/dist/locale/eo.mjs +1 -1
  63. package/dist/locale/es.js +1 -1
  64. package/dist/locale/es.min.js +1 -1
  65. package/dist/locale/es.min.mjs +1 -1
  66. package/dist/locale/es.mjs +1 -1
  67. package/dist/locale/et.js +1 -1
  68. package/dist/locale/et.min.js +1 -1
  69. package/dist/locale/et.min.mjs +1 -1
  70. package/dist/locale/et.mjs +1 -1
  71. package/dist/locale/eu.js +1 -1
  72. package/dist/locale/eu.min.js +1 -1
  73. package/dist/locale/eu.min.mjs +1 -1
  74. package/dist/locale/eu.mjs +1 -1
  75. package/dist/locale/fa.js +1 -1
  76. package/dist/locale/fa.min.js +1 -1
  77. package/dist/locale/fa.min.mjs +1 -1
  78. package/dist/locale/fa.mjs +1 -1
  79. package/dist/locale/fi.js +1 -1
  80. package/dist/locale/fi.min.js +1 -1
  81. package/dist/locale/fi.min.mjs +1 -1
  82. package/dist/locale/fi.mjs +1 -1
  83. package/dist/locale/fr.js +1 -1
  84. package/dist/locale/fr.min.js +1 -1
  85. package/dist/locale/fr.min.mjs +1 -1
  86. package/dist/locale/fr.mjs +1 -1
  87. package/dist/locale/he.js +1 -1
  88. package/dist/locale/he.min.js +1 -1
  89. package/dist/locale/he.min.mjs +1 -1
  90. package/dist/locale/he.mjs +1 -1
  91. package/dist/locale/hr.js +1 -1
  92. package/dist/locale/hr.min.js +1 -1
  93. package/dist/locale/hr.min.mjs +1 -1
  94. package/dist/locale/hr.mjs +1 -1
  95. package/dist/locale/hu.js +1 -1
  96. package/dist/locale/hu.min.js +1 -1
  97. package/dist/locale/hu.min.mjs +1 -1
  98. package/dist/locale/hu.mjs +1 -1
  99. package/dist/locale/hy-am.js +1 -1
  100. package/dist/locale/hy-am.min.js +1 -1
  101. package/dist/locale/hy-am.min.mjs +1 -1
  102. package/dist/locale/hy-am.mjs +1 -1
  103. package/dist/locale/id.js +1 -1
  104. package/dist/locale/id.min.js +1 -1
  105. package/dist/locale/id.min.mjs +1 -1
  106. package/dist/locale/id.mjs +1 -1
  107. package/dist/locale/it.js +1 -1
  108. package/dist/locale/it.min.js +1 -1
  109. package/dist/locale/it.min.mjs +1 -1
  110. package/dist/locale/it.mjs +1 -1
  111. package/dist/locale/ja.js +1 -1
  112. package/dist/locale/ja.min.js +1 -1
  113. package/dist/locale/ja.min.mjs +1 -1
  114. package/dist/locale/ja.mjs +1 -1
  115. package/dist/locale/kk.js +1 -1
  116. package/dist/locale/kk.min.js +1 -1
  117. package/dist/locale/kk.min.mjs +1 -1
  118. package/dist/locale/kk.mjs +1 -1
  119. package/dist/locale/km.js +1 -1
  120. package/dist/locale/km.min.js +1 -1
  121. package/dist/locale/km.min.mjs +1 -1
  122. package/dist/locale/km.mjs +1 -1
  123. package/dist/locale/ko.js +1 -1
  124. package/dist/locale/ko.min.js +1 -1
  125. package/dist/locale/ko.min.mjs +1 -1
  126. package/dist/locale/ko.mjs +1 -1
  127. package/dist/locale/ku.js +1 -1
  128. package/dist/locale/ku.min.js +1 -1
  129. package/dist/locale/ku.min.mjs +1 -1
  130. package/dist/locale/ku.mjs +1 -1
  131. package/dist/locale/ky.js +1 -1
  132. package/dist/locale/ky.min.js +1 -1
  133. package/dist/locale/ky.min.mjs +1 -1
  134. package/dist/locale/ky.mjs +1 -1
  135. package/dist/locale/lt.js +1 -1
  136. package/dist/locale/lt.min.js +1 -1
  137. package/dist/locale/lt.min.mjs +1 -1
  138. package/dist/locale/lt.mjs +1 -1
  139. package/dist/locale/lv.js +1 -1
  140. package/dist/locale/lv.min.js +1 -1
  141. package/dist/locale/lv.min.mjs +1 -1
  142. package/dist/locale/lv.mjs +1 -1
  143. package/dist/locale/mg.js +1 -1
  144. package/dist/locale/mg.min.js +1 -1
  145. package/dist/locale/mg.min.mjs +1 -1
  146. package/dist/locale/mg.mjs +1 -1
  147. package/dist/locale/mn.js +1 -1
  148. package/dist/locale/mn.min.js +1 -1
  149. package/dist/locale/mn.min.mjs +1 -1
  150. package/dist/locale/mn.mjs +1 -1
  151. package/dist/locale/my.js +1 -1
  152. package/dist/locale/my.min.js +1 -1
  153. package/dist/locale/my.min.mjs +1 -1
  154. package/dist/locale/my.mjs +1 -1
  155. package/dist/locale/nb-no.js +1 -1
  156. package/dist/locale/nb-no.min.js +1 -1
  157. package/dist/locale/nb-no.min.mjs +1 -1
  158. package/dist/locale/nb-no.mjs +1 -1
  159. package/dist/locale/nl.js +1 -1
  160. package/dist/locale/nl.min.js +1 -1
  161. package/dist/locale/nl.min.mjs +1 -1
  162. package/dist/locale/nl.mjs +1 -1
  163. package/dist/locale/pa.js +1 -1
  164. package/dist/locale/pa.min.js +1 -1
  165. package/dist/locale/pa.min.mjs +1 -1
  166. package/dist/locale/pa.mjs +1 -1
  167. package/dist/locale/pl.js +1 -1
  168. package/dist/locale/pl.min.js +1 -1
  169. package/dist/locale/pl.min.mjs +1 -1
  170. package/dist/locale/pl.mjs +1 -1
  171. package/dist/locale/pt-br.js +1 -1
  172. package/dist/locale/pt-br.min.js +1 -1
  173. package/dist/locale/pt-br.min.mjs +1 -1
  174. package/dist/locale/pt-br.mjs +1 -1
  175. package/dist/locale/pt.js +1 -1
  176. package/dist/locale/pt.min.js +1 -1
  177. package/dist/locale/pt.min.mjs +1 -1
  178. package/dist/locale/pt.mjs +1 -1
  179. package/dist/locale/ro.js +1 -1
  180. package/dist/locale/ro.min.js +1 -1
  181. package/dist/locale/ro.min.mjs +1 -1
  182. package/dist/locale/ro.mjs +1 -1
  183. package/dist/locale/ru.js +1 -1
  184. package/dist/locale/ru.min.js +1 -1
  185. package/dist/locale/ru.min.mjs +1 -1
  186. package/dist/locale/ru.mjs +1 -1
  187. package/dist/locale/sk.js +1 -1
  188. package/dist/locale/sk.min.js +1 -1
  189. package/dist/locale/sk.min.mjs +1 -1
  190. package/dist/locale/sk.mjs +1 -1
  191. package/dist/locale/sl.js +1 -1
  192. package/dist/locale/sl.min.js +1 -1
  193. package/dist/locale/sl.min.mjs +1 -1
  194. package/dist/locale/sl.mjs +1 -1
  195. package/dist/locale/sr.js +1 -1
  196. package/dist/locale/sr.min.js +1 -1
  197. package/dist/locale/sr.min.mjs +1 -1
  198. package/dist/locale/sr.mjs +1 -1
  199. package/dist/locale/sv.js +1 -1
  200. package/dist/locale/sv.min.js +1 -1
  201. package/dist/locale/sv.min.mjs +1 -1
  202. package/dist/locale/sv.mjs +1 -1
  203. package/dist/locale/sw.js +1 -1
  204. package/dist/locale/sw.min.js +1 -1
  205. package/dist/locale/sw.min.mjs +1 -1
  206. package/dist/locale/sw.mjs +1 -1
  207. package/dist/locale/ta.js +1 -1
  208. package/dist/locale/ta.min.js +1 -1
  209. package/dist/locale/ta.min.mjs +1 -1
  210. package/dist/locale/ta.mjs +1 -1
  211. package/dist/locale/th.js +1 -1
  212. package/dist/locale/th.min.js +1 -1
  213. package/dist/locale/th.min.mjs +1 -1
  214. package/dist/locale/th.mjs +1 -1
  215. package/dist/locale/tk.js +1 -1
  216. package/dist/locale/tk.min.js +1 -1
  217. package/dist/locale/tk.min.mjs +1 -1
  218. package/dist/locale/tk.mjs +1 -1
  219. package/dist/locale/tr.js +1 -1
  220. package/dist/locale/tr.min.js +1 -1
  221. package/dist/locale/tr.min.mjs +1 -1
  222. package/dist/locale/tr.mjs +1 -1
  223. package/dist/locale/ug-cn.js +1 -1
  224. package/dist/locale/ug-cn.min.js +1 -1
  225. package/dist/locale/ug-cn.min.mjs +1 -1
  226. package/dist/locale/ug-cn.mjs +1 -1
  227. package/dist/locale/uk.js +1 -1
  228. package/dist/locale/uk.min.js +1 -1
  229. package/dist/locale/uk.min.mjs +1 -1
  230. package/dist/locale/uk.mjs +1 -1
  231. package/dist/locale/uz-uz.js +1 -1
  232. package/dist/locale/uz-uz.min.js +1 -1
  233. package/dist/locale/uz-uz.min.mjs +1 -1
  234. package/dist/locale/uz-uz.mjs +1 -1
  235. package/dist/locale/vi.js +1 -1
  236. package/dist/locale/vi.min.js +1 -1
  237. package/dist/locale/vi.min.mjs +1 -1
  238. package/dist/locale/vi.mjs +1 -1
  239. package/dist/locale/zh-cn.js +1 -1
  240. package/dist/locale/zh-cn.min.js +1 -1
  241. package/dist/locale/zh-cn.min.mjs +1 -1
  242. package/dist/locale/zh-cn.mjs +1 -1
  243. package/dist/locale/zh-tw.js +1 -1
  244. package/dist/locale/zh-tw.min.js +1 -1
  245. package/dist/locale/zh-tw.min.mjs +1 -1
  246. package/dist/locale/zh-tw.mjs +1 -1
  247. package/es/components/carousel/index.mjs +2 -2
  248. package/es/components/carousel/src/carousel-item.mjs +8 -70
  249. package/es/components/carousel/src/carousel-item.mjs.map +1 -1
  250. package/es/components/carousel/src/carousel-item2.mjs +70 -8
  251. package/es/components/carousel/src/carousel-item2.mjs.map +1 -1
  252. package/es/components/cascader/index.mjs +2 -2
  253. package/es/components/cascader/src/cascader.mjs +83 -627
  254. package/es/components/cascader/src/cascader.mjs.map +1 -1
  255. package/es/components/cascader/src/cascader2.mjs +629 -83
  256. package/es/components/cascader/src/cascader2.mjs.map +1 -1
  257. package/es/components/cascader-panel/src/index.mjs +1 -0
  258. package/es/components/cascader-panel/src/index.mjs.map +1 -1
  259. package/es/components/collapse/index.mjs +2 -2
  260. package/es/components/collapse/src/collapse.mjs +18 -28
  261. package/es/components/collapse/src/collapse.mjs.map +1 -1
  262. package/es/components/collapse/src/collapse2.mjs +28 -18
  263. package/es/components/collapse/src/collapse2.mjs.map +1 -1
  264. package/es/components/color-picker/src/color-picker2.mjs +1 -0
  265. package/es/components/color-picker/src/color-picker2.mjs.map +1 -1
  266. package/es/components/dropdown/src/dropdown-item-impl.mjs +2 -3
  267. package/es/components/dropdown/src/dropdown-item-impl.mjs.map +1 -1
  268. package/es/components/dropdown/src/dropdown-menu.mjs +1 -1
  269. package/es/components/dropdown/src/dropdown2.mjs +7 -2
  270. package/es/components/dropdown/src/dropdown2.mjs.map +1 -1
  271. package/es/components/dropdown/src/useDropdown.mjs +1 -1
  272. package/es/components/dropdown/src/useDropdown.mjs.map +1 -1
  273. package/es/components/focus-trap/src/focus-trap.mjs +2 -2
  274. package/es/components/focus-trap/src/focus-trap.mjs.map +1 -1
  275. package/es/components/index.mjs +5 -5
  276. package/es/components/mention/src/mention2.mjs +51 -45
  277. package/es/components/mention/src/mention2.mjs.map +1 -1
  278. package/es/components/menu/src/utils/menu-item.mjs +1 -0
  279. package/es/components/menu/src/utils/menu-item.mjs.map +1 -1
  280. package/es/components/menu/src/utils/submenu.mjs +1 -0
  281. package/es/components/menu/src/utils/submenu.mjs.map +1 -1
  282. package/es/components/pagination/src/components/next.mjs +36 -19
  283. package/es/components/pagination/src/components/next.mjs.map +1 -1
  284. package/es/components/pagination/src/components/next2.mjs +19 -36
  285. package/es/components/pagination/src/components/next2.mjs.map +1 -1
  286. package/es/components/pagination/src/pagination.mjs +1 -1
  287. package/es/components/roving-focus-group/index.mjs +3 -3
  288. package/es/components/roving-focus-group/src/roving-focus-group-impl.mjs +1 -1
  289. package/es/components/roving-focus-group/src/roving-focus-group.mjs +29 -27
  290. package/es/components/roving-focus-group/src/roving-focus-group.mjs.map +1 -1
  291. package/es/components/roving-focus-group/src/roving-focus-group2.mjs +27 -29
  292. package/es/components/roving-focus-group/src/roving-focus-group2.mjs.map +1 -1
  293. package/es/components/roving-focus-group/src/roving-focus-item.mjs +3 -3
  294. package/es/components/roving-focus-group/src/roving-focus-item.mjs.map +1 -1
  295. package/es/components/roving-focus-group/src/utils.mjs +1 -1
  296. package/es/components/roving-focus-group/src/utils.mjs.map +1 -1
  297. package/es/components/scrollbar/index.mjs +2 -2
  298. package/es/components/scrollbar/src/scrollbar.mjs +55 -171
  299. package/es/components/scrollbar/src/scrollbar.mjs.map +1 -1
  300. package/es/components/scrollbar/src/scrollbar2.mjs +171 -55
  301. package/es/components/scrollbar/src/scrollbar2.mjs.map +1 -1
  302. package/es/components/segmented/index.mjs +2 -2
  303. package/es/components/segmented/src/segmented.mjs +34 -169
  304. package/es/components/segmented/src/segmented.mjs.map +1 -1
  305. package/es/components/segmented/src/segmented2.mjs +169 -34
  306. package/es/components/segmented/src/segmented2.mjs.map +1 -1
  307. package/es/components/select-v2/src/select-dropdown.mjs +7 -9
  308. package/es/components/select-v2/src/select-dropdown.mjs.map +1 -1
  309. package/es/components/select-v2/src/useSelect.mjs +2 -1
  310. package/es/components/select-v2/src/useSelect.mjs.map +1 -1
  311. package/es/components/slider/src/composables/use-slider-button.mjs +24 -15
  312. package/es/components/slider/src/composables/use-slider-button.mjs.map +1 -1
  313. package/es/components/tabs/src/tab-nav.mjs +21 -25
  314. package/es/components/tabs/src/tab-nav.mjs.map +1 -1
  315. package/es/components/tabs/src/tabs.mjs +1 -1
  316. package/es/components/tabs/src/tabs.mjs.map +1 -1
  317. package/es/components/tooltip/src/trigger.mjs +1 -1
  318. package/es/components/tooltip/src/trigger.mjs.map +1 -1
  319. package/es/components/tree/src/model/useKeydown.mjs +1 -1
  320. package/es/components/tree/src/model/useKeydown.mjs.map +1 -1
  321. package/es/hooks/use-escape-keydown/index.mjs +2 -3
  322. package/es/hooks/use-escape-keydown/index.mjs.map +1 -1
  323. package/es/index.mjs +5 -5
  324. package/es/version.d.ts +1 -1
  325. package/es/version.mjs +1 -1
  326. package/es/version.mjs.map +1 -1
  327. package/lib/components/carousel/index.js +2 -2
  328. package/lib/components/carousel/src/carousel-item.js +8 -70
  329. package/lib/components/carousel/src/carousel-item.js.map +1 -1
  330. package/lib/components/carousel/src/carousel-item2.js +70 -8
  331. package/lib/components/carousel/src/carousel-item2.js.map +1 -1
  332. package/lib/components/cascader/index.js +2 -2
  333. package/lib/components/cascader/src/cascader.js +84 -627
  334. package/lib/components/cascader/src/cascader.js.map +1 -1
  335. package/lib/components/cascader/src/cascader2.js +629 -84
  336. package/lib/components/cascader/src/cascader2.js.map +1 -1
  337. package/lib/components/cascader-panel/src/index.js +1 -0
  338. package/lib/components/cascader-panel/src/index.js.map +1 -1
  339. package/lib/components/collapse/index.js +2 -2
  340. package/lib/components/collapse/src/collapse.js +20 -28
  341. package/lib/components/collapse/src/collapse.js.map +1 -1
  342. package/lib/components/collapse/src/collapse2.js +28 -20
  343. package/lib/components/collapse/src/collapse2.js.map +1 -1
  344. package/lib/components/color-picker/src/color-picker2.js +1 -0
  345. package/lib/components/color-picker/src/color-picker2.js.map +1 -1
  346. package/lib/components/dropdown/src/dropdown-item-impl.js +2 -3
  347. package/lib/components/dropdown/src/dropdown-item-impl.js.map +1 -1
  348. package/lib/components/dropdown/src/dropdown-menu.js +1 -1
  349. package/lib/components/dropdown/src/dropdown2.js +7 -2
  350. package/lib/components/dropdown/src/dropdown2.js.map +1 -1
  351. package/lib/components/dropdown/src/useDropdown.js +1 -1
  352. package/lib/components/dropdown/src/useDropdown.js.map +1 -1
  353. package/lib/components/focus-trap/src/focus-trap.js +2 -2
  354. package/lib/components/focus-trap/src/focus-trap.js.map +1 -1
  355. package/lib/components/index.js +5 -5
  356. package/lib/components/mention/src/mention2.js +51 -45
  357. package/lib/components/mention/src/mention2.js.map +1 -1
  358. package/lib/components/menu/src/utils/menu-item.js +1 -0
  359. package/lib/components/menu/src/utils/menu-item.js.map +1 -1
  360. package/lib/components/menu/src/utils/submenu.js +1 -0
  361. package/lib/components/menu/src/utils/submenu.js.map +1 -1
  362. package/lib/components/pagination/src/components/next.js +36 -19
  363. package/lib/components/pagination/src/components/next.js.map +1 -1
  364. package/lib/components/pagination/src/components/next2.js +19 -36
  365. package/lib/components/pagination/src/components/next2.js.map +1 -1
  366. package/lib/components/pagination/src/pagination.js +1 -1
  367. package/lib/components/roving-focus-group/index.js +2 -2
  368. package/lib/components/roving-focus-group/src/roving-focus-group-impl.js +1 -1
  369. package/lib/components/roving-focus-group/src/roving-focus-group.js +33 -27
  370. package/lib/components/roving-focus-group/src/roving-focus-group.js.map +1 -1
  371. package/lib/components/roving-focus-group/src/roving-focus-group2.js +27 -33
  372. package/lib/components/roving-focus-group/src/roving-focus-group2.js.map +1 -1
  373. package/lib/components/roving-focus-group/src/roving-focus-item.js +3 -3
  374. package/lib/components/roving-focus-group/src/roving-focus-item.js.map +1 -1
  375. package/lib/components/roving-focus-group/src/utils.js +1 -1
  376. package/lib/components/roving-focus-group/src/utils.js.map +1 -1
  377. package/lib/components/scrollbar/index.js +2 -2
  378. package/lib/components/scrollbar/src/scrollbar.js +56 -171
  379. package/lib/components/scrollbar/src/scrollbar.js.map +1 -1
  380. package/lib/components/scrollbar/src/scrollbar2.js +171 -56
  381. package/lib/components/scrollbar/src/scrollbar2.js.map +1 -1
  382. package/lib/components/segmented/index.js +2 -2
  383. package/lib/components/segmented/src/segmented.js +34 -168
  384. package/lib/components/segmented/src/segmented.js.map +1 -1
  385. package/lib/components/segmented/src/segmented2.js +168 -34
  386. package/lib/components/segmented/src/segmented2.js.map +1 -1
  387. package/lib/components/select-v2/src/select-dropdown.js +7 -9
  388. package/lib/components/select-v2/src/select-dropdown.js.map +1 -1
  389. package/lib/components/select-v2/src/useSelect.js +2 -1
  390. package/lib/components/select-v2/src/useSelect.js.map +1 -1
  391. package/lib/components/slider/src/composables/use-slider-button.js +24 -15
  392. package/lib/components/slider/src/composables/use-slider-button.js.map +1 -1
  393. package/lib/components/tabs/src/tab-nav.js +21 -25
  394. package/lib/components/tabs/src/tab-nav.js.map +1 -1
  395. package/lib/components/tabs/src/tabs.js +1 -1
  396. package/lib/components/tabs/src/tabs.js.map +1 -1
  397. package/lib/components/tooltip/src/trigger.js +1 -1
  398. package/lib/components/tooltip/src/trigger.js.map +1 -1
  399. package/lib/components/tree/src/model/useKeydown.js +1 -1
  400. package/lib/components/tree/src/model/useKeydown.js.map +1 -1
  401. package/lib/hooks/use-escape-keydown/index.js +2 -3
  402. package/lib/hooks/use-escape-keydown/index.js.map +1 -1
  403. package/lib/index.js +5 -5
  404. package/lib/version.d.ts +1 -1
  405. package/lib/version.js +1 -1
  406. package/lib/version.js.map +1 -1
  407. package/package.json +2 -2
  408. package/web-types.json +1 -1
@@ -17,7 +17,7 @@ require('../../../hooks/index.js');
17
17
  var dropdown = require('./dropdown.js');
18
18
  var tokens = require('./tokens.js');
19
19
  var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
20
- var rovingFocusGroup = require('../../roving-focus-group/src/roving-focus-group.js');
20
+ var rovingFocusGroup = require('../../roving-focus-group/src/roving-focus-group2.js');
21
21
  var onlyChild = require('../../slot/src/only-child.js');
22
22
  var index$4 = require('../../../hooks/use-namespace/index.js');
23
23
  var index$5 = require('../../../hooks/use-locale/index.js');
@@ -54,7 +54,12 @@ const _sfc_main = vue.defineComponent({
54
54
  const scrollbar = vue.ref(null);
55
55
  const currentTabId = vue.ref(null);
56
56
  const isUsingKeyboard = vue.ref(false);
57
- const triggerKeys = [aria.EVENT_CODE.enter, aria.EVENT_CODE.space, aria.EVENT_CODE.down];
57
+ const triggerKeys = [
58
+ aria.EVENT_CODE.enter,
59
+ aria.EVENT_CODE.numpadEnter,
60
+ aria.EVENT_CODE.space,
61
+ aria.EVENT_CODE.down
62
+ ];
58
63
  const wrapStyle = vue.computed(() => ({
59
64
  maxHeight: style.addUnit(props.maxHeight)
60
65
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown2.js","sources":["../../../../../../packages/components/dropdown/src/dropdown.vue"],"sourcesContent":["<template>\n <div :class=\"[ns.b(), ns.is('disabled', disabled)]\">\n <el-tooltip\n ref=\"popperRef\"\n :role=\"role\"\n :effect=\"effect\"\n :fallback-placements=\"['bottom', 'top']\"\n :popper-options=\"popperOptions\"\n :gpu-acceleration=\"false\"\n :hide-after=\"trigger === 'hover' ? hideTimeout : 0\"\n :manual-mode=\"true\"\n :placement=\"placement\"\n :popper-class=\"[ns.e('popper'), popperClass]\"\n :reference-element=\"referenceElementRef?.$el\"\n :trigger=\"trigger\"\n :trigger-keys=\"triggerKeys\"\n :trigger-target-el=\"contentRef\"\n :show-after=\"trigger === 'hover' ? showTimeout : 0\"\n :stop-popper-mouse-event=\"false\"\n :virtual-ref=\"triggeringElementRef\"\n :virtual-triggering=\"splitButton\"\n :disabled=\"disabled\"\n :transition=\"`${ns.namespace.value}-zoom-in-top`\"\n :teleported=\"teleported\"\n pure\n persistent\n @before-show=\"handleBeforeShowTooltip\"\n @show=\"handleShowTooltip\"\n @before-hide=\"handleBeforeHideTooltip\"\n >\n <template #content>\n <el-scrollbar\n ref=\"scrollbar\"\n :wrap-style=\"wrapStyle\"\n tag=\"div\"\n :view-class=\"ns.e('list')\"\n >\n <el-roving-focus-group\n :loop=\"loop\"\n :current-tab-id=\"currentTabId\"\n orientation=\"horizontal\"\n @current-tab-id-change=\"handleCurrentTabIdChange\"\n @entry-focus=\"handleEntryFocus\"\n >\n <el-dropdown-collection>\n <slot name=\"dropdown\" />\n </el-dropdown-collection>\n </el-roving-focus-group>\n </el-scrollbar>\n </template>\n <template v-if=\"!splitButton\" #default>\n <el-only-child\n :id=\"triggerId\"\n ref=\"triggeringElementRef\"\n role=\"button\"\n :tabindex=\"tabindex\"\n >\n <slot name=\"default\" />\n </el-only-child>\n </template>\n </el-tooltip>\n <template v-if=\"splitButton\">\n <el-button-group>\n <el-button\n ref=\"referenceElementRef\"\n v-bind=\"buttonProps\"\n :size=\"dropdownSize\"\n :type=\"type\"\n :disabled=\"disabled\"\n :tabindex=\"tabindex\"\n @click=\"handlerMainButtonClick\"\n >\n <slot name=\"default\" />\n </el-button>\n <el-button\n :id=\"triggerId\"\n ref=\"triggeringElementRef\"\n v-bind=\"buttonProps\"\n role=\"button\"\n :size=\"dropdownSize\"\n :type=\"type\"\n :class=\"ns.e('caret-button')\"\n :disabled=\"disabled\"\n :tabindex=\"tabindex\"\n :aria-label=\"t('el.dropdown.toggleDropdown')\"\n >\n <el-icon :class=\"ns.e('icon')\"><arrow-down /></el-icon>\n </el-button>\n </el-button-group>\n </template>\n </div>\n</template>\n<script lang=\"ts\">\n// @ts-nocheck\nimport {\n computed,\n defineComponent,\n getCurrentInstance,\n onBeforeUnmount,\n provide,\n ref,\n toRef,\n unref,\n watch,\n} from 'vue'\nimport ElButton from '@element-plus/components/button'\nimport ElTooltip from '@element-plus/components/tooltip'\nimport ElScrollbar from '@element-plus/components/scrollbar'\nimport ElIcon from '@element-plus/components/icon'\nimport ElRovingFocusGroup from '@element-plus/components/roving-focus-group'\nimport { ElOnlyChild } from '@element-plus/components/slot'\nimport { useFormSize } from '@element-plus/components/form'\nimport { addUnit, ensureArray } from '@element-plus/utils'\nimport { ArrowDown } from '@element-plus/icons-vue'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { useId, useLocale, useNamespace } from '@element-plus/hooks'\nimport { ElCollection as ElDropdownCollection, dropdownProps } from './dropdown'\nimport { DROPDOWN_INJECTION_KEY } from './tokens'\n\nimport type { CSSProperties } from 'vue'\n\nconst { ButtonGroup: ElButtonGroup } = ElButton\n\nexport default defineComponent({\n name: 'ElDropdown',\n components: {\n ElButton,\n ElButtonGroup,\n ElScrollbar,\n ElDropdownCollection,\n ElTooltip,\n ElRovingFocusGroup,\n ElOnlyChild,\n ElIcon,\n ArrowDown,\n },\n props: dropdownProps,\n emits: ['visible-change', 'click', 'command'],\n setup(props, { emit }) {\n const _instance = getCurrentInstance()\n const ns = useNamespace('dropdown')\n const { t } = useLocale()\n\n const triggeringElementRef = ref()\n const referenceElementRef = ref()\n const popperRef = ref<InstanceType<typeof ElTooltip> | null>(null)\n const contentRef = ref<HTMLElement | null>(null)\n const scrollbar = ref(null)\n const currentTabId = ref<string | null>(null)\n const isUsingKeyboard = ref(false)\n const triggerKeys = [EVENT_CODE.enter, EVENT_CODE.space, EVENT_CODE.down]\n\n const wrapStyle = computed<CSSProperties>(() => ({\n maxHeight: addUnit(props.maxHeight),\n }))\n const dropdownTriggerKls = computed(() => [ns.m(dropdownSize.value)])\n const trigger = computed(() => ensureArray(props.trigger))\n\n const defaultTriggerId = useId().value\n const triggerId = computed<string>(() => props.id || defaultTriggerId)\n\n // The goal of this code is to focus on the tooltip triggering element when it is hovered.\n // This is a temporary fix for where closing the dropdown through pointerleave event focuses on a\n // completely different element. For a permanent solution, remove all calls to any \"element.focus()\"\n // that are triggered through pointer enter/leave events.\n watch(\n [triggeringElementRef, trigger],\n ([triggeringElement, trigger], [prevTriggeringElement]) => {\n if (prevTriggeringElement?.$el?.removeEventListener) {\n prevTriggeringElement.$el.removeEventListener(\n 'pointerenter',\n onAutofocusTriggerEnter\n )\n }\n if (triggeringElement?.$el?.removeEventListener) {\n triggeringElement.$el.removeEventListener(\n 'pointerenter',\n onAutofocusTriggerEnter\n )\n }\n if (\n triggeringElement?.$el?.addEventListener &&\n trigger.includes('hover')\n ) {\n triggeringElement.$el.addEventListener(\n 'pointerenter',\n onAutofocusTriggerEnter\n )\n }\n },\n { immediate: true }\n )\n\n onBeforeUnmount(() => {\n if (triggeringElementRef.value?.$el?.removeEventListener) {\n triggeringElementRef.value.$el.removeEventListener(\n 'pointerenter',\n onAutofocusTriggerEnter\n )\n }\n })\n\n function handleClick() {\n handleClose()\n }\n\n function handleClose() {\n popperRef.value?.onClose()\n }\n\n function handleOpen() {\n popperRef.value?.onOpen()\n }\n\n const dropdownSize = useFormSize()\n\n function commandHandler(...args: any[]) {\n emit('command', ...args)\n }\n\n function onAutofocusTriggerEnter() {\n triggeringElementRef.value?.$el?.focus()\n }\n\n function onItemEnter() {\n // NOOP for now\n }\n\n function onItemLeave() {\n const contentEl = unref(contentRef)\n\n trigger.value.includes('hover') && contentEl?.focus()\n currentTabId.value = null\n }\n\n function handleCurrentTabIdChange(id: string) {\n currentTabId.value = id\n }\n\n function handleEntryFocus(e: Event) {\n if (!isUsingKeyboard.value) {\n e.preventDefault()\n e.stopImmediatePropagation()\n }\n }\n\n function handleBeforeShowTooltip() {\n emit('visible-change', true)\n }\n\n function handleShowTooltip(event?: Event) {\n if (event?.type === 'keydown') {\n contentRef.value.focus()\n }\n }\n\n function handleBeforeHideTooltip() {\n emit('visible-change', false)\n }\n\n provide(DROPDOWN_INJECTION_KEY, {\n contentRef,\n role: computed(() => props.role),\n triggerId,\n isUsingKeyboard,\n onItemEnter,\n onItemLeave,\n })\n\n provide('elDropdown', {\n instance: _instance,\n dropdownSize,\n handleClick,\n commandHandler,\n trigger: toRef(props, 'trigger'),\n hideOnClick: toRef(props, 'hideOnClick'),\n })\n\n const onFocusAfterTrapped = (e: Event) => {\n e.preventDefault()\n contentRef.value?.focus?.({\n preventScroll: true,\n })\n }\n\n const handlerMainButtonClick = (event: MouseEvent) => {\n emit('click', event)\n }\n\n return {\n t,\n ns,\n scrollbar,\n wrapStyle,\n dropdownTriggerKls,\n dropdownSize,\n triggerId,\n triggerKeys,\n currentTabId,\n handleCurrentTabIdChange,\n handlerMainButtonClick,\n handleEntryFocus,\n handleClose,\n handleOpen,\n handleBeforeShowTooltip,\n handleShowTooltip,\n handleBeforeHideTooltip,\n onFocusAfterTrapped,\n popperRef,\n contentRef,\n triggeringElementRef,\n referenceElementRef,\n }\n },\n})\n</script>\n"],"names":["ElButton","defineComponent","ElScrollbar","ElDropdownCollection","ElTooltip","ElRovingFocusGroup","ElOnlyChild","ElIcon","ArrowDown","dropdownProps","getCurrentInstance","useNamespace","useLocale","ref","EVENT_CODE","computed","addUnit","ensureArray","useId","watch","onBeforeUnmount","useFormSize","unref","provide","DROPDOWN_INJECTION_KEY","toRef","_resolveComponent","_createSlots","_withCtx","_createV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../../../../packages/components/dropdown/src/dropdown.vue"],"sourcesContent":["<template>\n <div :class=\"[ns.b(), ns.is('disabled', disabled)]\">\n <el-tooltip\n ref=\"popperRef\"\n :role=\"role\"\n :effect=\"effect\"\n :fallback-placements=\"['bottom', 'top']\"\n :popper-options=\"popperOptions\"\n :gpu-acceleration=\"false\"\n :hide-after=\"trigger === 'hover' ? hideTimeout : 0\"\n :manual-mode=\"true\"\n :placement=\"placement\"\n :popper-class=\"[ns.e('popper'), popperClass]\"\n :reference-element=\"referenceElementRef?.$el\"\n :trigger=\"trigger\"\n :trigger-keys=\"triggerKeys\"\n :trigger-target-el=\"contentRef\"\n :show-after=\"trigger === 'hover' ? showTimeout : 0\"\n :stop-popper-mouse-event=\"false\"\n :virtual-ref=\"triggeringElementRef\"\n :virtual-triggering=\"splitButton\"\n :disabled=\"disabled\"\n :transition=\"`${ns.namespace.value}-zoom-in-top`\"\n :teleported=\"teleported\"\n pure\n persistent\n @before-show=\"handleBeforeShowTooltip\"\n @show=\"handleShowTooltip\"\n @before-hide=\"handleBeforeHideTooltip\"\n >\n <template #content>\n <el-scrollbar\n ref=\"scrollbar\"\n :wrap-style=\"wrapStyle\"\n tag=\"div\"\n :view-class=\"ns.e('list')\"\n >\n <el-roving-focus-group\n :loop=\"loop\"\n :current-tab-id=\"currentTabId\"\n orientation=\"horizontal\"\n @current-tab-id-change=\"handleCurrentTabIdChange\"\n @entry-focus=\"handleEntryFocus\"\n >\n <el-dropdown-collection>\n <slot name=\"dropdown\" />\n </el-dropdown-collection>\n </el-roving-focus-group>\n </el-scrollbar>\n </template>\n <template v-if=\"!splitButton\" #default>\n <el-only-child\n :id=\"triggerId\"\n ref=\"triggeringElementRef\"\n role=\"button\"\n :tabindex=\"tabindex\"\n >\n <slot name=\"default\" />\n </el-only-child>\n </template>\n </el-tooltip>\n <template v-if=\"splitButton\">\n <el-button-group>\n <el-button\n ref=\"referenceElementRef\"\n v-bind=\"buttonProps\"\n :size=\"dropdownSize\"\n :type=\"type\"\n :disabled=\"disabled\"\n :tabindex=\"tabindex\"\n @click=\"handlerMainButtonClick\"\n >\n <slot name=\"default\" />\n </el-button>\n <el-button\n :id=\"triggerId\"\n ref=\"triggeringElementRef\"\n v-bind=\"buttonProps\"\n role=\"button\"\n :size=\"dropdownSize\"\n :type=\"type\"\n :class=\"ns.e('caret-button')\"\n :disabled=\"disabled\"\n :tabindex=\"tabindex\"\n :aria-label=\"t('el.dropdown.toggleDropdown')\"\n >\n <el-icon :class=\"ns.e('icon')\"><arrow-down /></el-icon>\n </el-button>\n </el-button-group>\n </template>\n </div>\n</template>\n<script lang=\"ts\">\n// @ts-nocheck\nimport {\n computed,\n defineComponent,\n getCurrentInstance,\n onBeforeUnmount,\n provide,\n ref,\n toRef,\n unref,\n watch,\n} from 'vue'\nimport ElButton from '@element-plus/components/button'\nimport ElTooltip from '@element-plus/components/tooltip'\nimport ElScrollbar from '@element-plus/components/scrollbar'\nimport ElIcon from '@element-plus/components/icon'\nimport ElRovingFocusGroup from '@element-plus/components/roving-focus-group'\nimport { ElOnlyChild } from '@element-plus/components/slot'\nimport { useFormSize } from '@element-plus/components/form'\nimport { addUnit, ensureArray } from '@element-plus/utils'\nimport { ArrowDown } from '@element-plus/icons-vue'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { useId, useLocale, useNamespace } from '@element-plus/hooks'\nimport { ElCollection as ElDropdownCollection, dropdownProps } from './dropdown'\nimport { DROPDOWN_INJECTION_KEY } from './tokens'\n\nimport type { CSSProperties } from 'vue'\n\nconst { ButtonGroup: ElButtonGroup } = ElButton\n\nexport default defineComponent({\n name: 'ElDropdown',\n components: {\n ElButton,\n ElButtonGroup,\n ElScrollbar,\n ElDropdownCollection,\n ElTooltip,\n ElRovingFocusGroup,\n ElOnlyChild,\n ElIcon,\n ArrowDown,\n },\n props: dropdownProps,\n emits: ['visible-change', 'click', 'command'],\n setup(props, { emit }) {\n const _instance = getCurrentInstance()\n const ns = useNamespace('dropdown')\n const { t } = useLocale()\n\n const triggeringElementRef = ref()\n const referenceElementRef = ref()\n const popperRef = ref<InstanceType<typeof ElTooltip> | null>(null)\n const contentRef = ref<HTMLElement | null>(null)\n const scrollbar = ref(null)\n const currentTabId = ref<string | null>(null)\n const isUsingKeyboard = ref(false)\n const triggerKeys = [\n EVENT_CODE.enter,\n EVENT_CODE.numpadEnter,\n EVENT_CODE.space,\n EVENT_CODE.down,\n ]\n\n const wrapStyle = computed<CSSProperties>(() => ({\n maxHeight: addUnit(props.maxHeight),\n }))\n const dropdownTriggerKls = computed(() => [ns.m(dropdownSize.value)])\n const trigger = computed(() => ensureArray(props.trigger))\n\n const defaultTriggerId = useId().value\n const triggerId = computed<string>(() => props.id || defaultTriggerId)\n\n // The goal of this code is to focus on the tooltip triggering element when it is hovered.\n // This is a temporary fix for where closing the dropdown through pointerleave event focuses on a\n // completely different element. For a permanent solution, remove all calls to any \"element.focus()\"\n // that are triggered through pointer enter/leave events.\n watch(\n [triggeringElementRef, trigger],\n ([triggeringElement, trigger], [prevTriggeringElement]) => {\n if (prevTriggeringElement?.$el?.removeEventListener) {\n prevTriggeringElement.$el.removeEventListener(\n 'pointerenter',\n onAutofocusTriggerEnter\n )\n }\n if (triggeringElement?.$el?.removeEventListener) {\n triggeringElement.$el.removeEventListener(\n 'pointerenter',\n onAutofocusTriggerEnter\n )\n }\n if (\n triggeringElement?.$el?.addEventListener &&\n trigger.includes('hover')\n ) {\n triggeringElement.$el.addEventListener(\n 'pointerenter',\n onAutofocusTriggerEnter\n )\n }\n },\n { immediate: true }\n )\n\n onBeforeUnmount(() => {\n if (triggeringElementRef.value?.$el?.removeEventListener) {\n triggeringElementRef.value.$el.removeEventListener(\n 'pointerenter',\n onAutofocusTriggerEnter\n )\n }\n })\n\n function handleClick() {\n handleClose()\n }\n\n function handleClose() {\n popperRef.value?.onClose()\n }\n\n function handleOpen() {\n popperRef.value?.onOpen()\n }\n\n const dropdownSize = useFormSize()\n\n function commandHandler(...args: any[]) {\n emit('command', ...args)\n }\n\n function onAutofocusTriggerEnter() {\n triggeringElementRef.value?.$el?.focus()\n }\n\n function onItemEnter() {\n // NOOP for now\n }\n\n function onItemLeave() {\n const contentEl = unref(contentRef)\n\n trigger.value.includes('hover') && contentEl?.focus()\n currentTabId.value = null\n }\n\n function handleCurrentTabIdChange(id: string) {\n currentTabId.value = id\n }\n\n function handleEntryFocus(e: Event) {\n if (!isUsingKeyboard.value) {\n e.preventDefault()\n e.stopImmediatePropagation()\n }\n }\n\n function handleBeforeShowTooltip() {\n emit('visible-change', true)\n }\n\n function handleShowTooltip(event?: Event) {\n if (event?.type === 'keydown') {\n contentRef.value.focus()\n }\n }\n\n function handleBeforeHideTooltip() {\n emit('visible-change', false)\n }\n\n provide(DROPDOWN_INJECTION_KEY, {\n contentRef,\n role: computed(() => props.role),\n triggerId,\n isUsingKeyboard,\n onItemEnter,\n onItemLeave,\n })\n\n provide('elDropdown', {\n instance: _instance,\n dropdownSize,\n handleClick,\n commandHandler,\n trigger: toRef(props, 'trigger'),\n hideOnClick: toRef(props, 'hideOnClick'),\n })\n\n const onFocusAfterTrapped = (e: Event) => {\n e.preventDefault()\n contentRef.value?.focus?.({\n preventScroll: true,\n })\n }\n\n const handlerMainButtonClick = (event: MouseEvent) => {\n emit('click', event)\n }\n\n return {\n t,\n ns,\n scrollbar,\n wrapStyle,\n dropdownTriggerKls,\n dropdownSize,\n triggerId,\n triggerKeys,\n currentTabId,\n handleCurrentTabIdChange,\n handlerMainButtonClick,\n handleEntryFocus,\n handleClose,\n handleOpen,\n handleBeforeShowTooltip,\n handleShowTooltip,\n handleBeforeHideTooltip,\n onFocusAfterTrapped,\n popperRef,\n contentRef,\n triggeringElementRef,\n referenceElementRef,\n }\n },\n})\n</script>\n"],"names":["ElButton","defineComponent","ElScrollbar","ElDropdownCollection","ElTooltip","ElRovingFocusGroup","ElOnlyChild","ElIcon","ArrowDown","dropdownProps","getCurrentInstance","useNamespace","useLocale","ref","EVENT_CODE","computed","addUnit","ensureArray","useId","watch","onBeforeUnmount","useFormSize","unref","provide","DROPDOWN_INJECTION_KEY","toRef","_resolveComponent","_createSlots","_withCtx","_createVNode","_renderSlot","_openBlock","_createBlock","_mergeProps","_normalizeClass","_createCommentVNode","_export_sfc"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAM,EAAE,WAAa,EAAA,aAAA,EAAkB,GAAAA,cAAA,CAAA;AAEvC,MAAK,YAAaC,mBAAa,CAAA;AAAA,EAC7B,IAAM,EAAA,YAAA;AAAA,EACN,UAAY,EAAA;AAAA,cACVD,cAAA;AAAA,IACA,aAAA;AAAA,iBACAE,mBAAA;AAAA,0BACAC,qBAAA;AAAA,eACAC,iBAAA;AAAA,wBACAC,2BAAA;AAAA,iBACAC,mBAAA;AAAA,YACAC,cAAA;AAAA,eACAC,kBAAA;AAAA,GACF;AAAA,EACA,KAAO,EAAAC,sBAAA;AAAA,EACP,KAAO,EAAA,CAAC,gBAAkB,EAAA,OAAA,EAAS,SAAS,CAAA;AAAA,EAC5C,KAAM,CAAA,KAAA,EAAO,EAAE,IAAA,EAAQ,EAAA;AACrB,IAAA,MAAM,YAAYC,sBAAmB,EAAA,CAAA;AACrC,IAAM,MAAA,EAAA,GAAKC,qBAAa,UAAU,CAAA,CAAA;AAClC,IAAM,MAAA,EAAE,CAAE,EAAA,GAAIC,iBAAU,EAAA,CAAA;AAExB,IAAA,MAAM,uBAAuBC,OAAI,EAAA,CAAA;AACjC,IAAA,MAAM,sBAAsBA,OAAI,EAAA,CAAA;AAChC,IAAM,MAAA,SAAA,GAAYA,QAA2C,IAAI,CAAA,CAAA;AACjE,IAAM,MAAA,UAAA,GAAaA,QAAwB,IAAI,CAAA,CAAA;AAC/C,IAAM,MAAA,SAAA,GAAYA,QAAI,IAAI,CAAA,CAAA;AAC1B,IAAM,MAAA,YAAA,GAAeA,QAAmB,IAAI,CAAA,CAAA;AAC5C,IAAM,MAAA,eAAA,GAAkBA,QAAI,KAAK,CAAA,CAAA;AAC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CC,iCAAA,CAAA,SAAA,EAAA,CAAA,CAAA,QAAA,EAAA,WAAA,CAAA,EAAA,CAAA,QAAA,EAAA,cAAA,CAAA,CAAA,CAAA;;;;"}
@@ -43,7 +43,7 @@ const initDropdownDomEvent = (dropdownChildren, triggerElm, _instance) => {
43
43
  menuItems.value[0].focus();
44
44
  ev.preventDefault();
45
45
  ev.stopPropagation();
46
- } else if (code === aria.EVENT_CODE.enter) {
46
+ } else if ([aria.EVENT_CODE.enter, aria.EVENT_CODE.numpadEnter].includes(code)) {
47
47
  _instance.handleClick();
48
48
  } else if ([aria.EVENT_CODE.tab, aria.EVENT_CODE.esc].includes(code)) {
49
49
  _instance.hide();
@@ -1 +1 @@
1
- {"version":3,"file":"useDropdown.js","sources":["../../../../../../packages/components/dropdown/src/useDropdown.ts"],"sourcesContent":["// @ts-nocheck\nimport { computed, inject, ref } from 'vue'\nimport { addClass } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { useId, useNamespace } from '@element-plus/hooks'\nimport type { Nullable } from '@element-plus/utils'\nimport type { IElDropdownInstance } from './dropdown'\n\nexport const useDropdown = () => {\n const elDropdown = inject<IElDropdownInstance>('elDropdown', {})\n const _elDropdownSize = computed(() => elDropdown?.dropdownSize)\n\n return {\n elDropdown,\n _elDropdownSize,\n }\n}\n\nexport const initDropdownDomEvent = (\n dropdownChildren,\n triggerElm,\n _instance\n) => {\n const ns = useNamespace('dropdown')\n const menuItems = ref<Nullable<HTMLButtonElement[]>>(null)\n const menuItemsArray = ref<Nullable<HTMLElement[]>>(null)\n const dropdownElm = ref<Nullable<HTMLElement>>(null)\n const listId = useId()\n dropdownElm.value = dropdownChildren?.subTree.el\n\n function removeTabindex() {\n triggerElm.setAttribute('tabindex', '-1')\n menuItemsArray.value?.forEach((item) => item.setAttribute('tabindex', '-1'))\n }\n\n function resetTabindex(ele) {\n removeTabindex()\n ele?.setAttribute('tabindex', '0')\n }\n\n function handleTriggerKeyDown(ev: KeyboardEvent) {\n const code = ev.code\n if ([EVENT_CODE.up, EVENT_CODE.down].includes(code)) {\n removeTabindex()\n resetTabindex(menuItems.value[0])\n menuItems.value[0].focus()\n ev.preventDefault()\n ev.stopPropagation()\n } else if (code === EVENT_CODE.enter) {\n _instance.handleClick()\n } else if ([EVENT_CODE.tab, EVENT_CODE.esc].includes(code)) {\n _instance.hide()\n }\n }\n\n function handleItemKeyDown(ev) {\n const code = ev.code\n const target = ev.target\n const currentIndex = menuItemsArray.value.indexOf(target)\n const max = menuItemsArray.value.length - 1\n let nextIndex\n if ([EVENT_CODE.up, EVENT_CODE.down].includes(code)) {\n if (code === EVENT_CODE.up) {\n nextIndex = currentIndex !== 0 ? currentIndex - 1 : 0\n } else {\n nextIndex = currentIndex < max ? currentIndex + 1 : max\n }\n removeTabindex()\n resetTabindex(menuItems.value[nextIndex])\n menuItems.value[nextIndex].focus()\n ev.preventDefault()\n ev.stopPropagation()\n } else if (code === EVENT_CODE.enter) {\n triggerElmFocus()\n target.click()\n if (_instance.props.hideOnClick) {\n _instance.hide()\n }\n } else if ([EVENT_CODE.tab, EVENT_CODE.esc].includes(code)) {\n _instance.hide()\n triggerElmFocus()\n }\n }\n\n function initAria() {\n dropdownElm.value.setAttribute('id', listId.value)\n triggerElm.setAttribute('aria-haspopup', 'list')\n triggerElm.setAttribute('aria-controls', listId.value)\n if (!_instance.props.splitButton) {\n triggerElm.setAttribute('role', 'button')\n triggerElm.setAttribute('tabindex', _instance.props.tabindex)\n addClass(triggerElm, ns.b('selfdefine'))\n }\n }\n\n function initEvent() {\n triggerElm?.addEventListener('keydown', handleTriggerKeyDown)\n dropdownElm.value?.addEventListener('keydown', handleItemKeyDown, true)\n }\n\n function initDomOperation() {\n menuItems.value = dropdownElm.value.querySelectorAll(\n \"[tabindex='-1']\"\n ) as unknown as HTMLButtonElement[]\n menuItemsArray.value = Array.from(menuItems.value)\n\n initEvent()\n initAria()\n }\n\n function triggerElmFocus() {\n triggerElm.focus()\n }\n\n initDomOperation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"}
1
+ {"version":3,"file":"useDropdown.js","sources":["../../../../../../packages/components/dropdown/src/useDropdown.ts"],"sourcesContent":["// @ts-nocheck\nimport { computed, inject, ref } from 'vue'\nimport { addClass } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { useId, useNamespace } from '@element-plus/hooks'\nimport type { Nullable } from '@element-plus/utils'\nimport type { IElDropdownInstance } from './dropdown'\n\nexport const useDropdown = () => {\n const elDropdown = inject<IElDropdownInstance>('elDropdown', {})\n const _elDropdownSize = computed(() => elDropdown?.dropdownSize)\n\n return {\n elDropdown,\n _elDropdownSize,\n }\n}\n\nexport const initDropdownDomEvent = (\n dropdownChildren,\n triggerElm,\n _instance\n) => {\n const ns = useNamespace('dropdown')\n const menuItems = ref<Nullable<HTMLButtonElement[]>>(null)\n const menuItemsArray = ref<Nullable<HTMLElement[]>>(null)\n const dropdownElm = ref<Nullable<HTMLElement>>(null)\n const listId = useId()\n dropdownElm.value = dropdownChildren?.subTree.el\n\n function removeTabindex() {\n triggerElm.setAttribute('tabindex', '-1')\n menuItemsArray.value?.forEach((item) => item.setAttribute('tabindex', '-1'))\n }\n\n function resetTabindex(ele) {\n removeTabindex()\n ele?.setAttribute('tabindex', '0')\n }\n\n function handleTriggerKeyDown(ev: KeyboardEvent) {\n const code = ev.code\n if ([EVENT_CODE.up, EVENT_CODE.down].includes(code)) {\n removeTabindex()\n resetTabindex(menuItems.value[0])\n menuItems.value[0].focus()\n ev.preventDefault()\n ev.stopPropagation()\n } else if ([EVENT_CODE.enter, EVENT_CODE.numpadEnter].includes(code)) {\n _instance.handleClick()\n } else if ([EVENT_CODE.tab, EVENT_CODE.esc].includes(code)) {\n _instance.hide()\n }\n }\n\n function handleItemKeyDown(ev) {\n const code = ev.code\n const target = ev.target\n const currentIndex = menuItemsArray.value.indexOf(target)\n const max = menuItemsArray.value.length - 1\n let nextIndex\n if ([EVENT_CODE.up, EVENT_CODE.down].includes(code)) {\n if (code === EVENT_CODE.up) {\n nextIndex = currentIndex !== 0 ? currentIndex - 1 : 0\n } else {\n nextIndex = currentIndex < max ? currentIndex + 1 : max\n }\n removeTabindex()\n resetTabindex(menuItems.value[nextIndex])\n menuItems.value[nextIndex].focus()\n ev.preventDefault()\n ev.stopPropagation()\n } else if (code === EVENT_CODE.enter) {\n triggerElmFocus()\n target.click()\n if (_instance.props.hideOnClick) {\n _instance.hide()\n }\n } else if ([EVENT_CODE.tab, EVENT_CODE.esc].includes(code)) {\n _instance.hide()\n triggerElmFocus()\n }\n }\n\n function initAria() {\n dropdownElm.value.setAttribute('id', listId.value)\n triggerElm.setAttribute('aria-haspopup', 'list')\n triggerElm.setAttribute('aria-controls', listId.value)\n if (!_instance.props.splitButton) {\n triggerElm.setAttribute('role', 'button')\n triggerElm.setAttribute('tabindex', _instance.props.tabindex)\n addClass(triggerElm, ns.b('selfdefine'))\n }\n }\n\n function initEvent() {\n triggerElm?.addEventListener('keydown', handleTriggerKeyDown)\n dropdownElm.value?.addEventListener('keydown', handleItemKeyDown, true)\n }\n\n function initDomOperation() {\n menuItems.value = dropdownElm.value.querySelectorAll(\n \"[tabindex='-1']\"\n ) as unknown as HTMLButtonElement[]\n menuItemsArray.value = Array.from(menuItems.value)\n\n initEvent()\n initAria()\n }\n\n function triggerElmFocus() {\n triggerElm.focus()\n }\n\n initDomOperation()\n}\n"],"names":["inject","computed","useNamespace","ref","useId","EVENT_CODE","addClass"],"mappings":";;;;;;;;;;;;;AAIY,MAAC,WAAW,GAAG,MAAM;AACjC,EAAE,MAAM,UAAU,GAAGA,UAAM,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAC9C,EAAE,MAAM,eAAe,GAAGC,YAAQ,CAAC,MAAM,UAAU,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAChG,EAAE,OAAO;AACT,IAAI,UAAU;AACd,IAAI,eAAe;AACnB,GAAG,CAAC;AACJ,EAAE;AACU,MAAC,oBAAoB,GAAG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CAAC,CAAC;AACpE,MAAMC,cAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;AAC/C,KAAK;AACL,GAAG;AACH,EAAE,SAAS,SAAS,GAAG;AACvB,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,UAAU,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAC/F,IAAI,CAAC,EAAE,GAAG,WAAW,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;AACxG,GAAG;AACH,EAAE,SAAS,gBAAgB,GAAG;AAC9B,IAAI,SAAS,CAAC,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAC5E,IAAI,cAAc,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvD,IAAI,SAAS,EAAE,CAAC;AAChB,IAAI,QAAQ,EAAE,CAAC;AACf,GAAG;AACH,EAAE,SAAS,eAAe,GAAG;AAC7B,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;AACvB,GAAG;AACH,EAAE,gBAAgB,EAAE,CAAC;AACrB;;;;;"}
@@ -58,9 +58,9 @@ const _sfc_main = vue.defineComponent({
58
58
  return;
59
59
  if (focusLayer.paused)
60
60
  return;
61
- const { key, altKey, ctrlKey, metaKey, currentTarget, shiftKey } = e;
61
+ const { code, altKey, ctrlKey, metaKey, currentTarget, shiftKey } = e;
62
62
  const { loop } = props;
63
- const isTabbing = key === aria.EVENT_CODE.tab && !altKey && !ctrlKey && !metaKey;
63
+ const isTabbing = code === aria.EVENT_CODE.tab && !altKey && !ctrlKey && !metaKey;
64
64
  const currentFocusingEl = document.activeElement;
65
65
  if (isTabbing && currentFocusingEl) {
66
66
  const container = currentTarget;
@@ -1 +1 @@
1
- {"version":3,"file":"focus-trap.js","sources":["../../../../../../packages/components/focus-trap/src/focus-trap.vue"],"sourcesContent":["<template>\n <slot :handle-keydown=\"onKeydown\" />\n</template>\n<script lang=\"ts\">\nimport {\n defineComponent,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n unref,\n watch,\n} from 'vue'\nimport { isNil } from 'lodash-unified'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { useEscapeKeydown } from '@element-plus/hooks'\nimport { isString } from '@element-plus/utils'\nimport {\n createFocusOutPreventedEvent,\n focusFirstDescendant,\n focusableStack,\n getEdges,\n isFocusCausedByUserEvent,\n obtainAllFocusableElements,\n tryFocus,\n useFocusReason,\n} from './utils'\nimport {\n FOCUS_AFTER_RELEASED,\n FOCUS_AFTER_TRAPPED,\n FOCUS_AFTER_TRAPPED_OPTS,\n FOCUS_TRAP_INJECTION_KEY,\n ON_RELEASE_FOCUS_EVT,\n ON_TRAP_FOCUS_EVT,\n} from './tokens'\n\nimport type { PropType } from 'vue'\nimport type { FocusLayer } from './utils'\n\nexport default defineComponent({\n name: 'ElFocusTrap',\n inheritAttrs: false,\n props: {\n loop: Boolean,\n trapped: Boolean,\n focusTrapEl: Object as PropType<HTMLElement>,\n focusStartEl: {\n type: [Object, String] as PropType<'container' | 'first' | HTMLElement>,\n default: 'first',\n },\n },\n emits: [\n ON_TRAP_FOCUS_EVT,\n ON_RELEASE_FOCUS_EVT,\n 'focusin',\n 'focusout',\n 'focusout-prevented',\n 'release-requested',\n ],\n setup(props, { emit }) {\n const forwardRef = ref<HTMLElement | undefined>()\n let lastFocusBeforeTrapped: HTMLElement | null\n let lastFocusAfterTrapped: HTMLElement | null\n\n const { focusReason } = useFocusReason()\n\n useEscapeKeydown((event) => {\n if (props.trapped && !focusLayer.paused) {\n emit('release-requested', event)\n }\n })\n\n const focusLayer: FocusLayer = {\n paused: false,\n pause() {\n this.paused = true\n },\n resume() {\n this.paused = false\n },\n }\n\n const onKeydown = (e: KeyboardEvent) => {\n if (!props.loop && !props.trapped) return\n if (focusLayer.paused) return\n\n const { key, altKey, ctrlKey, metaKey, currentTarget, shiftKey } = e\n const { loop } = props\n const isTabbing =\n key === EVENT_CODE.tab && !altKey && !ctrlKey && !metaKey\n\n const currentFocusingEl = document.activeElement\n if (isTabbing && currentFocusingEl) {\n const container = currentTarget as HTMLElement\n const [first, last] = getEdges(container)\n const isTabbable = first && last\n if (!isTabbable) {\n if (currentFocusingEl === container) {\n const focusoutPreventedEvent = createFocusOutPreventedEvent({\n focusReason: focusReason.value,\n })\n emit('focusout-prevented', focusoutPreventedEvent)\n if (!focusoutPreventedEvent.defaultPrevented) {\n e.preventDefault()\n }\n }\n } else {\n if (!shiftKey && currentFocusingEl === last) {\n const focusoutPreventedEvent = createFocusOutPreventedEvent({\n focusReason: focusReason.value,\n })\n emit('focusout-prevented', focusoutPreventedEvent)\n if (!focusoutPreventedEvent.defaultPrevented) {\n e.preventDefault()\n if (loop) tryFocus(first, true)\n }\n } else if (\n shiftKey &&\n [first, container].includes(currentFocusingEl as HTMLElement)\n ) {\n const focusoutPreventedEvent = createFocusOutPreventedEvent({\n focusReason: focusReason.value,\n })\n emit('focusout-prevented', focusoutPreventedEvent)\n if (!focusoutPreventedEvent.defaultPrevented) {\n e.preventDefault()\n if (loop) tryFocus(last, true)\n }\n }\n }\n }\n }\n\n provide(FOCUS_TRAP_INJECTION_KEY, {\n focusTrapRef: forwardRef,\n onKeydown,\n })\n\n watch(\n () => props.focusTrapEl,\n (focusTrapEl) => {\n if (focusTrapEl) {\n forwardRef.value = focusTrapEl\n }\n },\n { immediate: true }\n )\n\n watch([forwardRef], ([forwardRef], [oldForwardRef]) => {\n if (forwardRef) {\n forwardRef.addEventListener('keydown', onKeydown)\n forwardRef.addEventListener('focusin', onFocusIn)\n forwardRef.addEventListener('focusout', onFocusOut)\n }\n if (oldForwardRef) {\n oldForwardRef.removeEventListener('keydown', onKeydown)\n oldForwardRef.removeEventListener('focusin', onFocusIn)\n oldForwardRef.removeEventListener('focusout', onFocusOut)\n }\n })\n\n const trapOnFocus = (e: Event) => {\n emit(ON_TRAP_FOCUS_EVT, e)\n }\n const releaseOnFocus = (e: Event) => emit(ON_RELEASE_FOCUS_EVT, e)\n\n const onFocusIn = (e: FocusEvent) => {\n const trapContainer = unref(forwardRef)\n if (!trapContainer) return\n\n const target = e.target as HTMLElement | null\n const relatedTarget = e.relatedTarget as HTMLElement | null\n const isFocusedInTrap = target && trapContainer.contains(target)\n\n if (!props.trapped) {\n const isPrevFocusedInTrap =\n relatedTarget && trapContainer.contains(relatedTarget)\n if (!isPrevFocusedInTrap) {\n lastFocusBeforeTrapped = relatedTarget\n }\n }\n\n if (isFocusedInTrap) emit('focusin', e)\n\n if (focusLayer.paused) return\n\n if (props.trapped) {\n if (isFocusedInTrap) {\n lastFocusAfterTrapped = target\n } else {\n tryFocus(lastFocusAfterTrapped, true)\n }\n }\n }\n\n const onFocusOut = (e: Event) => {\n const trapContainer = unref(forwardRef)\n if (focusLayer.paused || !trapContainer) return\n\n if (props.trapped) {\n const relatedTarget = (e as FocusEvent)\n .relatedTarget as HTMLElement | null\n if (!isNil(relatedTarget) && !trapContainer.contains(relatedTarget)) {\n // Give embedded focus layer time to pause this layer before reclaiming focus\n // And only reclaim focus if it should currently be trapping\n setTimeout(() => {\n if (!focusLayer.paused && props.trapped) {\n const focusoutPreventedEvent = createFocusOutPreventedEvent({\n focusReason: focusReason.value,\n })\n emit('focusout-prevented', focusoutPreventedEvent)\n if (!focusoutPreventedEvent.defaultPrevented) {\n tryFocus(lastFocusAfterTrapped, true)\n }\n }\n }, 0)\n }\n } else {\n const target = e.target as HTMLElement | null\n const isFocusedInTrap = target && trapContainer.contains(target)\n if (!isFocusedInTrap) emit('focusout', e)\n }\n }\n\n async function startTrap() {\n // Wait for forwardRef to resolve\n await nextTick()\n const trapContainer = unref(forwardRef)\n if (trapContainer) {\n focusableStack.push(focusLayer)\n const prevFocusedElement = trapContainer.contains(\n document.activeElement\n )\n ? lastFocusBeforeTrapped\n : document.activeElement\n lastFocusBeforeTrapped = prevFocusedElement as HTMLElement | null\n const isPrevFocusContained = trapContainer.contains(prevFocusedElement)\n if (!isPrevFocusContained) {\n const focusEvent = new Event(\n FOCUS_AFTER_TRAPPED,\n FOCUS_AFTER_TRAPPED_OPTS\n )\n trapContainer.addEventListener(FOCUS_AFTER_TRAPPED, trapOnFocus)\n trapContainer.dispatchEvent(focusEvent)\n if (!focusEvent.defaultPrevented) {\n nextTick(() => {\n let focusStartEl = props.focusStartEl\n if (!isString(focusStartEl)) {\n tryFocus(focusStartEl)\n if (document.activeElement !== focusStartEl) {\n focusStartEl = 'first'\n }\n }\n if (focusStartEl === 'first') {\n focusFirstDescendant(\n obtainAllFocusableElements(trapContainer),\n true\n )\n }\n if (\n document.activeElement === prevFocusedElement ||\n focusStartEl === 'container'\n ) {\n tryFocus(trapContainer)\n }\n })\n }\n }\n }\n }\n\n function stopTrap() {\n const trapContainer = unref(forwardRef)\n\n if (trapContainer) {\n trapContainer.removeEventListener(FOCUS_AFTER_TRAPPED, trapOnFocus)\n\n const releasedEvent = new CustomEvent(FOCUS_AFTER_RELEASED, {\n ...FOCUS_AFTER_TRAPPED_OPTS,\n detail: {\n focusReason: focusReason.value,\n },\n })\n trapContainer.addEventListener(FOCUS_AFTER_RELEASED, releaseOnFocus)\n trapContainer.dispatchEvent(releasedEvent)\n if (\n !releasedEvent.defaultPrevented &&\n (focusReason.value == 'keyboard' ||\n !isFocusCausedByUserEvent() ||\n trapContainer.contains(document.activeElement))\n ) {\n tryFocus(lastFocusBeforeTrapped ?? document.body)\n }\n\n trapContainer.removeEventListener(FOCUS_AFTER_RELEASED, releaseOnFocus)\n focusableStack.remove(focusLayer)\n }\n }\n\n onMounted(() => {\n if (props.trapped) {\n startTrap()\n }\n\n watch(\n () => props.trapped,\n (trapped) => {\n if (trapped) {\n startTrap()\n } else {\n stopTrap()\n }\n }\n )\n })\n\n onBeforeUnmount(() => {\n if (props.trapped) {\n stopTrap()\n }\n\n if (forwardRef.value) {\n forwardRef.value.removeEventListener('keydown', onKeydown)\n forwardRef.value.removeEventListener('focusin', onFocusIn)\n forwardRef.value.removeEventListener('focusout', onFocusOut)\n forwardRef.value = undefined\n }\n })\n\n return {\n onKeydown,\n }\n },\n})\n</script>\n"],"names":["defineComponent","ON_TRAP_FOCUS_EVT","ON_RELEASE_FOCUS_EVT","ref","useFocusReason","useEscapeKeydown","EVENT_CODE","getEdges","createFocusOutPreventedEvent","tryFocus","provide","FOCUS_TRAP_INJECTION_KEY","watch","forwardRef","unref","isNil","nextTick","focusableStack","FOCUS_AFTER_TRAPPED","FOCUS_AFTER_TRAPPED_OPTS","isString","focusFirstDescendant","obtainAllFocusableElements","FOCUS_AFTER_RELEASED","isFocusCausedByUserEvent","onMounted","onBeforeUnmount","_renderSlot","_export_sfc"],"mappings":";;;;;;;;;;;;;;;;AAwCA,MAAK,YAAaA,mBAAa,CAAA;AAAA,EAC7B,IAAM,EAAA,aAAA;AAAA,EACN,YAAc,EAAA,KAAA;AAAA,EACd,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,OAAA;AAAA,IACT,WAAa,EAAA,MAAA;AAAA,IACb,YAAc,EAAA;AAAA,MACZ,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,MACrB,OAAS,EAAA,OAAA;AAAA,KACX;AAAA,GACF;AAAA,EACA,KAAO,EAAA;AAAA,IACLC,wBAAA;AAAA,IACAC,2BAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,oBAAA;AAAA,IACA,mBAAA;AAAA,GACF;AAAA,EACA,KAAM,CAAA,KAAA,EAAO,EAAE,IAAA,EAAQ,EAAA;AACrB,IAAA,MAAM,aAAaC,OAA6B,EAAA,CAAA;AAChD,IAAI,IAAA,sBAAA,CAAA;AACJ,IAAI,IAAA,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AAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,aAAA,EAAA,IAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAA,CACF;AAEJ,kBAAC,gBAAAC,iCAAA,CAAA,SAAA,EAAA,CAAA,CAAA,QAAA,EAAA,WAAA,CAAA,EAAA,CAAA,QAAA,EAAA,gBAAA,CAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"focus-trap.js","sources":["../../../../../../packages/components/focus-trap/src/focus-trap.vue"],"sourcesContent":["<template>\n <slot :handle-keydown=\"onKeydown\" />\n</template>\n<script lang=\"ts\">\nimport {\n defineComponent,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n unref,\n watch,\n} from 'vue'\nimport { isNil } from 'lodash-unified'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { useEscapeKeydown } from '@element-plus/hooks'\nimport { isString } from '@element-plus/utils'\nimport {\n createFocusOutPreventedEvent,\n focusFirstDescendant,\n focusableStack,\n getEdges,\n isFocusCausedByUserEvent,\n obtainAllFocusableElements,\n tryFocus,\n useFocusReason,\n} from './utils'\nimport {\n FOCUS_AFTER_RELEASED,\n FOCUS_AFTER_TRAPPED,\n FOCUS_AFTER_TRAPPED_OPTS,\n FOCUS_TRAP_INJECTION_KEY,\n ON_RELEASE_FOCUS_EVT,\n ON_TRAP_FOCUS_EVT,\n} from './tokens'\n\nimport type { PropType } from 'vue'\nimport type { FocusLayer } from './utils'\n\nexport default defineComponent({\n name: 'ElFocusTrap',\n inheritAttrs: false,\n props: {\n loop: Boolean,\n trapped: Boolean,\n focusTrapEl: Object as PropType<HTMLElement>,\n focusStartEl: {\n type: [Object, String] as PropType<'container' | 'first' | HTMLElement>,\n default: 'first',\n },\n },\n emits: [\n ON_TRAP_FOCUS_EVT,\n ON_RELEASE_FOCUS_EVT,\n 'focusin',\n 'focusout',\n 'focusout-prevented',\n 'release-requested',\n ],\n setup(props, { emit }) {\n const forwardRef = ref<HTMLElement | undefined>()\n let lastFocusBeforeTrapped: HTMLElement | null\n let lastFocusAfterTrapped: HTMLElement | null\n\n const { focusReason } = useFocusReason()\n\n useEscapeKeydown((event) => {\n if (props.trapped && !focusLayer.paused) {\n emit('release-requested', event)\n }\n })\n\n const focusLayer: FocusLayer = {\n paused: false,\n pause() {\n this.paused = true\n },\n resume() {\n this.paused = false\n },\n }\n\n const onKeydown = (e: KeyboardEvent) => {\n if (!props.loop && !props.trapped) return\n if (focusLayer.paused) return\n\n const { code, altKey, ctrlKey, metaKey, currentTarget, shiftKey } = e\n const { loop } = props\n const isTabbing =\n code === EVENT_CODE.tab && !altKey && !ctrlKey && !metaKey\n\n const currentFocusingEl = document.activeElement\n if (isTabbing && currentFocusingEl) {\n const container = currentTarget as HTMLElement\n const [first, last] = getEdges(container)\n const isTabbable = first && last\n if (!isTabbable) {\n if (currentFocusingEl === container) {\n const focusoutPreventedEvent = createFocusOutPreventedEvent({\n focusReason: focusReason.value,\n })\n emit('focusout-prevented', focusoutPreventedEvent)\n if (!focusoutPreventedEvent.defaultPrevented) {\n e.preventDefault()\n }\n }\n } else {\n if (!shiftKey && currentFocusingEl === last) {\n const focusoutPreventedEvent = createFocusOutPreventedEvent({\n focusReason: focusReason.value,\n })\n emit('focusout-prevented', focusoutPreventedEvent)\n if (!focusoutPreventedEvent.defaultPrevented) {\n e.preventDefault()\n if (loop) tryFocus(first, true)\n }\n } else if (\n shiftKey &&\n [first, container].includes(currentFocusingEl as HTMLElement)\n ) {\n const focusoutPreventedEvent = createFocusOutPreventedEvent({\n focusReason: focusReason.value,\n })\n emit('focusout-prevented', focusoutPreventedEvent)\n if (!focusoutPreventedEvent.defaultPrevented) {\n e.preventDefault()\n if (loop) tryFocus(last, true)\n }\n }\n }\n }\n }\n\n provide(FOCUS_TRAP_INJECTION_KEY, {\n focusTrapRef: forwardRef,\n onKeydown,\n })\n\n watch(\n () => props.focusTrapEl,\n (focusTrapEl) => {\n if (focusTrapEl) {\n forwardRef.value = focusTrapEl\n }\n },\n { immediate: true }\n )\n\n watch([forwardRef], ([forwardRef], [oldForwardRef]) => {\n if (forwardRef) {\n forwardRef.addEventListener('keydown', onKeydown)\n forwardRef.addEventListener('focusin', onFocusIn)\n forwardRef.addEventListener('focusout', onFocusOut)\n }\n if (oldForwardRef) {\n oldForwardRef.removeEventListener('keydown', onKeydown)\n oldForwardRef.removeEventListener('focusin', onFocusIn)\n oldForwardRef.removeEventListener('focusout', onFocusOut)\n }\n })\n\n const trapOnFocus = (e: Event) => {\n emit(ON_TRAP_FOCUS_EVT, e)\n }\n const releaseOnFocus = (e: Event) => emit(ON_RELEASE_FOCUS_EVT, e)\n\n const onFocusIn = (e: FocusEvent) => {\n const trapContainer = unref(forwardRef)\n if (!trapContainer) return\n\n const target = e.target as HTMLElement | null\n const relatedTarget = e.relatedTarget as HTMLElement | null\n const isFocusedInTrap = target && trapContainer.contains(target)\n\n if (!props.trapped) {\n const isPrevFocusedInTrap =\n relatedTarget && trapContainer.contains(relatedTarget)\n if (!isPrevFocusedInTrap) {\n lastFocusBeforeTrapped = relatedTarget\n }\n }\n\n if (isFocusedInTrap) emit('focusin', e)\n\n if (focusLayer.paused) return\n\n if (props.trapped) {\n if (isFocusedInTrap) {\n lastFocusAfterTrapped = target\n } else {\n tryFocus(lastFocusAfterTrapped, true)\n }\n }\n }\n\n const onFocusOut = (e: Event) => {\n const trapContainer = unref(forwardRef)\n if (focusLayer.paused || !trapContainer) return\n\n if (props.trapped) {\n const relatedTarget = (e as FocusEvent)\n .relatedTarget as HTMLElement | null\n if (!isNil(relatedTarget) && !trapContainer.contains(relatedTarget)) {\n // Give embedded focus layer time to pause this layer before reclaiming focus\n // And only reclaim focus if it should currently be trapping\n setTimeout(() => {\n if (!focusLayer.paused && props.trapped) {\n const focusoutPreventedEvent = createFocusOutPreventedEvent({\n focusReason: focusReason.value,\n })\n emit('focusout-prevented', focusoutPreventedEvent)\n if (!focusoutPreventedEvent.defaultPrevented) {\n tryFocus(lastFocusAfterTrapped, true)\n }\n }\n }, 0)\n }\n } else {\n const target = e.target as HTMLElement | null\n const isFocusedInTrap = target && trapContainer.contains(target)\n if (!isFocusedInTrap) emit('focusout', e)\n }\n }\n\n async function startTrap() {\n // Wait for forwardRef to resolve\n await nextTick()\n const trapContainer = unref(forwardRef)\n if (trapContainer) {\n focusableStack.push(focusLayer)\n const prevFocusedElement = trapContainer.contains(\n document.activeElement\n )\n ? lastFocusBeforeTrapped\n : document.activeElement\n lastFocusBeforeTrapped = prevFocusedElement as HTMLElement | null\n const isPrevFocusContained = trapContainer.contains(prevFocusedElement)\n if (!isPrevFocusContained) {\n const focusEvent = new Event(\n FOCUS_AFTER_TRAPPED,\n FOCUS_AFTER_TRAPPED_OPTS\n )\n trapContainer.addEventListener(FOCUS_AFTER_TRAPPED, trapOnFocus)\n trapContainer.dispatchEvent(focusEvent)\n if (!focusEvent.defaultPrevented) {\n nextTick(() => {\n let focusStartEl = props.focusStartEl\n if (!isString(focusStartEl)) {\n tryFocus(focusStartEl)\n if (document.activeElement !== focusStartEl) {\n focusStartEl = 'first'\n }\n }\n if (focusStartEl === 'first') {\n focusFirstDescendant(\n obtainAllFocusableElements(trapContainer),\n true\n )\n }\n if (\n document.activeElement === prevFocusedElement ||\n focusStartEl === 'container'\n ) {\n tryFocus(trapContainer)\n }\n })\n }\n }\n }\n }\n\n function stopTrap() {\n const trapContainer = unref(forwardRef)\n\n if (trapContainer) {\n trapContainer.removeEventListener(FOCUS_AFTER_TRAPPED, trapOnFocus)\n\n const releasedEvent = new CustomEvent(FOCUS_AFTER_RELEASED, {\n ...FOCUS_AFTER_TRAPPED_OPTS,\n detail: {\n focusReason: focusReason.value,\n },\n })\n trapContainer.addEventListener(FOCUS_AFTER_RELEASED, releaseOnFocus)\n trapContainer.dispatchEvent(releasedEvent)\n if (\n !releasedEvent.defaultPrevented &&\n (focusReason.value == 'keyboard' ||\n !isFocusCausedByUserEvent() ||\n trapContainer.contains(document.activeElement))\n ) {\n tryFocus(lastFocusBeforeTrapped ?? document.body)\n }\n\n trapContainer.removeEventListener(FOCUS_AFTER_RELEASED, releaseOnFocus)\n focusableStack.remove(focusLayer)\n }\n }\n\n onMounted(() => {\n if (props.trapped) {\n startTrap()\n }\n\n watch(\n () => props.trapped,\n (trapped) => {\n if (trapped) {\n startTrap()\n } else {\n stopTrap()\n }\n }\n )\n })\n\n onBeforeUnmount(() => {\n if (props.trapped) {\n stopTrap()\n }\n\n if (forwardRef.value) {\n forwardRef.value.removeEventListener('keydown', onKeydown)\n forwardRef.value.removeEventListener('focusin', onFocusIn)\n forwardRef.value.removeEventListener('focusout', onFocusOut)\n forwardRef.value = undefined\n }\n })\n\n return {\n onKeydown,\n }\n },\n})\n</script>\n"],"names":["defineComponent","ON_TRAP_FOCUS_EVT","ON_RELEASE_FOCUS_EVT","ref","useFocusReason","useEscapeKeydown","EVENT_CODE","getEdges","createFocusOutPreventedEvent","tryFocus","provide","FOCUS_TRAP_INJECTION_KEY","watch","forwardRef","unref","isNil","nextTick","focusableStack","FOCUS_AFTER_TRAPPED","FOCUS_AFTER_TRAPPED_OPTS","isString","focusFirstDescendant","obtainAllFocusableElements","FOCUS_AFTER_RELEASED","isFocusCausedByUserEvent","onMounted","onBeforeUnmount","_renderSlot","_export_sfc"],"mappings":";;;;;;;;;;;;;;;;AAwCA,MAAK,YAAaA,mBAAa,CAAA;AAAA,EAC7B,IAAM,EAAA,aAAA;AAAA,EACN,YAAc,EAAA,KAAA;AAAA,EACd,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,OAAA;AAAA,IACT,WAAa,EAAA,MAAA;AAAA,IACb,YAAc,EAAA;AAAA,MACZ,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,MACrB,OAAS,EAAA,OAAA;AAAA,KACX;AAAA,GACF;AAAA,EACA,KAAO,EAAA;AAAA,IACLC,wBAAA;AAAA,IACAC,2BAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;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,OAAA;AACX,MAAW,SAAA;AACX,KAAW,CAAA;AACX,GAAA;AAAmB,CACrB,CAAA,CAAA;AAGF,SAAO,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA;AAAA,EACL,OAAAC,cAAA,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,aAAA,EAAA,IAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAA,CACF;AAEJ,kBAAC,gBAAAC,iCAAA,CAAA,SAAA,EAAA,CAAA,CAAA,QAAA,EAAA,WAAA,CAAA,EAAA,CAAA,QAAA,EAAA,gBAAA,CAAA,CAAA,CAAA;;;;"}
@@ -98,9 +98,9 @@ var constants$1 = require('./button/src/constants.js');
98
98
  var calendar = require('./calendar/src/calendar.js');
99
99
  var card = require('./card/src/card.js');
100
100
  var carousel = require('./carousel/src/carousel.js');
101
- var carouselItem = require('./carousel/src/carousel-item2.js');
101
+ var carouselItem = require('./carousel/src/carousel-item.js');
102
102
  var constants$2 = require('./carousel/src/constants.js');
103
- var cascader = require('./cascader/src/cascader2.js');
103
+ var cascader = require('./cascader/src/cascader.js');
104
104
  var types = require('./cascader-panel/src/types.js');
105
105
  var config = require('./cascader-panel/src/config.js');
106
106
  var checkTag = require('./check-tag/src/check-tag.js');
@@ -108,7 +108,7 @@ var checkboxGroup = require('./checkbox/src/checkbox-group.js');
108
108
  var checkbox = require('./checkbox/src/checkbox.js');
109
109
  var constants$3 = require('./checkbox/src/constants.js');
110
110
  var col = require('./col/src/col.js');
111
- var collapse = require('./collapse/src/collapse2.js');
111
+ var collapse = require('./collapse/src/collapse.js');
112
112
  var collapseItem = require('./collapse/src/collapse-item.js');
113
113
  var constants$4 = require('./collapse/src/constants.js');
114
114
  var colorPicker = require('./color-picker/src/color-picker.js');
@@ -167,7 +167,7 @@ var result = require('./result/src/result.js');
167
167
  var row = require('./row/src/row.js');
168
168
  var constants$c = require('./row/src/constants.js');
169
169
  var util = require('./scrollbar/src/util.js');
170
- var scrollbar = require('./scrollbar/src/scrollbar2.js');
170
+ var scrollbar = require('./scrollbar/src/scrollbar.js');
171
171
  var thumb = require('./scrollbar/src/thumb.js');
172
172
  var constants$d = require('./scrollbar/src/constants.js');
173
173
  var token = require('./select/src/token.js');
@@ -223,7 +223,7 @@ var tour = require('./tour/src/tour.js');
223
223
  var step = require('./tour/src/step.js');
224
224
  var content$3 = require('./tour/src/content.js');
225
225
  var anchor = require('./anchor/src/anchor.js');
226
- var segmented = require('./segmented/src/segmented2.js');
226
+ var segmented = require('./segmented/src/segmented.js');
227
227
  var mention = require('./mention/src/mention.js');
228
228
  var directive = require('./loading/src/directive.js');
229
229
  var service = require('./loading/src/service.js');
@@ -18,6 +18,7 @@ var input = require('../../input/src/input.js');
18
18
  var index = require('../../../hooks/use-namespace/index.js');
19
19
  var useFormCommonProps = require('../../form/src/hooks/use-form-common-props.js');
20
20
  var index$1 = require('../../../hooks/use-id/index.js');
21
+ var aria = require('../../../constants/aria.js');
21
22
  var shared = require('@vue/shared');
22
23
  var event = require('../../../constants/event.js');
23
24
  var index$2 = require('../../../hooks/use-focus-controller/index.js');
@@ -61,55 +62,60 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
61
62
  emit("update:modelValue", value);
62
63
  syncAfterCursorMove();
63
64
  };
64
- const handleInputKeyDown = (e) => {
65
+ const handleInputKeyDown = (event$1) => {
65
66
  var _a, _b, _c, _d;
66
- if (!("key" in e))
67
+ if (!("code" in event$1) || ((_a = elInputRef.value) == null ? void 0 : _a.isComposing))
67
68
  return;
68
- if ((_a = elInputRef.value) == null ? void 0 : _a.isComposing)
69
- return;
70
- if (["ArrowLeft", "ArrowRight"].includes(e.key)) {
71
- syncAfterCursorMove();
72
- } else if (["ArrowUp", "ArrowDown"].includes(e.key)) {
73
- if (!visible.value)
74
- return;
75
- e.preventDefault();
76
- const direction = e.key === "ArrowUp" ? "prev" : "next";
77
- (_b = dropdownRef.value) == null ? void 0 : _b.navigateOptions(direction);
78
- } else if (["Enter"].includes(e.key)) {
79
- if (!visible.value)
80
- return;
81
- e.preventDefault();
82
- if ((_c = dropdownRef.value) == null ? void 0 : _c.hoverOption) {
83
- (_d = dropdownRef.value) == null ? void 0 : _d.selectHoverOption();
84
- } else {
85
- visible.value = false;
86
- }
87
- } else if (["Escape"].includes(e.key)) {
88
- if (!visible.value)
89
- return;
90
- e.preventDefault();
91
- visible.value = false;
92
- } else if (["Backspace"].includes(e.key)) {
93
- if (props.whole && mentionCtx.value) {
94
- const { splitIndex, selectionEnd, pattern, prefixIndex, prefix } = mentionCtx.value;
95
- const inputEl = getInputEl();
96
- if (!inputEl)
69
+ switch (event$1.code) {
70
+ case aria.EVENT_CODE.left:
71
+ case aria.EVENT_CODE.right:
72
+ syncAfterCursorMove();
73
+ break;
74
+ case aria.EVENT_CODE.up:
75
+ case aria.EVENT_CODE.down:
76
+ if (!visible.value)
97
77
  return;
98
- const inputValue = inputEl.value;
99
- const matchOption = props.options.find((item) => item.value === pattern);
100
- const isWhole = shared.isFunction(props.checkIsWhole) ? props.checkIsWhole(pattern, prefix) : matchOption;
101
- if (isWhole && splitIndex !== -1 && splitIndex + 1 === selectionEnd) {
102
- e.preventDefault();
103
- const newValue = inputValue.slice(0, prefixIndex) + inputValue.slice(splitIndex + 1);
104
- emit(event.UPDATE_MODEL_EVENT, newValue);
105
- const newSelectionEnd = prefixIndex;
106
- vue.nextTick(() => {
107
- inputEl.selectionStart = newSelectionEnd;
108
- inputEl.selectionEnd = newSelectionEnd;
109
- syncDropdownVisible();
110
- });
78
+ event$1.preventDefault();
79
+ (_b = dropdownRef.value) == null ? void 0 : _b.navigateOptions(event$1.code === aria.EVENT_CODE.up ? "prev" : "next");
80
+ break;
81
+ case aria.EVENT_CODE.enter:
82
+ case aria.EVENT_CODE.numpadEnter:
83
+ if (!visible.value)
84
+ return;
85
+ event$1.preventDefault();
86
+ if ((_c = dropdownRef.value) == null ? void 0 : _c.hoverOption) {
87
+ (_d = dropdownRef.value) == null ? void 0 : _d.selectHoverOption();
88
+ } else {
89
+ visible.value = false;
90
+ }
91
+ break;
92
+ case aria.EVENT_CODE.esc:
93
+ if (!visible.value)
94
+ return;
95
+ event$1.preventDefault();
96
+ visible.value = false;
97
+ break;
98
+ case aria.EVENT_CODE.backspace:
99
+ if (props.whole && mentionCtx.value) {
100
+ const { splitIndex, selectionEnd, pattern, prefixIndex, prefix } = mentionCtx.value;
101
+ const inputEl = getInputEl();
102
+ if (!inputEl)
103
+ return;
104
+ const inputValue = inputEl.value;
105
+ const matchOption = props.options.find((item) => item.value === pattern);
106
+ const isWhole = shared.isFunction(props.checkIsWhole) ? props.checkIsWhole(pattern, prefix) : matchOption;
107
+ if (isWhole && splitIndex !== -1 && splitIndex + 1 === selectionEnd) {
108
+ event$1.preventDefault();
109
+ const newValue = inputValue.slice(0, prefixIndex) + inputValue.slice(splitIndex + 1);
110
+ emit(event.UPDATE_MODEL_EVENT, newValue);
111
+ const newSelectionEnd = prefixIndex;
112
+ vue.nextTick(() => {
113
+ inputEl.selectionStart = newSelectionEnd;
114
+ inputEl.selectionEnd = newSelectionEnd;
115
+ syncDropdownVisible();
116
+ });
117
+ }
111
118
  }
112
- }
113
119
  }
114
120
  };
115
121
  const { wrapperRef } = index$2.useFocusController(elInputRef, {
@@ -1 +1 @@
1
- {"version":3,"file":"mention2.js","sources":["../../../../../../packages/components/mention/src/mention.vue"],"sourcesContent":["<template>\n <div ref=\"wrapperRef\" :class=\"ns.b()\">\n <el-input\n v-bind=\"mergeProps(passInputProps, $attrs)\"\n ref=\"elInputRef\"\n :model-value=\"modelValue\"\n :disabled=\"disabled\"\n :role=\"dropdownVisible ? 'combobox' : undefined\"\n :aria-activedescendant=\"dropdownVisible ? hoveringId || '' : undefined\"\n :aria-controls=\"dropdownVisible ? contentId : undefined\"\n :aria-expanded=\"dropdownVisible || undefined\"\n :aria-label=\"ariaLabel\"\n :aria-autocomplete=\"dropdownVisible ? 'none' : undefined\"\n :aria-haspopup=\"dropdownVisible ? 'listbox' : undefined\"\n @input=\"handleInputChange\"\n @keydown=\"handleInputKeyDown\"\n @mousedown=\"handleInputMouseDown\"\n >\n <template v-for=\"(_, name) in $slots\" #[name]=\"slotProps\">\n <slot :name=\"name\" v-bind=\"slotProps\" />\n </template>\n </el-input>\n <el-tooltip\n ref=\"tooltipRef\"\n :visible=\"dropdownVisible\"\n :popper-class=\"[ns.e('popper'), popperClass]\"\n :popper-options=\"popperOptions\"\n :placement=\"computedPlacement\"\n :fallback-placements=\"computedFallbackPlacements\"\n effect=\"light\"\n pure\n :offset=\"offset\"\n :show-arrow=\"showArrow\"\n >\n <template #default>\n <div :style=\"cursorStyle\" />\n </template>\n <template #content>\n <el-mention-dropdown\n ref=\"dropdownRef\"\n :options=\"filteredOptions\"\n :disabled=\"disabled\"\n :loading=\"loading\"\n :content-id=\"contentId\"\n :aria-label=\"ariaLabel\"\n @select=\"handleSelect\"\n @click.stop=\"elInputRef?.focus\"\n >\n <template v-for=\"(_, name) in $slots\" #[name]=\"slotProps\">\n <slot :name=\"name\" v-bind=\"slotProps\" />\n </template>\n </el-mention-dropdown>\n </template>\n </el-tooltip>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, mergeProps, nextTick, ref } from 'vue'\nimport { pick } from 'lodash-unified'\nimport { useFocusController, useId, useNamespace } from '@element-plus/hooks'\nimport ElInput, { inputProps } from '@element-plus/components/input'\nimport ElTooltip from '@element-plus/components/tooltip'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { useFormDisabled } from '@element-plus/components/form'\nimport { isFunction } from '@element-plus/utils'\nimport { mentionEmits, mentionProps } from './mention'\nimport { getCursorPosition, getMentionCtx } from './helper'\nimport ElMentionDropdown from './mention-dropdown.vue'\n\nimport type { Placement } from '@popperjs/core'\nimport type { CSSProperties } from 'vue'\nimport type { InputInstance } from '@element-plus/components/input'\nimport type { TooltipInstance } from '@element-plus/components/tooltip'\nimport type { MentionCtx, MentionOption } from './types'\n\ndefineOptions({\n name: 'ElMention',\n inheritAttrs: false,\n})\n\nconst props = defineProps(mentionProps)\nconst emit = defineEmits(mentionEmits)\n\nconst passInputProps = computed(() => pick(props, Object.keys(inputProps)))\n\nconst ns = useNamespace('mention')\nconst disabled = useFormDisabled()\nconst contentId = useId()\n\nconst elInputRef = ref<InputInstance>()\nconst tooltipRef = ref<TooltipInstance>()\nconst dropdownRef = ref<InstanceType<typeof ElMentionDropdown>>()\n\nconst visible = ref(false)\nconst cursorStyle = ref<CSSProperties>()\nconst mentionCtx = ref<MentionCtx>()\n\nconst computedPlacement = computed<Placement>(() =>\n props.showArrow ? props.placement : `${props.placement}-start`\n)\n\nconst computedFallbackPlacements = computed<Placement[]>(() =>\n props.showArrow ? ['bottom', 'top'] : ['bottom-start', 'top-start']\n)\n\nconst filteredOptions = computed(() => {\n const { filterOption, options } = props\n if (!mentionCtx.value || !filterOption) return options\n return options.filter((option) =>\n filterOption(mentionCtx.value!.pattern, option)\n )\n})\n\nconst dropdownVisible = computed(() => {\n return visible.value && (!!filteredOptions.value.length || props.loading)\n})\n\nconst hoveringId = computed(() => {\n return `${contentId.value}-${dropdownRef.value?.hoveringIndex}`\n})\n\nconst handleInputChange = (value: string) => {\n emit('update:modelValue', value)\n syncAfterCursorMove()\n}\n\nconst handleInputKeyDown = (e: KeyboardEvent | Event) => {\n if (!('key' in e)) return\n if (elInputRef.value?.isComposing) return\n if (['ArrowLeft', 'ArrowRight'].includes(e.key)) {\n syncAfterCursorMove()\n } else if (['ArrowUp', 'ArrowDown'].includes(e.key)) {\n if (!visible.value) return\n e.preventDefault()\n const direction = e.key === 'ArrowUp' ? 'prev' : 'next'\n dropdownRef.value?.navigateOptions(direction)\n } else if (['Enter'].includes(e.key)) {\n if (!visible.value) return\n e.preventDefault()\n if (dropdownRef.value?.hoverOption) {\n dropdownRef.value?.selectHoverOption()\n } else {\n visible.value = false\n }\n } else if (['Escape'].includes(e.key)) {\n if (!visible.value) return\n e.preventDefault()\n visible.value = false\n } else if (['Backspace'].includes(e.key)) {\n if (props.whole && mentionCtx.value) {\n const { splitIndex, selectionEnd, pattern, prefixIndex, prefix } =\n mentionCtx.value\n const inputEl = getInputEl()\n if (!inputEl) return\n const inputValue = inputEl.value\n const matchOption = props.options.find((item) => item.value === pattern)\n const isWhole = isFunction(props.checkIsWhole)\n ? props.checkIsWhole(pattern, prefix)\n : matchOption\n if (isWhole && splitIndex !== -1 && splitIndex + 1 === selectionEnd) {\n e.preventDefault()\n const newValue =\n inputValue.slice(0, prefixIndex) + inputValue.slice(splitIndex + 1)\n emit(UPDATE_MODEL_EVENT, newValue)\n\n const newSelectionEnd = prefixIndex\n nextTick(() => {\n // input value is updated\n inputEl.selectionStart = newSelectionEnd\n inputEl.selectionEnd = newSelectionEnd\n syncDropdownVisible()\n })\n }\n }\n }\n}\n\nconst { wrapperRef } = useFocusController(elInputRef, {\n beforeFocus() {\n return disabled.value\n },\n afterFocus() {\n syncAfterCursorMove()\n },\n beforeBlur(event) {\n return tooltipRef.value?.isFocusInsideContent(event)\n },\n afterBlur() {\n visible.value = false\n },\n})\n\nconst handleInputMouseDown = () => {\n syncAfterCursorMove()\n}\n\nconst handleSelect = (item: MentionOption) => {\n if (!mentionCtx.value) return\n const inputEl = getInputEl()\n if (!inputEl) return\n const inputValue = inputEl.value\n const { split } = props\n\n const newEndPart = inputValue.slice(mentionCtx.value.end)\n const alreadySeparated = newEndPart.startsWith(split)\n const newMiddlePart = `${item.value}${alreadySeparated ? '' : split}`\n\n const newValue =\n inputValue.slice(0, mentionCtx.value.start) + newMiddlePart + newEndPart\n\n emit(UPDATE_MODEL_EVENT, newValue)\n emit('select', item, mentionCtx.value.prefix)\n\n const newSelectionEnd =\n mentionCtx.value.start + newMiddlePart.length + (alreadySeparated ? 1 : 0)\n\n nextTick(() => {\n // input value is updated\n inputEl.selectionStart = newSelectionEnd\n inputEl.selectionEnd = newSelectionEnd\n inputEl.focus()\n syncDropdownVisible()\n })\n}\n\nconst getInputEl = () =>\n props.type === 'textarea'\n ? elInputRef.value?.textarea\n : elInputRef.value?.input\n\nconst syncAfterCursorMove = () => {\n // can't use nextTick(), get cursor position will be wrong\n setTimeout(() => {\n syncCursor()\n syncDropdownVisible()\n nextTick(() => tooltipRef.value?.updatePopper())\n }, 0)\n}\n\nconst syncCursor = () => {\n const inputEl = getInputEl()\n if (!inputEl) return\n\n const caretPosition = getCursorPosition(inputEl)\n const inputRect = inputEl.getBoundingClientRect()\n const elInputRect = elInputRef.value!.$el.getBoundingClientRect()\n\n cursorStyle.value = {\n position: 'absolute',\n width: 0,\n height: `${caretPosition.height}px`,\n left: `${caretPosition.left + inputRect.left - elInputRect.left}px`,\n top: `${caretPosition.top + inputRect.top - elInputRect.top}px`,\n }\n}\n\nconst syncDropdownVisible = () => {\n const inputEl = getInputEl()\n if (document.activeElement !== inputEl) {\n visible.value = false\n return\n }\n const { prefix, split } = props\n mentionCtx.value = getMentionCtx(inputEl, prefix, split)\n if (mentionCtx.value && mentionCtx.value.splitIndex === -1) {\n visible.value = true\n emit('search', mentionCtx.value.pattern, mentionCtx.value.prefix)\n return\n }\n visible.value = false\n}\n\ndefineExpose({\n input: elInputRef,\n tooltip: tooltipRef,\n dropdownVisible,\n})\n</script>\n"],"names":["computed","pick","inputProps","useNamespace","useFormDisabled","useId","ref","isFunction","UPDATE_MODEL_EVENT","nextTick","useFocusController"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;uCA4Ec,CAAA;AAAA,EACZ,IAAM,EAAA,WAAA;AAAA,EACN,YAAc,EAAA,KAAA;AAChB,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAM,MAAA,cAAA,GAAiBA,aAAS,MAAMC,kBAAA,CAAK,OAAO,MAAO,CAAA,IAAA,CAAKC,gBAAU,CAAC,CAAC,CAAA,CAAA;AAE1E,IAAM,MAAA,EAAA,GAAKC,mBAAa,SAAS,CAAA,CAAA;AACjC,IAAA,MAAM,WAAWC,kCAAgB,EAA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AA,EAAA,CAAA;AAChE,OAAA,CAAA;AAAA,KACF,CAAA;AACA,IAAA,MAAA,mBAAgB,GAAA,MAAA;AAAA,MAClB,MAAA,OAAA,GAAA,UAAA,EAAA,CAAA;AAEA,MAAa,IAAA,QAAA,CAAA,aAAA,KAAA,OAAA,EAAA;AAAA,QACJ,OAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AAAA,QACE,OAAA;AAAA,OACT;AAAA,MACD,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,GAAA,KAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"mention2.js","sources":["../../../../../../packages/components/mention/src/mention.vue"],"sourcesContent":["<template>\n <div ref=\"wrapperRef\" :class=\"ns.b()\">\n <el-input\n v-bind=\"mergeProps(passInputProps, $attrs)\"\n ref=\"elInputRef\"\n :model-value=\"modelValue\"\n :disabled=\"disabled\"\n :role=\"dropdownVisible ? 'combobox' : undefined\"\n :aria-activedescendant=\"dropdownVisible ? hoveringId || '' : undefined\"\n :aria-controls=\"dropdownVisible ? contentId : undefined\"\n :aria-expanded=\"dropdownVisible || undefined\"\n :aria-label=\"ariaLabel\"\n :aria-autocomplete=\"dropdownVisible ? 'none' : undefined\"\n :aria-haspopup=\"dropdownVisible ? 'listbox' : undefined\"\n @input=\"handleInputChange\"\n @keydown=\"handleInputKeyDown\"\n @mousedown=\"handleInputMouseDown\"\n >\n <template v-for=\"(_, name) in $slots\" #[name]=\"slotProps\">\n <slot :name=\"name\" v-bind=\"slotProps\" />\n </template>\n </el-input>\n <el-tooltip\n ref=\"tooltipRef\"\n :visible=\"dropdownVisible\"\n :popper-class=\"[ns.e('popper'), popperClass]\"\n :popper-options=\"popperOptions\"\n :placement=\"computedPlacement\"\n :fallback-placements=\"computedFallbackPlacements\"\n effect=\"light\"\n pure\n :offset=\"offset\"\n :show-arrow=\"showArrow\"\n >\n <template #default>\n <div :style=\"cursorStyle\" />\n </template>\n <template #content>\n <el-mention-dropdown\n ref=\"dropdownRef\"\n :options=\"filteredOptions\"\n :disabled=\"disabled\"\n :loading=\"loading\"\n :content-id=\"contentId\"\n :aria-label=\"ariaLabel\"\n @select=\"handleSelect\"\n @click.stop=\"elInputRef?.focus\"\n >\n <template v-for=\"(_, name) in $slots\" #[name]=\"slotProps\">\n <slot :name=\"name\" v-bind=\"slotProps\" />\n </template>\n </el-mention-dropdown>\n </template>\n </el-tooltip>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, mergeProps, nextTick, ref } from 'vue'\nimport { pick } from 'lodash-unified'\nimport { useFocusController, useId, useNamespace } from '@element-plus/hooks'\nimport ElInput, { inputProps } from '@element-plus/components/input'\nimport ElTooltip from '@element-plus/components/tooltip'\nimport { EVENT_CODE, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { useFormDisabled } from '@element-plus/components/form'\nimport { isFunction } from '@element-plus/utils'\nimport { mentionEmits, mentionProps } from './mention'\nimport { getCursorPosition, getMentionCtx } from './helper'\nimport ElMentionDropdown from './mention-dropdown.vue'\n\nimport type { Placement } from '@popperjs/core'\nimport type { CSSProperties } from 'vue'\nimport type { InputInstance } from '@element-plus/components/input'\nimport type { TooltipInstance } from '@element-plus/components/tooltip'\nimport type { MentionCtx, MentionOption } from './types'\n\ndefineOptions({\n name: 'ElMention',\n inheritAttrs: false,\n})\n\nconst props = defineProps(mentionProps)\nconst emit = defineEmits(mentionEmits)\n\nconst passInputProps = computed(() => pick(props, Object.keys(inputProps)))\n\nconst ns = useNamespace('mention')\nconst disabled = useFormDisabled()\nconst contentId = useId()\n\nconst elInputRef = ref<InputInstance>()\nconst tooltipRef = ref<TooltipInstance>()\nconst dropdownRef = ref<InstanceType<typeof ElMentionDropdown>>()\n\nconst visible = ref(false)\nconst cursorStyle = ref<CSSProperties>()\nconst mentionCtx = ref<MentionCtx>()\n\nconst computedPlacement = computed<Placement>(() =>\n props.showArrow ? props.placement : `${props.placement}-start`\n)\n\nconst computedFallbackPlacements = computed<Placement[]>(() =>\n props.showArrow ? ['bottom', 'top'] : ['bottom-start', 'top-start']\n)\n\nconst filteredOptions = computed(() => {\n const { filterOption, options } = props\n if (!mentionCtx.value || !filterOption) return options\n return options.filter((option) =>\n filterOption(mentionCtx.value!.pattern, option)\n )\n})\n\nconst dropdownVisible = computed(() => {\n return visible.value && (!!filteredOptions.value.length || props.loading)\n})\n\nconst hoveringId = computed(() => {\n return `${contentId.value}-${dropdownRef.value?.hoveringIndex}`\n})\n\nconst handleInputChange = (value: string) => {\n emit('update:modelValue', value)\n syncAfterCursorMove()\n}\n\nconst handleInputKeyDown = (event: KeyboardEvent | Event) => {\n if (!('code' in event) || elInputRef.value?.isComposing) return\n\n switch (event.code) {\n case EVENT_CODE.left:\n case EVENT_CODE.right:\n syncAfterCursorMove()\n break\n case EVENT_CODE.up:\n case EVENT_CODE.down:\n if (!visible.value) return\n event.preventDefault()\n dropdownRef.value?.navigateOptions(\n event.code === EVENT_CODE.up ? 'prev' : 'next'\n )\n break\n case EVENT_CODE.enter:\n case EVENT_CODE.numpadEnter:\n if (!visible.value) return\n event.preventDefault()\n if (dropdownRef.value?.hoverOption) {\n dropdownRef.value?.selectHoverOption()\n } else {\n visible.value = false\n }\n break\n case EVENT_CODE.esc:\n if (!visible.value) return\n event.preventDefault()\n visible.value = false\n break\n case EVENT_CODE.backspace:\n if (props.whole && mentionCtx.value) {\n const { splitIndex, selectionEnd, pattern, prefixIndex, prefix } =\n mentionCtx.value\n const inputEl = getInputEl()\n if (!inputEl) return\n const inputValue = inputEl.value\n const matchOption = props.options.find((item) => item.value === pattern)\n const isWhole = isFunction(props.checkIsWhole)\n ? props.checkIsWhole(pattern, prefix)\n : matchOption\n if (isWhole && splitIndex !== -1 && splitIndex + 1 === selectionEnd) {\n event.preventDefault()\n const newValue =\n inputValue.slice(0, prefixIndex) + inputValue.slice(splitIndex + 1)\n emit(UPDATE_MODEL_EVENT, newValue)\n\n const newSelectionEnd = prefixIndex\n nextTick(() => {\n // input value is updated\n inputEl.selectionStart = newSelectionEnd\n inputEl.selectionEnd = newSelectionEnd\n syncDropdownVisible()\n })\n }\n }\n }\n}\n\nconst { wrapperRef } = useFocusController(elInputRef, {\n beforeFocus() {\n return disabled.value\n },\n afterFocus() {\n syncAfterCursorMove()\n },\n beforeBlur(event) {\n return tooltipRef.value?.isFocusInsideContent(event)\n },\n afterBlur() {\n visible.value = false\n },\n})\n\nconst handleInputMouseDown = () => {\n syncAfterCursorMove()\n}\n\nconst handleSelect = (item: MentionOption) => {\n if (!mentionCtx.value) return\n const inputEl = getInputEl()\n if (!inputEl) return\n const inputValue = inputEl.value\n const { split } = props\n\n const newEndPart = inputValue.slice(mentionCtx.value.end)\n const alreadySeparated = newEndPart.startsWith(split)\n const newMiddlePart = `${item.value}${alreadySeparated ? '' : split}`\n\n const newValue =\n inputValue.slice(0, mentionCtx.value.start) + newMiddlePart + newEndPart\n\n emit(UPDATE_MODEL_EVENT, newValue)\n emit('select', item, mentionCtx.value.prefix)\n\n const newSelectionEnd =\n mentionCtx.value.start + newMiddlePart.length + (alreadySeparated ? 1 : 0)\n\n nextTick(() => {\n // input value is updated\n inputEl.selectionStart = newSelectionEnd\n inputEl.selectionEnd = newSelectionEnd\n inputEl.focus()\n syncDropdownVisible()\n })\n}\n\nconst getInputEl = () =>\n props.type === 'textarea'\n ? elInputRef.value?.textarea\n : elInputRef.value?.input\n\nconst syncAfterCursorMove = () => {\n // can't use nextTick(), get cursor position will be wrong\n setTimeout(() => {\n syncCursor()\n syncDropdownVisible()\n nextTick(() => tooltipRef.value?.updatePopper())\n }, 0)\n}\n\nconst syncCursor = () => {\n const inputEl = getInputEl()\n if (!inputEl) return\n\n const caretPosition = getCursorPosition(inputEl)\n const inputRect = inputEl.getBoundingClientRect()\n const elInputRect = elInputRef.value!.$el.getBoundingClientRect()\n\n cursorStyle.value = {\n position: 'absolute',\n width: 0,\n height: `${caretPosition.height}px`,\n left: `${caretPosition.left + inputRect.left - elInputRect.left}px`,\n top: `${caretPosition.top + inputRect.top - elInputRect.top}px`,\n }\n}\n\nconst syncDropdownVisible = () => {\n const inputEl = getInputEl()\n if (document.activeElement !== inputEl) {\n visible.value = false\n return\n }\n const { prefix, split } = props\n mentionCtx.value = getMentionCtx(inputEl, prefix, split)\n if (mentionCtx.value && mentionCtx.value.splitIndex === -1) {\n visible.value = true\n emit('search', mentionCtx.value.pattern, mentionCtx.value.prefix)\n return\n }\n visible.value = false\n}\n\ndefineExpose({\n input: elInputRef,\n tooltip: tooltipRef,\n dropdownVisible,\n})\n</script>\n"],"names":["computed","pick","inputProps","useNamespace","useFormDisabled","useId","ref","event","EVENT_CODE","isFunction","UPDATE_MODEL_EVENT","nextTick","useFocusController","getCursorPosition","getMentionCtx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;uCA4Ec,CAAA;AAAA,EACZ,IAAM,EAAA,WAAA;AAAA,EACN,YAAc,EAAA,KAAA;AAChB,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAM,MAAA,cAAA,GAAiBA,aAAS,MAAMC,kBAAA,CAAK,OAAO,MAAO,CAAA,IAAA,CAAKC,gBAAU,CAAC,CAAC,CAAA,CAAA;AAE1E,IAAM,MAAA,EAAA,GAAKC,mBAAa,SAAS,CAAA,CAAA;AACjC,IAAA,MAAM,WAAWC,kCAAgB,EAAA,CAAA;AACjC,IAAA,MAAM,YAAYC,aAAM,EAAA,CAAA;AAExB,IAAA,MAAM,aAAaC,OAAmB,EAAA,CAAA;AACtC,IAAA,MAAM,aAAaA,OAAqB,EAAA,CAAA;AACxC,IAAA,MAAM,cAAcA,OAA4C,EAAA,CAAA;AAEhE,IAAM,MAAA,OAAA,GAAUA,QAAI,KAAK,CAAA,CAAA;AACzB,IAAA,MAAM,cAAcA,OAAmB,EAAA,CAAA;AACvC,IAAA,MAAM,aAAaA,OAAgB,EAAA,C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EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAAA,MACT,IAAA,UAAA,CAAA,KAAA,IAAA,UAAA,CAAA,KAAA,CAAA,UAAA,KAAA,CAAA,CAAA,EAAA;AAAA,QACD,OAAA,CAAA,KAAA,GAAA,IAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -44,6 +44,7 @@ class MenuItem {
44
44
  break;
45
45
  }
46
46
  case aria.EVENT_CODE.enter:
47
+ case aria.EVENT_CODE.numpadEnter:
47
48
  case aria.EVENT_CODE.space: {
48
49
  prevDef = true;
49
50
  event.currentTarget.click();
@@ -1 +1 @@
1
- {"version":3,"file":"menu-item.js","sources":["../../../../../../../packages/components/menu/src/utils/menu-item.ts"],"sourcesContent":["// @ts-nocheck\nimport { triggerEvent } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport SubMenu from './submenu'\n\nclass MenuItem {\n public submenu: SubMenu = null\n constructor(public domNode: HTMLElement, namespace: string) {\n this.submenu = null\n this.init(namespace)\n }\n\n init(namespace: string): void {\n this.domNode.setAttribute('tabindex', '0')\n const menuChild = this.domNode.querySelector(`.${namespace}-menu`)\n if (menuChild) {\n this.submenu = new SubMenu(this, menuChild)\n }\n this.addListeners()\n }\n\n addListeners(): void {\n this.domNode.addEventListener('keydown', (event: KeyboardEvent) => {\n let prevDef = false\n switch (event.code) {\n case EVENT_CODE.down: {\n triggerEvent(event.currentTarget as HTMLElement, 'mouseenter')\n this.submenu && this.submenu.gotoSubIndex(0)\n prevDef = true\n break\n }\n case EVENT_CODE.up: {\n triggerEvent(event.currentTarget as HTMLElement, 'mouseenter')\n this.submenu &&\n this.submenu.gotoSubIndex(this.submenu.subMenuItems.length - 1)\n prevDef = true\n break\n }\n case EVENT_CODE.tab: {\n triggerEvent(event.currentTarget as HTMLElement, 'mouseleave')\n break\n }\n case EVENT_CODE.enter:\n case EVENT_CODE.space: {\n prevDef = true\n ;(event.currentTarget as HTMLElement).click()\n break\n }\n }\n if (prevDef) {\n event.preventDefault()\n }\n })\n }\n}\n\nexport default MenuItem\n"],"names":["SubMenu","EVENT_CODE","triggerEvent"],"mappings":";;;;;;;;;;AAGA,MAAM,QAAQ,CAAC;AACf,EAAE,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE;AAClC,IAAI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3B,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACxB,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACxB,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACzB,GAAG;AACH,EAAE,IAAI,CAAC,SAAS,EAAE;AAClB,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AAC/C,IAAI,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,IAAI,IAAI,SAAS,EAAE;AACnB,MAAM,IAAI,CAAC,OAAO,GAAG,IAAIA,kBAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAClD,KAAK;AACL,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;AACxB,GAAG;AACH,EAAE,YAAY,GAAG;AACjB,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAK;AACxD,MAAM,IAAI,OAAO,GAAG,KAAK,CAAC;AAC1B,MAAM,QAAQ,KAAK,CAAC,IAAI;AACxB,QAAQ,KAAKC,eAAU,CAAC,IAAI,EAAE;AAC9B,UAAUC,mBAAY,CAAC,KAAK,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAC1D,UAAU,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AACvD,UAAU,OAAO,GAAG,IAAI,CAAC;AACzB,UAAU,MAAM;AAChB,SAAS;AACT,QAAQ,KAAKD,eAAU,CAAC,EAAE,EAAE;AAC5B,UAAUC,mBAAY,CAAC,KAAK,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAC1D,UAAU,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC1F,UAAU,OAAO,GAAG,IAAI,CAAC;AACzB,UAAU,MAAM;AAChB,SAAS;AACT,QAAQ,KAAKD,eAAU,CAAC,GAAG,EAAE;AAC7B,UAAUC,mBAAY,CAAC,KAAK,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAC1D,UAAU,MAAM;AAChB,SAAS;AACT,QAAQ,KAAKD,eAAU,CAAC,KAAK,CAAC;AAC9B,QAAQ,KAAKA,eAAU,CAAC,KAAK,EAAE;AAC/B,UAAU,OAAO,GAAG,IAAI,CAAC;AACzB,UAAU,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;AACtC,UAAU,MAAM;AAChB,SAAS;AACT,OAAO;AACP,MAAM,IAAI,OAAO,EAAE;AACnB,QAAQ,KAAK,CAAC,cAAc,EAAE,CAAC;AAC/B,OAAO;AACP,KAAK,CAAC,CAAC;AACP,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"menu-item.js","sources":["../../../../../../../packages/components/menu/src/utils/menu-item.ts"],"sourcesContent":["// @ts-nocheck\nimport { triggerEvent } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport SubMenu from './submenu'\n\nclass MenuItem {\n public submenu: SubMenu = null\n constructor(public domNode: HTMLElement, namespace: string) {\n this.submenu = null\n this.init(namespace)\n }\n\n init(namespace: string): void {\n this.domNode.setAttribute('tabindex', '0')\n const menuChild = this.domNode.querySelector(`.${namespace}-menu`)\n if (menuChild) {\n this.submenu = new SubMenu(this, menuChild)\n }\n this.addListeners()\n }\n\n addListeners(): void {\n this.domNode.addEventListener('keydown', (event: KeyboardEvent) => {\n let prevDef = false\n switch (event.code) {\n case EVENT_CODE.down: {\n triggerEvent(event.currentTarget as HTMLElement, 'mouseenter')\n this.submenu && this.submenu.gotoSubIndex(0)\n prevDef = true\n break\n }\n case EVENT_CODE.up: {\n triggerEvent(event.currentTarget as HTMLElement, 'mouseenter')\n this.submenu &&\n this.submenu.gotoSubIndex(this.submenu.subMenuItems.length - 1)\n prevDef = true\n break\n }\n case EVENT_CODE.tab: {\n triggerEvent(event.currentTarget as HTMLElement, 'mouseleave')\n break\n }\n case EVENT_CODE.enter:\n case EVENT_CODE.numpadEnter:\n case EVENT_CODE.space: {\n prevDef = true\n ;(event.currentTarget as HTMLElement).click()\n break\n }\n }\n if (prevDef) {\n event.preventDefault()\n }\n })\n }\n}\n\nexport default MenuItem\n"],"names":["SubMenu","EVENT_CODE","triggerEvent"],"mappings":";;;;;;;;;;AAGA,MAAM,QAAQ,CAAC;AACf,EAAE,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE;AAClC,IAAI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3B,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACxB,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACxB,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACzB,GAAG;AACH,EAAE,IAAI,CAAC,SAAS,EAAE;AAClB,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AAC/C,IAAI,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,IAAI,IAAI,SAAS,EAAE;AACnB,M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AC;AACzB,UAAU,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;AACtC,UAAU,MAAM;AAChB,SAAS;AACT,OAAO;AACP,MAAM,IAAI,OAAO,EAAE;AACnB,QAAQ,KAAK,CAAC,cAAc,EAAE,CAAC;AAC/B,OAAO;AACP,KAAK,CAAC,CAAC;AACP,GAAG;AACH;;;;"}
@@ -50,6 +50,7 @@ class SubMenu {
50
50
  break;
51
51
  }
52
52
  case aria.EVENT_CODE.enter:
53
+ case aria.EVENT_CODE.numpadEnter:
53
54
  case aria.EVENT_CODE.space: {
54
55
  prevDef = true;
55
56
  event.currentTarget.click();
@@ -1 +1 @@
1
- {"version":3,"file":"submenu.js","sources":["../../../../../../../packages/components/menu/src/utils/submenu.ts"],"sourcesContent":["// @ts-nocheck\nimport { triggerEvent } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport type MenuItem from './menu-item'\n\nclass SubMenu {\n public subMenuItems: NodeList\n public subIndex = 0\n constructor(public parent: MenuItem, public domNode: ParentNode) {\n this.subIndex = 0\n this.init()\n }\n\n init(): void {\n this.subMenuItems = this.domNode.querySelectorAll('li')\n this.addListeners()\n }\n\n gotoSubIndex(idx: number): void {\n if (idx === this.subMenuItems.length) {\n idx = 0\n } else if (idx < 0) {\n idx = this.subMenuItems.length - 1\n }\n ;(this.subMenuItems[idx] as HTMLElement).focus()\n this.subIndex = idx\n }\n\n addListeners(): void {\n const parentNode = this.parent.domNode\n Array.prototype.forEach.call(this.subMenuItems, (el: Element) => {\n el.addEventListener('keydown', (event: KeyboardEvent) => {\n let prevDef = false\n switch (event.code) {\n case EVENT_CODE.down: {\n this.gotoSubIndex(this.subIndex + 1)\n prevDef = true\n break\n }\n case EVENT_CODE.up: {\n this.gotoSubIndex(this.subIndex - 1)\n prevDef = true\n break\n }\n case EVENT_CODE.tab: {\n triggerEvent(parentNode as HTMLElement, 'mouseleave')\n break\n }\n case EVENT_CODE.enter:\n case EVENT_CODE.space: {\n prevDef = true\n ;(event.currentTarget as HTMLElement).click()\n break\n }\n }\n if (prevDef) {\n event.preventDefault()\n event.stopPropagation()\n }\n return false\n })\n })\n }\n}\n\nexport default SubMenu\n"],"names":["EVENT_CODE","triggerEvent"],"mappings":";;;;;;;;;AAEA,MAAM,OAAO,CAAC;AACd,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE;AAC/B,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACzB,IAAI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3B,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;AAChB,GAAG;AACH,EAAE,IAAI,GAAG;AACT,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAC5D,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;AACxB,GAAG;AACH,EAAE,YAAY,CAAC,GAAG,EAAE;AACpB,IAAI,IAAI,GAAG,KAAK,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;AAC1C,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,KAAK,MAAM,IAAI,GAAG,GAAG,CAAC,EAAE;AACxB,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,CAAC;AACL,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;AACnC,IAAI,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;AACxB,GAAG;AACH,EAAE,YAAY,GAAG;AACjB,IAAI,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;AAC3C,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,KAAK;AAC5D,MAAM,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAK;AAChD,QAAQ,IAAI,OAAO,GAAG,KAAK,CAAC;AAC5B,QAAQ,QAAQ,KAAK,CAAC,IAAI;AAC1B,UAAU,KAAKA,eAAU,CAAC,IAAI,EAAE;AAChC,YAAY,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;AACjD,YAAY,OAAO,GAAG,IAAI,CAAC;AAC3B,YAAY,MAAM;AAClB,WAAW;AACX,UAAU,KAAKA,eAAU,CAAC,EAAE,EAAE;AAC9B,YAAY,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;AACjD,YAAY,OAAO,GAAG,IAAI,CAAC;AAC3B,YAAY,MAAM;AAClB,WAAW;AACX,UAAU,KAAKA,eAAU,CAAC,GAAG,EAAE;AAC/B,YAAYC,mBAAY,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AACnD,YAAY,MAAM;AAClB,WAAW;AACX,UAAU,KAAKD,eAAU,CAAC,KAAK,CAAC;AAChC,UAAU,KAAKA,eAAU,CAAC,KAAK,EAAE;AACjC,YAAY,OAAO,GAAG,IAAI,CAAC;AAC3B,YAAY,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;AACxC,YAAY,MAAM;AAClB,WAAW;AACX,SAAS;AACT,QAAQ,IAAI,OAAO,EAAE;AACrB,UAAU,KAAK,CAAC,cAAc,EAAE,CAAC;AACjC,UAAU,KAAK,CAAC,eAAe,EAAE,CAAC;AAClC,SAAS;AACT,QAAQ,OAAO,KAAK,CAAC;AACrB,OAAO,CAAC,CAAC;AACT,KAAK,CAAC,CAAC;AACP,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"submenu.js","sources":["../../../../../../../packages/components/menu/src/utils/submenu.ts"],"sourcesContent":["// @ts-nocheck\nimport { triggerEvent } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport type MenuItem from './menu-item'\n\nclass SubMenu {\n public subMenuItems: NodeList\n public subIndex = 0\n constructor(public parent: MenuItem, public domNode: ParentNode) {\n this.subIndex = 0\n this.init()\n }\n\n init(): void {\n this.subMenuItems = this.domNode.querySelectorAll('li')\n this.addListeners()\n }\n\n gotoSubIndex(idx: number): void {\n if (idx === this.subMenuItems.length) {\n idx = 0\n } else if (idx < 0) {\n idx = this.subMenuItems.length - 1\n }\n ;(this.subMenuItems[idx] as HTMLElement).focus()\n this.subIndex = idx\n }\n\n addListeners(): void {\n const parentNode = this.parent.domNode\n Array.prototype.forEach.call(this.subMenuItems, (el: Element) => {\n el.addEventListener('keydown', (event: KeyboardEvent) => {\n let prevDef = false\n switch (event.code) {\n case EVENT_CODE.down: {\n this.gotoSubIndex(this.subIndex + 1)\n prevDef = true\n break\n }\n case EVENT_CODE.up: {\n this.gotoSubIndex(this.subIndex - 1)\n prevDef = true\n break\n }\n case EVENT_CODE.tab: {\n triggerEvent(parentNode as HTMLElement, 'mouseleave')\n break\n }\n case EVENT_CODE.enter:\n case EVENT_CODE.numpadEnter:\n case EVENT_CODE.space: {\n prevDef = true\n ;(event.currentTarget as HTMLElement).click()\n break\n }\n }\n if (prevDef) {\n event.preventDefault()\n event.stopPropagation()\n }\n return false\n })\n })\n }\n}\n\nexport default SubMenu\n"],"names":["EVENT_CODE","triggerEvent"],"mappings":";;;;;;;;;AAEA,MAAM,OAAO,CAAC;AACd,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE;AAC/B,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACzB,IAAI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3B,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;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